:root {
  --bg: #f6f7f9; --surface: #ffffff; --surface-2: #f0f2f5; --text: #1c2430; --muted: #5d6877; --line: #dfe3e9;
  --accent: #1f5fbf; --accent-ink: #ffffff; --accent-soft: #e6effb;
  --ok: #17803d; --ok-soft: #e4f4ea; --warn: #9a5b00; --warn-soft: #fdf0d9; --bad: #b42318; --bad-soft: #fde8e6;
  --c-orig: #3d6fc4; --c-adj: #e08a1e; --c-net: #1c2430; --shadow: 0 1px 2px rgba(20,30,50,.06), 0 2px 8px rgba(20,30,50,.05);
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #12161c; --surface: #1a2029; --surface-2: #222a35; --text: #e6e9ee; --muted: #9aa5b4; --line: #2c3644;
    --accent: #6ea2f0; --accent-ink: #0c1118; --accent-soft: #1f2d44;
    --ok: #55c07c; --ok-soft: #173424; --warn: #e2a64a; --warn-soft: #3a2c12; --bad: #f1857a; --bad-soft: #3d1f1c;
    --c-orig: #6ea2f0; --c-adj: #e9a645; --c-net: #e6e9ee; --shadow: none;
  }
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--text); font: 14px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif; }
h1, h2, h3, h4 { margin: 0; line-height: 1.2; }
a { color: var(--accent); }
button, input, select { font: inherit; color: inherit; }
.top { background: var(--surface); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 20; }
.top-inner { max-width: 1400px; margin: 0 auto; padding: 12px 16px 8px; display: flex; gap: 12px; align-items: center; justify-content: space-between; flex-wrap: wrap; }
.brand { display: flex; gap: 12px; align-items: center; }
.logo { width: 38px; height: 38px; border-radius: 10px; background: var(--accent); color: var(--accent-ink); display: grid; place-items: center; font-weight: 700; letter-spacing: .5px; }
.brand h1 { font-size: 18px; }
.sub { margin: 2px 0 0; color: var(--muted); font-size: 12.5px; }
.top-actions { display: flex; gap: 8px; align-items: center; }
.privacy { font-size: 12px; color: var(--ok); background: var(--ok-soft); padding: 4px 9px; border-radius: 999px; white-space: nowrap; }
.tabs { max-width: 1400px; margin: 0 auto; padding: 0 12px; display: flex; gap: 2px; overflow-x: auto; scrollbar-width: thin; }
.tab { background: none; border: 0; padding: 9px 13px; cursor: pointer; color: var(--muted); border-bottom: 2px solid transparent; white-space: nowrap; font-weight: 500; }
.tab:hover { color: var(--text); }
.tab[aria-selected="true"] { color: var(--accent); border-bottom-color: var(--accent); }
.tab .badge { margin-left: 6px; font-size: 11px; background: var(--bad-soft); color: var(--bad); padding: 1px 6px; border-radius: 999px; }
main { max-width: 1400px; margin: 0 auto; padding: 16px; }
.btn { border: 1px solid var(--line); background: var(--surface); padding: 7px 13px; border-radius: 8px; cursor: pointer; font-weight: 500; }
.btn:hover { background: var(--surface-2); }
.btn.primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.btn.primary:hover { filter: brightness(1.08); }
.btn.ghost { background: transparent; }
.btn.danger-ghost { color: var(--bad); background: transparent; }
.btn.sm { padding: 3px 9px; font-size: 12.5px; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 16px; box-shadow: var(--shadow); margin-bottom: 16px; }
.card > h2, .card > .card-h h2 { font-size: 15px; margin-bottom: 10px; }
.card-h { display: flex; justify-content: space-between; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 8px; }
.card-h h2 { margin: 0 !important; }
.muted { color: var(--muted); }
.small { font-size: 12.5px; }
.filters { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 10px; background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 12px; margin-bottom: 16px; align-items: end; }
.filters label { display: block; font-size: 11.5px; color: var(--muted); margin-bottom: 3px; font-weight: 600; text-transform: uppercase; letter-spacing: .03em; }
.filters input, .filters select, .field input, .field select { width: 100%; padding: 7px 9px; border: 1px solid var(--line); border-radius: 8px; background: var(--surface); }
.seg { display: inline-flex; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; }
.seg button { background: var(--surface); border: 0; padding: 7px 12px; cursor: pointer; }
.seg button + button { border-left: 1px solid var(--line); }
.seg button[aria-pressed="true"] { background: var(--accent); color: var(--accent-ink); }
.drop { border: 2px dashed var(--line); border-radius: 12px; padding: 26px; text-align: center; background: var(--surface-2); cursor: pointer; transition: .15s; }
.drop.over { border-color: var(--accent); background: var(--accent-soft); }
.drop strong { font-size: 15px; }
.progress { height: 8px; background: var(--surface-2); border-radius: 999px; overflow: hidden; margin-top: 12px; }
.progress > div { height: 100%; background: var(--accent); width: 0; transition: width .2s; }
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 12px; margin-bottom: 16px; }
.kpi { background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 12px 14px; box-shadow: var(--shadow); }
.kpi .l { font-size: 11.5px; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; font-weight: 600; }
.kpi .v { font-size: 19px; white-space: nowrap; font-weight: 650; margin-top: 4px; font-variant-numeric: tabular-nums; }
.kpi .s { font-size: 12px; color: var(--muted); margin-top: 3px; font-variant-numeric: tabular-nums; }
.kpi.warn .v { color: var(--warn); } .kpi.bad .v { color: var(--bad); }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
@media (max-width: 980px) { .grid2 { grid-template-columns: 1fr; } }
.tw { overflow: auto; border: 1px solid var(--line); border-radius: 10px; max-height: 70vh; }
table { border-collapse: collapse; width: 100%; font-variant-numeric: tabular-nums; }
th, td { padding: 6px 10px; border-bottom: 1px solid var(--line); text-align: left; white-space: nowrap; font-size: 13px; }
th { position: sticky; top: 0; background: var(--surface-2); font-weight: 600; z-index: 1; font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: .03em; }
td.num, th.num { text-align: right; }
tr:last-child td { border-bottom: 0; }
tbody tr:hover td { background: var(--surface-2); }
tr.total td { font-weight: 650; background: var(--surface-2); border-top: 2px solid var(--line); }
tr.subtotal td { font-weight: 600; background: var(--accent-soft); }
td.zero { color: var(--muted); }
td.neg { color: var(--bad); }
.pill { display: inline-block; padding: 1px 8px; border-radius: 999px; font-size: 11.5px; font-weight: 600; background: var(--surface-2); color: var(--muted); }
.pill.ok { background: var(--ok-soft); color: var(--ok); } .pill.warn { background: var(--warn-soft); color: var(--warn); } .pill.bad { background: var(--bad-soft); color: var(--bad); }
.note { background: var(--warn-soft); color: var(--warn); border-radius: 10px; padding: 10px 12px; margin: 0 0 12px; font-size: 13px; }
.note.info { background: var(--accent-soft); color: var(--accent); }
.note.ok { background: var(--ok-soft); color: var(--ok); }
.note.bad { background: var(--bad-soft); color: var(--bad); }
.checks { list-style: none; margin: 0; padding: 0; }
.checks li { display: flex; gap: 8px; padding: 4px 0; font-size: 13px; }
.checks .ic { font-weight: 700; width: 16px; }
.checks .ok { color: var(--ok); } .checks .bad { color: var(--bad); }
.chart { width: 100%; height: auto; display: block; }
.chart text { fill: var(--muted); font-size: 11px; }
.chart .grid { stroke: var(--line); stroke-width: 1; }
.chart .axis { stroke: var(--muted); stroke-width: 1; }
.chart .b-orig { fill: var(--c-orig); } .chart .b-adj { fill: var(--c-adj); }
.chart .l-net { stroke: var(--c-net); fill: none; stroke-width: 2; } .chart .d-net { fill: var(--c-net); }
.legend { display: flex; gap: 14px; font-size: 12px; color: var(--muted); margin-top: 6px; flex-wrap: wrap; }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 2px; margin-right: 5px; vertical-align: -1px; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.field { min-width: 150px; }
.field label { display: block; font-size: 11.5px; color: var(--muted); margin-bottom: 3px; font-weight: 600; text-transform: uppercase; }
.steps { margin: 0; padding-left: 18px; } .steps li { margin: 4px 0; }
.foot { text-align: center; color: var(--muted); font-size: 12.5px; padding: 18px 10px 26px; }
.foot .dot { margin: 0 6px; }
dialog { border: 1px solid var(--line); border-radius: 14px; padding: 0; background: var(--surface); color: var(--text); max-width: min(720px, 94vw); width: 100%; box-shadow: 0 10px 40px rgba(0,0,0,.25); }
dialog::backdrop { background: rgba(10,15,25,.5); }
.dlg-body { padding: 18px 20px; max-height: 70vh; overflow: auto; }
.dlg-body h3 { margin-bottom: 8px; } .dlg-body p { margin: 8px 0; }
.dlg-actions { display: flex; gap: 8px; justify-content: flex-end; padding: 10px 16px 14px; border-top: 1px solid var(--line); }
details.sec { border: 1px solid var(--line); border-radius: 10px; margin-bottom: 10px; background: var(--surface); }
details.sec > summary { cursor: pointer; padding: 10px 14px; font-weight: 600; display: flex; gap: 8px; align-items: center; }
details.sec > div { padding: 0 14px 14px; }
.kv { display: grid; grid-template-columns: max-content 1fr; gap: 3px 14px; font-size: 13px; }
.kv dt { color: var(--muted); } .kv dd { margin: 0; word-break: break-word; }
.empty { text-align: center; padding: 36px 10px; color: var(--muted); }
.pager { display: flex; gap: 8px; align-items: center; justify-content: flex-end; margin-top: 8px; }
@media (max-width: 640px) { main { padding: 10px; } .kpi .v { font-size: 17px; } .brand h1 { font-size: 16px; } .sub { display: none; } }
@media print { .top, .filters, .foot, .btn { display: none !important; } }

.attr-row { grid-column: 1 / -1; display: flex; gap: 10px; flex-wrap: wrap; align-items: center; border-top: 1px dashed var(--line); padding-top: 10px; }
.attr { display: flex; gap: 12px; align-items: center; border: 1px solid var(--line); border-radius: 8px; padding: 5px 10px; background: var(--surface); }
.attr-l { font-size: 11.5px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: .03em; }
.filters .attr label { display: flex; align-items: center; gap: 5px; margin: 0; text-transform: none; letter-spacing: 0; font-size: 13px; font-weight: 500; color: var(--text); }
.filters .attr input { width: auto; padding: 0; }
