:root {
  --bg: #f4f6fa; --surface: #ffffff; --surface-2: #f8f9fc; --border: #e3e7ef; --text: #172033; --muted: #66708a;
  --primary: #2f5bea; --primary-weak: #e8eeff; --pos: #11845b; --pos-weak: #e3f5ee; --neg: #c93636; --neg-weak: #fdeaea;
  --warn: #a86400; --warn-weak: #fff4e0; --info: #2f6fa8; --info-weak: #e7f1fb;
  --side: #0f1729; --side-text: #c4cbe0; --side-active: #1d2a47;
  --c1: #2f5bea; --c2: #14a3a3; --c3: #e0882c; --c4: #9b59d0; --c5: #d64a7a; --c6: #6b8e23; --c7: #5c6b8a; --c8: #c9a227;
  --shadow: 0 1px 2px rgba(16,24,40,.05), 0 1px 3px rgba(16,24,40,.06);
  --radius: 10px; color-scheme: light;
}
:root[data-theme="dark"] {
  --bg: #0c1220; --surface: #141c2e; --surface-2: #19223a; --border: #26314b; --text: #e6eaf4; --muted: #8f9ab5;
  --primary: #6d8cff; --primary-weak: #1d2a52; --pos: #3ccf91; --pos-weak: #123528; --neg: #ff7171; --neg-weak: #3d1a1d;
  --warn: #f1b048; --warn-weak: #3a2b12; --info: #6fb2ef; --info-weak: #15283d;
  --side: #080d18; --side-text: #9aa5c2; --side-active: #18223a; --shadow: none; color-scheme: dark;
}
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body { font: 14px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  background: var(--bg); color: var(--text); }
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }
.layout { display: grid; grid-template-columns: 232px 1fr; min-height: 100vh; }
.side { background: var(--side); color: var(--side-text); padding: 18px 12px; position: sticky; top: 0; height: 100vh; overflow-y: auto; }
.brand { display: flex; align-items: center; gap: 10px; padding: 4px 10px 18px; color: #fff; font-weight: 700; font-size: 16px; }
.brand .logo { width: 30px; height: 30px; border-radius: 8px; background: linear-gradient(135deg, #2f5bea, #14a3a3);
  display: grid; place-items: center; font-weight: 800; }
.brand small { display: block; font-weight: 500; font-size: 11px; color: var(--side-text); }
.nav a { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 9px 12px; border-radius: 8px;
  color: var(--side-text); margin-bottom: 2px; font-weight: 500; }
.nav a:hover { background: var(--side-active); color: #fff; text-decoration: none; }
.nav a.active { background: var(--side-active); color: #fff; box-shadow: inset 3px 0 0 #6d8cff; }
.nav .sec { font-size: 11px; text-transform: uppercase; letter-spacing: .08em; color: #5d6886; padding: 14px 12px 6px; }
.badge-n { background: #2f5bea; color: #fff; border-radius: 99px; font-size: 11px; padding: 1px 7px; }
.badge-n.warn { background: #c27a00; }
.main { min-width: 0; }
.topbar { display: flex; align-items: center; gap: 12px; padding: 12px 28px; border-bottom: 1px solid var(--border);
  background: var(--surface); position: sticky; top: 0; z-index: 5; }
.topbar form { flex: 1; max-width: 520px; }
.topbar input[type=search] { width: 100%; }
.content { padding: 24px 28px 60px; max-width: 1500px; }
h1 { font-size: 22px; margin: 0 0 4px; }
h2 { font-size: 16px; margin: 0 0 12px; }
h3 { font-size: 14px; margin: 0 0 8px; }
.sub { color: var(--muted); margin: 0 0 18px; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); padding: 18px; }
.grid { display: grid; gap: 16px; }
.kpis { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.charts { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.kpi .label { color: var(--muted); font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: .04em; }
.kpi .value { font-size: 24px; font-weight: 700; margin-top: 4px; font-variant-numeric: tabular-nums; }
.kpi .hint { font-size: 12px; color: var(--muted); margin-top: 2px; }
.pos { color: var(--pos); } .neg { color: var(--neg); }
.row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.spacer { flex: 1; }
.btn { display: inline-flex; align-items: center; gap: 6px; border: 1px solid var(--border); background: var(--surface); color: var(--text);
  padding: 7px 12px; border-radius: 8px; font: inherit; font-weight: 600; cursor: pointer; white-space: nowrap; }
.btn:hover { background: var(--surface-2); text-decoration: none; }
.btn.primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn.primary:hover { filter: brightness(1.07); }
.btn.danger { color: var(--neg); border-color: var(--neg); }
.btn.success { background: var(--pos); border-color: var(--pos); color: #fff; }
.btn.sm { padding: 4px 9px; font-size: 12px; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.seg { display: inline-flex; border: 1px solid var(--border); border-radius: 8px; overflow: hidden; background: var(--surface); flex-wrap: wrap; }
.seg a { padding: 6px 11px; color: var(--text); border-right: 1px solid var(--border); font-weight: 500; font-size: 13px; }
.seg a:last-child { border-right: 0; }
.seg a.on { background: var(--primary); color: #fff; }
.seg a:hover { text-decoration: none; background: var(--surface-2); }
.seg a.on:hover { background: var(--primary); }
input, select, textarea { font: inherit; color: var(--text); background: var(--surface); border: 1px solid var(--border);
  border-radius: 7px; padding: 7px 9px; min-width: 0; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--primary-weak); border-color: var(--primary); }
label { font-size: 12px; font-weight: 600; color: var(--muted); display: block; margin-bottom: 4px; }
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; }
th { text-align: left; font-size: 11px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); font-weight: 700;
  padding: 9px 10px; border-bottom: 1px solid var(--border); background: var(--surface-2); white-space: nowrap; position: sticky; top: 0; }
td { padding: 9px 10px; border-bottom: 1px solid var(--border); vertical-align: top; }
tr:hover td { background: var(--surface-2); }
td.num, th.num { text-align: right; white-space: nowrap; }
tr.strong td { font-weight: 700; }
tr.rev td { color: var(--muted); text-decoration: line-through; }
.pill { display: inline-block; padding: 2px 8px; border-radius: 99px; font-size: 11px; font-weight: 700; white-space: nowrap; }
.pill.NEEDS_REVIEW, .pill.warn { background: var(--warn-weak); color: var(--warn); }
.pill.READY, .pill.info { background: var(--info-weak); color: var(--info); }
.pill.BOOKED, .pill.ok { background: var(--pos-weak); color: var(--pos); }
.pill.IGNORED, .pill.muted { background: var(--surface-2); color: var(--muted); }
.pill.PENDING_IMPORT { background: var(--primary-weak); color: var(--primary); }
.pill.err { background: var(--neg-weak); color: var(--neg); }
.issues { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.issues li { padding: 8px 10px; border-radius: 8px; font-size: 13px; border-left: 3px solid; }
.issues li.error { background: var(--neg-weak); border-color: var(--neg); }
.issues li.warning { background: var(--warn-weak); border-color: var(--warn); }
.issues li.info { background: var(--info-weak); border-color: var(--info); }
.drop { border: 2px dashed var(--border); border-radius: 12px; padding: 34px; text-align: center; background: var(--surface);
  transition: .15s; cursor: pointer; }
.drop.over { border-color: var(--primary); background: var(--primary-weak); }
.drop strong { font-size: 16px; }
.progress { height: 6px; background: var(--surface-2); border-radius: 99px; overflow: hidden; margin-top: 12px; }
.progress > div { height: 100%; background: var(--primary); width: 0; transition: width .2s; }
.review { display: grid; grid-template-columns: minmax(0, 1.05fr) minmax(0, 1fr); gap: 16px; align-items: start; }
.preview { position: sticky; top: 70px; height: calc(100vh - 100px); padding: 0; overflow: hidden; }
.preview iframe, .preview img { width: 100%; height: 100%; border: 0; object-fit: contain; background: #525659; }
.preview pre { margin: 0; padding: 14px; height: 100%; overflow: auto; font-size: 12px; white-space: pre-wrap; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px 14px; }
.form-grid .full { grid-column: 1 / -1; }
.field input, .field select { width: 100%; }
.field input[type=checkbox] { width: auto; }
.check { display: flex !important; gap: 8px; align-items: center; font-weight: 500 !important; color: var(--text) !important; margin: 4px 0 6px; }
.conf { font-size: 10px; font-weight: 700; padding: 1px 6px; border-radius: 99px; margin-left: 6px; vertical-align: 1px; cursor: help; }
.conf.hi { background: var(--pos-weak); color: var(--pos); }
.conf.mid { background: var(--warn-weak); color: var(--warn); }
.conf.lo { background: var(--neg-weak); color: var(--neg); }
.conf.man { background: var(--primary-weak); color: var(--primary); }
.src { font-size: 11px; color: var(--muted); margin-top: 3px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.grid-edit td { padding: 4px; }
.grid-edit input { width: 100%; border-color: transparent; background: transparent; text-align: right; }
.grid-edit input:hover { border-color: var(--border); }
.grid-edit input:focus { background: var(--surface); }
.sticky-actions { position: sticky; bottom: 0; background: var(--surface); border-top: 1px solid var(--border); margin: 16px -18px -18px;
  padding: 12px 18px; border-radius: 0 0 var(--radius) var(--radius); display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.chart { width: 100%; height: 260px; }
.chart svg { width: 100%; height: 100%; display: block; overflow: visible; }
.chart .empty { height: 100%; display: grid; place-items: center; color: var(--muted); font-size: 13px; text-align: center; }
.legend { display: flex; gap: 14px; flex-wrap: wrap; font-size: 12px; color: var(--muted); margin-top: 8px; }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 5px; vertical-align: -1px; }
.tip { position: fixed; pointer-events: none; background: var(--text); color: var(--bg); padding: 6px 9px; border-radius: 6px;
  font-size: 12px; z-index: 50; opacity: 0; transition: opacity .1s; white-space: nowrap; }
.banner { padding: 10px 14px; border-radius: 8px; margin-bottom: 16px; font-size: 13px; }
.banner.warn { background: var(--warn-weak); color: var(--warn); }
.banner.info { background: var(--info-weak); color: var(--info); }
.banner.demo { background: #6b21a8; color: #fff; font-weight: 700; text-align: center; border-radius: 0; margin: 0; }
.formula { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 12px; background: var(--surface-2);
  padding: 10px 12px; border-radius: 8px; border: 1px solid var(--border); white-space: pre-wrap; }
details summary { cursor: pointer; font-weight: 600; }
.modal { position: fixed; inset: 0; background: rgba(5,10,20,.55); display: none; align-items: center; justify-content: center; z-index: 60; padding: 16px; }
.modal.open { display: flex; }
.modal .card { width: 100%; max-width: 440px; }
.toast { position: fixed; right: 20px; bottom: 20px; background: var(--text); color: var(--bg); padding: 10px 14px; border-radius: 8px;
  z-index: 70; opacity: 0; transform: translateY(8px); transition: .2s; max-width: 420px; }
.toast.show { opacity: 1; transform: none; }
.hamb { display: none; }
@media (max-width: 1100px) { .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); } .charts { grid-template-columns: 1fr; }
  .review { grid-template-columns: 1fr; } .preview { position: static; height: 70vh; } }
@media (max-width: 760px) {
  .layout { grid-template-columns: 1fr; }
  .side { position: fixed; left: -260px; width: 240px; z-index: 40; transition: left .2s; }
  .side.open { left: 0; }
  .hamb { display: inline-flex; }
  .content { padding: 16px; } .topbar { padding: 10px 16px; }
  .kpis { grid-template-columns: 1fr 1fr; gap: 10px; } .kpi .value { font-size: 19px; }
  .form-grid { grid-template-columns: 1fr; }
}
