/* ============================================================
   ConsultX Back Office — Design System
   ============================================================ */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&display=swap');

:root {
  /* Base surfaces */
  --app-bg: #F7F9FC;
  --surface: #FFFFFF;
  --surface-2: #F3F6F9;
  --border: #E5E7EB;
  --border-strong: #D6DBE2;
  --table-head: #F9FAFB;

  /* Text */
  --text-1: #111827;
  --text-2: #4B5563;
  --text-3: #6B7280;
  --text-4: #9CA3AF;

  /* Brand / accent */
  --blue: #2563EB;
  --blue-hover: #1D4ED8;
  --blue-bg: #EFF6FF;
  --teal: #0F766E;
  --teal-bg: #ECFDF5;

  /* Status */
  --success: #16A34A; --success-bg: #DCFCE7;
  --warning: #D97706; --warning-bg: #FEF3C7;
  --critical: #DC2626; --critical-bg: #FEE2E2;
  --info: #2563EB;    --info-bg: #DBEAFE;
  --review: #7C3AED;  --review-bg: #F3E8FF;
  --neutral: #6B7280; --neutral-bg: #F3F4F6;

  /* Sidebar (deep navy) */
  --nav-bg: #0E1A2B;
  --nav-bg-2: #0B1521;
  --nav-text: #94A3B8;
  --nav-text-active: #FFFFFF;
  --nav-active-bg: rgba(37,99,235,0.16);
  --nav-hover-bg: rgba(255,255,255,0.05);
  --nav-section: #5A6B82;
  --nav-border: rgba(255,255,255,0.07);

  /* Geometry */
  --r-sm: 6px;
  --r: 10px;
  --r-lg: 14px;
  --shadow-sm: 0 1px 2px rgba(16,24,40,0.05);
  --shadow: 0 1px 3px rgba(16,24,40,0.07), 0 1px 2px rgba(16,24,40,0.04);
  --shadow-md: 0 4px 12px rgba(16,24,40,0.08), 0 2px 4px rgba(16,24,40,0.04);
  --shadow-lg: 0 12px 32px rgba(16,24,40,0.14), 0 4px 10px rgba(16,24,40,0.06);

  --sidebar-w: 248px;
  --topbar-h: 64px;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: 'Inter', system-ui, -apple-system, sans-serif;
  background: var(--app-bg);
  color: var(--text-1);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
button { font-family: inherit; cursor: pointer; }
input, select, textarea { font-family: inherit; }
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { background: #D1D7E0; border-radius: 6px; border: 2px solid var(--app-bg); }
::-webkit-scrollbar-thumb:hover { background: #B9C1CD; }

/* ===================== MENUS / POPOVERS ===================== */
.menu-pop { position: absolute; top: calc(100% + 6px); z-index: 60; background: #fff; border: 1px solid var(--border); border-radius: 10px; box-shadow: var(--shadow-lg); padding: 6px; min-width: 200px; max-height: 360px; overflow-y: auto; }
.menu-pop.left { left: 0; } .menu-pop.right { right: 0; }
.menu-sep { height: 1px; background: var(--border); margin: 5px 4px; }
.menu-label { font-size: 10.5px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.5px; color: var(--text-4); padding: 7px 10px 3px; }
.menu-item { display: flex; align-items: center; gap: 10px; width: 100%; padding: 8px 10px; border: none; background: transparent; border-radius: 7px; font-size: 13px; font-weight: 500; color: var(--text-2); text-align: left; cursor: pointer; line-height: 1.2; }
.menu-item:hover { background: var(--surface-2); color: var(--text-1); }
.menu-item.danger { color: var(--critical); }
.menu-item.danger:hover { background: var(--critical-bg); }
.menu-item svg { flex: 0 0 16px; opacity: .85; }
.menu-item .mi-end { margin-left: auto; font-size: 11px; color: var(--text-4); }
.menu-item.on { color: var(--blue); font-weight: 600; }

/* split button */
.split-btn { display: inline-flex; align-items: stretch; }
.split-btn > .btn { border-top-right-radius: 0; border-bottom-right-radius: 0; }
.split-btn > .split-caret { border-top-left-radius: 0; border-bottom-left-radius: 0; border-left: 1px solid rgba(255,255,255,0.25); padding: 0 8px; }
.split-btn.sec > .split-caret { border-left: 1px solid var(--border); }

/* ===================== MODAL ===================== */
.modal-card { position: fixed; top: 50%; left: 50%; transform: translate(-50%,-50%); z-index: 101; width: 520px; max-width: 94vw; max-height: 88vh; overflow: auto; background: #fff; border-radius: 14px; box-shadow: var(--shadow-lg); }
.modal-head { display: flex; align-items: flex-start; gap: 12px; padding: 18px 20px; border-bottom: 1px solid var(--border); }
.modal-head h3 { margin: 0; font-size: 17px; font-weight: 700; letter-spacing: -0.2px; }
.modal-head p { margin: 3px 0 0; font-size: 13px; color: var(--text-3); }
.modal-body { padding: 20px; }
.modal-foot { padding: 14px 20px; border-top: 1px solid var(--border); display: flex; gap: 10px; background: var(--surface-2); border-radius: 0 0 14px 14px; }

/* ===================== MY DAY ===================== */
.myday { background: linear-gradient(120deg, #0E1A2B 0%, #112236 55%, #0c3340 100%); border-radius: var(--r-lg); padding: 18px 20px; color: #fff; margin-bottom: 16px; box-shadow: var(--shadow); }
.myday-head { display: flex; align-items: center; gap: 11px; margin-bottom: 15px; }
.myday-head .md-ic { width: 34px; height: 34px; border-radius: 9px; background: rgba(255,255,255,0.12); display: flex; align-items: center; justify-content: center; flex: 0 0 34px; }
.myday-head h3 { margin: 0; font-size: 16px; font-weight: 700; letter-spacing: -0.2px; }
.myday-head .md-date { font-size: 12.5px; color: #94A3B8; }
.myday-tiles { display: grid; grid-template-columns: repeat(6, 1fr); gap: 10px; }
.myday-tile { background: rgba(255,255,255,0.06); border: 1px solid rgba(255,255,255,0.08); border-radius: 11px; padding: 12px 13px; cursor: pointer; transition: background .12s, transform .12s; }
.myday-tile:hover { background: rgba(255,255,255,0.11); transform: translateY(-1px); }
.myday-tile .mt-top { display: flex; align-items: center; gap: 7px; margin-bottom: 8px; }
.myday-tile .mt-ic { width: 24px; height: 24px; border-radius: 7px; display: flex; align-items: center; justify-content: center; flex: 0 0 24px; }
.myday-tile .mt-n { font-size: 26px; font-weight: 700; letter-spacing: -1px; line-height: 1; }
.myday-tile .mt-k { font-size: 11.5px; color: #B6C2D2; font-weight: 500; margin-top: 4px; }
.myday-pri { margin-top: 14px; background: rgba(255,255,255,0.05); border-radius: 11px; padding: 4px 14px; }
.myday-pri .mp-row { display: flex; align-items: center; gap: 11px; padding: 10px 0; border-bottom: 1px solid rgba(255,255,255,0.07); cursor: pointer; }
.myday-pri .mp-row:last-child { border-bottom: none; }
.myday-pri .mp-row:hover .mp-title { color: #fff; }
.myday-pri .mp-dot { width: 8px; height: 8px; border-radius: 50%; flex: 0 0 8px; }
.myday-pri .mp-title { font-size: 13px; font-weight: 500; color: #E2E8F0; flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.myday-pri .mp-meta { font-size: 12px; color: #8DA0B6; white-space: nowrap; }
.myday-empty { padding: 16px 4px; font-size: 13px; color: #94A3B8; }
@media (max-width: 1100px) { .myday-tiles { grid-template-columns: repeat(3, 1fr); } }
@media (max-width: 560px) { .myday-tiles { grid-template-columns: repeat(2, 1fr); } }

/* ===================== BULK BAR ===================== */
.bulkbar { display: flex; align-items: center; gap: 10px; padding: 10px 14px; background: #0E1A2B; color: #fff; border-radius: 10px; margin: 0 0 -1px; flex-wrap: wrap; }
.bulkbar .bb-count { font-size: 13.5px; font-weight: 600; }
.bulkbar .bb-count b { color: #fff; }
.bulkbar .btn-bb { height: 32px; padding: 0 11px; border-radius: 8px; font-size: 12.5px; font-weight: 600; background: rgba(255,255,255,0.12); color: #fff; border: none; display: inline-flex; align-items: center; gap: 6px; }
.bulkbar .btn-bb:hover { background: rgba(255,255,255,0.2); }
.bulkbar .bb-x { margin-left: auto; color: #94A3B8; background: transparent; border: none; cursor: pointer; display: flex; }
.tbl .chk { width: 16px; height: 16px; accent-color: var(--blue); cursor: pointer; }

/* ===================== REQUIRED DOCS CHIPS ===================== */
.docchips { display: flex; flex-wrap: wrap; gap: 8px; }
.docchip { display: inline-flex; align-items: center; gap: 7px; height: 32px; padding: 0 11px; border-radius: 8px; border: 1px solid var(--border); background: #fff; font-size: 12.5px; font-weight: 500; color: var(--text-2); cursor: pointer; transition: all .12s; }
.docchip:hover { border-color: var(--border-strong); }
.docchip.on { background: var(--blue-bg); border-color: #BBD3FB; color: var(--blue-hover); font-weight: 600; }
.docchip .dc-box { width: 15px; height: 15px; border-radius: 4px; border: 1.5px solid var(--border-strong); display: flex; align-items: center; justify-content: center; }
.docchip.on .dc-box { background: var(--blue); border-color: var(--blue); color: #fff; }

/* ===================== AUDIT / ACTIVITY ===================== */
.audit { display: flex; flex-direction: column; }
.audit-row { display: flex; gap: 13px; padding: 13px 0; border-bottom: 1px solid var(--border); }
.audit-row:last-child { border-bottom: none; }
.audit-ic { width: 32px; height: 32px; border-radius: 8px; flex: 0 0 32px; display: flex; align-items: center; justify-content: center; background: var(--surface-2); color: var(--text-3); }
.audit-main { flex: 1; min-width: 0; }
.audit-act { font-size: 13.5px; color: var(--text-1); }
.audit-act b { font-weight: 600; }
.audit-change { font-size: 12.5px; color: var(--text-3); margin-top: 3px; display: flex; align-items: center; gap: 7px; flex-wrap: wrap; }
.audit-old { text-decoration: line-through; color: var(--text-4); }
.audit-new { color: var(--success); font-weight: 600; }
.audit-meta { font-size: 12px; color: var(--text-4); margin-top: 3px; }
.recur-preview { padding: 11px 13px; background: var(--teal-bg); border: 1px solid #A7E3D5; border-radius: 10px; font-size: 13px; color: #0F766E; display: flex; align-items: center; gap: 9px; }
.seg { display: inline-flex; background: var(--surface-2); border: 1px solid var(--border); border-radius: 9px; padding: 3px; gap: 3px; }
.seg button { border: none; background: transparent; padding: 7px 13px; border-radius: 7px; font-size: 12.5px; font-weight: 600; color: var(--text-3); cursor: pointer; }
.seg button.on { background: #fff; color: var(--blue); box-shadow: var(--shadow-sm); }

/* ===================== APP SHELL ===================== */
/* Toggle row / switch vertical centering */
.toggle-row { align-items: center; }
.switch { align-self: center; flex: 0 0 40px; vertical-align: middle; }
.toggle-row .tr-txt { align-self: center; }
/* Global icon alignment — icons stay vertically centered in rows/cells/chips everywhere */
.tbl td, .tbl th { vertical-align: middle; }
.m-ic, .ci, .nav-avatar, .av { display: inline-flex; align-items: center; justify-content: center; vertical-align: middle; }
.client-cell, .cellstack { vertical-align: middle; }
.tbl td .row, .tbl td .client-cell { align-items: center; }
.badge svg, .btn svg, .nav-item svg, .menu-item svg, .m-foot svg { vertical-align: middle; flex: 0 0 auto; }

/* Viewport-locked shell: sidebar fixed, main area scrolls */
.app { display: flex; height: 100vh; overflow: hidden; }

/* ---- Sidebar ---- */
.sidebar {
  width: var(--sidebar-w);
  flex: 0 0 var(--sidebar-w);
  background: linear-gradient(180deg, var(--nav-bg) 0%, var(--nav-bg-2) 100%);
  color: var(--nav-text);
  height: 100vh;
  display: flex; flex-direction: column;
  z-index: 30;
  overflow-y: auto;
  transition: width .2s cubic-bezier(.4,0,.2,1), flex-basis .2s cubic-bezier(.4,0,.2,1);
}
.brand {
  display: flex; align-items: center; gap: 11px;
  padding: 19px 20px 18px;
  border-bottom: 1px solid var(--nav-border);
}
.brand-mark {
  width: 34px; height: 34px; border-radius: 9px;
  background: linear-gradient(135deg, #2563EB, #0F766E);
  display: flex; align-items: center; justify-content: center;
  color: #fff; font-weight: 700; font-size: 16px; letter-spacing: -0.5px;
  box-shadow: 0 2px 8px rgba(37,99,235,0.35);
}
.brand-name { color: #fff; font-weight: 700; font-size: 16px; letter-spacing: -0.2px; line-height: 1.1; }
.brand-sub { font-size: 10.5px; color: var(--nav-section); font-weight: 500; letter-spacing: 0.4px; text-transform: uppercase; }

.nav { flex: 1; overflow-y: auto; padding: 12px 12px 18px; }
.nav::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.12); border-color: transparent; }
.nav-section-label {
  font-size: 10.5px; font-weight: 600; letter-spacing: 0.7px; text-transform: uppercase;
  color: var(--nav-section); padding: 16px 10px 7px;
}
.nav-item {
  display: flex; align-items: center; gap: 11px;
  padding: 8.5px 10px; border-radius: 8px; margin-bottom: 2px;
  color: var(--nav-text); font-size: 13.5px; font-weight: 500;
  cursor: pointer; user-select: none; position: relative;
  transition: background .12s, color .12s;
}
.nav-item:hover { background: var(--nav-hover-bg); color: #CBD5E1; }
.nav-item.active { background: var(--nav-active-bg); color: var(--nav-text-active); font-weight: 600; }
.nav-item.active::before {
  content: ''; position: absolute; left: -12px; top: 7px; bottom: 7px;
  width: 3px; border-radius: 0 3px 3px 0; background: var(--blue);
}
.nav-item svg { flex: 0 0 18px; width: 18px; height: 18px; opacity: .9; }
.nav-item .nav-badge {
  margin-left: auto; font-size: 11px; font-weight: 700;
  background: var(--critical); color: #fff; min-width: 18px; height: 18px;
  border-radius: 9px; display: flex; align-items: center; justify-content: center; padding: 0 5px;
}
.nav-item .nav-badge.muted { background: rgba(255,255,255,0.12); color: #CBD5E1; }
.nav-footer {
  padding: 12px; border-top: 1px solid var(--nav-border);
  display: flex; align-items: center; gap: 10px;
}
.nav-avatar {
  width: 34px; height: 34px; border-radius: 50%; background: #1E3A5F; color: #fff;
  display: flex; align-items: center; justify-content: center; font-weight: 600; font-size: 13px;
  flex: 0 0 34px;
}
.nav-user-name { color: #E2E8F0; font-size: 13px; font-weight: 600; line-height: 1.2; }
.nav-user-role { color: var(--nav-section); font-size: 11px; }

/* ---- Collapse toggle ---- */
.nav-collapse-btn {
  position: absolute; top: 22px; right: -13px; z-index: 31;
  width: 26px; height: 26px; border-radius: 50%;
  background: var(--surface); border: 1px solid var(--border-strong);
  color: var(--text-2); display: flex; align-items: center; justify-content: center;
  box-shadow: var(--shadow); transition: background .12s, color .12s, transform .12s;
}
.nav-collapse-btn:hover { background: var(--blue); color: #fff; border-color: var(--blue); }
.nav-collapse-btn svg { transition: transform .2s; }

/* ---- Rail (collapsed) state — desktop only ---- */
/* brand-mark is 34px wide; 20px padding each side = 74px total */
.sidebar.collapsed { width: 74px; flex-basis: 74px; overflow: visible; }
.sidebar.collapsed .brand { justify-content: center; padding: 19px 0 18px; }
.sidebar.collapsed .brand-text { display: none; }
.sidebar.collapsed .nav { padding: 12px 10px 18px; overflow: visible; }
.sidebar.collapsed .nav-section-label { text-align: center; padding: 16px 0 7px; font-size: 9px; letter-spacing: 0.3px; opacity: .6; }
.sidebar.collapsed .nav-item { justify-content: center; padding: 10px 0; gap: 0; }
.sidebar.collapsed .nav-item .nav-label,
.sidebar.collapsed .nav-item .nav-badge { display: none; }
.sidebar.collapsed .nav-item.active::before { left: -10px; }
/* unread dot when a badge exists but label hidden */
.sidebar.collapsed .nav-item.has-badge::after {
  content: ''; position: absolute; top: 7px; right: 14px;
  width: 7px; height: 7px; border-radius: 50%; background: var(--critical); border: 1.5px solid var(--nav-bg);
}
.sidebar.collapsed .nav-footer { justify-content: center; padding: 12px 0; gap: 0; }
.sidebar.collapsed .nav-user-meta,
.sidebar.collapsed .nav-footer .icon-btn,
.sidebar.collapsed .nav-edit-icon { display: none; }
.sidebar.collapsed .nav-collapse-btn svg { transform: rotate(180deg); }
/* tooltip on hover when collapsed */
.sidebar.collapsed .nav-item[data-tip]:hover::before {
  content: attr(data-tip); position: absolute; left: calc(100% + 14px); top: 50%; transform: translateY(-50%);
  background: #0B1521; color: #fff; font-size: 12.5px; font-weight: 600; padding: 6px 10px; border-radius: 7px;
  white-space: nowrap; box-shadow: var(--shadow-lg); z-index: 50; width: auto;
}
.sidebar.collapsed .nav-item[data-tip]:hover::after {
  content: ''; position: absolute; left: calc(100% + 8px); top: 50%; transform: translateY(-50%) rotate(45deg);
  width: 8px; height: 8px; background: #0B1521; z-index: 50; border-radius: 1px;
}

/* ---- Main column — this is the scroll container ---- */
.main { flex: 1; min-width: 0; display: flex; flex-direction: column; overflow-y: auto; height: 100vh; }

/* ---- Top bar ---- */
.topbar {
  height: var(--topbar-h); flex: 0 0 var(--topbar-h);
  background: var(--surface); border-bottom: 1px solid var(--border);
  display: flex; align-items: center; gap: 16px; padding: 0 26px;
  position: sticky; top: 0; z-index: 20;
}
.crumbs { display: flex; align-items: center; gap: 7px; font-size: 13px; color: var(--text-3); }
.crumbs .sep { color: var(--text-4); }
.crumbs .current { color: var(--text-1); font-weight: 600; }
.topbar-search {
  margin-left: 8px; flex: 0 1 360px; display: flex; align-items: center; gap: 9px;
  background: var(--surface-2); border: 1px solid var(--border); border-radius: 9px;
  padding: 0 12px; height: 38px; color: var(--text-3);
}
.topbar-search input { border: none; background: transparent; outline: none; flex: 1; font-size: 13.5px; color: var(--text-1); }
.topbar-search input::placeholder { color: var(--text-4); }
.topbar-search kbd {
  font-size: 11px; color: var(--text-4); background: var(--surface); border: 1px solid var(--border);
  border-radius: 5px; padding: 1px 6px; font-family: inherit;
}
.topbar-spacer { flex: 1; }
.icon-btn {
  width: 38px; height: 38px; border-radius: 9px; border: 1px solid var(--border);
  background: var(--surface); color: var(--text-2); display: flex; align-items: center; justify-content: center;
  position: relative; transition: background .12s, border-color .12s;
}
.icon-btn:hover { background: var(--surface-2); border-color: var(--border-strong); }
.icon-btn .dot { position: absolute; top: 8px; right: 9px; width: 7px; height: 7px; border-radius: 50%; background: var(--critical); border: 1.5px solid #fff; }
.role-chip {
  display: flex; align-items: center; gap: 7px; height: 38px; padding: 0 12px 0 7px;
  border-radius: 9px; border: 1px solid var(--border); background: var(--surface); cursor: pointer;
}
.role-chip:hover { background: var(--surface-2); }
.role-chip .av { width: 26px; height: 26px; border-radius: 50%; background: linear-gradient(135deg,#2563EB,#0F766E); color:#fff; font-size:11px; font-weight:700; display:flex; align-items:center; justify-content:center; }
.role-chip .nm { font-size: 13px; font-weight: 600; color: var(--text-1); line-height: 1; }
.role-chip .rl { font-size: 11px; color: var(--text-3); line-height: 1.2; }

/* ---- Content ---- */
.content { padding: 26px 30px 60px; max-width: 1480px; width: 100%; margin: 0 auto; }
.page-head { display: flex; align-items: flex-start; gap: 18px; margin-bottom: 22px; }
.page-head .ph-left { flex: 1; min-width: 0; }
.page-title { font-size: 27px; font-weight: 700; letter-spacing: -0.4px; color: var(--text-1); margin: 0; }
.page-sub { font-size: 14px; color: var(--text-3); margin: 5px 0 0; }
.page-actions { display: flex; align-items: center; gap: 10px; }

/* ===================== BUTTONS ===================== */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  height: 38px; padding: 0 15px; border-radius: 9px; border: 1px solid transparent;
  font-size: 13.5px; font-weight: 600; white-space: nowrap; transition: background .12s, border-color .12s, box-shadow .12s;
}
.btn svg { width: 17px; height: 17px; }
.btn-primary { background: var(--blue); color: #fff; box-shadow: 0 1px 2px rgba(37,99,235,0.25); }
.btn-primary:hover { background: var(--blue-hover); }
.btn-secondary { background: var(--surface); color: var(--text-2); border-color: var(--border); }
.btn-secondary:hover { background: var(--surface-2); border-color: var(--border-strong); color: var(--text-1); }
.btn-ghost { background: transparent; color: var(--text-2); }
.btn-ghost:hover { background: var(--surface-2); }
.btn-teal { background: var(--teal); color: #fff; }
.btn-teal:hover { background: #0c5e57; }
.btn-danger { background: var(--surface); color: var(--critical); border-color: #F3CFCF; }
.btn-danger:hover { background: var(--critical-bg); }
.btn-sm { height: 32px; padding: 0 11px; font-size: 12.5px; border-radius: 8px; }
.btn-sm svg { width: 15px; height: 15px; }

/* ===================== CARDS ===================== */
.card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-lg);
  box-shadow: var(--shadow-sm);
}
.card-pad { padding: 20px; }
.card-head {
  display: flex; align-items: center; gap: 12px; padding: 16px 20px;
  border-bottom: 1px solid var(--border);
}
.card-head h3 { margin: 0; font-size: 15px; font-weight: 600; color: var(--text-1); }
.card-head .ch-sub { font-size: 12.5px; color: var(--text-3); font-weight: 500; }
.card-head .spacer { flex: 1; }

/* ---- Metric card ---- */
.metric-grid { display: grid; gap: 16px; }
.metric {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-lg);
  padding: 17px 18px 16px; box-shadow: var(--shadow-sm); position: relative; overflow: hidden;
  transition: box-shadow .14s, transform .14s, border-color .14s;
}
.metric:hover { box-shadow: var(--shadow-md); transform: translateY(-1px); }
.metric .m-top { display: flex; align-items: center; gap: 10px; margin-bottom: 12px; }
.metric .m-ic { width: 34px; height: 34px; border-radius: 9px; display: flex; align-items: center; justify-content: center; flex: 0 0 34px; }
.metric .m-ic svg { width: 18px; height: 18px; }
.metric .m-label { font-size: 12.5px; font-weight: 600; color: var(--text-3); letter-spacing: 0.1px; }
.metric .m-num { font-size: 33px; font-weight: 700; letter-spacing: -1px; color: var(--text-1); line-height: 1; }
.metric .m-foot { margin-top: 9px; font-size: 12px; color: var(--text-3); display: flex; align-items: center; gap: 6px; }
.metric .m-accent { position: absolute; left: 0; top: 0; bottom: 0; width: 3px; }
.metric .trend { font-weight: 600; display: inline-flex; align-items: center; gap: 3px; }
.trend.up { color: var(--success); }
.trend.down { color: var(--critical); }

/* ===================== BADGES ===================== */
.badge {
  display: inline-flex; align-items: center; gap: 5px; height: 22px; padding: 0 9px;
  border-radius: 999px; font-size: 12px; font-weight: 600; white-space: nowrap; line-height: 1;
}
.badge .bd { width: 6px; height: 6px; border-radius: 50%; }
.badge.success { background: var(--success-bg); color: #15803D; }
.badge.warning { background: var(--warning-bg); color: #B45309; }
.badge.critical { background: var(--critical-bg); color: #B91C1C; }
.badge.info { background: var(--info-bg); color: #1D4ED8; }
.badge.review { background: var(--review-bg); color: #6D28D9; }
.badge.neutral { background: var(--neutral-bg); color: #4B5563; }
.badge.teal { background: var(--teal-bg); color: #0F766E; }
/* outline variant for priority */
.badge.out { background: transparent; border: 1px solid currentColor; }
.badge.out.success { color: #15803D; }
.badge.out.warning { color: #B45309; }
.badge.out.critical { color: #B91C1C; }
.badge.out.neutral { color: var(--text-3); border-color: var(--border-strong); }

/* dot-only risk pill */
.risk { display: inline-flex; align-items: center; gap: 6px; font-size: 12.5px; font-weight: 600; }
.risk .rd { width: 8px; height: 8px; border-radius: 50%; }

/* ===================== TABLES ===================== */
.tbl-wrap { width: 100%; overflow-x: auto; }
table.tbl { width: 100%; border-collapse: separate; border-spacing: 0; font-size: 13.5px; }
.tbl thead th {
  position: sticky; top: 0; background: var(--table-head); z-index: 2;
  text-align: left; font-size: 11.5px; font-weight: 600; letter-spacing: 0.4px; text-transform: uppercase;
  color: var(--text-3); padding: 11px 14px; border-bottom: 1px solid var(--border); white-space: nowrap;
}
.tbl thead th.sortable { cursor: pointer; }
.tbl thead th.sortable:hover { color: var(--text-1); }
.tbl thead th .th-in { display: inline-flex; align-items: center; gap: 5px; }
.tbl tbody td { padding: 13px 14px; border-bottom: 1px solid var(--border); color: var(--text-2); vertical-align: middle; }
.tbl tbody tr { transition: background .1s; }
.tbl tbody tr:hover { background: #FAFBFD; }
.tbl tbody tr:last-child td { border-bottom: none; }
.tbl .t-primary { color: var(--text-1); font-weight: 600; }
.tbl .t-mut { color: var(--text-3); font-size: 12.5px; }
.cellstack { display: flex; flex-direction: column; gap: 2px; }
.client-cell { display: flex; align-items: center; gap: 10px; }
.client-cell .ci {
  width: 30px; height: 30px; border-radius: 8px; flex: 0 0 30px; font-size: 11.5px; font-weight: 700;
  display: flex; align-items: center; justify-content: center; color: #fff; letter-spacing: -0.3px;
}
.row-menu-btn { width: 30px; height: 30px; border-radius: 7px; border: 1px solid transparent; background: transparent; color: var(--text-3); display: flex; align-items: center; justify-content: center; }
.row-menu-btn:hover { background: var(--surface-2); border-color: var(--border); color: var(--text-1); }

/* ---- Filter bar ---- */
.filterbar { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; padding: 14px 16px; border-bottom: 1px solid var(--border); }
.fsearch { display: flex; align-items: center; gap: 8px; background: var(--surface-2); border: 1px solid var(--border); border-radius: 8px; height: 36px; padding: 0 11px; flex: 0 1 280px; color: var(--text-3); }
.fsearch input { border: none; background: transparent; outline: none; flex: 1; font-size: 13px; color: var(--text-1); }
.fselect {
  height: 36px; border: 1px solid var(--border); background: var(--surface); border-radius: 8px;
  padding: 0 30px 0 11px; font-size: 13px; color: var(--text-2); font-weight: 500; cursor: pointer;
  appearance: none; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 24 24' fill='none' stroke='%236B7280' stroke-width='2.2' stroke-linecap='round'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 9px center;
}
.fselect:hover { border-color: var(--border-strong); }
.fchip {
  height: 36px; display: inline-flex; align-items: center; gap: 7px; padding: 0 12px; border-radius: 8px;
  border: 1px solid var(--border); background: var(--surface); font-size: 13px; font-weight: 500; color: var(--text-2);
}
.fchip.toggle.on { background: var(--blue-bg); border-color: #BBD3FB; color: var(--blue-hover); }
.fchip .x { color: var(--text-4); }
.filter-spacer { flex: 1; }

/* ---- Tabs ---- */
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--border); }
.tab { padding: 11px 14px; font-size: 13.5px; font-weight: 600; color: var(--text-3); border-bottom: 2px solid transparent; margin-bottom: -1px; cursor: pointer; display: inline-flex; align-items: center; gap: 7px; }
.tab:hover { color: var(--text-1); }
.tab.active { color: var(--blue); border-bottom-color: var(--blue); }
.tab .tc { background: var(--surface-2); color: var(--text-3); border-radius: 999px; font-size: 11px; font-weight: 700; padding: 1px 7px; }
.tab.active .tc { background: var(--blue-bg); color: var(--blue); }

/* ---- Pagination ---- */
.pager { display: flex; align-items: center; gap: 12px; padding: 13px 16px; border-top: 1px solid var(--border); }
.pager .pinfo { font-size: 13px; color: var(--text-3); }
.pager .pbtns { margin-left: auto; display: flex; gap: 6px; }
.pbtn { min-width: 32px; height: 32px; border-radius: 7px; border: 1px solid var(--border); background: var(--surface); font-size: 13px; font-weight: 600; color: var(--text-2); padding: 0 8px; }
.pbtn:hover { background: var(--surface-2); }
.pbtn.active { background: var(--blue); color: #fff; border-color: var(--blue); }
.pbtn:disabled { opacity: .45; cursor: not-allowed; }

/* ===================== FORMS ===================== */
.form-section { border-top: 1px solid var(--border); }
.form-section:first-child { border-top: none; }
.fs-head { display: flex; gap: 13px; padding: 20px 22px 4px; }
.fs-num { width: 26px; height: 26px; border-radius: 8px; background: var(--blue-bg); color: var(--blue); font-size: 12.5px; font-weight: 700; display: flex; align-items: center; justify-content: center; flex: 0 0 26px; }
.fs-title { font-size: 15px; font-weight: 600; color: var(--text-1); }
.fs-desc { font-size: 12.5px; color: var(--text-3); margin-top: 1px; }
.fs-body { padding: 14px 22px 22px 22px; }
.fgrid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px 20px; }
.field { display: flex; flex-direction: column; gap: 6px; }
.field.full { grid-column: 1 / -1; }
.field label { font-size: 13px; font-weight: 600; color: var(--text-2); }
.field label .req { color: var(--critical); margin-left: 2px; }
.field .help { font-size: 12px; color: var(--text-3); }
.field .help.sensitive { color: #B45309; display: flex; gap: 5px; align-items: flex-start; }
.inp, .field select, .field textarea {
  height: 40px; border: 1px solid var(--border); border-radius: 9px; background: var(--surface);
  padding: 0 12px; font-size: 13.5px; color: var(--text-1); outline: none; transition: border-color .12s, box-shadow .12s;
}
.field textarea { height: auto; padding: 10px 12px; resize: vertical; min-height: 80px; }
.field select { appearance: none; cursor: pointer;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 24 24' fill='none' stroke='%236B7280' stroke-width='2.2' stroke-linecap='round'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 11px center; padding-right: 32px;
}
.inp:focus, .field select:focus, .field textarea:focus { border-color: var(--blue); box-shadow: 0 0 0 3px rgba(37,99,235,0.12); }
.inp::placeholder, .field textarea::placeholder { color: var(--text-4); }
.input-icon { position: relative; display: flex; }
.input-icon svg { position: absolute; left: 11px; top: 50%; transform: translateY(-50%); color: var(--text-4); width: 17px; height: 17px; }
.input-icon .inp { padding-left: 36px; width: 100%; }

/* toggle */
.switch { position: relative; width: 40px; height: 23px; border-radius: 999px; background: var(--border-strong); transition: background .15s; flex: 0 0 40px; }
.switch.on { background: var(--blue); }
.switch .knob { position: absolute; top: 2.5px; left: 2.5px; width: 18px; height: 18px; border-radius: 50%; background: #fff; box-shadow: 0 1px 2px rgba(0,0,0,.2); transition: left .15s; }
.switch.on .knob { left: 19.5px; }
.toggle-row { display: flex; align-items: center; gap: 12px; padding: 11px 0; }
.toggle-row .tr-txt { flex: 1; }
.toggle-row .tr-label { font-size: 13.5px; font-weight: 600; color: var(--text-1); }
.toggle-row .tr-desc { font-size: 12px; color: var(--text-3); margin-top: 1px; }
.form-footer { display: flex; align-items: center; gap: 10px; padding: 16px 22px; border-top: 1px solid var(--border); background: var(--surface-2); border-radius: 0 0 var(--r-lg) var(--r-lg); position: sticky; bottom: 0; }

/* ===================== EMPTY STATE ===================== */
.empty { display: flex; flex-direction: column; align-items: center; text-align: center; padding: 48px 24px; }
.empty .e-ic { width: 56px; height: 56px; border-radius: 14px; background: var(--surface-2); color: var(--text-4); display: flex; align-items: center; justify-content: center; margin-bottom: 14px; }
.empty .e-ic svg { width: 26px; height: 26px; }
.empty h4 { margin: 0 0 5px; font-size: 15px; font-weight: 600; color: var(--text-1); }
.empty p { margin: 0 0 16px; font-size: 13px; color: var(--text-3); max-width: 320px; }

/* ===================== CHARTS (lightweight) ===================== */
.bars { display: flex; flex-direction: column; gap: 13px; }
.bar-row { display: grid; grid-template-columns: 130px 1fr 42px; align-items: center; gap: 12px; }
.bar-row .bl { font-size: 13px; color: var(--text-2); font-weight: 500; }
.bar-track { height: 9px; background: var(--surface-2); border-radius: 999px; overflow: hidden; }
.bar-fill { height: 100%; border-radius: 999px; }
.bar-row .bv { font-size: 13px; font-weight: 600; color: var(--text-1); text-align: right; }

.donut-wrap { display: flex; align-items: center; gap: 24px; }
.legend { display: flex; flex-direction: column; gap: 9px; }
.legend-item { display: flex; align-items: center; gap: 9px; font-size: 13px; color: var(--text-2); }
.legend-item .ld { width: 10px; height: 10px; border-radius: 3px; }
.legend-item .lv { margin-left: auto; font-weight: 600; color: var(--text-1); padding-left: 16px; }

/* mini list */
.minilist { display: flex; flex-direction: column; }
.mli { display: flex; align-items: center; gap: 12px; padding: 11px 0; border-bottom: 1px solid var(--border); }
.mli:last-child { border-bottom: none; }
.mli .rank { width: 22px; height: 22px; border-radius: 6px; background: var(--surface-2); color: var(--text-3); font-size: 11.5px; font-weight: 700; display: flex; align-items: center; justify-content: center; flex: 0 0 22px; }
.mli .mli-main { flex: 1; min-width: 0; }
.mli .mli-t { font-size: 13.5px; font-weight: 600; color: var(--text-1); }
.mli .mli-s { font-size: 12px; color: var(--text-3); }
.mli .mli-v { font-size: 13.5px; font-weight: 700; color: var(--text-1); }

/* ===================== DRAWER / OVERLAY ===================== */
.overlay { position: fixed; inset: 0; background: rgba(16,24,40,0.42); z-index: 100; opacity: 0; pointer-events: none; transition: opacity .18s; }
.overlay.show { opacity: 1; pointer-events: auto; }
.drawer {
  position: fixed; top: 0; right: 0; height: 100vh; width: 760px; max-width: 94vw; background: var(--app-bg);
  z-index: 101; box-shadow: var(--shadow-lg); transform: translateX(100%); transition: transform .22s cubic-bezier(.4,0,.2,1);
  display: flex; flex-direction: column;
}
.drawer.show { transform: translateX(0); }
.drawer-head { display: flex; align-items: center; gap: 14px; padding: 18px 22px; background: var(--surface); border-bottom: 1px solid var(--border); }
.drawer-head h2 { margin: 0; font-size: 18px; font-weight: 700; letter-spacing: -0.3px; }
.drawer-head p { margin: 2px 0 0; font-size: 13px; color: var(--text-3); }
.drawer-body { flex: 1; overflow-y: auto; }
.drawer-card { background: var(--surface); margin: 18px 22px; border: 1px solid var(--border); border-radius: var(--r-lg); box-shadow: var(--shadow-sm); }

/* ===================== UTIL ===================== */
.row { display: flex; align-items: center; }
.gap6 { gap: 6px; } .gap8 { gap: 8px; } .gap10 { gap: 10px; } .gap12 { gap: 12px; } .gap16 { gap: 16px; }
.wrap { flex-wrap: wrap; }
.muted { color: var(--text-3); }
.strong { color: var(--text-1); font-weight: 600; }
.mono { font-family: 'SFMono-Regular', ui-monospace, Menlo, monospace; font-size: 12.5px; letter-spacing: -0.2px; }
.divider { height: 1px; background: var(--border); }
.dim { color: var(--text-4); }
.nowrap { white-space: nowrap; }
.link { color: var(--blue); font-weight: 600; cursor: pointer; }
.link:hover { color: var(--blue-hover); text-decoration: underline; }
.days-left { font-weight: 700; }
.days-left.crit { color: var(--critical); }
.days-left.warn { color: var(--warning); }
.days-left.ok { color: var(--text-2); }

/* toast */
.toast-wrap { position: fixed; bottom: 22px; left: 50%; transform: translateX(-50%); z-index: 200; display: flex; flex-direction: column; gap: 8px; align-items: center; }
.toast { background: #0E1A2B; color: #fff; padding: 11px 16px; border-radius: 10px; font-size: 13.5px; font-weight: 500; box-shadow: var(--shadow-lg); display: flex; align-items: center; gap: 9px; animation: toastin .22s ease; }
.toast svg { width: 17px; height: 17px; color: #4ADE80; }
@keyframes toastin { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: translateY(0); } }
@keyframes cx-spin { to { transform: rotate(360deg); } }

@media (max-width: 860px) {
  .login-wrap { grid-template-columns: 1fr !important; }
  .login-aside { display: none !important; }
}

/* responsive */
@media (max-width: 1200px) {
  .metric-collapse { grid-template-columns: repeat(3, 1fr) !important; }
}
@media (max-width: 1180px) {
  .content { padding: 22px 18px 50px; }
}
@media (max-width: 980px) {
  .collapsible { grid-template-columns: 1fr !important; }
}
@media (max-width: 760px) {
  .metric-collapse { grid-template-columns: repeat(2, 1fr) !important; }
  .collapsible { grid-template-columns: 1fr !important; }
  .page-head { flex-direction: column; gap: 12px; }
  .page-actions { width: 100%; flex-wrap: wrap; }
  .page-title { font-size: 23px; }
  .drawer { width: 100vw; }
  .fgrid { grid-template-columns: 1fr !important; }
}
@media (max-width: 480px) {
  .metric-collapse { grid-template-columns: 1fr !important; }
  .content { padding: 18px 14px 50px; }
}

/* mobile sidebar drawer */
.hamburger { display: none; }
@media (max-width: 900px) {
  /* on mobile the sidebar is a full overlay drawer, not part of flex layout */
  .sidebar {
    position: fixed; left: 0; top: 0; transform: translateX(-100%);
    transition: transform .22s cubic-bezier(.4,0,.2,1); box-shadow: var(--shadow-lg);
    display: flex; z-index: 60; width: 268px; flex-basis: 268px; height: 100vh;
  }
  .sidebar.open { transform: translateX(0); }
  /* force expanded look inside the drawer even if collapsed flag is set */
  .sidebar.collapsed { width: 268px; flex-basis: 268px; }
  .sidebar.collapsed .brand-text, .sidebar.collapsed .nav-label,
  .sidebar.collapsed .nav-badge, .sidebar.collapsed .nav-user-meta { display: block; }
  .sidebar.collapsed .brand { justify-content: flex-start; padding: 19px 20px 18px; }
  .sidebar.collapsed .nav-item { justify-content: flex-start; padding: 8.5px 10px; gap: 11px; }
  .sidebar.collapsed .nav-item.has-badge::after { display: none; }
  .sidebar.collapsed .nav-section-label { text-align: left; padding: 16px 10px 7px; font-size: 10.5px; opacity: 1; }
  .sidebar.collapsed .nav-footer { justify-content: flex-start; padding: 12px; }
  .nav-collapse-btn { display: none; }
  .sidebar-scrim { position: fixed; inset: 0; background: rgba(16,24,40,0.45); z-index: 59; }
  .hamburger { display: flex; }
  .topbar { padding: 0 14px; gap: 10px; }
  .topbar-search { display: none; }
  .role-chip .nm, .role-chip .rl { display: none; }
  .role-chip { padding: 0 8px; }
}

/* portal-specific accent (teal) */
.portal .metric .m-num { color: var(--text-1); }
.portal-banner {
  background: linear-gradient(120deg, #0F766E 0%, #115E59 100%); color: #fff; border-radius: var(--r-lg);
  padding: 24px 26px; display: flex; align-items: center; gap: 20px; box-shadow: var(--shadow);
}
.portal-banner .pb-mark { width: 52px; height: 52px; border-radius: 13px; background: rgba(255,255,255,0.15); display: flex; align-items: center; justify-content: center; }
.portal-banner h2 { margin: 0; font-size: 21px; font-weight: 700; }
.portal-banner p { margin: 4px 0 0; font-size: 13.5px; opacity: .9; }
