:root {
  --sidebar-bg: #1b2330;
  --sidebar-active: #2a3648;
  --accent: #2e86de;
  --bg: #f4f6f9;
}

body {
  background: var(--bg);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

/* --- App shell ------------------------------------------------------- */
.app-shell {
  display: flex;
  min-height: 100vh;
}

.app-sidebar {
  width: 230px;
  background: var(--sidebar-bg);
  color: #cfd8e3;
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
}

.sidebar-brand {
  padding: 16px 18px;
  font-size: 1.15rem;
  font-weight: 600;
  color: #fff;
  border-bottom: 1px solid rgba(255,255,255,0.08);
  display: flex;
  align-items: center;
}
.sidebar-brand i { margin-right: 8px; color: var(--accent); }
.sidebar-logo { height: 32px; width: auto; margin-right: 10px; flex-shrink: 0; }

.sidebar-nav {
  list-style: none;
  margin: 0;
  padding: 10px 0;
  flex: 1;
}
.sidebar-nav li a {
  display: block;
  padding: 11px 20px;
  color: #cfd8e3;
  text-decoration: none;
  font-size: 0.92rem;
}
.sidebar-nav li a i { width: 20px; margin-right: 10px; }
.sidebar-nav li a:hover { background: rgba(255,255,255,0.06); color: #fff; }
.sidebar-nav li.active a { background: var(--sidebar-active); color: #fff; border-left: 3px solid var(--accent); }

.sidebar-footer { padding: 16px 20px; border-top: 1px solid rgba(255,255,255,0.08); }

.app-main { flex: 1; display: flex; flex-direction: column; min-width: 0; }

.app-header {
  background: #fff;
  border-bottom: 1px solid #e3e7ed;
  padding: 16px 28px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.app-header h1 { font-size: 1.25rem; margin: 0; }

.app-content { padding: 24px 28px; flex: 1; }

/* --- Cards ------------------------------------------------------------- */
.card { border: 1px solid #e3e7ed; box-shadow: 0 1px 2px rgba(0,0,0,0.03); margin-bottom: 20px; }
.card-header { background: #fff; font-weight: 600; border-bottom: 1px solid #e3e7ed; }

/* --- Stat grid ----------------------------------------------------------- */
.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}
.stat-card {
  background: #fff;
  border: 1px solid #e3e7ed;
  border-radius: 6px;
  padding: 18px;
  text-align: center;
}
.stat-value { font-size: 1.9rem; font-weight: 700; }
.stat-label { color: #6c757d; font-size: 0.85rem; text-transform: uppercase; letter-spacing: .03em; }
.stat-open .stat-value { color: #2e86de; }
.stat-pending .stat-value { color: #e1b12c; }
.stat-closed .stat-value { color: #6c757d; }
.stat-urgent .stat-value { color: #e74c3c; }

/* --- Badges -------------------------------------------------------------- */
.badge-status-new { background: #6c757d; }
.badge-status-open { background: #2e86de; }
.badge-status-pending { background: #e1b12c; color: #222; }
.badge-status-closed { background: #16a34a; }

.badge-priority-P1 { background: #e74c3c; }
.badge-priority-P2 { background: #e67e22; }
.badge-priority-P3 { background: #2e86de; }
.badge-priority-P4 { background: #7f9cb5; }
.badge-priority-P5 { background: #9aa5b1; }

.badge, .role-badge {
  display: inline-block;
  padding: 3px 8px;
  border-radius: 4px;
  font-size: 0.72rem;
  color: #fff;
  text-transform: capitalize;
}
.role-badge.role-admin { background: #8e44ad; }
.role-badge.role-user { background: #2e86de; }
.role-badge.role-viewer { background: #6c757d; }
.role-badge.role-hr { background: #16a085; }
.role-badge.role-dtr-approver { background: #d35400; }

/* --- Comments -------------------------------------------------------- */
.comment { padding: 10px 0; border-bottom: 1px solid #eee; }
.comment:last-child { border-bottom: none; }
.comment-internal { background: #fff8e6; padding: 10px; border-radius: 4px; }
.comment-meta { margin-bottom: 4px; }

/* --- Login page -------------------------------------------------------- */
.login-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #1b2330, #2e86de);
}
.login-card {
  background: #fff;
  padding: 36px;
  border-radius: 8px;
  width: 100%;
  max-width: 440px;
  box-shadow: 0 10px 30px rgba(0,0,0,0.2);
}
.login-brand { text-align: center; margin-bottom: 20px; }
.login-brand i { font-size: 2.2rem; color: var(--accent); }
.login-logo { max-width: 240px; width: 100%; height: auto; margin-bottom: 4px; }
.login-brand h1 { font-size: 1.15rem; line-height: 1.35; margin: 8px 0 0; font-weight: 600; }

/* --- Chat --------------------------------------------------------------- */
/* .app-content has 24px vertical padding and .app-header is ~65px tall
   (16px*2 padding + ~1 line of text), so this heuristic keeps the whole
   two-pane layout filling the viewport without an outer page scrollbar. */
.chat-wrapper {
  display: flex;
  height: calc(100vh - 170px);
  min-height: 420px;
  border: 1px solid #e3e7ed;
  border-radius: 6px;
  background: #fff;
  overflow: hidden;
}

.chat-sidebar {
  width: 240px;
  flex-shrink: 0;
  border-right: 1px solid #e3e7ed;
  background: #f8f9fb;
  overflow-y: auto;
  padding: 12px 0;
}

.chat-sidebar-section { margin-bottom: 18px; }
.chat-sidebar-heading {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 4px 16px;
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: #6c757d;
}
.chat-add-btn {
  border: none;
  background: transparent;
  color: #6c757d;
  font-size: 1rem;
  line-height: 1;
  padding: 0 4px;
  cursor: pointer;
}
.chat-add-btn:hover { color: var(--accent); }

.chat-list { list-style: none; margin: 0; padding: 0; }
.chat-list li a {
  display: block;
  padding: 7px 16px;
  color: #333;
  text-decoration: none;
  font-size: 0.88rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.chat-list li a i { width: 16px; margin-right: 8px; color: #8a94a3; }
.chat-list li a:hover { background: #eef1f5; }
.chat-list li.active a { background: var(--sidebar-active); color: #fff; }
.chat-list li.active a i { color: #fff; }
.chat-dm-picker li a { display: flex; align-items: center; gap: 6px; }

.chat-main { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.chat-header { padding: 12px 20px; border-bottom: 1px solid #e3e7ed; }
.chat-header h2 { font-size: 1.05rem; margin: 0; }

.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 16px 20px;
}
.chat-empty { text-align: center; margin-top: 20px; }

.chat-message { display: flex; gap: 12px; margin-bottom: 14px; }
.chat-message-avatar {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: var(--accent);
  color: #fff;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
  font-size: 0.85rem;
}
.chat-message-body { min-width: 0; }
.chat-message-meta { font-size: 0.85rem; margin-bottom: 2px; }
.chat-message-meta span { font-size: 0.75rem; margin-left: 4px; }
.chat-message-text { font-size: 0.92rem; white-space: pre-wrap; word-break: break-word; }

.chat-input-row {
  display: flex;
  gap: 10px;
  padding: 12px 20px;
  border-top: 1px solid #e3e7ed;
}
.chat-input-row input { flex: 1; }

/* --- DTR ------------------------------------------------------------ */
.dtr-badge-draft { background: #6c757d; }
.dtr-badge-submitted { background: #e1b12c; color: #222; }
.dtr-badge-approved { background: #16a34a; }
.dtr-badge-rejected { background: #e74c3c; }

.dtr-table th, .dtr-table td { vertical-align: middle; font-size: 0.85rem; }
.dtr-table input.form-control-sm { min-width: 90px; }
.dtr-table td:last-child { min-width: unset; }

.comment-approved { border-left: 3px solid #16a34a; padding-left: 10px; }
.comment-rejected { border-left: 3px solid #e74c3c; padding-left: 10px; }
