/* ============================================================
   D2C OPs – Main Stylesheet
   Brand colors preserved exactly as specified.
   ============================================================ */

/* ── CSS Custom Properties ────────────────────────────────── */
:root {
  --navy:         #042C53;
  --navy-mid:     #185FA5;
  --navy-light:   #1E3A5F;
  --teal:         #0F6E56;
  --teal-hover:   #1D9E75;
  --teal-bg:      #E1F5EE;
  --amber:        #BA7517;
  --danger:       #A32D2D;
  --page-bg:      #F1EFE8;
  --white:        #FFFFFF;
  --border:       #DDD9D0;
  --border-light: #EDEAE3;
  --text-dark:    #1A1A2E;
  --text-mid:     #444444;
  --text-muted:   #888888;
  --shadow-xs:    0 1px 2px rgba(0,0,0,.06);
  --shadow-sm:    0 1px 4px rgba(0,0,0,.08);
  --shadow-md:    0 2px 12px rgba(0,0,0,.10);
  --shadow-lg:    0 4px 24px rgba(0,0,0,.12);
  --radius-sm:    4px;
  --radius-md:    8px;
  --radius-lg:    12px;
  --radius-xl:    16px;
  --sidebar-w:    240px;
  --sidebar-collapsed: 64px;
  --header-h:     56px;
  --transition:   0.2s ease;
  --bg-subtle:         #f8f8f6;
  --card-selected-bg:  rgba(0,0,0,.06);
}

[data-theme="dark"] {
  --page-bg:      #0F1117;
  --white:        #1A1D24;
  --border:       #2D3142;
  --border-light: #232636;
  --text-dark:    #E8EAF0;
  --text-mid:     #B0B7C3;
  --text-muted:   #9CA3AF;
  --shadow-sm:    0 1px 4px rgba(0,0,0,.30);
  --shadow-md:    0 2px 12px rgba(0,0,0,.40);
  --shadow-lg:    0 4px 24px rgba(0,0,0,.50);
  --teal-bg:      rgba(15,110,86,.15);
  /* Override navy colours so every inline color:var(--navy) is readable */
  --navy:         #5B9BD5;
  --navy-mid:     #60A5FA;
  --navy-light:   #3B82F6;
  --bg-subtle:         #15181F;
  --card-selected-bg:  rgba(255,255,255,.08);
}

/* ── Reset ────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; }

html { font-size: 15px; scroll-behavior: smooth; }

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  font-size: 1rem;
  line-height: 1.6;
  color: var(--text-dark);
  background: var(--page-bg);
}

a { color: var(--teal); text-decoration: none; }
a:hover { color: var(--teal-hover); }

img { max-width: 100%; }

h1,h2,h3,h4,h5,h6 {
  margin: 0 0 .75rem;
  font-weight: 600;
  line-height: 1.3;
  color: var(--text-dark);
}

p { margin: 0 0 1rem; }

ul, ol { margin: 0; padding: 0 0 0 1.25rem; }

/* ── Auth Layout ──────────────────────────────────────────── */
.auth-body {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px 16px;
  background: var(--page-bg);
}

.auth-wrapper {
  width: 100%;
  max-width: 420px;
}

.auth-brand {
  text-align: center;
  margin-bottom: 28px;
}

.auth-logo {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 26px;
  font-weight: 800;
  letter-spacing: 0.5px;
}

.auth-logo-img {
  height: 64px;
  width: auto;
  object-fit: contain;
  border-radius: 6px;
}

.logo-d2c     { color: var(--navy); }
.logo-telcare { color: var(--teal); }

.auth-tagline {
  color: var(--text-muted);
  font-size: .8rem;
  margin: 4px 0 0;
  letter-spacing: .5px;
  text-transform: uppercase;
}

.auth-card {
  background: var(--white);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  overflow: hidden;
  border: 1px solid var(--border);
}

.auth-card-header {
  background: var(--navy);
  padding: 24px 28px 20px;
}

.auth-card-header h2 {
  color: #fff;
  margin: 0 0 4px;
  font-size: 1.2rem;
  font-weight: 600;
}

.auth-card-header p {
  color: rgba(255,255,255,.6);
  font-size: .82rem;
  margin: 0;
}

.auth-card-body {
  padding: 28px;
}

.auth-footer-link {
  text-align: center;
  margin-top: 20px;
  font-size: .85rem;
  color: var(--text-muted);
}

.auth-footer-link a {
  color: var(--teal);
  font-weight: 500;
}

/* ── Alerts ───────────────────────────────────────────────── */
.alert {
  padding: 10px 14px;
  border-radius: var(--radius-md);
  font-size: .875rem;
  margin-bottom: 16px;
  display: flex;
  align-items: flex-start;
  gap: 8px;
  line-height: 1.5;
}

.alert-danger  { background: #FEF2F2; color: #991B1B; border: 1px solid #FECACA; }
.alert-success { background: #F0FDF4; color: #166534; border: 1px solid #BBF7D0; }
.alert-info    { background: #EFF6FF; color: #1E40AF; border: 1px solid #BFDBFE; }
.alert-warning { background: #FFFBEB; color: #92400E; border: 1px solid #FDE68A; }
.alert-debug   { background: #FFF7ED; color: #9A3412; border: 2px dashed #FDBA74; font-family: monospace; }

/* ── Form Controls ────────────────────────────────────────── */
.form-group {
  margin-bottom: 18px;
}

.form-label {
  display: block;
  font-size: .82rem;
  font-weight: 500;
  color: var(--text-mid);
  margin-bottom: 6px;
  letter-spacing: .2px;
}

.form-control {
  display: block;
  width: 100%;
  padding: 9px 12px;
  font-size: .9rem;
  line-height: 1.5;
  color: var(--text-dark);
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  outline: none;
  transition: border-color var(--transition), box-shadow var(--transition);
  font-family: inherit;
}

.form-control:focus {
  border-color: var(--teal);
  box-shadow: 0 0 0 3px rgba(15,110,86,.12);
}

.form-control::placeholder { color: var(--text-muted); }

.form-control:disabled,
.form-control[readonly] {
  background: var(--page-bg);
  cursor: not-allowed;
  opacity: .75;
}

select.form-control {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' fill='none'%3E%3Cpath d='M1 1l5 5 5-5' stroke='%23888' stroke-width='1.5' stroke-linecap='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 36px;
}

textarea.form-control { resize: vertical; min-height: 90px; }

.input-wrapper {
  position: relative;
}

.input-icon-btn {
  position: absolute;
  right: 10px;
  top: 50%;
  transform: translateY(-50%);
  background: none;
  border: none;
  cursor: pointer;
  color: var(--text-muted);
  padding: 4px;
  line-height: 1;
}

.input-icon-btn:hover { color: var(--teal); }

.form-hint {
  font-size: .78rem;
  color: var(--text-muted);
  margin-top: 4px;
}

.form-error {
  font-size: .78rem;
  color: var(--danger);
  margin-top: 4px;
}

/* ── Buttons ──────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 9px 18px;
  font-size: .875rem;
  font-weight: 500;
  line-height: 1;
  border-radius: var(--radius-md);
  border: 1px solid transparent;
  cursor: pointer;
  transition: background var(--transition), color var(--transition), border-color var(--transition), box-shadow var(--transition);
  white-space: nowrap;
  text-decoration: none;
  font-family: inherit;
}

.btn:disabled { opacity: .6; cursor: not-allowed; }

.btn-block { width: 100%; }

.btn-sm  { padding: 6px 12px; font-size: .8rem; }
.btn-xs  { padding: 3px 9px;  font-size: .72rem; border-radius: 5px; }
.btn-lg  { padding: 12px 24px; font-size: 1rem; }

.btn-primary {
  background: var(--teal);
  color: #fff;
  border-color: var(--teal);
}
.btn-primary:hover {
  background: var(--teal-hover);
  border-color: var(--teal-hover);
  color: #fff;
}

.btn-secondary {
  background: var(--white);
  color: var(--text-mid);
  border-color: var(--border);
}
.btn-secondary:hover {
  background: var(--page-bg);
  border-color: var(--text-muted);
}

.btn-navy {
  background: var(--navy);
  color: #fff;
  border-color: var(--navy);
}
.btn-navy:hover {
  background: var(--navy-light);
  border-color: var(--navy-light);
  color: #fff;
}

.btn-danger {
  background: var(--danger);
  color: #fff;
  border-color: var(--danger);
}
.btn-danger:hover {
  background: #8B2323;
  border-color: #8B2323;
  color: #fff;
}

.btn-ghost {
  background: transparent;
  color: var(--teal);
  border-color: transparent;
}
.btn-ghost:hover {
  background: var(--teal-bg);
}

.btn-link {
  background: none;
  border: none;
  color: var(--teal);
  padding: 0;
  font-size: inherit;
  cursor: pointer;
  text-decoration: underline;
}
.btn-link:hover { color: var(--teal-hover); }

/* ── Badges ───────────────────────────────────────────────── */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 8px;
  font-size: .72rem;
  font-weight: 600;
  border-radius: 999px;
  letter-spacing: .3px;
  white-space: nowrap;
}

.badge-success   { background: #DCFCE7; color: #15803D; }
.badge-danger    { background: #FEE2E2; color: #B91C1C; }
.badge-warning   { background: #FEF3C7; color: #B45309; }
.badge-primary   { background: var(--teal-bg); color: var(--teal); }
.badge-info      { background: #DBEAFE; color: #1D4ED8; }
.badge-secondary { background: #F3F4F6; color: #6B7280; }
.badge-navy      { background: rgba(4,44,83,.1); color: var(--navy); }
.badge-teal      { background: var(--teal-bg); color: var(--teal-hover); }

/* Severity badges */
.badge-sev1 { background: #FEE2E2; color: #991B1B; }
.badge-sev2 { background: #FFF7ED; color: #9A3412; }
.badge-sev3 { background: #FEF3C7; color: #B45309; }
.badge-sev4 { background: #F0FDF4; color: #166534; }

/* ── OTP Input ────────────────────────────────────────────── */
.otp-inputs {
  display: flex;
  gap: 8px;
  justify-content: center;
  margin: 8px 0;
}

.otp-input {
  width: 48px;
  height: 56px;
  text-align: center;
  font-size: 1.4rem;
  font-weight: 700;
  border: 2px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--white);
  color: var(--navy);
  outline: none;
  transition: border-color var(--transition), box-shadow var(--transition);
  caret-color: var(--teal);
}

.otp-input:focus {
  border-color: var(--teal);
  box-shadow: 0 0 0 3px rgba(15,110,86,.15);
}

.otp-input.filled {
  border-color: var(--teal);
  background: var(--teal-bg);
}

/* ── Divider ──────────────────────────────────────────────── */
.divider {
  display: flex;
  align-items: center;
  gap: 12px;
  color: var(--text-muted);
  font-size: .8rem;
  margin: 16px 0;
}
.divider::before,
.divider::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--border);
}

/* ── Utilities ────────────────────────────────────────────── */
.text-center  { text-align: center; }
.text-right   { text-align: right; }
.text-muted   { color: var(--text-muted); }
.text-danger  { color: var(--danger); }
.text-success { color: var(--teal); }
.text-navy    { color: var(--navy); }
.text-sm      { font-size: .8rem; }
.text-xs      { font-size: .72rem; }

.mt-1 { margin-top: .25rem; }
.mt-2 { margin-top: .5rem; }
.mt-3 { margin-top: 1rem; }
.mt-4 { margin-top: 1.5rem; }
.mb-0 { margin-bottom: 0; }
.mb-1 { margin-bottom: .25rem; }
.mb-2 { margin-bottom: .5rem; }
.mb-3 { margin-bottom: 1rem; }
.ms-auto { margin-left: auto; }

.d-flex         { display: flex; }
.align-center   { align-items: center; }
.justify-between{ justify-content: space-between; }
.gap-2          { gap: .5rem; }
.gap-3          { gap: 1rem; }
.flex-1         { flex: 1; }

.fw-600 { font-weight: 600; }
.fw-700 { font-weight: 700; }

/* ── Responsive (auth) ────────────────────────────────────── */
@media (max-width: 480px) {
  .auth-card-body { padding: 20px 16px; }
  .otp-input { width: 40px; height: 48px; font-size: 1.2rem; }
}

/* ============================================================
   LAYOUT SYSTEM — Sidebar + Header + Main
   ============================================================ */

/* ── App shell ────────────────────────────────────────────── */
.app-body {
  display: flex;
  min-height: 100vh;
  background: var(--page-bg);
}

/* ── Sidebar ──────────────────────────────────────────────── */
.sidebar {
  width: var(--sidebar-w);
  min-height: 100vh;
  background: var(--navy);
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  z-index: 200;
  display: flex;
  flex-direction: column;
  transition: width .22s cubic-bezier(.4,0,.2,1);
  overflow: hidden;
}

.sidebar.collapsed { width: var(--sidebar-collapsed); }

/* Brand */
.sidebar-brand {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 12px 0 16px;
  height: var(--header-h);
  border-bottom: 1px solid rgba(255,255,255,.07);
  flex-shrink: 0;
}

.sidebar-logo-link {
  display: flex;
  align-items: center;
  gap: 6px;
  text-decoration: none;
  min-width: 0;
  overflow: hidden;
}

.sidebar-logo-img {
  height: 44px;
  width: auto;
  max-width: 180px;
  object-fit: contain;
  border-radius: 4px;
  flex-shrink: 0;
}

.sidebar.collapsed .sidebar-logo-img { display: none; }

.sidebar-collapse-btn {
  width: 28px;
  height: 28px;
  border: none;
  background: rgba(255,255,255,.08);
  border-radius: 6px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  color: rgba(255,255,255,.6);
  flex-shrink: 0;
  transition: background var(--transition), transform .22s;
}

.sidebar-collapse-btn:hover { background: rgba(255,255,255,.15); color: #fff; }
.sidebar.collapsed .sidebar-collapse-btn { transform: rotate(180deg); }

/* Process badge */
.sidebar-process {
  padding: 10px 12px;
  border-bottom: 1px solid rgba(255,255,255,.07);
  flex-shrink: 0;
  overflow: hidden;
}

.process-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: rgba(255,255,255,.1);
  color: rgba(255,255,255,.85);
  font-size: .72rem;
  font-weight: 600;
  padding: 4px 10px;
  border-radius: 999px;
  letter-spacing: .3px;
  white-space: nowrap;
  text-transform: uppercase;
}

.process-chip::before {
  content: '';
  width: 6px;
  height: 6px;
  background: var(--teal-hover);
  border-radius: 50%;
  flex-shrink: 0;
}

.process-chip-admin::before { background: var(--amber); }

/* Nav */
.sidebar-nav {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 8px 0 16px;
  scrollbar-width: thin;
  scrollbar-color: rgba(255,255,255,.1) transparent;
}

.sidebar-nav::-webkit-scrollbar { width: 3px; }
.sidebar-nav::-webkit-scrollbar-thumb { background: rgba(255,255,255,.15); border-radius: 3px; }

.nav-group { margin-bottom: 4px; }

.nav-group-label {
  display: block;
  font-size: .62rem;
  text-transform: uppercase;
  letter-spacing: 1.2px;
  color: rgba(255,255,255,.3);
  padding: 12px 20px 4px;
  white-space: nowrap;
  overflow: hidden;
  transition: opacity .15s;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px 8px 16px;
  margin: 1px 8px;
  color: rgba(255,255,255,.65);
  font-size: .845rem;
  font-weight: 450;
  border-radius: 7px;
  text-decoration: none;
  transition: background var(--transition), color var(--transition);
  white-space: nowrap;
  overflow: hidden;
  position: relative;
}

.nav-item svg { flex-shrink: 0; }

.nav-item:hover {
  color: #fff;
  background: rgba(255,255,255,.09);
  text-decoration: none;
}

.nav-item.active {
  color: #fff;
  background: var(--teal);
  font-weight: 500;
}

.nav-item.active:hover { background: var(--teal-hover); }

.nav-label {
  transition: opacity .15s;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Count badge on a nav item (e.g. pending approvals awaiting a decision) */
.nav-badge {
  margin-left: auto;
  flex-shrink: 0;
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  border-radius: 9px;
  background: var(--danger);
  color: #fff;
  font-size: .68rem;
  font-weight: 700;
  line-height: 18px;
  text-align: center;
  font-variant-numeric: tabular-nums;
}

/* Collapsed sidebar: the number would not fit, so show a marker dot instead */
.sidebar.collapsed .nav-badge {
  position: absolute;
  top: 5px;
  right: 5px;
  min-width: 8px;
  width: 8px;
  height: 8px;
  padding: 0;
  border-radius: 50%;
  font-size: 0;
  line-height: 0;
  overflow: hidden;
}

/* Collapsed state — hide text, center icons */
.sidebar.collapsed .nav-group-label,
.sidebar.collapsed .sidebar-brand-text,
.sidebar.collapsed .sidebar-process,
.sidebar.collapsed .nav-label,
.sidebar.collapsed .sidebar-user-info {
  opacity: 0;
  width: 0;
  overflow: hidden;
}

.sidebar.collapsed .nav-item {
  justify-content: center;
  padding: 10px;
  margin: 2px 6px;
}

.sidebar.collapsed .nav-group { margin-bottom: 0; }

.sidebar.collapsed .nav-group-label { display: none; }

.sidebar.collapsed .sidebar-signout-form { display: none; }

/* Sidebar footer */
.sidebar-footer {
  padding: 12px;
  border-top: 1px solid rgba(255,255,255,.07);
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.sidebar-footer .sidebar-user {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.sidebar-signout-form { margin: 0; }

.sidebar-signout-btn {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 8px 16px;
  border: 1.5px solid rgba(255,255,255,.22);
  border-radius: 50px;
  background: transparent;
  color: rgba(255,255,255,.7);
  font-size: .8rem;
  font-weight: 500;
  cursor: pointer;
  transition: background .15s, color .15s, border-color .15s;
}

.sidebar-signout-btn:hover {
  background: rgba(255,255,255,.08);
  color: #ef4444;
  border-color: rgba(239,68,68,.45);
}

.sidebar-user {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 4px;
  overflow: hidden;
}

.user-avatar {
  width: 32px;
  height: 32px;
  min-width: 32px;
  border-radius: 8px;
  background: var(--navy-mid);
  color: #fff;
  font-size: .72rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  letter-spacing: .5px;
}

.user-avatar.xs { width: 22px; height: 22px; min-width: 22px; font-size: .55rem; border-radius: 5px; }
.user-avatar.sm { width: 28px; height: 28px; min-width: 28px; font-size: .65rem; border-radius: 6px; }
.user-avatar.md { width: 40px; height: 40px; min-width: 40px; font-size: .85rem; border-radius: 10px; }
.user-avatar.lg { width: 56px; height: 56px; min-width: 56px; font-size: 1.1rem; border-radius: 12px; }
.user-avatar.xl { width: 72px; height: 72px; min-width: 72px; font-size: 1.4rem; border-radius: 16px; }

/* Avatar colours by role */
.avatar-super_admin { background: var(--teal); }
.avatar-admin       { background: var(--navy-mid); }
.avatar-manager     { background: #5B6DA0; }
.avatar-operator    { background: #6B7280; }
.avatar-viewer      { background: #9CA3AF; }
.avatar-client      { background: var(--amber); }
.avatar-agent       { background: #B91C1C; }

.sidebar-user-info {
  min-width: 0;
  overflow: hidden;
  transition: opacity .15s;
}

.sidebar-user-name {
  display: block;
  font-size: .8rem;
  font-weight: 600;
  color: #fff;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.sidebar-user-role {
  display: block;
  font-size: .68rem;
  color: rgba(255,255,255,.45);
  white-space: nowrap;
}

/* Mobile overlay */
.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.5);
  z-index: 199;
}

.sidebar-overlay.active { display: block; }

/* ── Main wrapper ─────────────────────────────────────────── */
.main-wrapper {
  margin-left: var(--sidebar-w);
  flex: 1;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  transition: margin-left .22s cubic-bezier(.4,0,.2,1);
  min-width: 0;
}

.main-wrapper.sidebar-collapsed { margin-left: var(--sidebar-collapsed); }

/* ── Top header ───────────────────────────────────────────── */
.top-header {
  height: var(--header-h);
  background: var(--white);
  border-bottom: 1px solid var(--border-light);
  position: sticky;
  top: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  padding: 0 20px 0 24px;
  gap: 12px;
  box-shadow: var(--shadow-xs);
  flex-shrink: 0;
}

.header-left {
  display: flex;
  align-items: center;
  gap: 12px;
  flex: 1;
  min-width: 0;
}

.header-right {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
}

.mobile-menu-btn {
  display: none;
  width: 36px;
  height: 36px;
  border: none;
  background: none;
  cursor: pointer;
  color: var(--text-mid);
  border-radius: 6px;
  align-items: center;
  justify-content: center;
}

.mobile-menu-btn:hover { background: var(--page-bg); }

.page-title {
  font-size: 1rem;
  font-weight: 600;
  color: var(--navy);
  margin: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Live indicator */
.live-indicator {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: .72rem;
  font-weight: 600;
  color: var(--text-muted);
  letter-spacing: .3px;
}

.live-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--teal-hover);
  box-shadow: 0 0 0 2px rgba(29,158,117,.25);
  animation: livePulse 2s infinite;
}

@keyframes livePulse {
  0%, 100% { box-shadow: 0 0 0 2px rgba(29,158,117,.25); }
  50%       { box-shadow: 0 0 0 5px rgba(29,158,117,.1); }
}

@keyframes pulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50%       { opacity: .5; transform: scale(1.4); }
}

/* Header icon buttons */
.icon-btn {
  width: 36px;
  height: 36px;
  border: none;
  background: none;
  cursor: pointer;
  color: var(--text-muted);
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  transition: background var(--transition), color var(--transition);
}

.icon-btn:hover {
  background: var(--page-bg);
  color: var(--text-dark);
}

/* Profile dropdown */
.profile-dropdown { position: relative; }

.profile-btn {
  display: flex;
  align-items: center;
  gap: 8px;
  border: none;
  background: none;
  cursor: pointer;
  padding: 4px 8px 4px 4px;
  border-radius: 8px;
  transition: background var(--transition);
}

.profile-btn:hover { background: var(--page-bg); }

.profile-btn-name {
  font-size: .82rem;
  font-weight: 500;
  color: var(--text-dark);
  max-width: 120px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.dropdown-menu {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  min-width: 180px;
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-md);
  padding: 6px;
  z-index: 300;
  display: none;
}

.dropdown-menu.open { display: block; }

.dropdown-menu a,
.dropdown-menu button {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  padding: 8px 10px;
  border-radius: 6px;
  font-size: .845rem;
  color: var(--text-mid);
  text-decoration: none;
  background: none;
  border: none;
  cursor: pointer;
  font-family: inherit;
  text-align: left;
  transition: background var(--transition);
}

.dropdown-menu a:hover,
.dropdown-menu button:hover {
  background: var(--page-bg);
  color: var(--text-dark);
}

.dropdown-menu hr {
  border: none;
  border-top: 1px solid var(--border-light);
  margin: 4px 0;
}

.dropdown-menu .item-danger { color: var(--danger); }
.dropdown-menu .item-danger:hover { background: #FEF2F2; }

/* ── Main content ─────────────────────────────────────────── */
.main-content {
  flex: 1;
  padding: 24px;
}

/* ── Page header ──────────────────────────────────────────── */
.page-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 20px;
  flex-wrap: wrap;
}

.page-header-title h2 {
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--text-dark);
  margin: 0 0 2px;
}

.page-header-title p {
  font-size: .82rem;
  color: var(--text-muted);
  margin: 0;
}

.page-header-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

/* ── Cards ────────────────────────────────────────────────── */
.card {
  background: var(--white);
  border-radius: var(--radius-lg);
  border: 1px solid var(--border-light);
  box-shadow: var(--shadow-sm);
}

.card-header {
  padding: 14px 20px;
  border-bottom: 1px solid var(--border-light);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}

.card-header-title {
  font-size: .92rem;
  font-weight: 600;
  color: var(--text-dark);
  margin: 0;
  display: flex;
  align-items: center;
  gap: 8px;
}

.card-body  { padding: 20px; }
.card-body-sm { padding: 12px 16px; }

.card-footer {
  padding: 12px 20px;
  border-top: 1px solid var(--border-light);
  background: var(--page-bg);
  border-radius: 0 0 var(--radius-lg) var(--radius-lg);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

/* ── Stat cards ───────────────────────────────────────────── */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}

.stat-card {
  background: var(--white);
  border-radius: var(--radius-lg);
  border: 1px solid var(--border-light);
  box-shadow: var(--shadow-sm);
  padding: 18px 20px;
  display: flex;
  align-items: flex-start;
  gap: 14px;
  position: relative;
  overflow: hidden;
}

.stat-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  background: var(--stat-accent, var(--teal));
}

.stat-card-danger  { --stat-accent: var(--danger); }
.stat-card-warning { --stat-accent: var(--amber); }
.stat-card-info    { --stat-accent: var(--navy-mid); }
.stat-card-success { --stat-accent: var(--teal); }

.stat-icon {
  width: 40px;
  height: 40px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--stat-icon-bg, var(--teal-bg));
  color: var(--stat-icon-color, var(--teal));
  flex-shrink: 0;
}

.stat-icon-danger  { --stat-icon-bg: #FEE2E2; --stat-icon-color: var(--danger); }
.stat-icon-warning { --stat-icon-bg: #FEF3C7; --stat-icon-color: var(--amber); }
.stat-icon-info    { --stat-icon-bg: #DBEAFE; --stat-icon-color: var(--navy-mid); }

.stat-body { flex: 1; min-width: 0; }

.stat-value {
  font-size: 1.75rem;
  font-weight: 700;
  color: var(--text-dark);
  line-height: 1;
  margin-bottom: 4px;
}

.stat-label {
  font-size: .78rem;
  color: var(--text-muted);
  font-weight: 500;
  letter-spacing: .2px;
}

.stat-sub {
  font-size: .73rem;
  color: var(--text-muted);
  margin-top: 6px;
}

/* Shorthand accent aliases */
.stat-danger  { --stat-accent: var(--danger); }
.stat-warning { --stat-accent: var(--amber); }
.stat-primary { --stat-accent: var(--navy-mid); }
.stat-navy    { --stat-accent: var(--navy); }
.stat-teal    { --stat-accent: var(--teal); }

/* ── Tables ───────────────────────────────────────────────── */
.table-wrapper {
  overflow-x: auto;
  border-radius: var(--radius-lg);
  border: 1px solid var(--border-light);
  box-shadow: var(--shadow-sm);
}

.table {
  width: 100%;
  border-collapse: collapse;
  font-size: .855rem;
  background: var(--white);
}

.table thead th {
  background: var(--page-bg);
  color: var(--text-muted);
  font-size: .72rem;
  text-transform: uppercase;
  letter-spacing: .6px;
  font-weight: 600;
  padding: 10px 16px;
  text-align: left;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

.table tbody td {
  padding: 12px 16px;
  border-bottom: 1px solid var(--border-light);
  color: var(--text-mid);
  vertical-align: middle;
}

.table tbody tr:last-child td { border-bottom: none; }

.table tbody tr:hover td { background: rgba(15,110,86,.03); }

.table-link { color: var(--navy); font-weight: 500; }
.table-link:hover { color: var(--teal); }

.table-muted { color: var(--text-muted); font-size: .8rem; }

/* ── Modals ───────────────────────────────────────────────── */
.modal {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 500;
}

.modal.open { display: flex; align-items: center; justify-content: center; }

.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0,0,0,.45);
  backdrop-filter: blur(2px);
}

.modal-box {
  position: relative;
  z-index: 1;
  background: var(--white);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-lg);
  width: 100%;
  max-width: 480px;
  margin: 16px;
  animation: modalIn .18s ease;
}

.modal-box-lg { max-width: 680px; }
.modal-box-xl { max-width: 860px; }

@keyframes modalIn {
  from { opacity: 0; transform: translateY(-12px) scale(.97); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 22px 16px;
  border-bottom: 1px solid var(--border-light);
}

.modal-title {
  font-size: 1rem;
  font-weight: 600;
  color: var(--text-dark);
  margin: 0;
}

.modal-close {
  width: 30px;
  height: 30px;
  border: none;
  background: none;
  cursor: pointer;
  color: var(--text-muted);
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background var(--transition);
}

.modal-close:hover { background: var(--page-bg); color: var(--text-dark); }

.modal-body   { padding: 22px; }
.modal-footer {
  padding: 14px 22px;
  border-top: 1px solid var(--border-light);
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}

body.modal-open { overflow: hidden; }

/* ── Empty state ──────────────────────────────────────────── */
.empty-state {
  text-align: center;
  padding: 48px 24px;
}

.empty-state-icon {
  width: 56px;
  height: 56px;
  border-radius: 14px;
  background: var(--page-bg);
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto 16px;
  color: var(--text-muted);
}

.empty-state-title {
  font-size: 1rem;
  font-weight: 600;
  color: var(--text-dark);
  margin-bottom: 6px;
}

.empty-state-msg {
  font-size: .855rem;
  color: var(--text-muted);
  margin-bottom: 20px;
  max-width: 360px;
  margin-left: auto;
  margin-right: auto;
}

/* ── Pagination ───────────────────────────────────────────── */
.pagination {
  display: flex;
  align-items: center;
  gap: 4px;
}

.page-btn {
  min-width: 32px;
  height: 32px;
  padding: 0 8px;
  border: 1px solid var(--border);
  background: var(--white);
  color: var(--text-mid);
  border-radius: 6px;
  font-size: .8rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  text-decoration: none;
  transition: all var(--transition);
}

.page-btn:hover    { border-color: var(--teal); color: var(--teal); }
.page-btn.active   { background: var(--teal); border-color: var(--teal); color: #fff; font-weight: 600; }
.page-btn.disabled { opacity: .4; cursor: not-allowed; pointer-events: none; }
.page-btn.ellipsis { border: none; background: none; cursor: default; pointer-events: none; color: var(--text-muted); }

.page-info {
  margin-left: 10px;
  font-size: .76rem;
  color: var(--text-muted);
}

/* ── Breadcrumb ───────────────────────────────────────────── */
.breadcrumb {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: .78rem;
  color: var(--text-muted);
  margin-bottom: 16px;
  flex-wrap: wrap;
}

.breadcrumb a {
  color: var(--text-muted);
  text-decoration: none;
}

.breadcrumb a:hover { color: var(--teal); }

.breadcrumb-sep {
  color: var(--border);
  font-size: .65rem;
}

.breadcrumb-current { color: var(--text-dark); font-weight: 500; }

/* ── Grid layout ──────────────────────────────────────────── */
.grid    { display: grid; gap: 20px; }
.grid-2  { grid-template-columns: repeat(2, 1fr); }
.grid-3  { grid-template-columns: repeat(3, 1fr); }
.grid-4  { grid-template-columns: repeat(4, 1fr); }
.grid-auto { grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); }

/* ── Separator ────────────────────────────────────────────── */
.section-sep { margin: 24px 0; border: none; border-top: 1px solid var(--border-light); }

/* ── Status and severity dot ──────────────────────────────── */
.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  display: inline-block;
  flex-shrink: 0;
}

.dot-success { background: var(--teal-hover); }
.dot-danger  { background: var(--danger); }
.dot-warning { background: var(--amber); }
.dot-info    { background: var(--navy-mid); }
.dot-muted   { background: var(--text-muted); }

/* ── Timeline (for incident history) ─────────────────────── */
.timeline { list-style: none; padding: 0; margin: 0; }

.timeline-item {
  display: flex;
  gap: 12px;
  padding-bottom: 20px;
  position: relative;
}

.timeline-item:not(:last-child)::before {
  content: '';
  position: absolute;
  left: 15px;
  top: 28px;
  bottom: 0;
  width: 1px;
  background: var(--border-light);
}

.timeline-dot {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: var(--page-bg);
  border: 2px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  color: var(--text-muted);
  margin-top: 2px;
}

.timeline-dot.active { border-color: var(--teal); background: var(--teal-bg); color: var(--teal); }

.timeline-content { flex: 1; min-width: 0; }
.timeline-meta { font-size: .75rem; color: var(--text-muted); margin-top: 2px; }

/* ── Dark mode overrides (layout) ─────────────────────────── */
[data-theme="dark"] .top-header {
  background: #1A1D24;
  border-color: #2D3142;
}

/* ── Dark mode: re-pin backgrounds that must stay dark ────── */
/* sidebar already re-pinned above; fix auth header + buttons */
[data-theme="dark"] .auth-card-header { background: #042C53; }
[data-theme="dark"] .btn-navy         { background: #1D4ED8; border-color: #1D4ED8; }
[data-theme="dark"] .btn-navy:hover   { background: #1E40AF; border-color: #1E40AF; }
[data-theme="dark"] .badge-navy       { background: rgba(96,165,250,.15); }

/* ── Dark mode: force all headings to light colour ─────────── */
[data-theme="dark"] h1, [data-theme="dark"] h2,
[data-theme="dark"] h3, [data-theme="dark"] h4,
[data-theme="dark"] h5, [data-theme="dark"] h6 { color: #E8EAF0; }
[data-theme="dark"] .page-title         { color: #E8EAF0; }
[data-theme="dark"] .breadcrumb-current { color: #E8EAF0; }
[data-theme="dark"] .card-title         { color: #E8EAF0; }

[data-theme="dark"] .sidebar { background: #0D1117; }
[data-theme="dark"] .process-chip { background: rgba(255,255,255,.08); }
[data-theme="dark"] .card { background: #1A1D24; border-color: #2D3142; }
[data-theme="dark"] .card-header { border-color: #2D3142; }
[data-theme="dark"] .card-footer { background: #15181F; border-color: #2D3142; }
[data-theme="dark"] .table { background: #1A1D24; }
[data-theme="dark"] .table thead th { background: #15181F; border-color: #2D3142; }
[data-theme="dark"] .table tbody td { border-color: #232636; }
[data-theme="dark"] .table-wrapper { border-color: #2D3142; }
[data-theme="dark"] .modal-box { background: #1A1D24; }
[data-theme="dark"] .dropdown-menu { background: #1A1D24; border-color: #2D3142; }
[data-theme="dark"] .stat-card { background: #1A1D24; border-color: #2D3142; }
[data-theme="dark"] .page-btn { background: #1A1D24; border-color: #2D3142; }

/* ── Notification Bell ────────────────────────────────────── */
.notif-wrap { position: relative; }

.notif-badge {
  position: absolute;
  top: 2px; right: 2px;
  background: #B91C1C;
  color: #fff;
  font-size: 9px;
  font-weight: 700;
  min-width: 17px;
  height: 17px;
  padding: 0 4px;
  border-radius: 9px;
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: none;
  line-height: 1;
  border: 2px solid var(--white);
}

.notif-panel {
  position: absolute;
  top: calc(100% + 10px);
  right: 0;
  width: 348px;
  background: var(--white);
  border: 1px solid var(--border-light);
  border-radius: 12px;
  box-shadow: 0 12px 40px rgba(0,0,0,.16), 0 2px 8px rgba(0,0,0,.08);
  z-index: 999;
  display: none;
  flex-direction: column;
  overflow: hidden;
}

.notif-panel.open { display: flex; }

.notif-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 13px 16px 11px;
  border-bottom: 1px solid var(--border-light);
  background: var(--page-bg);
}

.notif-head-title {
  font-size: .82rem;
  font-weight: 700;
  color: var(--text-dark);
  letter-spacing: .1px;
}

.notif-head-link {
  font-size: .71rem;
  font-weight: 600;
  color: var(--navy-mid);
  text-decoration: none;
  padding: 3px 8px;
  border-radius: 5px;
  background: rgba(24,95,165,.08);
}

.notif-head-link:hover { background: rgba(24,95,165,.15); }

.notif-list {
  max-height: 380px;
  overflow-y: auto;
}

.notif-item {
  position: relative;
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 10px 14px;
  border-bottom: 1px solid var(--border-light);
  text-decoration: none;
  color: inherit;
  transition: background .12s;
}

.notif-item:last-child { border-bottom: none; }

.notif-item:hover {
  background: var(--page-bg);
}

.notif-dot {
  position: absolute;
  top: 50%;
  left: 5px;
  transform: translateY(-50%);
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--navy-mid);
  display: none;
  flex-shrink: 0;
}

.notif-item.notif-unread .notif-dot { display: block; }

.notif-item.notif-unread {
  background: rgba(4, 44, 83, 0.04);
}

.notif-item.notif-unread .notif-event {
  font-weight: 700;
  color: var(--text-dark);
}

[data-theme="dark"] .notif-item.notif-unread {
  background: rgba(255, 255, 255, 0.04);
}

[data-theme="dark"] .notif-dot { background: #60A5FA; }

.notif-icon-pill {
  flex-shrink: 0;
  width: 36px;
  height: 36px;
  border-radius: 9px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: .6rem;
  font-weight: 800;
  letter-spacing: .5px;
}

.notif-body { flex: 1; min-width: 0; }

.notif-event {
  font-size: .79rem;
  font-weight: 600;
  color: var(--text-dark);
  margin-bottom: 1px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.notif-desc {
  font-size: .72rem;
  color: var(--text-muted);
  margin-bottom: 2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.notif-meta {
  font-size: .67rem;
  color: var(--text-muted);
  opacity: .8;
}

.notif-arrow {
  flex-shrink: 0;
  font-size: 1rem;
  color: var(--border);
  line-height: 1;
}

.notif-empty {
  padding: 32px 16px;
  text-align: center;
  font-size: .82rem;
  color: var(--text-muted);
}

.notif-footer {
  display: block;
  padding: 10px 16px;
  font-size: .77rem;
  font-weight: 600;
  color: var(--navy-mid);
  text-decoration: none;
  text-align: center;
  border-top: 1px solid var(--border-light);
  background: var(--page-bg);
  letter-spacing: .1px;
}

.notif-footer:hover { color: var(--navy); }

[data-theme="dark"] .notif-panel   { background: #1A1D24; border-color: #2D3142; box-shadow: 0 12px 40px rgba(0,0,0,.4); }
[data-theme="dark"] .notif-head    { background: #15181F; border-color: #2D3142; }
[data-theme="dark"] .notif-item    { border-color: #232636; }
[data-theme="dark"] .notif-footer  { background: #15181F; border-color: #2D3142; }
[data-theme="dark"] .notif-badge   { border-color: #1A1D24; }

/* ── Dark mode: alerts ────────────────────────────────────── */
[data-theme="dark"] .alert-danger  { background: rgba(185,28,28,.18);  color: #FCA5A5; border-color: rgba(185,28,28,.4); }
[data-theme="dark"] .alert-success { background: rgba(22,101,52,.18);  color: #86EFAC; border-color: rgba(22,101,52,.4); }
[data-theme="dark"] .alert-info    { background: rgba(30,64,175,.18);  color: #93C5FD; border-color: rgba(30,64,175,.4); }
[data-theme="dark"] .alert-warning { background: rgba(146,64,14,.18);  color: #FCD34D; border-color: rgba(146,64,14,.4); }

/* ── Dark mode: badges ────────────────────────────────────── */
[data-theme="dark"] .badge-success   { background: rgba(22,101,52,.25);  color: #86EFAC; }
[data-theme="dark"] .badge-danger    { background: rgba(185,28,28,.25);  color: #FCA5A5; }
[data-theme="dark"] .badge-warning   { background: rgba(146,64,14,.25);  color: #FCD34D; }
[data-theme="dark"] .badge-primary   { background: rgba(29,78,216,.25);  color: #93C5FD; }
[data-theme="dark"] .badge-secondary { background: rgba(107,114,128,.2); color: #D1D5DB; }
[data-theme="dark"] .badge-sev1 { background: rgba(153,27,27,.25); color: #FCA5A5; }
[data-theme="dark"] .badge-sev2 { background: rgba(154,52,18,.25); color: #FED7AA; }
[data-theme="dark"] .badge-sev3 { background: rgba(180,83,9,.25);  color: #FCD34D; }
[data-theme="dark"] .badge-sev4 { background: rgba(22,101,52,.25); color: #86EFAC; }

/* ── Dark mode: select arrow ──────────────────────────────── */
[data-theme="dark"] select.form-control {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' fill='none'%3E%3Cpath d='M1 1l5 5 5-5' stroke='%23888' stroke-width='1.5' stroke-linecap='round'/%3E%3C/svg%3E");
  color-scheme: dark;
}

/* ── Dark mode: table rows ────────────────────────────────── */
[data-theme="dark"] .table tbody tr:hover td { background: rgba(255,255,255,.03); }

/* ── Export dropdown ──────────────────────────────────────── */
.export-details { position: relative; display: inline-block; }
.export-details > summary { list-style: none; cursor: pointer; }
.export-details > summary::-webkit-details-marker { display: none; }
.export-options {
  position: absolute;
  right: 0;
  top: calc(100% + 6px);
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  min-width: 170px;
  z-index: 200;
  box-shadow: var(--shadow-lg);
  padding: 6px 0;
}
.export-options a {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 9px 14px;
  font-size: .82rem;
  color: var(--text-dark);
  text-decoration: none;
  white-space: nowrap;
}
.export-options a:hover { background: var(--page-bg); color: var(--teal); }
[data-theme="dark"] .export-options { background: #1A1D24; border-color: #2D3142; }
[data-theme="dark"] .export-options a:hover { background: #15181F; }

/* ── Responsive ───────────────────────────────────────────── */
@media (max-width: 768px) {
  .sidebar {
    transform: translateX(-100%);
    transition: transform .22s cubic-bezier(.4,0,.2,1);
  }

  .sidebar.mobile-open { transform: translateX(0); }

  .main-wrapper,
  .main-wrapper.sidebar-collapsed {
    margin-left: 0;
  }

  .mobile-menu-btn { display: flex; }

  .profile-btn-name { display: none; }

  .main-content { padding: 16px; }

  .grid-2, .grid-3, .grid-4 { grid-template-columns: 1fr; }

  .stats-grid { grid-template-columns: repeat(2, 1fr); }

  .page-header { flex-direction: column; gap: 12px; }
}

@media (max-width: 480px) {
  .stats-grid { grid-template-columns: 1fr; }
  .top-header { padding: 0 12px; }
}
