/* =====================================================================
   ARTEMIS DESIGN SYSTEM · v1.0 · Interactive prototype
   Boston Diabetes · Demo data only · Not for clinical use
   ===================================================================== */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&family=JetBrains+Mono:wght@400;500&display=swap');

:root {
  /* Core palette */
  --navy-950: #070F24;
  --navy-900: #0B1630;
  --navy-800: #122142;
  --navy-700: #1C2D55;
  --navy-600: #2B3D69;
  --teal-700: #0B6E64;
  --teal-600: #0E8577;
  --teal-500: #129C8C;
  --teal-400: #3DB7A8;
  --teal-100: #CFEFEA;
  --teal-50:  #EBF7F5;
  --violet-600: #5B4FD6;
  --violet-50: #F0EEFD;

  /* Neutrals */
  --ink:   #0F172A;
  --ink-2: #3F4B5F;
  --ink-3: #6B778C;
  --ink-4: #98A2B3;
  --line:  #E5E8EE;
  --line-2:#EEF0F4;
  --bg:    #F5F6F8;
  --bg-2:  #FAFBFC;
  --surface: #FFFFFF;

  /* Status */
  --ok: #117A55;     --ok-bg: #E7F5EE;
  --warn: #A85A06;   --warn-bg: #FDF2E2;
  --bad: #B42318;    --bad-bg: #FDECEA;
  --info: #2450C4;   --info-bg: #EAF0FD;
  --muted: #5B6578;  --muted-bg: #F0F2F5;

  /* CGM ranges (consensus bands) */
  --g-vlow: #8C1D1D;
  --g-low:  #DE4A4A;
  --g-in:   #129C8C;
  --g-high: #EDB541;
  --g-vhigh:#DD7F2A;

  /* Type */
  --font: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  --mono: 'JetBrains Mono', ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;

  /* Shape */
  --r-sm: 6px;
  --r: 10px;
  --r-lg: 14px;
  --shadow-sm: 0 1px 2px rgba(15, 23, 42, .05);
  --shadow: 0 1px 3px rgba(15, 23, 42, .06), 0 1px 2px rgba(15, 23, 42, .04);
  --shadow-lg: 0 18px 48px -12px rgba(15, 23, 42, .22), 0 4px 12px rgba(15, 23, 42, .06);

  --sidebar-w: 248px;
  --sidebar-w-collapsed: 68px;
  --topbar-h: 60px;

  --accent: var(--teal-600);
  --accent-soft: var(--teal-50);
}

body[data-portal="admin"] { --accent: var(--violet-600); --accent-soft: var(--violet-50); }

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.5;
  color: var(--ink);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  font-feature-settings: 'cv11', 'ss01';
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
img, svg { display: block; }
button, input, select, textarea { font: inherit; color: inherit; }
h1, h2, h3, h4, h5 { margin: 0; font-weight: 600; letter-spacing: -0.01em; color: var(--ink); }
h1 { font-size: 22px; line-height: 1.3; letter-spacing: -0.02em; }
h2 { font-size: 16px; line-height: 1.35; }
h3 { font-size: 14px; line-height: 1.4; }
h4 { font-size: 13px; }
p { margin: 0; }
hr { border: 0; border-top: 1px solid var(--line); margin: 16px 0; }
code, .mono { font-family: var(--mono); font-size: 12px; }
::selection { background: var(--teal-100); }

/* ---------- Prototype ribbon ---------- */
.proto-ribbon {
  position: fixed; inset: 0 0 auto 0; height: 26px; z-index: 60;
  display: flex; align-items: center; justify-content: center; gap: 10px;
  background: var(--navy-950); color: #C9D3E6;
  font-size: 11.5px; letter-spacing: .02em;
}
.proto-ribbon b { color: #fff; font-weight: 600; }
.proto-ribbon .dot { width: 6px; height: 6px; border-radius: 50%; background: #F2B544; }
.proto-ribbon a { color: #9FE3D9; }
.proto-ribbon .sep { opacity: .4; }
body.has-ribbon { padding-top: 26px; }

/* ---------- App layout ---------- */
.app { display: flex; min-height: calc(100vh - 26px); }
.sidebar {
  position: fixed; top: 26px; bottom: 0; left: 0; z-index: 40;
  width: var(--sidebar-w);
  background: var(--navy-900);
  color: #C5CEE0;
  display: flex; flex-direction: column;
  transition: width .18s ease, transform .2s ease;
}
body[data-portal="admin"] .sidebar { background: #0E1222; }
.sidebar-head {
  height: var(--topbar-h); display: flex; align-items: center; gap: 10px;
  padding: 0 18px; border-bottom: 1px solid rgba(255,255,255,.06);
}
.brand { display: flex; align-items: center; gap: 10px; color: #fff; text-decoration: none !important; min-width: 0; }
.brand-mark { width: 28px; height: 28px; flex: none; }
.brand-text { display: flex; flex-direction: column; line-height: 1.1; min-width: 0; }
.brand-name { font-weight: 700; font-size: 15px; letter-spacing: .08em; }
.brand-sub { font-size: 10.5px; color: #8A97B2; letter-spacing: .04em; white-space: nowrap; }
.sidebar-nav { flex: 1; overflow-y: auto; padding: 12px 10px 16px; scrollbar-width: thin; scrollbar-color: rgba(255,255,255,.12) transparent; }
.nav-group { margin-top: 14px; }
.nav-group:first-child { margin-top: 0; }
.nav-label { font-size: 10.5px; text-transform: uppercase; letter-spacing: .09em; color: #6F7C98; padding: 6px 10px; white-space: nowrap; }
.nav-item {
  display: flex; align-items: center; gap: 11px;
  height: 36px; padding: 0 10px; border-radius: 8px;
  color: #BAC4D8; text-decoration: none !important; font-size: 13.5px; font-weight: 500;
  white-space: nowrap; position: relative;
}
.nav-item svg { width: 18px; height: 18px; flex: none; opacity: .85; }
.nav-item:hover { background: rgba(255,255,255,.05); color: #fff; }
.nav-item.active { background: rgba(255,255,255,.08); color: #fff; }
.nav-item.active::before { content: ''; position: absolute; left: -10px; top: 8px; bottom: 8px; width: 3px; border-radius: 0 3px 3px 0; background: var(--teal-400); }
body[data-portal="admin"] .nav-item.active::before { background: #8B80F0; }
.nav-item .count { margin-left: auto; font-size: 11px; font-weight: 600; background: rgba(255,255,255,.1); color: #E6ECF7; padding: 1px 7px; border-radius: 10px; }
.nav-item .count.hot { background: #E0484C; color: #fff; }
.sidebar-foot { padding: 12px 10px; border-top: 1px solid rgba(255,255,255,.06); }
.sidebar-user { display: flex; align-items: center; gap: 10px; padding: 6px; border-radius: 8px; }
.sidebar-user .who { min-width: 0; line-height: 1.25; }
.sidebar-user .who b { display: block; color: #fff; font-size: 13px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sidebar-user .who span { font-size: 11.5px; color: #8A97B2; white-space: nowrap; }
.collapse-btn { margin-left: auto; background: none; border: 0; color: #8A97B2; cursor: pointer; padding: 6px; border-radius: 6px; }
.collapse-btn:hover { color: #fff; background: rgba(255,255,255,.06); }

body.sb-collapsed .sidebar { width: var(--sidebar-w-collapsed); }
body.sb-collapsed .brand-text,
body.sb-collapsed .nav-label,
body.sb-collapsed .nav-item span,
body.sb-collapsed .nav-item .count,
body.sb-collapsed .sidebar-user .who { display: none; }
body.sb-collapsed .nav-item { justify-content: center; padding: 0; }
body.sb-collapsed .sidebar-head { padding: 0; justify-content: center; }
body.sb-collapsed .sidebar-user { justify-content: center; flex-direction: column; }
body.sb-collapsed .collapse-btn { margin: 0; transform: rotate(180deg); }
body.sb-collapsed .nav-group { margin-top: 8px; border-top: 1px solid rgba(255,255,255,.06); padding-top: 8px; }
body.sb-collapsed .nav-group:first-child { border: 0; padding-top: 0; }

.main { flex: 1; min-width: 0; margin-left: var(--sidebar-w); transition: margin .18s ease; }
body.sb-collapsed .main { margin-left: var(--sidebar-w-collapsed); }

.topbar {
  position: sticky; top: 26px; z-index: 30; height: var(--topbar-h);
  display: flex; align-items: center; gap: 14px; padding: 0 28px;
  background: rgba(255,255,255,.86); backdrop-filter: saturate(1.4) blur(10px);
  border-bottom: 1px solid var(--line);
}
.topbar .menu-btn { display: none; }
.crumbs { display: flex; align-items: center; gap: 6px; font-size: 13px; color: var(--ink-3); min-width: 0; white-space: nowrap; overflow: hidden; }
.crumbs a { color: var(--ink-3); }
.crumbs b { color: var(--ink); font-weight: 600; overflow: hidden; text-overflow: ellipsis; }
.crumbs svg { width: 14px; height: 14px; opacity: .5; flex: none; }
.topbar-search { margin-left: auto; position: relative; width: 320px; max-width: 34vw; }
.topbar-search input {
  width: 100%; height: 36px; padding: 0 12px 0 36px; border-radius: 9px;
  border: 1px solid var(--line); background: var(--bg-2); font-size: 13px; outline: none;
}
.topbar-search input:focus { border-color: var(--teal-400); background: #fff; box-shadow: 0 0 0 3px var(--teal-50); }
.topbar-search > svg { position: absolute; left: 11px; top: 10px; width: 16px; height: 16px; color: var(--ink-4); }
.topbar-search kbd { position: absolute; right: 9px; top: 8px; font-family: var(--font); font-size: 11px; color: var(--ink-4); border: 1px solid var(--line); border-radius: 5px; padding: 0 5px; background: #fff; }
.search-results { position: absolute; top: 42px; left: 0; right: 0; background: #fff; border: 1px solid var(--line); border-radius: 12px; box-shadow: var(--shadow-lg); padding: 6px; display: none; max-height: 380px; overflow: auto; }
.search-results.open { display: block; }
.search-results a { display: flex; align-items: center; gap: 10px; padding: 8px; border-radius: 8px; color: var(--ink); text-decoration: none; }
.search-results a:hover, .search-results a.hl { background: var(--bg); }
.search-results .sr-meta { font-size: 12px; color: var(--ink-3); }
.search-results .sr-empty { padding: 14px; color: var(--ink-3); font-size: 13px; text-align: center; }
.topbar-actions { display: flex; align-items: center; gap: 4px; }
.icon-btn {
  position: relative; width: 36px; height: 36px; border-radius: 9px; border: 0; background: none;
  display: inline-grid; place-items: center; cursor: pointer; color: var(--ink-2);
}
.icon-btn:hover { background: var(--bg); color: var(--ink); }
.icon-btn svg { width: 18px; height: 18px; }
.icon-btn .pip { position: absolute; top: 7px; right: 8px; width: 8px; height: 8px; border-radius: 50%; background: #E0484C; border: 2px solid #fff; }

.page { padding: 28px; max-width: 1480px; margin: 0 auto; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 20px; margin-bottom: 22px; flex-wrap: wrap; }
.page-head .sub { color: var(--ink-3); margin-top: 4px; font-size: 13.5px; }
.page-head .actions { display: flex; gap: 8px; flex-wrap: wrap; }
.eyebrow { font-size: 11px; font-weight: 600; letter-spacing: .09em; text-transform: uppercase; color: var(--ink-3); }

/* ---------- Dropdown / popover ---------- */
.dropdown { position: relative; }
.menu {
  position: absolute; right: 0; top: calc(100% + 6px); z-index: 50; min-width: 220px;
  background: #fff; border: 1px solid var(--line); border-radius: 12px; box-shadow: var(--shadow-lg);
  padding: 6px; display: none;
}
.menu.open { display: block; animation: pop .12s ease-out; }
.menu.left { left: 0; right: auto; }
.menu-item { display: flex; align-items: center; gap: 10px; width: 100%; padding: 8px 10px; border-radius: 8px; border: 0; background: none; text-align: left; cursor: pointer; color: var(--ink); font-size: 13px; text-decoration: none !important; }
.menu-item:hover { background: var(--bg); }
.menu-item svg { width: 16px; height: 16px; color: var(--ink-3); }
.menu-sep { height: 1px; background: var(--line); margin: 6px 0; }
.menu-head { padding: 8px 10px 6px; font-size: 11px; font-weight: 600; letter-spacing: .08em; text-transform: uppercase; color: var(--ink-4); }
@keyframes pop { from { opacity: 0; transform: translateY(-4px); } to { opacity: 1; transform: none; } }

.notif-panel { width: 380px; padding: 0; }
.notif-panel .np-head { display: flex; align-items: center; justify-content: space-between; padding: 14px 16px; border-bottom: 1px solid var(--line); }
.notif-panel .np-list { max-height: 420px; overflow: auto; }
.notif { display: flex; gap: 12px; padding: 12px 16px; border-bottom: 1px solid var(--line-2); cursor: pointer; }
.notif:hover { background: var(--bg-2); }
.notif.unread { background: #FBFDFF; }
.notif.unread .n-title::after { content: ''; display: inline-block; width: 7px; height: 7px; border-radius: 50%; background: var(--accent); margin-left: 6px; vertical-align: middle; }
.notif .n-ico { width: 32px; height: 32px; border-radius: 8px; display: grid; place-items: center; flex: none; background: var(--bg); color: var(--ink-2); }
.notif .n-ico svg { width: 16px; height: 16px; }
.notif .n-title { font-size: 13px; font-weight: 500; }
.notif .n-time { font-size: 11.5px; color: var(--ink-4); margin-top: 2px; }

/* ---------- Cards ---------- */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); box-shadow: var(--shadow-sm); }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 16px 20px 0; flex-wrap: wrap; }
.card-head .sub { font-size: 12.5px; color: var(--ink-3); margin-top: 2px; }
.card-body { padding: 16px 20px 20px; }
.card-foot { padding: 12px 20px; border-top: 1px solid var(--line-2); display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.card.flat { box-shadow: none; }
.card.pad { padding: 20px; }
.card-link { font-size: 12.5px; font-weight: 500; display: inline-flex; align-items: center; gap: 4px; }
.card-link svg { width: 14px; height: 14px; }
.section-title { display: flex; align-items: center; justify-content: space-between; margin: 26px 0 12px; }
.section-title h2 { font-size: 15px; }

/* ---------- Grid ---------- */
.grid { display: grid; gap: 16px; }
.g-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.g-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.g-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.g-5 { grid-template-columns: repeat(5, minmax(0, 1fr)); }
.g-6 { grid-template-columns: repeat(6, minmax(0, 1fr)); }
.g-main { grid-template-columns: minmax(0, 2fr) minmax(0, 1fr); }
.g-main-r { grid-template-columns: minmax(0, 1fr) minmax(0, 2fr); }
.g-side { grid-template-columns: 320px minmax(0, 1fr); }
.span-2 { grid-column: span 2; }
.span-3 { grid-column: span 3; }
.stack { display: flex; flex-direction: column; gap: 16px; }
.stack-sm { display: flex; flex-direction: column; gap: 8px; }
.row { display: flex; align-items: center; gap: 10px; }
.row-sb { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.wrap { flex-wrap: wrap; }
.grow { flex: 1; min-width: 0; }
.mt-4 { margin-top: 4px; } .mt-8 { margin-top: 8px; } .mt-12 { margin-top: 12px; } .mt-16 { margin-top: 16px; } .mt-24 { margin-top: 24px; }
.mb-8 { margin-bottom: 8px; } .mb-12 { margin-bottom: 12px; } .mb-16 { margin-bottom: 16px; }
.muted { color: var(--ink-3); }
.small { font-size: 12.5px; }
.xs { font-size: 11.5px; }
.strong { font-weight: 600; }
.right { text-align: right; }
.center { text-align: center; }
.nowrap { white-space: nowrap; }
.hidden { display: none !important; }
.num { font-variant-numeric: tabular-nums; }

/* ---------- KPI ---------- */
.kpi { padding: 16px 18px; display: flex; flex-direction: column; gap: 6px; position: relative; overflow: hidden; }
.kpi-label { font-size: 12.5px; color: var(--ink-3); font-weight: 500; display: flex; align-items: center; gap: 7px; }
.kpi-label svg { width: 15px; height: 15px; color: var(--ink-4); }
.kpi-value { font-size: 26px; font-weight: 600; letter-spacing: -0.02em; line-height: 1.15; font-variant-numeric: tabular-nums; }
.kpi-value small { font-size: 14px; font-weight: 500; color: var(--ink-3); margin-left: 2px; }
.kpi-foot { font-size: 12px; color: var(--ink-3); display: flex; align-items: center; gap: 6px; }
.kpi .spark { position: absolute; right: 14px; bottom: 14px; width: 86px; height: 30px; }
a.kpi { color: inherit; text-decoration: none !important; transition: border-color .15s; }
a.kpi:hover { border-color: #CBD2DD; }
.delta { font-weight: 600; font-size: 12px; display: inline-flex; align-items: center; gap: 2px; }
.delta.up { color: var(--ok); } .delta.down { color: var(--bad); } .delta.flat { color: var(--ink-3); }
.delta svg { width: 13px; height: 13px; }

.kpi-strip { display: grid; grid-template-columns: repeat(6, minmax(0,1fr)); }
.kpi-strip .kpi { border-right: 1px solid var(--line-2); }
.kpi-strip .kpi:last-child { border-right: 0; }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  height: 36px; padding: 0 14px; border-radius: 9px; border: 1px solid var(--line);
  background: #fff; color: var(--ink); font-size: 13px; font-weight: 500; cursor: pointer;
  white-space: nowrap; text-decoration: none !important; transition: background .12s, border-color .12s, box-shadow .12s;
  box-shadow: var(--shadow-sm);
}
.btn:hover { background: var(--bg-2); border-color: #D3D8E1; }
.btn:focus-visible { outline: none; box-shadow: 0 0 0 3px var(--teal-100); }
.btn svg { width: 16px; height: 16px; }
.btn-primary { background: var(--navy-800); border-color: var(--navy-800); color: #fff; }
.btn-primary:hover { background: var(--navy-700); border-color: var(--navy-700); }
.btn-accent { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn-accent:hover { filter: brightness(1.06); background: var(--accent); }
.btn-ok { background: var(--ok); border-color: var(--ok); color: #fff; }
.btn-ok:hover { background: #0E6A49; }
.btn-danger { color: var(--bad); }
.btn-danger:hover { background: var(--bad-bg); border-color: #F3C7C2; }
.btn-danger-solid { background: var(--bad); border-color: var(--bad); color: #fff; }
.btn-ghost { background: none; border-color: transparent; box-shadow: none; }
.btn-ghost:hover { background: var(--bg); border-color: transparent; }
.btn-sm { height: 30px; padding: 0 10px; font-size: 12.5px; border-radius: 8px; }
.btn-sm svg { width: 14px; height: 14px; }
.btn-lg { height: 44px; padding: 0 20px; font-size: 14px; border-radius: 10px; }
.btn-block { width: 100%; }
.btn[disabled], .btn.disabled { opacity: .5; pointer-events: none; }
.btn-group { display: inline-flex; border: 1px solid var(--line); border-radius: 9px; padding: 2px; background: var(--bg); gap: 2px; }
.btn-group button { border: 0; background: none; height: 30px; padding: 0 12px; border-radius: 7px; font-size: 12.5px; font-weight: 500; color: var(--ink-3); cursor: pointer; }
.btn-group button.active { background: #fff; color: var(--ink); box-shadow: var(--shadow); }
.btn-group button:hover:not(.active) { color: var(--ink); }

/* ---------- Badges / chips ---------- */
.badge {
  display: inline-flex; align-items: center; gap: 5px; height: 22px; padding: 0 8px;
  border-radius: 6px; font-size: 11.5px; font-weight: 600; white-space: nowrap;
  background: var(--muted-bg); color: var(--muted);
}
.badge .bd { width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.badge.ok { background: var(--ok-bg); color: var(--ok); }
.badge.warn { background: var(--warn-bg); color: var(--warn); }
.badge.bad { background: var(--bad-bg); color: var(--bad); }
.badge.info { background: var(--info-bg); color: var(--info); }
.badge.teal { background: var(--teal-50); color: var(--teal-700); }
.badge.violet { background: var(--violet-50); color: var(--violet-600); }
.badge.navy { background: var(--navy-800); color: #fff; }
.badge.outline { background: #fff; border: 1px solid var(--line); color: var(--ink-2); }
.badge.lg { height: 26px; padding: 0 10px; font-size: 12px; }
.sub-pill { display: inline-grid; place-items: center; min-width: 26px; height: 20px; padding: 0 5px; border-radius: 5px; font-size: 11px; font-weight: 700; letter-spacing: .02em; }
.sub-pill.S1 { background: #EEF0FD; color: #4338CA; }
.sub-pill.S2 { background: var(--teal-50); color: var(--teal-700); }
.sub-pill.S3 { background: #FDF0E6; color: #B45309; }
.sub-pill.off { background: var(--muted-bg); color: var(--ink-4); text-decoration: line-through; }
.chip { display: inline-flex; align-items: center; gap: 6px; height: 30px; padding: 0 12px; border-radius: 15px; border: 1px solid var(--line); background: #fff; font-size: 12.5px; font-weight: 500; cursor: pointer; color: var(--ink-2); }
.chip:hover { border-color: #CBD2DD; }
.chip.active { background: var(--navy-800); color: #fff; border-color: var(--navy-800); }
.chip .c { font-size: 11px; opacity: .7; }
.chips { display: flex; gap: 6px; flex-wrap: wrap; }
.tag { display: inline-flex; align-items: center; height: 22px; padding: 0 8px; border-radius: 5px; background: var(--bg); border: 1px solid var(--line); font-size: 11.5px; color: var(--ink-2); font-weight: 500; }
.code-tag { font-family: var(--mono); font-size: 11px; color: var(--ink-3); background: var(--bg); border: 1px solid var(--line); padding: 1px 6px; border-radius: 5px; white-space: nowrap; }

/* ---------- Avatar ---------- */
.avatar { width: 34px; height: 34px; border-radius: 50%; flex: none; display: grid; place-items: center; font-size: 12px; font-weight: 600; color: #fff; background: var(--navy-600); letter-spacing: .02em; }
.avatar.sm { width: 28px; height: 28px; font-size: 11px; }
.avatar.lg { width: 56px; height: 56px; font-size: 18px; }
.avatar.xl { width: 72px; height: 72px; font-size: 22px; }
.avatar.c1 { background: #2B5A8A; } .avatar.c2 { background: #0E8577; } .avatar.c3 { background: #6B4FBB; }
.avatar.c4 { background: #B4573E; } .avatar.c5 { background: #3D6B4F; } .avatar.c6 { background: #8A6A2B; }
.person { display: flex; align-items: center; gap: 10px; min-width: 0; }
.person .pn { font-weight: 600; font-size: 13.5px; color: var(--ink); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.person .pm { font-size: 12px; color: var(--ink-3); white-space: nowrap; }
a.person:hover .pn { color: var(--accent); }
a.person { text-decoration: none !important; }

/* ---------- Tables ---------- */
.table-wrap { overflow-x: auto; }
table.tbl { width: 100%; border-collapse: separate; border-spacing: 0; font-size: 13px; }
.tbl th {
  text-align: left; font-weight: 500; font-size: 12px; color: var(--ink-3); white-space: nowrap;
  padding: 10px 14px; background: var(--bg-2); border-bottom: 1px solid var(--line); position: sticky; top: 0;
}
.tbl th.sortable { cursor: pointer; user-select: none; }
.tbl th.sortable:hover { color: var(--ink); }
.tbl th .sort-ind { display: inline-block; margin-left: 4px; opacity: .35; font-size: 10px; }
.tbl th.sorted .sort-ind { opacity: 1; color: var(--accent); }
.tbl td { padding: 11px 14px; border-bottom: 1px solid var(--line-2); vertical-align: middle; }
.tbl tbody tr { transition: background .1s; }
.tbl tbody tr:hover { background: #FAFBFD; }
.tbl tbody tr.clickable { cursor: pointer; }
.tbl tbody tr:last-child td { border-bottom: 0; }
.tbl.compact td { padding: 8px 14px; }
.tbl .num { text-align: right; }
.tbl-toolbar { display: flex; align-items: center; gap: 10px; padding: 14px 16px; border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.tbl-foot { display: flex; align-items: center; justify-content: space-between; padding: 12px 16px; border-top: 1px solid var(--line); font-size: 12.5px; color: var(--ink-3); flex-wrap: wrap; gap: 10px; }
.pager { display: flex; gap: 4px; align-items: center; }
.pager button { min-width: 30px; height: 30px; border-radius: 7px; border: 1px solid var(--line); background: #fff; font-size: 12.5px; cursor: pointer; color: var(--ink-2); padding: 0 8px; }
.pager button.active { background: var(--navy-800); color: #fff; border-color: var(--navy-800); }
.pager button:disabled { opacity: .4; cursor: default; }
.empty { padding: 40px 20px; text-align: center; color: var(--ink-3); }
.empty svg { width: 28px; height: 28px; margin: 0 auto 10px; color: var(--ink-4); }

/* ---------- Forms ---------- */
.field { display: flex; flex-direction: column; gap: 6px; }
.field label, .label { font-size: 12.5px; font-weight: 500; color: var(--ink-2); }
.field .hint { font-size: 12px; color: var(--ink-3); }
.input, .select, .textarea {
  height: 36px; padding: 0 12px; border-radius: 9px; border: 1px solid var(--line); background: #fff;
  font-size: 13px; outline: none; width: 100%; transition: border-color .12s, box-shadow .12s;
}
.textarea { height: auto; min-height: 90px; padding: 10px 12px; resize: vertical; line-height: 1.5; }
.select { appearance: none; padding-right: 32px; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%236B778C' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 11px center; cursor: pointer; }
.input:focus, .select:focus, .textarea:focus { border-color: var(--teal-400); box-shadow: 0 0 0 3px var(--teal-50); }
.input.sm, .select.sm { height: 32px; font-size: 12.5px; }
.input-icon { position: relative; }
.input-icon svg { position: absolute; left: 11px; top: 50%; transform: translateY(-50%); width: 15px; height: 15px; color: var(--ink-4); pointer-events: none; }
.input-icon .input { padding-left: 34px; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0,1fr)); gap: 14px 16px; }
.form-grid .full { grid-column: 1 / -1; }
.check { display: flex; align-items: flex-start; gap: 10px; cursor: pointer; font-size: 13px; }
.check input { width: 16px; height: 16px; margin: 2px 0 0; accent-color: var(--teal-600); flex: none; }

.toggle { position: relative; width: 40px; height: 23px; flex: none; display: inline-block; }
.toggle input { opacity: 0; width: 0; height: 0; position: absolute; }
.toggle .tr { position: absolute; inset: 0; border-radius: 12px; background: #D4D9E2; transition: background .16s; cursor: pointer; }
.toggle .tr::after { content: ''; position: absolute; top: 3px; left: 3px; width: 17px; height: 17px; border-radius: 50%; background: #fff; box-shadow: 0 1px 2px rgba(0,0,0,.2); transition: transform .16s; }
.toggle input:checked + .tr { background: var(--teal-500); }
.toggle input:checked + .tr::after { transform: translateX(17px); }
.toggle input:focus-visible + .tr { box-shadow: 0 0 0 3px var(--teal-100); }
.toggle input:disabled + .tr { opacity: .5; cursor: not-allowed; }

.seg { display: inline-flex; border-radius: 9px; background: var(--bg); padding: 3px; border: 1px solid var(--line); }
.seg label { cursor: pointer; }
.seg input { display: none; }
.seg span { display: inline-block; padding: 5px 12px; border-radius: 7px; font-size: 12.5px; font-weight: 500; color: var(--ink-3); }
.seg input:checked + span { background: #fff; color: var(--ink); box-shadow: var(--shadow); }

/* ---------- Tabs ---------- */
.tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--line); overflow-x: auto; scrollbar-width: none; }
.tabs::-webkit-scrollbar { display: none; }
.tab {
  position: relative; padding: 11px 14px; font-size: 13px; font-weight: 500; color: var(--ink-3);
  background: none; border: 0; cursor: pointer; white-space: nowrap; display: inline-flex; gap: 6px; align-items: center;
}
.tab:hover { color: var(--ink); }
.tab.active { color: var(--ink); }
.tab.active::after { content: ''; position: absolute; left: 10px; right: 10px; bottom: -1px; height: 2px; background: var(--accent); border-radius: 2px 2px 0 0; }
.tab .count { font-size: 11px; background: var(--bg); color: var(--ink-3); border-radius: 9px; padding: 0 6px; }
.tab-panel { display: none; }
.tab-panel.active { display: block; animation: fade .15s ease-out; }
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }

/* ---------- Modal ---------- */
.modal-back { position: fixed; inset: 0; z-index: 100; background: rgba(11, 22, 48, .42); backdrop-filter: blur(2px); display: grid; place-items: center; padding: 20px; animation: fade .15s; }
.modal { width: 560px; max-width: 100%; max-height: calc(100vh - 40px); background: #fff; border-radius: 16px; box-shadow: var(--shadow-lg); display: flex; flex-direction: column; animation: rise .18s ease-out; }
.modal.lg { width: 820px; }
.modal.sm { width: 420px; }
.modal-head { padding: 20px 22px 0; display: flex; justify-content: space-between; gap: 12px; align-items: flex-start; }
.modal-head .sub { color: var(--ink-3); font-size: 13px; margin-top: 4px; }
.modal-body { padding: 18px 22px; overflow-y: auto; }
.modal-foot { padding: 14px 22px; border-top: 1px solid var(--line); display: flex; justify-content: flex-end; gap: 8px; background: var(--bg-2); border-radius: 0 0 16px 16px; }
@keyframes rise { from { opacity: 0; transform: translateY(10px) scale(.98); } to { opacity: 1; transform: none; } }

/* ---------- Toast ---------- */
.toasts { position: fixed; right: 20px; bottom: 20px; z-index: 200; display: flex; flex-direction: column; gap: 8px; }
.toast {
  min-width: 280px; max-width: 400px; padding: 12px 14px; border-radius: 12px; background: var(--navy-900); color: #fff;
  box-shadow: var(--shadow-lg); display: flex; gap: 10px; align-items: flex-start; font-size: 13px; animation: rise .2s ease-out;
}
.toast svg { width: 18px; height: 18px; flex: none; margin-top: 1px; }
.toast.ok svg { color: #5FD3A6; } .toast.warn svg { color: #F2B544; } .toast.bad svg { color: #F58A84; } .toast.info svg { color: #8FB3FF; }
.toast .t-sub { color: #A8B4CC; font-size: 12px; margin-top: 2px; }
.toast.out { opacity: 0; transform: translateY(6px); transition: all .2s; }

/* ---------- Callouts ---------- */
.callout { display: flex; gap: 12px; padding: 12px 14px; border-radius: 10px; border: 1px solid var(--line); background: var(--bg-2); font-size: 13px; color: var(--ink-2); }
.callout > svg { width: 18px; height: 18px; flex: none; margin-top: 1px; }
.callout b { color: var(--ink); }
.callout.info { background: var(--info-bg); border-color: #D2DEF8; } .callout.info > svg { color: var(--info); }
.callout.warn { background: var(--warn-bg); border-color: #F4DDB9; } .callout.warn > svg { color: var(--warn); }
.callout.bad { background: var(--bad-bg); border-color: #F4CCC7; } .callout.bad > svg { color: var(--bad); }
.callout.ok { background: var(--ok-bg); border-color: #C6E6D6; } .callout.ok > svg { color: var(--ok); }
.callout.navy { background: var(--navy-900); color: #C9D3E6; border-color: var(--navy-900); }
.callout.navy b { color: #fff; } .callout.navy > svg { color: var(--teal-400); }

.locked {
  border: 1px dashed #C8CFDB; border-radius: var(--r-lg); padding: 18px; background:
  repeating-linear-gradient(135deg, #FAFBFC 0 8px, #F4F6F9 8px 16px);
  display: flex; gap: 14px; align-items: flex-start;
}
.locked .lk { width: 36px; height: 36px; border-radius: 9px; background: #fff; border: 1px solid var(--line); display: grid; place-items: center; flex: none; }
.locked .lk svg { width: 17px; height: 17px; color: var(--ink-3); }
.locked h3 { font-size: 13.5px; }
.locked p { font-size: 12.5px; color: var(--ink-3); margin-top: 3px; }
.class-tag { display: inline-flex; align-items: center; gap: 5px; font-size: 10.5px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; padding: 2px 7px; border-radius: 4px; }
.class-tag.a { background: var(--ok-bg); color: var(--ok); }
.class-tag.b { background: #EEF0F4; color: var(--ink-3); }
.class-tag.nd { background: var(--info-bg); color: var(--info); }

.awaiting { font-style: italic; color: var(--ink-3); background: var(--bg); border: 1px dashed var(--line); border-radius: 8px; padding: 8px 12px; font-size: 12.5px; display: inline-flex; gap: 8px; align-items: center; }
.awaiting svg { width: 14px; height: 14px; }

/* ---------- Lists ---------- */
.list { display: flex; flex-direction: column; }
.list-item { display: flex; align-items: center; gap: 12px; padding: 12px 0; border-bottom: 1px solid var(--line-2); }
.list-item:last-child { border-bottom: 0; padding-bottom: 0; }
.list-item:first-child { padding-top: 0; }
.li-ico { width: 34px; height: 34px; border-radius: 9px; display: grid; place-items: center; flex: none; background: var(--bg); color: var(--ink-2); }
.li-ico svg { width: 17px; height: 17px; }
.li-ico.teal { background: var(--teal-50); color: var(--teal-700); }
.li-ico.violet { background: var(--violet-50); color: var(--violet-600); }
.li-ico.warn { background: var(--warn-bg); color: var(--warn); }
.li-ico.bad { background: var(--bad-bg); color: var(--bad); }
.li-ico.ok { background: var(--ok-bg); color: var(--ok); }
.li-ico.info { background: var(--info-bg); color: var(--info); }
.li-title { font-size: 13.5px; font-weight: 500; }
.li-sub { font-size: 12px; color: var(--ink-3); }

.dl { display: grid; grid-template-columns: 150px 1fr; gap: 10px 16px; font-size: 13px; }
.dl dt { color: var(--ink-3); }
.dl dd { margin: 0; color: var(--ink); }
.dl.tight { grid-template-columns: 120px 1fr; gap: 6px 12px; }
.kv { display: flex; justify-content: space-between; gap: 12px; padding: 8px 0; border-bottom: 1px solid var(--line-2); font-size: 13px; }
.kv:last-child { border-bottom: 0; }
.kv span:first-child { color: var(--ink-3); }
.kv span:last-child { font-weight: 500; text-align: right; }

/* ---------- Timeline ---------- */
.timeline { position: relative; padding-left: 22px; }
.timeline::before { content: ''; position: absolute; left: 6px; top: 6px; bottom: 6px; width: 2px; background: var(--line); border-radius: 2px; }
.tl-item { position: relative; padding-bottom: 18px; }
.tl-item:last-child { padding-bottom: 0; }
.tl-dot { position: absolute; left: -22px; top: 3px; width: 14px; height: 14px; border-radius: 50%; background: #fff; border: 2px solid var(--ink-4); }
.tl-dot.teal { border-color: var(--teal-500); background: var(--teal-500); box-shadow: 0 0 0 3px var(--teal-50); }
.tl-dot.violet { border-color: var(--violet-600); }
.tl-dot.warn { border-color: var(--warn); }
.tl-dot.bad { border-color: var(--bad); }
.tl-dot.ok { border-color: var(--ok); }
.tl-dot.info { border-color: var(--info); }
.tl-time { font-size: 11.5px; color: var(--ink-4); font-weight: 500; }
.tl-title { font-size: 13.5px; font-weight: 500; margin-top: 1px; }
.tl-body { font-size: 12.5px; color: var(--ink-3); margin-top: 2px; }

/* ---------- Stepper / journey ---------- */
.stepper { display: flex; align-items: flex-start; gap: 0; overflow-x: auto; padding: 4px 2px 8px; }
.step { flex: 1; min-width: 104px; display: flex; flex-direction: column; align-items: center; text-align: center; position: relative; }
.step::before { content: ''; position: absolute; top: 15px; left: -50%; right: 50%; height: 2px; background: var(--line); z-index: 0; }
.step:first-child::before { display: none; }
.step.done::before, .step.current::before { background: var(--teal-500); }
.step .sc { width: 32px; height: 32px; border-radius: 50%; display: grid; place-items: center; background: #fff; border: 2px solid var(--line); z-index: 1; font-size: 12px; font-weight: 600; color: var(--ink-4); }
.step .sc svg { width: 15px; height: 15px; }
.step.done .sc { background: var(--teal-500); border-color: var(--teal-500); color: #fff; }
.step.current .sc { border-color: var(--teal-500); color: var(--teal-600); box-shadow: 0 0 0 5px var(--teal-50); }
.step .sl { font-size: 12px; font-weight: 500; margin-top: 8px; color: var(--ink-3); padding: 0 4px; }
.step.done .sl, .step.current .sl { color: var(--ink); }
.step .sd { font-size: 11px; color: var(--ink-4); margin-top: 2px; }

.loop { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.loop .ls { padding: 6px 12px; border-radius: 8px; border: 1px solid var(--line); background: #fff; font-size: 12.5px; font-weight: 500; color: var(--ink-3); }
.loop .ls.on { background: var(--navy-800); color: #fff; border-color: var(--navy-800); }
.loop svg { width: 14px; height: 14px; color: var(--ink-4); }

/* ---------- Progress ---------- */
.progress { height: 8px; border-radius: 4px; background: var(--line-2); overflow: hidden; }
.progress > i { display: block; height: 100%; background: var(--teal-500); border-radius: 4px; }
.progress.sm { height: 5px; }
.progress.violet > i { background: var(--violet-600); }
.progress.warn > i { background: #E3A13B; }

.tir-bar { display: flex; height: 10px; border-radius: 5px; overflow: hidden; gap: 2px; }
.tir-bar > i { display: block; height: 100%; }
.tir-legend { display: flex; flex-wrap: wrap; gap: 4px 14px; font-size: 12px; color: var(--ink-3); }
.tir-legend span { display: inline-flex; align-items: center; gap: 6px; }
.tir-legend i { width: 9px; height: 9px; border-radius: 2px; display: inline-block; }

/* ---------- Charts ---------- */
.chart { position: relative; width: 100%; }
.chart svg { width: 100%; height: 100%; overflow: visible; }
.chart .ax text { font-size: 11px; fill: var(--ink-4); font-family: var(--font); }
.chart .grid line { stroke: var(--line-2); }
.chart-tip {
  position: absolute; pointer-events: none; z-index: 5; background: var(--navy-900); color: #fff; border-radius: 8px;
  padding: 8px 10px; font-size: 12px; line-height: 1.4; box-shadow: var(--shadow-lg); white-space: nowrap; opacity: 0; transition: opacity .1s;
}
.chart-tip.on { opacity: 1; }
.chart-tip .tt { color: #A8B4CC; font-size: 11px; }
.chart-tip .tv { font-weight: 600; font-size: 13px; }
.chart-legend { display: flex; gap: 14px; flex-wrap: wrap; font-size: 12px; color: var(--ink-3); }
.chart-legend span { display: inline-flex; align-items: center; gap: 6px; }
.chart-legend i { width: 10px; height: 3px; border-radius: 2px; display: inline-block; }
.chart-legend i.sq { width: 10px; height: 10px; border-radius: 3px; }
.demo-label { display: inline-flex; align-items: center; gap: 5px; font-size: 10.5px; font-weight: 600; text-transform: uppercase; letter-spacing: .07em; color: var(--warn); background: var(--warn-bg); padding: 2px 7px; border-radius: 4px; }

/* ---------- Misc components ---------- */
.stat-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); gap: 0; border: 1px solid var(--line); border-radius: var(--r); overflow: hidden; background: #fff; }
.stat-row > div { padding: 12px 14px; border-right: 1px solid var(--line-2); }
.stat-row > div:last-child { border-right: 0; }
.stat-row .sv { font-size: 18px; font-weight: 600; font-variant-numeric: tabular-nums; letter-spacing: -0.01em; }
.stat-row .sl { font-size: 11.5px; color: var(--ink-3); }

.mini-cal { display: flex; gap: 6px; }
.mini-cal .d { flex: 1; text-align: center; padding: 8px 0; border-radius: 9px; border: 1px solid var(--line); background: #fff; cursor: pointer; }
.mini-cal .d .dw { font-size: 11px; color: var(--ink-3); }
.mini-cal .d .dn { font-size: 15px; font-weight: 600; }
.mini-cal .d.active { background: var(--navy-800); color: #fff; border-color: var(--navy-800); }
.mini-cal .d.active .dw { color: #A8B4CC; }

.appt { display: flex; gap: 14px; padding: 12px 0; border-bottom: 1px solid var(--line-2); align-items: center; }
.appt:last-child { border-bottom: 0; }
.appt .at { width: 62px; flex: none; }
.appt .at b { display: block; font-size: 13.5px; font-variant-numeric: tabular-nums; }
.appt .at span { font-size: 11.5px; color: var(--ink-3); }
.appt .bar { width: 3px; align-self: stretch; border-radius: 2px; background: var(--teal-500); }
.appt .bar.v { background: var(--violet-600); } .appt .bar.w { background: #E3A13B; }

.quick-actions { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; }
.qa { display: flex; flex-direction: column; gap: 10px; padding: 14px; border-radius: 12px; border: 1px solid var(--line); background: #fff; cursor: pointer; text-align: left; transition: border-color .12s, transform .12s; color: var(--ink); text-decoration: none !important; }
.qa:hover { border-color: var(--teal-400); }
.qa .qi { width: 32px; height: 32px; border-radius: 9px; display: grid; place-items: center; background: var(--teal-50); color: var(--teal-700); }
.qa .qi svg { width: 17px; height: 17px; }
.qa b { font-size: 13px; font-weight: 600; }
.qa span { font-size: 11.5px; color: var(--ink-3); margin-top: -6px; }

.split { display: grid; grid-template-columns: 360px minmax(0,1fr); border: 1px solid var(--line); border-radius: var(--r-lg); background: #fff; overflow: hidden; min-height: 640px; }
.split-list { border-right: 1px solid var(--line); display: flex; flex-direction: column; min-height: 0; }
.split-list .sl-head { padding: 14px; border-bottom: 1px solid var(--line); }
.split-list .sl-body { overflow-y: auto; flex: 1; }
.split-item { display: block; padding: 14px 16px; border-bottom: 1px solid var(--line-2); cursor: pointer; color: inherit; text-decoration: none !important; border-left: 3px solid transparent; }
.split-item:hover { background: var(--bg-2); }
.split-item.active { background: #F5FAF9; border-left-color: var(--teal-500); }
.split-detail { min-width: 0; display: flex; flex-direction: column; }

.decision-bar { position: sticky; bottom: 0; background: rgba(255,255,255,.96); backdrop-filter: blur(8px); border-top: 1px solid var(--line); padding: 14px 22px; display: flex; gap: 10px; align-items: center; justify-content: space-between; flex-wrap: wrap; }

.gantt { position: relative; }
.gantt-row { display: grid; grid-template-columns: 170px 1fr; align-items: center; min-height: 34px; border-bottom: 1px dashed var(--line-2); }
.gantt-row:last-child { border-bottom: 0; }
.gantt-label { font-size: 12.5px; font-weight: 500; color: var(--ink-2); padding-right: 10px; }
.gantt-track { position: relative; height: 34px; }
.gantt-bar { position: absolute; top: 9px; height: 16px; border-radius: 5px; background: var(--teal-100); border: 1px solid var(--teal-400); font-size: 10.5px; color: var(--teal-700); padding: 0 6px; display: flex; align-items: center; white-space: nowrap; overflow: hidden; font-weight: 600; }
.gantt-bar.v { background: var(--violet-50); border-color: #B8B1F2; color: var(--violet-600); }
.gantt-bar.w { background: var(--warn-bg); border-color: #EBC68C; color: var(--warn); }
.gantt-bar.n { background: #EEF2F8; border-color: #C9D3E3; color: var(--navy-600); }
.gantt-dot { position: absolute; top: 10px; width: 14px; height: 14px; margin-left: -7px; border-radius: 50%; background: var(--navy-800); border: 2px solid #fff; box-shadow: 0 0 0 1px var(--navy-800); }
.gantt-dot.teal { background: var(--teal-500); box-shadow: 0 0 0 1px var(--teal-500); }
.gantt-dot.diamond { border-radius: 2px; transform: rotate(45deg); background: var(--violet-600); box-shadow: 0 0 0 1px var(--violet-600); }
.gantt-axis { display: grid; grid-template-columns: 170px 1fr; }
.gantt-axis .ticks { position: relative; height: 22px; }
.gantt-axis .ticks span { position: absolute; transform: translateX(-50%); font-size: 11px; color: var(--ink-4); }
.gantt-now { position: absolute; top: 0; bottom: 0; width: 0; border-left: 2px dashed #E0484C; z-index: 2; }

.lifecycle { display: flex; align-items: center; gap: 0; overflow-x: auto; }
.lc-step { display: flex; align-items: center; gap: 6px; padding: 6px 10px; font-size: 12px; font-weight: 500; color: var(--ink-4); white-space: nowrap; }
.lc-step .n { width: 20px; height: 20px; border-radius: 50%; display: grid; place-items: center; font-size: 10.5px; border: 1.5px solid var(--line); font-weight: 600; }
.lc-step.done { color: var(--ink-2); }
.lc-step.done .n { background: var(--teal-500); border-color: var(--teal-500); color: #fff; }
.lc-step.cur { color: var(--ink); }
.lc-step.cur .n { border-color: var(--accent); color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.lc-arrow { width: 14px; height: 14px; color: var(--ink-4); flex: none; }

.check-list { display: grid; gap: 8px; }
.check-row { display: flex; gap: 10px; align-items: flex-start; font-size: 13px; padding: 10px 12px; border-radius: 9px; border: 1px solid var(--line); background: #fff; }
.check-row .ci { width: 20px; height: 20px; border-radius: 50%; display: grid; place-items: center; flex: none; }
.check-row .ci svg { width: 12px; height: 12px; }
.check-row.pass .ci { background: var(--ok-bg); color: var(--ok); }
.check-row.fail .ci { background: var(--bad-bg); color: var(--bad); }
.check-row.pend .ci { background: var(--muted-bg); color: var(--ink-4); }

.matrix { border-collapse: collapse; font-size: 12.5px; }
.matrix th, .matrix td { border: 1px solid var(--line); padding: 7px 10px; text-align: center; }
.matrix th { background: var(--bg-2); font-weight: 500; color: var(--ink-3); }
.matrix td.rl { text-align: left; font-weight: 500; color: var(--ink-2); }

.kdigo { display: grid; grid-template-columns: 90px repeat(3, 1fr); gap: 3px; font-size: 11.5px; }
.kdigo div { padding: 7px 6px; border-radius: 5px; text-align: center; }
.kdigo .kh { background: none; color: var(--ink-3); font-weight: 500; }
.kdigo .k-g { background: #DFF3E9; } .kdigo .k-y { background: #FCF0CF; } .kdigo .k-o { background: #FBDDC2; } .kdigo .k-r { background: #F7C9C4; }
.kdigo .here { outline: 2.5px solid var(--navy-800); outline-offset: -1px; font-weight: 700; color: var(--navy-900); }

.score-ring { position: relative; width: 120px; height: 120px; }
.score-ring .sr-c { position: absolute; inset: 0; display: grid; place-items: center; text-align: center; }
.score-ring .sr-v { font-size: 26px; font-weight: 600; letter-spacing: -0.02em; line-height: 1; }
.score-ring .sr-l { font-size: 11px; color: var(--ink-3); margin-top: 3px; }

.plan-card { border: 1px solid var(--line); border-radius: var(--r-lg); background: #fff; padding: 22px; display: flex; flex-direction: column; gap: 14px; position: relative; }
.plan-card.current { border-color: var(--teal-500); box-shadow: 0 0 0 3px var(--teal-50); }
.plan-card .pc-code { width: 44px; height: 44px; border-radius: 12px; display: grid; place-items: center; font-weight: 700; font-size: 15px; }
.plan-card ul { margin: 0; padding: 0; list-style: none; display: grid; gap: 8px; font-size: 13px; }
.plan-card li { display: flex; gap: 8px; align-items: flex-start; }
.plan-card li svg { width: 15px; height: 15px; color: var(--teal-600); flex: none; margin-top: 2px; }
.plan-ribbon { position: absolute; top: 16px; right: 16px; }

.integration { display: flex; flex-direction: column; gap: 12px; }
.int-logo { width: 42px; height: 42px; border-radius: 11px; display: grid; place-items: center; font-weight: 700; font-size: 13px; color: #fff; }

.status-dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; background: var(--ink-4); }
.status-dot.ok { background: #17A673; box-shadow: 0 0 0 3px #DDF3EA; }
.status-dot.warn { background: #E3A13B; box-shadow: 0 0 0 3px #FBEED7; }
.status-dot.bad { background: #E0484C; box-shadow: 0 0 0 3px #FBE0DF; }
.status-dot.off { background: #A7B0BF; box-shadow: 0 0 0 3px #EEF0F4; }

.board { display: grid; grid-template-columns: repeat(7, minmax(200px, 1fr)); gap: 12px; overflow-x: auto; padding-bottom: 6px; }
.board-col { background: var(--bg-2); border: 1px solid var(--line); border-radius: 12px; padding: 10px; display: flex; flex-direction: column; gap: 8px; min-height: 220px; }
.board-col h4 { display: flex; justify-content: space-between; font-size: 12px; color: var(--ink-3); padding: 2px 4px 6px; font-weight: 600; }
.board-card { background: #fff; border: 1px solid var(--line); border-radius: 9px; padding: 10px; font-size: 12.5px; cursor: pointer; box-shadow: var(--shadow-sm); }
.board-card:hover { border-color: #C9D0DB; }
.board-card .bc-t { font-weight: 500; line-height: 1.35; }
.board-card .bc-m { display: flex; justify-content: space-between; margin-top: 6px; color: var(--ink-4); font-size: 11.5px; }

/* ---------- Login ---------- */
.login-wrap { min-height: calc(100vh - 26px); display: grid; grid-template-columns: 1.05fr 1fr; }
.login-art { background: var(--navy-900); color: #C9D3E6; padding: 48px 56px; display: flex; flex-direction: column; position: relative; overflow: hidden; }
.login-art::after { content: ''; position: absolute; right: -180px; bottom: -180px; width: 520px; height: 520px; border-radius: 50%; border: 1px solid rgba(255,255,255,.06); box-shadow: 0 0 0 70px rgba(255,255,255,.015), 0 0 0 140px rgba(255,255,255,.012); }
.login-art h1 { color: #fff; font-size: 34px; line-height: 1.15; letter-spacing: -0.03em; font-weight: 600; margin-top: auto; max-width: 520px; }
.login-art .lead { font-size: 15px; color: #9AA7C2; max-width: 480px; margin-top: 16px; line-height: 1.6; }
.login-loop { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 28px; }
.login-loop span { font-size: 12px; color: #C9D3E6; border: 1px solid rgba(255,255,255,.12); border-radius: 20px; padding: 5px 12px; }
.login-panel { display: flex; align-items: center; justify-content: center; padding: 40px; background: #fff; }
.login-box { width: 100%; max-width: 460px; }
.role-card { display: flex; gap: 14px; align-items: center; padding: 16px; border-radius: 12px; border: 1px solid var(--line); background: #fff; cursor: pointer; transition: border-color .12s, box-shadow .12s; width: 100%; text-align: left; }
.role-card:hover { border-color: #C9D0DB; }
.role-card.active { border-color: var(--teal-500); box-shadow: 0 0 0 3px var(--teal-50); }
.role-card .ri { width: 42px; height: 42px; border-radius: 11px; display: grid; place-items: center; flex: none; }
.role-card .ri svg { width: 20px; height: 20px; }
.otp { display: flex; gap: 8px; }
.otp input { width: 46px; height: 50px; text-align: center; font-size: 20px; font-weight: 600; border-radius: 10px; border: 1px solid var(--line); outline: none; }
.otp input:focus { border-color: var(--teal-400); box-shadow: 0 0 0 3px var(--teal-50); }

/* =====================================================================
   PATIENT PORTAL — friendlier, app-like layer
   ===================================================================== */
body[data-portal="patient"] { background: #F4F6F7; font-size: 15px; }
body[data-portal="patient"] .main { margin-left: 0; }
.p-top { position: sticky; top: 26px; z-index: 30; background: rgba(255,255,255,.92); backdrop-filter: blur(10px); border-bottom: 1px solid var(--line); }
.p-top-in { max-width: 1180px; margin: 0 auto; height: 64px; display: flex; align-items: center; gap: 18px; padding: 0 24px; }
.p-top .brand { color: var(--navy-900); }
.p-top .brand-sub { color: var(--ink-3); }
.p-nav { display: flex; gap: 2px; margin-left: 18px; overflow-x: auto; scrollbar-width: none; }
.p-nav::-webkit-scrollbar { display: none; }
.p-nav a { padding: 8px 10px; border-radius: 9px; font-size: 13.5px; font-weight: 500; color: var(--ink-3); white-space: nowrap; text-decoration: none !important; }
.p-nav a:hover { color: var(--ink); background: var(--bg); }
.p-nav a.active { color: var(--teal-700); background: var(--teal-50); }
.p-top .right-tools { margin-left: auto; display: flex; align-items: center; gap: 6px; }
.profile-switch { display: flex; align-items: center; gap: 8px; padding: 4px 10px 4px 4px; border-radius: 22px; border: 1px solid var(--line); background: #fff; cursor: pointer; }
.profile-switch b { font-size: 13px; font-weight: 600; }
.p-page { max-width: 1180px; margin: 0 auto; padding: 28px 24px 100px; }
.p-hello { font-size: 26px; font-weight: 600; letter-spacing: -0.02em; }
.p-card { background: #fff; border: 1px solid var(--line); border-radius: 18px; padding: 22px; }
.p-card h2 { font-size: 17px; }
.p-card .p-sub { color: var(--ink-3); font-size: 14px; }
.p-headline { font-size: 40px; font-weight: 600; letter-spacing: -0.03em; line-height: 1; font-variant-numeric: tabular-nums; }
.p-headline small { font-size: 16px; color: var(--ink-3); font-weight: 500; letter-spacing: 0; }
.p-meaning { font-size: 14.5px; color: var(--ink-2); line-height: 1.55; }
.today-card { background: var(--navy-900); color: #DCE3F0; border-radius: 20px; padding: 24px; position: relative; overflow: hidden; }
.today-card::after { content: ''; position: absolute; right: -60px; top: -60px; width: 220px; height: 220px; border-radius: 50%; background: radial-gradient(circle, rgba(61,183,168,.22), transparent 70%); }
.today-card h2 { color: #fff; font-size: 20px; line-height: 1.35; max-width: 560px; font-weight: 600; }
.today-card .eyebrow { color: #7FD4C7; }
.today-card .btn { background: #fff; color: var(--navy-900); border-color: #fff; }
.today-card .btn-ghost { background: rgba(255,255,255,.08); color: #fff; border-color: transparent; }
.three-q { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
.three-q > div { background: #fff; border: 1px solid var(--line); border-radius: 16px; padding: 18px; }
.three-q .q { font-size: 12px; font-weight: 600; letter-spacing: .06em; text-transform: uppercase; color: var(--ink-4); }
.comp-row { display: grid; grid-template-columns: 1fr auto auto 20px; align-items: center; gap: 12px; padding: 14px 0; border-bottom: 1px solid var(--line-2); cursor: pointer; }
.comp-row:last-of-type { border-bottom: 0; }
.comp-row:hover .cr-name { color: var(--teal-700); }
.comp-row .cr-name { font-size: 15px; font-weight: 500; }
.comp-row svg { width: 16px; height: 16px; color: var(--ink-4); }
.state { font-size: 13px; font-weight: 600; padding: 3px 10px; border-radius: 12px; }
.state.stable { background: var(--ok-bg); color: var(--ok); }
.state.watch { background: var(--warn-bg); color: var(--warn); }
.state.attn { background: var(--bad-bg); color: var(--bad); }
.dir { font-size: 13px; color: var(--ink-3); display: inline-flex; align-items: center; gap: 4px; min-width: 64px; }
.dir svg { width: 14px; height: 14px; }
.gauge-wrap { display: flex; gap: 24px; align-items: center; }
.checkin { display: grid; gap: 14px; }
.checkin .ci-q { font-size: 14px; font-weight: 500; margin-bottom: 8px; }
.tap-row { display: flex; gap: 8px; flex-wrap: wrap; }
.tap { flex: 1; min-width: 88px; padding: 12px 10px; border-radius: 12px; border: 1px solid var(--line); background: #fff; cursor: pointer; font-size: 14px; font-weight: 500; text-align: center; }
.tap:hover { border-color: var(--teal-400); }
.tap.on { background: var(--teal-50); border-color: var(--teal-500); color: var(--teal-700); }
.sub-section { border-radius: 18px; border: 1px solid var(--line); background: #fff; overflow: hidden; }
.sub-section .ss-head { display: flex; align-items: center; gap: 12px; padding: 18px 22px; border-bottom: 1px solid var(--line-2); }
.sub-section .ss-body { padding: 22px; }
.p-bottom-nav { display: none; }
.journey-v { display: flex; flex-direction: column; }
.jv-step { display: grid; grid-template-columns: 44px 1fr; gap: 16px; }
.jv-rail { display: flex; flex-direction: column; align-items: center; }
.jv-dot { width: 36px; height: 36px; border-radius: 50%; display: grid; place-items: center; border: 2px solid var(--line); background: #fff; color: var(--ink-4); flex: none; }
.jv-dot svg { width: 17px; height: 17px; }
.jv-line { flex: 1; width: 2px; background: var(--line); min-height: 24px; }
.jv-step.done .jv-dot { background: var(--teal-500); border-color: var(--teal-500); color: #fff; }
.jv-step.done .jv-line { background: var(--teal-500); }
.jv-step.current .jv-dot { border-color: var(--teal-500); color: var(--teal-600); box-shadow: 0 0 0 6px var(--teal-50); }
.jv-content { padding: 6px 0 26px; }
.jv-content h3 { font-size: 16px; }
.jv-content .jv-meta { font-size: 13px; color: var(--ink-3); margin-top: 2px; }
.jv-content .jv-card { margin-top: 10px; background: #fff; border: 1px solid var(--line); border-radius: 14px; padding: 14px 16px; font-size: 14px; color: var(--ink-2); }
.jv-step.upcoming h3 { color: var(--ink-3); }

/* ---------- Responsive ---------- */
@media (max-width: 1280px) {
  .g-6 { grid-template-columns: repeat(3, minmax(0,1fr)); }
  .kpi-strip { grid-template-columns: repeat(3, minmax(0,1fr)); }
  .kpi-strip .kpi:nth-child(3n) { border-right: 0; }
  .kpi-strip .kpi:nth-child(-n+3) { border-bottom: 1px solid var(--line-2); }
  .board { grid-template-columns: repeat(7, 220px); }
}
@media (max-width: 1100px) {
  .g-4, .g-5 { grid-template-columns: repeat(2, minmax(0,1fr)); }
  .g-main, .g-main-r, .g-side { grid-template-columns: minmax(0,1fr); }
  .split { grid-template-columns: 300px minmax(0,1fr); }
  .login-wrap { grid-template-columns: 1fr; }
  .login-art { padding: 36px 28px; min-height: 300px; }
  .login-art h1 { font-size: 26px; margin-top: 40px; }
}
@media (max-width: 860px) {
  .sidebar { transform: translateX(-100%); width: var(--sidebar-w) !important; box-shadow: var(--shadow-lg); }
  body.sb-open .sidebar { transform: none; }
  body.sb-open::after { content: ''; position: fixed; inset: 0; background: rgba(11,22,48,.4); z-index: 35; }
  body.sb-collapsed .brand-text, body.sb-collapsed .nav-label, body.sb-collapsed .nav-item span, body.sb-collapsed .nav-item .count, body.sb-collapsed .sidebar-user .who { display: revert; }
  body.sb-collapsed .nav-item { justify-content: flex-start; padding: 0 10px; }
  .collapse-btn { display: none; }
  .main, body.sb-collapsed .main { margin-left: 0; }
  .topbar { padding: 0 16px; }
  .topbar .menu-btn { display: inline-grid; }
  .topbar-search { width: auto; flex: 1; max-width: none; }
  .topbar-search kbd { display: none; }
  .crumbs { display: none; }
  .page { padding: 18px 16px; }
  .g-2, .g-3, .g-4, .g-5, .g-6 { grid-template-columns: minmax(0,1fr); }
  .g-4.keep, .g-6.keep { grid-template-columns: repeat(2, minmax(0,1fr)); }
  .span-2, .span-3 { grid-column: auto; }
  .kpi-strip { grid-template-columns: repeat(2, minmax(0,1fr)); }
  .kpi-strip .kpi { border-right: 1px solid var(--line-2) !important; border-bottom: 1px solid var(--line-2); }
  .kpi-strip .kpi:nth-child(2n) { border-right: 0 !important; }
  .split { grid-template-columns: 1fr; }
  .split-list { max-height: 320px; border-right: 0; border-bottom: 1px solid var(--line); }
  .form-grid { grid-template-columns: 1fr; }
  .dl { grid-template-columns: 1fr; gap: 2px 0; }
  .dl dd { margin-bottom: 8px; }
  .modal { max-height: calc(100vh - 20px); }
  .gantt-row, .gantt-axis { grid-template-columns: 110px 1fr; }
  .notif-panel { width: calc(100vw - 32px); }
  h1 { font-size: 19px; }
  .p-nav { display: none; }
  .p-top-in { padding: 0 16px; }
  .p-page { padding: 18px 16px 110px; }
  .three-q { grid-template-columns: 1fr; }
  .p-bottom-nav { display: flex; position: fixed; left: 0; right: 0; bottom: 0; z-index: 40; background: #fff; border-top: 1px solid var(--line); padding: 6px 6px calc(6px + env(safe-area-inset-bottom)); justify-content: space-around; }
  .p-bottom-nav a { display: flex; flex-direction: column; align-items: center; gap: 2px; font-size: 10.5px; color: var(--ink-3); padding: 4px 6px; border-radius: 8px; text-decoration: none !important; min-width: 54px; }
  .p-bottom-nav a svg { width: 21px; height: 21px; }
  .p-bottom-nav a.active { color: var(--teal-600); }
  .profile-switch b { display: none; }
  .gauge-wrap { flex-direction: column; align-items: flex-start; }
  .toasts { left: 16px; right: 16px; bottom: 80px; }
  .toast { min-width: 0; max-width: none; }
}
@media print {
  .sidebar, .topbar, .proto-ribbon, .p-top, .p-bottom-nav { display: none !important; }
  .main { margin: 0 !important; }
}

/* 7-up metric strip */
.kpi-strip.k7 { grid-template-columns: repeat(7, minmax(0,1fr)); }
@media (max-width: 1280px) { .kpi-strip.k7 { grid-template-columns: repeat(4, minmax(0,1fr)); } .kpi-strip.k7 .kpi { border-bottom: 1px solid var(--line-2); } }
@media (max-width: 860px) { .kpi-strip.k7 { grid-template-columns: repeat(2, minmax(0,1fr)); } }

@media (max-width: 1240px) { .p-top .brand-sub { display: none; } .p-nav { margin-left: 4px; } .p-nav a { padding: 8px 7px; font-size: 13px; } .profile-switch b { display: none; } }
@media (max-width: 860px) { .proto-ribbon .hide-sm { display: none; } .split-detail .row-sb.wrap > .person { min-width: 0; } }

/* ===== Mobile refinements ===== */
.gl-sub { display: none; }
.chart svg rect, .chart svg path, .chart svg circle { touch-action: pan-y; }
@media (max-width: 860px) {
  /* Data tables become stacked cards */
  .tbl.cards-sm thead { display: none; }
  .tbl.cards-sm, .tbl.cards-sm tbody, .tbl.cards-sm tr, .tbl.cards-sm td { display: block; width: 100%; }
  .tbl.cards-sm tr { padding: 12px 14px; border-bottom: 1px solid var(--line); }
  .tbl.cards-sm tbody tr:last-child { border-bottom: 0; }
  .tbl.cards-sm td { border: 0; padding: 4px 0; display: flex; justify-content: space-between; align-items: center; gap: 12px; text-align: right; min-height: 26px; }
  .tbl.cards-sm td::before { content: attr(data-label); font-size: 11.5px; color: var(--ink-3); font-weight: 500; text-align: left; flex: none; max-width: 45%; }
  .tbl.cards-sm td:first-child { padding-bottom: 8px; margin-bottom: 4px; border-bottom: 1px dashed var(--line-2); text-align: left; }
  .tbl.cards-sm td:first-child::before { display: none; }
  .tbl.cards-sm td[data-label=""]::before { display: none; }
  .tbl.cards-sm td[data-label=""] { justify-content: flex-end; }
  .tbl.cards-sm td.num { text-align: right; }
  .tbl.cards-sm td .nowrap, .tbl.cards-sm td [style*="nowrap"] { white-space: normal; }
  .tbl.cards-sm td colspan, .tbl.cards-sm td .empty { width: 100%; }
  .tbl-toolbar .input-icon { width: 100% !important; max-width: none !important; flex: 1 1 100% !important; }
  .tbl-toolbar .select { flex: 1 1 45%; }
  .tbl-foot { justify-content: center; }

  /* Split-view headers: stack actions under the name */
  .split-detail > div:first-child > .row-sb { flex-direction: column; align-items: flex-start; }
  .split-detail > div:first-child .person { width: 100%; }
  .split-detail > div:first-child .person > div { min-width: 0; }
  .split-detail > div:first-child h2 { font-size: 16px !important; }
  .split-detail .pm { white-space: normal; }
  .split-detail > div[style*="padding:20px 22px"] { padding: 16px !important; }
  .decision-bar { padding: 12px 16px; }
  .decision-bar > .row { width: 100%; }
  .decision-bar .btn { flex: 1 1 auto; }

  /* Timelines: captions move under the row label; bars stay as shapes */
  .gantt-row, .gantt-axis { grid-template-columns: 118px 1fr; }
  .gantt-label { font-size: 11.5px; line-height: 1.3; padding: 4px 8px 4px 0; }
  .gl-sub { display: block; font-size: 10.5px; color: var(--ink-4); font-weight: 400; }
  .gantt-bar { color: transparent !important; padding: 0; }
  .gantt-axis .ticks span:nth-child(even) { display: none; }

  /* Page heads and misc */
  .page-head { align-items: flex-start; }
  .page-head .actions { width: 100%; }
  .lifecycle { padding-bottom: 4px; }
  .doc-sec { grid-template-columns: 1fr !important; gap: 4px !important; }
  .rule-row { grid-template-columns: 1fr; }
  .p-headline { font-size: 34px; }
  .comp-row { grid-template-columns: 1fr auto 20px; }
  .comp-row .dir { display: none; }
  .res-row { grid-template-columns: 1fr auto 16px !important; }
  .res-row .state { display: none; }
}
@media (max-width: 860px) {
  .card-body > .tbl, .p-card .tbl, .modal-body .tbl, .card > .tbl { display: block; overflow-x: auto; }
}
