/* East Digital · Profitability OS */
:root {
  color-scheme: light;
  --bg: #f6f5f2;
  --surface: #ffffff;
  --surface-2: #faf9f6;
  --surface-3: #f1efea;
  --border: #e6e3dc;
  --border-strong: #d6d2c8;
  --ink: #16150f;
  --ink-2: #4f4c45;
  --muted: #8a867c;
  --accent: #f68721;
  --accent-ink: #b45309;
  --accent-soft: #fef1e3;
  --good: #1a7f47;
  --good-soft: #e5f4ea;
  --warn: #9a6700;
  --warn-soft: #fbf1d9;
  --bad: #c0362c;
  --bad-soft: #fbe8e5;
  --info: #2a78d6;
  --info-soft: #e7f0fb;
  --series-1: #2a78d6;
  --series-2: #eb6834;
  --series-3: #1baf7a;
  --grid: #ebe8e1;
  --shadow: 0 1px 2px rgba(22, 21, 15, .05), 0 4px 16px rgba(22, 21, 15, .04);
  --shadow-lg: 0 12px 48px rgba(22, 21, 15, .18);
  --radius: 12px;
  --radius-sm: 8px;
  --sidebar: 232px;
  --font: 'Inter', ui-sans-serif, system-ui, -apple-system, 'Segoe UI', sans-serif;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --bg: #111110; --surface: #1a1a18; --surface-2: #1f1f1d; --surface-3: #262623;
    --border: #2d2c29; --border-strong: #3a3935; --ink: #f2f1ed; --ink-2: #c1beb5; --muted: #8b887f;
    --accent-ink: #f7a154; --accent-soft: #3a2513; --good: #4cc27f; --good-soft: #15291d;
    --warn: #e0ac3a; --warn-soft: #2e2512; --bad: #ef7a6f; --bad-soft: #33191a;
    --info: #5b9ff0; --info-soft: #152236; --series-1: #3987e5; --series-2: #d95926; --series-3: #199e70;
    --grid: #262623; --shadow: 0 1px 2px rgba(0,0,0,.3); --shadow-lg: 0 12px 48px rgba(0,0,0,.55);
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #111110; --surface: #1a1a18; --surface-2: #1f1f1d; --surface-3: #262623;
  --border: #2d2c29; --border-strong: #3a3935; --ink: #f2f1ed; --ink-2: #c1beb5; --muted: #8b887f;
  --accent-ink: #f7a154; --accent-soft: #3a2513; --good: #4cc27f; --good-soft: #15291d;
  --warn: #e0ac3a; --warn-soft: #2e2512; --bad: #ef7a6f; --bad-soft: #33191a;
  --info: #5b9ff0; --info-soft: #152236; --series-1: #3987e5; --series-2: #d95926; --series-3: #199e70;
  --grid: #262623; --shadow: 0 1px 2px rgba(0,0,0,.3); --shadow-lg: 0 12px 48px rgba(0,0,0,.55);
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--ink); font: 14px/1.5 var(--font);
  font-feature-settings: 'cv11', 'ss01'; -webkit-font-smoothing: antialiased;
}
a { color: inherit; }
button, input, select, textarea { font: inherit; color: inherit; }
.num, .tbl td.r, .kpi-value, .money { font-variant-numeric: tabular-nums; }
h1, h2, h3, h4 { margin: 0; font-weight: 600; letter-spacing: -.01em; }
.muted { color: var(--muted); }
.ink2 { color: var(--ink-2); }
.good { color: var(--good); }
.bad { color: var(--bad); }
.warn { color: var(--warn); }
.small { font-size: 12px; }
.nowrap { white-space: nowrap; }
.hidden { display: none !important; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.boot-splash { min-height: 100vh; display: grid; place-items: center; }
.boot-splash img { animation: pulse 1.2s ease-in-out infinite; }
@keyframes pulse { 50% { opacity: .35; } }

/* ---------- Auth ---------- */
.auth { min-height: 100vh; display: grid; place-items: center; padding: 24px 16px; }
.auth-card { width: 100%; max-width: 380px; background: var(--surface); border: 1px solid var(--border); border-radius: 16px; padding: 32px 28px; box-shadow: var(--shadow); }
.auth-card .logo { margin-bottom: 28px; }
.auth-card .logo img { height: 44px; width: auto; }
.auth-card h1 { font-size: 20px; margin-bottom: 4px; }
.auth-card p { margin: 0 0 20px; color: var(--ink-2); }
.auth-card .btn { width: 100%; justify-content: center; margin-top: 8px; height: 42px; }
.auth-foot { margin-top: 20px; font-size: 12px; color: var(--muted); text-align: center; }

/* ---------- Shell ---------- */
.app { display: grid; grid-template-columns: var(--sidebar) minmax(0, 1fr); min-height: 100vh; }
.sidebar {
  position: sticky; top: 0; height: 100vh; overflow-y: auto; display: flex; flex-direction: column;
  border-right: 1px solid var(--border); background: var(--surface); padding: 20px 12px;
}
.brand { display: block; padding: 4px 10px 22px; text-decoration: none; }
.brand img { height: 34px; display: block; }
.logo-dark { display: none !important; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .logo-light { display: none !important; }
  :root:not([data-theme="light"]) .logo-dark { display: block !important; }
}
:root[data-theme="dark"] .logo-light { display: none !important; }
:root[data-theme="dark"] .logo-dark { display: block !important; }
.m-logo-link { display: none; }
.brand-sub { font-size: 10.5px; letter-spacing: .14em; text-transform: uppercase; color: var(--muted); margin-top: 8px; }
.nav { display: flex; flex-direction: column; gap: 2px; }
.nav a {
  display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: 8px;
  text-decoration: none; color: var(--ink-2); font-weight: 500; position: relative;
}
.nav a svg { width: 18px; height: 18px; flex: none; opacity: .8; }
.nav a:hover { background: var(--surface-3); color: var(--ink); }
.nav a.active { background: var(--accent-soft); color: var(--ink); }
.nav a.active svg { color: var(--accent-ink); opacity: 1; }
.nav a .badge { margin-left: auto; }
.nav-sep { height: 1px; background: var(--border); margin: 12px 6px; }
.sidebar-foot { margin-top: auto; padding: 12px 10px 0; font-size: 12px; color: var(--muted); display: flex; gap: 6px; align-items: center; }
.sidebar-foot button { background: none; border: 0; padding: 6px; border-radius: 6px; cursor: pointer; color: var(--muted); display: inline-flex; }
.sidebar-foot button:hover { background: var(--surface-3); color: var(--ink); }
.sidebar-foot svg { width: 16px; height: 16px; }

.main { min-width: 0; display: flex; flex-direction: column; }
.topbar {
  position: sticky; top: 0; z-index: 20; display: flex; align-items: center; gap: 12px;
  padding: 14px 28px; background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: saturate(1.4) blur(10px); -webkit-backdrop-filter: saturate(1.4) blur(10px);
  border-bottom: 1px solid transparent;
}
.topbar.scrolled { border-bottom-color: var(--border); }
.search { position: relative; flex: 1; max-width: 460px; }
.search svg { position: absolute; left: 11px; top: 50%; transform: translateY(-50%); width: 16px; height: 16px; color: var(--muted); }
.search input {
  width: 100%; height: 38px; padding: 0 64px 0 34px; border: 1px solid var(--border); border-radius: 10px;
  background: var(--surface);
}
.search input:focus { outline: none; border-color: var(--border-strong); box-shadow: 0 0 0 3px var(--accent-soft); }
.search kbd { position: absolute; right: 8px; top: 50%; transform: translateY(-50%); }
kbd {
  font: 500 11px/1 var(--font); padding: 3px 6px; border-radius: 5px; border: 1px solid var(--border);
  background: var(--surface-2); color: var(--muted);
}
.topbar-spacer { flex: 1; }
.content { padding: 8px 28px 64px; max-width: 1360px; width: 100%; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin: 12px 0 20px; }
.page-head h1 { font-size: 24px; }
.page-head .sub { color: var(--muted); margin-top: 2px; }
.page-actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.crumb { font-size: 13px; color: var(--muted); margin-bottom: 4px; }
.crumb a { text-decoration: none; }
.crumb a:hover { color: var(--ink); }

/* ---------- Buttons & inputs ---------- */
.btn {
  display: inline-flex; align-items: center; gap: 6px; height: 36px; padding: 0 14px; border-radius: 9px;
  border: 1px solid var(--border); background: var(--surface); color: var(--ink); font-weight: 500;
  cursor: pointer; white-space: nowrap; text-decoration: none; transition: background .12s, border-color .12s;
}
.btn:hover { background: var(--surface-3); border-color: var(--border-strong); }
.btn svg { width: 16px; height: 16px; }
.btn-primary { background: var(--ink); border-color: var(--ink); color: var(--bg); }
.btn-primary:hover { background: color-mix(in srgb, var(--ink) 86%, var(--accent)); border-color: transparent; }
.btn-ghost { background: transparent; border-color: transparent; }
.btn-ghost:hover { background: var(--surface-3); border-color: transparent; }
.btn-danger { color: var(--bad); }
.btn-danger:hover { background: var(--bad-soft); border-color: transparent; }
.btn-sm { height: 30px; padding: 0 10px; font-size: 13px; border-radius: 8px; }
.btn-icon { width: 36px; padding: 0; justify-content: center; }
.btn-sm.btn-icon { width: 30px; }
.btn:disabled { opacity: .5; cursor: default; }

.field { display: flex; flex-direction: column; gap: 5px; margin-bottom: 14px; min-width: 0; }
.field > label, .label { font-size: 12.5px; font-weight: 500; color: var(--ink-2); }
.field .hint { font-size: 12px; color: var(--muted); }
.input, select.input, textarea.input {
  width: 100%; height: 38px; padding: 0 11px; border: 1px solid var(--border); border-radius: 9px;
  background: var(--surface); transition: border-color .12s, box-shadow .12s; min-width: 0;
}
textarea.input { height: auto; min-height: 72px; padding: 9px 11px; resize: vertical; }
select.input { padding-right: 28px; appearance: none; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%238a867c' stroke-width='2.5'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 10px center; }
.input:focus { outline: none; border-color: var(--border-strong); box-shadow: 0 0 0 3px var(--accent-soft); }
.input.big { height: 52px; font-size: 24px; font-weight: 600; letter-spacing: -.01em; }
.input-group { display: flex; min-width: 0; }
.input-group > .input:first-child, .input-group > select:first-child { border-radius: 9px 0 0 9px; }
.input-group > .input:last-child { border-radius: 0 9px 9px 0; margin-left: -1px; }
.input-group > select.input.cur { width: 88px; flex: none; font-weight: 600; }
.input-group > .input.big ~ select, .input-group:has(.input.big) > select.input { height: 52px; }
.row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.row3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 12px; }
.check { display: inline-flex; align-items: center; gap: 8px; cursor: pointer; user-select: none; }
.check input { width: 16px; height: 16px; accent-color: var(--ink); }
.seg { display: inline-flex; background: var(--surface-3); border-radius: 9px; padding: 3px; gap: 2px; flex-wrap: wrap; }
.seg button, .seg a {
  border: 0; background: transparent; padding: 5px 11px; border-radius: 7px; cursor: pointer; font-weight: 500;
  color: var(--ink-2); font-size: 13px; text-decoration: none; white-space: nowrap;
}
.seg button.on, .seg a.on { background: var(--surface); color: var(--ink); box-shadow: 0 1px 2px rgba(0,0,0,.08); }
.chips { display: flex; gap: 6px; flex-wrap: wrap; }
.chip {
  border: 1px solid var(--border); background: var(--surface); border-radius: 999px; padding: 4px 11px;
  font-size: 12.5px; cursor: pointer; color: var(--ink-2);
}
.chip.on { background: var(--ink); color: var(--bg); border-color: var(--ink); }

/* ---------- Cards ---------- */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); min-width: 0; }
.card-pad { padding: 18px 20px; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 16px 20px 0; flex-wrap: wrap; }
.card-head h3 { font-size: 14.5px; }
.card-head .sub { font-size: 12.5px; color: var(--muted); }
.card-body { padding: 14px 20px 18px; }
.grid { display: grid; gap: 16px; }
.g2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.g3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.g-main { grid-template-columns: minmax(0, 1.65fr) minmax(0, 1fr); }
.stack { display: flex; flex-direction: column; gap: 16px; }

.kpis { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; margin-bottom: 16px; }
.kpi { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px 16px; box-shadow: var(--shadow); min-width: 0; }
.kpi-label { font-size: 12.5px; color: var(--muted); display: flex; align-items: center; gap: 6px; }
.kpi-value { font-size: 23px; font-weight: 600; letter-spacing: -.02em; margin-top: 4px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.kpi-foot { font-size: 12px; color: var(--muted); margin-top: 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.kpi.hero { background: var(--ink); border-color: var(--ink); color: var(--bg); }
.kpi.hero .kpi-label, .kpi.hero .kpi-foot { color: color-mix(in srgb, var(--bg) 65%, transparent); }
.kpi.accent { border-top: 3px solid var(--accent); }
.delta { font-size: 12px; font-weight: 500; }
.tip { display: inline-flex; width: 14px; height: 14px; border-radius: 50%; border: 1px solid currentColor; font-size: 9.5px; align-items: center; justify-content: center; cursor: help; opacity: .6; font-weight: 600; }

/* ---------- Tables ---------- */
.tbl-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.tbl { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.tbl th {
  text-align: left; font-weight: 500; font-size: 12px; color: var(--muted); padding: 10px 12px;
  border-bottom: 1px solid var(--border); white-space: nowrap; background: var(--surface); position: sticky; top: 0;
}
.tbl th.sortable { cursor: pointer; user-select: none; }
.tbl th.sortable:hover { color: var(--ink); }
.tbl td { padding: 10px 12px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.tbl tr:last-child td { border-bottom: 0; }
.tbl tbody tr.click { cursor: pointer; }
.tbl tbody tr.click:hover td { background: var(--surface-2); }
.tbl .r { text-align: right; white-space: nowrap; }
.tbl .c { text-align: center; }
.tbl tfoot td { font-weight: 600; border-top: 1px solid var(--border-strong); border-bottom: 0; background: var(--surface-2); }
.tbl .t-main { font-weight: 500; color: var(--ink); }
.tbl .t-sub { font-size: 12px; color: var(--muted); }
.tbl td:first-child, .tbl th:first-child { padding-left: 20px; }
.tbl td:last-child, .tbl th:last-child { padding-right: 20px; }
.tbl.compact td { padding: 7px 12px; }
.pl td { padding: 8px 12px; }
.pl .sec td { font-size: 11.5px; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); padding-top: 18px; font-weight: 600; border-bottom: 0; }
.pl .ind td:first-child { padding-left: 34px; color: var(--ink-2); }
.pl .sub td { font-weight: 600; background: var(--surface-2); }
.pl .total td { font-weight: 700; font-size: 15px; border-top: 2px solid var(--ink); }
.pl .alt td { color: var(--muted); }

.empty { text-align: center; padding: 40px 20px; color: var(--muted); }
.empty h3 { color: var(--ink); font-size: 15px; margin-bottom: 4px; }
.empty .btn { margin-top: 14px; }

/* ---------- Pills & badges ---------- */
.pill { display: inline-flex; align-items: center; gap: 5px; padding: 2px 8px; border-radius: 999px; font-size: 12px; font-weight: 500; background: var(--surface-3); color: var(--ink-2); white-space: nowrap; }
.pill::before { content: ''; width: 6px; height: 6px; border-radius: 50%; background: currentColor; opacity: .8; }
.pill.plain::before { display: none; }
.pill.good { background: var(--good-soft); color: var(--good); }
.pill.warn { background: var(--warn-soft); color: var(--warn); }
.pill.bad { background: var(--bad-soft); color: var(--bad); }
.pill.info { background: var(--info-soft); color: var(--info); }
.pill.accent { background: var(--accent-soft); color: var(--accent-ink); }
.badge { font-size: 11px; font-weight: 600; background: var(--accent); color: #fff; border-radius: 999px; padding: 1px 7px; }
.tag { font-size: 11px; padding: 1px 6px; border-radius: 5px; background: var(--surface-3); color: var(--muted); font-weight: 500; }

/* ---------- Bars / meters ---------- */
.meter { height: 6px; border-radius: 3px; background: var(--surface-3); overflow: hidden; }
.meter > i { display: block; height: 100%; border-radius: 3px; background: var(--ink); }
.hbars { display: flex; flex-direction: column; gap: 12px; }
.hbar-row { display: grid; grid-template-columns: 150px minmax(0, 1fr) 96px; gap: 12px; align-items: center; font-size: 13px; }
.hbar-row .lbl { color: var(--ink-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.hbar-row .val { text-align: right; font-variant-numeric: tabular-nums; font-weight: 500; }
.hbar-row .val small { display: block; color: var(--muted); font-weight: 400; font-size: 11.5px; }
.hbar-track { height: 10px; background: var(--surface-3); border-radius: 0 4px 4px 0; position: relative; }
.hbar-track > i { position: absolute; left: 0; top: 0; bottom: 0; background: var(--series-1); border-radius: 0 4px 4px 0; min-width: 2px; }

/* ---------- Charts ---------- */
.chart { position: relative; width: 100%; }
.chart svg { display: block; width: 100%; overflow: visible; }
.chart .axis text { fill: var(--muted); font-size: 11px; font-family: var(--font); }
.chart .gridline { stroke: var(--grid); stroke-width: 1; }
.chart .baseline { stroke: var(--border-strong); stroke-width: 1; }
.chart .hit { fill: transparent; cursor: default; }
.chart .hit:hover { fill: var(--ink); fill-opacity: .04; }
.legend { display: flex; gap: 16px; flex-wrap: wrap; font-size: 12.5px; color: var(--ink-2); }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.legend i { width: 10px; height: 10px; border-radius: 3px; display: inline-block; }
.legend i.line { height: 2px; border-radius: 1px; width: 14px; }
.tooltip {
  position: fixed; z-index: 100; pointer-events: none; background: var(--ink); color: var(--bg); border-radius: 8px;
  padding: 8px 10px; font-size: 12px; box-shadow: var(--shadow-lg); min-width: 140px; opacity: 0; transition: opacity .1s;
}
.tooltip.on { opacity: 1; }
.tooltip b { display: block; margin-bottom: 4px; font-weight: 600; }
.tooltip .tr { display: flex; justify-content: space-between; gap: 14px; font-variant-numeric: tabular-nums; }
.tooltip .tr i { width: 8px; height: 8px; border-radius: 2px; display: inline-block; margin-right: 6px; }

.funnel { display: flex; flex-direction: column; gap: 8px; }
.funnel-row { display: grid; grid-template-columns: 110px minmax(0, 1fr) 110px; gap: 12px; align-items: center; font-size: 13px; }
.funnel-bar { height: 28px; background: var(--surface-3); border-radius: 6px; position: relative; overflow: hidden; }
.funnel-bar > i { position: absolute; inset: 0 auto 0 0; border-radius: 6px; }
.funnel-bar > span { position: absolute; left: 10px; top: 50%; transform: translateY(-50%); font-weight: 600; font-size: 13px; mix-blend-mode: normal; }
.funnel-row .pct { text-align: right; color: var(--muted); font-variant-numeric: tabular-nums; }
.funnel-row .pct b { color: var(--ink); font-weight: 600; }

/* ---------- Alerts / lists ---------- */
.alerts { display: flex; flex-direction: column; }
.alert { display: flex; gap: 12px; padding: 11px 20px; border-top: 1px solid var(--border); font-size: 13.5px; align-items: flex-start; }
.alert:first-child { border-top: 0; }
.alert .ico { width: 26px; height: 26px; border-radius: 7px; display: grid; place-items: center; flex: none; background: var(--surface-3); color: var(--ink-2); }
.alert .ico svg { width: 15px; height: 15px; }
.alert.info .ico { background: var(--info-soft); color: var(--info); }
.alert.warn .ico { background: var(--warn-soft); color: var(--warn); }
.alert.good .ico { background: var(--good-soft); color: var(--good); }
.alert.accent .ico { background: var(--accent-soft); color: var(--accent-ink); }
.alert a { text-decoration: none; }
.alert a:hover { text-decoration: underline; }
.list { display: flex; flex-direction: column; }
.li { display: flex; align-items: center; gap: 12px; padding: 10px 20px; border-top: 1px solid var(--border); font-size: 13.5px; }
.li:first-child { border-top: 0; }
.li .grow { flex: 1; min-width: 0; }
.li .t { font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.li .s { font-size: 12px; color: var(--muted); }
.li-total { display: flex; justify-content: space-between; padding: 12px 20px; border-top: 1px solid var(--border-strong); font-weight: 600; background: var(--surface-2); border-radius: 0 0 var(--radius) var(--radius); }
.avatar { width: 30px; height: 30px; border-radius: 8px; display: grid; place-items: center; font-weight: 600; font-size: 12px; background: var(--surface-3); color: var(--ink-2); flex: none; }
.date-box { width: 38px; text-align: center; flex: none; line-height: 1.1; }
.date-box b { display: block; font-size: 16px; }
.date-box span { font-size: 10.5px; text-transform: uppercase; color: var(--muted); letter-spacing: .06em; }

/* ---------- Filters ---------- */
.filters { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin-bottom: 14px; }
.filters .input { height: 34px; width: auto; min-width: 130px; font-size: 13px; }
.filters .search-inline { min-width: 200px; flex: 1; max-width: 300px; }

/* ---------- Project/entity header ---------- */
.ent-head { display: flex; gap: 16px; align-items: flex-start; justify-content: space-between; flex-wrap: wrap; margin: 12px 0 18px; }
.ent-head h1 { font-size: 24px; }
.meta { display: flex; flex-wrap: wrap; gap: 6px 18px; margin-top: 8px; font-size: 13px; color: var(--ink-2); }
.meta span b { font-weight: 500; color: var(--muted); margin-right: 4px; }
.kv { display: grid; grid-template-columns: auto 1fr; gap: 8px 16px; font-size: 13.5px; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; text-align: right; font-variant-numeric: tabular-nums; font-weight: 500; }
.split-num { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; padding: 7px 0; border-bottom: 1px dashed var(--border); font-size: 13.5px; }
.split-num:last-child { border-bottom: 0; }
.split-num .v { font-variant-numeric: tabular-nums; font-weight: 500; }
.split-num.total { border-bottom: 0; border-top: 1px solid var(--border-strong); margin-top: 4px; padding-top: 10px; font-weight: 600; }
.split-num.total .v { font-weight: 700; font-size: 15px; }
.tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--border); margin-bottom: 16px; overflow-x: auto; }
.tabs button { background: none; border: 0; padding: 10px 14px; font-weight: 500; color: var(--muted); border-bottom: 2px solid transparent; margin-bottom: -1px; cursor: pointer; white-space: nowrap; }
.tabs button.on { color: var(--ink); border-bottom-color: var(--accent); }
.tabs button .tag { margin-left: 4px; }

/* ---------- Drawer & modal ---------- */
.scrim { position: fixed; inset: 0; background: rgba(15, 14, 10, .38); z-index: 60; opacity: 0; transition: opacity .18s; }
.scrim.on { opacity: 1; }
.drawer {
  position: fixed; top: 0; right: 0; bottom: 0; width: 480px; max-width: 100%; z-index: 61; background: var(--surface);
  box-shadow: var(--shadow-lg); display: flex; flex-direction: column; transform: translateX(100%); transition: transform .22s cubic-bezier(.2, .8, .2, 1);
}
.drawer.on { transform: none; }
.drawer.wide { width: 620px; }
.drawer-head { display: flex; align-items: center; justify-content: space-between; padding: 16px 20px; border-bottom: 1px solid var(--border); gap: 12px; }
.drawer-head h2 { font-size: 16px; }
.drawer-body { flex: 1; overflow-y: auto; padding: 18px 20px; }
.drawer-foot { display: flex; gap: 8px; justify-content: flex-end; padding: 14px 20px; border-top: 1px solid var(--border); background: var(--surface-2); flex-wrap: wrap; }
.drawer-foot .left { margin-right: auto; }
.more-toggle { display: flex; align-items: center; gap: 8px; width: 100%; background: none; border: 0; border-top: 1px solid var(--border); padding: 14px 0 4px; margin-top: 4px; font-weight: 500; color: var(--ink-2); cursor: pointer; }
.more-toggle svg { width: 16px; height: 16px; transition: transform .15s; }
.more-toggle.open svg { transform: rotate(180deg); }
.suggest { font-size: 12px; color: var(--accent-ink); background: var(--accent-soft); border-radius: 7px; padding: 6px 10px; margin: -6px 0 14px; }
.calc-box { background: var(--surface-2); border: 1px solid var(--border); border-radius: 10px; padding: 12px 14px; margin-bottom: 14px; }
.alloc-row { display: grid; grid-template-columns: 1fr 120px 30px; gap: 8px; margin-bottom: 8px; }
.dropzone { border: 1.5px dashed var(--border-strong); border-radius: 10px; padding: 14px; text-align: center; color: var(--muted); font-size: 13px; cursor: pointer; }
.dropzone:hover, .dropzone.over { border-color: var(--accent); color: var(--ink); background: var(--accent-soft); }

.menu {
  position: absolute; z-index: 70; background: var(--surface); border: 1px solid var(--border); border-radius: 10px;
  box-shadow: var(--shadow-lg); padding: 5px; min-width: 200px;
}
.menu button { display: flex; width: 100%; align-items: center; gap: 10px; background: none; border: 0; padding: 8px 10px; border-radius: 7px; cursor: pointer; text-align: left; }
.menu button:hover { background: var(--surface-3); }
.menu button svg { width: 16px; height: 16px; color: var(--muted); }
.menu button kbd { margin-left: auto; }

.toast-wrap { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); z-index: 120; display: flex; flex-direction: column; gap: 8px; align-items: center; }
.toast { background: var(--ink); color: var(--bg); padding: 10px 16px; border-radius: 10px; font-size: 13.5px; box-shadow: var(--shadow-lg); animation: toastIn .2s ease-out; display: flex; gap: 12px; align-items: center; }
.toast.err { background: var(--bad); color: #fff; }
.toast button { background: none; border: 0; color: var(--accent); font-weight: 600; cursor: pointer; padding: 0; }
@keyframes toastIn { from { transform: translateY(8px); opacity: 0; } }

/* ---------- Search results ---------- */
.insight { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 1px; background: var(--border); border-top: 1px solid var(--border); }
.insight > div { background: var(--surface); padding: 12px 20px; }
.insight .l { font-size: 12px; color: var(--muted); }
.insight .v { font-size: 17px; font-weight: 600; font-variant-numeric: tabular-nums; }

.report-nav { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 16px; }
.note { font-size: 12.5px; color: var(--muted); padding: 12px 20px; border-top: 1px solid var(--border); }
.callout { background: var(--surface-2); border: 1px solid var(--border); border-radius: 10px; padding: 12px 14px; font-size: 13px; color: var(--ink-2); }
.callout b { color: var(--ink); }

/* ---------- Mobile ---------- */
.mnav { display: none; }
@media (max-width: 1100px) {
  .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .g-main, .g3 { grid-template-columns: minmax(0, 1fr); }
  .insight { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 860px) {
  .app { grid-template-columns: minmax(0, 1fr); }
  .sidebar { display: none; }
  .topbar { padding: 10px 16px; }
  .m-logo-link { display: block; flex: none; }
  .m-logo-link img { height: 24px; width: auto; }
  .content { padding: 4px 16px 110px; }
  .g2 { grid-template-columns: minmax(0, 1fr); }
  .page-head h1, .ent-head h1 { font-size: 20px; }
  .kpi-value { font-size: 19px; }
  .hbar-row { grid-template-columns: 100px minmax(0, 1fr) 84px; }
  .funnel-row { grid-template-columns: 84px minmax(0, 1fr) 84px; }
  .row3 { grid-template-columns: 1fr 1fr; }
  .drawer, .drawer.wide { width: 100%; }
  .search kbd, .hide-m { display: none; }
  .mnav {
    display: flex; position: fixed; left: 0; right: 0; bottom: 0; z-index: 30; background: var(--surface);
    border-top: 1px solid var(--border); padding: 6px 4px calc(6px + env(safe-area-inset-bottom)); justify-content: space-around;
  }
  .mnav a, .mnav button { display: flex; flex-direction: column; align-items: center; gap: 2px; font-size: 10.5px; text-decoration: none; color: var(--muted); background: none; border: 0; padding: 4px 6px; min-width: 52px; cursor: pointer; }
  .mnav svg { width: 20px; height: 20px; }
  .mnav a.active { color: var(--ink); }
  .mnav .fab { width: 46px; height: 46px; border-radius: 14px; background: var(--ink); color: var(--bg); display: grid; place-items: center; margin-top: -18px; box-shadow: var(--shadow-lg); }
}
@media (max-width: 520px) {
  .row { grid-template-columns: minmax(0, 1fr); }
  .kpis { gap: 8px; }
  .kpi { padding: 12px; }
  .card-head, .card-body { padding-left: 14px; padding-right: 14px; }
  .tbl td:first-child, .tbl th:first-child { padding-left: 14px; }
  .tbl td:last-child, .tbl th:last-child { padding-right: 14px; }
  .li, .alert { padding-left: 14px; padding-right: 14px; }
}

@media print {
  .sidebar, .topbar, .mnav, .page-actions, .report-nav, .no-print { display: none !important; }
  .app { display: block; }
  .content { padding: 0; max-width: none; }
  .card { box-shadow: none; break-inside: avoid; }
  body { background: #fff; }
}
