:root {
  --plane: #f1f5fc; --surface: #ffffff; --surface-2: #f3f6fb;
  --ink: #10203a; --ink-2: #47566e; --muted: #75839a; --grid: #e6ebf3;
  --border: rgba(16, 32, 58, .10);
  --blue: #1d5fd1; --orange: #d9700a; --teal: #008f7c; --violet: #6d3ae0; --pink: #d6246e;
  --accent: var(--blue); --accent-soft: rgba(29, 95, 209, .10);
  --good: #0a8a0a; --critical: #d03b3b;
  --shadow: 0 1px 2px rgba(16, 32, 58, .05), 0 12px 28px rgba(16, 32, 58, .08);
  --radius: 16px;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { color-scheme: light; }
body { margin: 0; background: var(--plane); color: var(--ink); font-family: "Segoe UI", system-ui, -apple-system, Roboto, sans-serif; font-size: 15px; line-height: 1.5; -webkit-font-smoothing: antialiased; }
.wrap { max-width: 1320px; margin: 0 auto; padding: 0 22px; }
h1, h2, h3 { margin: 0; text-wrap: balance; }

/* hero */
.hero { color: #fff; padding: 18px 0 26px; background:
  radial-gradient(760px 340px at 92% -10%, rgba(214, 36, 110, .62), transparent 70%),
  radial-gradient(680px 340px at 62% 120%, rgba(0, 163, 141, .60), transparent 70%),
  linear-gradient(115deg, #0a1f55 0%, #1647a8 55%, #5a2fc4 100%); }
.hero-top { display: flex; align-items: center; justify-content: space-between; gap: 14px; flex-wrap: wrap; margin-bottom: 16px; }
.logo-plate { display: inline-flex; background: #fff; border-radius: 12px; padding: 3px 6px; box-shadow: 0 6px 16px rgba(0, 0, 0, .22); }
.logo-plate img { height: 60px; width: 60px; object-fit: contain; display: block; }
.hero-links { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.stamp { font-size: 12.5px; opacity: .88; }
.eyebrow { font-size: 12px; letter-spacing: .14em; text-transform: uppercase; font-weight: 700; color: #bfe9ff; }
.hero h1 { font-size: clamp(25px, 3.3vw, 36px); font-weight: 780; letter-spacing: -.015em; margin-top: 6px; line-height: 1.12; }
.sub { font-size: 14px; margin: 9px 0 0; opacity: .94; max-width: 92ch; }
.sub b { font-weight: 700; }

/* buttons */
.btn { appearance: none; font: inherit; font-size: 13.5px; font-weight: 650; border-radius: 10px; padding: 8px 14px; cursor: pointer; text-decoration: none; display: inline-flex; align-items: center; gap: 6px; border: 1px solid transparent; }
.btn:focus-visible, .tab:focus-visible, .mchip:focus-visible, .tchip:focus-visible, .tool:focus-visible, .brandchip:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.btn-import { background: #ffb020; color: #2a1a00; box-shadow: 0 6px 16px rgba(0, 0, 0, .2); }
.btn-import:hover { background: #ffc24d; }
.btn-ghost { background: rgba(255, 255, 255, .14); color: #fff; border-color: rgba(255, 255, 255, .35); }
.btn-ghost:hover { background: rgba(255, 255, 255, .24); }
.btn-primary { background: var(--blue); color: #fff; }
.btn-primary:hover { background: #174fb0; }
.btn-primary:disabled { background: #b8c3d6; cursor: not-allowed; }
.btn-plain { background: var(--surface); color: var(--ink-2); border-color: var(--border); }

/* KPI */
.kpis { display: grid; gap: 14px; margin-top: 20px; }
.k4 { grid-template-columns: repeat(4, 1fr); }
.k5 { grid-template-columns: repeat(5, 1fr); }
.kpi { border-radius: var(--radius); padding: 15px 18px; min-width: 0; color: #fff; box-shadow: 0 10px 24px rgba(5, 15, 50, .28); }
.kpi.c1 { background: linear-gradient(135deg, #123f9e, #1d5fd1); }
.kpi.c2 { background: linear-gradient(135deg, #4f22b8, #7a45e8); }
.kpi.c3 { background: linear-gradient(135deg, #00665a, #008f7c); }
.kpi.c4 { background: linear-gradient(135deg, #a83a06, #cc6206); }
.kpi.c5 { background: linear-gradient(135deg, #a4124f, #d6246e); }
.k-label { font-size: 12px; font-weight: 650; letter-spacing: .02em; opacity: .92; }
.k-val { font-size: 28px; font-weight: 790; letter-spacing: -.02em; margin-top: 4px; line-height: 1.1; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
.k-note { font-size: 12px; margin-top: 6px; opacity: .95; }
.k-note b { font-weight: 750; }
.delta { font-weight: 800; white-space: nowrap; font-variant-numeric: tabular-nums; }
.kpi .delta { color: #fff; }
.card .delta.up { color: var(--good); }
.card .delta.down { color: var(--critical); }

/* tabs + month filter */
nav.tabs { position: sticky; top: 0; z-index: 30; background: rgba(255, 255, 255, .92); backdrop-filter: blur(10px); border-bottom: 1px solid var(--border); box-shadow: 0 4px 16px rgba(16, 32, 58, .06); }
.tabs-inner { display: flex; gap: 8px; overflow-x: auto; padding: 10px 0 8px; scrollbar-width: none; }
.tab { appearance: none; border: 1px solid var(--border); background: var(--surface); font: inherit; cursor: pointer; padding: 7px 18px; border-radius: 999px; color: var(--ink-2); font-weight: 680; font-size: 14px; white-space: nowrap; }
.tab:hover { border-color: var(--accent); }
.tab[aria-selected="true"] { color: #fff; border-color: transparent; }
.tab.t-ov[aria-selected="true"] { background: linear-gradient(135deg, #123f9e, #1d5fd1); }
.tab.t-mo[aria-selected="true"] { background: linear-gradient(135deg, #4f22b8, #7a45e8); }
.tab.t-pr[aria-selected="true"] { background: linear-gradient(135deg, #00665a, #008f7c); }
.mbar { display: flex; align-items: center; gap: 8px; padding: 0 0 10px; overflow-x: auto; scrollbar-width: none; }
.mb-label { font-size: 11px; font-weight: 800; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); white-space: nowrap; flex: none; }
.mb-chips { display: flex; gap: 6px; flex: none; }
.mchip { appearance: none; font: inherit; cursor: pointer; border: 1px solid var(--border); background: var(--surface); color: var(--ink-2); font-size: 12.5px; font-weight: 700; padding: 4px 11px; border-radius: 8px; font-variant-numeric: tabular-nums; white-space: nowrap; }
.mchip:hover { border-color: var(--accent); }
.mchip[aria-pressed="true"] { background: var(--accent); border-color: var(--accent); color: #fff; }
.mchip.preset { font-weight: 650; }
.mchip.preset[aria-pressed="true"] { background: var(--accent-soft); color: var(--ink); border-color: var(--accent); }
.mb-sep { width: 1px; height: 20px; background: var(--border); flex: none; margin: 0 4px; }
.mb-info { font-size: 12px; color: var(--muted); white-space: nowrap; margin-left: auto; padding-left: 10px; flex: none; }

/* layout */
section[role=tabpanel] { padding: 22px 0 40px; }
section[hidden] { display: none; }
.grid { display: grid; gap: 16px; margin-top: 16px; }
.g-2 { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px 18px 18px; box-shadow: var(--shadow); min-width: 0; }
.card.span { margin-top: 16px; }
.c-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 8px; }
.c-title { font-size: 16px; font-weight: 730; letter-spacing: -.01em; }
.c-sub { font-size: 12.5px; color: var(--muted); margin-top: 1px; }
.tools { display: flex; gap: 6px; flex-wrap: wrap; }
.tool { appearance: none; font: inherit; font-size: 12.5px; font-weight: 650; padding: 5px 10px; border-radius: 8px; cursor: pointer; background: var(--surface); color: var(--ink-2); border: 1px solid var(--border); white-space: nowrap; }
.tool:hover { border-color: var(--accent); color: var(--ink); }
.tool.primary { background: var(--blue); border-color: var(--blue); color: #fff; }
.tool.primary:hover { background: #174fb0; color: #fff; }
.types { display: flex; gap: 5px; flex-wrap: wrap; margin-bottom: 8px; }
.tchip { appearance: none; font: inherit; font-size: 12px; font-weight: 650; padding: 3px 10px; border-radius: 999px; cursor: pointer; background: var(--surface-2); color: var(--ink-2); border: 1px solid transparent; white-space: nowrap; }
.tchip:hover { border-color: var(--accent); }
.tchip[aria-pressed="true"] { background: var(--accent); color: #fff; }
.tchip.d3 { background: #f3ecff; color: #4f22b8; }
.tchip.d3[aria-pressed="true"] { background: linear-gradient(135deg, #4f22b8, #d6246e); color: #fff; }
.chart { width: 100%; height: 390px; }
.chart.tall { height: 450px; }
.hint-3d { font-size: 11.5px; color: var(--muted); margin-top: 2px; min-height: 16px; }

/* section KPI cards */
.kpis.sec { margin: 0 0 16px; }
.kpis.sec .kpi { box-shadow: var(--shadow); }

/* insights */
.insights { background: linear-gradient(120deg, #fff6e5, #fdeef6 55%, #eef2ff); border: 1px solid var(--border); border-radius: var(--radius); padding: 15px 20px 16px; }
.insights h3 { font-size: 12px; letter-spacing: .08em; text-transform: uppercase; color: #a83a06; font-weight: 800; margin-bottom: 9px; }
.insights ul { margin: 0; padding: 0; list-style: none; display: grid; gap: 7px; }
.insights li { position: relative; padding-left: 20px; font-size: 13.5px; color: var(--ink-2); }
.insights li::before { content: ""; position: absolute; left: 2px; top: 7px; width: 8px; height: 8px; border-radius: 2px; background: linear-gradient(135deg, #d6246e, #f08a00); }
.insights li b { color: var(--ink); font-weight: 720; }

/* tables */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th, td { text-align: right; padding: 8px 10px; border-bottom: 1px solid var(--border); white-space: nowrap; }
th:first-child, td:first-child { text-align: left; }
thead th { font-size: 11px; letter-spacing: .03em; text-transform: uppercase; color: #fff; font-weight: 700; background: #1b3f86; position: sticky; top: 0; }
thead th:first-child { border-radius: 8px 0 0 0; }
thead th:last-child { border-radius: 0 8px 0 0; }
tbody tr:nth-child(even) { background: #f8fafe; }
tbody tr:hover { background: #eef3fd; }
td.num { font-variant-numeric: tabular-nums; font-weight: 600; }
td.lead { font-weight: 700; }
td.txt { text-align: left; }
th.txt { text-align: left; }
td.clip { max-width: 260px; overflow: hidden; text-overflow: ellipsis; }
tfoot td { font-weight: 800; border-top: 2px solid #1b3f86; border-bottom: 0; font-variant-numeric: tabular-nums; background: var(--surface-2); }
.swatch { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 8px; vertical-align: -1px; }
.chip { display: inline-block; font-size: 11px; font-weight: 700; padding: 1px 8px; border-radius: 20px; background: var(--surface-2); color: var(--ink-2); border: 1px solid var(--border); }
.rk { display: inline-flex; align-items: center; justify-content: center; width: 22px; height: 22px; border-radius: 6px; font-size: 11px; font-weight: 800; background: var(--surface-2); color: var(--muted); }
.rk.top1 { background: #f4c84a; color: #3a2c00; }
.rk.top2 { background: #cdd2d8; color: #2a2f36; }
.rk.top3 { background: #e0a878; color: #3a2200; }
.scroll-y { max-height: 390px; overflow-y: auto; }
.cellbar { position: relative; height: 6px; border-radius: 3px; background: var(--surface-2); min-width: 60px; overflow: hidden; }
.cellbar i { position: absolute; left: 0; top: 0; bottom: 0; background: linear-gradient(90deg, #1d5fd1, #d6246e); border-radius: 3px; }

/* brand deep-dive */
.chips { display: flex; flex-wrap: wrap; gap: 7px; margin-bottom: 14px; }
.brandchip { appearance: none; border: 1px solid var(--border); background: var(--surface); font: inherit; cursor: pointer; padding: 6px 11px; border-radius: 10px; display: flex; align-items: center; gap: 7px; font-weight: 650; font-size: 13px; color: var(--ink-2); }
.brandchip .swatch { margin: 0; }
.brandchip small { color: var(--muted); font-weight: 600; font-variant-numeric: tabular-nums; }
.brandchip[aria-pressed="true"] { border-color: var(--accent); color: var(--ink); background: var(--accent-soft); box-shadow: inset 0 0 0 1px var(--accent); }
.mini-stat { display: flex; gap: 24px; margin-bottom: 12px; flex-wrap: wrap; }
.mini-stat .v { font-size: 20px; font-weight: 770; display: block; font-variant-numeric: tabular-nums; }
.mini-stat .l { font-size: 11.5px; color: var(--muted); font-weight: 600; }
.sub-h { font-size: 11.5px; font-weight: 700; letter-spacing: .05em; text-transform: uppercase; color: var(--muted); margin: 0 0 8px; }

.notice { background: #fff; border: 1px solid var(--border); border-left: 4px solid var(--orange); border-radius: 10px; padding: 14px 18px; margin-top: 20px; }
.empty { padding: 36px; text-align: center; color: var(--muted); }

/* import dialog */
.modal { width: min(860px, calc(100vw - 24px)); max-height: calc(100vh - 32px); border: 0; border-radius: 18px; padding: 0; color: var(--ink); box-shadow: 0 30px 80px rgba(5, 15, 50, .4); }
.modal[open] { display: flex; flex-direction: column; }
.modal::backdrop { background: rgba(8, 20, 50, .55); }
.modal-head { display: flex; align-items: center; justify-content: space-between; padding: 15px 20px; color: #fff; background: linear-gradient(115deg, #0a1f55, #1647a8 60%, #5a2fc4); }
.modal-head h2 { font-size: 17px; }
.icon-btn { appearance: none; background: none; border: 0; color: #fff; font-size: 16px; cursor: pointer; padding: 4px 8px; border-radius: 6px; }
.icon-btn:hover { background: rgba(255, 255, 255, .18); }
.modal-body { padding: 16px 20px; overflow-y: auto; flex: 1; }
.modal-foot { display: flex; justify-content: flex-end; gap: 10px; padding: 12px 20px; border-top: 1px solid var(--border); }
.hint { font-size: 13.5px; color: var(--ink-2); margin: 0 0 12px; }
.file-drop { display: block; border: 2px dashed #b9c8e4; border-radius: 12px; padding: 16px; text-align: center; cursor: pointer; font-weight: 650; color: var(--blue); background: #f6f9ff; }
.file-drop:hover { border-color: var(--blue); }
.file-drop input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.file-drop:focus-within { outline: 2px solid var(--accent); outline-offset: 2px; }
.pv-sec { margin-top: 16px; }
.pv-sec h3 { font-size: 13.5px; margin-bottom: 7px; }
.pv-stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); gap: 8px; }
.pv-stat { background: var(--surface-2); border-radius: 10px; padding: 9px 12px; }
.pv-stat b { display: block; font-size: 17px; font-variant-numeric: tabular-nums; }
.pv-stat span { font-size: 11.5px; color: var(--muted); }
.map-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 9px 14px; }
.map-grid label { display: block; font-size: 12.5px; font-weight: 650; color: var(--ink-2); }
.map-grid select, .map-grid input { display: block; width: 100%; font: inherit; font-size: 13px; padding: 6px 8px; border: 1px solid var(--border); border-radius: 8px; margin-top: 3px; background: #fff; color: var(--ink); }
.map-grid label.need select { border-color: var(--critical); }
.alert { font-size: 13px; border-radius: 10px; padding: 9px 13px; margin-top: 10px; }
.alert.warn { background: #fff5e0; color: #6b4500; }
.alert.err { background: #fde8e8; color: #8a1f1f; }
.alert.ok { background: #e3f7ea; color: #14572c; }
.alert ul { margin: 5px 0 0; padding-left: 18px; }
.lower { color: var(--critical); font-weight: 700; }
tr.lower-row td { background: #fff1f1; }
details summary { cursor: pointer; font-weight: 650; font-size: 13px; }

.toast { position: fixed; left: 50%; bottom: 26px; transform: translate(-50%, 20px); background: #10203a; color: #fff; font-size: 13.5px; font-weight: 600; padding: 10px 18px; border-radius: 10px; box-shadow: 0 10px 28px rgba(0, 0, 0, .3); opacity: 0; pointer-events: none; transition: opacity .16s, transform .16s; z-index: 200; max-width: calc(100vw - 32px); }
.toast.show { opacity: 1; transform: translate(-50%, 0); }

@media (max-width: 960px) {
  .k4, .k5 { grid-template-columns: 1fr 1fr; }
  .g-2 { grid-template-columns: minmax(0, 1fr); }
  .chart { height: 340px; }
}
@media (max-width: 480px) { .wrap { padding: 0 16px; } .k-val { font-size: 23px; } }
@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }
@media print {
  @page { size: A4 landscape; margin: 9mm; }
  nav.tabs, .tools, .types, .hint-3d, .btn { display: none !important; }
  .hero, .kpi, thead th { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  body { background: #fff; }
  .wrap { max-width: 100%; padding: 0; }
  .card { break-inside: avoid; box-shadow: none; }
  .scroll-y, .table-wrap { max-height: none; overflow: visible; }
}
