/* ==========================================================================
   Bengkel Kilat — design system
   Workshop-floor industrial: graphite, off-white, safety orange.
   Mobile-first. Light + dark. One accent, honest hairlines, no card soup.
   ========================================================================== */

/* ---------- 1. Tokens ---------------------------------------------------- */
:root {
  /* palette — dark (default) */
  --bg: #0C0E11;
  --bg-elev: #12161B;
  --surface: #151A20;
  --surface-2: #1B2129;
  --surface-3: #232A34;
  --line: #262E38;
  --line-strong: #35404D;
  --ink: #EDF1F5;
  --ink-2: #A8B3C0;
  --ink-3: #6F7B8A;
  --ink-inverse: #0C0E11;

  --accent: #FF5A1F;
  --accent-ink: #1A0B04;
  --accent-soft: rgba(255, 90, 31, 0.14);
  --accent-line: rgba(255, 90, 31, 0.38);

  --cobalt: #5B8CFF;
  --cobalt-soft: rgba(91, 140, 255, 0.14);
  --ok: #37D39A;
  --ok-soft: rgba(55, 211, 154, 0.13);
  --warn: #F5B93D;
  --warn-soft: rgba(245, 185, 61, 0.14);
  --bad: #FF5C6C;
  --bad-soft: rgba(255, 92, 108, 0.14);

  --shadow-1: 0 1px 2px rgba(0, 0, 0, 0.28);
  --shadow-2: 0 8px 24px -12px rgba(0, 0, 0, 0.7), 0 1px 2px rgba(0, 0, 0, 0.4);
  --shadow-3: 0 24px 60px -20px rgba(0, 0, 0, 0.8), 0 2px 8px rgba(0,0,0,.4);

  /* type */
  --font-display: 'Space Grotesk', 'Plus Jakarta Sans', system-ui, sans-serif;
  --font-body: 'Plus Jakarta Sans', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --font-mono: 'JetBrains Mono', ui-monospace, 'SF Mono', Menlo, monospace;

  --fs-xs: 0.6875rem;
  --fs-sm: 0.8125rem;
  --fs-base: 0.9375rem;
  --fs-md: 1.0625rem;
  --fs-lg: 1.3125rem;
  --fs-xl: 1.625rem;
  --fs-2xl: 2.125rem;
  --fs-3xl: clamp(2rem, 8.5vw, 2.75rem);

  /* spacing */
  --s1: 4px;  --s2: 8px;  --s3: 12px; --s4: 16px;
  --s5: 20px; --s6: 24px; --s7: 32px; --s8: 44px; --s9: 64px;

  /* shape */
  --r-xs: 6px; --r-sm: 10px; --r-md: 14px; --r-lg: 20px; --r-xl: 28px; --r-pill: 999px;

  /* metrics */
  --topbar-h: 58px;
  --tabbar-h: 62px;
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-t: env(safe-area-inset-top, 0px);
  --gutter: 18px;
  --maxw: 1280px;

  --ease: cubic-bezier(0.22, 0.61, 0.36, 1);
  --ease-out: cubic-bezier(0.16, 1, 0.3, 1);
  --dur: 200ms;
}

/* light theme */
:root[data-theme='light'] {
  --bg: #F1F0EC;
  --bg-elev: #FAF9F6;
  --surface: #FFFFFF;
  --surface-2: #F5F4F0;
  --surface-3: #EAE8E2;
  --line: #DFDCD4;
  --line-strong: #C4C0B6;
  --ink: #14161A;
  --ink-2: #4E565F;
  --ink-3: #7A838D;
  --ink-inverse: #FFFFFF;

  --accent: #E14A0B;
  --accent-ink: #FFFFFF;
  --accent-soft: rgba(225, 74, 11, 0.10);
  --accent-line: rgba(225, 74, 11, 0.32);

  --cobalt: #2E56C9;
  --cobalt-soft: rgba(46, 86, 201, 0.10);
  --ok: #0E8A5F;
  --ok-soft: rgba(14, 138, 95, 0.10);
  --warn: #A9700A;
  --warn-soft: rgba(169, 112, 10, 0.12);
  --bad: #C43A48;
  --bad-soft: rgba(196, 58, 72, 0.10);

  --shadow-1: 0 1px 2px rgba(20, 22, 26, 0.06);
  --shadow-2: 0 6px 18px -10px rgba(20, 22, 26, 0.28), 0 1px 2px rgba(20, 22, 26, 0.06);
  --shadow-3: 0 24px 50px -24px rgba(20, 22, 26, 0.35), 0 2px 6px rgba(20, 22, 26, 0.08);
}

@media (prefers-color-scheme: light) {
  :root[data-theme='auto'] {
    --bg: #F1F0EC;
    --bg-elev: #FAF9F6;
    --surface: #FFFFFF;
    --surface-2: #F5F4F0;
    --surface-3: #EAE8E2;
    --line: #DFDCD4;
    --line-strong: #C4C0B6;
    --ink: #14161A;
    --ink-2: #4E565F;
    --ink-3: #7A838D;
    --ink-inverse: #FFFFFF;
    --accent: #E14A0B;
    --accent-ink: #FFFFFF;
    --accent-soft: rgba(225, 74, 11, 0.10);
    --accent-line: rgba(225, 74, 11, 0.32);
    --cobalt: #2E56C9;
    --cobalt-soft: rgba(46, 86, 201, 0.10);
    --ok: #0E8A5F;
    --ok-soft: rgba(14, 138, 95, 0.10);
    --warn: #A9700A;
    --warn-soft: rgba(169, 112, 10, 0.12);
    --bad: #C43A48;
    --bad-soft: rgba(196, 58, 72, 0.10);
    --shadow-1: 0 1px 2px rgba(20, 22, 26, 0.06);
    --shadow-2: 0 6px 18px -10px rgba(20, 22, 26, 0.28), 0 1px 2px rgba(20, 22, 26, 0.06);
    --shadow-3: 0 24px 50px -24px rgba(20, 22, 26, 0.35), 0 2px 6px rgba(20, 22, 26, 0.08);
  }
}

/* ---------- 2. Reset ----------------------------------------------------- */
*, *::before, *::after { box-sizing: border-box; }

* { -webkit-tap-highlight-color: transparent; }

html {
  background: var(--bg);
  color-scheme: dark light;
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

:root[data-theme='light'] { color-scheme: light; }

body {
  margin: 0;
  min-height: 100svh;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-body);
  font-size: var(--fs-base);
  line-height: 1.55;
  letter-spacing: -0.005em;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  overscroll-behavior-y: none;
}

h1, h2, h3, h4, p, figure, ul, ol, dl, dd { margin: 0; }
ul, ol { padding: 0; list-style: none; }
button, input, select, textarea { font: inherit; color: inherit; }
button { background: none; border: 0; padding: 0; cursor: pointer; }
button, a, input, select, textarea { touch-action: manipulation; }
a { color: var(--cobalt); text-decoration: none; }
button:focus-visible, a:focus-visible { outline-offset: 3px; }
img, svg, canvas { display: block; max-width: 100%; }
table { border-collapse: collapse; width: 100%; }
[hidden] { display: none !important; }

::selection { background: var(--accent); color: var(--accent-ink); }

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: var(--r-xs);
}

/* scrollbars */
* { scrollbar-width: thin; scrollbar-color: var(--line-strong) transparent; }
*::-webkit-scrollbar { width: 8px; height: 8px; }
*::-webkit-scrollbar-thumb { background: var(--line-strong); border-radius: 99px; }
*::-webkit-scrollbar-track { background: transparent; }

/* ---------- 3. App shell ------------------------------------------------- */
.app {
  min-height: 100svh;
  display: grid;
  grid-template-rows: auto 1fr auto;
}

.topbar {
  min-height: var(--topbar-h);
  position: sticky;
  top: 0;
  z-index: 40;
  padding: calc(var(--safe-t) + 10px) var(--gutter) 10px;
  display: flex;
  align-items: center;
  gap: var(--s3);
  background: color-mix(in srgb, var(--bg) 84%, transparent);
  backdrop-filter: blur(16px) saturate(1.4);
  -webkit-backdrop-filter: blur(16px) saturate(1.4);
  border-bottom: 1px solid transparent;
  transition: border-color var(--dur) var(--ease), background var(--dur) var(--ease);
}
.topbar.is-scrolled { border-bottom-color: var(--line); box-shadow: 0 8px 24px -22px var(--ink); }

.brand { display: flex; align-items: center; gap: 10px; min-width: 0; color: var(--ink); text-align: left; }
.brand:active { transform: scale(0.985); }
.brand-mark {
  width: 34px; height: 34px; border-radius: 10px;
  background: var(--accent);
  display: grid; place-items: center;
  color: var(--accent-ink);
  flex: none;
  box-shadow: 0 6px 16px -8px color-mix(in srgb, var(--accent) 80%, transparent);
}
.brand-mark svg { width: 20px; height: 20px; }
.brand-text { min-width: 0; }
.brand-name {
  font-family: var(--font-display);
  font-size: 1rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  line-height: 1.1;
  white-space: nowrap;
}
.brand-sub {
  font-size: var(--fs-xs);
  color: var(--ink-3);
  letter-spacing: 0.06em;
  text-transform: uppercase;
  font-weight: 600;
  line-height: 1.3;
}

.topbar-spacer { flex: 1; }

.role-chip {
  display: inline-flex; align-items: center; gap: 7px;
  height: 34px; padding: 0 12px 0 10px;
  border-radius: var(--r-pill);
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--ink-2);
  font-size: var(--fs-sm);
  font-weight: 600;
  white-space: nowrap;
  transition: border-color var(--dur) var(--ease), color var(--dur) var(--ease);
}
.role-chip:hover { border-color: var(--line-strong); color: var(--ink); }
.role-chip .dot {
  width: 7px; height: 7px; border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}
.role-chip .chev { color: var(--ink-3); transition: transform var(--dur) var(--ease); }

.view {
  padding: var(--s5) var(--gutter) calc(var(--tabbar-h) + var(--safe-b) + 40px);
  width: 100%;
  max-width: var(--maxw);
  margin: 0 auto;
  outline: none;
}
.view.view-enter { animation: viewIn 220ms var(--ease-out) both; }
@keyframes viewIn { from { opacity: .01; transform: translateY(6px); } to { opacity: 1; transform: none; } }

/* ---------- 4. Tab bar --------------------------------------------------- */
.tabbar {
  position: fixed;
  left: 0; right: 0; bottom: 0;
  z-index: 50;
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: 1fr;
  padding: 6px 8px calc(6px + var(--safe-b));
  background: color-mix(in srgb, var(--bg-elev) 92%, transparent);
  backdrop-filter: blur(20px) saturate(1.5);
  -webkit-backdrop-filter: blur(20px) saturate(1.5);
  border-top: 1px solid var(--line);
}

.tab {
  position: relative;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 3px;
  min-height: 48px;
  border-radius: var(--r-sm);
  color: var(--ink-3);
  font-size: var(--fs-xs);
  font-weight: 600;
  letter-spacing: 0.01em;
  transition: color var(--dur) var(--ease), background var(--dur) var(--ease);
}
.tab svg { width: 21px; height: 21px; }
.tab.is-active { color: var(--ink); }
.tab.is-active::before {
  content: '';
  position: absolute; top: 0; left: 50%; transform: translateX(-50%);
  width: 22px; height: 2.5px; border-radius: 99px;
  background: var(--accent);
}
.tab.is-active svg { color: var(--accent); }
.tab:active { transform: scale(0.96); }
.tab-badge {
  position: absolute;
  top: 2px; left: calc(50% + 8px);
  min-width: 16px; height: 16px;
  padding: 0 4px;
  border-radius: 99px;
  background: var(--accent);
  color: var(--accent-ink);
  font-size: 9px;
  font-weight: 700;
  display: grid; place-items: center;
  font-family: var(--font-mono);
  line-height: 1;
}

/* ---------- 5. Typography ------------------------------------------------ */
.h1, .h2, .h3, .h4 {
  font-family: var(--font-display);
  font-weight: 700;
  letter-spacing: -0.025em;
  line-height: 1.12;
  text-wrap: balance;
  color: var(--ink);
}
.h1 { font-size: var(--fs-2xl); }
.h2 { font-size: var(--fs-xl); }
.h3 { font-size: var(--fs-lg); letter-spacing: -0.015em; line-height: 1.22; }
.h4 { font-size: var(--fs-md); letter-spacing: -0.01em; line-height: 1.3; }

.eyebrow {
  font-family: var(--font-mono);
  font-size: var(--fs-xs);
  font-weight: 500;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--ink-3);
}
.muted { color: var(--ink-2); }
.dim { color: var(--ink-3); }
.mono { font-family: var(--font-mono); font-variant-numeric: tabular-nums; letter-spacing: -0.01em; }
.num { font-family: var(--font-mono); font-variant-numeric: tabular-nums; letter-spacing: -0.03em; }
.strong { font-weight: 600; color: var(--ink); }
.small { font-size: var(--fs-sm); }
.tiny { font-size: var(--fs-xs); }
.measure { max-width: 62ch; }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.text-right { text-align: right; }

.lead { font-size: var(--fs-md); line-height: 1.5; color: var(--ink-2); }

/* ---------- 6. Layout primitives ----------------------------------------- */
.stack { display: flex; flex-direction: column; }
.stack-1 { gap: var(--s1); } .stack-2 { gap: var(--s2); } .stack-3 { gap: var(--s3); }
.stack-4 { gap: var(--s4); } .stack-5 { gap: var(--s5); } .stack-6 { gap: var(--s6); }
.stack-7 { gap: var(--s7); }
.row { display: flex; align-items: center; }
.row-2 { gap: var(--s2); } .row-3 { gap: var(--s3); } .row-4 { gap: var(--s4); }
.wrap { flex-wrap: wrap; }
.between { justify-content: space-between; }
.center { justify-content: center; }
.grow { flex: 1; min-width: 0; }
.grid { display: grid; gap: var(--s4); }
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.mt-2 { margin-top: var(--s2); } .mt-3 { margin-top: var(--s3); }
.mt-4 { margin-top: var(--s4); } .mt-5 { margin-top: var(--s5); }
.mt-6 { margin-top: var(--s6); } .mt-7 { margin-top: var(--s7); }
.mb-3 { margin-bottom: var(--s3); } .mb-4 { margin-bottom: var(--s4); }

.divider { height: 1px; background: var(--line); border: 0; margin: var(--s4) 0; }
.divider-dashed { height: 1px; border-top: 1px dashed var(--line-strong); margin: var(--s4) 0; }

/* ---------- 7. Sections -------------------------------------------------- */
.section { margin-top: var(--s7); }
.section:first-child { margin-top: 0; }
.section-head {
  display: flex; align-items: baseline; justify-content: space-between;
  min-height: 24px;
  gap: var(--s3); margin-bottom: var(--s3);
}
.section-title {
  font-family: var(--font-display);
  font-size: var(--fs-md);
  font-weight: 600;
  letter-spacing: -0.015em;
}
.section-link {
  font-size: var(--fs-sm); font-weight: 600; color: var(--ink-3);
  display: inline-flex; align-items: center; gap: 4px;
}
.section-link:hover { color: var(--accent); }

/* ---------- 8. Cards ----------------------------------------------------- */
.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  box-shadow: var(--shadow-1);
}
.card-pad { padding: var(--s4); }
.card-pad-lg { padding: var(--s5); }
.card-flush { overflow: hidden; }

.card-hero {
  background:
    radial-gradient(120% 140% at 100% 0%, var(--accent-soft) 0%, transparent 58%),
    var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  padding: var(--s5);
  position: relative;
  overflow: hidden;
}
.card-hero::before {
  content: '';
  position: absolute;
  left: 0; top: 20px; bottom: 20px;
  width: 3px;
  border-radius: 0 99px 99px 0;
  background: var(--accent);
  opacity: .9;
}
.card-hero::after {
  content: '';
  position: absolute; inset: 0;
  background-image: linear-gradient(var(--line) 1px, transparent 1px);
  background-size: 100% 26px;
  opacity: 0.16;
  pointer-events: none;
  mask-image: linear-gradient(to bottom, black, transparent 70%);
  -webkit-mask-image: linear-gradient(to bottom, black, transparent 70%);
}

.panel {
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
  padding: var(--s3) var(--s4);
  transition: background var(--dur) var(--ease), border-color var(--dur) var(--ease), transform 140ms var(--ease-out), box-shadow var(--dur) var(--ease);
}
.panel:hover { border-color: var(--line-strong); background: var(--surface); }
.panel:active { transform: scale(0.985); }
button.panel, a.panel { cursor: pointer; }

/* ---------- 9. Buttons --------------------------------------------------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center;
  gap: 8px;
  min-height: 44px;
  padding: 0 16px;
  border-radius: var(--r-sm);
  border: 1px solid var(--line-strong);
  background: var(--surface-2);
  color: var(--ink);
  font-size: var(--fs-base);
  font-weight: 600;
  letter-spacing: -0.01em;
  cursor: pointer;
  transition: transform 120ms var(--ease), background var(--dur) var(--ease),
              border-color var(--dur) var(--ease), box-shadow var(--dur) var(--ease), opacity var(--dur);
  user-select: none;
  white-space: nowrap;
}
.btn svg { width: 18px; height: 18px; flex: none; }
.btn:hover { border-color: color-mix(in srgb, var(--line-strong) 60%, var(--ink-3)); }
.btn:active { transform: scale(0.975); }
.btn:focus-visible { box-shadow: 0 0 0 3px var(--accent-soft); }
.btn-primary:focus-visible { box-shadow: 0 0 0 3px var(--accent-soft), 0 8px 20px -12px color-mix(in srgb, var(--accent) 90%, transparent); }
.btn[disabled] { opacity: 0.45; pointer-events: none; }

.btn-primary {
  background: var(--accent);
  border-color: transparent;
  color: var(--accent-ink);
  box-shadow: 0 8px 20px -12px color-mix(in srgb, var(--accent) 90%, transparent);
}
.btn-primary:hover { background: color-mix(in srgb, var(--accent) 88%, white 12%); }

.btn-ghost {
  background: transparent;
  border-color: transparent;
  color: var(--ink-2);
}
.btn-ghost:hover { background: var(--surface-2); color: var(--ink); }

.btn-outline { background: transparent; border-color: var(--line-strong); }
.btn-danger { color: var(--bad); border-color: color-mix(in srgb, var(--bad) 40%, transparent); background: var(--bad-soft); }
.btn-ok { color: var(--ok); border-color: color-mix(in srgb, var(--ok) 40%, transparent); background: var(--ok-soft); }

.btn-sm { min-height: 34px; padding: 0 12px; font-size: var(--fs-sm); border-radius: var(--r-xs); }
.btn-sm svg { width: 15px; height: 15px; }
.btn-lg { min-height: 52px; padding: 0 22px; font-size: var(--fs-md); border-radius: var(--r-md); }
.btn-block { width: 100%; }
.btn-icon { width: 40px; min-height: 40px; padding: 0; border-radius: var(--r-sm); }

.btn-row { display: flex; gap: var(--s2); }
.btn-row > .btn { flex: 1; }

.fab {
  position: fixed;
  right: var(--gutter);
  bottom: calc(var(--tabbar-h) + var(--safe-b) + 16px);
  z-index: 45;
  width: 56px; height: 56px;
  border-radius: 18px;
  background: var(--accent);
  color: var(--accent-ink);
  display: grid; place-items: center;
  box-shadow: 0 16px 32px -14px color-mix(in srgb, var(--accent) 85%, transparent), var(--shadow-2);
  transition: transform 160ms var(--ease-out);
}
.fab:active { transform: scale(0.94); }
.fab svg { width: 26px; height: 26px; }

/* ---------- 10. Chips / badges ------------------------------------------- */
.chip {
  display: inline-flex; align-items: center; gap: 6px;
  min-height: 32px;
  padding: 0 12px;
  border-radius: var(--r-pill);
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--ink-2);
  font-size: var(--fs-sm);
  font-weight: 600;
  white-space: nowrap;
  transition: all var(--dur) var(--ease);
}
.chip:hover { border-color: var(--line-strong); color: var(--ink); }
.chip.is-active {
  background: var(--ink);
  border-color: var(--ink);
  color: var(--bg);
}
.chip .count {
  font-family: var(--font-mono);
  font-size: var(--fs-xs);
  opacity: 0.7;
}

.chipbar {
  display: flex;
  gap: var(--s2);
  overflow-x: auto;
  scrollbar-width: none;
  padding-bottom: 2px;
  margin-inline: calc(var(--gutter) * -1);
  padding-inline: var(--gutter);
  scroll-snap-type: x proximity;
}
.chipbar::-webkit-scrollbar { display: none; }
.chipbar > * { scroll-snap-align: start; flex: none; }

.badge {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 3px 9px;
  border-radius: var(--r-pill);
  font-size: var(--fs-xs);
  font-weight: 700;
  letter-spacing: 0.015em;
  white-space: nowrap;
  border: 1px solid transparent;
}
.badge .bdot { width: 5px; height: 5px; border-radius: 50%; background: currentColor; }
.badge-accent { background: var(--accent-soft); color: var(--accent); border-color: var(--accent-line); }
.badge-ok { background: var(--ok-soft); color: var(--ok); border-color: color-mix(in srgb, var(--ok) 30%, transparent); }
.badge-warn { background: var(--warn-soft); color: var(--warn); border-color: color-mix(in srgb, var(--warn) 30%, transparent); }
.badge-bad { background: var(--bad-soft); color: var(--bad); border-color: color-mix(in srgb, var(--bad) 30%, transparent); }
.badge-info { background: var(--cobalt-soft); color: var(--cobalt); border-color: color-mix(in srgb, var(--cobalt) 28%, transparent); }
.badge-neutral { background: var(--surface-2); color: var(--ink-2); border-color: var(--line); }

.tag {
  display: inline-flex; align-items: center;
  padding: 2px 8px;
  border-radius: var(--r-xs);
  background: var(--surface-2);
  border: 1px solid var(--line);
  color: var(--ink-2);
  font-size: var(--fs-xs);
  font-weight: 600;
}

/* ---------- 11. Progress / meters ---------------------------------------- */
.meter {
  height: 6px;
  border-radius: 99px;
  background: var(--surface-3);
  overflow: hidden;
}
.meter > i {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: var(--accent);
  transition: width 420ms var(--ease-out);
}
.meter-ok > i { background: var(--ok); }
.meter-warn > i { background: var(--warn); }
.meter-bad > i { background: var(--bad); }

.meter-row { display: flex; align-items: center; gap: var(--s3); }
.meter-row .meter { flex: 1; }
.meter-val { font-family: var(--font-mono); font-size: var(--fs-xs); color: var(--ink-2); min-width: 42px; text-align: right; }

/* ---------- 12. KPI tiles ------------------------------------------------ */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1px;
  background: var(--line);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  overflow: hidden;
}
.kpi {
  background: var(--surface);
  padding: var(--s4);
  display: flex; flex-direction: column; gap: 2px;
  min-height: 92px;
  position: relative;
  transition: background var(--dur) var(--ease), transform 140ms var(--ease-out);
}
.kpi:hover { background: var(--surface-2); }
.kpi:active { transform: scale(.985); }
.kpi-label {
  font-size: var(--fs-xs);
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--ink-3);
  display: flex; align-items: center; gap: 5px;
}
.kpi-val {
  font-family: var(--font-display);
  font-size: 1.75rem;
  font-weight: 700;
  letter-spacing: -0.035em;
  line-height: 1.1;
  color: var(--ink);
  font-variant-numeric: tabular-nums;
  display: flex; align-items: baseline; gap: 4px;
}
.kpi-val .unit { font-size: var(--fs-sm); font-weight: 600; color: var(--ink-3); letter-spacing: 0; }
.kpi-foot { font-size: var(--fs-xs); color: var(--ink-3); display: flex; align-items: center; gap: 4px; }
.kpi-accent .kpi-val { color: var(--accent); }
.kpi-ok .kpi-val { color: var(--ok); }
.kpi-bad .kpi-val { color: var(--bad); }

.trend { display: inline-flex; align-items: center; gap: 2px; font-weight: 700; }
.trend-up { color: var(--ok); }
.trend-down { color: var(--bad); }

/* ---------- 13. Lists ---------------------------------------------------- */
.list { display: flex; flex-direction: column; }
.list-item {
  display: flex; align-items: center; gap: var(--s3);
  min-height: 60px;
  padding: var(--s3) var(--s4);
  border-bottom: 1px solid var(--line);
  text-align: left;
  width: 100%;
  color: inherit;
  transition: background var(--dur) var(--ease);
  position: relative;
}
.list-item:last-child { border-bottom: 0; }
.list-item:hover { background: var(--surface-2); }
.list-item:active { background: var(--surface-3); transform: scale(0.995); }
.list-item:focus-visible { z-index: 1; box-shadow: inset 0 0 0 2px var(--accent); }
.list-title { font-weight: 600; letter-spacing: -0.01em; display: flex; align-items: center; gap: 6px; }
.list-sub { font-size: var(--fs-sm); color: var(--ink-3); }
.list-chev { color: var(--ink-3); flex: none; }
.list-chev svg { width: 18px; height: 18px; }

.avatar {
  width: 38px; height: 38px; border-radius: 12px;
  display: grid; place-items: center;
  font-family: var(--font-display);
  font-size: var(--fs-sm);
  font-weight: 700;
  background: var(--surface-3);
  color: var(--ink-2);
  flex: none;
  letter-spacing: 0;
}
.avatar-accent { background: var(--accent-soft); color: var(--accent); }
.avatar-lg { width: 52px; height: 52px; border-radius: 16px; font-size: var(--fs-md); }
.avatar-sm { width: 28px; height: 28px; border-radius: 9px; font-size: var(--fs-xs); }

/* plate */
.plate {
  display: inline-flex; align-items: center;
  font-family: var(--font-mono);
  font-weight: 600;
  font-size: var(--fs-sm);
  letter-spacing: 0.04em;
  padding: 3px 8px;
  border-radius: var(--r-xs);
  background: var(--surface-3);
  color: var(--ink);
  border: 1px solid var(--line-strong);
  white-space: nowrap;
}
.plate-lg { font-size: var(--fs-md); padding: 5px 11px; letter-spacing: 0.06em; }

/* ---------- 14. Stage pipeline ------------------------------------------- */
.pipeline { display: flex; flex-direction: column; gap: 0; }
.stage {
  display: grid;
  grid-template-columns: 26px 1fr;
  gap: var(--s3);
  position: relative;
  padding-bottom: var(--s4);
}
.stage:last-child { padding-bottom: 0; }
.stage::before {
  content: '';
  position: absolute;
  left: 12px; top: 22px; bottom: -2px;
  width: 2px;
  background: var(--line);
}
.stage:last-child::before { display: none; }
.stage.is-done::before { background: color-mix(in srgb, var(--ok) 55%, var(--line)); }

.stage-dot {
  width: 26px; height: 26px;
  border-radius: 50%;
  border: 2px solid var(--line-strong);
  background: var(--bg);
  display: grid; place-items: center;
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: 600;
  color: var(--ink-3);
  position: relative;
  z-index: 1;
  flex: none;
}
.stage.is-done .stage-dot { border-color: var(--ok); background: var(--ok-soft); color: var(--ok); }
.stage.is-current .stage-dot {
  border-color: var(--accent);
  background: var(--accent);
  color: var(--accent-ink);
  box-shadow: 0 0 0 4px var(--accent-soft);
}
.stage.is-current .stage-dot::after {
  content: '';
  position: absolute; inset: -7px;
  border-radius: 50%;
  border: 1.5px solid var(--accent-line);
  animation: pulse 2.4s var(--ease) infinite;
}
@keyframes pulse {
  0% { transform: scale(0.85); opacity: 0.9; }
  70% { transform: scale(1.25); opacity: 0; }
  100% { opacity: 0; }
}
.stage-body { min-width: 0; padding-top: 1px; }
.stage-name { font-weight: 600; font-size: var(--fs-base); letter-spacing: -0.01em; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.stage-meta { font-size: var(--fs-xs); color: var(--ink-3); margin-top: 2px; }
.stage.is-current .stage-name { color: var(--accent); }
.stage.is-todo .stage-name { color: var(--ink-2); }

/* horizontal mini rail */
.rail { display: flex; gap: 4px; }
.rail > i {
  height: 4px; flex: 1; border-radius: 99px;
  background: var(--surface-3);
  transition: background var(--dur) var(--ease);
}
.rail > i.done { background: var(--ok); }
.rail > i.now { background: var(--accent); }

/* ---------- 15. Forms ---------------------------------------------------- */
.field { display: flex; flex-direction: column; gap: 6px; }
.label {
  font-size: var(--fs-xs);
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--ink-3);
}
.input, .select, .textarea {
  width: 100%;
  min-height: 46px;
  padding: 11px 13px;
  border-radius: var(--r-sm);
  border: 1px solid var(--line-strong);
  background: var(--bg-elev);
  color: var(--ink);
  font-size: 16px; /* prevents iOS zoom */
  transition: border-color var(--dur) var(--ease), background var(--dur) var(--ease), box-shadow var(--dur) var(--ease);
  appearance: none;
}
.textarea { min-height: 88px; resize: vertical; line-height: 1.5; font-family: inherit; }
.input::placeholder, .textarea::placeholder { color: var(--ink-3); }
.input:hover, .select:hover, .textarea:hover { border-color: color-mix(in srgb, var(--line-strong) 75%, var(--ink-3)); }
.input:focus, .select:focus, .textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
  background: var(--surface);
}
.select {
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%236F7B8A' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'><path d='M6 9l6 6 6-6'/></svg>");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 36px;
}
.input-group { position: relative; }
.input-group .input { padding-left: 40px; }
.input-group svg {
  position: absolute; left: 13px; top: 50%; transform: translateY(-50%);
  width: 17px; height: 17px; color: var(--ink-3); pointer-events: none;
}
.input-prefix {
  position: absolute; left: 13px; top: 50%; transform: translateY(-50%);
  font-family: var(--font-mono); font-size: var(--fs-sm); color: var(--ink-3);
  pointer-events: none;
}

.form-grid { display: grid; gap: var(--s3); }
.field-row { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--s3); }

.switch {
  display: flex; align-items: center; justify-content: space-between;
  gap: var(--s4); min-height: 48px; width: 100%; text-align: left;
}
.switch-track {
  width: 44px; height: 26px; border-radius: 99px;
  background: var(--surface-3); border: 1px solid var(--line-strong);
  position: relative; flex: none;
  transition: background var(--dur) var(--ease), border-color var(--dur) var(--ease);
}
.switch-track::after {
  content: ''; position: absolute; top: 2px; left: 2px;
  width: 20px; height: 20px; border-radius: 50%;
  background: var(--ink-2);
  transition: transform var(--dur) var(--ease), background var(--dur) var(--ease);
}
.switch[aria-checked='true'] .switch-track { background: var(--accent); border-color: var(--accent); }
.switch[aria-checked='true'] .switch-track::after { transform: translateX(18px); background: var(--accent-ink); }

/* segmented control */
.segmented {
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: 1fr;
  gap: 2px;
  padding: 3px;
  border-radius: var(--r-sm);
  background: var(--surface-2);
  border: 1px solid var(--line);
}
.segmented button {
  min-height: 36px;
  border-radius: calc(var(--r-sm) - 3px);
  font-size: var(--fs-sm);
  font-weight: 600;
  color: var(--ink-3);
  transition: background var(--dur) var(--ease), color var(--dur) var(--ease), box-shadow var(--dur) var(--ease);
}
.segmented button.is-active {
  background: var(--surface);
  color: var(--ink);
  box-shadow: var(--shadow-1);
}

/* ---------- 16. Sheet / modal -------------------------------------------- */
.sheet-root { position: fixed; inset: 0; z-index: 100; pointer-events: none; }
.sheet-backdrop {
  position: absolute; inset: 0;
  background: rgba(0, 0, 0, 0.55);
  opacity: 0;
  transition: opacity var(--dur) var(--ease);
  pointer-events: auto;
  backdrop-filter: blur(2px);
}
.sheet {
  overscroll-behavior: contain;
  position: absolute;
  left: 0; right: 0; bottom: 0;
  max-height: 92svh;
  display: flex; flex-direction: column;
  background: var(--bg-elev);
  border-radius: var(--r-xl) var(--r-xl) 0 0;
  border-top: 1px solid var(--line);
  box-shadow: var(--shadow-3);
  transform: translateY(100%);
  transition: transform 320ms var(--ease-out);
  pointer-events: auto;
  padding-bottom: var(--safe-b);
}
.sheet.is-open .sheet-backdrop { opacity: 1; }
.sheet.is-open { transform: none; }
.sheet:not(.is-open) { pointer-events: none; }
.sheet::before {
  content: '';
  width: 38px; height: 4px; border-radius: 99px;
  background: var(--line-strong);
  margin: 10px auto 4px;
  flex: none;
}
.sheet-head {
  display: flex; align-items: flex-start; gap: var(--s3);
  padding: var(--s2) var(--s5) var(--s3);
  flex: none;
  position: sticky;
  top: 0;
  z-index: 2;
  background: var(--bg-elev);
}
.sheet-title { font-family: var(--font-display); font-size: var(--fs-lg); font-weight: 700; letter-spacing: -0.02em; }
.sheet-sub { font-size: var(--fs-sm); color: var(--ink-3); margin-top: 2px; }
.sheet-close {
  width: 34px; height: 34px; border-radius: 50%;
  display: grid; place-items: center;
  background: var(--surface-2); color: var(--ink-2); flex: none;
  margin-left: auto;
}
.sheet-close svg { width: 18px; height: 18px; }
.sheet-body {
  padding: 0 var(--s5) var(--s5);
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  flex: 1;
}
.sheet-foot {
  padding: var(--s3) var(--s5) var(--s4);
  border-top: 1px solid var(--line);
  background: var(--bg-elev);
  box-shadow: 0 -12px 24px -24px var(--ink);
  flex: none;
  display: flex; gap: var(--s2);
}
.sheet-foot .btn { flex: 1; }

/* ---------- 17. Toasts --------------------------------------------------- */
.toast-root {
  position: fixed;
  left: 50%; transform: translateX(-50%);
  bottom: calc(var(--tabbar-h) + var(--safe-b) + 18px);
  z-index: 200;
  display: flex; flex-direction: column; gap: 8px;
  align-items: center;
  pointer-events: none;
  width: min(92vw, 420px);
}
.toast {
  display: flex; align-items: center; gap: 10px;
  padding: 11px 16px;
  border-radius: var(--r-pill);
  background: var(--ink);
  color: var(--bg);
  font-size: var(--fs-sm);
  font-weight: 600;
  box-shadow: var(--shadow-3);
  animation: toastIn 260ms var(--ease-out);
  max-width: 100%;
}
.toast svg { width: 17px; height: 17px; flex: none; }
.toast.is-out { animation: toastOut 220ms var(--ease) forwards; }
.toast-ok svg { color: var(--ok); }
.toast-bad svg { color: var(--bad); }
.toast-warn svg { color: var(--warn); }
@keyframes toastIn { from { opacity: 0; transform: translateY(12px) scale(0.96); } to { opacity: 1; transform: none; } }
@keyframes toastOut { to { opacity: 0; transform: translateY(8px) scale(0.97); } }

/* ---------- 18. Empty state ---------------------------------------------- */
.empty {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  text-align: center;
  padding: var(--s8) var(--s5);
  gap: var(--s3);
  border: 1px dashed var(--line-strong);
  border-radius: var(--r-md);
  background: color-mix(in srgb, var(--surface) 55%, transparent);
}
.empty-icon {
  width: 48px; height: 48px; border-radius: 14px;
  display: grid; place-items: center;
  background: var(--surface-2); color: var(--ink-3);
  border: 1px solid var(--line);
}
.empty-icon svg { width: 22px; height: 22px; }
.empty-title { font-family: var(--font-display); font-weight: 600; font-size: var(--fs-md); }
.empty-text { font-size: var(--fs-sm); color: var(--ink-3); max-width: 34ch; line-height: 1.5; }
.empty .btn { margin-top: var(--s2); }

/* skeleton */
.skel {
  border-radius: var(--r-sm);
  background: linear-gradient(100deg, var(--surface-2) 30%, var(--surface-3) 50%, var(--surface-2) 70%);
  background-size: 220% 100%;
  animation: shimmer 1.3s linear infinite;
}
@keyframes shimmer { from { background-position: 140% 0; } to { background-position: -40% 0; } }

/* ---------- 19. Charts --------------------------------------------------- */
.chart-wrap { width: 100%; overflow: hidden; }
.chart-wrap svg { width: 100%; height: auto; overflow: visible; }
.chart-legend { display: flex; flex-wrap: wrap; gap: var(--s3); font-size: var(--fs-xs); color: var(--ink-3); }
.chart-legend i { width: 9px; height: 9px; border-radius: 3px; display: inline-block; margin-right: 5px; }

.activity-feed { display: flex; flex-direction: column; }
.activity-item { display: flex; align-items: center; gap: 10px; min-height: 48px; width: 100%; text-align: left; border-bottom: 1px solid var(--line); }
.activity-item:last-child { border-bottom: 0; }
.activity-item:hover .strong { color: var(--accent); }
.activity-dot { width: 8px; height: 8px; flex: none; border-radius: 50%; background: var(--accent); box-shadow: 0 0 0 4px var(--accent-soft); }
.storage-ring { width: 132px; height: 132px; margin-inline: auto; border-radius: 50%; display: grid; place-items: center; background: conic-gradient(var(--accent) 0 72%, var(--surface-3) 72% 100%); position: relative; }
.storage-ring::after { content: ''; position: absolute; inset: 11px; border-radius: 50%; background: var(--surface); }
.storage-ring > div { position: relative; z-index: 1; display: grid; text-align: center; }
.storage-ring strong { font-family: var(--font-display); font-size: 1.7rem; line-height: 1; }
.storage-ring span { color: var(--ink-3); font-size: var(--fs-xs); margin-top: 5px; }
.bar-row { display: grid; grid-template-columns: 1fr auto; gap: 2px var(--s3); align-items: center; padding: 7px 0; }
.bar-row .bar-label { font-size: var(--fs-sm); color: var(--ink-2); display: flex; align-items: center; gap: 6px; }
.bar-row .bar-val { font-family: var(--font-mono); font-size: var(--fs-xs); color: var(--ink-2); }

.spark { display: flex; align-items: flex-end; gap: 3px; height: 32px; }
.spark i { flex: 1; background: var(--surface-3); border-radius: 2px 2px 0 0; min-height: 3px; }
.spark i.on { background: var(--accent); }

/* ---------- 20. Stars ---------------------------------------------------- */
.stars { display: inline-flex; gap: 2px; color: var(--warn); }
.stars svg { width: 15px; height: 15px; }
.stars .off { color: var(--surface-3); }
.rating-input { display: flex; gap: 6px; }
.rating-input button {
  width: 44px; height: 44px;
  display: grid; place-items: center;
  color: var(--surface-3);
  transition: color 150ms var(--ease), transform 150ms var(--ease-out);
}
.rating-input button svg { width: 30px; height: 30px; }
.rating-input button.on { color: var(--warn); }
.rating-input button:active { transform: scale(0.9); }

/* ---------- 21. Timeline / activity -------------------------------------- */
.timeline { display: flex; flex-direction: column; }
.tl-item {
  display: grid; grid-template-columns: 14px 1fr; gap: var(--s3);
  padding-bottom: var(--s4);
  position: relative;
}
.tl-item:last-child { padding-bottom: 0; }
.tl-item::before {
  content: ''; position: absolute; left: 6px; top: 14px; bottom: 0;
  width: 1px; background: var(--line);
}
.tl-item:last-child::before { display: none; }
.tl-dot { width: 13px; height: 13px; border-radius: 50%; border: 2px solid var(--line-strong); background: var(--bg); margin-top: 3px; }
.tl-item.accent .tl-dot { border-color: var(--accent); background: var(--accent); }
.tl-body { min-width: 0; }
.tl-text { font-size: var(--fs-sm); line-height: 1.45; }
.tl-time { font-size: var(--fs-xs); color: var(--ink-3); font-family: var(--font-mono); }

/* ---------- 22. Calendar heatmap ----------------------------------------- */
.cal { display: grid; grid-template-columns: repeat(7, 1fr); gap: 5px; }
.cal-dow {
  text-align: center;
  font-size: 10px;
  font-weight: 700;
  color: var(--ink-3);
  padding-bottom: 2px;
  letter-spacing: 0.06em;
}
.cal-cell {
  aspect-ratio: 1;
  border-radius: 7px;
  background: var(--surface-2);
  border: 1px solid transparent;
  display: grid; place-items: center;
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--ink-3);
  position: relative;
}
.cal-cell.lvl-1 { background: color-mix(in srgb, var(--ok) 22%, var(--surface-2)); color: var(--ink-2); }
.cal-cell.lvl-2 { background: color-mix(in srgb, var(--ok) 55%, var(--surface-2)); color: var(--ink-inverse); }
.cal-cell.lvl-3 { background: var(--ok); color: var(--ink-inverse); font-weight: 600; }
.cal-cell.lvl-late { background: var(--warn-soft); border-color: color-mix(in srgb, var(--warn) 40%, transparent); color: var(--warn); }
.cal-cell.lvl-off { background: transparent; border: 1px dashed var(--line); color: var(--ink-3); }
.cal-cell.is-today { box-shadow: 0 0 0 1.5px var(--accent); }
.cal-cell.is-future { opacity: 0.35; }

/* ---------- 23. Invoice / print ------------------------------------------ */
.inv-sheet {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  padding: var(--s5);
}
.inv-header { display: flex; justify-content: space-between; gap: var(--s4); align-items: flex-start; }
.inv-no { font-family: var(--font-mono); font-size: var(--fs-sm); color: var(--ink-2); }
.inv-table th {
  text-align: left;
  font-size: var(--fs-xs);
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--ink-3);
  padding: 0 0 8px;
  border-bottom: 1px solid var(--line-strong);
}
.inv-table th.r, .inv-table td.r { text-align: right; }
.inv-table td {
  padding: 11px 0;
  border-bottom: 1px solid var(--line);
  font-size: var(--fs-sm);
  vertical-align: top;
}
.inv-table tfoot td { border-bottom: 0; padding: 6px 0; }
.inv-table tfoot tr.total td {
  border-top: 1px solid var(--line-strong);
  padding-top: 12px;
  font-family: var(--font-display);
  font-size: var(--fs-md);
  font-weight: 700;
}
.inv-item-name { font-weight: 600; }
.inv-item-kind { font-size: var(--fs-xs); color: var(--ink-3); }

/* ---------- 24. Photo grid ----------------------------------------------- */
.photo-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; }
.photo-tile {
  position: relative;
  aspect-ratio: 1;
  transition: transform 140ms var(--ease-out), border-color var(--dur) var(--ease);
  border-radius: var(--r-sm);
  overflow: hidden;
  background: var(--surface-2);
  border: 1px solid var(--line);
  display: grid; place-items: center;
}
.photo-tile:active { transform: scale(.97); }
.photo-tile img { width: 100%; height: 100%; object-fit: cover; }
.photo-tile .ph-label {
  position: absolute; left: 4px; bottom: 4px;
  padding: 1px 6px; border-radius: 4px;
  background: rgba(0,0,0,0.62);
  color: #fff; font-size: 9px; font-weight: 700;
  letter-spacing: 0.03em; text-transform: uppercase;
}
.photo-add {
  border: 1px dashed var(--line-strong);
  background: transparent;
  color: var(--ink-3);
  gap: 4px;
  font-size: var(--fs-xs);
  font-weight: 600;
}
.photo-add svg { width: 20px; height: 20px; }

/* ---------- 25. Utility -------------------------------------------------- */
.sr-only {
  position: absolute; width: 1px; height: 1px;
  padding: 0; margin: -1px; overflow: hidden;
  clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}
.pill-row { display: flex; flex-wrap: wrap; gap: 6px; }
.scroll-x { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.no-scroll-x { overflow-x: hidden; }
.hide-sm { display: none; }
.show-sm { display: initial; }
.mobile-only { display: initial; }
.desktop-only { display: none; }
.tap-none { pointer-events: none; }
.pos-rel { position: relative; }
.hairline-top { border-top: 1px solid var(--line); }
.hairline-bottom { border-bottom: 1px solid var(--line); }
.text-accent { color: var(--accent); }
.text-ok { color: var(--ok); }
.text-bad { color: var(--bad); }
.text-warn { color: var(--warn); }
.strike { text-decoration: line-through; opacity: 0.6; }
.nowrap { white-space: nowrap; }
.tabular { font-variant-numeric: tabular-nums; }

/* ---------- 26. Desktop -------------------------------------------------- */
@media (max-width: 379px) {
  :root { --gutter: 14px; }
  .kpi-grid { grid-template-columns: 1fr; }
  .role-chip { padding-inline: 9px; font-size: var(--fs-xs); }
}

@media (min-width: 760px) {
  :root { --gutter: 32px; --fs-base: 0.9375rem; }
  .mobile-only { display: none; }
  .desktop-only { display: initial; }
  .view { padding-top: var(--s6); }
  .kpi-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .kpi { min-height: 104px; }
  .kpi-val { font-size: 2rem; }
  .hide-sm { display: initial; }
  .grid-md-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .grid-md-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .grid-md-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .photo-grid { grid-template-columns: repeat(4, 1fr); }
  .toast-root { bottom: 28px; }
  .fab { bottom: 28px; }

  /* desktop: tab bar becomes a left rail */
  .tabbar {
    position: fixed;
    top: 0; bottom: 0; left: 0; right: auto;
    width: 232px;
    grid-auto-flow: row;
    grid-auto-columns: auto;
    grid-auto-rows: min-content;
    align-content: start;
    padding: calc(var(--safe-t) + 20px) 14px 20px;
    gap: 4px;
    border-top: 0;
    border-right: 1px solid var(--line);
  }
  .tab {
    flex-direction: row;
    justify-content: flex-start;
    gap: 11px;
    padding: 0 12px;
    height: 44px;
    min-height: 44px;
    font-size: var(--fs-sm);
    border-radius: var(--r-sm);
  }
  .tab.is-active { background: var(--surface-2); }
  .tab.is-active::before {
    top: 50%; left: 0; transform: translateY(-50%) translateX(-14px);
    width: 3px; height: 20px;
  }
  .tab-badge { position: static; margin-left: auto; }

  .app { padding-left: 232px; }
  .topbar { padding-inline: var(--gutter); }
  .view { padding-bottom: 64px; }
}

@media (min-width: 1080px) {
  :root { --gutter: 44px; }
  .grid-lg-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .grid-lg-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .view { padding-inline: 0; }
}

@media (min-width: 1400px) {
  :root { --maxw: 1180px; }
}

/* ---------- 27. Print ---------------------------------------------------- */
@media print {
  @page { margin: 14mm; }
  html, body { background: #fff !important; color: #000 !important; }
  body > *:not(.print-layer) { display: none !important; }
  .print-layer {
    display: block !important;
    position: static;
    color: #000;
    background: #fff;
    font-family: var(--font-body);
  }
  .print-layer * { color: #000 !important; border-color: #999 !important; background: transparent !important; box-shadow: none !important; }
  .print-layer .inv-table td, .print-layer .inv-table th { border-color: #ccc !important; }
  .print-layer .no-print { display: none !important; }
  .print-sheet { max-width: 180mm; margin: 0 auto; padding: 0; }
}

.print-layer { display: none; }

/* ---------- 28. Motion / a11y -------------------------------------------- */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
    scroll-behavior: auto !important;
  }
}

html { scroll-behavior: smooth; }
@media (prefers-reduced-motion: reduce) { html { scroll-behavior: auto; } .view.view-enter { animation: none; } }

/* ---------- 29. Reference-inspired workspace revamp ---------------------
   Light operations console: cool canvas, quiet surfaces, dense but breathable
   navigation, activity-led cards and stronger content hierarchy.              */
:root[data-theme='light'] {
  --bg: #F5F7FB;
  --bg-elev: #FFFFFF;
  --surface: #FFFFFF;
  --surface-2: #F8FAFD;
  --surface-3: #EEF2F8;
  --line: #E4EAF2;
  --line-strong: #CBD5E2;
  --ink: #172033;
  --ink-2: #5D6B80;
  --ink-3: #8B98AA;
  --accent: #2563EB;
  --accent-ink: #FFFFFF;
  --accent-soft: rgba(37, 99, 235, .10);
  --accent-line: rgba(37, 99, 235, .28);
  --cobalt: #2563EB;
  --cobalt-soft: rgba(37, 99, 235, .09);
  --ok: #159570;
  --ok-soft: rgba(21, 149, 112, .10);
  --warn: #C17A0B;
  --warn-soft: rgba(193, 122, 11, .11);
  --bad: #D04457;
  --bad-soft: rgba(208, 68, 87, .10);
  --shadow-1: 0 1px 2px rgba(23, 32, 51, .03);
  --shadow-2: 0 10px 28px -18px rgba(40, 65, 103, .22), 0 1px 2px rgba(40, 65, 103, .05);
  --shadow-3: 0 24px 60px -28px rgba(40, 65, 103, .28), 0 2px 8px rgba(40, 65, 103, .08);
  --r-sm: 10px; --r-md: 14px; --r-lg: 18px; --r-xl: 24px;
}
:root[data-theme='light'] body { letter-spacing: -0.012em; }
:root[data-theme='light'] .app { background: var(--bg); }
:root[data-theme='light'] .topbar {
  min-height: 70px;
  background: rgba(255,255,255,.82);
  border-bottom-color: var(--line);
}
:root[data-theme='light'] .brand-mark { border-radius: 9px; box-shadow: none; }
:root[data-theme='light'] .brand-sub { text-transform: none; letter-spacing: 0; font-weight: 500; }
:root[data-theme='light'] .role-chip { background: var(--surface-2); border-color: var(--line); color: var(--ink-2); }
:root[data-theme='light'] .view { padding-top: 30px; }
:root[data-theme='light'] .card, :root[data-theme='light'] .panel, :root[data-theme='light'] .card-hero { box-shadow: var(--shadow-1); }
:root[data-theme='light'] .card { border-color: var(--line); }
:root[data-theme='light'] .card-hero {
  background: linear-gradient(135deg, #FFFFFF 0%, #F1F6FF 100%);
  border-color: #DDE7F8;
  box-shadow: 0 14px 32px -24px rgba(37, 99, 235, .36);
}
:root[data-theme='light'] .card-hero::after { opacity: .10; }
:root[data-theme='light'] .panel { background: #FBFCFE; }
:root[data-theme='light'] .panel:hover { background: #FFFFFF; box-shadow: var(--shadow-2); }
:root[data-theme='light'] .kpi-grid { gap: 0; background: var(--line); box-shadow: var(--shadow-1); }
:root[data-theme='light'] .kpi { background: var(--surface); min-height: 112px; }
:root[data-theme='light'] .kpi-label { text-transform: none; letter-spacing: 0; font-weight: 600; }
:root[data-theme='light'] .kpi-val { font-size: 1.9rem; }
:root[data-theme='light'] .section-title { font-size: 1rem; }
:root[data-theme='light'] .btn-primary { background: var(--accent); box-shadow: 0 8px 18px -14px rgba(37,99,235,.85); }
:root[data-theme='light'] .btn-outline { background: #FFFFFF; border-color: var(--line-strong); }
:root[data-theme='light'] .tabbar {
  background: #FFFFFF;
  border-color: var(--line);
  box-shadow: 8px 0 28px -28px rgba(37, 56, 90, .35);
}
.rail-brand { display: none; }
.rail-label { display: none; }
@media (min-width: 760px) {
  .rail-brand {
    display: flex; align-items: center; gap: 10px;
    padding: 0 8px 22px;
    margin-bottom: 8px;
    border-bottom: 1px solid var(--line);
    color: var(--ink);
  }
  .rail-brand .brand-mark { width: 32px; height: 32px; }
  .rail-brand strong { display: block; font-family: var(--font-display); font-size: .92rem; line-height: 1.1; }
  .rail-brand small { display: block; margin-top: 4px; color: var(--ink-3); font-size: 10px; }
  .rail-label { display: block; padding: 10px 12px 6px; color: var(--ink-3); font-size: 10px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; }
  .topbar .brand { display: none; }
  .topbar { padding-left: 40px; }
  .view { max-width: 1220px; }
  .tab { color: var(--ink-2); }
  .tab.is-active { color: var(--accent); }
  .tab.is-active svg { color: var(--accent); }
}
@media (max-width: 759px) {
  .rail-brand, .rail-label { display: none; }
  .view { padding-top: 22px; }
}
@media (max-width: 520px) {
  :root[data-theme='light'] .card-hero { border-radius: 16px; padding: 18px; }
  :root[data-theme='light'] .card-pad-lg { padding: 18px; }
  :root[data-theme='light'] .kpi { min-height: 104px; }
}

