:root {
  --bg: #0a0d14; --panel: #111622; --panel2: #161c2b; --line: #222b3d; --line2: #2b3650;
  --text: #e8ecf4; --muted: #8592ab; --accent: #4c8dff; --accent2: #2f6fe0;
  --good: #22c55e; --bad: #ef4444; --warn: #f59e0b;
  --radius: 14px;
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--text); font: 14px/1.45 "Inter", system-ui, -apple-system, "Segoe UI", sans-serif; }
a { color: var(--accent); text-decoration: none; }
button, select, input { font: inherit; color: inherit; }

.layout { display: grid; grid-template-columns: 230px 1fr; min-height: 100vh; }
.side { background: #0d111b; border-right: 1px solid var(--line); padding: 18px 12px; position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column; gap: 4px; }
.brand { font-weight: 800; font-size: 18px; padding: 4px 10px 14px; letter-spacing: .2px; }
.brand small { display: block; font-weight: 500; font-size: 12px; color: var(--muted); }
.side select { width: 100%; margin: 0 0 12px; }
.nav a { display: block; padding: 9px 12px; border-radius: 9px; color: var(--muted); }
.nav a:hover { background: var(--panel); color: var(--text); }
.nav a.on { background: rgba(76,141,255,.14); color: var(--text); }
.nav .grp { font-size: 11px; text-transform: uppercase; letter-spacing: .08em; color: #5d6a84; padding: 14px 12px 4px; }
.side .foot { margin-top: auto; font-size: 12px; color: var(--muted); padding: 8px 10px; }

main { padding: 24px 28px 60px; min-width: 0; }
.head { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; flex-wrap: wrap; }
h1 { font-size: 28px; margin: 0; font-weight: 800; }
.sub { color: var(--muted); margin-top: 4px; font-size: 13px; }
.exports { display: flex; gap: 6px; }
.exports button { background: transparent; border: 1px solid var(--line2); border-radius: 8px; padding: 5px 10px; font-size: 12px; cursor: pointer; }
.exports button:hover { border-color: var(--accent); }

.filters { margin: 18px 0 20px; display: flex; flex-direction: column; gap: 10px; }
.row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.chip { background: var(--panel); border: 1px solid var(--line2); border-radius: 9px; padding: 6px 13px; cursor: pointer; white-space: nowrap; }
.chip:hover { border-color: #3d4b6a; }
.chip.on { background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 600; }
.seg { display: inline-flex; border: 1px solid var(--line2); border-radius: 9px; overflow: hidden; }
.seg button { background: var(--panel); border: 0; padding: 6px 13px; cursor: pointer; border-right: 1px solid var(--line2); }
.seg button:last-child { border-right: 0; }
.seg button.on { background: var(--accent); color: #fff; font-weight: 600; }
select, input[type=date] { background: var(--panel); border: 1px solid var(--line2); border-radius: 9px; padding: 6px 10px; color-scheme: dark; }
.lbl { color: var(--muted); font-size: 12px; }

.grid { display: grid; gap: 14px; }
.kpis { grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px 20px; }
.kpi .t { color: var(--muted); font-size: 13px; display: flex; gap: 6px; align-items: center; }
.kpi .v { font-size: 27px; font-weight: 800; margin-top: 6px; letter-spacing: -.3px; white-space: nowrap; }
.kpi .h { color: #67748e; font-size: 12px; margin-top: 4px; }
.q { display: inline-grid; place-items: center; width: 16px; height: 16px; border-radius: 50%; background: #1d2a46; color: var(--accent); font-size: 10px; font-weight: 700; cursor: help; position: relative; }
.q:hover::after { content: attr(data-tip); position: absolute; left: 50%; bottom: 140%; transform: translateX(-50%); width: 240px; background: #1b2336; border: 1px solid var(--line2); color: var(--text); padding: 8px 10px; border-radius: 8px; font-weight: 400; font-size: 12px; line-height: 1.4; z-index: 20; white-space: normal; }
.section { margin-top: 18px; }
.section h2 { font-size: 17px; margin: 0 0 4px; }
.section .note { color: var(--muted); font-size: 12px; margin-bottom: 14px; }
.two { grid-template-columns: 1fr 1fr; }
@media (max-width: 1100px) { .two { grid-template-columns: 1fr; } }

table { width: 100%; border-collapse: collapse; }
th { text-align: right; color: var(--muted); font-weight: 500; font-size: 12px; padding: 10px 10px; border-bottom: 1px solid var(--line2); white-space: nowrap; cursor: pointer; user-select: none; position: sticky; top: 0; background: var(--panel); }
th:first-child, td:first-child { text-align: left; }
th.sorted { color: var(--accent); }
td { text-align: right; padding: 11px 10px; border-bottom: 1px solid var(--line); white-space: nowrap; font-variant-numeric: tabular-nums; }
tr.total td { font-weight: 700; border-top: 1px solid var(--line2); border-bottom: 0; }
tr.subrow td { color: var(--muted); font-size: 13px; background: #0e131e; }
tr.subrow td:first-child { padding-left: 30px; }
td .tw { color: var(--muted); font-size: 12px; display: block; }
.tbl { overflow: auto; max-height: 70vh; }
.good { color: var(--good); } .bad { color: var(--bad); } .warn { color: var(--warn); } .muted { color: var(--muted); }
.link { color: var(--accent); cursor: pointer; border-bottom: 1px dashed currentColor; }
.drill { padding: 6px 4px 10px 22px; max-width: 760px; white-space: normal; }
.drill .dt { color: var(--text); font-weight: 600; margin-bottom: 8px; }
.drill .dr { display: grid; grid-template-columns: 260px 1fr 56px 60px; gap: 10px; align-items: center; margin: 5px 0; }
.drill .dn { color: var(--text); text-align: left; overflow: hidden; text-overflow: ellipsis; }
.drill .db { height: 14px; background: #182033; border-radius: 4px; overflow: hidden; }
.drill .db i { display: block; height: 100%; background: var(--accent); border-radius: 4px; }
.drill .db i.red { background: #e2564f; }
.drill b { color: var(--text); text-align: right; }
.drill .dp { color: var(--muted); text-align: right; }
.tog { cursor: pointer; color: var(--muted); display: inline-block; width: 16px; }

.funnel { display: flex; align-items: stretch; gap: 8px; flex-wrap: wrap; }
.step { background: var(--panel2); border-radius: 12px; padding: 12px 18px; min-width: 120px; text-align: center; }
.step .t { color: var(--muted); font-size: 12px; }
.step .v { font-size: 24px; font-weight: 800; }
.arrow { display: flex; flex-direction: column; align-items: center; justify-content: center; font-weight: 700; font-size: 14px; min-width: 56px; }
.arrow span { color: var(--muted); }

.bars .b { display: grid; grid-template-columns: 180px 1fr 110px; gap: 10px; align-items: center; margin: 8px 0; }
.bars .b .n { color: var(--muted); font-size: 12px; text-align: right; }
.bars .b .bar { height: 26px; background: var(--accent); border-radius: 6px; }
.bars .b .val { font-weight: 600; }

.banner { background: #2a1d0b; border: 1px solid #5c3d0c; color: #fcd38a; padding: 10px 14px; border-radius: 10px; margin-bottom: 14px; font-size: 13px; }
.loading { color: var(--muted); padding: 40px; text-align: center; }
.empty { color: var(--muted); padding: 18px; text-align: center; }

.login { max-width: 360px; margin: 14vh auto; }
.login input { width: 100%; background: var(--panel2); border: 1px solid var(--line2); border-radius: 9px; padding: 10px 12px; margin: 6px 0 12px; }
.login button { width: 100%; background: var(--accent); border: 0; border-radius: 9px; padding: 10px; color: #fff; font-weight: 700; cursor: pointer; }

@media (max-width: 800px) {
  .layout { grid-template-columns: 1fr; }
  .side { position: static; height: auto; }
  main { padding: 16px; }
}
@media print {
  .side, .filters, .exports { display: none !important; }
  .layout { display: block; }
  body { background: #fff; color: #000; }
  .card { border-color: #ccc; background: #fff; }
  th { background: #fff; }
  .tbl { max-height: none; overflow: visible; }
}
