/* ==========================================================================
   WiseInsure design system
   Everything is driven by CSS variables set per company in the layout:
   --brand, --accent, --fs (base font px), --radius, --font, plus
   html[data-theme], [data-menu], [data-sidebar], [data-density].
   ========================================================================== */

:root {
  --series-1: #2a78d6; --series-2: #eb6834; --series-3: #1baf7a;
  --brand: #2563eb;
  --accent: #0ea5e9;
  --fs: 14px;
  --radius: 10px;
  --font: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  --mono: ui-monospace, 'SFMono-Regular', Menlo, Consolas, monospace;

  --brand-600: color-mix(in srgb, var(--brand) 88%, #000);
  --brand-700: color-mix(in srgb, var(--brand) 75%, #000);
  --brand-50: color-mix(in srgb, var(--brand) 7%, #fff);
  --brand-100: color-mix(in srgb, var(--brand) 14%, #fff);
  --brand-200: color-mix(in srgb, var(--brand) 28%, #fff);
  --on-brand: #fff;

  --bg: #f5f7fa;
  --surface: #ffffff;
  --surface-2: #f8fafc;
  --surface-3: #f1f5f9;
  --border: #e5e8ee;
  --border-strong: #d4d9e1;
  --text: #0f172a;
  --text-2: #475569;
  --text-3: #64748b;
  --text-4: #94a3b8;
  --ring: color-mix(in srgb, var(--brand) 35%, transparent);

  --success: #059669; --success-bg: #ecfdf5; --success-bd: #a7f3d0;
  --warning: #b45309; --warning-bg: #fffbeb; --warning-bd: #fde68a;
  --danger: #dc2626;  --danger-bg: #fef2f2;  --danger-bd: #fecaca;
  --info: #0369a1;    --info-bg: #f0f9ff;    --info-bd: #bae6fd;
  --neutral: #475569; --neutral-bg: #f1f5f9; --neutral-bd: #e2e8f0;

  --shadow-sm: 0 1px 2px rgba(15, 23, 42, .05);
  --shadow: 0 1px 3px rgba(15, 23, 42, .06), 0 1px 2px rgba(15, 23, 42, .04);
  --shadow-md: 0 4px 12px rgba(15, 23, 42, .08), 0 2px 4px rgba(15, 23, 42, .04);
  --shadow-lg: 0 20px 40px -12px rgba(15, 23, 42, .25), 0 8px 16px -8px rgba(15, 23, 42, .1);

  --sidebar-w: 256px;
  --sidebar-w-collapsed: 72px;
  --header-h: 60px;
  --gap: 20px;
  --pad: 20px;
  --control-h: 38px;

  --sb-bg: #0f172a; --sb-text: #cbd5e1; --sb-muted: #64748b; --sb-hover: rgba(255,255,255,.06);
  --sb-active-bg: color-mix(in srgb, var(--brand) 22%, transparent); --sb-active-text: #fff; --sb-border: rgba(255,255,255,.06);
}

html[data-density="compact"] { --gap: 14px; --pad: 14px; --control-h: 32px; --header-h: 52px; }

html[data-sidebar="light"] { --sb-bg: var(--surface); --sb-text: var(--text-2); --sb-muted: var(--text-4); --sb-hover: var(--surface-3); --sb-active-bg: var(--brand-50); --sb-active-text: var(--brand-700); --sb-border: var(--border); }
html[data-sidebar="brand"] { --sb-bg: var(--brand-700); --sb-text: rgba(255,255,255,.82); --sb-muted: rgba(255,255,255,.55); --sb-hover: rgba(255,255,255,.1); --sb-active-bg: rgba(255,255,255,.18); --sb-active-text: #fff; --sb-border: rgba(255,255,255,.12); }

html[data-theme="dark"] {
  color-scheme: dark;
  --series-1: #3987e5; --series-2: #d95926; --series-3: #199e70;
  --bg: #0b1120; --surface: #111827; --surface-2: #0f172a; --surface-3: #1e293b;
  --border: #1f2a3c; --border-strong: #334155;
  --text: #e2e8f0; --text-2: #cbd5e1; --text-3: #94a3b8; --text-4: #64748b;
  --brand-50: color-mix(in srgb, var(--brand) 14%, #111827);
  --brand-100: color-mix(in srgb, var(--brand) 24%, #111827);
  --brand-200: color-mix(in srgb, var(--brand) 38%, #111827);
  --brand-700: color-mix(in srgb, var(--brand) 70%, #fff);
  --success: #34d399; --success-bg: rgba(16,185,129,.12); --success-bd: rgba(16,185,129,.3);
  --warning: #fbbf24; --warning-bg: rgba(245,158,11,.12); --warning-bd: rgba(245,158,11,.3);
  --danger: #f87171;  --danger-bg: rgba(239,68,68,.12);  --danger-bd: rgba(239,68,68,.3);
  --info: #38bdf8;    --info-bg: rgba(14,165,233,.12);   --info-bd: rgba(14,165,233,.3);
  --neutral: #94a3b8; --neutral-bg: rgba(148,163,184,.12); --neutral-bd: rgba(148,163,184,.25);
  --shadow: 0 1px 3px rgba(0,0,0,.4); --shadow-md: 0 4px 12px rgba(0,0,0,.45); --shadow-lg: 0 20px 40px -12px rgba(0,0,0,.7);
  --sb-bg: #0a0f1c;
}
html[data-theme="dark"][data-sidebar="light"] { --sb-bg: var(--surface); }

/* ── Base ──────────────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; }
html { font-size: var(--fs); -webkit-text-size-adjust: 100%; }
body { margin: 0; font-family: var(--font); font-size: 1rem; line-height: 1.5; color: var(--text); background: var(--bg); -webkit-font-smoothing: antialiased; }
a { color: var(--brand-600); text-decoration: none; }
a:hover { color: var(--brand-700); text-decoration: underline; text-underline-offset: 2px; }
h1, h2, h3, h4 { margin: 0; line-height: 1.25; font-weight: 650; letter-spacing: -.01em; }
p { margin: 0 0 .75rem; }
hr { border: 0; border-top: 1px solid var(--border); margin: var(--gap) 0; }
img { max-width: 100%; }
code, .mono { font-family: var(--mono); font-size: .92em; }
.icon { width: 1.15em; height: 1.15em; flex: none; stroke: currentColor; fill: none; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; vertical-align: -.2em; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
::selection { background: var(--brand-200); }
:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; }

/* ── App shell ─────────────────────────────────────────────────────────── */
.app { min-height: 100vh; display: grid; grid-template-columns: var(--sidebar-w) minmax(0, 1fr); grid-template-areas: "side main"; }
html[data-menu="right"] .app { grid-template-columns: minmax(0, 1fr) var(--sidebar-w); grid-template-areas: "main side"; }
html[data-menu="top"] .app { grid-template-columns: minmax(0, 1fr); grid-template-areas: "main"; }
html.sb-collapsed .app { grid-template-columns: var(--sidebar-w-collapsed) minmax(0, 1fr); }
html.sb-collapsed[data-menu="right"] .app { grid-template-columns: minmax(0, 1fr) var(--sidebar-w-collapsed); }
.main { grid-area: main; min-width: 0; display: flex; flex-direction: column; }
.content { padding: calc(var(--gap) + 4px) calc(var(--gap) + 8px) 48px; width: 100%; max-width: 1480px; margin: 0 auto; flex: 1; }

/* Sidebar */
.sidebar { grid-area: side; position: sticky; top: 0; height: 100vh; background: var(--sb-bg); color: var(--sb-text); display: flex; flex-direction: column; border-right: 1px solid var(--sb-border); z-index: 40; }
html[data-menu="right"] .sidebar { border-right: 0; border-left: 1px solid var(--sb-border); }
html[data-menu="top"] .sidebar { display: none; }
.sb-brand { height: var(--header-h); display: flex; align-items: center; gap: 10px; padding: 0 16px; border-bottom: 1px solid var(--sb-border); flex: none; }
.sb-logo { width: 34px; height: 34px; border-radius: 9px; background: var(--brand); color: #fff; display: grid; place-items: center; font-weight: 700; font-size: 13px; flex: none; overflow: hidden; }
.sb-logo img { width: 100%; height: 100%; object-fit: contain; background: #fff; }
.sb-name { font-weight: 650; color: var(--sb-active-text); font-size: 1rem; line-height: 1.2; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
html[data-sidebar="light"] .sb-name { color: var(--text); }
.sb-sub { font-size: .78rem; color: var(--sb-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sb-nav { flex: 1; overflow-y: auto; padding: 12px 10px; scrollbar-width: thin; scrollbar-color: var(--sb-hover) transparent; }
.sb-item, .sb-sub a { display: flex; align-items: center; gap: 11px; padding: 8px 11px; border-radius: 8px; color: var(--sb-text); font-weight: 500; cursor: pointer; background: none; border: 0; width: 100%; font: inherit; text-align: left; white-space: nowrap; }
.sb-item:hover, .sb-sub a:hover { background: var(--sb-hover); color: var(--sb-active-text); text-decoration: none; }
html[data-sidebar="light"] .sb-item:hover, html[data-sidebar="light"] .sb-sub a:hover { color: var(--text); }
.sb-item.active { background: var(--sb-active-bg); color: var(--sb-active-text); }
.sb-item .icon { width: 18px; height: 18px; opacity: .9; }
.sb-item .chev { margin-left: auto; width: 14px; height: 14px; transition: transform .2s; opacity: .6; }
.sb-group.open > .sb-item .chev { transform: rotate(90deg); }
.sb-sub { display: none; padding: 2px 0 6px 29px; }
.sb-group.open > .sb-sub { display: block; }
.sb-sub a { font-weight: 450; padding: 6px 11px; font-size: .95rem; color: var(--sb-muted); position: relative; }
.sb-sub a::before { content: ''; position: absolute; left: -9px; top: 50%; width: 5px; height: 5px; border-radius: 50%; background: currentColor; opacity: .35; transform: translateY(-50%); }
.sb-sub a.active { color: var(--sb-active-text); font-weight: 600; }
html[data-sidebar="light"] .sb-sub a.active { color: var(--brand-700); }
.sb-sub a.active::before { opacity: 1; background: var(--brand); }
html[data-sidebar="brand"] .sb-sub a.active::before { background: #fff; }
.sb-count { margin-left: auto; background: var(--brand); color: #fff; font-size: .72rem; font-weight: 700; border-radius: 999px; padding: 1px 7px; min-width: 20px; text-align: center; }
html[data-sidebar="brand"] .sb-count { background: #fff; color: var(--brand-700); }
.sb-foot { padding: 12px; border-top: 1px solid var(--sb-border); font-size: .8rem; color: var(--sb-muted); display: flex; align-items: center; gap: 8px; }
.sb-collapse { background: none; border: 0; color: var(--sb-muted); cursor: pointer; padding: 6px; border-radius: 6px; margin-left: auto; }
.sb-collapse:hover { background: var(--sb-hover); color: var(--sb-active-text); }
html.sb-collapsed .sb-name, html.sb-collapsed .sb-sub-title, html.sb-collapsed .sb-item span, html.sb-collapsed .sb-item .chev, html.sb-collapsed .sb-sub, html.sb-collapsed .sb-foot-text, html.sb-collapsed .sb-count { display: none !important; }
html.sb-collapsed .sb-item { justify-content: center; padding: 10px; }
html.sb-collapsed .sb-brand { justify-content: center; padding: 0; }
html.sb-collapsed .sb-foot { justify-content: center; }
html.sb-collapsed .sb-collapse { margin: 0; transform: rotate(180deg); }
html.sb-collapsed[data-menu="right"] .sb-collapse, html[data-menu="right"] .sb-collapse { transform: rotate(180deg); }
html.sb-collapsed[data-menu="right"] .sb-collapse { transform: none; }

/* Header */
.header { height: var(--header-h); background: var(--surface); border-bottom: 1px solid var(--border); display: flex; align-items: center; gap: 12px; padding: 0 calc(var(--gap) + 8px); position: sticky; top: 0; z-index: 30; }
.header .brand-inline { display: none; align-items: center; gap: 10px; font-weight: 650; color: var(--text); margin-right: 8px; }
html[data-menu="top"] .header .brand-inline { display: flex; }
.header .brand-inline .sb-logo { width: 32px; height: 32px; }
.menu-toggle { display: none; }
.search { position: relative; flex: 1; max-width: 460px; }
.search input { width: 100%; height: 38px; border-radius: 9px; border: 1px solid var(--border); background: var(--surface-2); padding: 0 12px 0 36px; font: inherit; color: var(--text); transition: .15s; }
.search input:focus { outline: 0; border-color: var(--brand); background: var(--surface); box-shadow: 0 0 0 3px var(--ring); }
.search > .icon { position: absolute; left: 11px; top: 50%; transform: translateY(-50%); color: var(--text-4); }
.search kbd { position: absolute; right: 9px; top: 50%; transform: translateY(-50%); font-size: .7rem; color: var(--text-4); border: 1px solid var(--border); border-radius: 5px; padding: 1px 5px; background: var(--surface); font-family: inherit; }
.search-results { position: absolute; top: calc(100% + 6px); left: 0; right: 0; background: var(--surface); border: 1px solid var(--border); border-radius: 12px; box-shadow: var(--shadow-lg); padding: 6px; display: none; max-height: 420px; overflow: auto; z-index: 60; }
.search-results.open { display: block; }
.search-results .sr-group { font-size: .72rem; text-transform: uppercase; letter-spacing: .06em; color: var(--text-4); padding: 8px 10px 4px; font-weight: 600; }
.search-results a { display: flex; gap: 10px; align-items: center; padding: 8px 10px; border-radius: 8px; color: var(--text); }
.search-results a:hover, .search-results a.hl { background: var(--brand-50); text-decoration: none; }
.search-results .sr-meta { color: var(--text-3); font-size: .85rem; margin-left: auto; }
.header-actions { margin-left: auto; display: flex; align-items: center; gap: 6px; }
.hbtn { position: relative; height: 38px; min-width: 38px; border-radius: 9px; border: 0; background: none; color: var(--text-2); display: inline-flex; align-items: center; justify-content: center; gap: 6px; cursor: pointer; padding: 0 9px; font: inherit; }
.hbtn:hover { background: var(--surface-3); color: var(--text); }
.hbtn .icon { width: 19px; height: 19px; }
.hbtn .pip { position: absolute; top: 5px; right: 5px; min-width: 17px; height: 17px; border-radius: 999px; background: var(--danger); color: #fff; font-size: .68rem; font-weight: 700; display: grid; place-items: center; padding: 0 4px; border: 2px solid var(--surface); }
.user-chip { display: flex; align-items: center; gap: 9px; padding: 4px 8px 4px 4px; border-radius: 10px; border: 0; background: none; cursor: pointer; font: inherit; color: var(--text); text-align: left; }
.user-chip:hover { background: var(--surface-3); }
.user-chip .who { line-height: 1.2; }
.user-chip .who b { display: block; font-weight: 600; font-size: .92rem; }
.user-chip .who small { color: var(--text-3); font-size: .78rem; }

/* Top navigation (menu position = top) */
.topnav { display: none; background: var(--surface); border-bottom: 1px solid var(--border); padding: 0 calc(var(--gap) + 8px); position: sticky; top: var(--header-h); z-index: 29; }
html[data-menu="top"] .topnav { display: block; }
html[data-menu="top"][data-sidebar="brand"] .topnav, html[data-menu="top"][data-sidebar="dark"] .topnav { background: var(--sb-bg); border-color: var(--sb-border); }
.topnav-inner { display: flex; gap: 2px; align-items: center; overflow-x: auto; scrollbar-width: none; }
.tn-item { position: relative; }
.tn-link { display: flex; align-items: center; gap: 7px; padding: 12px 12px; color: var(--sb-text); font-weight: 500; border: 0; background: none; font: inherit; cursor: pointer; white-space: nowrap; border-bottom: 2px solid transparent; }
html[data-sidebar="light"] .tn-link { color: var(--text-2); }
.tn-link:hover { color: var(--sb-active-text); text-decoration: none; }
html[data-sidebar="light"] .tn-link:hover { color: var(--text); }
.tn-link.active { color: var(--sb-active-text); border-bottom-color: var(--brand); }
html[data-sidebar="brand"] .tn-link.active { border-bottom-color: #fff; }
html[data-sidebar="light"] .tn-link.active { color: var(--brand-700); }
.tn-link .icon { width: 17px; height: 17px; }
.tn-menu { position: fixed; min-width: 220px; background: var(--surface); border: 1px solid var(--border); border-radius: 12px; box-shadow: var(--shadow-lg); padding: 6px; display: none; z-index: 70; }
.tn-item.open .tn-menu { display: block; }
.tn-menu a { display: block; padding: 8px 11px; border-radius: 8px; color: var(--text); }
.tn-menu a:hover, .tn-menu a.active { background: var(--brand-50); color: var(--brand-700); text-decoration: none; }

/* ── Page header, breadcrumbs ─────────────────────────────────────────── */
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: calc(var(--gap) + 2px); flex-wrap: wrap; }
.page-head h1 { font-size: 1.6rem; font-weight: 700; letter-spacing: -.02em; }
.page-head .sub { color: var(--text-3); margin-top: 4px; }
.page-head .actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.crumbs { display: flex; align-items: center; gap: 6px; font-size: .85rem; color: var(--text-3); margin-bottom: 8px; flex-wrap: wrap; }
.crumbs a { color: var(--text-3); }
.crumbs .icon { width: 13px; height: 13px; opacity: .6; }
.title-row { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }

/* ── Buttons ──────────────────────────────────────────────────────────── */
.btn { --b-bg: var(--surface); --b-fg: var(--text); --b-bd: var(--border-strong); display: inline-flex; align-items: center; justify-content: center; gap: 7px; height: var(--control-h); padding: 0 14px; border-radius: calc(var(--radius) * .85); border: 1px solid var(--b-bd); background: var(--b-bg); color: var(--b-fg); font: inherit; font-weight: 550; cursor: pointer; white-space: nowrap; transition: background .15s, border-color .15s, box-shadow .15s, transform .05s; box-shadow: var(--shadow-sm); text-decoration: none !important; user-select: none; }
.btn:hover { background: var(--surface-3); color: var(--b-fg); }
.btn:active { transform: translateY(1px); }
.btn:focus-visible { outline: 0; box-shadow: 0 0 0 3px var(--ring); }
.btn[disabled], .btn.disabled { opacity: .55; pointer-events: none; }
.btn .icon { width: 16px; height: 16px; }
.btn-primary { --b-bg: var(--brand); --b-fg: var(--on-brand); --b-bd: var(--brand); }
.btn-primary:hover { background: var(--brand-600); border-color: var(--brand-600); color: var(--on-brand); }
.btn-success { --b-bg: #059669; --b-fg: #fff; --b-bd: #059669; }
.btn-success:hover { background: #047857; color: #fff; }
.btn-danger { --b-bg: #dc2626; --b-fg: #fff; --b-bd: #dc2626; }
.btn-danger:hover { background: #b91c1c; color: #fff; }
.btn-warning { --b-bg: #d97706; --b-fg: #fff; --b-bd: #d97706; }
.btn-warning:hover { background: #b45309; color: #fff; }
.btn-soft { --b-bg: var(--brand-50); --b-fg: var(--brand-700); --b-bd: transparent; box-shadow: none; }
.btn-soft:hover { background: var(--brand-100); }
.btn-ghost { --b-bg: transparent; --b-bd: transparent; box-shadow: none; --b-fg: var(--text-2); }
.btn-ghost:hover { background: var(--surface-3); }
.btn-danger-ghost { --b-bg: transparent; --b-bd: transparent; box-shadow: none; --b-fg: var(--danger); }
.btn-danger-ghost:hover { background: var(--danger-bg); color: var(--danger); }
.btn-sm { height: calc(var(--control-h) - 8px); padding: 0 10px; font-size: .9rem; }
.btn-lg { height: calc(var(--control-h) + 8px); padding: 0 20px; font-size: 1.05rem; }
.btn-icon { width: var(--control-h); padding: 0; }
.btn-sm.btn-icon { width: calc(var(--control-h) - 8px); }
.btn-block { width: 100%; }
.btn-group { display: inline-flex; }
.btn-group .btn { border-radius: 0; margin-left: -1px; }
.btn-group .btn:first-child { border-radius: calc(var(--radius) * .85) 0 0 calc(var(--radius) * .85); margin-left: 0; }
.btn-group .btn:last-child { border-radius: 0 calc(var(--radius) * .85) calc(var(--radius) * .85) 0; }
.btn-group .btn.on { background: var(--brand-50); color: var(--brand-700); border-color: var(--brand-200); z-index: 1; }
.btn .spinner { width: 14px; height: 14px; border: 2px solid currentColor; border-right-color: transparent; border-radius: 50%; animation: spin .7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ── Cards ────────────────────────────────────────────────────────────── */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); min-width: 0; }
.content > .card + .card, .content > form > .card + .card { margin-top: var(--gap); }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 14px var(--pad); border-bottom: 1px solid var(--border); min-height: 54px; flex-wrap: wrap; }
.card-head h2, .card-head h3 { font-size: 1.02rem; font-weight: 650; display: flex; align-items: center; gap: 8px; }
.card-head h2 .icon, .card-head h3 .icon { color: var(--text-3); }
.card-head .sub { color: var(--text-3); font-size: .88rem; font-weight: 400; }
.card-body { padding: var(--pad); }
.card-foot { padding: 12px var(--pad); border-top: 1px solid var(--border); background: var(--surface-2); border-radius: 0 0 var(--radius) var(--radius); display: flex; gap: 8px; justify-content: flex-end; align-items: center; flex-wrap: wrap; }
.card-flush .card-body { padding: 0; }
.card.accent-top { border-top: 3px solid var(--brand); }

/* ── Grid & utilities ─────────────────────────────────────────────────── */
.grid { display: grid; gap: var(--gap); }
.g-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.g-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.g-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.g-main { grid-template-columns: minmax(0, 2fr) minmax(300px, 1fr); }
.g-side { grid-template-columns: 280px minmax(0, 1fr); }
.stack { display: flex; flex-direction: column; gap: var(--gap); }
.row { display: flex; align-items: center; gap: 10px; }
.row-wrap { flex-wrap: wrap; }
.between { justify-content: space-between; }
.end { justify-content: flex-end; }
.grow { flex: 1; min-width: 0; }
.mt-0 { margin-top: 0 !important; } .mt-1 { margin-top: 6px; } .mt-2 { margin-top: 12px; } .mt-3 { margin-top: 18px; } .mt-4 { margin-top: 24px; }
.mb-0 { margin-bottom: 0 !important; } .mb-1 { margin-bottom: 6px; } .mb-2 { margin-bottom: 12px; } .mb-3 { margin-bottom: 18px; } .mb-4 { margin-bottom: 24px; }
.gap-1 { gap: 6px; } .gap-2 { gap: 12px; } .gap-3 { gap: 18px; }
.muted { color: var(--text-3); } .faint { color: var(--text-4); } .small { font-size: .86rem; } .tiny { font-size: .76rem; }
.strong { font-weight: 650; } .fw-500 { font-weight: 500; }
.right { text-align: right; } .center { text-align: center; }
.nowrap { white-space: nowrap; }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.num { font-variant-numeric: tabular-nums; text-align: right; white-space: nowrap; }
.text-success { color: var(--success); } .text-danger { color: var(--danger); } .text-warning { color: var(--warning); } .text-brand { color: var(--brand-600); }
.hidden { display: none !important; }
.divider { height: 1px; background: var(--border); margin: 16px 0; }

/* ── Forms ────────────────────────────────────────────────────────────── */
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px 18px; }
.form-grid.cols-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.form-grid.cols-1 { grid-template-columns: minmax(0, 1fr); }
.span-2 { grid-column: span 2; } .span-3 { grid-column: 1 / -1; } .span-all { grid-column: 1 / -1; }
.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.field > label, .label { font-weight: 550; font-size: .9rem; color: var(--text-2); }
.field > label .req, .label .req { color: var(--danger); margin-left: 2px; }
.hint { font-size: .8rem; color: var(--text-3); }
.input, .select, .textarea { width: 100%; height: var(--control-h); border: 1px solid var(--border-strong); border-radius: calc(var(--radius) * .8); background: var(--surface); color: var(--text); font: inherit; padding: 0 11px; transition: border-color .15s, box-shadow .15s; }
.textarea { height: auto; min-height: 88px; padding: 9px 11px; resize: vertical; line-height: 1.45; }
.select { appearance: none; padding-right: 32px; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%2394a3b8' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 9px center; }
.input:hover, .select:hover, .textarea:hover { border-color: var(--text-4); }
.input:focus, .select:focus, .textarea:focus { outline: 0; border-color: var(--brand); box-shadow: 0 0 0 3px var(--ring); }
.input[readonly], .input:disabled, .select:disabled { background: var(--surface-3); color: var(--text-3); }
.is-invalid { border-color: var(--danger) !important; }
.is-invalid:focus { box-shadow: 0 0 0 3px color-mix(in srgb, var(--danger) 25%, transparent) !important; }
.field-error { color: var(--danger); font-size: .82rem; }
.input-group { display: flex; align-items: stretch; }
.input-group .input { border-radius: 0; flex: 1; min-width: 0; }
.input-group .input:first-child { border-radius: calc(var(--radius) * .8) 0 0 calc(var(--radius) * .8); }
.input-group .input:last-child { border-radius: 0 calc(var(--radius) * .8) calc(var(--radius) * .8) 0; }
.input-group .addon { display: flex; align-items: center; padding: 0 11px; background: var(--surface-3); border: 1px solid var(--border-strong); color: var(--text-3); font-size: .9rem; white-space: nowrap; }
.input-group .addon:first-child { border-right: 0; border-radius: calc(var(--radius) * .8) 0 0 calc(var(--radius) * .8); }
.input-group .addon:last-child { border-left: 0; border-radius: 0 calc(var(--radius) * .8) calc(var(--radius) * .8) 0; }
.input-icon { position: relative; }
.input-icon .icon { position: absolute; left: 11px; top: 50%; transform: translateY(-50%); color: var(--text-4); pointer-events: none; }
.input-icon .input { padding-left: 35px; }
.check { display: inline-flex; align-items: center; gap: 9px; cursor: pointer; user-select: none; }
.check input { width: 17px; height: 17px; accent-color: var(--brand); margin: 0; }
.fieldset { border: 1px solid var(--border); border-radius: var(--radius); padding: 16px 18px; }
.fieldset legend { padding: 0 6px; font-weight: 650; color: var(--text-2); }
.form-section { padding: var(--pad); border-bottom: 1px solid var(--border); }
.form-section:last-child { border-bottom: 0; }
.form-section h3 { font-size: 1rem; margin-bottom: 4px; }
.form-section > .muted { margin-bottom: 16px; }
.form-2col { display: grid; grid-template-columns: 260px minmax(0, 1fr); gap: 24px; }
.form-2col .desc h3 { font-size: 1rem; margin-bottom: 4px; }

/* Switch */
.switch { position: relative; display: inline-flex; align-items: center; gap: 10px; cursor: pointer; user-select: none; }
.switch input { position: absolute; opacity: 0; width: 0; height: 0; }
.switch .track { width: 38px; height: 22px; border-radius: 999px; background: var(--border-strong); position: relative; transition: background .2s; flex: none; }
.switch .track::after { content: ''; position: absolute; top: 3px; left: 3px; width: 16px; height: 16px; border-radius: 50%; background: #fff; box-shadow: 0 1px 2px rgba(0,0,0,.25); transition: transform .2s; }
.switch input:checked + .track { background: var(--brand); }
.switch input:checked + .track::after { transform: translateX(16px); }
.switch input:focus-visible + .track { box-shadow: 0 0 0 3px var(--ring); }
.switch input:disabled + .track { opacity: .5; }
.switch.sm .track { width: 32px; height: 18px; }
.switch.sm .track::after { width: 12px; height: 12px; }
.switch.sm input:checked + .track::after { transform: translateX(14px); }

/* Segmented choice (radio cards) */
.choices { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 10px; }
.choice { position: relative; }
.choice input { position: absolute; opacity: 0; }
.choice .box { display: flex; flex-direction: column; gap: 6px; padding: 12px; border: 1.5px solid var(--border); border-radius: var(--radius); cursor: pointer; transition: .15s; height: 100%; background: var(--surface); }
.choice .box:hover { border-color: var(--text-4); }
.choice input:checked + .box { border-color: var(--brand); background: var(--brand-50); box-shadow: 0 0 0 3px var(--ring); }
.choice input:focus-visible + .box { box-shadow: 0 0 0 3px var(--ring); }
.choice .box b { font-weight: 600; }
.choice .box small { color: var(--text-3); }

/* Combobox (enhanced select) */
.combo { position: relative; }
.combo-display { width: 100%; height: var(--control-h); border: 1px solid var(--border-strong); border-radius: calc(var(--radius) * .8); background: var(--surface); color: var(--text); font: inherit; padding: 0 32px 0 11px; text-align: left; cursor: pointer; display: flex; align-items: center; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%2394a3b8' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 9px center; }
.combo-display.placeholder { color: var(--text-4); }
.combo-display:focus { outline: 0; border-color: var(--brand); box-shadow: 0 0 0 3px var(--ring); }
.combo-pop { position: absolute; top: calc(100% + 4px); left: 0; right: 0; background: var(--surface); border: 1px solid var(--border); border-radius: 12px; box-shadow: var(--shadow-lg); z-index: 80; display: none; }
.combo.open .combo-pop { display: block; }
.combo-pop input { width: calc(100% - 12px); margin: 6px; height: 34px; border: 1px solid var(--border); border-radius: 8px; padding: 0 10px; font: inherit; background: var(--surface-2); color: var(--text); }
.combo-pop input:focus { outline: 0; border-color: var(--brand); }
.combo-list { max-height: 260px; overflow: auto; padding: 0 6px 6px; }
.combo-opt { padding: 8px 10px; border-radius: 8px; cursor: pointer; display: flex; flex-direction: column; }
.combo-opt small { color: var(--text-3); }
.combo-opt.hl, .combo-opt:hover { background: var(--brand-50); }
.combo-opt.sel { font-weight: 600; color: var(--brand-700); }
.combo-empty { padding: 12px; color: var(--text-3); text-align: center; }

/* ── Tables ───────────────────────────────────────────────────────────── */
.table-wrap { overflow-x: auto; }
.table { width: 100%; border-collapse: separate; border-spacing: 0; font-size: .95rem; }
.table th { text-align: left; font-weight: 600; font-size: .78rem; text-transform: uppercase; letter-spacing: .04em; color: var(--text-3); background: var(--surface-2); padding: 10px 14px; border-bottom: 1px solid var(--border); white-space: nowrap; position: sticky; top: 0; }
.table td { padding: 11px 14px; border-bottom: 1px solid var(--border); vertical-align: middle; }
html[data-density="compact"] .table td { padding: 7px 12px; }
html[data-density="compact"] .table th { padding: 7px 12px; }
.table tbody tr { transition: background .1s; }
.table tbody tr:hover { background: var(--surface-2); }
.table tbody tr:last-child td { border-bottom: 0; }
.table tr.clickable { cursor: pointer; }
.table .num, .table th.num { text-align: right; }
.table td.actions { text-align: right; white-space: nowrap; width: 1%; }
.table tfoot td { font-weight: 650; background: var(--surface-2); border-top: 1px solid var(--border); border-bottom: 0; }
.table .cell-main { font-weight: 600; color: var(--text); }
.table .cell-sub { font-size: .82rem; color: var(--text-3); }
.table a.cell-main:hover { color: var(--brand-700); }
.table-sm td, .table-sm th { padding: 7px 12px; }
.card > .table-wrap:first-child .table th:first-child { border-top-left-radius: var(--radius); }
.card > .table-wrap:first-child .table th:last-child { border-top-right-radius: var(--radius); }

/* Filters bar */
.filters { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; padding: 12px var(--pad); border-bottom: 1px solid var(--border); }
.filters .input, .filters .select { width: auto; min-width: 150px; height: 36px; }
.filters .input-icon { flex: 1; min-width: 220px; max-width: 380px; }
.filters .input-icon .input { width: 100%; }
.chip-tabs { display: flex; gap: 4px; flex-wrap: wrap; }
.chip-tab { padding: 6px 12px; border-radius: 999px; color: var(--text-2); font-weight: 500; font-size: .9rem; border: 1px solid transparent; }
.chip-tab:hover { background: var(--surface-3); text-decoration: none; color: var(--text); }
.chip-tab.active { background: var(--brand-50); color: var(--brand-700); border-color: var(--brand-200); }
.chip-tab .count { margin-left: 5px; font-size: .78rem; color: var(--text-3); }

/* Pagination */
.pager { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px var(--pad); border-top: 1px solid var(--border); flex-wrap: wrap; }
.pager .pages { display: flex; gap: 4px; }
.pager a, .pager span.cur { min-width: 34px; height: 34px; border-radius: 8px; display: inline-flex; align-items: center; justify-content: center; padding: 0 8px; border: 1px solid var(--border); color: var(--text-2); font-weight: 500; font-size: .9rem; }
.pager a:hover { background: var(--surface-3); text-decoration: none; }
.pager span.cur { background: var(--brand); border-color: var(--brand); color: #fff; }
.pager .gap { padding: 0 4px; color: var(--text-4); align-self: center; }

/* ── Badges, pills, avatars ───────────────────────────────────────────── */
.badge { display: inline-flex; align-items: center; gap: 6px; padding: 2px 9px; border-radius: 999px; font-size: .78rem; font-weight: 600; white-space: nowrap; border: 1px solid transparent; line-height: 1.6; }
.badge .dot { width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.badge-success { color: var(--success); background: var(--success-bg); border-color: var(--success-bd); }
.badge-warning { color: var(--warning); background: var(--warning-bg); border-color: var(--warning-bd); }
.badge-danger { color: var(--danger); background: var(--danger-bg); border-color: var(--danger-bd); }
.badge-info { color: var(--info); background: var(--info-bg); border-color: var(--info-bd); }
.badge-neutral { color: var(--neutral); background: var(--neutral-bg); border-color: var(--neutral-bd); }
.badge-brand { color: var(--brand-700); background: var(--brand-50); border-color: var(--brand-200); }
.tag { display: inline-flex; align-items: center; gap: 5px; padding: 1px 8px; border-radius: 6px; font-size: .78rem; font-weight: 550; background: var(--surface-3); color: var(--text-2); border: 1px solid var(--border); }
.avatar { width: 34px; height: 34px; border-radius: 50%; background: var(--brand-100); color: var(--brand-700); display: inline-grid; place-items: center; font-weight: 650; font-size: .82rem; flex: none; }
.avatar.lg { width: 56px; height: 56px; font-size: 1.15rem; }
.avatar.sm { width: 26px; height: 26px; font-size: .7rem; }
.avatar-stack { display: flex; }
.avatar-stack .avatar { border: 2px solid var(--surface); margin-left: -8px; }
.avatar-stack .avatar:first-child { margin-left: 0; }

/* ── Stat tiles ───────────────────────────────────────────────────────── */
.stat { padding: 16px var(--pad); display: flex; gap: 14px; align-items: flex-start; }
.stat .ico { width: 42px; height: 42px; border-radius: 11px; display: grid; place-items: center; flex: none; background: var(--brand-50); color: var(--brand-600); }
.stat .ico .icon { width: 21px; height: 21px; }
.stat .ico.green { background: var(--success-bg); color: var(--success); }
.stat .ico.amber { background: var(--warning-bg); color: var(--warning); }
.stat .ico.red { background: var(--danger-bg); color: var(--danger); }
.stat .ico.sky { background: var(--info-bg); color: var(--info); }
.stat .lbl { color: var(--text-3); font-size: .86rem; font-weight: 500; }
.stat .val { font-size: 1.55rem; font-weight: 700; letter-spacing: -.02em; line-height: 1.25; margin-top: 2px; font-variant-numeric: tabular-nums; }
.stat .foot { font-size: .8rem; color: var(--text-3); margin-top: 4px; }
.stat .foot .up { color: var(--success); font-weight: 600; }
.stat .foot .down { color: var(--danger); font-weight: 600; }
a.card.stat-link { display: block; color: inherit; transition: border-color .15s, box-shadow .15s, transform .15s; }
a.card.stat-link:hover { border-color: var(--brand-200); box-shadow: var(--shadow-md); text-decoration: none; transform: translateY(-1px); }

/* ── Key-value lists ──────────────────────────────────────────────────── */
.kv { display: grid; grid-template-columns: minmax(120px, 38%) minmax(0, 1fr); gap: 0; }
.kv > div { padding: 9px 0; border-bottom: 1px dashed var(--border); }
.kv > div:nth-last-child(-n+2) { border-bottom: 0; }
.kv .k { color: var(--text-3); font-size: .9rem; }
.kv .v { font-weight: 500; text-align: right; overflow-wrap: anywhere; }
.kv.left .v { text-align: left; }
.kv-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 16px 20px; }
.kv-grid .k { color: var(--text-3); font-size: .82rem; margin-bottom: 2px; }
.kv-grid .v { font-weight: 550; overflow-wrap: anywhere; }

/* Amount summary (premium breakdown) */
.sum-box { background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px 16px; }
.sum-line { display: flex; justify-content: space-between; padding: 5px 0; font-variant-numeric: tabular-nums; }
.sum-line.total { border-top: 1px solid var(--border-strong); margin-top: 6px; padding-top: 10px; font-weight: 700; font-size: 1.12rem; }
.sum-line .muted { font-size: .9rem; }

/* ── Tabs ─────────────────────────────────────────────────────────────── */
.tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--border); padding: 0 var(--pad); overflow-x: auto; scrollbar-width: none; }
.tab { padding: 12px 12px; border: 0; background: none; font: inherit; font-weight: 550; color: var(--text-3); cursor: pointer; border-bottom: 2px solid transparent; margin-bottom: -1px; white-space: nowrap; display: inline-flex; align-items: center; gap: 7px; }
.tab:hover { color: var(--text); text-decoration: none; }
.tab.active { color: var(--brand-700); border-bottom-color: var(--brand); }
.tab .count { font-size: .75rem; background: var(--surface-3); color: var(--text-3); border-radius: 999px; padding: 0 7px; }
.tab.active .count { background: var(--brand-100); color: var(--brand-700); }
.tab-panel { display: none; }
.tab-panel.active { display: block; }

/* ── Alerts, empty states ─────────────────────────────────────────────── */
.alert { display: flex; gap: 12px; align-items: flex-start; padding: 12px 14px; border-radius: var(--radius); border: 1px solid; margin-bottom: var(--gap); }
.alert .icon { margin-top: 2px; width: 18px; height: 18px; }
.alert b { display: block; margin-bottom: 2px; }
.alert-info { background: var(--info-bg); border-color: var(--info-bd); color: var(--info); }
.alert-success { background: var(--success-bg); border-color: var(--success-bd); color: var(--success); }
.alert-warning { background: var(--warning-bg); border-color: var(--warning-bd); color: var(--warning); }
.alert-danger { background: var(--danger-bg); border-color: var(--danger-bd); color: var(--danger); }
.alert .alert-body { color: var(--text-2); }
.alert .alert-body b { color: inherit; }
.alert-info .alert-body b { color: var(--info); } .alert-success .alert-body b { color: var(--success); } .alert-warning .alert-body b { color: var(--warning); } .alert-danger .alert-body b { color: var(--danger); }
.empty { text-align: center; padding: 48px 20px; color: var(--text-3); }
.empty .ico { width: 56px; height: 56px; border-radius: 16px; display: grid; place-items: center; margin: 0 auto 14px; background: var(--surface-3); color: var(--text-4); }
.empty .ico .icon { width: 26px; height: 26px; }
.empty h3 { color: var(--text); font-size: 1.05rem; margin-bottom: 4px; }

/* ── Dropdown ─────────────────────────────────────────────────────────── */
.dropdown { position: relative; }
.dd-menu { position: absolute; right: 0; top: calc(100% + 6px); min-width: 220px; background: var(--surface); border: 1px solid var(--border); border-radius: 12px; box-shadow: var(--shadow-lg); padding: 6px; display: none; z-index: 70; }
.dropdown.left .dd-menu { right: auto; left: 0; }
.dropdown.open .dd-menu { display: block; animation: pop .12s ease-out; }
@keyframes pop { from { opacity: 0; transform: translateY(-4px); } to { opacity: 1; transform: none; } }
.dd-menu a, .dd-menu button { display: flex; width: 100%; align-items: center; gap: 10px; padding: 8px 10px; border-radius: 8px; color: var(--text); background: none; border: 0; font: inherit; text-align: left; cursor: pointer; }
.dd-menu a:hover, .dd-menu button:hover { background: var(--surface-3); text-decoration: none; }
.dd-menu .icon { color: var(--text-3); width: 16px; height: 16px; }
.dd-menu .danger, .dd-menu .danger .icon { color: var(--danger); }
.dd-sep { height: 1px; background: var(--border); margin: 6px 4px; }
.dd-head { padding: 8px 10px 10px; border-bottom: 1px solid var(--border); margin-bottom: 6px; }
.dd-label { font-size: .72rem; text-transform: uppercase; letter-spacing: .06em; color: var(--text-4); padding: 6px 10px 4px; font-weight: 600; }
.dd-row { display: flex; gap: 4px; padding: 2px 6px 6px; }
.dd-row button { flex: 1; justify-content: center; border: 1px solid var(--border); padding: 6px 4px; font-size: .82rem; }
.dd-row button.on { background: var(--brand-50); border-color: var(--brand-200); color: var(--brand-700); }

/* Notifications panel */
.notif-menu { width: 380px; padding: 0; }
.notif-menu .nm-head { display: flex; justify-content: space-between; align-items: center; padding: 12px 14px; border-bottom: 1px solid var(--border); }
.notif-list { max-height: 420px; overflow: auto; }
.notif { display: flex; gap: 11px; padding: 11px 14px; border-bottom: 1px solid var(--border); color: var(--text); }
.notif:hover { background: var(--surface-2); text-decoration: none; }
.notif.unread { background: var(--brand-50); }
.notif .n-ico { width: 32px; height: 32px; border-radius: 9px; background: var(--surface-3); display: grid; place-items: center; flex: none; color: var(--text-3); }
.notif.unread .n-ico { background: var(--brand-100); color: var(--brand-700); }
.notif .n-title { font-weight: 550; font-size: .92rem; }
.notif .n-body { color: var(--text-3); font-size: .84rem; }
.notif .n-time { color: var(--text-4); font-size: .76rem; margin-top: 2px; }

/* ── Modal ────────────────────────────────────────────────────────────── */
.modal { position: fixed; inset: 0; background: rgba(15, 23, 42, .5); backdrop-filter: blur(2px); display: none; align-items: flex-start; justify-content: center; z-index: 100; padding: 6vh 16px 16px; overflow-y: auto; }
.modal.open { display: flex; animation: fade .15s ease-out; }
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }
.modal-box { background: var(--surface); border-radius: calc(var(--radius) + 4px); box-shadow: var(--shadow-lg); width: 100%; max-width: 560px; animation: rise .18s ease-out; border: 1px solid var(--border); }
.modal-box.lg { max-width: 820px; } .modal-box.sm { max-width: 420px; }
@keyframes rise { from { transform: translateY(12px); opacity: .6; } to { transform: none; opacity: 1; } }
.modal-head { display: flex; align-items: center; justify-content: space-between; padding: 16px 20px; border-bottom: 1px solid var(--border); }
.modal-head h3 { font-size: 1.1rem; }
.modal-body { padding: 20px; }
.modal-foot { padding: 14px 20px; border-top: 1px solid var(--border); display: flex; justify-content: flex-end; gap: 8px; background: var(--surface-2); border-radius: 0 0 calc(var(--radius) + 4px) calc(var(--radius) + 4px); }
.modal-x { background: none; border: 0; color: var(--text-3); cursor: pointer; padding: 6px; border-radius: 8px; }
.modal-x:hover { background: var(--surface-3); color: var(--text); }

/* ── Toasts ───────────────────────────────────────────────────────────── */
.toasts { position: fixed; top: 72px; right: 16px; z-index: 200; display: flex; flex-direction: column; gap: 10px; max-width: 400px; }
.toast { display: flex; gap: 11px; align-items: flex-start; background: var(--surface); border: 1px solid var(--border); border-left: 4px solid var(--brand); border-radius: 12px; padding: 12px 14px; box-shadow: var(--shadow-lg); animation: slide .25s ease-out; }
.toast.success { border-left-color: var(--success); } .toast.error { border-left-color: var(--danger); } .toast.warning { border-left-color: var(--warning); }
.toast .icon { margin-top: 2px; }
.toast.success .icon { color: var(--success); } .toast.error .icon { color: var(--danger); } .toast.warning .icon { color: var(--warning); }
.toast .t-body { flex: 1; font-size: .93rem; }
.toast button { background: none; border: 0; color: var(--text-4); cursor: pointer; padding: 0; }
.toast.hide { opacity: 0; transform: translateX(20px); transition: .3s; }
@keyframes slide { from { transform: translateX(30px); opacity: 0; } to { transform: none; opacity: 1; } }

/* ── Timeline ─────────────────────────────────────────────────────────── */
.timeline { position: relative; padding-left: 26px; }
.timeline::before { content: ''; position: absolute; left: 9px; top: 6px; bottom: 6px; width: 2px; background: var(--border); }
.tl-item { position: relative; padding-bottom: 18px; }
.tl-item:last-child { padding-bottom: 0; }
.tl-dot { position: absolute; left: -26px; top: 1px; width: 20px; height: 20px; border-radius: 50%; background: var(--surface); border: 2px solid var(--border-strong); display: grid; place-items: center; }
.tl-dot .icon { width: 11px; height: 11px; stroke-width: 3; }
.tl-dot.green { border-color: var(--success); background: var(--success); color: #fff; }
.tl-dot.red { border-color: var(--danger); background: var(--danger); color: #fff; }
.tl-dot.amber { border-color: #d97706; background: #d97706; color: #fff; }
.tl-dot.brand { border-color: var(--brand); background: var(--brand); color: #fff; }
.tl-dot.grey { border-color: var(--text-4); background: var(--surface-3); color: var(--text-3); }
.tl-title { font-weight: 550; }
.tl-meta { color: var(--text-3); font-size: .83rem; }
.tl-note { margin-top: 6px; background: var(--surface-2); border: 1px solid var(--border); border-radius: 9px; padding: 8px 11px; font-size: .9rem; color: var(--text-2); }

/* ── Workflow stepper ─────────────────────────────────────────────────── */
.wf { display: flex; gap: 0; overflow-x: auto; padding: 4px 2px 8px; }
.wf-step { flex: 1; min-width: 170px; position: relative; padding-right: 18px; }
.wf-step:not(:last-child)::after { content: ''; position: absolute; top: 17px; left: 42px; right: 6px; height: 2px; background: var(--border-strong); }
.wf-step.done:not(:last-child)::after { background: var(--success); }
.wf-node { width: 36px; height: 36px; border-radius: 50%; display: grid; place-items: center; border: 2px solid var(--border-strong); background: var(--surface); color: var(--text-3); font-weight: 700; position: relative; z-index: 1; }
.wf-node .icon { width: 17px; height: 17px; stroke-width: 2.5; }
.wf-step.done .wf-node { background: var(--success); border-color: var(--success); color: #fff; }
.wf-step.current .wf-node { border-color: var(--brand); color: var(--brand); box-shadow: 0 0 0 5px var(--brand-100); animation: pulse 2s infinite; }
@keyframes pulse { 0%, 100% { box-shadow: 0 0 0 5px var(--brand-100); } 50% { box-shadow: 0 0 0 9px color-mix(in srgb, var(--brand) 8%, transparent); } }
.wf-step.rejected .wf-node { background: var(--danger); border-color: var(--danger); color: #fff; }
.wf-step.returned .wf-node { background: #d97706; border-color: #d97706; color: #fff; }
.wf-step.skipped .wf-node, .wf-step.not_reached .wf-node { border-style: dashed; color: var(--text-4); }
.wf-name { font-weight: 600; margin-top: 10px; font-size: .93rem; }
.wf-step.skipped .wf-name, .wf-step.not_reached .wf-name { color: var(--text-4); }
.wf-who { font-size: .8rem; color: var(--text-3); margin-top: 2px; }
.wf-cond { font-size: .75rem; margin-top: 4px; }

/* ── Progress ─────────────────────────────────────────────────────────── */
.progress { height: 8px; background: var(--surface-3); border-radius: 999px; overflow: hidden; }
.progress > span { display: block; height: 100%; background: var(--brand); border-radius: 999px; transition: width .4s; }
.progress.green > span { background: var(--success); }

/* ── Permission matrix ────────────────────────────────────────────────── */
.role-list a { display: flex; align-items: center; gap: 10px; padding: 10px 14px; border-bottom: 1px solid var(--border); color: var(--text); }
.role-list a:hover { background: var(--surface-2); text-decoration: none; }
.role-list a.active { background: var(--brand-50); box-shadow: inset 3px 0 0 var(--brand); }
.role-list .rl-name { font-weight: 600; }
.role-list .rl-meta { font-size: .8rem; color: var(--text-3); }
.perm-module { border: 1px solid var(--border); border-radius: var(--radius); margin-bottom: 14px; overflow: hidden; background: var(--surface); }
.perm-module-head { display: flex; align-items: center; gap: 12px; padding: 11px 14px; background: var(--surface-2); border-bottom: 1px solid var(--border); }
.perm-module-head .m-ico { width: 32px; height: 32px; border-radius: 9px; background: var(--brand-50); color: var(--brand-600); display: grid; place-items: center; }
.perm-module-head b { font-weight: 650; }
.perm-module-head .m-count { font-size: .8rem; color: var(--text-3); }
.perm-rows { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); }
.perm-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 10px 14px; border-bottom: 1px solid var(--border); border-right: 1px solid var(--border); }
.perm-row .p-label { font-weight: 500; font-size: .93rem; }
.perm-row .p-key { font-family: var(--mono); font-size: .74rem; color: var(--text-4); }
.perm-rows { margin-bottom: -1px; margin-right: -1px; }
.tri { display: inline-flex; border: 1px solid var(--border-strong); border-radius: 8px; overflow: hidden; flex: none; }
.tri label { cursor: pointer; }
.tri input { position: absolute; opacity: 0; width: 0; }
.tri span { display: inline-flex; align-items: center; gap: 4px; padding: 4px 9px; font-size: .78rem; font-weight: 600; color: var(--text-3); border-left: 1px solid var(--border); }
.tri label:first-child span { border-left: 0; }
.tri input:checked + span.t-inherit { background: var(--surface-3); color: var(--text); }
.tri input:checked + span.t-grant { background: var(--success); color: #fff; }
.tri input:checked + span.t-revoke { background: var(--danger); color: #fff; }
.tri input:focus-visible + span { box-shadow: inset 0 0 0 2px var(--brand); }
.eff { font-size: .75rem; font-weight: 700; display: inline-flex; align-items: center; gap: 4px; }
.eff.yes { color: var(--success); } .eff.no { color: var(--text-4); }
.perm-row.overridden { background: color-mix(in srgb, var(--warning-bg) 60%, transparent); }
.perm-row .reason { margin-top: 6px; }
.perm-row .reason input { height: 30px; font-size: .85rem; }
.legend { display: flex; gap: 16px; flex-wrap: wrap; font-size: .85rem; color: var(--text-3); }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.legend i { width: 10px; height: 10px; border-radius: 3px; display: inline-block; }

/* ── Workflow designer ────────────────────────────────────────────────── */
.steps-editor { display: flex; flex-direction: column; gap: 12px; }
.step-card { border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); display: grid; grid-template-columns: 44px minmax(0, 1fr) auto; gap: 14px; padding: 14px; align-items: start; position: relative; }
.step-card .num-badge { width: 32px; height: 32px; border-radius: 50%; background: var(--brand); color: #fff; display: grid; place-items: center; font-weight: 700; }
.step-card .step-tools { display: flex; flex-direction: column; gap: 4px; }
.step-arrow { text-align: center; color: var(--text-4); margin: -6px 0; }
.flow-preview { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.flow-chip { display: inline-flex; flex-direction: column; padding: 8px 12px; border-radius: 10px; border: 1px solid var(--border); background: var(--surface-2); font-size: .85rem; }
.flow-chip b { font-weight: 600; }
.flow-chip.cond { border-style: dashed; }
.flow-arrow { color: var(--text-4); }

/* ── Appearance preview ───────────────────────────────────────────────── */
.swatches { display: flex; gap: 8px; flex-wrap: wrap; }
.swatch { width: 30px; height: 30px; border-radius: 8px; cursor: pointer; border: 2px solid transparent; box-shadow: inset 0 0 0 1px rgba(0,0,0,.1); }
.swatch.on { border-color: var(--text); }
.color-field { display: flex; gap: 8px; align-items: center; }
.color-field input[type=color] { width: 44px; height: var(--control-h); border: 1px solid var(--border-strong); border-radius: 8px; padding: 3px; background: var(--surface); cursor: pointer; }
.preview-frame { border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; background: var(--bg); height: 240px; display: grid; grid-template-columns: 70px 1fr; font-size: 10px; }
.preview-frame.pv-right { grid-template-columns: 1fr 70px; }
.preview-frame.pv-right .pv-side { order: 2; }
.preview-frame.pv-top { grid-template-columns: 1fr; grid-template-rows: auto auto 1fr; }
.preview-frame.pv-top .pv-side { display: none; }
.pv-side { background: var(--sb-bg); padding: 8px 6px; display: flex; flex-direction: column; gap: 5px; }
.pv-side i { display: block; height: 7px; border-radius: 3px; background: var(--sb-text); opacity: .35; }
.pv-side i.on { background: var(--brand); opacity: 1; }
.pv-main { display: flex; flex-direction: column; min-width: 0; }
.pv-head { height: 24px; background: var(--surface); border-bottom: 1px solid var(--border); }
.pv-topnav { display: none; height: 18px; background: var(--sb-bg); gap: 6px; padding: 5px 8px; }
.preview-frame.pv-top .pv-topnav { display: flex; }
.pv-topnav i { width: 30px; height: 7px; border-radius: 3px; background: var(--sb-text); opacity: .4; }
.pv-topnav i.on { background: var(--brand); opacity: 1; }
.pv-body { padding: 10px; display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; align-content: start; }
.pv-card { background: var(--surface); border: 1px solid var(--border); border-radius: calc(var(--radius) * .5); height: 44px; }
.pv-card.wide { grid-column: span 3; height: 70px; }
.pv-btn { width: 50px; height: 14px; border-radius: 4px; background: var(--brand); margin: 6px; }

/* ── Auth pages ───────────────────────────────────────────────────────── */
.auth { min-height: 100vh; display: grid; grid-template-columns: minmax(0, 1.1fr) minmax(420px, .9fr); background: var(--surface); }
.auth-art { position: relative; overflow: hidden; background: radial-gradient(1200px 600px at 10% 10%, color-mix(in srgb, var(--accent) 55%, transparent), transparent 60%), linear-gradient(135deg, var(--brand-700), var(--brand) 55%, color-mix(in srgb, var(--accent) 70%, var(--brand))); color: #fff; padding: 48px; display: flex; flex-direction: column; justify-content: space-between; }
.auth-art::after { content: ''; position: absolute; inset: 0; background-image: radial-gradient(rgba(255,255,255,.14) 1px, transparent 1px); background-size: 22px 22px; mask-image: linear-gradient(to bottom, #000, transparent 85%); pointer-events: none; }
.auth-art > * { position: relative; z-index: 1; }
.auth-brand { display: flex; align-items: center; gap: 12px; font-weight: 700; font-size: 1.2rem; }
.auth-brand .sb-logo { width: 44px; height: 44px; background: rgba(255,255,255,.18); border: 1px solid rgba(255,255,255,.3); font-size: 15px; }
.auth-art h2 { font-size: 2.3rem; line-height: 1.15; font-weight: 750; letter-spacing: -.03em; max-width: 520px; }
.auth-art p { font-size: 1.08rem; opacity: .88; max-width: 480px; margin-top: 14px; }
.auth-points { display: grid; gap: 14px; max-width: 460px; }
.auth-point { display: flex; gap: 12px; align-items: flex-start; background: rgba(255,255,255,.1); border: 1px solid rgba(255,255,255,.18); border-radius: 14px; padding: 12px 14px; backdrop-filter: blur(4px); }
.auth-point .icon { width: 20px; height: 20px; margin-top: 2px; }
.auth-point b { display: block; }
.auth-point span { opacity: .85; font-size: .9rem; }
.auth-form { display: flex; flex-direction: column; justify-content: center; padding: 48px clamp(24px, 6vw, 80px); background: var(--surface); }
.auth-form .inner { width: 100%; max-width: 400px; margin: 0 auto; }
.auth-form h1 { font-size: 1.75rem; font-weight: 750; letter-spacing: -.02em; }
.auth-form .lead { color: var(--text-3); margin: 6px 0 26px; }
.auth-form .field { margin-bottom: 16px; }
.auth-form .input { height: 44px; }
.auth-foot { margin-top: 26px; display: flex; justify-content: space-between; align-items: center; color: var(--text-3); font-size: .85rem; }
.lang-switch { display: inline-flex; border: 1px solid var(--border); border-radius: 8px; overflow: hidden; }
.lang-switch a { padding: 4px 10px; color: var(--text-3); font-size: .82rem; font-weight: 600; }
.lang-switch a.on { background: var(--brand-50); color: var(--brand-700); }
.lang-switch a:hover { text-decoration: none; }
.pw-toggle { position: absolute; right: 8px; top: 50%; transform: translateY(-50%); background: none; border: 0; color: var(--text-4); cursor: pointer; padding: 4px; }
.company-pill { display: flex; align-items: center; gap: 10px; padding: 10px 12px; border: 1px solid var(--border); border-radius: 12px; background: var(--surface-2); margin-bottom: 18px; }
.demo-box { margin-top: 22px; border: 1px dashed var(--border-strong); border-radius: 12px; padding: 12px 14px; font-size: .85rem; color: var(--text-2); background: var(--surface-2); }
.demo-box table { width: 100%; border-collapse: collapse; margin-top: 6px; }
.demo-box td { padding: 3px 0; }
.demo-box button { background: none; border: 0; color: var(--brand-600); cursor: pointer; font: inherit; padding: 0; }

/* ── Dashboard bits ───────────────────────────────────────────────────── */
.welcome { display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap; padding: 20px var(--pad); background: linear-gradient(120deg, var(--brand-50), var(--surface) 70%); }
.welcome h2 { font-size: 1.3rem; }
.chart-box { position: relative; height: 280px; }
.chart-box.sm { height: 220px; }
.task { display: flex; gap: 12px; align-items: center; padding: 12px var(--pad); border-bottom: 1px solid var(--border); color: var(--text); }
.task:hover { background: var(--surface-2); text-decoration: none; }
.task:last-child { border-bottom: 0; }
.task .t-ico { width: 36px; height: 36px; border-radius: 10px; display: grid; place-items: center; background: var(--warning-bg); color: var(--warning); flex: none; }
.bar-list .bl-row { display: grid; grid-template-columns: 130px minmax(0, 1fr) auto; gap: 12px; align-items: center; padding: 7px 0; }
.bar-list .bl-bar { height: 10px; background: var(--surface-3); border-radius: 999px; overflow: hidden; }
.bar-list .bl-bar span { display: block; height: 100%; background: var(--brand); border-radius: 999px; }

/* ── Print ────────────────────────────────────────────────────────────── */
@media print {
  .sidebar, .header, .topnav, .page-head .actions, .no-print { display: none !important; }
  .app { display: block; }
  .content { padding: 0; }
  .card { box-shadow: none; }
}

/* ── Responsive ───────────────────────────────────────────────────────── */
@media (max-width: 1200px) {
  .g-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .g-main { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 1024px) {
  .app, html[data-menu="right"] .app, html.sb-collapsed .app { grid-template-columns: minmax(0, 1fr); grid-template-areas: "main"; }
  .sidebar { position: fixed; top: 0; bottom: 0; left: 0; width: var(--sidebar-w); transform: translateX(-100%); transition: transform .25s; box-shadow: var(--shadow-lg); }
  html[data-menu="right"] .sidebar { left: auto; right: 0; transform: translateX(100%); }
  html[data-menu="top"] .sidebar { display: flex; }
  html[data-menu="top"] .topnav { display: none; }
  html.sb-open .sidebar { transform: none; }
  html.sb-open::after { content: ''; position: fixed; inset: 0; background: rgba(15,23,42,.45); z-index: 35; }
  html.sb-collapsed .sb-name, html.sb-collapsed .sb-item span, html.sb-collapsed .sb-sub { display: revert !important; }
  .menu-toggle { display: inline-flex; }
  .sb-collapse { display: none; }
  .header .brand-inline { display: none !important; }
  .g-3, .g-side { grid-template-columns: minmax(0, 1fr); }
  .form-2col { grid-template-columns: minmax(0, 1fr); gap: 8px; }
  .auth { grid-template-columns: minmax(0, 1fr); }
  .auth-art { display: none; }
}
@media (max-width: 720px) {
  .g-2, .g-4, .form-grid, .form-grid.cols-3 { grid-template-columns: minmax(0, 1fr); }
  .span-2 { grid-column: auto; }
  .content { padding: 16px 14px 40px; }
  .header { padding: 0 12px; }
  .user-chip .who, .search kbd { display: none; }
  .page-head h1 { font-size: 1.35rem; }
  .kv { grid-template-columns: minmax(0, 1fr); }
  .kv .v { text-align: left; padding-top: 0; }
  .kv > div.k { border-bottom: 0; padding-bottom: 0; }
  .notif-menu { width: calc(100vw - 24px); }
  .dropdown .dd-menu.notif-menu { position: fixed; top: 60px; left: 12px; right: 12px; }
}

/* Forms placed inline among buttons */
.page-head .actions form, .row > form.inline, .actions-inline form { display: contents; }

/* ── Phase 2 ─────────────────────────────────────────────────────── */
.choices-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
@media (max-width: 900px) { .choices-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
.diff { display: grid; grid-template-columns: minmax(90px, .8fr) minmax(0, 1fr) minmax(0, 1fr); gap: 0; border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; }
.diff > div { padding: 10px 14px; border-top: 1px solid var(--border); font-size: .92em; }
.diff > .h { background: var(--surface-2); font-weight: 600; font-size: .78em; text-transform: uppercase; letter-spacing: .04em; color: var(--text-3); border-top: 0; }
.diff .was { color: var(--text-3); text-decoration: line-through; text-decoration-color: color-mix(in srgb, var(--danger) 55%, transparent); }
.diff .now { color: var(--text); font-weight: 600; }
.amount-pos { color: var(--danger); }
.amount-neg { color: var(--success); }
.age-bar { display: flex; height: 10px; border-radius: 999px; overflow: hidden; background: var(--surface-2); gap: 2px; }
.age-bar span { display: block; height: 100%; }
.statement-table td.bal { font-weight: 600; }
.g-5 { grid-template-columns: repeat(5, minmax(0, 1fr)); }
@media (max-width: 900px) { .g-5 { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
.diff > div { overflow-wrap: anywhere; min-width: 0; }
@media (max-width: 720px) { .diff > div { padding: 8px 10px; font-size: .85em; } }

/* ── Phase 3: reports ────────────────────────────────────────────── */
.report-filters { display: flex; flex-wrap: wrap; gap: 10px; align-items: flex-end; padding: 14px 16px; }
.report-filters .select, .report-filters .input { width: auto; min-width: 150px; }
.field-inline { display: flex; flex-direction: column; gap: 4px; }
.report-table tr.r-section td { background: var(--surface-2); font-weight: 600; padding-top: 14px; }
.report-table tr.r-subtotal td { font-weight: 700; border-top: 1px solid var(--border); }
.report-card { display: flex; gap: 12px; align-items: flex-start; padding: 16px; color: inherit; }
.report-card:hover { text-decoration: none; }
.report-card .ico { flex: none; }
.report-card h3 { margin: 0 0 4px; font-size: 1rem; }
.report-card p { margin: 0; color: var(--text-3); font-size: .88rem; }
@media (max-width: 720px) { .report-filters .select, .report-filters .input { min-width: 0; width: 100%; } .field-inline { width: 100%; } }
.section-title { display: flex; align-items: center; gap: 8px; font-size: 1rem; font-weight: 600; color: var(--text-2); }
.report-table th, .report-table td { white-space: nowrap; }
.report-table td:first-child { max-width: 320px; overflow: hidden; text-overflow: ellipsis; }

/* Reinsurance: how a sum insured is shared out (validated categorical slots 1-3) */
.split-bar { display: flex; gap: 2px; height: 14px; border-radius: 7px; overflow: hidden; background: var(--surface); }
.split-bar > span { display: block; min-width: 4px; }
.split-bar > span:first-child { border-radius: 7px 0 0 7px; }
.split-bar > span:last-child { border-radius: 0 7px 7px 0; }
.split-bar > span:only-child { border-radius: 7px; }
.sw-1 { background: var(--series-1); } .sw-2 { background: var(--series-2); } .sw-3 { background: var(--series-3); }
.legend i.sw-1, .legend i.sw-2, .legend i.sw-3 { width: 10px; height: 10px; }
.dotkey { display: inline-block; width: 8px; height: 8px; border-radius: 2px; margin-right: 6px; vertical-align: middle; }

/* Claims: progress tones, document checklist, tab count warning */
.progress.red > span { background: var(--danger); }
.progress.amber > span { background: var(--warning); }
.tabs .count.warn { background: var(--warning-bg); color: var(--warning); }
.checklist { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 6px 16px; }
.check-item { display: flex; align-items: center; gap: 8px; font-size: .88rem; padding: 6px 0; border-bottom: 1px dashed var(--border); }
.check-item > span:nth-child(2) { flex: 1; min-width: 0; }
.check-item .icon { color: var(--text-4); flex: none; }
.check-item.done .icon { color: var(--success); }
.check-item.missing .icon { color: var(--warning); }
.check-item.missing > span:nth-child(2) { font-weight: 600; }
.text-warning { color: var(--warning); }
.pb-0 { padding-bottom: 0 !important; } .m-0 { margin: 0 !important; }
/* Simple magnitude bar (single series, validated slot 1) */
.bar-track { height: 10px; border-radius: 5px; background: var(--surface-3); overflow: hidden; }
.bar-fill { display: block; height: 100%; background: var(--series-1); border-radius: 0 5px 5px 0; }
.doc-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 8px 20px; }
.doc-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; font-size: .9rem; padding: 4px 0; border-bottom: 1px dashed var(--border); }
.doc-row .select { width: 140px; flex: none; }
.pt-0 { padding-top: 0 !important; }
.tabs.wrap { flex-wrap: wrap; overflow: visible; }
.copied { color: var(--success) !important; border-color: var(--success) !important; }

/* ── Phase 7: communication, WhatsApp inbox, cashbook, analytics ───────── */
.card.flat { box-shadow: none; background: var(--surface-2); }
details.card > summary { list-style: none; display: flex; align-items: center; gap: 8px; }
details.card > summary::-webkit-details-marker { display: none; }
.wa { display: grid; grid-template-columns: 320px minmax(0, 1fr); min-height: 560px; }
.wa-list { border-right: 1px solid var(--border); display: flex; flex-direction: column; min-width: 0; }
.wa-list .wa-search { padding: 10px; border-bottom: 1px solid var(--border); }
.wa-items { overflow-y: auto; max-height: 640px; }
.wa-item { display: flex; gap: 10px; padding: 11px 12px; border-bottom: 1px solid var(--border); color: inherit; text-decoration: none; align-items: flex-start; }
.wa-item:hover { background: var(--surface-2); }
.wa-item.active { background: var(--brand-50); }
.wa-item .av { width: 38px; height: 38px; border-radius: 50%; background: var(--success-bg); color: var(--success); display: grid; place-items: center; font-weight: 700; font-size: .85rem; flex: none; }
.wa-item .nm { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.wa-item .snip { color: var(--text-3); font-size: .84rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.wa-item .meta { margin-left: auto; text-align: right; font-size: .75rem; color: var(--text-3); flex: none; display: flex; flex-direction: column; align-items: flex-end; gap: 4px; }
.wa-item .unread { background: var(--success); color: #fff; border-radius: 999px; padding: 0 7px; font-weight: 700; font-size: .72rem; }
.wa-thread { display: flex; flex-direction: column; min-width: 0; }
.wa-head { display: flex; align-items: center; gap: 10px; padding: 12px 16px; border-bottom: 1px solid var(--border); flex-wrap: wrap; }
.wa-msgs { flex: 1; overflow-y: auto; max-height: 520px; padding: 16px; background: var(--surface-2); display: flex; flex-direction: column; gap: 8px; }
.bubble { max-width: min(78%, 520px); padding: 8px 12px 6px; border-radius: 12px; background: var(--surface); border: 1px solid var(--border); word-wrap: break-word; font-size: .92rem; }
.bubble .bt { white-space: pre-wrap; }
.wa-head .grow { flex: 1 1 200px; min-width: 0; }
.bubble.out { align-self: flex-end; background: var(--success-bg); border-color: var(--success-bd); border-bottom-right-radius: 4px; }
.bubble.in { align-self: flex-start; border-bottom-left-radius: 4px; }
.bubble .bm { font-size: .72rem; color: var(--text-3); margin-top: 3px; display: flex; gap: 6px; justify-content: flex-end; align-items: center; }
.bubble .bm .icon { width: 13px; height: 13px; }
.bubble.failed { border-color: var(--danger-bd); }
.wa-day { align-self: center; font-size: .75rem; color: var(--text-3); background: var(--surface); border: 1px solid var(--border); border-radius: 999px; padding: 1px 10px; }
.wa-compose { border-top: 1px solid var(--border); padding: 12px 16px; display: flex; gap: 8px; align-items: flex-end; }
.wa-compose textarea { flex: 1; min-height: 44px; }
.wa-empty { display: grid; place-items: center; flex: 1; color: var(--text-3); padding: 40px; text-align: center; }
@media (max-width: 860px) {
  .wa { grid-template-columns: 1fr; }
  .wa.has-thread .wa-list { display: none; }
  .wa:not(.has-thread) .wa-thread { display: none; }
  .wa-list { border-right: 0; }
}
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 14px; }
.chart-tall { position: relative; height: 320px; }
.chart-mid { position: relative; height: 260px; }
.spark { display: block; }
.delta-up { color: var(--success); font-weight: 600; }
.delta-down { color: var(--danger); font-weight: 600; }
.bar-cell { min-width: 110px; white-space: nowrap; }
.bar-cell .fill { display: inline-block; height: 8px; border-radius: 4px; background: var(--brand-200); margin-right: 8px; vertical-align: middle; }
.legend-dot { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 6px; vertical-align: -1px; }
.money-in { color: var(--success); }
.money-out { color: var(--danger); }
tr.cleared td { background: var(--success-bg); }
.analytics-filters { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.analytics-filters .select { width: auto; min-width: 150px; }
.kpis .stat .val { font-size: 1.3rem; }

/* ── Phase 8: client portal ───────────────────────────────────────────── */
[hidden] { display: none !important; }
.seg { display: grid; grid-template-columns: 1fr 1fr; gap: 4px; padding: 4px; background: var(--surface-2); border: 1px solid var(--border); border-radius: calc(var(--radius) + 2px); }
.seg button { display: flex; align-items: center; justify-content: center; gap: 6px; padding: 9px 10px; border: 0; background: transparent; border-radius: var(--radius); font: inherit; font-weight: 600; color: var(--text-2); cursor: pointer; }
.seg button .icon { width: 16px; height: 16px; }
.seg button.on { background: var(--surface); color: var(--brand-700); box-shadow: var(--shadow); }
.portal { min-height: 100vh; background: var(--bg); display: flex; flex-direction: column; }
.p-header { background: var(--surface); border-bottom: 1px solid var(--border); position: sticky; top: 0; z-index: 40; }
.p-header .p-inner { max-width: 1160px; margin: 0 auto; padding: 0 20px; display: flex; align-items: center; gap: 16px; min-height: 62px; }
.p-brand { display: flex; align-items: center; gap: 10px; font-weight: 700; color: var(--text); text-decoration: none; min-width: 0; }
.p-brand .sb-logo { width: 36px; height: 36px; border-radius: 9px; background: var(--brand); color: #fff; display: grid; place-items: center; font-weight: 700; font-size: .85rem; overflow: hidden; flex: none; }
.p-brand .sb-logo img { width: 100%; height: 100%; object-fit: contain; background: #fff; }
.p-brand .nm { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.p-brand small { display: block; font-weight: 500; color: var(--text-3); font-size: .75rem; }
.p-nav { background: var(--surface); border-bottom: 1px solid var(--border); }
.p-nav .p-inner { max-width: 1160px; margin: 0 auto; padding: 0 12px; display: flex; gap: 2px; overflow-x: auto; scrollbar-width: none; }
.p-nav .p-inner::-webkit-scrollbar { display: none; }
.p-nav a { display: flex; align-items: center; gap: 7px; padding: 12px 12px; color: var(--text-2); text-decoration: none; font-weight: 600; font-size: .92rem; border-bottom: 2px solid transparent; white-space: nowrap; }
.p-nav a .icon { width: 17px; height: 17px; }
.p-nav a.active { color: var(--brand-700); border-bottom-color: var(--brand); }
.p-nav a .sb-count { margin-left: 2px; }
.p-main { flex: 1; width: 100%; max-width: 1160px; margin: 0 auto; padding: 22px 20px 48px; }
.p-foot { text-align: center; color: var(--text-3); font-size: .8rem; padding: 18px; }
.p-hero { background: linear-gradient(135deg, var(--brand), var(--brand-700)); color: #fff; border-radius: calc(var(--radius) + 4px); padding: 22px 24px; margin-bottom: 18px; display: flex; flex-wrap: wrap; gap: 16px; align-items: center; justify-content: space-between; }
.p-hero h1 { color: #fff; font-size: 1.4rem; margin: 0; }
.p-hero p { margin: 4px 0 0; opacity: .9; }
.p-hero .btn { background: #fff; color: var(--brand-700); border-color: #fff; }
.p-tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 14px; margin-bottom: 18px; }
.p-list .p-row { display: flex; gap: 12px; align-items: center; padding: 14px 16px; border-bottom: 1px solid var(--border); color: inherit; text-decoration: none; }
.p-list .p-row:last-child { border-bottom: 0; }
.p-list .p-row:hover { background: var(--surface-2); }
.p-row .ic { width: 40px; height: 40px; border-radius: 10px; display: grid; place-items: center; background: var(--brand-50); color: var(--brand-600); flex: none; }
.p-row .grow { min-width: 0; }
.p-row .t { font-weight: 600; }
.p-row .s { color: var(--text-3); font-size: .85rem; }
.p-row .r { margin-left: auto; text-align: right; flex: none; }
.timeline { list-style: none; margin: 0; padding: 0; }
.timeline li { position: relative; padding: 0 0 16px 26px; }
.timeline li::before { content: ''; position: absolute; left: 7px; top: 18px; bottom: 0; width: 2px; background: var(--border); }
.timeline li:last-child::before { display: none; }
.timeline li .dot { position: absolute; left: 0; top: 3px; width: 16px; height: 16px; border-radius: 50%; background: var(--surface); border: 2px solid var(--border-strong, var(--border)); }
.timeline li.done .dot { background: var(--success); border-color: var(--success); }
.timeline li.now .dot { background: var(--brand); border-color: var(--brand); box-shadow: 0 0 0 4px var(--brand-50); }
.timeline li .tt { font-weight: 600; }
.timeline li .ts { color: var(--text-3); font-size: .82rem; }
.note { border: 1px solid var(--border); border-radius: var(--radius); padding: 10px 12px; margin-bottom: 10px; background: var(--surface); }
.note.staff { background: var(--brand-50); border-color: var(--brand-200); }
.note .nh { font-size: .8rem; color: var(--text-3); margin-bottom: 4px; display: flex; justify-content: space-between; gap: 8px; }
.note .nb { white-space: pre-wrap; }
@media (max-width: 640px) {
  .p-header .p-inner { padding: 0 14px; gap: 10px; }
  .p-main { padding: 16px 14px 40px; }
  .p-brand small { display: none; }
  .p-hero { padding: 18px; }
}
@media (max-width: 640px) { .hide-sm { display: none !important; } }
.doc-pick{display:grid;gap:6px;padding:10px;border:1px dashed var(--border);border-radius:var(--radius);margin-bottom:8px}
.doc-pick .input[type=file]{padding:6px;font-size:.9em;min-width:0}
.demo-box td { padding: 3px 8px 3px 0; vertical-align: top; }
.demo-box button { word-break: break-all; text-align: left; }
@media (max-width: 480px) {
  .demo-box tr { display: grid; grid-template-columns: auto 1fr; column-gap: 8px; padding: 5px 0; border-top: 1px dashed var(--border); }
  .demo-box tr:first-child { border-top: 0; }
  .demo-box td:nth-child(3) { grid-column: 2; padding-top: 0; }
}
/* Go-live checklist */
.gl-list { padding: 4px 0; }
.gl-row { display: flex; gap: 12px; padding: 12px var(--pad); border-top: 1px solid var(--border); align-items: flex-start; }
.gl-row:first-child { border-top: 0; }
.gl-ic .icon { width: 20px; height: 20px; margin-top: 1px; }
.gl-t { font-weight: 600; }
.gl-fix { display: flex; gap: 6px; margin-top: 6px; padding: 7px 10px; border-radius: 8px; background: var(--surface-2); color: var(--text-2); }
.gl-fix .icon { flex: none; width: 14px; height: 14px; margin-top: 2px; }
.gl-fail .gl-fix { background: var(--danger-bg); }
.gl-warn .gl-fix { background: var(--warning-bg); }
.demo-box tr:hover td, .demo-box tr.picked td { background: var(--surface-3); }
.demo-box tr.picked button { font-weight: 700; }
