*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  font-family: var(--font); font-size: var(--fs); color: var(--text); background: var(--bg);
  -webkit-font-smoothing: antialiased; line-height: 1.45; font-feature-settings: 'cv11', 'ss01';
}
.num, .tnum, td.num, .kpi-value, .money { font-variant-numeric: tabular-nums; }
a { color: var(--brand); text-decoration: none; }
a:hover { text-decoration: underline; }
button, input, select, textarea { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; border-radius: 6px; }
h1, h2, h3, h4 { margin: 0; font-weight: 650; letter-spacing: -0.01em; }
h1 { font-size: var(--fs-2xl); }
h2 { font-size: var(--fs-xl); }
h3 { font-size: var(--fs-lg); }
p { margin: 0 0 0.5em; }
code, .mono { font-family: var(--mono); font-size: 0.92em; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); border: 0; }
.muted { color: var(--text-2); }
.subtle { color: var(--text-3); font-size: var(--fs-sm); }
.hidden { display: none !important; }

/* ── boot splash */
.boot-splash { position: fixed; inset: 0; display: grid; place-items: center; background: radial-gradient(1200px 600px at 20% 10%, #e3f2ea 0%, var(--bg) 60%); z-index: 1000; transition: opacity 300ms var(--ease); }
.boot-splash.fade { opacity: 0; pointer-events: none; }
.boot-card { width: min(420px, 90vw); text-align: center; padding: 36px 32px; background: var(--surface); border: 1px solid var(--border); border-radius: 22px; box-shadow: var(--shadow-3); }
.boot-logo { display: inline-grid; margin-bottom: 14px; }
.boot-title { font-size: 22px; font-weight: 700; letter-spacing: -0.02em; }
.boot-sub { color: var(--text-2); margin: 4px 0 22px; font-size: 13px; }
.boot-bar { height: 8px; background: var(--slate-100); border-radius: 99px; overflow: hidden; }
.boot-bar-fill { height: 100%; width: 3%; background: linear-gradient(90deg, var(--brand), #22a06b); border-radius: 99px; transition: width 200ms linear; }
.boot-label { margin-top: 10px; font-size: 12.5px; color: var(--text-2); min-height: 18px; font-variant-numeric: tabular-nums; }
.boot-foot { margin-top: 18px; font-size: 11.5px; color: var(--text-3); }

/* ── app shell */
.shell { display: grid; grid-template-columns: var(--sidebar-w) 1fr; min-height: 100vh; transition: grid-template-columns var(--dur) var(--ease); }
.shell.collapsed { grid-template-columns: var(--sidebar-w-collapsed) 1fr; }
.sidebar { position: sticky; top: 0; height: 100vh; overflow-y: auto; background: var(--surface); border-right: 1px solid var(--border); display: flex; flex-direction: column; z-index: 30; scrollbar-width: thin; }
.brand { display: flex; align-items: center; gap: 10px; padding: 14px 16px; height: var(--topbar-h); border-bottom: 1px solid var(--border); }
.brand-mark { width: 32px; height: 32px; flex: none; }
.brand-text { line-height: 1.1; overflow: hidden; white-space: nowrap; }
.brand-text b { display: block; font-size: 14px; letter-spacing: -0.01em; }
.brand-text span { font-size: 11px; color: var(--text-3); }
.nav { padding: 8px 10px 16px; flex: 1; }
.nav-group { margin-top: 10px; }
.nav-group-title { font-size: 10.5px; font-weight: 650; text-transform: uppercase; letter-spacing: 0.08em; color: var(--text-3); padding: 6px 10px; white-space: nowrap; }
.nav a { display: flex; align-items: center; gap: 10px; padding: 7px 10px; margin: 1px 0; border-radius: 10px; color: var(--text-2); font-weight: 520; white-space: nowrap; text-decoration: none; position: relative; }
.nav a:hover { background: var(--surface-2); color: var(--text); }
.nav a.active { background: var(--brand-50); color: var(--brand); font-weight: 620; }
.nav a.active::before { content: ''; position: absolute; left: -10px; top: 8px; bottom: 8px; width: 3px; border-radius: 3px; background: var(--brand); }
.nav a .ico { flex: none; }
.nav a .nav-badge { margin-left: auto; }
.shell.collapsed .brand-text, .shell.collapsed .nav-group-title, .shell.collapsed .nav a span.lbl, .shell.collapsed .nav-badge, .shell.collapsed .sidebar-foot { display: none; }
.shell.collapsed .nav a { justify-content: center; }
.sidebar-foot { padding: 12px 16px; border-top: 1px solid var(--border); font-size: 11px; color: var(--text-3); }

.main { min-width: 0; display: flex; flex-direction: column; }
.topbar { position: sticky; top: 0; z-index: 25; height: var(--topbar-h); display: flex; align-items: center; gap: 10px; padding: 0 18px; background: var(--surface-glass); backdrop-filter: blur(var(--blur)); -webkit-backdrop-filter: blur(var(--blur)); border-bottom: 1px solid var(--border); }
.topbar .spacer { flex: 1; }
.content { padding: 20px 22px 40px; min-width: 0; flex: 1; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 12px; margin-bottom: 16px; flex-wrap: wrap; }
.page-head .crumbs { font-size: 12px; color: var(--text-3); margin-bottom: 2px; }
.page-head h1 { font-size: 22px; }
.page-actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.footer { padding: 12px 22px; font-size: 11.5px; color: var(--text-3); border-top: 1px solid var(--border); display: flex; justify-content: space-between; gap: 10px; flex-wrap: wrap; }

/* ── grid helpers */
.grid { display: grid; gap: 14px; }
.g-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.g-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.g-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.g-6 { grid-template-columns: repeat(6, minmax(0, 1fr)); }
.g-kpi { grid-template-columns: repeat(auto-fill, minmax(178px, 1fr)); }
.span-2 { grid-column: span 2; }
.span-3 { grid-column: span 3; }
.row { display: flex; gap: 10px; align-items: center; }
.row.wrap { flex-wrap: wrap; }
.col { display: flex; flex-direction: column; gap: 10px; }
.between { justify-content: space-between; }
.gap-s { gap: 6px; }
.mt { margin-top: 14px; }
.mb { margin-bottom: 14px; }
.flex1 { flex: 1; min-width: 0; }

@media (max-width: 1200px) { .g-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); } .g-6 { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
@media (max-width: 900px) {
  .shell, .shell.collapsed { grid-template-columns: 1fr; }
  .sidebar { position: fixed; left: 0; top: 0; width: 270px; transform: translateX(-100%); transition: transform var(--dur) var(--ease); box-shadow: var(--shadow-3); }
  .shell.mobile-open .sidebar { transform: none; }
  .g-2, .g-3, .g-4 { grid-template-columns: 1fr; }
  .g-6 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .span-2, .span-3 { grid-column: auto; }
  .content { padding: 14px 12px 30px; }
  .topbar { padding: 0 10px; gap: 6px; }
  .hide-mobile { display: none !important; }
}
@media (min-width: 901px) { .show-mobile { display: none !important; } }
@media print {
  .sidebar, .topbar, .footer, .page-actions, .no-print, .demo-fab, .toast-host { display: none !important; }
  .shell { display: block; }
  body { background: #fff; }
  .card { box-shadow: none; border-color: #ccc; break-inside: avoid; }
}
