/* ==========================================================================
   AM888 — Credit & Settlement Console · design system
   Spark-Admin structure, deep forest green + lime accent, light workspace.
   Forest + white are the foundation; lime is the energy (actions, selection,
   progress, positive trend) and stays under ~15% of any screen. Lime is never
   small text on white — readable green text uses --lime-text.

    1 Variables        6 Header           11 Toggles        16 Drawers
    2 Reset            7 Navigation       12 Buttons        17 Modals & overlays
    3 Typography       8 Cards            13 Tables         18 Feature modules
    4 Layout shell     9 KPI              14 Badges         19 Utilities
    5 Sidebar         10 Forms            15 Charts         20 Responsive
   ========================================================================== */

/* ============================================================ 1 Variables */
:root {
  color-scheme: light;

  /* brand: deep forest */
  --forest-950: #0D1A2E;
  --forest-900: #16263f;
  --forest-850: #16263F;
  --forest-800: #1e3a5f;
  --forest-700: #274668;
  /* brand: lime (accent only) */
  --lime-500: #2F6BE0;
  --lime-450: #3B78EC;
  --lime-400: #5A93F5;
  --lime-hover: #1d5fcc;
  --lime-text: #1E5AC0;      /* readable lime-family text on white */
  --lime-dark: #1E4FA8;
  --lime-wash: rgba(47, 107, 224, 0.10);
  --lime-ring: rgba(47, 107, 224, 0.22);
  --lime-tint: #f3f6fa;      /* very pale selected row */

  /* light theme */
  --canvas: #f3f6fa;
  --surface: #FFFFFF;
  --surface-soft: #ffffff;
  --surface-muted: #e9ebee;
  --surface-input: #f3f6fa;
  --surface-attn: #edf7f0;
  --border: #e9ebee;
  --border-card: #e9ebee;
  --border-soft: #e9ebee;
  --border-row: #e9ebee;
  --border-strong: #d7e0e8;
  --border-hover: #d7e0e8;
  --text-primary: #171b20;
  --text-secondary: #5f646c;
  --text-muted: #989ca1;
  --text-faint: #b7babf;
  --text-meta: #6e737a;      /* muted, but clears 4.5:1 on white for small text */

  /* semantic */
  --success: #189B5A;  --success-soft: #edf7f0;  --success-ink: #0F7443;
  --warning: #E4A11B;  --warning-soft: #fff7e7;  --warning-ink: #8A5A00;
  --danger:  #D64545;  --danger-soft:  #fff0ef;  --danger-ink:  #B32F2F;
  --info:    #3B82F6;  --info-soft:    #f3f6fa;  --info-ink:    #1D5FCC;
  --pending: #7C5CE5;  --pending-soft: #F3F0FF;  --pending-ink: #5B3CC4;
  --neutral-soft: #e9ebee; --neutral-ink: #4f545b;

  /* charts: forest main, lime highlight, gray support */
  --chart-1: #16263F;
  --chart-2: #2F6BE0;
  --chart-neutral: #989ca1;
  --chart-grid: #e9ebee;
  --chart-axis: #989ca1;
  --age-0: #16263F; --age-1: #E99A90; --age-2: #DE6A5E; --age-3: #C23B3B; --age-4: #8A2626;

  /* sidebar */
  --sidebar-bg: #16263F;
  --sb-ink: rgba(255, 255, 255, 0.72);
  --sb-ink-strong: #FFFFFF;
  --sb-ink-group: rgba(255, 255, 255, 0.38);
  --sb-hover: rgba(255, 255, 255, 0.045);
  --sb-active: rgba(255, 255, 255, 0.06);
  --sb-line: rgba(255, 255, 255, 0.08);
  --sb-w-open: 244px;
  --sb-w-closed: 72px;
  --sb-w: var(--sb-w-open);

  /* geometry */
  --header-h: 64px;
  --h-btn: 40px; --h-btn-sm: 32px; --h-btn-lg: 48px;
  --h-input: 40px; --h-field: 52px;
  --r-xs: 6px; --r-sm: 8px; --r-btn: 10px; --r-input: 10px; --r-card: 12px; --r-lg: 16px;
  --sp-1: 4px; --sp-2: 8px; --sp-3: 12px; --sp-4: 16px; --sp-5: 20px; --sp-6: 24px; --sp-7: 32px;
  --gutter: 28px;          /* page side padding */
  --gap: 20px;             /* grid gap between cards */
  --card-pad: 22px;

  /* elevation — almost none */
  --shadow-card: 0 2px 8px rgba(16, 26, 45, 0.035);
  --shadow-hover: 0 5px 16px rgba(16, 26, 45, 0.06);
  --shadow-pop: 0 12px 36px -8px rgba(13, 26, 46, 0.22), 0 2px 6px rgba(13, 26, 46, 0.06);

  /* motion */
  --ease: cubic-bezier(0.22, 1, 0.36, 1);
  --t-fast: 150ms; --t-card: 160ms; --t-knob: 170ms; --t-slide: 220ms;

  /* layers */
  --z-sticky: 20; --z-header: 30; --z-sidebar: 40; --z-fab: 45; --z-drawer: 60; --z-modal: 80; --z-palette: 90; --z-login: 100; --z-toast: 110;

  /* type */
  --sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Noto Sans SC', sans-serif;
  --mono: 'Geist Mono', ui-monospace, 'SF Mono', Menlo, Consolas, monospace;

  /* legacy aliases so older module markup inherits the new system */
  --bg: var(--surface); --ink: var(--text-primary); --ink-body: var(--text-primary);
  --ink-2: var(--text-secondary); --ink-3: var(--text-meta); --line: var(--border-row);
  --line-solid: var(--border); --line-2: var(--border-strong);
  --surface-2: var(--surface-muted); --surface-3: #e9ebee;
  --primary: var(--forest-850); --ok: var(--success-ink); --warn: var(--warning-ink); --risk: var(--danger-ink);
  --risk-bg: var(--danger-soft); --coral: var(--warning);
}

/* ================================================================ 2 Reset */
*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--canvas); color: var(--text-primary);
  font: 400 14px/1.55 var(--sans);
  -webkit-font-smoothing: antialiased; -moz-osx-font-smoothing: grayscale;
  font-feature-settings: 'cv11', 'ss01';
}
svg { width: 16px; height: 16px; flex: none; vertical-align: -3px; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
p { margin: 0; }
a { color: var(--forest-800); text-decoration: none; }
a:hover { color: var(--forest-950); text-decoration: underline; text-underline-offset: 2px; }
:focus-visible { outline: 2px solid var(--lime-dark); outline-offset: 2px; border-radius: var(--r-xs); }
::selection { background: rgba(47, 107, 224, 0.28); }
*::-webkit-scrollbar { width: 9px; height: 9px; }
*::-webkit-scrollbar-thumb { background: rgba(23, 32, 27, 0.18); border-radius: 8px; border: 2px solid transparent; background-clip: padding-box; }
*::-webkit-scrollbar-track { background: transparent; }

/* =========================================================== 3 Typography */
h1, h2, h3, h4 { margin: 0; color: var(--text-primary); text-wrap: balance; letter-spacing: -0.01em; }
h1 { font-size: 28px; line-height: 1.2; font-weight: 700; letter-spacing: -0.02em; }
h2 { font-size: 20px; line-height: 1.3; font-weight: 600; }
h3 { font-size: 16px; line-height: 1.4; font-weight: 600; }
h4 { font-size: 14px; line-height: 1.4; font-weight: 600; }
table, .num, .money, .tile-v, .kv .v, .kpi-value, .stat-v { font-variant-numeric: tabular-nums; }
.mono, .ref { font-family: var(--mono); font-size: 0.94em; }
.money { white-space: nowrap; }
.money-ccy { font-size: 0.62em; font-weight: 600; color: var(--text-secondary); margin-right: 0.3em; letter-spacing: 0.02em; vertical-align: 0.12em; }
td .money-ccy, .kv .money-ccy { font-size: 0.8em; vertical-align: 0; font-weight: 500; }
.t-sub { font-size: 13px; color: var(--text-secondary); line-height: 1.45; }
.t-strong { font-weight: 600; color: var(--text-primary); }
.muted { color: var(--text-secondary); }
.dim { color: var(--text-meta); }
.lbl { font-size: 12px; font-weight: 600; color: var(--text-secondary); letter-spacing: 0.01em; }
.eyebrow { font-size: 12px; font-weight: 600; letter-spacing: 0.08em; text-transform: uppercase; color: var(--text-meta); }
.neg { color: var(--danger-ink); }
.pos { color: var(--lime-text); }
/* Chinese sets wider and wants no negative tracking */
:root[data-lang='zh'] body { line-height: 1.65; }
:root[data-lang='zh'] h1, :root[data-lang='zh'] h2, :root[data-lang='zh'] h3,
:root[data-lang='zh'] .kpi-value { letter-spacing: 0; }
:root[data-lang='zh'] .eyebrow, :root[data-lang='zh'] .nav-label, :root[data-lang='zh'] thead th { letter-spacing: 0.02em; text-transform: none; }

/* ========================================================= 4 Layout shell */
.app { display: flex; min-height: 100dvh; }
.app.sb-collapsed { --sb-w: var(--sb-w-closed); }
.workspace { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.main { flex: 1; padding: 26px var(--gutter) 96px; min-width: 0; }
.main > section { max-width: 1560px; margin: 0 auto; }

.page-head { display: flex; align-items: flex-end; gap: 16px 24px; flex-wrap: wrap; margin-bottom: 24px; }
.page-head > div:first-child, .page-head-text { flex: 1 1 320px; min-width: 0; }
.page-eyebrow { margin-bottom: 6px; color: var(--lime-text); }
.page-head h1 + p { margin-top: 6px; color: var(--text-secondary); font-size: 14px; max-width: 78ch; }
.head-actions { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }

.stack { display: grid; gap: var(--gap); }
.split { display: grid; gap: var(--gap); grid-template-columns: minmax(0, 1.55fr) minmax(300px, 1fr); align-items: start; }
.grid { display: grid; gap: var(--gap); }
.row { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
.row-tight { display: inline-flex; gap: 8px; align-items: center; }
.between { display: flex; gap: 16px; align-items: center; justify-content: space-between; flex-wrap: wrap; }

/* ============================================================== 5 Sidebar */
.sidebar {
  position: sticky; top: 0; height: 100dvh; width: var(--sb-w); flex: none;
  background: var(--sidebar-bg); color: var(--sb-ink);
  display: flex; flex-direction: column; z-index: var(--z-sidebar);
  transition: width var(--t-slide) var(--ease);
}
.sb-brand {
  display: flex; align-items: center; gap: 11px; height: var(--header-h); flex: none;
  padding: 0 18px; border-bottom: 1px solid var(--sb-line); color: #FFF; overflow: hidden;
}
.sb-brand:hover { text-decoration: none; color: #FFF; }
.sb-logo {
  width: 34px; height: 34px; border-radius: 9px; flex: none; display: grid; place-items: center;
  background: var(--forest-950); color: var(--lime-500); font-size: 13px; font-weight: 700; letter-spacing: 0.02em;
  box-shadow: inset 0 0 0 1px rgba(47, 107, 224, 0.22);
}
.sb-brand-text { min-width: 0; line-height: 1.15; white-space: nowrap; }
.sb-brand-text strong { display: block; font-size: 16px; font-weight: 700; color: #FFF; letter-spacing: 0.01em; }
.sb-brand-text strong b, .tb-brand b { color: var(--lime-500); font-weight: 700; }
.sb-brand-text em { display: block; font-style: normal; font-size: 12px; color: var(--sb-ink-group); margin-top: 3px; }

.sb-foot { flex: none; border-top: 1px solid var(--sb-line); padding: 10px 12px 12px; display: grid; gap: 8px; }
.nav-note { font-size: 12px; color: var(--sb-ink-group); padding: 0 6px; line-height: 1.4; }
.sb-collapse {
  display: flex; align-items: center; gap: 11px; height: 36px; padding: 0 10px; border: 0; border-radius: var(--r-sm);
  background: none; color: var(--sb-ink); font-size: 13px; white-space: nowrap; overflow: hidden;
  transition: background var(--t-fast) var(--ease), color var(--t-fast) var(--ease);
}
.sb-collapse:hover { background: var(--sb-hover); color: #FFF; }
.sb-collapse svg { width: 18px; height: 18px; transition: transform var(--t-slide) var(--ease); }
.sb-collapsed .sb-collapse svg { transform: scaleX(-1); }
.lang-drawer { display: flex; gap: 2px; padding: 3px; background: rgba(255, 255, 255, 0.05); border-radius: var(--r-sm); }
.lang-drawer button { flex: 1; border: 0; background: none; padding: 5px 0; border-radius: 6px; font-size: 12px; font-weight: 600; color: var(--sb-ink-group); }
.lang-drawer button:hover { color: #FFF; }
.lang-drawer button[aria-pressed='true'] { background: rgba(255, 255, 255, 0.10); color: #FFF; }

/* collapsed rail (desktop only — the drawer always shows labels) */
@media (min-width: 1025px) {
  .sb-collapsed .sb-brand { padding: 0 19px; }
  .sb-collapsed .sb-brand-text, .sb-collapsed .nav-note, .sb-collapsed .lang-drawer,
  .sb-collapsed .nav .nav-txt, .sb-collapsed .nav-line .ntxt, .sb-collapsed .nav-line .chev,
  .sb-collapsed .nav-items, .sb-collapsed .sb-collapse .nav-txt { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); }
  .sb-collapsed .nav-label { height: 1px; margin: 10px 14px; padding: 0; background: var(--sb-line); color: transparent; overflow: hidden; }
  .sb-collapsed .nav a, .sb-collapsed .nav-line .nav-group { justify-content: center; padding: 0; margin-right: 10px; margin-left: 10px; border-radius: var(--r-sm); }
  .sb-collapsed .nav a[aria-current='page'] { box-shadow: inset 3px 0 0 var(--lime-500); }
  .sb-collapsed .nav a .badge { position: absolute; top: 5px; right: 8px; min-width: 8px; width: 8px; height: 8px; padding: 0; font-size: 0; background: var(--lime-500); }
  .sb-collapsed .nav-line .ldot-wrap { margin: 0; }
  .sb-collapsed .sb-collapse { justify-content: center; padding: 0; }
}

/* =============================================================== 6 Header */
.topbar {
  position: sticky; top: 0; z-index: var(--z-header);
  background: var(--surface); border-bottom: 1px solid #e9ebee;
}
.tb-row { display: flex; align-items: center; gap: 10px; min-height: var(--header-h); padding: 0 var(--gutter) 0 16px; }
.tb-spacer { flex: 1; }
.tb-icon {
  position: relative; width: 40px; height: 40px; flex: none; border: 0; border-radius: var(--r-btn);
  background: none; color: var(--text-secondary); display: grid; place-items: center;
  transition: background var(--t-fast) var(--ease), color var(--t-fast) var(--ease);
}
.tb-icon:hover { background: var(--surface-muted); color: var(--text-primary); }
.tb-icon svg { width: 20px; height: 20px; }
.tb-brand { display: none; align-items: center; gap: 9px; font-size: 16px; font-weight: 700; color: var(--forest-850); }
.tb-brand:hover { text-decoration: none; color: var(--forest-850); }
.tb-brand .sb-logo { width: 30px; height: 30px; font-size: 12px; border-radius: 8px; }
.tb-brand b { color: var(--lime-text); }

/* global context selectors — compact, not pills */
.ctx { display: flex; align-items: center; gap: 2px; min-width: 0; }
.ctx-field {
  position: relative; display: inline-flex; align-items: center; gap: 7px; height: 38px; padding: 0 6px 0 10px;
  border-radius: var(--r-sm); color: var(--text-primary); cursor: pointer; flex: none;
  transition: background var(--t-fast) var(--ease);
}
.ctx-field + .ctx-field::before { content: ''; position: absolute; left: -1px; top: 11px; bottom: 11px; width: 1px; background: var(--border); }
.ctx-field:hover { background: var(--surface-soft); }
.ctx-field:focus-within { background: var(--surface-soft); box-shadow: 0 0 0 2px var(--lime-ring); }
.ctx-field > svg { width: 16px; height: 16px; color: var(--text-meta); }
.ctx-select {
  appearance: none; border: 0; background: transparent; outline: none; cursor: pointer;
  font-size: 14px; font-weight: 600; color: var(--text-primary); padding: 0 20px 0 0; height: 36px; max-width: 220px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16' fill='none' stroke='%2398A19B' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M4 6.5 8 10.5l4-4'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 0 center; background-size: 14px;
}

.tb-search {
  display: flex; align-items: center; gap: 10px; width: clamp(220px, 24vw, 340px); height: 40px; padding: 0 10px 0 12px;
  background: var(--surface-input); border: 1px solid transparent; border-radius: var(--r-input);
  color: var(--text-muted); font-size: 14px; text-align: left;
  transition: border-color var(--t-fast) var(--ease), box-shadow var(--t-fast) var(--ease), background var(--t-fast) var(--ease);
}
.tb-search:hover { background: #e9ebee; }
.tb-search:focus-visible { outline: none; border-color: var(--lime-500); box-shadow: 0 0 0 3px rgba(47, 107, 224, 0.10); background: var(--surface); }
.tb-search svg { width: 17px; height: 17px; color: var(--text-meta); }
.tb-search-txt { flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; color: var(--text-meta); }
.tb-search kbd { font: 600 12px var(--sans); color: var(--text-meta); background: var(--surface); border: 1px solid var(--border); border-radius: 5px; padding: 1px 6px; }

.notif-wrap { position: relative; }
.notif-dot { position: absolute; top: 9px; right: 10px; width: 8px; height: 8px; border-radius: 50%; background: var(--danger); box-shadow: 0 0 0 2px var(--surface); }

.lang-top { display: flex; gap: 2px; padding: 3px; background: var(--surface-muted); border-radius: var(--r-sm); }
.lang-top button { border: 0; background: none; height: 28px; padding: 0 9px; border-radius: 6px; font-size: 12px; font-weight: 600; color: var(--text-meta); }
.lang-top button:hover { color: var(--text-primary); }
.lang-top button[aria-pressed='true'] { background: var(--surface); color: var(--forest-850); box-shadow: 0 1px 2px rgba(16, 26, 45, 0.08); }

.tb-user {
  display: flex; align-items: center; gap: 10px; height: 44px; padding: 0 8px 0 4px; border: 0; border-radius: var(--r-btn);
  background: none; text-align: left; min-width: 0; transition: background var(--t-fast) var(--ease);
}
.tb-user:hover { background: var(--surface-muted); }
.avatar {
  width: 34px; height: 34px; border-radius: 50%; flex: none; display: grid; place-items: center;
  background: var(--forest-850); color: #FFF; font-size: 12px; font-weight: 700; letter-spacing: 0.02em;
}
.tb-user-text { min-width: 0; line-height: 1.2; }
.tb-user-name { display: block; font-size: 13px; font-weight: 600; color: var(--text-primary); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 140px; }
.tb-user-role { display: block; font-size: 12px; color: var(--text-meta); }
.tb-user > svg { width: 14px; height: 14px; color: var(--text-muted); }

/* notification centre */
.notif {
  position: absolute; right: -8px; top: calc(100% + 10px); width: 380px; max-width: calc(100vw - 24px);
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-card); box-shadow: var(--shadow-pop);
  overflow: hidden; z-index: var(--z-drawer); animation: pop-in 160ms var(--ease);
}
@keyframes pop-in { from { opacity: 0; transform: translateY(-4px); } to { opacity: 1; transform: none; } }
.notif-head { display: flex; align-items: center; justify-content: space-between; padding: 14px 16px 10px; }
.notif-head h2 { font-size: 16px; }
.notif-head button { border: 0; background: none; color: var(--lime-text); font-size: 13px; font-weight: 600; padding: 4px 6px; border-radius: 6px; }
.notif-head button:hover { background: var(--lime-tint); }
.notif-day { padding: 10px 16px 4px; }
.notif-list { max-height: 420px; overflow-y: auto; padding-bottom: 6px; }
.notif-item { display: flex; gap: 12px; padding: 10px 16px; cursor: pointer; transition: background var(--t-fast) var(--ease); }
.notif-item:hover, .notif-item:focus-visible { background: var(--surface-soft); outline: none; }
.notif-sev { width: 8px; height: 8px; border-radius: 50%; flex: none; margin-top: 6px; }
.notif-sev.danger { background: var(--danger); } .notif-sev.warning { background: var(--warning); }
.notif-sev.pending { background: var(--pending); } .notif-sev.info { background: var(--info); }
.notif-body { flex: 1; min-width: 0; }
.notif-title, .notif-ref { display: block; }
.notif-title { font-size: 14px; font-weight: 500; color: var(--text-primary); line-height: 1.35; }
.notif-item.unread .notif-title { font-weight: 600; }
.notif-ref { font-size: 12px; color: var(--text-secondary); margin-top: 1px; }
.notif-when { font-size: 12px; color: var(--text-meta); white-space: nowrap; }
.notif-empty { padding: 28px 16px; text-align: center; color: var(--text-meta); font-size: 13px; }

/* =========================================================== 7 Navigation */
.nav { flex: 1; overflow-y: auto; overflow-x: hidden; padding: 8px 0 16px; scrollbar-width: thin; scrollbar-color: rgba(255,255,255,.14) transparent; }
.nav::-webkit-scrollbar-thumb { background: rgba(255, 255, 255, 0.14); background-clip: padding-box; }
.nav-block { padding: 6px 0 4px; }
.nav-label {
  padding: 12px 20px 6px; font-size: 12px; font-weight: 600; letter-spacing: 0.09em; text-transform: uppercase;
  color: var(--sb-ink-group); white-space: nowrap;
}
.nav a, .nav-line .nav-group {
  position: relative; display: flex; align-items: center; gap: 12px; height: 38px; margin: 1px 10px 1px 0; padding: 0 12px 0 17px;
  border-left: 3px solid transparent; border-radius: 0 var(--r-sm) var(--r-sm) 0;
  color: var(--sb-ink); font-size: 14px; font-weight: 500; white-space: nowrap; text-decoration: none;
  transition: background var(--t-fast) var(--ease), color var(--t-fast) var(--ease);
}
.nav a:hover, .nav-line .nav-group:hover { background: var(--sb-hover); color: #FFF; text-decoration: none; }
.nav a svg { width: 18px; height: 18px; color: rgba(255, 255, 255, 0.62); transition: color var(--t-fast) var(--ease); }
.nav a:hover svg { color: #FFF; }
.nav a[aria-current='page'] { background: var(--sb-active); border-left-color: var(--lime-500); color: #FFF; font-weight: 600; }
.nav a[aria-current='page'] svg { color: var(--lime-500); }
.nav-txt { min-width: 0; overflow: hidden; text-overflow: ellipsis; }
.nav a .badge { margin-left: auto; }
.badge {
  min-width: 20px; height: 18px; padding: 0 6px; border-radius: 9px; display: inline-grid; place-items: center;
  background: rgba(255, 255, 255, 0.10); color: rgba(255, 255, 255, 0.86); font-size: 12px; font-weight: 700; font-style: normal;
}
.nav a[aria-current='page'] .badge { background: var(--lime-500); color: var(--forest-950); }

/* business lines: expandable groups whose items are the books inside */
.nav-sec { display: flex; flex-direction: column; }
.nav-line .nav-group { width: calc(100% - 10px); border-top: 0; border-right: 0; border-bottom: 0; background: none; text-align: left; }
.ldot-wrap { width: 20px; display: grid; place-items: center; flex: none; }
.ldot { width: 9px; height: 9px; border-radius: 3px; }
/* business-line icon tile (soccer / horse racing / baccarat / money changer) */
.lico { width: 20px; height: 20px; border-radius: 6px; display: grid; place-items: center; color: #FFF; flex: none; }
.lico svg { width: 13px; height: 13px; }
.ntxt { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; }
.nav-group .chev { width: 13px; height: 13px; opacity: 0.55; transition: transform var(--t-fast) var(--ease); }
.nav-sec.open .nav-group .chev { transform: rotate(90deg); }
.nav-sec.open > .nav-group { color: #FFF; }
.nav-items { display: none; padding: 2px 0 6px; }
.nav-sec.open .nav-items { display: block; }
.nav-items a { height: 32px; padding-left: 47px; font-size: 13px; font-weight: 400; color: rgba(255, 255, 255, 0.6); gap: 10px; }
.nav-items a .pdot { width: 5px; height: 5px; border-radius: 50%; background: currentColor; opacity: 0.6; flex: none; }
.nav-items a[aria-current='page'] { background: var(--sb-active); color: #FFF; }
.nav-items a[aria-current='page'] .pdot { background: var(--lime-500); opacity: 1; }

/* underline tabs (lime underline, never pills) */
.tabs { display: flex; gap: 24px; border-bottom: 1px solid var(--border); overflow-x: auto; scrollbar-width: none; margin-bottom: var(--gap); }
.tabs::-webkit-scrollbar { display: none; }
.tabs button { border: 0; background: none; padding: 0 0 12px; white-space: nowrap; font-size: 14px; font-weight: 500; color: var(--text-secondary); border-bottom: 2px solid transparent; margin-bottom: -1px; }
.tabs button:hover { color: var(--text-primary); }
.tabs button[aria-selected='true'] { color: var(--text-primary); font-weight: 600; border-bottom-color: var(--lime-500); }

/* segmented range control (7D · 4W · 3M) */
.seg { display: inline-flex; gap: 2px; padding: 3px; background: var(--surface-muted); border-radius: var(--r-sm); }
.seg button { border: 0; background: none; height: 28px; padding: 0 11px; border-radius: 6px; font-size: 13px; font-weight: 600; color: var(--text-secondary); transition: background var(--t-fast) var(--ease), color var(--t-fast) var(--ease); }
.seg button:hover { color: var(--text-primary); }
.seg button[aria-pressed='true'] { background: var(--surface); color: var(--forest-850); box-shadow: 0 1px 2px rgba(16, 26, 45, 0.10), inset 0 -2px 0 var(--lime-500); }

/* ================================================================ 8 Cards */
.card, .panel {
  background: var(--surface); border: 1px solid var(--border-card); border-radius: var(--r-card);
  box-shadow: var(--shadow-card); padding: var(--card-pad); min-width: 0;
}
.card-head, .panel-head { display: flex; align-items: flex-start; gap: 12px; margin-bottom: 16px; }
.card-titles { flex: 1; min-width: 0; }
.card-title, .panel-head h2, .panel-head h3 { flex: 1; min-width: 0; font-size: 16px; font-weight: 600; line-height: 1.35; }
.card-sub { margin-top: 3px; font-size: 13px; color: var(--text-secondary); }
.card-actions { display: flex; gap: 8px; align-items: center; flex: 0 1 auto; flex-wrap: wrap; justify-content: flex-end; min-width: 0; }
.card-titles { min-width: min(200px, 100%); }
.panel-body { padding: 0; }
.panel-foot { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-top: 16px; }
.card-link { display: inline-flex; align-items: center; gap: 4px; font-size: 13px; font-weight: 600; color: var(--lime-text); white-space: nowrap; }
.card-link svg { width: 14px; height: 14px; }
.card-link:hover { color: var(--lime-dark); }
/* only clickable surfaces react */
.is-link, .seg-go, [data-go].card { cursor: pointer; transition: transform var(--t-card) var(--ease), border-color var(--t-card) var(--ease), box-shadow var(--t-card) var(--ease); }
.is-link:hover, .seg-go:hover, [data-go].card:hover { transform: translateY(-1px); border-color: var(--border-hover); box-shadow: var(--shadow-hover); }
.is-link:focus-visible, [data-go]:focus-visible { outline: 2px solid var(--lime-dark); outline-offset: 2px; }

/* the metric band on module pages: a grid of compact white tiles */
.tiles { display: grid; gap: 16px; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); }
.tile { background: var(--surface); border: 1px solid var(--border-card); border-radius: var(--r-card); box-shadow: var(--shadow-card); padding: 16px 18px; min-width: 0; }
.tile .lbl { display: block; margin-bottom: 6px; }
.tile-v { font-size: 24px; font-weight: 700; color: var(--text-primary); letter-spacing: -0.015em; line-height: 1.2; }
.tile-v small { font-size: 13px; font-weight: 600; color: var(--text-secondary); margin-right: 3px; letter-spacing: 0; }
.tile-v .dec { font-size: 0.55em; font-weight: 500; color: var(--text-meta); }
.tile-d { margin-top: 6px; font-size: 13px; color: var(--text-secondary); display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.tile-dominant { box-shadow: inset 0 3px 0 var(--forest-850), var(--shadow-card); }
.tile-dominant .tile-v { font-size: 28px; }

/* ================================================================== 9 KPI */
.kpi {
  position: relative; display: flex; flex-direction: column; gap: 10px; min-width: 0;
  background: var(--surface); border: 1px solid var(--border-card); border-radius: var(--r-card);
  box-shadow: var(--shadow-card); padding: 18px 20px 18px;
}
.kpi-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; min-height: 22px; }
.kpi-label { font-size: 13px; font-weight: 600; color: var(--text-secondary); }
.kpi-go { width: 26px; height: 26px; border-radius: 8px; display: grid; place-items: center; color: var(--text-muted); background: var(--surface-soft); transition: background var(--t-card) var(--ease), color var(--t-card) var(--ease); }
.kpi-go svg { width: 14px; height: 14px; }
.kpi.is-link:hover .kpi-go { background: var(--lime-500); color: var(--forest-950); }
.kpi-body { display: flex; align-items: flex-end; justify-content: space-between; gap: 12px; }
.kpi-main { min-width: 0; }
.kpi-value { font-size: 28px; font-weight: 700; line-height: 1.1; letter-spacing: -0.025em; color: var(--text-primary); white-space: nowrap; }
.kpi-value .money-ccy { font-size: 0.5em; vertical-align: 0.3em; }
.kpi-foot { display: flex; align-items: center; gap: 8px; margin-top: 8px; flex-wrap: wrap; }
.kpi-cmp { font-size: 12px; color: var(--text-meta); }
.kpi-spark { flex: none; margin-bottom: 2px; }
.kpi-sub { font-size: 13px; color: var(--text-secondary); }
.kpi-meter { display: grid; gap: 6px; margin-top: 2px; }
.kpi-meter-row { display: flex; justify-content: space-between; font-size: 12px; color: var(--text-secondary); }
.kpi-meter-row b { color: var(--text-primary); font-weight: 600; }
.kpi-feature .kpi-value { font-size: 32px; }

.trend { display: inline-flex; align-items: center; gap: 3px; height: 22px; padding: 0 7px; border-radius: 6px; font-size: 12px; font-weight: 600; white-space: nowrap; }
.trend svg { width: 12px; height: 12px; vertical-align: 0; }
.trend-good { background: var(--lime-wash); color: var(--lime-text); }
.trend-bad { background: var(--danger-soft); color: var(--danger-ink); }
.trend-flat { background: var(--surface-muted); color: var(--text-secondary); }

/* compact secondary figures in one card */
.stat-strip { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); }
.stat { padding: 2px 20px; border-left: 1px solid var(--border-soft); min-width: 0; }
.stat:first-child { border-left: 0; padding-left: 0; }
.stat.is-link { border-radius: 0; }
.stat.is-link:hover { transform: none; box-shadow: none; }
.stat.is-link:hover .stat-v { color: var(--forest-700); }
.stat-l { font-size: 12px; font-weight: 600; color: var(--text-secondary); display: flex; align-items: center; gap: 6px; }
.stat-v { font-size: 20px; font-weight: 700; letter-spacing: -0.015em; color: var(--text-primary); margin-top: 5px; white-space: nowrap; }
.stat-v .money-ccy { font-size: 0.58em; vertical-align: 0.18em; }
.stat .trend { margin-top: 6px; height: 20px; font-size: 12px; }

/* ================================================================ 10 Forms */
.field { display: grid; gap: 6px; min-width: 0; }
.field + .field { margin-top: 14px; }
.field > label { font-size: 13px; font-weight: 600; color: var(--text-secondary); }
.input, .select {
  width: 100%; height: var(--h-input); padding: 0 12px; border: 1px solid var(--border-strong); border-radius: var(--r-input);
  background: var(--surface); color: var(--text-primary); font-size: 14px;
  transition: border-color var(--t-fast) var(--ease), box-shadow var(--t-fast) var(--ease);
}
textarea.input { height: auto; padding: 10px 12px; line-height: 1.5; }
.input:hover, .select:hover { border-color: #cbcfd5; }
.input:focus, .select:focus { outline: none; border-color: var(--lime-500); box-shadow: 0 0 0 3px var(--lime-ring); }
.input::placeholder { color: var(--text-muted); }
.select {
  appearance: none; padding-right: 32px; cursor: pointer;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16' fill='none' stroke='%235F6C64' stroke-width='1.6' stroke-linecap='round'%3E%3Cpath d='M4 6.5 8 10.5l4-4'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 10px center; background-size: 15px;
}
.search { position: relative; }
.search .input { padding-left: 38px; background: var(--surface-input); border-color: transparent; }
.search .input:focus { background: var(--surface); border-color: var(--lime-500); }
.search svg { position: absolute; left: 12px; top: 50%; translate: 0 -50%; width: 17px; height: 17px; color: var(--text-meta); pointer-events: none; }
.filters { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-bottom: 16px; }
.filters .search { flex: 1 1 280px; max-width: 380px; }
.filters .spacer { flex: 1 1 auto; }
.filters .select { width: auto; }

/* checkboxes stay checkboxes (multi-select, permission matrices) */
input[type='checkbox']:not([role='switch']) {
  appearance: none; width: 17px; height: 17px; margin: 0; flex: none; cursor: pointer;
  border: 1.5px solid #cbcfd5; border-radius: 5px; background: var(--surface); display: inline-grid; place-content: center;
  transition: background var(--t-fast) var(--ease), border-color var(--t-fast) var(--ease);
}
input[type='checkbox']:not([role='switch']):hover { border-color: var(--forest-700); }
input[type='checkbox']:not([role='switch']):checked { background: var(--forest-850); border-color: var(--forest-850); }
input[type='checkbox']:not([role='switch']):checked::after { content: ''; width: 9px; height: 5px; border: 2px solid var(--lime-500); border-top: 0; border-right: 0; rotate: -45deg; translate: 0 -1px; }

/* floating-label field: the label rests in the shell and rises above the value */
.ff { position: relative; min-width: 0; }
.ff + .ff, .ff + .field, .field + .ff { margin-top: 14px; }
.ff-input {
  display: block; width: 100%; height: var(--h-field); padding: 20px 14px 6px; border: 1px solid var(--border-strong);
  border-radius: var(--r-input); background: var(--surface); color: var(--text-primary); font-size: 14px; font-weight: 500;
  transition: border-color var(--t-fast) var(--ease), box-shadow var(--t-fast) var(--ease);
}
.ff-input:hover { border-color: #cbcfd5; }
.ff-input:focus { outline: none; border-color: var(--lime-500); box-shadow: 0 0 0 3px var(--lime-ring); }
.ff > label {
  position: absolute; left: 15px; top: 16px; font-size: 14px; color: var(--text-meta); pointer-events: none;
  transform-origin: left top; transition: transform var(--t-fast) var(--ease), color var(--t-fast) var(--ease);
}
.ff-input:focus + label, .ff-input:not(:placeholder-shown) + label,
.ff-select > label, .ff-file > label { transform: translateY(-9px) scale(0.8); color: var(--text-secondary); font-weight: 600; }
.ff-input:focus + label { color: var(--lime-text); }
.ff-select .ff-input {
  appearance: none; cursor: pointer; padding-right: 36px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16' fill='none' stroke='%235F6C64' stroke-width='1.6' stroke-linecap='round'%3E%3Cpath d='M4 6.5 8 10.5l4-4'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 13px center; background-size: 15px;
}
.ff-area .ff-input { height: auto; min-height: 96px; padding-top: 24px; resize: vertical; line-height: 1.5; }
.ff-file .ff-input { padding-top: 22px; font-size: 13px; }
.ff-hint { display: block; margin-top: 5px; font-size: 12px; color: var(--text-meta); }

/* =============================================================== 11 Toggles */
.switch { position: relative; display: inline-flex; flex: none; width: 42px; height: 24px; }
.switch input { position: absolute; inset: 0; margin: 0; opacity: 0; cursor: pointer; z-index: 1; }
.switch-track { width: 100%; height: 100%; border-radius: 12px; background: #d8dbde; transition: background var(--t-knob) var(--ease); position: relative; }
.switch-track::after {
  content: ''; position: absolute; top: 2px; left: 2px; width: 20px; height: 20px; border-radius: 50%; background: #FFF;
  box-shadow: 0 1px 3px rgba(13, 26, 46, 0.25); transition: transform var(--t-knob) var(--ease);
}
.switch input:checked + .switch-track { background: var(--lime-500); }
.switch input:checked + .switch-track::after { transform: translateX(18px); }
.switch input:focus-visible + .switch-track { box-shadow: 0 0 0 3px var(--lime-ring), 0 0 0 1px var(--lime-dark); }
.switch input:disabled + .switch-track { opacity: 0.5; }
.switch-row { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 12px 0; cursor: pointer; }
.switch-row + .switch-row { border-top: 1px solid var(--border-soft); }
.switch-text { display: grid; gap: 2px; font-size: 14px; color: var(--text-primary); }
.switch-text small { font-size: 12px; color: var(--text-meta); }
.switch-inline { padding: 0; justify-content: flex-start; flex-direction: row-reverse; gap: 10px; }
.switch-inline .switch-text { font-size: 13px; color: var(--text-secondary); }

/* =============================================================== 12 Buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; height: var(--h-btn); padding: 0 16px;
  border: 1px solid var(--border-strong); border-radius: var(--r-btn); background: var(--surface); color: var(--forest-850);
  font-size: 14px; font-weight: 600; white-space: nowrap; text-decoration: none;
  transition: background var(--t-fast) var(--ease), border-color var(--t-fast) var(--ease), color var(--t-fast) var(--ease), transform 90ms ease;
}
.btn:hover { background: var(--surface-soft); border-color: #cbcfd5; text-decoration: none; color: var(--forest-950); }
.btn:active { transform: scale(0.985); }
.btn svg { width: 16px; height: 16px; }
.btn[disabled] { opacity: 0.5; cursor: not-allowed; }
.btn-primary { background: var(--lime-500); border-color: var(--lime-500); color: var(--forest-950); }
.btn-primary:hover { background: var(--lime-hover); border-color: var(--lime-hover); color: var(--forest-950); }
.btn-dark { background: var(--forest-850); border-color: var(--forest-850); color: #FFF; }
.btn-dark:hover { background: var(--forest-800); border-color: var(--forest-800); color: #FFF; }
.btn-danger { background: var(--danger); border-color: var(--danger); color: #FFF; }
.btn-danger:hover { background: var(--danger-ink); border-color: var(--danger-ink); color: #FFF; }
.btn-risk { color: var(--danger-ink); }
.btn-risk:hover { background: var(--danger-soft); border-color: #f0c9c9; color: var(--danger-ink); }
.btn-ghost { border-color: transparent; background: none; }
.btn-ghost:hover { background: var(--surface-muted); border-color: transparent; }
.btn-neutral { color: var(--text-primary); }
.btn-icon { width: var(--h-btn); padding: 0; }
.btn-sm { height: var(--h-btn-sm); padding: 0 12px; font-size: 13px; border-radius: var(--r-sm); }
.btn-lg { height: var(--h-btn-lg); padding: 0 22px; font-size: 16px; }
.btn-block { width: 100%; }
.chip {
  display: inline-flex; align-items: center; height: 30px; padding: 0 12px; border: 1px solid var(--border-strong); border-radius: var(--r-sm);
  background: var(--surface); color: var(--text-secondary); font-size: 13px; font-weight: 600;
  transition: border-color var(--t-fast) var(--ease), color var(--t-fast) var(--ease), background var(--t-fast) var(--ease);
}
.chip:hover { border-color: var(--forest-700); color: var(--forest-850); }
.chip[aria-pressed='true'], .chip.on { background: var(--forest-850); border-color: var(--forest-850); color: #FFF; }

/* ================================================================ 13 Tables */
.tw { overflow-x: auto; }
.card .tw, .panel .tw { margin: 0 calc(var(--card-pad) * -1); padding: 0 calc(var(--card-pad) - 14px); }
dialog .tw { margin: 0; padding: 0; }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
thead th {
  text-align: left; font-size: 12px; font-weight: 600; letter-spacing: 0.06em; text-transform: uppercase; color: var(--text-meta);
  background: #ffffff; padding: 10px 14px; white-space: nowrap; border-bottom: 1px solid var(--border-row);
}
thead th:first-child { border-radius: var(--r-sm) 0 0 var(--r-sm); }
thead th:last-child { border-radius: 0 var(--r-sm) var(--r-sm) 0; }
tbody td { padding: 0 14px; height: 48px; border-bottom: 1px solid var(--border-row); vertical-align: middle; color: var(--text-primary); }
tbody tr:last-child td { border-bottom: 0; }
tbody tr { transition: background 100ms var(--ease); }
tbody tr:hover { background: #ffffff; }
tbody tr[data-click], tbody tr[data-go] { cursor: pointer; }
tbody tr.row-hi, tbody tr.row-hi:hover { background: rgba(47,107,224,0.08); box-shadow: inset 3px 0 0 var(--lime-500); }
tfoot td { padding: 0 14px; height: 48px; font-weight: 600; color: var(--text-primary); border-top: 1px solid var(--border-strong); }
th.r, td.r, .r { text-align: right; }
.c { text-align: center; }
td.num, td.r { font-variant-numeric: tabular-nums; white-space: nowrap; }
td.ccy { font-size: 12px; font-weight: 600; color: var(--text-secondary); }
.ref { white-space: nowrap; color: var(--text-secondary); }
.th-sort { cursor: pointer; user-select: none; }
.th-sort:hover { color: var(--text-primary); }
.flash { animation: flash 1.4s var(--ease); }
@keyframes flash { from { background: var(--lime-tint); } to { background: transparent; } }
/* phone rendering of a table: compact cards instead of a squeezed grid */
.mlist { display: none; }
.mcard { padding: 12px 0; border-bottom: 1px solid var(--border-row); }
.mcard:last-child { border-bottom: 0; }
.mcard-top { display: flex; justify-content: space-between; align-items: center; gap: 10px; }
.mcard-title { font-weight: 600; font-size: 14px; }
.mcard-meta { font-size: 12px; color: var(--text-secondary); margin-top: 2px; }
.mcard-figs { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; margin-top: 8px; font-size: 13px; }

/* ================================================================ 14 Badges */
.pill {
  display: inline-flex; align-items: center; gap: 6px; height: 24px; padding: 0 9px; border-radius: 7px;
  font-size: 12px; font-weight: 600; white-space: nowrap; background: var(--neutral-soft); color: var(--neutral-ink);
}
.pill::before { content: ''; width: 6px; height: 6px; border-radius: 50%; background: currentColor; flex: none; }
.pill-ok { background: var(--success-soft); color: var(--success-ink); }
.pill-warn { background: var(--warning-soft); color: var(--warning-ink); }
.pill-risk { background: var(--danger-soft); color: var(--danger-ink); }
.pill-info { background: var(--info-soft); color: var(--info-ink); }
.pill-pend { background: var(--pending-soft); color: var(--pending-ink); }
.pill-off { background: var(--neutral-soft); color: var(--neutral-ink); }
.pill-plain, .pill-ok.pill-plain { background: none; color: var(--text-secondary); padding: 0; height: auto; font-weight: 500; }
.pill-plain::before { display: none; }
.tag { display: inline-flex; align-items: center; height: 22px; padding: 0 7px; border-radius: var(--r-xs); background: var(--surface-muted); color: var(--text-secondary); font-size: 12px; font-weight: 600; letter-spacing: 0.02em; white-space: nowrap; }
.tag-boss { background: var(--forest-850); color: var(--lime-500); }
.plat, .cc { display: inline-grid; place-items: center; height: 18px; min-width: 24px; padding: 0 5px; border-radius: 4px; background: var(--surface-muted); color: var(--text-secondary); font-size: 12px; font-weight: 700; letter-spacing: 0.03em; flex: none; }
/* delivery-channel icon (WhatsApp / Telegram / WeChat / Email·SMS): brand tile + glyph */
.plat.plat-ic { width: 20px; height: 20px; min-width: 0; padding: 0; border-radius: 6px; background: var(--pc); color: #FFF; vertical-align: middle; }
.plat.plat-ic svg { width: 13px; height: 13px; color: #FFF; }
.plat.plat-ic.plat-sm { width: 16px; height: 16px; border-radius: 5px; margin-right: 6px; }
.plat.plat-ic.plat-sm svg { width: 11px; height: 11px; }
.seg-mini { display: inline-grid; place-items: center; flex: none; }
.seg-mini svg { width: 15px; height: 15px; }
.rp-access { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.rp-access .pill { background: var(--surface-muted); color: var(--text-secondary); }
.rp-access .pill::before { display: none; }

/* =============================================================== 15 Charts */
.chart { position: relative; outline: none; border-radius: var(--r-sm); }
.chart:focus-visible { box-shadow: 0 0 0 2px var(--lime-ring); }
.chart-plot svg, .spark, .kpi-spark svg { display: block; overflow: visible; width: auto; height: auto; }
.chart .grid { stroke: var(--chart-grid); stroke-width: 1; }
.chart .grid-base { stroke: var(--border-strong); stroke-width: 1; }
.chart .axis { font: 500 12px var(--sans); fill: var(--chart-axis); font-variant-numeric: tabular-nums; }
.chart .axis-unit { font: 600 12px var(--sans); fill: var(--text-meta); letter-spacing: 0.04em; }
.chart .end-label { font: 600 12px var(--sans); fill: var(--text-secondary); }
.chart .line { fill: none; stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.chart .bar { transition: opacity var(--t-fast) var(--ease); }
.chart .bar.dim { opacity: 0.35; }
.chart .crosshair { stroke: var(--text-muted); stroke-width: 1; stroke-dasharray: 3 3; }
.chart-tip {
  position: absolute; z-index: 5; pointer-events: none; min-width: 168px; padding: 10px 12px;
  background: var(--forest-950); color: #FFF; border-radius: var(--r-sm); box-shadow: var(--shadow-pop); font-size: 12px;
}
.chart-tip-date { font-weight: 600; color: rgba(255, 255, 255, 0.7); margin-bottom: 6px; }
.chart-tip-row { display: grid; grid-template-columns: 10px auto 1fr; align-items: center; gap: 8px; line-height: 1.8; }
.chart-tip-row strong { font-weight: 600; font-variant-numeric: tabular-nums; order: 3; text-align: right; }
.chart-tip-row span:not(.key) { color: rgba(255, 255, 255, 0.72); }
.chart-tip .key { width: 10px; height: 10px; border-radius: 3px; }
.chart-draw { stroke-dasharray: 1; stroke-dashoffset: 1; animation: chart-draw-in 1.4s cubic-bezier(.16, 1, .3, 1) forwards; }
@keyframes chart-draw-in { to { stroke-dashoffset: 0; } }
.chart-fade { opacity: 0; animation: fade-in 700ms ease 500ms forwards; }
@keyframes fade-in { to { opacity: 1; } }
.bar-rise { transform-box: fill-box; transform-origin: bottom; animation: bar-rise 700ms var(--ease) both; }
@keyframes bar-rise { from { transform: scaleY(0); } }
.legend { display: flex; flex-wrap: wrap; gap: 6px 16px; font-size: 12px; color: var(--text-secondary); }
.legend-item { display: inline-flex; align-items: center; gap: 7px; }
.legend-key { width: 10px; height: 10px; border-radius: 3px; flex: none; }
.legend-key.is-line { height: 3px; width: 14px; border-radius: 2px; }
.chart-table { margin-top: 14px; }
.chart-table summary { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; font-weight: 600; color: var(--text-secondary); cursor: pointer; list-style: none; padding: 4px 0; }
.chart-table summary::-webkit-details-marker { display: none; }
.chart-table summary::before { content: '▸'; font-size: 10px; transition: transform var(--t-fast) var(--ease); }
.chart-table[open] summary::before { transform: rotate(90deg); }
.chart-table summary:hover { color: var(--text-primary); }
.chart-table .tw { max-height: 260px; overflow-y: auto; margin-top: 8px; }
.tip {
  position: fixed; left: 0; top: 0; z-index: var(--z-toast); pointer-events: none; max-width: 280px;
  padding: 6px 10px; border-radius: var(--r-sm); background: var(--forest-950); color: #FFF; font-size: 12px; font-weight: 500;
  box-shadow: var(--shadow-pop); font-variant-numeric: tabular-nums;
}
/* meters + stacked bars */
.meter { height: 8px; border-radius: 4px; background: #e9ebee; overflow: hidden; }
.meter > i { display: block; height: 100%; border-radius: 4px; background: var(--forest-850); transition: width 400ms var(--ease); }
.meter-lime > i { background: var(--lime-500); }
.meter-ok > i { background: var(--success); }
.meter-warn > i { background: var(--warning); }
.meter-risk > i { background: var(--danger); }
.util { display: flex; align-items: center; gap: 10px; min-width: 120px; }
.util .meter { flex: 1; height: 6px; }
.util .n { font-variant-numeric: tabular-nums; color: var(--text-secondary); min-width: 38px; text-align: right; font-size: 13px; font-weight: 500; }
.stack-bar { display: flex; gap: 2px; height: 14px; border-radius: 4px; overflow: hidden; }
.stack-bar > i { display: block; height: 100%; min-width: 3px; transition: opacity var(--t-fast) var(--ease); }
.stack-bar > i:hover { opacity: 0.82; }

/* =============================================================== 16 Drawers */
.drawer {
  position: fixed; inset: 0 0 0 auto; width: min(560px, 100%); background: var(--surface); z-index: var(--z-drawer);
  box-shadow: var(--shadow-pop); display: flex; flex-direction: column; animation: slide-in var(--t-slide) var(--ease);
}
@keyframes slide-in { from { transform: translateX(24px); opacity: 0; } to { transform: none; opacity: 1; } }
.drawer .panel-head { padding: 20px 24px 16px; margin: 0; border-bottom: 1px solid var(--border); }
.drawer-body { flex: 1; overflow-y: auto; padding: 20px 24px; }
.drawer .panel-foot { margin: 0; padding: 14px 24px; border-top: 1px solid var(--border); background: var(--surface-soft); }
#navscrim, .scrim { position: fixed; inset: 0; background: rgba(13, 26, 46, 0.42); z-index: calc(var(--z-drawer) - 1); opacity: 0; pointer-events: none; transition: opacity var(--t-slide) var(--ease); }
#navscrim.show { opacity: 1; pointer-events: auto; }

/* ====================================================== 17 Modals & overlays */
dialog {
  border: 0; padding: 0; width: 100%; max-width: min(540px, calc(100vw - 24px)); max-height: calc(100dvh - 32px);
  border-radius: 14px; background: var(--surface); color: var(--text-primary); box-shadow: var(--shadow-pop);
}
dialog::backdrop { background: rgba(13, 26, 46, 0.45); }
/* data-dense drawers (agent settlement engine) get more room */
dialog:has(#agent-settle-dlg), dialog:has(#acct-players-dlg) { max-width: min(780px, calc(100vw - 24px)); }
dialog[open] { animation: pop-in 180ms var(--ease); }
dialog form { display: flex; flex-direction: column; max-height: calc(100dvh - 32px); }
dialog .panel-head { margin: 0; padding: 20px 24px 16px; border-bottom: 1px solid var(--border-soft); }
dialog .panel-head h2 { font-size: 18px; }
dialog .panel-body { padding: 20px 24px; overflow-y: auto; }
dialog .panel-foot { margin: 0; padding: 14px 24px; border-top: 1px solid var(--border-soft); background: var(--surface-soft); justify-content: flex-end; border-radius: 0 0 14px 14px; }
dialog .panel-body > .field + .field, dialog .panel-body > .field { margin-top: 0; }

/* command palette */
.palette { position: fixed; inset: 0; z-index: var(--z-palette); background: rgba(13, 26, 46, 0.42); display: grid; place-items: start center; padding: 12vh 12px 0; }
.palette-box { width: 600px; max-width: 100%; background: var(--surface); border-radius: var(--r-card); box-shadow: var(--shadow-pop); overflow: hidden; animation: pop-in 160ms var(--ease); }
.palette-input { display: flex; align-items: center; gap: 10px; padding: 14px 16px; border-bottom: 1px solid var(--border-soft); }
.palette-input svg { width: 19px; height: 19px; color: var(--text-meta); }
.palette-input input { flex: 1; border: 0; outline: 0; background: none; font-size: 16px; color: var(--text-primary); }
.palette-results { max-height: 52vh; overflow-y: auto; padding: 6px; }
.palette-item { display: flex; align-items: center; gap: 12px; padding: 9px 12px; border-radius: var(--r-sm); cursor: pointer; }
.palette-item:hover { background: var(--surface-soft); }
.palette-item.sel { background: var(--lime-tint); box-shadow: inset 3px 0 0 var(--lime-500); }
.pi-type { flex: none; width: 72px; text-align: center; padding: 3px 6px; border-radius: 5px; background: var(--surface-muted); color: var(--text-secondary); font-size: 12px; font-weight: 700; letter-spacing: 0.05em; text-transform: uppercase; }
.palette-item.sel .pi-type { background: var(--surface); }
.pi-main { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pi-label { font-weight: 600; color: var(--text-primary); }
.pi-sub { color: var(--text-meta); font-size: 12px; }
.palette-empty { padding: 26px; text-align: center; color: var(--text-meta); }
.palette-foot { padding: 8px 16px; border-top: 1px solid var(--border-soft); font-size: 12px; color: var(--text-meta); }

/* toasts */
.toasts { position: fixed; bottom: 24px; left: 50%; translate: -50% 0; z-index: var(--z-toast); display: grid; gap: 8px; justify-items: center; }
.toast { display: flex; align-items: center; gap: 10px; padding: 11px 16px; border-radius: var(--r-btn); background: var(--forest-950); color: #FFF; font-size: 14px; box-shadow: var(--shadow-pop); animation: rise 220ms var(--ease); max-width: calc(100vw - 32px); }
.toast svg { width: 16px; height: 16px; color: var(--lime-500); }
.toast-progress { position: relative; overflow: hidden; }
.toast-progress::after { content: ''; position: absolute; left: 0; bottom: 0; height: 2px; width: 100%; background: var(--lime-500); transform-origin: left; animation: toast-bar 1.2s linear forwards; }
@keyframes toast-bar { from { transform: scaleX(0); } to { transform: scaleX(1); } }
@keyframes rise { from { transform: translateY(10px); opacity: 0; } to { transform: none; opacity: 1; } }

/* AI assistant — part of the product, not a separate one */
.ai-fab {
  position: fixed; right: 24px; bottom: 24px; z-index: var(--z-fab); display: inline-flex; align-items: center; gap: 8px;
  height: 44px; padding: 0 16px 0 13px; border: 0; border-radius: 12px; background: var(--forest-850); color: #FFF;
  font-size: 14px; font-weight: 600; box-shadow: 0 8px 22px -8px rgba(13, 26, 46, 0.55);
  transition: background var(--t-fast) var(--ease), transform var(--t-card) var(--ease);
}
.ai-fab:hover { background: var(--forest-800); transform: translateY(-1px); }
.ai-fab svg { width: 18px; height: 18px; color: var(--lime-500); }
.ai-panel {
  position: fixed; inset: 0 0 0 auto; width: 400px; max-width: 100vw; height: 100dvh; z-index: var(--z-drawer);
  background: var(--surface); border-left: 1px solid var(--border); box-shadow: var(--shadow-pop);
  display: flex; flex-direction: column; transform: translateX(104%); transition: transform var(--t-slide) var(--ease);
}
.ai-panel.open { transform: none; }
.ai-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; min-height: var(--header-h); padding: 0 12px 0 18px; border-bottom: 1px solid var(--border-soft); }
.ai-title { display: flex; align-items: center; gap: 10px; font-weight: 600; font-size: 16px; }
.ai-mark { width: 30px; height: 30px; border-radius: 9px; background: var(--forest-850); color: var(--lime-500); display: grid; place-items: center; }
.ai-mark svg { width: 16px; height: 16px; }
.ai-head-actions { display: flex; align-items: center; gap: 2px; }
.ai-icon { width: 34px; height: 34px; border: 0; background: none; border-radius: var(--r-sm); color: var(--text-secondary); display: grid; place-items: center; font-size: 14px; }
.ai-icon:hover { background: var(--surface-muted); color: var(--text-primary); }
.ai-icon svg { width: 17px; height: 17px; }
.ai-body { flex: 1; overflow-y: auto; padding: 18px; display: flex; flex-direction: column; gap: 10px; background: var(--surface-soft); }
.ai-msg { max-width: 88%; padding: 10px 13px; border-radius: 12px; font-size: 14px; line-height: 1.5; }
.ai-msg.user { align-self: flex-end; background: var(--forest-850); color: #FFF; border-bottom-right-radius: 4px; }
.ai-msg.bot { align-self: flex-start; background: var(--surface); border: 1px solid var(--border-soft); color: var(--text-primary); border-bottom-left-radius: 4px; white-space: pre-line; }
.ai-suggest { padding: 12px 18px 6px; display: flex; flex-wrap: wrap; gap: 6px; border-top: 1px solid var(--border-soft); }
.ai-chip { border: 1px solid var(--border-strong); background: var(--surface); border-radius: var(--r-sm); padding: 6px 11px; font-size: 13px; color: var(--text-secondary); text-align: left; }
.ai-chip:hover { border-color: var(--forest-700); color: var(--forest-850); background: var(--lime-tint); }
.ai-compose { display: flex; gap: 8px; padding: 12px 18px 16px; }
.ai-compose input { flex: 1; min-width: 0; height: 40px; border: 1px solid var(--border-strong); border-radius: var(--r-input); padding: 0 12px; background: var(--surface); outline: none; }
.ai-compose input:focus { border-color: var(--lime-500); box-shadow: 0 0 0 3px var(--lime-ring); }
.ai-compose .btn-sm { height: 40px; }
.ai-history { flex: 1; overflow-y: auto; padding: 8px; }
.ai-hist-item { display: flex; align-items: center; gap: 8px; padding: 10px; border-radius: var(--r-sm); cursor: pointer; }
.ai-hist-item:hover { background: var(--surface-soft); }
.ai-hist-main { flex: 1; min-width: 0; }
.ai-hist-title { font-weight: 600; font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ai-hist-when { font-size: 12px; color: var(--text-meta); margin-top: 1px; }
.ai-hist-del { border: 0; background: none; color: var(--text-meta); font-size: 13px; padding: 4px 6px; border-radius: 6px; }
.ai-hist-del:hover { color: var(--danger-ink); background: var(--danger-soft); }

/* ======================================================= 18 Feature modules */

/* ---- dashboard grid (the reference layout) ---- */
.dash-grid { display: grid; grid-template-columns: repeat(12, minmax(0, 1fr)); gap: var(--gap); align-items: stretch; }
.d-used, .d-net, .d-exp, .d-ovd { grid-column: span 4; }
.d-att { grid-column: 9 / span 4; grid-row: 1 / span 2; }
.d-sec { grid-column: span 12; }
.d-chart { grid-column: span 8; }
.d-risk { grid-column: span 4; }
.d-coll { grid-column: span 7; }
.d-prov { grid-column: span 5; }
.d-age, .d-ccy { grid-column: span 6; }
.dash-note { display: flex; align-items: center; gap: 8px; margin-top: var(--gap); font-size: 12px; color: var(--text-meta); }
.dash-note svg { width: 14px; height: 14px; }

/* needs-attention card: pale green, lime accent line */
.attn { background: var(--surface-attn); border-color: #DCEFE0; box-shadow: inset 3px 0 0 var(--lime-500), var(--shadow-card); display: flex; flex-direction: column; }
.attn-head { display: flex; align-items: center; gap: 10px; }
.attn-ic { width: 32px; height: 32px; border-radius: 9px; background: var(--forest-850); color: var(--lime-500); display: grid; place-items: center; flex: none; }
.attn-ic svg { width: 17px; height: 17px; }
.attn-count { margin-top: 14px; font-size: 24px; font-weight: 700; letter-spacing: -0.02em; line-height: 1.2; }
.attn-count b { font-size: 32px; color: var(--forest-850); margin-right: 4px; }
.attn-list { list-style: none; margin: 14px 0 0; padding: 0; display: grid; gap: 2px; flex: 1; align-content: start; }
.attn-list li > * { display: flex; align-items: center; gap: 10px; padding: 8px 10px; margin: 0 -10px; border-radius: var(--r-sm); font-size: 14px; color: var(--text-primary); }
.attn-list li > [data-go]:hover { background: rgba(26, 54, 38, 0.05); }
.attn-n { min-width: 28px; height: 24px; padding: 0 7px; border-radius: 6px; display: inline-grid; place-items: center; font-size: 13px; font-weight: 700; font-variant-numeric: tabular-nums; }
.attn-n.risk { background: var(--danger-soft); color: var(--danger-ink); }
.attn-n.warn { background: var(--warning-soft); color: var(--warning-ink); }
.attn-n.pend { background: var(--pending-soft); color: var(--pending-ink); }
.attn-n.info { background: var(--info-soft); color: var(--info-ink); }
.attn-list .go { margin-left: auto; color: var(--text-muted); }
.attn-list .go svg { width: 14px; height: 14px; }
.attn-foot { margin-top: 14px; }

/* chart card header */
.chart-summary { display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap; margin: -4px 0 14px; }
.chart-summary .big { font-size: 24px; font-weight: 700; letter-spacing: -0.02em; }
.chart-summary .big .money-ccy { font-size: 0.55em; vertical-align: 0.25em; }
.chart-summary .what { font-size: 13px; color: var(--text-secondary); }
.chart-foot { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-top: 10px; }

/* credit utilisation rows */
.risk-bar { margin: 2px 0 14px; }
.risk-rows { display: grid; gap: 2px; }
.risk-row { display: grid; grid-template-columns: 10px minmax(0, 1fr) auto; gap: 4px 10px; align-items: center; padding: 8px 10px; margin: 0 -10px; border-radius: var(--r-sm); }
.risk-row[data-go]:hover { background: var(--surface-soft); }
.risk-key { width: 10px; height: 10px; border-radius: 3px; }
.risk-name { font-size: 14px; font-weight: 600; }
.risk-name small { font-weight: 500; color: var(--text-meta); font-size: 12px; margin-left: 6px; }
.risk-n { font-size: 16px; font-weight: 700; font-variant-numeric: tabular-nums; text-align: right; }
.risk-row .meter { grid-column: 2 / -1; height: 6px; }

/* debt ageing value list */
.age-list { display: grid; margin-top: 14px; }
.age-item { display: grid; grid-template-columns: minmax(0, 1fr) auto 52px; align-items: center; gap: 14px; min-height: 40px; border-bottom: 1px solid var(--border-row); }
.age-item:last-child { border-bottom: 0; }
.age-lbl { display: flex; align-items: center; gap: 8px; font-size: 14px; color: var(--text-primary); white-space: nowrap; }
.age-lbl i { width: 10px; height: 10px; border-radius: 3px; flex: none; }
.age-v { font-size: 14px; font-weight: 700; text-align: right; white-space: nowrap; }
.age-v .money-ccy { font-size: 0.78em; vertical-align: 0; }
.age-p { font-size: 12px; color: var(--text-meta); text-align: right; font-variant-numeric: tabular-nums; }

/* collections progress rows */
.coll-rows { display: grid; gap: 4px; }
.coll-row { display: grid; grid-template-columns: minmax(84px, 120px) minmax(0, 1fr) minmax(128px, auto) 44px; gap: 6px 14px; align-items: center; padding: 9px 10px; margin: 0 -10px; border-radius: var(--r-sm); }
.coll-row[data-go]:hover { background: var(--surface-soft); }
.coll-name { font-weight: 600; font-size: 14px; }
.coll-name small { display: block; font-weight: 500; font-size: 12px; color: var(--text-meta); }
.coll-row .meter { height: 10px; border-radius: 5px; }
.coll-row .meter > i { border-radius: 5px; }
.coll-pct { font-weight: 700; font-size: 14px; text-align: right; font-variant-numeric: tabular-nums; }
.coll-amt { font-size: 13px; color: var(--text-secondary); text-align: right; white-space: nowrap; }
.coll-amt .money-ccy { font-size: 0.8em; vertical-align: 0; }

/* outstanding by currency */
.ccy-rows { display: grid; gap: 2px; }
.ccy-row { display: grid; grid-template-columns: 64px minmax(0, 1fr) auto; gap: 12px; align-items: center; padding: 5px 10px; margin: 0 -10px; border-radius: var(--r-sm); }
.ccy-row[data-go]:hover { background: var(--surface-soft); }
.ccy-code { font-weight: 700; font-size: 13px; display: flex; align-items: center; gap: 6px; }
.ccy-bar { height: 8px; border-radius: 4px; background: #e9ebee; overflow: hidden; }
.ccy-bar i { display: block; height: 100%; background: var(--forest-850); border-radius: 4px; }
.ccy-amt { text-align: right; font-size: 14px; font-weight: 600; white-space: nowrap; }
.ccy-amt small { display: inline; margin-left: 8px; font-size: 12px; font-weight: 500; color: var(--text-meta); }
.ccy-note { margin-top: 12px; font-size: 12px; color: var(--text-meta); line-height: 1.45; }

/* ---- key/value statements ---- */
.kv { display: grid; }
.kv > div { display: flex; align-items: baseline; gap: 16px; padding: 11px 0; border-bottom: 1px solid var(--border-row); }
.kv > div:last-child { border-bottom: 0; }
.kv .k { flex: 1; min-width: 0; color: var(--text-secondary); font-size: 14px; }
.kv .k small { display: block; font-size: 12px; color: var(--text-meta); margin-top: 1px; }
.kv .v { text-align: right; color: var(--text-primary); font-weight: 600; font-variant-numeric: tabular-nums; }
.kv .sub .k { padding-left: 14px; }
.kv-total { border-top: 1px solid var(--border-strong) !important; border-bottom: 0 !important; padding-top: 14px !important; }
.kv-total .k { color: var(--text-primary); font-weight: 600; }
.kv-total .v { font-size: 20px; font-weight: 700; letter-spacing: -0.015em; }

/* ---- callouts + attention rows ---- */
.callout { display: flex; gap: 10px; padding: 12px 14px; border-radius: var(--r-btn); background: var(--surface-soft); border: 1px solid var(--border-soft); font-size: 13px; color: var(--text-secondary); line-height: 1.5; }
.callout svg { width: 16px; height: 16px; margin-top: 2px; color: var(--text-meta); }
.callout strong { color: var(--text-primary); font-weight: 600; }
.callout-warn { background: var(--warning-soft); border-color: #F5E2B5; color: #6E4B06; }
.callout-warn svg, .callout-warn strong { color: var(--warning-ink); }
.callout-risk { background: var(--danger-soft); border-color: #f0c9c9; color: #8a2626; }
.callout-risk svg, .callout-risk strong { color: var(--danger-ink); }
.attention { display: flex; align-items: center; gap: 12px; padding: 14px 16px; background: var(--surface); border: 1px solid var(--border-card); border-radius: var(--r-card); box-shadow: inset 3px 0 0 var(--danger), var(--shadow-card); font-size: 14px; }
.panel .attention { box-shadow: inset 3px 0 0 var(--warning); }
.panel .attention + .attention { margin-top: 8px; }
.attention > svg { width: 17px; height: 17px; color: var(--danger); }
.attention .grow { flex: 1; min-width: 0; color: var(--text-secondary); }
.attention strong { color: var(--text-primary); font-weight: 600; }

/* ---- statement steps (workflow indicator) ---- */
.steps { display: flex; gap: 6px; overflow-x: auto; scrollbar-width: none; padding: 4px 0; }
.steps::-webkit-scrollbar { display: none; }
.step { flex: none; display: flex; align-items: center; gap: 8px; height: 36px; padding: 0 14px 0 8px; border-radius: 18px; background: var(--surface); border: 1px solid var(--border-card); font-size: 13px; color: var(--text-meta); white-space: nowrap; }
.step .n { width: 22px; height: 22px; border-radius: 50%; display: grid; place-items: center; font-size: 12px; font-weight: 700; background: var(--surface-muted); color: var(--text-meta); }
.step.done { color: var(--text-secondary); }
.step.done .n { background: var(--forest-850); color: var(--lime-500); }
.step.current { color: var(--forest-950); font-weight: 600; border-color: var(--lime-500); box-shadow: 0 0 0 3px var(--lime-wash); }
.step.current .n { background: var(--lime-500); color: var(--forest-950); }

/* ---- hierarchy, snapshot, log ---- */
.k-name { white-space: nowrap; }
.i1 { padding-left: 34px !important; } .i2 { padding-left: 54px !important; }
.log { display: grid; }
.log > div { display: flex; gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--border-row); font-size: 13px; color: var(--text-secondary); }
.log > div:last-child { border-bottom: 0; }
.log time { width: 110px; flex: none; color: var(--text-meta); font-variant-numeric: tabular-nums; }
.log b { color: var(--text-primary); font-weight: 600; }
.snap-row { display: flex; gap: 12px; align-items: baseline; padding: 10px 0; border-bottom: 1px solid var(--border-row); }
.snap-row:last-child { border-bottom: 0; }
.snap-row .k { width: 150px; flex: none; color: var(--text-secondary); font-size: 13px; }
.snap-row .v { min-width: 0; font-weight: 500; }
.panel > .card { padding: 0; border: 0; box-shadow: none; }
.rank-list { display: grid; }
.rank-row { display: flex; align-items: center; justify-content: space-between; gap: 16px; min-height: 44px; border-bottom: 1px solid var(--border-row); }
.rank-row:last-child { border-bottom: 0; }
.rank-row[data-go]:hover { background: var(--surface-soft); }

/* ---- boss overview + business lines ---- */
.seg-grid { display: grid; gap: var(--gap); grid-template-columns: repeat(4, minmax(0, 1fr)); }
@media (max-width: 1320px) { .seg-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 640px) { .seg-grid { grid-template-columns: minmax(0, 1fr); } }
.seg-card { display: grid; gap: 12px; padding: 18px; border: 1px solid var(--border-card); border-radius: var(--r-card); background: var(--surface); }
.seg-top { display: flex; align-items: flex-start; gap: 12px; }
.seg-top > div { flex: 1; min-width: 0; }
.seg-top h3 { font-size: 16px; }
.seg-ic { width: 36px; height: 36px; flex: none; border-radius: 10px; display: grid; place-items: center; color: #FFF; }
.seg-ic svg { width: 19px; height: 19px; }
.seg-zh { font-weight: 500; color: var(--text-meta); font-size: 13px; margin-left: 6px; }
.seg-split { display: grid; gap: 6px; }
.seg-bar { display: flex; gap: 2px; height: 8px; border-radius: 4px; overflow: hidden; background: #e9ebee; }
.seg-bar i { display: block; height: 100%; }
.seg-legend { display: flex; justify-content: space-between; gap: 10px; font-size: 12px; color: var(--text-secondary); flex-wrap: wrap; }
.seg-legend b { color: var(--text-primary); font-weight: 600; }
.seg-foot { display: flex; justify-content: space-between; gap: 10px; font-size: 12px; color: var(--text-meta); border-top: 1px solid var(--border-soft); padding-top: 10px; flex-wrap: wrap; }
.seg-foot b { color: var(--text-secondary); font-weight: 600; }
.contrib { display: grid; gap: 14px; }
.contrib .cr { display: grid; grid-template-columns: 140px minmax(0, 1fr) 100px; gap: 12px; align-items: center; font-size: 13px; }
.contrib .cr b { font-weight: 600; }
.contrib .cbar { height: 10px; border-radius: 5px; background: #e9ebee; overflow: hidden; }
.contrib .cbar i { display: block; height: 100%; border-radius: 5px; }
.contrib .cv { text-align: right; font-weight: 600; font-variant-numeric: tabular-nums; }
.donut-wrap { display: flex; gap: 28px; align-items: center; flex-wrap: wrap; }
.donut-wrap svg { width: 150px; height: 150px; }
.donut-legend { display: grid; gap: 11px; flex: 1; min-width: 190px; }
.donut-legend .dl { display: flex; align-items: center; gap: 10px; font-size: 13px; color: var(--text-secondary); }
.donut-legend .sw { width: 10px; height: 10px; border-radius: 3px; flex: none; }
.donut-legend .dv { margin-left: auto; font-weight: 600; color: var(--text-primary); font-variant-numeric: tabular-nums; }
.donut-c { font-size: 12px; fill: var(--text-meta); }
.donut-t { font-size: 18px; font-weight: 700; fill: var(--text-primary); }

/* ---- connector health ---- */
.ssn { font-size: 13px; font-weight: 600; white-space: nowrap; }
.ssn.ok { color: var(--success-ink); } .ssn.warn { color: var(--warning-ink); } .ssn.risk { color: var(--danger-ink); } .ssn.dim { color: var(--text-meta); }
.seg-chips { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 14px; }
.seg-chip { height: 30px; padding: 0 12px; border: 1px solid var(--border-strong); border-radius: var(--r-sm); background: var(--surface); color: var(--text-secondary); font-size: 13px; font-weight: 600; }
.seg-chip:hover { border-color: var(--forest-700); color: var(--forest-850); }
.seg-chip.on { background: var(--forest-850); border-color: var(--forest-850); color: #FFF; }

.empty { padding: 48px 24px; text-align: center; color: var(--text-secondary); }
.empty h3 { margin-bottom: 6px; }
.demo-note { display: flex; align-items: center; gap: 8px; font-size: 12px; color: var(--text-meta); }
.demo-note svg { width: 14px; height: 14px; }

/* ---- sign in: forest brand half + white form half ---- */
.loginwrap { position: fixed; inset: 0; z-index: var(--z-login); display: grid; grid-template-columns: minmax(0, 1.05fr) minmax(0, 0.95fr); background: var(--surface); overflow-y: auto; }
.login-hero { position: relative; overflow: hidden; display: flex; align-items: center; padding: 56px clamp(40px, 5.5vw, 88px); background: var(--forest-850); color: #FFF; }
.login-glow {
  position: absolute; inset: 0; pointer-events: none;
  background-image: linear-gradient(rgba(255,255,255,.035) 1px, transparent 1px), linear-gradient(90deg, rgba(255,255,255,.035) 1px, transparent 1px);
  background-size: 44px 44px; -webkit-mask-image: radial-gradient(ellipse 80% 70% at 70% 40%, #000 30%, transparent 75%); mask-image: radial-gradient(ellipse 80% 70% at 70% 40%, #000 30%, transparent 75%);
}
.login-hero-in { position: relative; max-width: 480px; width: 100%; }
.login-brand { display: flex; align-items: center; gap: 12px; }
.login-mark { width: 44px; height: 44px; border-radius: 12px; display: grid; place-items: center; flex: none; background: var(--forest-950); color: var(--lime-500); font-weight: 700; font-size: 16px; box-shadow: inset 0 0 0 1px rgba(47, 107, 224, 0.25); }
.login-brand b { display: block; font-size: 18px; font-weight: 700; }
.login-brand b i, .login-mobile-brand b i { font-style: normal; color: #FFF; }
.login-brand em { display: block; font-style: normal; font-size: 12px; color: rgba(255, 255, 255, 0.55); margin-top: 1px; }
.login-welcome { margin: 56px 0 0; font-size: clamp(36px, 4.2vw, 56px); line-height: 1.04; font-weight: 700; letter-spacing: -0.035em; color: #FFF; }
.login-welcome span { color: #FFF; }
.login-lede { margin-top: 20px; max-width: 42ch; font-size: 16px; line-height: 1.6; color: rgba(255, 255, 255, 0.68); }
.login-chart { margin-top: 40px; }
.login-chart svg { width: 100%; height: 112px; display: block; overflow: visible; }
.lc-line { stroke-dasharray: 1600; stroke-dashoffset: 1600; animation: lc-draw 2.4s cubic-bezier(.16, 1, .3, 1) .4s forwards; }
@keyframes lc-draw { to { stroke-dashoffset: 0; } }
.lc-area, .lc-end { opacity: 0; animation: fade-in 1s ease 2.2s forwards; }
.lc-halo { opacity: 0; transform-box: fill-box; transform-origin: center; animation: lc-ping 2.4s ease-out 2.8s infinite; }
@keyframes lc-ping { 0% { opacity: .8; transform: scale(1); } 100% { opacity: 0; transform: scale(3.2); } }
.login-chart-cap { display: flex; align-items: center; gap: 8px; margin-top: 12px; font-size: 12px; color: rgba(255, 255, 255, 0.55); }
.lc-live { width: 7px; height: 7px; border-radius: 50%; background: var(--lime-500); flex: none; }
.login-mfa { display: flex; align-items: center; gap: 10px; margin-top: 36px; font-size: 13px; color: rgba(255, 255, 255, 0.6); }
.login-mfa svg { width: 18px; height: 18px; color: var(--lime-500); }
.login-pane { display: flex; align-items: center; justify-content: center; padding: 40px 32px; background: var(--surface); }
.login-form { width: 100%; max-width: 380px; }
.login-mobile-brand { display: none; align-items: center; gap: 10px; margin-bottom: 32px; font-size: 18px; }
.login-mobile-brand b { color: var(--forest-850); }
.login-mobile-brand b i { color: var(--lime-text); }
.login-form h1 { font-size: 28px; }
.login-sub { margin: 8px 0 24px; font-size: 14px; color: var(--text-secondary); }
.login-sub strong { color: var(--text-primary); }
.login-row { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-top: 16px; font-size: 13px; }
.login-link { color: var(--lime-text); font-weight: 600; cursor: pointer; }
.login-link:hover { text-decoration: underline; }
.login-btn { margin-top: 22px; }
.login-demo { margin-top: 26px; padding-top: 20px; border-top: 1px solid var(--border-soft); }
.login-demo > span { font-size: 12px; font-weight: 600; letter-spacing: 0.08em; text-transform: uppercase; color: var(--text-meta); }
.login-demo-roles { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }
.otp-row { display: flex; gap: 8px; margin: 4px 0 8px; }
.otp-box { width: 48px; height: 56px; text-align: center; font-size: 24px; font-weight: 700; font-variant-numeric: tabular-nums; border: 1px solid var(--border-strong); border-radius: var(--r-input); background: var(--surface); transition: border-color var(--t-fast) var(--ease), box-shadow var(--t-fast) var(--ease); }
.otp-box:focus { outline: none; border-color: var(--lime-500); box-shadow: 0 0 0 3px var(--lime-ring); }
.login-center { text-align: center; font-size: 13px; color: var(--text-secondary); margin-top: 16px; }
.login-foot { margin-top: 24px; font-size: 12px; color: var(--text-meta); line-height: 1.5; }
#lg-otp:not([hidden]) { animation: rise 320ms var(--ease); }

/* ---- printable statement ---- */
#print-doc { display: none; }
.pdoc { font-family: var(--sans); color: #171b20; max-width: 660px; margin: 0 auto; }
.pdoc .phead { display: flex; justify-content: space-between; align-items: flex-start; border-bottom: 2px solid #16263F; padding-bottom: 12px; margin-bottom: 18px; }
.pdoc h2 { font-size: 24px; }
.pdoc .psub { color: #5f646c; font-size: 13px; margin-top: 3px; }
.pdoc .pmeta { text-align: right; font-family: var(--mono); font-size: 12px; color: #5f646c; line-height: 1.5; }
.pdoc .pgrid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px 24px; margin-bottom: 20px; }
.pdoc .pgrid span { display: block; font-size: 12px; color: #6e737a; }
.pdoc .pgrid b { font-weight: 600; }
.pdoc .ptable { width: 100%; border-collapse: collapse; margin-bottom: 14px; }
.pdoc .ptable td { padding: 9px 0; border-bottom: 1px solid #e9ebee; font-size: 14px; height: auto; }
.pdoc .ptable .r { text-align: right; font-variant-numeric: tabular-nums; }
.pdoc .ptable tfoot td { border-top: 2px solid #16263F; border-bottom: 0; font-weight: 700; font-size: 16px; padding-top: 12px; }
.pdoc .neg { color: #B32F2F; }
.pdoc .pfx { font-size: 13px; color: #5f646c; margin-top: 4px; }
.pdoc .pfoot { margin-top: 22px; font-size: 12px; color: #6e737a; border-top: 1px solid #e9ebee; padding-top: 12px; line-height: 1.5; }


/* ---- shared page parts ---- */
.kpi-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: var(--gap); margin-bottom: var(--gap); }
.kpi-row-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.kpi-of { font-size: 0.55em; font-weight: 600; color: var(--text-meta); letter-spacing: 0; }
/* every page root stacks its blocks on one rhythm */
.main > section > [id$='-root'] { display: grid; grid-template-columns: minmax(0, 1fr); gap: var(--gap); }
.main > section > [id$='-root'] > * { margin-top: 0 !important; margin-bottom: 0 !important; }
.main > section > [id$='-root'] > .page-head { margin-bottom: 4px !important; }
.title-count { display: inline-flex; align-items: center; height: 26px; padding: 0 10px; margin-left: 10px; border-radius: 8px; background: var(--danger-soft); color: var(--danger-ink); font-size: 13px; font-weight: 700; vertical-align: 5px; letter-spacing: 0; }
.toolbar { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 16px; }
.chip-row { display: flex; flex-wrap: wrap; gap: 6px; }
.card .chip-row + .has-mlist, .card .chip-row + .tw { margin-top: 14px; }
.chip-n { display: inline-grid; place-items: center; min-width: 20px; height: 18px; padding: 0 5px; margin-left: 6px; border-radius: 9px; background: var(--surface-muted); color: var(--text-secondary); font-size: 12px; }
.chip[aria-pressed='true'] .chip-n { background: rgba(255, 255, 255, 0.16); color: #FFF; }
.card-foot-note { margin-top: 14px; font-size: 13px; color: var(--text-meta); }
.cell-wrap { white-space: normal; max-width: 260px; }
.form-hint { margin-top: 14px; font-size: 13px; color: var(--text-secondary); line-height: 1.5; }
.formula { font-family: var(--mono); font-size: 12px; padding: 2px 6px; border-radius: 5px; background: var(--surface-muted); color: var(--forest-800); white-space: nowrap; }
.lock { color: var(--text-muted); }
.lock svg { width: 14px; height: 14px; }
.live-dot { width: 7px; height: 7px; border-radius: 50%; background: #cbcfd5; flex: none; }
.live-dot.on { background: var(--success); }
.drawer-title { font-size: 18px; }
.drawer-sec { margin: 22px 0 10px; font-size: 13px; color: var(--text-secondary); }
.scrim.show { opacity: 1; pointer-events: auto; }
.panel-foot .spacer { flex: 1; }

/* timeline: maker-checker, delivery log, activity */
.timeline { list-style: none; margin: 0; padding: 0; display: grid; }
.timeline li { position: relative; display: grid; grid-template-columns: minmax(0, 1fr) auto; column-gap: 12px; padding: 0 0 16px 24px; font-size: 14px; }
.timeline li:last-child { padding-bottom: 0; }
.timeline li::before { content: ''; position: absolute; left: 0; top: 4px; width: 12px; height: 12px; border-radius: 50%; background: var(--surface); border: 2px solid var(--border-strong); }
.timeline li::after { content: ''; position: absolute; left: 5px; top: 18px; bottom: 2px; width: 2px; background: var(--border-soft); }
.timeline li:last-child::after { display: none; }
.timeline li.done::before { background: var(--forest-850); border-color: var(--forest-850); }
.timeline li.current::before { background: var(--lime-500); border-color: var(--lime-500); box-shadow: 0 0 0 4px var(--lime-wash); }
.timeline li.bad::before { background: var(--danger); border-color: var(--danger); }
.timeline b { font-weight: 600; color: var(--text-primary); }
.timeline span { grid-column: 1; color: var(--text-secondary); font-size: 13px; }
.timeline time { grid-column: 2; grid-row: 1; font-size: 12px; color: var(--text-meta); white-space: nowrap; font-variant-numeric: tabular-nums; }

/* ---- exceptions ---- */
.sev-card { text-align: left; font: inherit; color: inherit; width: 100%; box-shadow: inset 0 3px 0 var(--sev, var(--border)), var(--shadow-card); }
.sev-card.sev-crit { --sev: var(--danger); } .sev-card.sev-warn { --sev: var(--warning); } .sev-card.sev-info { --sev: var(--info); }
.sev-card[aria-pressed='true'] { border-color: var(--sev); background: var(--surface-soft); }
.sev-card .kpi-label { display: inline-flex; align-items: center; gap: 8px; }
.sev-dot { display: inline-block; width: 9px; height: 9px; border-radius: 50%; flex: none; background: var(--sev, var(--text-muted)); }
.sev-dot.sev-crit { background: var(--danger); } .sev-dot.sev-warn { background: var(--warning); } .sev-dot.sev-info { background: var(--info); }

/* ---- approvals ---- */
.req-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: var(--gap); }
.req-card { display: flex; flex-direction: column; gap: 10px; padding: 18px 20px; }
.req-top { display: flex; justify-content: space-between; align-items: center; gap: 10px; }
.req-type { font-size: 12px; font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase; color: var(--text-meta); }
.req-agent { font-family: var(--mono); font-size: 16px; font-weight: 600; }
.req-agent .t-sub { font-family: var(--sans); font-weight: 500; }
.req-change { display: flex; align-items: center; gap: 10px; font-size: 18px; font-weight: 700; font-variant-numeric: tabular-nums; }
.req-change svg { color: var(--text-muted); width: 16px; height: 16px; }
.req-change .dim { font-weight: 600; }
.req-detail { font-size: 16px; font-weight: 600; }
.req-delta { font-size: 13px; font-weight: 700; }
.req-delta.up { color: var(--lime-text); } .req-delta.down { color: var(--danger-ink); }
.req-delta .t-sub { font-weight: 500; margin-left: 4px; }
.req-meta { font-size: 13px; color: var(--text-secondary); }
.req-meta b { color: var(--text-primary); font-weight: 600; }
.req-foot { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-top: auto; padding-top: 12px; border-top: 1px solid var(--border-soft); }
.req-wait { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; font-weight: 600; color: var(--pending-ink); }
.req-wait svg { width: 14px; height: 14px; }
.review-change { padding: 16px; border-radius: var(--r-card); background: var(--surface-soft); border: 1px solid var(--border-soft); margin-bottom: 16px; }
.review-cols { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; }
.review-from, .review-to, .review-delta { margin-top: 4px; font-size: 18px; font-weight: 700; font-variant-numeric: tabular-nums; }
.review-from { color: var(--text-secondary); }
.review-delta.up { color: var(--lime-text); } .review-delta.down { color: var(--danger-ink); }

/* ---- hierarchy tree ---- */
.hier-sum { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)) minmax(180px, 1.3fr) minmax(0, 1fr); gap: 16px; padding-bottom: 18px; margin-bottom: 16px; border-bottom: 1px solid var(--border-soft); }
.hier-sum .stat { padding: 0 0 0 16px; }
.hier-sum .stat:first-child { padding-left: 0; }
.hier-used .stat-l { justify-content: space-between; margin-bottom: 12px; }
.hier-used .stat-l b { color: var(--text-primary); }
.stat-v.pos { color: var(--lime-text); }
.tree-table td:first-child { position: relative; }
.tree { display: flex; align-items: center; gap: 8px; padding-left: calc(var(--lvl) * 22px); white-space: nowrap; }
.tree-caret { width: 22px; height: 22px; border: 0; border-radius: 6px; background: none; color: var(--text-meta); display: grid; place-items: center; padding: 0; flex: none; }
.tree-caret:hover { background: var(--surface-muted); color: var(--text-primary); }
.tree-caret svg { width: 14px; height: 14px; transform: rotate(90deg); transition: transform var(--t-fast) var(--ease); }
.tree-caret[aria-expanded='false'] svg { transform: none; }
.tree-leaf { width: 14px; height: 1px; background: var(--border-strong); margin: 0 4px 0 8px; flex: none; }
.tree-sub { display: block; font-size: 12px; margin-top: 1px; }
.tree-parent td { background: #ffffff; }
.tree-parent.tier-boss td { background: #ffffff; font-weight: 600; }
.mgroup { display: flex; align-items: center; gap: 8px; font-size: 13px; }
.mgroup svg { width: 13px; height: 13px; color: var(--text-muted); transform: rotate(90deg); }
.mgroup .t-sub { margin-left: auto; }
.mcard .meter { margin-top: 8px; height: 6px; }
.mgrid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; margin-top: 8px; font-size: 12px; color: var(--text-meta); }
.mgrid b { display: block; font-size: 13px; color: var(--text-primary); font-weight: 600; margin-top: 1px; }

/* ---- agent snapshot ---- */
.snap-head { align-items: center; }
.snap-id { display: flex; align-items: center; gap: 16px; min-width: 0; }
.avatar-lg { width: 56px; height: 56px; border-radius: 16px; font-size: 18px; box-shadow: inset 0 0 0 1px rgba(47, 107, 224, 0.25); color: var(--lime-500); }
.snap-head .snap-id h1 { font-family: var(--mono); letter-spacing: -0.01em; }
.snap-id p { margin-top: 4px; color: var(--text-secondary); display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.snap-top { display: grid; grid-template-columns: minmax(0, 0.9fr) minmax(0, 1.3fr); gap: var(--gap); margin-bottom: var(--gap); }
.snap-bals { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 20px 24px; align-content: start; }
.snap-bal { display: grid; gap: 4px; }
.snap-bal-v { font-size: 24px; font-weight: 700; letter-spacing: -0.02em; font-variant-numeric: tabular-nums; white-space: nowrap; }
.snap-bal-v .money-ccy { font-size: 0.55em; vertical-align: 0.25em; }
.snap-bal.pos .snap-bal-v { color: var(--lime-text); }
.snap-bal.neg .snap-bal-v { color: var(--danger-ink); }
.snap-used { grid-column: 1 / -1; display: grid; gap: 8px; padding-top: 16px; border-top: 1px solid var(--border-soft); }
.snap-chart .card-head, .d-chart .card-head { flex-wrap: wrap; }
.tab-body { min-width: 0; }

/* ---- statement ---- */
.stmt-hero { display: grid; grid-template-columns: minmax(0, 1fr) minmax(280px, 0.8fr); gap: 24px; align-items: center; margin-bottom: 16px; background: linear-gradient(90deg, var(--surface) 55%, var(--surface-attn)); }
.stmt-serial { font-size: 13px; color: var(--text-secondary); }
.stmt-agent { display: flex; align-items: baseline; gap: 10px; margin-top: 6px; flex-wrap: wrap; }
.stmt-agent b { font-size: 24px; font-weight: 700; font-family: var(--mono); }
.stmt-tags { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-top: 12px; }
.stmt-fig { display: grid; gap: 6px; justify-items: end; text-align: right; }
.stmt-big { font-size: 32px; font-weight: 700; letter-spacing: -0.03em; line-height: 1.1; font-variant-numeric: tabular-nums; white-space: nowrap; }
.stmt-big .money-ccy { font-size: 0.45em; vertical-align: 0.5em; }
.stmt-prog { width: 100%; max-width: 340px; display: grid; gap: 6px; }
.steps { align-items: center; gap: 0; }
.step-line { flex: 1 0 18px; height: 2px; background: var(--border); min-width: 18px; }
.step.done + .step-line { background: var(--forest-850); }
.stmt-lines .v { min-width: 150px; }
.stmt-fx, .stmt-sum + .callout { margin-top: 16px; }
.stmt-sum { margin-top: 12px; }
.stmt-sum > div { padding: 8px 0; }

/* ---- contra / net ---- */
.contra-sum { display: grid; grid-template-columns: minmax(0, 2fr) minmax(0, 1fr); gap: var(--gap); }
.contra-sum .card { display: grid; gap: 6px; align-content: center; }
.contra-hero { background: linear-gradient(90deg, var(--surface) 55%, var(--surface-attn)); }
.net-flow { display: grid; grid-template-columns: minmax(0, 1.1fr) minmax(0, 1fr); gap: var(--gap); align-items: start; }
.net-flow .card-titles { display: flex; align-items: center; gap: 10px; }
.step-no { width: 24px; height: 24px; border-radius: 50%; background: var(--forest-850); color: var(--lime-500); display: inline-grid; place-items: center; font-size: 12px; font-weight: 700; flex: none; }
.net-area { height: 260px; font-family: var(--mono); font-size: 13px; line-height: 1.7; resize: vertical; background: var(--surface-soft); }

/* ---- providers ---- */
.method-strip { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 16px; }
.method-tile { display: flex; align-items: center; gap: 14px; min-width: 0; }
.method-tile + .method-tile { border-left: 1px solid var(--border-soft); padding-left: 16px; }
.method-ic { width: 42px; height: 42px; border-radius: 12px; display: grid; place-items: center; background: var(--surface-muted); color: var(--forest-850); flex: none; }
.method-ic svg { width: 20px; height: 20px; }
.method-ic.lime { background: var(--forest-850); color: var(--lime-500); }
.method-tile .stat-v { margin-top: 0; font-size: 18px; }
td .row-tight svg { width: 16px; height: 16px; color: var(--text-meta); }

/* ---- connector health ---- */
.health-top { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.2fr); gap: var(--gap); }
.health-ring-card { display: flex; align-items: center; gap: 28px; }
.ring { --p: 50; width: 132px; height: 132px; border-radius: 50%; flex: none; display: grid; place-items: center;
  background: conic-gradient(var(--success) calc(var(--p) * 1%), #e9ebee 0); }
.ring-in { width: 100px; height: 100px; border-radius: 50%; background: var(--surface); display: grid; place-content: center; text-align: center; }
.ring-in b { font-size: 28px; font-weight: 700; letter-spacing: -0.02em; }
.ring-in span { font-size: 12px; color: var(--text-meta); }
.health-legend { display: grid; gap: 8px; flex: 1; min-width: 0; }
.health-legend > div { display: flex; align-items: center; gap: 8px; font-size: 14px; }
.health-legend i { width: 10px; height: 10px; border-radius: 3px; flex: none; }
.health-legend b { margin-left: auto; font-variant-numeric: tabular-nums; }
.health-alert { display: flex; gap: 14px; align-items: flex-start; background: var(--danger-soft); border-color: #F5D5D5; box-shadow: inset 3px 0 0 var(--danger), var(--shadow-card); }
.health-alert .attn-ic { background: var(--danger); color: #FFF; }
.health-list { list-style: none; margin: 12px 0 0; padding: 0; display: grid; gap: 6px; }
.health-list li { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 8px 12px; border-radius: var(--r-sm); background: var(--surface); font-size: 13px; }

/* ---- platform queue ---- */
.plat-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: var(--gap); }
.plat-card { display: grid; gap: 10px; text-align: left; font: inherit; color: inherit; width: 100%; }
.plat-card.on { border-color: var(--forest-850); box-shadow: inset 0 0 0 1px var(--forest-850), var(--shadow-card); }
.plat-card-top { display: flex; justify-content: space-between; align-items: center; }
.plat-lg { height: 30px; min-width: 38px; border-radius: 8px; font-size: 12px; background: var(--forest-850); color: var(--lime-500); }
.plat.plat-ic.plat-lg { width: 36px; height: 36px; border-radius: 10px; background: var(--pc); color: #FFF; }
.plat.plat-ic.plat-lg svg { width: 21px; height: 21px; }
.plat-card-name { font-size: 16px; font-weight: 700; }
.plat-card-figs { display: flex; gap: 14px; font-size: 13px; color: var(--text-secondary); }
.plat-card-figs b { font-size: 16px; color: var(--text-primary); }
.plat-card-figs b.neg { color: var(--danger-ink); }

/* ---- reports ---- */
.report-scope { display: flex; flex-wrap: wrap; gap: 8px; margin: -6px 0 var(--gap); }
.report-scope span { display: inline-flex; align-items: center; gap: 8px; height: 32px; padding: 0 12px; border-radius: var(--r-sm); background: var(--surface); border: 1px solid var(--border); font-size: 13px; font-weight: 600; }
.report-scope em { font-style: normal; font-weight: 500; color: var(--text-meta); }
.wl-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(340px, 1fr)); gap: var(--gap); }
.wl-total { font-size: 28px; font-weight: 700; letter-spacing: -0.02em; margin-top: 4px; }
.wl-total .money-ccy { font-size: 0.5em; vertical-align: 0.35em; }
.hbars, .rank-bars { display: grid; gap: 10px; }
.hbar, .rank-bar { display: grid; grid-template-columns: 96px minmax(0, 1fr) 84px; align-items: center; gap: 12px; font-size: 13px; }
.rank-bar { grid-template-columns: 24px 110px minmax(0, 1fr) 72px; }
.rank-n { width: 22px; height: 22px; border-radius: 6px; background: var(--surface-muted); display: grid; place-items: center; font-size: 12px; font-weight: 700; color: var(--text-secondary); }
.hbar-l { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.hbar-track { height: 10px; border-radius: 5px; background: #e9ebee; overflow: hidden; }
.hbar-track i { display: block; height: 100%; border-radius: 5px; background: var(--forest-850); }
.hbar-track i.neg { background: var(--danger); }
.hbar-v { text-align: right; font-weight: 600; font-variant-numeric: tabular-nums; white-space: nowrap; }
.audit-list { list-style: none; margin: 0; padding: 0; display: grid; }
.audit-list li { display: flex; gap: 14px; padding: 14px 0; border-bottom: 1px solid var(--border-row); }
.audit-list li:last-child { border-bottom: 0; }
.audit-mark { width: 4px; border-radius: 2px; flex: none; background: var(--success); }
.audit-edit .audit-mark { background: var(--warning); } .audit-delete .audit-mark { background: var(--danger); }
.audit-main { flex: 1; min-width: 0; display: grid; gap: 4px; }
.audit-top { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.audit-amt { margin-left: auto; font-weight: 700; }
.fx-grid, .bank-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: var(--gap); }
.fx-card, .bank-card { display: grid; gap: 6px; }
.fx-top, .bank-top { display: flex; align-items: center; gap: 8px; }
.fx-top b { font-size: 16px; }
.fx-top .tag { margin-left: auto; }
.fx-rate { font-size: 28px; font-weight: 700; letter-spacing: -0.02em; font-variant-numeric: tabular-nums; margin-top: 6px; }
.bank-top { justify-content: space-between; }
.bank-ic { width: 40px; height: 40px; border-radius: 11px; background: var(--forest-850); color: var(--lime-500); display: grid; place-items: center; }
.bank-ic svg { width: 19px; height: 19px; }
.bank-name { font-size: 16px; font-weight: 700; margin-top: 8px; }
.bank-toggle { margin-top: 8px; padding: 12px 0 0; border-top: 1px solid var(--border-soft); }
.bank-card.off .bank-ic { background: var(--surface-muted); color: var(--text-muted); }
.bank-card.off .bank-name { color: var(--text-secondary); }

/* ---- boss overview + business lines ---- */
.boss-hero { display: grid; grid-template-columns: minmax(0, 1.5fr) minmax(0, 1fr); gap: 28px; align-items: center; margin-bottom: var(--gap); }
.boss-big { font-size: 38px; font-weight: 700; letter-spacing: -0.03em; line-height: 1.1; margin-top: 6px; font-variant-numeric: tabular-nums; }
.boss-big .money-ccy { font-size: 0.42em; vertical-align: 0.6em; }
.boss-mix { margin-top: 18px; display: grid; gap: 10px; }
.boss-mix .legend b { color: var(--text-primary); margin-left: 2px; }
.boss-hero-side { display: grid; gap: 14px; padding-left: 28px; border-left: 1px solid var(--border-soft); }
.boss-hero-side .stat { padding: 0; border: 0; display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap; }
.boss-hero-side .stat-l { min-width: 130px; }
.boss-hero-side .stat-v { margin-top: 0; font-size: 18px; }
.seg-card { position: relative; overflow: hidden; }
.seg-card::before { content: ''; position: absolute; left: 0; right: 0; top: 0; height: 3px; background: var(--seg); }
.seg-top .kpi-go { margin-left: auto; }
.seg-card.is-link:hover .kpi-go, .seg-go:hover .kpi-go { background: var(--lime-500); color: var(--forest-950); }
.seg-net { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; font-size: 24px; font-weight: 700; letter-spacing: -0.02em; }
.seg-net .money-ccy { font-size: 0.5em; vertical-align: 0.3em; }
.seg-share { font-size: 12px; font-weight: 600; color: var(--text-meta); letter-spacing: 0; }
.seg-spark { width: 100%; height: 44px; }
.contrib .cr b { display: inline-flex; align-items: center; gap: 8px; }
.boss-kv { margin-top: 18px; padding-top: 6px; border-top: 1px solid var(--border-soft); }
.bk-name { padding-left: 34px !important; color: var(--text-secondary); }
.seg-ic-lg { width: 56px; height: 56px; border-radius: 16px; }
.seg-ic-lg svg { width: 26px; height: 26px; }
.line-head .seg-zh { font-size: 20px; }
.page-eyebrow a { color: inherit; }
.line-band { display: grid; grid-template-columns: minmax(0, 1.2fr) minmax(0, 1fr) minmax(0, 1.4fr) minmax(0, 0.8fr); gap: 16px; margin-bottom: var(--gap); box-shadow: inset 0 3px 0 var(--seg), var(--shadow-card); }
.line-band .stat { padding-left: 16px; }
.line-band .stat:first-child { padding-left: 0; }
.line-net { font-size: 28px; }
.line-wl .seg-bar { margin: 12px 0 8px; height: 10px; }

/* ---- dialogs ---- */
.form-2, .form-3 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.form-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.form-2 + .ff, .ff + .form-2, .form-2 + .form-2, .form-3 + .ff, .ff + .form-3, .form-2 + .form-3, .form-3 + .form-2 { margin-top: 14px; }
.form-2 > .ff + .ff, .form-3 > .ff + .ff { margin-top: 0; }
.panel-body > .switch-row { margin-top: 6px; }
.panel-body > .switch-row + .switch-row { margin-top: 0; }
.dlg-fig { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; padding: 12px 14px; margin-bottom: 16px; border-radius: var(--r-btn); background: var(--surface-attn); border: 1px solid #DCEFE0; }
.dlg-fig b { font-size: 18px; font-weight: 700; }
.dlg-fig-soft { margin: 16px 0 0; background: var(--surface-soft); border-color: var(--border-soft); }
.bulk { display: grid; }
.bulk-row { display: grid; grid-template-columns: minmax(0, 1fr) 110px 110px; gap: 12px; align-items: end; padding: 10px 0; border-bottom: 1px solid var(--border-row); }
.bulk-row > span { display: grid; gap: 1px; align-self: center; }
.bulk-in { display: grid; gap: 4px; font-size: 12px; font-weight: 600; color: var(--text-meta); }
.bulk-in .input { height: 38px; text-align: right; font-variant-numeric: tabular-nums; }
.formula-kv { margin-top: 18px; }
.formula-meta { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 16px; }
.formula-meta span { display: inline-flex; gap: 6px; padding: 5px 10px; border-radius: var(--r-sm); background: var(--surface-muted); font-size: 13px; font-weight: 600; }
.formula-meta em { font-style: normal; font-weight: 500; color: var(--text-meta); }

@media (max-width: 1180px) {
  .snap-top, .health-top, .boss-hero, .stmt-hero, .net-flow { grid-template-columns: minmax(0, 1fr); }
  .boss-hero-side { padding: 18px 0 0; border-left: 0; border-top: 1px solid var(--border-soft); grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .boss-hero-side .stat { display: grid; gap: 2px; }
  .stmt-fig { justify-items: start; text-align: left; }
  .hier-sum { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .hier-used { grid-column: span 2; }
  .plat-grid, .method-strip { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .method-tile:nth-child(3) { border-left: 0; padding-left: 0; }
  .line-band { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .line-band .stat:nth-child(3) { padding-left: 0; }
}
@media (max-width: 640px) {
  .kpi-row, .kpi-row-3 { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; margin-bottom: 12px; }
  .kpi-row-3 > :first-child { grid-column: span 2; }
  .title-count { height: 22px; font-size: 12px; vertical-align: 3px; }
  .hier-sum { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .hier-sum .stat { padding-left: 0; border-left: 0; }
  .hier-used { grid-column: span 2; }
  .snap-id { gap: 12px; }
  .avatar-lg, .seg-ic-lg { width: 46px; height: 46px; font-size: 16px; border-radius: 13px; }
  .snap-bal-v { font-size: 18px; }
  .stmt-big, .boss-big { font-size: 28px; }
  .stmt-agent b { font-size: 20px; }
  .contra-sum, .req-grid, .plat-grid, .method-strip, .wl-grid { grid-template-columns: minmax(0, 1fr); }
  .plat-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
  .method-tile + .method-tile { border-left: 0; padding-left: 0; }
  .health-ring-card { flex-direction: column; align-items: stretch; }
  .ring { margin: 0 auto; }
  .boss-hero-side { grid-template-columns: minmax(0, 1fr); }
  .line-band { grid-template-columns: minmax(0, 1fr); }
  .line-band .stat { padding-left: 0; }
  .form-2, .form-3 { grid-template-columns: minmax(0, 1fr); }
  .form-2 > .ff + .ff, .form-3 > .ff + .ff { margin-top: 14px; }
  .review-cols { grid-template-columns: minmax(0, 1fr); }
  .bulk-row { grid-template-columns: minmax(0, 1fr) 84px 84px; }
  .hbar { grid-template-columns: 76px minmax(0, 1fr) 70px; }
  .rank-bar { grid-template-columns: 22px 92px minmax(0, 1fr) 60px; }
  .step-line { flex-basis: 10px; min-width: 10px; }
  .snap-bals { gap: 16px; }
  .drawer { width: 100%; }
}

/* ============================================================ 19 Utilities */
.sr, .sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; border: 0; }
.grow { flex: 1; min-width: 0; }
.nowrap { white-space: nowrap; }
.mt-0 { margin-top: 0 !important; }

/* =========================================================== 20 Responsive */
/* wide desktop → laptop: dashboard reflows to 2-up blocks */
@media (max-width: 1320px) {
  .d-used, .d-net, .d-exp, .d-ovd { grid-column: span 6; }
  .d-att { grid-column: span 12; grid-row: auto; }
  .d-chart { grid-column: span 12; }
  .d-risk, .d-age { grid-column: span 6; }
  .d-coll, .d-prov { grid-column: span 6; }
  .d-ccy { grid-column: span 12; }
  .attn-list { grid-template-columns: repeat(2, minmax(0, 1fr)); column-gap: 28px; }
  .d-att { order: 1; } .d-sec { order: 2; }
  .d-chart, .d-risk, .d-coll, .d-prov, .d-age, .d-ccy { order: 3; }
  .tb-user-text { display: none; }
}
@media (max-width: 1180px) {
  .split { grid-template-columns: minmax(0, 1fr); }
  .tb-search { width: 40px; padding: 0; justify-content: center; }
  .tb-search-txt, .tb-search kbd { display: none; }
}

/* tablet and below: the sidebar becomes a slide-out drawer */
@media (max-width: 1024px) {
  :root { --gutter: 22px; --gap: 16px; --card-pad: 20px; }
  .sidebar {
    position: fixed; inset: 0 auto 0 0; width: 272px; max-width: 86vw; height: 100dvh; z-index: var(--z-drawer);
    transform: translateX(-100%); transition: transform var(--t-slide) var(--ease); box-shadow: none;
  }
  .sidebar.open { transform: none; box-shadow: 0 0 48px rgba(0, 0, 0, 0.35); }
  .sb-collapse { display: none; }
  .tb-brand { display: inline-flex; }
  .tb-row { padding-left: 12px; }
}
@media (max-width: 860px) {
  .d-risk, .d-age, .d-coll, .d-prov { grid-column: span 12; }
  .ctx-field > svg { display: none; }
  .ctx-select { max-width: 150px; }
  .lang-top { display: none; }
}

/* phone: two-row header, 2-up KPIs, tables → cards */
@media (max-width: 640px) {
  :root { --gutter: 16px; --gap: 12px; --card-pad: 16px; --header-h: 56px; }
  h1 { font-size: 24px; }
  .main { padding-top: 18px; padding-bottom: 110px; }
  .page-head { margin-bottom: 16px; align-items: flex-start; }
  .page-head h1 + p { font-size: 13px; }
  .tb-row { flex-wrap: wrap; gap: 4px; padding: 0 8px; }
  .tb-row > .tb-menu, .tb-row > .tb-brand { order: 0; }
  .tb-brand { margin-left: 2px; }
  .ctx {
    order: 10; flex: 1 0 100%; height: 44px; margin: 0 -8px; padding: 0 10px; gap: 0;
    border-top: 1px solid var(--border-soft); overflow-x: auto; scrollbar-width: none;
  }
  .ctx::-webkit-scrollbar { display: none; }
  .ctx-field { height: 34px; padding: 0 4px 0 8px; }
  .ctx-select { font-size: 13px; max-width: none; }
  .tb-user { padding: 0 2px; } .tb-user > svg { display: none; }
  .avatar { width: 32px; height: 32px; }
  .head-actions { width: 100%; }
  .head-actions .btn { flex: 1; }

  .dash-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .dash-grid > * { grid-column: span 2 !important; grid-row: auto !important; }
  .dash-grid > .d-exp, .dash-grid > .d-ovd { grid-column: span 1 !important; }
  .d-used { order: 1; } .d-exp { order: 2; } .d-ovd { order: 3; } .d-chart { order: 4; } .d-att { order: 5; }
  .d-net { order: 6; } .d-risk { order: 7; } .d-age { order: 8; } .d-coll { order: 9; } .d-prov { order: 10; } .d-ccy { order: 11; } .d-sec { order: 12; }
  .kpi { padding: 14px; gap: 8px; }
  .kpi-value { font-size: 24px; }
  .kpi-feature .kpi-value { font-size: 28px; }
  .d-exp .kpi-value, .d-ovd .kpi-value { font-size: 20px; }
  .d-exp .kpi-cmp, .d-ovd .kpi-cmp, .d-exp .kpi-sub, .d-ovd .kpi-sub, .d-exp .kpi-go, .d-ovd .kpi-go { display: none; }
  .kpi-spark svg { width: 76px; }
  .attn-list { grid-template-columns: minmax(0, 1fr); }
  .stat-strip { grid-template-columns: repeat(2, minmax(0, 1fr)); row-gap: 16px; }
  .stat { padding: 0 0 0 14px; }
  .stat:nth-child(odd) { border-left: 0; padding-left: 0; }
  .coll-row { grid-template-columns: minmax(0, 1fr) auto 40px; }
  .coll-row .meter { grid-column: 1 / -1; order: 3; }
  .ccy-amt small { display: block; margin-left: 0; }
  .card-head { flex-wrap: wrap; }
  .card-head > .legend, .card-actions:has(.legend) { flex-basis: 100%; justify-content: flex-start; }

  .has-mlist > .tw { display: none; }
  .has-mlist > .mlist { display: block; }
  .tw td, .tw th { white-space: nowrap; }
  .tiles { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
  .tile { padding: 14px; } .tile-v { font-size: 18px; } .tile-dominant .tile-v { font-size: 24px; }
  .contrib .cr { grid-template-columns: 96px minmax(0, 1fr) 84px; }
  .snap-row .k { width: 112px; }

  .notif { position: fixed; left: 8px; right: 8px; top: 60px; width: auto; }
  .ai-fab { right: 16px; bottom: 16px; width: 48px; height: 48px; padding: 0; justify-content: center; border-radius: 14px; }
  .ai-fab span { display: none; }
  .ai-panel { width: 100vw; }
  .toasts { bottom: 76px; }

  .loginwrap { grid-template-columns: 1fr; }
  .login-hero { display: none; }
  .login-pane { align-items: flex-start; padding: 40px 20px; }
  .login-mobile-brand { display: flex; }
  .otp-box { width: 44px; height: 52px; }
}
@media (min-width: 641px) and (max-width: 900px) {
  .loginwrap { grid-template-columns: 1fr; }
  .login-hero { display: none; }
  .login-mobile-brand { display: flex; }
}

@media print {
  .app, .toasts, dialog, .ai-fab, .ai-panel, #navscrim, .loginwrap { display: none !important; }
  #print-doc { display: block !important; }
  @page { margin: 16mm; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 1ms !important; animation-delay: 0ms !important; transition-duration: 1ms !important; }
  .chart-draw, .lc-line { stroke-dashoffset: 0 !important; }
}

.stat-v.stat-ccy { font-size: 18px; line-height: 1.4; font-weight: 650; }
.stat-v.stat-ccy .mono { font-size: 12px; color: var(--text-meta); font-weight: 600; }

/* settlement drawer: position inputs (desktop table + mobile cards) */
.pos-in { width: 72px; text-align: right; }
.pos-mrow { display: flex; gap: 12px; margin: 10px 0; }
.pos-ml { flex: 1; display: flex; flex-direction: column; gap: 5px; font-size: 12px; font-weight: 600; color: var(--text-secondary); }
.pos-ml .pos-in { width: 100%; }
.mcard-foot { display: flex; align-items: center; justify-content: space-between; margin-top: 8px; }
.mcard-sel { margin-top: 10px; }
.mcard-sel .select { width: 100%; }
/* connector health banner (overall status mirrored by /api/health) */
.health-banner { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.health-banner > div { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.health-banner code { font-size: 12px; padding: 1px 6px; border-radius: 6px; background: var(--surface-input); }
.health-list li { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.health-list li .t-sub { flex: 1 1 auto; }

/* weekly settlement + boss weekly report */
.wk-bar { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.wk-bar .chip-row { flex-wrap: wrap; }
.wk-bar-r { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.wk-fx { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; color: var(--text-secondary); }
.wk-fx .input { width: 96px; }
.wk-form { display: grid; gap: 10px; }
.wk-form .btn-primary { justify-self: start; }
.health-alert p { margin: 2px 0; }
.section-h { font-size: 14px; font-weight: 650; color: var(--text-secondary); margin: 18px 0 2px; }
@media (max-width: 640px) { .wk-bar-r { width: 100%; } .wk-fx { width: 100%; } .wk-fx .input { flex: 1; } }
@media print {
  .sidebar, .topbar, .ai-fab, .ai-panel, .nav, header, .page-head .head-actions, .wk-bar-r, .boss-hero, .seg-grid, .section-h ~ * { display: none !important; }
  .main { padding: 0 !important; } .card { box-shadow: none !important; break-inside: avoid; }
}

/* ---- agent portal (own statement) ---- */
.my-preview { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 16px; }
.my-preview .select { min-width: 160px; }
.my-preview .t-sub { margin: 0; flex: 1 1 280px; }
.my-status { margin-left: auto; }
.my-pending { margin-bottom: 16px; }
.my-hero { display: grid; grid-template-columns: minmax(0, 0.9fr) minmax(0, 1.1fr); gap: 28px; align-items: center; margin-bottom: 16px; }
.my-fig { display: grid; gap: 6px; align-content: center; }
.my-fig .stmt-big { white-space: normal; overflow-wrap: anywhere; }
.my-fig .stmt-big.dim { color: var(--text-secondary); }
.my-owe { font-size: 16px; font-weight: 650; }
.my-owe.dim { color: var(--text-secondary); }
.my-hero .stmt-lines .v { min-width: 0; }
body.role-agent .ctx, body.role-agent .notif-wrap, body.role-agent .ai-fab, body.role-agent .ai-panel, body.role-agent .tb-search { display: none !important; }
@media (max-width: 760px) {
  .my-hero { grid-template-columns: minmax(0, 1fr); gap: 14px; }
  .my-fig .stmt-big { font-size: 32px; }
  .my-status { margin-left: 0; }
}
@media print { .no-print, .my-preview { display: none !important; } .my-hero { break-inside: avoid; } }
.mcard-acts { display: flex; gap: 6px; flex-shrink: 0; align-items: center; }
