/* Aglink UI theme – MyProject 2.0 fork. Deep navy surfaces, lime accent, Montserrat. API reference: KIT.md */
@font-face {
  font-family: "Montserrat";
  src: url("../fonts/montserrat-latin.woff2") format("woff2");
  font-weight: 400 800;
  font-display: swap;
}

:root {
  --bg: #0b111a;
  --bg-2: #0f1620;
  --surface: #162130;
  --surface-2: #1c2935;
  --surface-3: #22303f;
  --surface-end: #131d2a;          /* card gradient end */
  --th: #142030;                   /* table header */
  --line: #2a3645;
  --line-soft: rgba(255, 255, 255, .06);
  --line-strong: #4a5a6c;          /* form-control borders (≥3:1 on --bg-2) */
  --text: #e8ecf0;
  --muted: #a8b2bd;
  --faint: #8693a1;                /* ≥4.5:1 on --surface / --surface-2 */
  --accent: #8ec63f;
  --accent-2: #b7dd6e;
  --accent-3: #a8d55c;             /* gradient partner of --accent */
  --accent-ink: #0b111a;
  --good: #8ec63f;
  --warn: #f2b53a;
  --bad: #ef5b5b;
  --bad-text: #ffb3b3;             /* error text on dark */
  --info: #4fb3d9;
  --violet: #9b8cff;
  --focus: #b7dd6e;
  --radius: 14px;
  --radius-sm: 9px;
  --shadow: 0 10px 30px rgba(0, 0, 0, .35);
  --sidebar: 232px;
  --ease: cubic-bezier(.2, .7, .2, 1);
  --tap: 36px;                     /* min control height; 44px on phones */
  /* tinted status surfaces (note boxes, hit areas) */
  --info-bg: rgba(79, 179, 217, .08);  --info-line: rgba(79, 179, 217, .32);
  --warn-bg: rgba(242, 181, 58, .08);  --warn-line: rgba(242, 181, 58, .42);
  --bad-bg: rgba(239, 91, 91, .08);    --bad-line: rgba(239, 91, 91, .4);
  --good-bg: rgba(142, 198, 63, .08);  --good-line: rgba(142, 198, 63, .4);
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  font: 14px/1.5 "Montserrat", "Segoe UI", system-ui, sans-serif;
  color: var(--text);
  background:
    radial-gradient(1200px 500px at 85% -10%, rgba(142, 198, 63, .10), transparent 60%),
    radial-gradient(900px 400px at -10% 110%, rgba(79, 179, 217, .06), transparent 60%),
    var(--bg);
  background-attachment: fixed;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--accent-2); text-decoration: none; }
a:hover { color: var(--accent); }
button, input, select, textarea { font: inherit; color: inherit; }
::selection { background: rgba(142, 198, 63, .35); }
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { background: var(--line); border-radius: 10px; border: 2px solid var(--bg); }
::-webkit-scrollbar-track, ::-webkit-scrollbar-corner { background: transparent; }
[hidden] { display: none !important; }

/* ---------- focus + accessibility ---------- */
:focus { outline: none; }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; border-radius: 4px; }
input:focus-visible, select:focus-visible, textarea:focus-visible { outline-offset: 0; }
.main:focus, .drawer:focus, .modal:focus, .wz-pane:focus, .split-detail:focus { outline: none; }
.skip {
  position: fixed; left: 12px; top: -60px; z-index: 100; padding: 10px 16px; border-radius: 10px;
  background: var(--accent); color: var(--accent-ink); font-weight: 700; transition: top .15s;
}
.skip:focus { top: 12px; color: var(--accent-ink); }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .001ms !important; animation-iteration-count: 1 !important; transition-duration: .001ms !important; scroll-behavior: auto !important; }
}

/* ---------- shell ---------- */
.sidebar {
  position: fixed; inset: 0 auto 0 0; width: var(--sidebar); z-index: 30;
  display: flex; flex-direction: column; gap: 6px; padding: 22px 14px;
  background: linear-gradient(180deg, #0d1520 0%, #0a1018 100%);
  border-right: 1px solid var(--line-soft); overflow-y: auto; transition: width .2s ease;
}
.logo { display: flex; align-items: center; gap: 12px; padding: 4px 10px 18px; }
.logo-mark {
  width: 38px; height: 38px; border-radius: 11px; display: grid; place-items: center; flex: none;
  background: linear-gradient(135deg, var(--accent) 0%, #5f9a1f 100%); color: var(--accent-ink);
  font-weight: 800; letter-spacing: -.5px; box-shadow: 0 6px 18px rgba(142, 198, 63, .35);
}
.logo-text { line-height: 1.15; }
.logo-text b { display: block; font-size: 15px; letter-spacing: .5px; }
.logo-text span { font-size: 11px; color: var(--muted); letter-spacing: 1.5px; text-transform: uppercase; }
.nav-group + .nav-group { margin-top: 8px; }
.nav-h { padding: 8px 12px 4px; font-size: 10.5px; font-weight: 700; letter-spacing: 1.2px; text-transform: uppercase; color: var(--faint); }
.nav a {
  display: flex; align-items: center; gap: 12px; padding: 9px 12px; margin: 2px 0;
  border-radius: 10px; color: var(--muted); font-weight: 500; transition: background .15s, color .15s;
}
.nav a svg { width: 19px; height: 19px; flex: none; }
.nav a:hover { background: rgba(255, 255, 255, .04); color: var(--text); }
.nav a:hover .kbd, .nav a:focus-visible .kbd { opacity: .75; }
.nav a.active {
  color: var(--accent-ink); font-weight: 600;
  background: linear-gradient(90deg, var(--accent) 0%, var(--accent-3) 100%);
  box-shadow: 0 6px 18px rgba(142, 198, 63, .25);
}
.nav .kbd { margin-left: auto; font-size: 9.5px; opacity: 0; transition: opacity .15s; border: 1px solid currentColor; border-radius: 4px; padding: 0 4px; white-space: nowrap; }
.sidebar-foot { margin-top: auto; padding: 12px; font-size: 11px; color: var(--faint); border-top: 1px solid var(--line-soft); }
.user-box { margin: -4px 0 12px; padding-bottom: 12px; border-bottom: 1px solid var(--line-soft); }
.user-box:empty { display: none; }
.user-box .who { display: flex; align-items: center; gap: 10px; }
.user-box .who .t { min-width: 0; }
.user-box .who b { display: block; font-size: 12.5px; color: var(--text); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.user-box .who span { font-size: 11px; color: var(--muted); }
.avatar.sm { width: 32px; height: 32px; font-size: 12px; }
.user-links { display: flex; flex-direction: column; gap: 2px; }
.user-links a { display: flex; align-items: center; gap: 8px; padding: 6px; border-radius: 8px; color: var(--muted); font-size: 12px; font-weight: 600; }
.user-links a svg { width: 15px; height: 15px; }
.user-links a:hover, .user-links a.on { background: rgba(255, 255, 255, .05); color: var(--accent-2); }
.sidebar-foot .dot { display: inline-block; width: 7px; height: 7px; border-radius: 50%; background: var(--good); margin-right: 6px; box-shadow: 0 0 0 3px rgba(142, 198, 63, .2); }

.main { margin-left: var(--sidebar); min-height: 100%; transition: margin-left .2s ease; }
.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; gap: 12px 14px; flex-wrap: wrap;
  padding: 14px 28px; background: rgba(11, 17, 26, .82); backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--line-soft);
}
.tb-title { min-width: 0; }
.topbar h1 { margin: 0; font-size: 21px; font-weight: 700; letter-spacing: -.2px; }
.topbar .sub { color: var(--muted); font-size: 12px; }
.topbar .sub:empty { display: none; }
.topbar .spacer { flex: 1; }
.tb-actions { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.tb-actions:empty { display: none; }
.content { padding: 24px 28px 48px; max-width: 1680px; }

/* breadcrumbs */
.crumbs ol { list-style: none; margin: 0 0 2px; padding: 0; display: flex; flex-wrap: wrap; gap: 4px; font-size: 12px; color: var(--muted); }
.crumbs li { display: flex; align-items: center; gap: 4px; }
.crumbs li + li::before { content: "/"; color: var(--faint); }
.crumbs a { color: var(--muted); }
.crumbs a:hover { color: var(--accent-2); }

/* topbar buttons, pop-overs */
.tb-btn, .me-btn {
  position: relative; display: grid; place-items: center; width: 38px; height: 38px; flex: none; padding: 0; cursor: pointer;
  border-radius: 50%; border: 1px solid var(--line); background: var(--surface); color: var(--muted);
}
.tb-btn:hover { color: var(--text); border-color: var(--line-strong); }
.tb-btn svg { width: 18px; height: 18px; }
.me-btn { border: 2px solid var(--line); background: linear-gradient(135deg, #2b3a4c, #1e2a38); color: var(--accent-2); font-weight: 700; font-size: 12px; }
.me-btn svg { width: 16px; height: 16px; }
.nb {
  position: absolute; top: -4px; right: -4px; min-width: 18px; height: 18px; padding: 0 5px; border-radius: 9px;
  background: var(--bad); color: #fff; font-size: 10.5px; font-weight: 700; line-height: 18px; text-align: center; box-shadow: 0 0 0 2px var(--bg);
}
.menu-wrap { position: relative; }
.pop {
  position: absolute; top: calc(100% + 8px); right: 0; z-index: 45; min-width: 240px; max-height: min(70vh, 560px); overflow: auto;
  background: var(--surface-2); border: 1px solid var(--line); border-radius: 14px; box-shadow: var(--shadow); padding: 8px;
}
.me-menu { width: 280px; }
.me-menu .who { padding: 6px 8px 10px; border-bottom: 1px solid var(--line-soft); margin-bottom: 6px; }
.me-menu .who b { display: block; font-size: 13px; }
.me-menu .who span { display: block; font-size: 11.5px; color: var(--muted); overflow-wrap: anywhere; }
.me-menu .who .co { display: flex; align-items: center; gap: 6px; margin-top: 4px; color: var(--accent-2); font-weight: 600; }
.me-menu .who .co svg { width: 14px; height: 14px; }
.me-menu > a, .me-menu > button {
  display: flex; align-items: center; gap: 10px; width: 100%; padding: 9px 8px; border: 0; border-radius: 9px; min-height: var(--tap);
  background: none; color: var(--text); font-size: 13px; font-weight: 600; text-align: left; cursor: pointer;
}
.me-menu > a svg, .me-menu > button svg { width: 17px; height: 17px; color: var(--muted); flex: none; }
.me-menu > a:hover, .me-menu > button:hover, .me-menu > a.on { background: rgba(255, 255, 255, .06); color: var(--accent-2); }
.mm-h { margin: 8px 8px 4px; padding-top: 8px; border-top: 1px solid var(--line-soft); font-size: 10.5px; font-weight: 700; letter-spacing: 1px; text-transform: uppercase; color: var(--faint); }
.mm-filter { width: calc(100% - 8px); margin: 4px; padding: 7px 10px; border-radius: 8px; border: 1px solid var(--line-strong); background: var(--bg-2); }
.mm-co { display: flex; flex-direction: column; max-height: 240px; overflow: auto; margin-bottom: 6px; border-bottom: 1px solid var(--line-soft); padding-bottom: 6px; }
.mm-co button { display: flex; align-items: center; gap: 8px; padding: 7px 8px; min-height: var(--tap); border: 0; border-radius: 8px; background: none; text-align: left; cursor: pointer; font-size: 12.5px; color: var(--text); }
.mm-co button b { min-width: 46px; color: var(--muted); font-size: 11px; }
.mm-co button span { flex: 1; }
.mm-co button svg { width: 15px; height: 15px; color: var(--accent); }
.mm-co button:hover { background: rgba(255, 255, 255, .06); }
.mm-co button.on { color: var(--accent-2); }

/* notifications */
.np { width: 360px; padding: 0; }
.np-h { display: flex; align-items: center; gap: 8px; padding: 12px 14px; border-bottom: 1px solid var(--line-soft); position: sticky; top: 0; background: var(--surface-2); }
.np-h b { flex: 1; }
.np-list { display: flex; flex-direction: column; padding: 6px; }
.np-item { display: block; padding: 10px; border-radius: 10px; color: var(--text); position: relative; }
.np-item:hover { background: rgba(255, 255, 255, .05); color: var(--text); }
.np-item b { display: block; font-size: 13px; font-weight: 600; }
.np-item span { display: block; font-size: 12px; color: var(--muted); }
.np-item small { font-size: 11px; color: var(--faint); }
.np-item.unread { background: rgba(142, 198, 63, .07); padding-left: 22px; }
.np-item.unread::before { content: ""; position: absolute; left: 9px; top: 16px; width: 7px; height: 7px; border-radius: 50%; background: var(--accent); }
.np-msg { padding: 16px; color: var(--muted); font-size: 12.5px; }

/* global search */
.gsearch { position: relative; }
.gs-box {
  display: flex; align-items: center; gap: 8px; width: 300px; padding: 0 10px; height: 38px;
  background: var(--bg-2); border: 1px solid var(--line-strong); border-radius: 10px;
}
.gs-box:focus-within { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(142, 198, 63, .18); }
.gs-box > svg { width: 16px; height: 16px; color: var(--faint); flex: none; }
.gs-box input { flex: 1; min-width: 0; border: 0; background: transparent; height: 100%; }
.gs-box input:focus-visible { outline: none; }
.gs-box input::-webkit-search-cancel-button { display: none; }
.gs-box kbd { font: 600 10px/1 inherit; color: var(--faint); border: 1px solid var(--line); border-radius: 4px; padding: 3px 5px; white-space: nowrap; }
.gs-open, .gs-close { display: none !important; }
.gs-pop { left: 0; right: auto; width: 420px; padding: 6px; }
.gs-h { padding: 8px 10px 4px; font-size: 10.5px; font-weight: 700; letter-spacing: 1px; text-transform: uppercase; color: var(--faint); }
.gs-item { display: block; padding: 8px 10px; border-radius: 9px; color: var(--text); }
.gs-item b { display: block; font-size: 13px; font-weight: 600; }
.gs-item span { display: block; font-size: 11.5px; color: var(--muted); }
.gs-item:hover, .gs-item.on { background: rgba(142, 198, 63, .12); color: var(--text); }
.gs-msg { padding: 14px 10px; color: var(--muted); font-size: 12.5px; }
.gs-msg.err { color: var(--bad-text); }

/* date range bar */
.rangebar { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.seg { display: inline-flex; padding: 3px; gap: 2px; border-radius: 11px; background: var(--surface); border: 1px solid var(--line); }
.seg button {
  border: 0; background: transparent; padding: 6px 11px; border-radius: 8px; cursor: pointer;
  color: var(--muted); font-size: 12.5px; font-weight: 600; transition: all .15s;
}
.seg button:hover { color: var(--text); }
.seg button.on { background: var(--accent); color: var(--accent-ink); }
.dates { display: inline-flex; align-items: center; gap: 6px; color: var(--muted); font-size: 12px; }
.dates input { background: var(--surface); border: 1px solid var(--line-strong); border-radius: 9px; padding: 5px 8px; color-scheme: dark; font-size: 12.5px; }

/* ---------- building blocks ---------- */
.grid { display: grid; gap: 16px; }
.kpis { grid-template-columns: repeat(auto-fill, minmax(205px, 1fr)); margin-bottom: 16px; }
.row-2-1 { grid-template-columns: 2fr 1fr; }
.row-1-1 { grid-template-columns: 1fr 1fr; }
.row-1-1-1 { grid-template-columns: repeat(3, 1fr); }
@media (max-width: 1200px) { .row-2-1 { grid-template-columns: 3fr 2fr; } .row-1-1-1 { grid-template-columns: 1fr 1fr; } }

/* left menu collapse toggle (desktop + tablet) */
.nav-toggle {
  display: flex; align-items: center; gap: 12px; margin-top: 8px; padding: 9px 12px; border: 0; border-radius: 10px;
  background: none; color: var(--faint); font: inherit; font-size: 12px; font-weight: 600; cursor: pointer; text-align: left;
}
.nav-toggle svg { width: 19px; height: 19px; flex: none; transition: transform .2s; }
.nav-toggle:hover { background: rgba(255, 255, 255, .04); color: var(--text); }

/* icon rail */
html.nav-rail { --sidebar: 72px; }
html.nav-rail .sidebar .logo { justify-content: center; padding: 4px 0 18px; }
html.nav-rail .sidebar .logo-text, html.nav-rail .nav a span, html.nav-rail .nav .kbd, html.nav-rail .nav-toggle span, html.nav-rail .sidebar .nav-h,
html.nav-rail .user-box .t, html.nav-rail .sidebar-foot > span:not(.dot), html.nav-rail .sidebar-foot > br { display: none; }
html.nav-rail .nav-group + .nav-group { border-top: 1px solid var(--line-soft); padding-top: 6px; }
html.nav-rail .sidebar { padding: 18px 10px; }
html.nav-rail .nav a, html.nav-rail .nav-toggle { justify-content: center; padding: 12px 0; }
html.nav-rail .nav-toggle svg { transform: scaleX(-1); }
html.nav-rail .sidebar-foot { padding: 8px 0; text-align: center; font-size: 0; }
html.nav-rail .user-box .who { justify-content: center; }

/* tablet */
@media (max-width: 1024px) and (min-width: 761px) {
  .row-2-1, .row-1-1, .row-1-1-1 { grid-template-columns: 1fr; }
  .content, .topbar { padding-left: 18px; padding-right: 18px; }
  .gs-box { width: 220px; }
}

.card {
  background: linear-gradient(180deg, var(--surface) 0%, var(--surface-end) 100%);
  border: 1px solid var(--line-soft); border-radius: var(--radius); padding: 18px 18px 16px;
  box-shadow: var(--shadow); min-width: 0; position: relative;
}
.card-h { display: flex; align-items: center; gap: 10px; margin-bottom: 12px; flex-wrap: wrap; }
.card-h h3, .card-h h2 { margin: 0; font-size: 14.5px; font-weight: 600; }
.card-h .hint { color: var(--faint); font-size: 11.5px; }
.card-h .more { margin-left: auto; font-size: 12px; font-weight: 600; display: inline-flex; gap: 4px; align-items: center; }
.chart { width: 100%; height: 320px; }
.chart.sm { height: 240px; }
.chart.lg { height: 380px; }

/* KPI tile */
.kpi {
  display: block; color: inherit; padding: 16px 16px 14px; border-radius: var(--radius);
  background: linear-gradient(160deg, var(--surface-2) 0%, var(--surface) 100%);
  border: 1px solid var(--line-soft); position: relative; overflow: hidden;
  transition: transform .18s var(--ease), border-color .18s, box-shadow .18s;
  animation: rise .45s var(--ease) both;
}
a.kpi:hover { transform: translateY(-2px); border-color: rgba(142, 198, 63, .45); box-shadow: 0 12px 30px rgba(0, 0, 0, .4); color: inherit; }
a.kpi:active { border-color: rgba(142, 198, 63, .6); }
.kpi::after {
  content: ""; position: absolute; right: -30px; top: -30px; width: 110px; height: 110px; border-radius: 50%;
  background: radial-gradient(circle, var(--glow, rgba(142, 198, 63, .16)) 0%, transparent 70%); pointer-events: none;
}
.kpi .k-label { display: flex; align-items: center; gap: 8px; color: var(--muted); font-size: 12px; font-weight: 500; }
.kpi .k-label svg { width: 16px; height: 16px; color: var(--ic, var(--accent)); flex: none; }
.kpi .k-value { font-size: 28px; font-weight: 700; letter-spacing: -.5px; margin: 6px 0 2px; font-variant-numeric: tabular-nums; }
.kpi .k-value small { font-size: 14px; font-weight: 600; color: var(--muted); margin-left: 3px; }
.kpi .k-foot { font-size: 11.5px; color: var(--faint); display: flex; gap: 8px; align-items: center; min-height: 18px; }
.delta { font-weight: 700; font-size: 11.5px; padding: 1px 6px; border-radius: 20px; }
.delta.up { color: var(--good); background: rgba(142, 198, 63, .12); }
.delta.down { color: var(--bad); background: rgba(239, 91, 91, .12); }
.delta.flat { color: var(--muted); background: rgba(255, 255, 255, .06); }
.kpi.bad { --glow: rgba(239, 91, 91, .2); --ic: var(--bad); }
.kpi.warn { --glow: rgba(242, 181, 58, .2); --ic: var(--warn); }
.kpi.info { --glow: rgba(79, 179, 217, .2); --ic: var(--info); }
.kpi.violet { --glow: rgba(155, 140, 255, .2); --ic: var(--violet); }
@keyframes rise { from { transform: translateY(8px); } to { transform: none; } }

/* tabs */
.tabs { display: flex; gap: 4px; margin: -6px 0 18px; border-bottom: 1px solid var(--line); overflow-x: auto; scrollbar-width: none; }
.tabs::-webkit-scrollbar { display: none; }
.tabs a, .tabs [data-tab] {
  padding: 10px 16px; color: var(--muted); font-weight: 600; font-size: 13.5px; white-space: nowrap; cursor: pointer;
  border: 0; background: none; border-bottom: 2px solid transparent; margin-bottom: -1px; display: inline-flex; gap: 8px; align-items: center;
}
.tabs a:hover, .tabs [data-tab]:hover { color: var(--text); }
.tabs a.on, .tabs [data-tab].on { color: var(--accent); border-bottom-color: var(--accent); }
.tabs :focus-visible { outline-offset: -2px; }
.tabs .count { font-size: 11px; background: var(--surface-3); color: var(--muted); padding: 0 7px; border-radius: 10px; }
.drawer-b .tabs { margin-top: 0; }

/* toolbar, search, buttons, chips */
.toolbar { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin-bottom: 12px; }
.toolbar .end, .toolbar .push { margin-left: auto; }
.search {
  display: inline-flex; align-items: center; gap: 8px; padding: 0 12px; min-width: 240px; min-height: var(--tap);
  background: var(--bg-2); border: 1px solid var(--line-strong); border-radius: 10px;
}
.search:focus-within { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(142, 198, 63, .18); }
.search svg { width: 15px; height: 15px; color: var(--faint); flex: none; }
.search input { border: 0; background: transparent; width: 100%; padding: 7px 0; }
.search input:focus-visible { outline: none; }
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: var(--tap);
  border: 1px solid var(--line-strong); background: var(--surface-2); padding: 7px 13px; border-radius: 10px;
  cursor: pointer; font-size: 12.5px; font-weight: 600; color: var(--text); white-space: nowrap; text-decoration: none;
  transition: border-color .15s, color .15s, background .15s, filter .15s;
}
.btn:hover { border-color: var(--accent); color: var(--accent-2); }
.btn:active { filter: brightness(.92); }
.btn svg { width: 15px; height: 15px; flex: none; }
.btn.primary { background: linear-gradient(90deg, var(--accent), var(--accent-3)); border-color: var(--accent); color: var(--accent-ink); }
.btn.primary:hover { color: var(--accent-ink); filter: brightness(1.07); }
.btn.danger { background: rgba(239, 91, 91, .14); border-color: rgba(239, 91, 91, .6); color: var(--bad-text); }
.btn.danger:hover { background: var(--bad); border-color: var(--bad); color: #fff; }
.btn.ghost { background: transparent; border-color: transparent; color: var(--muted); }
.btn.ghost:hover { background: rgba(255, 255, 255, .05); color: var(--text); border-color: transparent; }
.btn.sm { min-height: 30px; padding: 4px 10px; font-size: 12px; border-radius: 8px; }
.btn.icon { padding: 0; width: var(--tap); }
.btn.sm.icon { width: 30px; }
.btn.block { width: 100%; }
.btn[disabled], .btn:disabled { opacity: .55; cursor: not-allowed; filter: none; }
.btn.busy { position: relative; color: transparent !important; pointer-events: none; }
.btn.busy::after { content: ""; position: absolute; inset: 0; margin: auto; width: 16px; height: 16px; border: 2px solid currentColor; border-color: var(--accent-ink) transparent var(--accent-ink) var(--accent-ink); border-radius: 50%; animation: rot .7s linear infinite; }
.btn:not(.primary).busy::after { border-color: var(--text) transparent var(--text) var(--text); }
button.link, .link { border: 0; background: none; padding: 0; color: var(--accent-2); font-weight: 600; cursor: pointer; text-decoration: underline; text-underline-offset: 2px; }
.chips { display: flex; gap: 6px; flex-wrap: wrap; }
.chip {
  display: inline-flex; align-items: center; gap: 4px; border: 1px solid var(--line-strong); background: var(--bg-2); color: var(--muted);
  padding: 5px 11px; border-radius: 20px; font-size: 12px; font-weight: 600; cursor: pointer; white-space: nowrap;
}
.chip:hover { color: var(--text); }
.chip.on, .chip[aria-pressed="true"] { background: rgba(142, 198, 63, .14); border-color: rgba(142, 198, 63, .6); color: var(--accent-2); }
.chip .n { opacity: .75; margin-left: 4px; font-weight: 500; }

/* tables */
.table-wrap { overflow: auto; border-radius: var(--radius-sm); border: 1px solid var(--line-soft); max-height: 640px; }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th, td { padding: 9px 12px; text-align: left; white-space: nowrap; }
th {
  position: sticky; top: 0; z-index: 1; background: var(--th); color: var(--muted);
  font-size: 11px; text-transform: uppercase; letter-spacing: .6px; font-weight: 600; user-select: none;
}
.th-sort { display: inline-flex; align-items: center; gap: 4px; border: 0; background: none; padding: 2px 0; margin: -2px 0; cursor: pointer; font: inherit; color: inherit; text-transform: inherit; letter-spacing: inherit; }
th.num .th-sort { flex-direction: row-reverse; }
.th-sort:hover { color: var(--text); }
.sort-ic { width: 10px; display: inline-block; text-align: center; opacity: .45; }
.sort-ic::after { content: "↕"; }
th.sorted { color: var(--accent-2); }
th.sorted .sort-ic { opacity: 1; }
th.sorted .sort-ic::after { content: "▾"; }
th.sorted.asc .sort-ic::after { content: "▴"; }
td { border-top: 1px solid var(--line-soft); }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
td.wrap { white-space: normal; min-width: 220px; overflow-wrap: anywhere; }
tbody tr { transition: background .12s; }
tbody tr:hover { background: rgba(142, 198, 63, .06); }
tbody tr.click { cursor: pointer; }
tbody tr:focus-visible { outline: 2px solid var(--focus); outline-offset: -2px; background: rgba(142, 198, 63, .08); }
tbody tr.selected { background: rgba(142, 198, 63, .10); }
th.sel, td.sel { width: 40px; padding-right: 0; }
th.sel input, td.sel input, .matrix input { width: 17px; height: 17px; accent-color: var(--accent); cursor: pointer; margin: 0; vertical-align: middle; }
tr.group td, tr.group th { background: rgba(255, 255, 255, .03); font-weight: 700; color: var(--accent-2); font-size: 12px; letter-spacing: .4px; text-transform: uppercase; }
tr.total td { font-weight: 700; background: rgba(142, 198, 63, .07); }
.muted { color: var(--muted); }
.faint { color: var(--faint); }
.empty { color: var(--faint); text-align: center; padding: 28px; white-space: normal; }
tr.empty-row:hover { background: none; }
.pt-table { transition: opacity .15s; }
.pt-table.loading { opacity: .55; pointer-events: none; }
.pt-msg:empty { display: none; }
.pt-msg { margin-bottom: 10px; }

/* pager + bulk bar */
.pager { display: flex; align-items: center; gap: 10px 14px; flex-wrap: wrap; margin-top: 10px; font-size: 12.5px; color: var(--muted); }
.pg { display: flex; align-items: center; gap: 4px; flex-wrap: wrap; }
.pg-b {
  min-width: 32px; height: 32px; padding: 0 8px; display: inline-grid; place-items: center; border-radius: 8px; cursor: pointer;
  border: 1px solid var(--line); background: var(--surface-2); color: var(--text); font-size: 12.5px; font-weight: 600; font-variant-numeric: tabular-nums;
}
.pg-b svg { width: 14px; height: 14px; }
.pg-b:hover { border-color: var(--accent); }
.pg-b.on { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.pg-b:disabled { opacity: .4; cursor: default; border-color: var(--line); }
.pg-gap { padding: 0 2px; color: var(--faint); }
.pg-size { margin-left: auto; display: inline-flex; align-items: center; gap: 6px; }
.pg-size select { padding: 5px 8px; border-radius: 8px; border: 1px solid var(--line-strong); background: var(--bg-2); color-scheme: dark; }
/* floats over the page bottom, so showing it never pushes the table down (S12) */
.bulkbar {
  position: fixed; left: calc(var(--sidebar) + 28px); right: 28px; bottom: 16px; z-index: 25; max-width: 980px; margin: 0 auto;
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  padding: 8px 10px 8px 16px; border-radius: 12px; background: var(--surface-3); border: 1px solid rgba(142, 198, 63, .45); box-shadow: 0 14px 40px rgba(0, 0, 0, .55);
  animation: tin .16s var(--ease);
}
html.has-bulkbar .content { padding-bottom: 96px; }
.bulkbar .bb-n { color: var(--accent-2); font-size: 13px; }
.bulkbar .bb-a { display: flex; gap: 6px; flex-wrap: wrap; flex: 1; }

/* badges & bars */
.badge { display: inline-flex; align-items: center; gap: 5px; padding: 2px 9px; border-radius: 20px; font-size: 11.5px; font-weight: 600; white-space: nowrap; }
.badge::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.b-good { color: var(--good); background: rgba(142, 198, 63, .12); }
.b-warn { color: var(--warn); background: rgba(242, 181, 58, .12); }
.b-bad { color: var(--bad); background: rgba(239, 91, 91, .12); }
.b-info { color: var(--info); background: rgba(79, 179, 217, .12); }
.b-violet { color: var(--violet); background: rgba(155, 140, 255, .14); }
.b-mute { color: var(--muted); background: rgba(255, 255, 255, .06); }
.bar { height: 7px; border-radius: 7px; background: rgba(255, 255, 255, .07); overflow: hidden; min-width: 90px; }
.bar > i { display: block; height: 100%; border-radius: 7px; background: linear-gradient(90deg, var(--accent) 0%, var(--accent-2) 100%); transition: width .2s; }
.bar.warn > i { background: linear-gradient(90deg, #d99a1e, var(--warn)); }
.bar.bad > i { background: linear-gradient(90deg, #c94040, var(--bad)); }
.stackbar { display: flex; height: 10px; border-radius: 10px; overflow: hidden; background: rgba(255, 255, 255, .06); }
.stackbar i { display: block; height: 100%; }

/* lists */
.list { display: flex; flex-direction: column; }
.li { display: flex; align-items: center; gap: 12px; padding: 10px 4px; border-top: 1px solid var(--line-soft); color: inherit; }
.li:first-child { border-top: 0; }
a.li:hover, .li[role="button"]:hover { background: rgba(255, 255, 255, .03); color: inherit; border-radius: 8px; cursor: pointer; }
.li .ic { width: 34px; height: 34px; border-radius: 10px; display: grid; place-items: center; flex: none; background: var(--surface-3); color: var(--accent); }
.li .ic svg { width: 17px; height: 17px; }
.li .ic.bad { color: var(--bad); background: rgba(239, 91, 91, .12); }
.li .ic.warn { color: var(--warn); background: rgba(242, 181, 58, .12); }
.li .ic.info { color: var(--info); background: rgba(79, 179, 217, .12); }
.li .t { flex: 1; min-width: 0; }
.li .t b { display: block; font-weight: 600; font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.li .t > span:not(.badge) { font-size: 11.5px; color: var(--faint); }
.li .v { font-weight: 700; font-variant-numeric: tabular-nums; }
.date-tile { width: 44px; flex: none; text-align: center; border-radius: 10px; background: var(--surface-3); padding: 4px 0; font-size: 10px; color: var(--muted); text-transform: uppercase; letter-spacing: .5px; }
.date-tile b { display: block; font-size: 17px; color: var(--text); letter-spacing: 0; }

/* ring */
.ring { position: relative; width: 168px; height: 168px; margin: 4px auto; }
.ring svg { transform: rotate(-90deg); }
.ring .lbl { position: absolute; inset: 0; display: grid; place-items: center; text-align: center; }
.ring .lbl b { font-size: 34px; font-weight: 700; letter-spacing: -1px; display: block; }
.ring .lbl span { font-size: 11px; color: var(--muted); }
.legend { display: grid; grid-template-columns: 1fr 1fr; gap: 8px 14px; margin-top: 12px; font-size: 12.5px; }
.legend div { display: flex; align-items: center; gap: 8px; }
.legend i { width: 10px; height: 10px; border-radius: 3px; flex: none; }
.legend b { margin-left: auto; font-variant-numeric: tabular-nums; }

/* people cards */
.people-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 12px; }
.pcard {
  display: flex; gap: 12px; align-items: center; padding: 14px; border-radius: var(--radius-sm); cursor: pointer;
  background: var(--surface-2); border: 1px solid var(--line-soft); transition: border-color .15s, transform .15s; color: inherit;
}
.pcard:hover { border-color: rgba(142, 198, 63, .5); transform: translateY(-1px); color: inherit; }
.pcard:active { border-color: rgba(142, 198, 63, .7); }
.avatar {
  width: 44px; height: 44px; border-radius: 50%; flex: none; display: grid; place-items: center; font-weight: 700;
  background: linear-gradient(135deg, #2b3a4c, #1e2a38); color: var(--accent-2); font-size: 14px; border: 2px solid var(--line); object-fit: cover;
}
.pcard .t { flex: 1; min-width: 0; }
.pcard .t b { display: block; font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pcard .t span { font-size: 11.5px; color: var(--faint); display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pcard .pct { font-weight: 700; font-size: 15px; font-variant-numeric: tabular-nums; }

/* ---------- overlays ---------- */
.scrim { position: fixed; inset: 0; background: rgba(4, 8, 12, .62); z-index: 40; opacity: 0; pointer-events: none; transition: opacity .2s; }
.scrim.open { opacity: 1; pointer-events: auto; }
.drawer {
  position: fixed; top: 0; right: 0; bottom: 0; width: min(760px, 96vw); z-index: 50;
  background: linear-gradient(180deg, #121c28 0%, #0e1621 100%); border-left: 1px solid var(--line);
  box-shadow: -20px 0 50px rgba(0, 0, 0, .5); transform: translateX(102%); visibility: hidden;
  transition: transform .28s var(--ease), visibility 0s linear .28s, width .2s;
  display: flex; flex-direction: column;
}
.drawer.open { transform: none; visibility: visible; transition: transform .28s var(--ease), visibility 0s, width .2s; }
.drawer.wide { width: min(1180px, 96vw); }
.drawer-h { display: flex; align-items: center; gap: 14px; padding: 18px 24px; border-bottom: 1px solid var(--line-soft); }
.drawer-h > div:first-child { min-width: 0; }
.drawer-h h2 { margin: 0; font-size: 19px; overflow-wrap: anywhere; }
.drawer-h .sub { color: var(--muted); font-size: 12.5px; }
.drawer-actions { margin-left: auto; display: flex; gap: 8px; }
.drawer-actions + .x { margin-left: 0; }
.x {
  margin-left: auto; border: 0; background: var(--surface-3); width: 36px; height: 36px; border-radius: 10px; cursor: pointer;
  color: var(--muted); display: grid; place-items: center; flex: none; padding: 0;
}
.x svg { width: 18px; height: 18px; }
.x:hover { color: var(--text); background: var(--line); }
.drawer-b { padding: 20px 24px 40px; overflow: auto; flex: 1; }
.drawer-b section { margin-bottom: 22px; }
.drawer-b h4 { margin: 0 0 10px; font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: .8px; }
.facts { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; }
.fact { background: var(--surface-2); border-radius: 10px; padding: 10px 12px; border: 1px solid var(--line-soft); }
.fact > span { display: block; font-size: 11px; color: var(--faint); }
.fact b { font-size: 14px; font-variant-numeric: tabular-nums; }
.photo { width: 76px; height: 76px; border-radius: 16px; object-fit: cover; border: 2px solid var(--line); }

.modal-wrap { position: fixed; inset: 0; z-index: 70; display: grid; place-items: center; padding: 20px; }
.modal-bg { position: absolute; inset: 0; background: rgba(4, 8, 12, .66); opacity: 0; transition: opacity .18s; }
.modal {
  position: relative; width: min(560px, 100%); max-height: calc(100vh - 40px); display: flex; flex-direction: column;
  background: linear-gradient(180deg, #172332 0%, #111a26 100%); border: 1px solid var(--line); border-radius: 16px; box-shadow: 0 30px 70px rgba(0, 0, 0, .6);
  opacity: 0; transform: translateY(10px) scale(.98); transition: opacity .18s, transform .18s var(--ease);
}
.modal-wrap.open .modal-bg, .modal-wrap.open .modal { opacity: 1; transform: none; }
.modal.sm { width: min(420px, 100%); }
.modal.lg { width: min(980px, 100%); }
.modal.sheet { width: min(420px, 100%); }
.modal-h { display: flex; align-items: center; gap: 12px; padding: 16px 20px; border-bottom: 1px solid var(--line-soft); }
.modal-h h2 { margin: 0; font-size: 17px; }
.modal-b { padding: 18px 20px; overflow: auto; }
.modal-text { margin: 0; color: var(--muted); }
.modal-f { display: flex; justify-content: flex-end; gap: 8px; padding: 12px 20px 16px; border-top: 1px solid var(--line-soft); flex-wrap: wrap; }
.sheet-nav { display: flex; flex-direction: column; margin-bottom: 8px; }
.sheet-nav .nav-h { padding-left: 4px; }
.sheet-nav a { display: flex; align-items: center; gap: 12px; padding: 10px 8px; min-height: 48px; border-radius: 10px; color: var(--text); font-weight: 600; }
.sheet-nav a svg { width: 20px; height: 20px; color: var(--muted); }
.sheet-nav a.active { background: rgba(142, 198, 63, .14); color: var(--accent-2); }

.toasts { position: fixed; right: 18px; bottom: 18px; z-index: 90; display: flex; flex-direction: column; gap: 8px; align-items: flex-end; pointer-events: none; }
.toast {
  pointer-events: auto; display: flex; align-items: center; gap: 10px; min-width: 260px; max-width: 440px;
  background: var(--surface-3); border: 1px solid var(--line); border-left: 4px solid var(--info); padding: 8px 8px 8px 12px;
  border-radius: 10px; box-shadow: var(--shadow); font-size: 13px; animation: tin .2s var(--ease);
}
.toast > svg { width: 18px; height: 18px; flex: none; color: var(--info); }
.toast .tt { flex: 1; }
.toast .x { width: 30px; height: 30px; margin-left: 0; background: transparent; }
.toast.ok { border-left-color: var(--good); } .toast.ok > svg { color: var(--good); }
.toast.err { border-left-color: var(--bad); } .toast.err > svg { color: var(--bad); }
.toast.warn { border-left-color: var(--warn); } .toast.warn > svg { color: var(--warn); }
.toast.out { opacity: 0; transform: translateX(20px); transition: opacity .18s, transform .18s; }
@keyframes tin { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

/* ---------- forms ---------- */
.form { display: grid; gap: 14px; }
.form.cols-2 { grid-template-columns: 1fr 1fr; gap: 14px 16px; }
.form.cols-2 > .span-2, .form.cols-2 > .msg, .form.cols-2 > .form-actions { grid-column: 1 / -1; }
.field { display: block; min-width: 0; margin: 0; padding: 0; border: 0; }
.field > label, .field > span, .field > legend { display: block; font-size: 12px; color: var(--muted); margin-bottom: 6px; font-weight: 600; padding: 0; }
.field > label.check, .field > label.switch { display: inline-flex; margin-bottom: 0; font-size: 13px; font-weight: 500; color: var(--text); }
.field .req { color: var(--warn); font-style: normal; }
.field input:not([type=checkbox]):not([type=radio]), .field select, .field textarea, .input {
  display: block; width: 100%; min-height: 40px; padding: 9px 12px; border-radius: 10px; border: 1px solid var(--line-strong); background: var(--bg-2);
  color: var(--text); color-scheme: dark; transition: border-color .15s, box-shadow .15s;
}
.field textarea { resize: vertical; min-height: 84px; }
.field input:focus, .field select:focus, .field textarea:focus, .input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(142, 198, 63, .18); outline: none; }
.field input[readonly], .field input:disabled, .field select:disabled, .field textarea:disabled { opacity: .65; cursor: not-allowed; }
.field input::placeholder, .field textarea::placeholder { color: var(--faint); }
.field .help { display: block; margin-top: 5px; font-size: 11.5px; color: var(--faint); }
.field .err { display: block; font-size: 12px; color: var(--bad-text); margin-top: 5px; }
.field .err:empty { display: none; }
.field.invalid input:not([type=checkbox]):not([type=radio]), .field.invalid select, .field.invalid textarea, .field.invalid .lk-box { border-color: var(--bad); }
.radios { display: flex; flex-wrap: wrap; gap: 6px 16px; }
.check, .switch { display: inline-flex; align-items: center; gap: 10px; font-size: 13px; cursor: pointer; min-height: var(--tap); }
.check input { width: 18px; height: 18px; accent-color: var(--accent); margin: 0; flex: none; }
.switch input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.switch { position: relative; }
.switch .sw { display: block; position: relative; width: 38px; height: 22px; border-radius: 22px; background: var(--surface-3); border: 1px solid var(--line-strong); flex: none; transition: background .15s; }
.switch .sw::after { content: ""; position: absolute; top: 2px; left: 2px; width: 16px; height: 16px; border-radius: 50%; background: var(--muted); transition: transform .15s, background .15s; }
.switch input:checked + .sw { background: rgba(142, 198, 63, .35); border-color: var(--accent); }
.switch input:checked + .sw::after { transform: translateX(16px); background: var(--accent); }
.switch input:focus-visible + .sw { outline: 2px solid var(--focus); outline-offset: 2px; }
.form-actions { display: flex; gap: 8px; justify-content: flex-end; align-items: center; flex-wrap: wrap; }
.form-actions .spacer { flex: 1; }
.msg { font-size: 13px; min-height: 0; }
.msg:empty { display: none; }
.msg.err { color: var(--bad-text); padding: 10px 12px; border-radius: 10px; background: rgba(239, 91, 91, .1); border: 1px solid rgba(239, 91, 91, .3); }
.msg.ok { color: var(--accent-2); padding: 10px 12px; border-radius: 10px; background: rgba(142, 198, 63, .08); border: 1px solid rgba(142, 198, 63, .3); }
.secret { display: flex; gap: 10px; align-items: center; padding: 14px; border-radius: 12px; background: rgba(142, 198, 63, .08); border: 1px dashed rgba(142, 198, 63, .5); }
.secret code { font-size: 18px; letter-spacing: 1px; font-weight: 700; color: var(--accent-2); flex: 1; overflow-wrap: anywhere; }

/* password toggle + strength meter */
.pw { position: relative; display: block; }
.pw input { padding-right: 46px !important; }
.pw-t { position: absolute; right: 3px; top: 50%; transform: translateY(-50%); width: 38px; height: 34px; border: 0; border-radius: 8px; background: none; color: var(--muted); cursor: pointer; display: grid; place-items: center; }
.pw-t:hover { color: var(--text); background: rgba(255, 255, 255, .05); }
.pw-t svg { width: 18px; height: 18px; }
.pwm { margin-top: 8px; font-size: 12px; }
.pwm-bar { display: grid; grid-template-columns: repeat(4, 1fr); gap: 4px; }
.pwm-bar i { height: 5px; border-radius: 4px; background: var(--surface-3); transition: background .15s; }
.pwm[data-s="1"] .pwm-bar i:nth-child(-n+1) { background: var(--bad); }
.pwm[data-s="2"] .pwm-bar i:nth-child(-n+2) { background: var(--warn); }
.pwm[data-s="3"] .pwm-bar i:nth-child(-n+3) { background: var(--accent-2); }
.pwm[data-s="4"] .pwm-bar i { background: var(--accent); }
.pwm-t { display: block; margin-top: 4px; color: var(--muted); font-weight: 600; min-height: 1em; }
.pwm-rules { list-style: none; margin: 6px 0 0; padding: 0; display: grid; gap: 2px; color: var(--faint); }
.pwm-rules li { display: flex; align-items: center; gap: 6px; }
.pwm-rules svg { width: 13px; height: 13px; opacity: .25; }
.pwm-rules li.ok { color: var(--accent-2); }
.pwm-rules li.ok svg { opacity: 1; }

/* auth screens (login, change / forgot / reset password) */
.auth-page { display: grid; place-items: center; min-height: 100vh; padding: 24px; }
.auth { width: min(420px, 100%); }
.auth .brand { display: flex; align-items: center; gap: 12px; justify-content: center; margin-bottom: 26px; }
.auth .card { padding: 30px 30px 26px; }
.auth h1 { font-size: 21px; margin: 0 0 4px; }
.auth p.sub { color: var(--muted); margin: 0 0 22px; font-size: 13px; }
.auth form { display: grid; gap: 14px; }
.auth form[hidden] { display: none; }
.auth .btn.primary, .auth button.primary { width: 100%; min-height: 44px; font-size: 14px; font-weight: 700; margin-top: 4px; }
.auth button.primary:not(.btn) {
  border: 0; border-radius: 10px; padding: 12px; cursor: pointer; color: var(--accent-ink);
  background: linear-gradient(90deg, var(--accent), var(--accent-3)); box-shadow: 0 8px 22px rgba(142, 198, 63, .25);
}
.auth .primary:disabled { opacity: .6; cursor: default; }
.auth .links { display: flex; justify-content: space-between; gap: 10px; flex-wrap: wrap; font-size: 12.5px; }
.auth .foot { text-align: center; color: var(--faint); font-size: 11.5px; margin-top: 18px; }
.auth .code { letter-spacing: 8px; text-align: center; font-size: 20px; font-variant-numeric: tabular-nums; }

/* lookup / combobox */
.lookup { position: relative; }
.lk-box {
  display: flex; align-items: center; flex-wrap: wrap; gap: 4px; min-height: 40px; padding: 4px 34px 4px 8px; position: relative;
  border: 1px solid var(--line-strong); border-radius: 10px; background: var(--bg-2); cursor: text;
}
.lk-box:focus-within { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(142, 198, 63, .18); }
.lk-box input { flex: 1; min-width: 90px; border: 0 !important; background: transparent !important; padding: 5px 4px !important; min-height: 0 !important; box-shadow: none !important; }
.lk-box input:focus-visible { outline: none; }
.lk-caret { position: absolute; right: 10px; width: 15px; height: 15px; color: var(--faint); pointer-events: none; }
.lk-clear { position: absolute; right: 30px; width: 26px; height: 26px; border: 0; border-radius: 6px; background: none; color: var(--faint); cursor: pointer; display: grid; place-items: center; }
.lk-clear svg { width: 14px; height: 14px; }
.lk-clear:hover { color: var(--text); }
.lk-chips { display: contents; }
.lk-chip { cursor: default; padding: 2px 4px 2px 10px; }
.lk-chip button { display: grid; place-items: center; width: 22px; height: 22px; border: 0; border-radius: 50%; background: none; color: inherit; cursor: pointer; }
.lk-chip button svg { width: 12px; height: 12px; }
.lk-chip button:hover { background: rgba(255, 255, 255, .1); }
.lk-pop { left: 0; right: 0; min-width: 0; top: calc(100% + 4px); padding: 4px; max-height: 280px; }
.lk-opt { display: flex; align-items: center; gap: 8px; padding: 8px 10px; border-radius: 8px; cursor: pointer; }
.lk-opt b { display: block; font-weight: 600; font-size: 13px; }
.lk-opt small { display: block; font-size: 11.5px; color: var(--muted); }
.lk-opt:hover, .lk-opt.on { background: rgba(142, 198, 63, .12); }
.lk-opt[aria-selected="true"] b { color: var(--accent-2); }
.lk-opt.create { color: var(--accent-2); font-weight: 600; }
.lk-opt.off { opacity: .55; cursor: not-allowed; }
.lk-opt svg { width: 15px; height: 15px; }
.lk-tick { width: 16px; height: 16px; flex: none; border: 1px solid var(--line-strong); border-radius: 4px; display: grid; place-items: center; color: var(--accent); }
.lk-tick svg { width: 12px; height: 12px; }
.lk-msg { padding: 10px; color: var(--muted); font-size: 12.5px; }

/* empty state */
.empty-state { text-align: center; padding: 40px 20px; color: var(--muted); }
.empty-state .es-ic { width: 44px; height: 44px; padding: 10px; border-radius: 14px; background: var(--surface-3); color: var(--accent); margin-bottom: 10px; }
.empty-state h3 { margin: 0 0 6px; font-size: 15px; color: var(--text); }
.empty-state p { margin: 0 auto; max-width: 420px; font-size: 13px; }
.empty-state .es-a { display: flex; gap: 8px; justify-content: center; flex-wrap: wrap; margin-top: 16px; }
.empty-state.compact { padding: 20px 12px; }
.empty-state.compact .es-ic { width: 36px; height: 36px; padding: 8px; }

/* timeline */
.timeline { list-style: none; margin: 0; padding: 0; position: relative; }
.tl { position: relative; display: flex; gap: 14px; padding-bottom: 18px; }
.tl::before { content: ""; position: absolute; left: 13px; top: 28px; bottom: 0; width: 2px; background: var(--line); }
.tl:last-child::before { display: none; }
.tl-dot { width: 28px; height: 28px; border-radius: 50%; flex: none; display: grid; place-items: center; background: var(--surface-3); border: 2px solid var(--line-strong); color: var(--accent); }
.tl-dot svg { width: 14px; height: 14px; }
.tl.good .tl-dot { border-color: var(--good); } .tl.warn .tl-dot { border-color: var(--warn); color: var(--warn); } .tl.bad .tl-dot { border-color: var(--bad); color: var(--bad); } .tl.info .tl-dot { border-color: var(--info); color: var(--info); }
.tl-b { flex: 1; min-width: 0; padding-top: 3px; }
.tl-h { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.tl-h b { font-size: 13.5px; }
.tl-h time { margin-left: auto; font-size: 11.5px; color: var(--faint); white-space: nowrap; }
.tl-who { font-size: 12px; color: var(--muted); }
.tl-b p { margin: 4px 0 0; font-size: 13px; color: var(--muted); }
.tl-a { display: flex; gap: 4px; flex-wrap: wrap; margin-top: 6px; }

/* wizard / stepper */
.stepper { list-style: none; display: flex; gap: 6px; margin: 0 0 18px; padding: 0; counter-reset: st; overflow-x: auto; }
.stepper li { flex: 1; min-width: 0; }
.st-b { display: flex; align-items: center; gap: 8px; width: 100%; padding: 8px 10px; border: 0; border-bottom: 3px solid var(--line); background: none; color: var(--faint); font-weight: 600; font-size: 12.5px; text-align: left; cursor: pointer; }
.st-b:disabled { cursor: default; }
.st-b .n { width: 24px; height: 24px; flex: none; border-radius: 50%; display: grid; place-items: center; background: var(--surface-3); font-size: 12px; }
.st-b .t { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.stepper li.on .st-b { color: var(--text); border-bottom-color: var(--accent); }
.stepper li.on .st-b .n { background: var(--accent); color: var(--accent-ink); }
.stepper li.done .st-b { color: var(--accent-2); border-bottom-color: rgba(142, 198, 63, .45); }
.stepper li.done .st-b .n { background: rgba(142, 198, 63, .2); color: var(--accent-2); }
.stepper li.done .st-b:hover { color: var(--accent); }
.wz-pane { min-height: 120px; }
.wz-pane .form, .wz-pane > .field + .field { margin-top: 0; }
.wizard > .msg { margin: 12px 0 0; }
.wz-actions { margin-top: 16px; padding-top: 14px; border-top: 1px solid var(--line-soft); }

/* split pane (master-detail) */
.split { display: grid; grid-template-columns: var(--split-w, 290px) minmax(0, 1fr); gap: 16px; align-items: start; }
.split-list { display: flex; flex-direction: column; gap: 10px; padding: 12px; position: sticky; top: 84px; max-height: calc(100vh - 110px); }
.split-list .search { min-width: 0; width: 100%; }
.split-items { overflow: auto; display: flex; flex-direction: column; gap: 2px; margin: 0 -4px; padding: 0 4px; }
.sitem { display: block; width: 100%; text-align: left; padding: 9px 10px; border: 1px solid transparent; border-radius: 10px; background: none; color: var(--text); cursor: pointer; font-size: 13px; }
.sitem:hover { background: rgba(255, 255, 255, .04); }
.sitem.on { background: rgba(142, 198, 63, .12); border-color: rgba(142, 198, 63, .45); }
.sitem small { display: block; color: var(--faint); font-size: 11.5px; }
.split-back { display: none; margin-bottom: 10px; }

/* tree */
.tree, .tree ul { list-style: none; margin: 0; padding: 0; }
.tree li[role=treeitem] { outline: none; }
.tree-row {
  display: flex; align-items: center; gap: 6px; padding: 5px 8px 5px calc(6px + var(--depth, 0) * 18px); min-height: 32px;
  border-radius: 8px; cursor: pointer; font-size: 13px; user-select: none; border: 1px solid transparent;
}
.tree-row:hover { background: rgba(255, 255, 255, .04); }
.tree-row.on { background: rgba(142, 198, 63, .14); color: var(--accent-2); }
.tree li[role=treeitem]:focus-visible > .tree-row { outline: 2px solid var(--focus); outline-offset: -2px; }
.tree-toggle { width: 18px; height: 18px; flex: none; display: grid; place-items: center; color: var(--faint); border-radius: 4px; }
.tree-toggle svg { width: 14px; height: 14px; transition: transform .15s; }
.tree-toggle:hover { color: var(--text); background: rgba(255, 255, 255, .06); }
[aria-expanded="true"] > .tree-row .tree-toggle svg, tr[aria-expanded="true"] .tree-toggle svg { transform: rotate(90deg); }
.tree-ic { width: 16px; height: 16px; flex: none; color: var(--muted); }
.tree-row.on .tree-ic { color: var(--accent); }
.tree-label { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tree-msg { padding: 6px 8px 6px calc(30px + var(--depth, 0) * 18px); font-size: 12px; color: var(--muted); }
.tree-msg.err { color: var(--bad-text); }
.tree li.dragging > .tree-row { opacity: .45; }
.tree-row.drop-inside { border-color: var(--accent); background: rgba(142, 198, 63, .1); }
.tree-row.drop-before { box-shadow: inset 0 2px 0 var(--accent); }
.tree-row.drop-after { box-shadow: inset 0 -2px 0 var(--accent); }
.tree li[draggable=true] > .tree-row { cursor: grab; }

/* tree-grid */
.tt-cell { display: inline-flex; align-items: center; gap: 6px; padding-left: calc(var(--depth, 0) * 20px); }
.tt .tree-toggle { cursor: pointer; }
.tt tr[data-id]:focus-visible { outline: 2px solid var(--focus); outline-offset: -2px; }
tr.tt-msg td { color: var(--muted); font-size: 12px; }

/* permission matrix */
.mx-wrap { max-height: 70vh; }
.matrix th.mx-first, .matrix td.mx-first { position: sticky; left: 0; z-index: 2; background: var(--th); text-align: left; min-width: 220px; white-space: normal; }
.matrix tbody th.mx-first { background: var(--surface); text-transform: none; letter-spacing: 0; font-size: 13px; font-weight: 600; color: var(--text); }
.matrix tbody th.mx-first small { display: block; font-weight: 500; font-size: 11px; color: var(--faint); }
.matrix thead th.mx-first { z-index: 3; }
.matrix tr.group th.mx-first { background: #1a2532; color: var(--accent-2); text-transform: uppercase; font-size: 12px; }
.matrix .mx-c { text-align: center; min-width: 92px; }
.matrix td.mx-c { padding: 6px 12px; }
.matrix td.dirty { background: rgba(242, 181, 58, .14); box-shadow: inset 0 0 0 1px rgba(242, 181, 58, .5); }
.matrix input.inh { opacity: .55; }
.mx-all { display: inline-flex; flex-direction: column; align-items: center; gap: 4px; cursor: pointer; }
.matrix.radio input { accent-color: var(--accent); }
.mx-hint { display: none; align-items: center; gap: 6px; }
.mx-hint svg { width: 14px; height: 14px; }

/* dropzone */
.dropzone {
  display: flex; align-items: center; gap: 14px; padding: 22px; border: 2px dashed var(--line-strong); border-radius: 14px; background: rgba(255, 255, 255, .02);
  cursor: pointer; transition: border-color .15s, background .15s;
}
.dropzone:hover, .dropzone.over { border-color: var(--accent); background: rgba(142, 198, 63, .06); }
.dropzone .dz-ic { width: 36px; height: 36px; padding: 7px; border-radius: 10px; background: var(--surface-3); color: var(--accent); flex: none; }
.dropzone b { display: block; font-size: 14px; }
.dropzone span { font-size: 12.5px; color: var(--muted); }
.dz-list { list-style: none; margin: 10px 0 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.dz-list:empty { display: none; }
.dz-item { display: flex; align-items: center; gap: 10px; padding: 8px 8px 8px 12px; border-radius: 10px; background: var(--surface-2); border: 1px solid var(--line-soft); }
.dz-fi { width: 20px; height: 20px; color: var(--muted); flex: none; }
.dz-t { flex: 1; min-width: 0; display: grid; gap: 3px; }
.dz-t b { font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dz-s { font-size: 11.5px; color: var(--muted); }
.dz-item .bar { min-width: 0; height: 5px; }
.dz-item.done .dz-fi, .dz-item.done .dz-s { color: var(--accent-2); }
.dz-item.error { border-color: rgba(239, 91, 91, .4); }
.dz-item.error .dz-s, .dz-item.error .dz-fi { color: var(--bad-text); }
.dz-item.error .bar, .dz-item.cancelled .bar, .dz-item.done .bar { display: none; }

/* preview */
.preview { border-radius: 12px; overflow: hidden; background: var(--bg-2); border: 1px solid var(--line-soft); }
.pv-img { display: block; max-width: 100%; max-height: calc(100vh - 160px); margin: 0 auto; object-fit: contain; }
.pv-frame { display: block; width: 100%; height: calc(100vh - 150px); border: 0; background: #fff; }
.pv-media { display: block; width: 100%; }
.pv-text { margin: 0; padding: 16px; max-height: calc(100vh - 160px); overflow: auto; font: 12.5px/1.55 Consolas, "Cascadia Mono", monospace; white-space: pre-wrap; overflow-wrap: anywhere; }
.pv-card { display: grid; justify-items: center; gap: 6px; padding: 40px 20px; text-align: center; }
.pv-card .pv-fi { width: 48px; height: 48px; color: var(--muted); }
.pv-card span, .pv-card p { color: var(--muted); font-size: 12.5px; margin: 0; }
.pv-card .btn { margin-top: 10px; }
.pv-head { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; }
.pv-head > div { flex: 1; min-width: 0; }
.pv-head b { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pv-head span { font-size: 12px; color: var(--muted); }
.pv-head + .preview .pv-frame { height: 70vh; }

/* skeleton / misc */
.skeleton { border-radius: var(--radius); background: linear-gradient(90deg, #162130 25%, #1d2a3a 50%, #162130 75%); background-size: 200% 100%; animation: sk 1.2s infinite; min-height: 110px; }
@keyframes sk { to { background-position: -200% 0; } }
.note { font-size: 11.5px; color: var(--faint); margin-top: 8px; }
.pre { white-space: pre-wrap; overflow-wrap: anywhere; }

/* ---------- shared page patterns (UI/UX review §2: one rule instead of five page-local copies) ---------- */
/* uppercase section heading – same look as .drawer-b h4 */
.sec-h { margin: 0 0 10px; font-size: 12px; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: .8px; }
.sec { margin: 0 0 22px; }
.sec-h + .note { margin-top: -4px; }
/* note boxes: <p class="note info">…</p>, .note.warn, .note.bad, .note.good (an optional leading svg is coloured) */
.note.info, .note.warn, .note.bad, .note.good {
  display: block; position: relative; margin: 0 0 12px; padding: 10px 12px; border-radius: 10px;
  font-size: 12.5px; line-height: 1.5; color: var(--text); background: var(--info-bg); border: 1px solid var(--info-line);
}
.note.warn { background: var(--warn-bg); border-color: var(--warn-line); }
.note.bad { background: var(--bad-bg); border-color: var(--bad-line); }
.note.good { background: var(--good-bg); border-color: var(--good-line); }
.note.info > svg:first-child, .note.warn > svg:first-child, .note.bad > svg:first-child, .note.good > svg:first-child { position: absolute; left: 12px; top: 12px; width: 15px; height: 15px; color: var(--info); }
.note.info:has(> svg:first-child), .note.warn:has(> svg:first-child), .note.bad:has(> svg:first-child), .note.good:has(> svg:first-child) { padding-left: 35px; }
.note.warn > svg { color: var(--warn); } .note.bad > svg { color: var(--bad); } .note.good > svg { color: var(--good); }
.note b { color: var(--text); }
/* linked-item lists: <ul class="list"><li class="li"><div class="t"><b>Title</b><small>sub</small></div><div class="a">buttons</div></li></ul> */
ul.list, ol.list { list-style: none; margin: 0 0 10px; padding: 0; }
.li .t small { display: block; font-size: 11.5px; color: var(--faint); }
.li .t b.wrap, .list.wrap .li .t b { white-space: normal; overflow-wrap: anywhere; }
.li .a { display: flex; gap: 4px; flex: none; margin-left: auto; align-items: center; }
.list.boxed { gap: 6px; }
.list.boxed .li, .list.boxed .li:first-child { padding: 8px 10px; border: 1px solid var(--line-soft); border-radius: 10px; background: var(--surface-2); }
/* inline "add a link" row: <div class="add-row"><div class="grow">lookup</div><button class="btn">Add</button></div> */
.add-row { display: flex; flex-wrap: wrap; gap: 8px; align-items: flex-end; margin: 10px 0 12px; }
.add-row > .grow, .add-row > .lookup, .add-row > .field { flex: 1 1 220px; min-width: 0; margin: 0; }
.add-row > .field.narrow { flex: 0 1 170px; }
/* filter block with labelled chip rows: <div class="filters"><div class="filter-row"><span class="fl">Status</span><div class="chips scroll">… */
.filters { display: grid; gap: 8px; margin: 4px 0 14px; }
.filter-row { display: flex; gap: 10px; align-items: flex-start; min-width: 0; }
.filter-row > .fl { flex: none; width: 92px; padding-top: 7px; font-size: 11px; font-weight: 700; letter-spacing: .6px; text-transform: uppercase; color: var(--faint); }
.filter-row > .chips, .filter-row > .grow { flex: 1; min-width: 0; }
.filter-selects { display: flex; flex-wrap: wrap; gap: 8px; flex: 1; min-width: 0; }
.filter-selects .field { flex: 1 1 170px; max-width: 280px; }
.filter-selects .field > label { font-size: 11px; margin-bottom: 3px; color: var(--faint); }
.filters-toggle { display: none; }
/* result count line inside a toolbar */
.toolbar > .count, .count-line { color: var(--muted); font-size: 12.5px; }
.toolbar > .count { margin-left: auto; }
.count b, .count-line b { color: var(--text); }
/* detail header (title, badges, actions) for split panes and full pages */
.detail-h { display: flex; flex-wrap: wrap; gap: 10px 16px; align-items: flex-start; margin-bottom: 14px; }
.detail-h > .dt { flex: 1 1 260px; min-width: 0; }
.detail-h h2 { margin: 0 0 4px; font-size: 19px; overflow-wrap: anywhere; display: flex; gap: 8px; align-items: center; }
.detail-h h2 > svg { width: 20px; height: 20px; color: var(--accent); flex: none; }
.detail-h .sub { color: var(--muted); font-size: 12.5px; }
.badges { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.btn-row, .action-bar { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.action-bar:empty { display: none; }
.detail-h > .action-bar { margin-left: auto; }
/* selects: use .input (or .field select); .input.auto keeps its natural width in toolbars */
select.input { padding-right: 30px; }
.input.auto { width: auto; min-width: 150px; }
.toolbar .input { min-height: var(--tap); padding-top: 6px; padding-bottom: 6px; }
/* sticky Save/Cancel bar for App.form({sticky:true}) – the edit mode of a record drawer (M2) */
.form.sticky > .form-actions {
  position: sticky; bottom: 0; z-index: 4; padding: 12px 0; margin-top: 4px;
  background: #0f1823; border-top: 1px solid var(--line-soft); box-shadow: 0 -10px 24px rgba(0, 0, 0, .25);
}
.drawer-b:has(.form.sticky) { padding-bottom: 0; }
.drawer-b .form.sticky > .form-actions { margin: 4px -24px 0; padding: 12px 24px 14px; }
.form-intro { font-size: 12.5px; color: var(--muted); }
/* read-only status stepper: App.statusSteps() */
.stepper.static .st-b { cursor: default; }
.stepper.static .st-b .t small { display: block; font-size: 11px; font-weight: 500; color: var(--faint); }
.stepper .st-b .n svg { width: 13px; height: 13px; }
.stepper li.bad .st-b { color: var(--bad-text); border-bottom-color: var(--bad); }
.stepper li.bad .st-b .n { background: var(--bad); color: #fff; }
/* tree inside a split pane (business models): <div class="split split-tree"><div class="split-list card">…tree…</div> */
.split.split-tree { --split-w: minmax(300px, 440px); }
.split-list .tree-host { overflow: auto; min-height: 120px; flex: 1; }
.tree-host.wrap .tree-label { white-space: normal; overflow-wrap: anywhere; }
.tree-host.wrap .tree-row { align-items: flex-start; }
.tree-host.wrap .tree-row > .tree-toggle, .tree-host.wrap .tree-row > .tree-ic { margin-top: 1px; }
/* read-only matrix cells */
.matrix td.mx-ro .badge { font-size: 11px; }
.mx-no { color: var(--faint); }

/* ---------- overflow menu (App.menu) ---------- */
.menu-layer { position: fixed; inset: 0; z-index: 80; }
.menu-bg { position: absolute; inset: 0; }
.menu-pop {
  position: fixed; min-width: 210px; max-width: min(340px, calc(100vw - 16px)); max-height: min(60vh, 440px); overflow: auto; padding: 6px;
  background: var(--surface-2); border: 1px solid var(--line); border-radius: 12px; box-shadow: var(--shadow); animation: tin .12s var(--ease);
}
.menu-i {
  display: flex; align-items: center; gap: 10px; width: 100%; min-height: var(--tap); padding: 7px 10px; border: 0; border-radius: 8px;
  background: none; color: var(--text); font-size: 13px; font-weight: 600; text-align: left; cursor: pointer;
}
.menu-i > span { flex: 1; min-width: 0; }
.menu-i svg { width: 16px; height: 16px; color: var(--muted); flex: none; }
.menu-i small { color: var(--faint); font-weight: 500; font-size: 11.5px; }
.menu-i:hover, .menu-i:focus { background: rgba(255, 255, 255, .07); outline: none; }
.menu-i:focus-visible { box-shadow: inset 0 0 0 2px var(--focus); }
.menu-i.danger { color: var(--bad-text); }
.menu-i.danger svg { color: var(--bad); }
.menu-i.danger:hover, .menu-i.danger:focus { background: rgba(239, 91, 91, .14); }
.menu-i[aria-disabled="true"] { opacity: .5; cursor: not-allowed; }
.menu-sep { height: 1px; margin: 6px 4px; background: var(--line-soft); }

/* ---------- help panel (App.help / App.pageHelp) ---------- */
.help-btn { font-size: 16px; font-weight: 700; }
.help-wrap { position: fixed; inset: 0; z-index: 60; }
.help-bg { position: absolute; inset: 0; background: rgba(4, 8, 12, .45); opacity: 0; transition: opacity .2s; }
.help-panel {
  position: absolute; top: 0; right: 0; bottom: 0; width: min(440px, 100vw); display: flex; flex-direction: column;
  background: linear-gradient(180deg, #121c28 0%, #0e1621 100%); border-left: 1px solid var(--line); box-shadow: -20px 0 50px rgba(0, 0, 0, .5);
  transform: translateX(102%); transition: transform .24s var(--ease);
}
.help-panel:focus { outline: none; }
.help-wrap.open .help-panel { transform: none; }
.help-wrap.open .help-bg { opacity: 1; }
.help-h { display: flex; align-items: center; gap: 10px; padding: 16px 20px; border-bottom: 1px solid var(--line-soft); }
.help-h > svg { width: 20px; height: 20px; color: var(--accent); flex: none; }
.help-h h2 { margin: 0; font-size: 17px; flex: 1; min-width: 0; }
.help-b { padding: 16px 20px 32px; overflow: auto; flex: 1; font-size: 13.5px; line-height: 1.6; color: var(--muted); }
.help-b h3 { margin: 18px 0 6px; font-size: 13px; color: var(--text); }
.help-b h3:first-child { margin-top: 0; }
.help-b p, .help-b ul, .help-b ol { margin: 0 0 10px; }
.help-b ul, .help-b ol { padding-left: 20px; }
.help-b b { color: var(--text); }
.kbd-list { display: grid; grid-template-columns: max-content 1fr; gap: 6px 14px; margin: 0; font-size: 12.5px; }
.kbd-list dt { white-space: nowrap; }
.kbd-list dd { margin: 0; }
kbd { font: 600 11px/1 inherit; color: var(--text); border: 1px solid var(--line-strong); border-bottom-width: 2px; border-radius: 5px; padding: 2px 6px; background: var(--surface-2); }

/* global search start list (recent + quick actions) */
.gs-item.has-ic { display: flex; gap: 10px; align-items: center; }
.gs-item .gs-ic { width: 16px; height: 16px; color: var(--faint); flex: none; }
.gs-item .gs-t { min-width: 0; flex: 1; color: var(--text); font-size: 13px; }
.error-box { padding: 16px; border-radius: var(--radius-sm); background: rgba(239, 91, 91, .1); color: var(--bad-text); border: 1px solid rgba(239, 91, 91, .3); }
.spin { display: inline-block; width: 14px; height: 14px; border: 2px solid var(--line); border-top-color: var(--accent); border-radius: 50%; animation: rot .7s linear infinite; vertical-align: -2px; }
@keyframes rot { to { transform: rotate(360deg); } }


/* ======================================================================== Phone (<= 760 px)
   Bottom tab bar (4 + More), compact top bar, swipeable chips/tabs, 2-up KPI tiles, full-screen sheets,
   44 px touch targets, tables with a pinned first column or stacked cards. */
.bottom-nav, .seg .custom-btn { display: none; }
@media (max-width: 760px) {
  :root { --sidebar: 0px; --navh: 62px; --tap: 44px; }
  html, body { overflow-x: hidden; }
  body { background-attachment: scroll; -webkit-tap-highlight-color: transparent; }
  .sidebar { display: none; }
  .main { margin-left: 0; padding-bottom: calc(var(--navh) + env(safe-area-inset-bottom) + 8px); }

  /* bottom tab bar */
  .bottom-nav {
    display: flex; position: fixed; left: 0; right: 0; bottom: 0; z-index: 35;
    height: calc(var(--navh) + env(safe-area-inset-bottom)); padding: 6px 4px env(safe-area-inset-bottom);
    background: rgba(10, 16, 24, .96); backdrop-filter: blur(14px); border-top: 1px solid var(--line-soft);
  }
  .bottom-nav a, .bottom-nav button {
    flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px; min-width: 0; min-height: 48px;
    color: var(--muted); font-size: 10.5px; font-weight: 600; border-radius: 12px; border: 0; background: none; cursor: pointer; padding: 0;
  }
  .bottom-nav span { max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .bottom-nav svg { width: 22px; height: 22px; }
  .bottom-nav .active { color: var(--accent); }
  .bottom-nav .active svg { filter: drop-shadow(0 0 8px rgba(142, 198, 63, .5)); }
  .bottom-nav a:active, .bottom-nav button:active { background: rgba(255, 255, 255, .05); }

  /* compact top bar */
  .topbar { padding: 8px 12px; gap: 8px; padding-top: calc(8px + env(safe-area-inset-top)); }
  .tb-title { flex: 1; min-width: 0; }
  .topbar h1 { font-size: 17px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .topbar .sub { font-size: 11px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .crumbs ol { flex-wrap: nowrap; overflow: hidden; white-space: nowrap; font-size: 11px; }
  .topbar .spacer { display: none; }
  .tb-actions { order: 5; width: 100%; }
  .tb-actions:empty { display: none; }
  .tb-btn, .me-btn { width: 44px; height: 44px; }
  .gs-open { display: grid !important; }
  .gs-box { display: none; }
  .gsearch { position: static; }
  .gsearch.open .gs-box { display: flex; position: absolute; left: 8px; right: 8px; top: calc(6px + env(safe-area-inset-top)); width: auto; height: 46px; z-index: 4; background: var(--bg-2); padding-right: 2px; }
  .gsearch.open .gs-close { display: grid !important; width: 40px; height: 40px; border: 0; background: none; }
  .gs-box kbd { display: none; }
  .gs-pop { left: 8px; right: 8px; width: auto; top: calc(56px + env(safe-area-inset-top)); }
  .menu-wrap { position: static; }
  .pop { left: 8px; right: 8px; width: auto !important; top: calc(100% + 4px); max-height: calc(100vh - 160px); }
  .np-item { min-height: 44px; }

  /* date range */
  .rangebar { width: 100%; order: 6; flex-wrap: nowrap; }
  .seg { overflow-x: auto; scrollbar-width: none; max-width: 100%; flex-wrap: nowrap; }
  .seg::-webkit-scrollbar { display: none; }
  .seg button { white-space: nowrap; padding: 7px 11px; min-height: 40px; }
  .seg .custom-btn { display: inline-block; }
  .dates { display: none; }
  .rangebar.show-dates { flex-wrap: wrap; }
  .rangebar.show-dates .dates { display: flex; width: 100%; }
  .dates input { flex: 1; min-width: 0; font-size: 16px; }

  /* layout */
  .content { padding: 12px 12px 24px; }
  .grid { gap: 10px; }
  .row-2-1, .row-1-1, .row-1-1-1 { grid-template-columns: minmax(0, 1fr) !important; }
  .card { padding: 14px 12px 12px; border-radius: 12px; }
  .card-h { gap: 4px 10px; }
  .card-h .hint { flex-basis: 100%; order: 3; }
  .chart { height: 260px; }
  .chart.sm { height: 220px; }
  .chart.lg { height: 340px; }

  /* KPI tiles two per row */
  .kpis { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) !important; gap: 8px; margin-bottom: 10px; }
  .kpi { padding: 11px 11px 10px; border-radius: 12px; min-width: 0; }
  .kpi .k-label { font-size: 11px; gap: 6px; }
  .kpi .k-label svg { width: 14px; height: 14px; }
  .kpi .k-value { font-size: 21px; margin: 4px 0 1px; }
  .kpi .k-value small { font-size: 11.5px; }
  .kpi .k-foot { font-size: 10.5px; flex-wrap: wrap; gap: 4px; line-height: 1.3; }
  .kpi::after { width: 70px; height: 70px; right: -20px; top: -20px; }

  /* touch targets */
  .btn, .btn.sm { min-height: 44px; }
  .btn.icon, .btn.sm.icon { width: 44px; }
  .chip { min-height: 40px; padding: 8px 14px; }
  .tabs a, .tabs [data-tab] { min-height: 44px; }
  .pg-b { min-width: 44px; height: 44px; }
  .x { width: 44px; height: 44px; }
  .check, .switch { min-height: 44px; }
  .tree-row { min-height: 44px; }
  .sitem { min-height: 44px; }
  .lk-opt { min-height: 44px; }
  .me-menu > a, .me-menu > button, .mm-co button { min-height: 44px; }
  th.sel, td.sel { width: 48px; }
  th.sel input, td.sel input, .matrix input { width: 22px; height: 22px; }

  /* tabs and chips scroll sideways instead of wrapping */
  .tabs { margin: -2px -12px 12px; padding: 0 12px; }
  .tabs a, .tabs [data-tab] { padding: 10px 12px; font-size: 13px; }
  .toolbar { gap: 8px; }
  .toolbar .end, .toolbar .push { margin-left: 0; }
  .search { min-width: 0; width: 100%; }
  input, select, textarea, .search input { font-size: 16px !important; }   /* 16 px stops iOS zooming into the field */
  .toolbar .chips, .chips.scroll { flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; width: 100%; padding-bottom: 2px; }
  .toolbar .chips::-webkit-scrollbar, .chips.scroll::-webkit-scrollbar { display: none; }

  /* tables: smaller, pinned first column */
  .table-wrap { max-height: 70vh !important; border-radius: 10px; }
  table { font-size: 12.5px; }
  th, td { padding: 8px 9px; }
  td.wrap { min-width: 180px; }
  th:first-child, td:first-child { position: sticky; left: 0; z-index: 1; background: var(--th); }
  th:first-child { z-index: 2; }
  tbody tr:hover { background: transparent; }
  tbody tr.click:active { background: rgba(142, 198, 63, .1); }
  tr.group td:first-child { background: #1a2532; }
  tr.total td:first-child { background: #1d2b22; }
  td.empty:first-child { position: static; background: none; }

  /* table(..., {mobile:'cards'}) – each row becomes a card */
  .t-cards { max-height: none !important; border: 0; overflow: visible; }
  .t-cards table, .t-cards tbody, .t-cards tr, .t-cards td { display: block; width: 100%; }
  .t-cards thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
  .t-cards tbody tr[data-i] { margin-bottom: 8px; padding: 8px 12px; border-radius: 12px; background: var(--surface-2); border: 1px solid var(--line-soft); position: relative; }
  .t-cards tbody tr.selected { background: rgba(142, 198, 63, .08); border-color: rgba(142, 198, 63, .5); }
  .t-cards td { position: static !important; background: none !important; border: 0; padding: 3px 0; white-space: normal; text-align: left !important; display: flex; gap: 10px; justify-content: space-between; }
  .t-cards td::before { content: attr(data-label); color: var(--faint); font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: .4px; flex: none; }
  .t-cards td:first-child:not(.sel), .t-cards td.sel + td { font-size: 14px; font-weight: 600; padding-right: 40px; }
  .t-cards td:first-child:not(.sel)::before, .t-cards td.sel + td::before { display: none; }
  .t-cards td.sel { position: absolute !important; left: auto; right: 6px; top: 4px; width: 44px; height: 44px; padding: 0; display: grid; place-items: center; }
  .t-cards td.sel::before { display: none; }
  .t-cards tfoot { display: none; }

  /* lists, people */
  .people-grid { grid-template-columns: minmax(0, 1fr); gap: 8px; }
  .pcard { min-width: 0; padding: 11px; }
  .pcard .pct { flex: none; }
  .li { padding: 9px 2px; min-height: 44px; }

  /* overlays = full-screen / bottom sheets */
  .drawer, .drawer.wide { width: 100vw; border-left: 0; }
  .drawer-h { padding: 10px 12px; padding-top: calc(10px + env(safe-area-inset-top)); gap: 10px; flex-wrap: wrap; }
  .drawer-h h2 { font-size: 17px; }
  /* S8: title and close button share the first row; only the actions wrap onto the next one */
  .drawer-h > :not(.drawer-actions):not(.x) { flex: 1 1 0; min-width: 0; }
  .drawer-h > .x { order: 2; margin-left: auto; }
  .drawer-actions { order: 3; width: 100%; margin: 0; flex-wrap: wrap; }
  .drawer-actions + .x { margin-left: auto; }
  .drawer-b .form.sticky > .form-actions { margin: 4px -12px 0; padding: 10px 12px calc(10px + env(safe-area-inset-bottom)); }
  .menu-bg { background: rgba(4, 8, 12, .5); }
  .menu-pop { left: 8px !important; right: 8px; top: auto !important; bottom: calc(8px + env(safe-area-inset-bottom)); max-width: none; max-height: 70vh; border-radius: 16px; padding: 8px; }
  .menu-i { min-height: 48px; font-size: 14px; }
  .filters-toggle { display: inline-flex; }
  .filters.collapsible:not(.open) { display: none; }
  .filter-row { flex-direction: column; gap: 4px; }
  .filter-row > .fl { width: auto; padding-top: 0; }
  .filter-row > .chips { width: 100%; flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; }
  .filter-row > .chips > * { flex: none; }
  .filter-selects .field { max-width: none; min-width: 0; flex-basis: calc(50% - 4px); }
  .toolbar > .count { margin-left: 0; width: 100%; }
  .detail-h > .action-bar { margin-left: 0; width: 100%; }
  .stepper.static .st-b .t { display: inline !important; }
  .stepper.static .st-b { flex-direction: column; gap: 4px; padding: 6px 2px; text-align: center; font-size: 11.5px; }
  .input.auto { min-width: 0; flex: 1 1 45%; }
  .help-panel { width: 100vw; }
  .drawer-b { padding: 14px 12px calc(30px + env(safe-area-inset-bottom)); }
  .facts { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 8px; }
  .fact { padding: 8px 10px; min-width: 0; overflow-wrap: anywhere; }
  .photo { width: 60px; height: 60px; }
  .modal-wrap { padding: 0; place-items: end stretch; }
  .modal, .modal.sm, .modal.lg, .modal.sheet { width: 100%; max-height: 92vh; border-radius: 18px 18px 0 0; padding-bottom: env(safe-area-inset-bottom); }
  .modal-f .btn { flex: 1; }
  .toasts { left: 12px; right: 12px; bottom: calc(var(--navh) + 12px + env(safe-area-inset-bottom)); align-items: stretch; }
  .toast { min-width: 0; max-width: none; }

  /* forms */
  .form.cols-2 { grid-template-columns: minmax(0, 1fr); }
  .form-actions .btn { flex: 1; }
  .form-actions .spacer { display: none; }
  .auth .card { padding: 22px 18px 18px; }

  /* components */
  .split { grid-template-columns: minmax(0, 1fr); }
  .split-list { position: static; max-height: none; }
  .split.show-detail .split-list { display: none; }
  .split:not(.show-detail) .split-detail { display: none; }
  .split-back { display: inline-flex; }
  .stepper .st-b .t { display: none; }
  .stepper li.on .st-b .t { display: inline; }
  .mx-hint { display: flex; }
  .matrix th.mx-first { min-width: 150px; }
  .dropzone { padding: 16px; }
  .pv-frame { height: 75vh; }
  .pg-size { margin-left: 0; }
  .bulkbar { left: 8px; right: 8px; bottom: calc(var(--navh) + 8px + env(safe-area-inset-bottom)); padding-left: 12px; }
  html.has-bulkbar .content { padding-bottom: 140px; }
  .split.split-tree { --split-w: minmax(0, 1fr); }
}
