:root {
  --bg: #0a0e15;
  --bg-soft: #0d121b;
  --surface: #121923;
  --surface-2: #171f2b;
  --surface-3: #1d2735;
  --surface-4: #243043;
  --border: #263244;
  --border-soft: #1d2735;
  --text: #e9eef6;
  --strong: #ffffff;
  --muted: #9ba7b8;
  --muted-2: #718096;
  --violet: #7c88ff;
  --violet-2: #5e6be6;
  --violet-soft: rgba(124, 136, 255, 0.13);
  --green: #54d5a8;
  --green-soft: rgba(84, 213, 168, 0.12);
  --amber: #f3b85f;
  --amber-soft: rgba(243, 184, 95, 0.12);
  --blue: #64b5f6;
  --blue-soft: rgba(100, 181, 246, 0.12);
  --red: #ff7c8b;
  --red-soft: rgba(255, 124, 139, 0.12);
  --sidebar: #070a0f;
  --shadow: 0 18px 50px rgba(0, 0, 0, 0.22);
  --radius: 14px;
  --radius-sm: 10px;
  color-scheme: dark;
}

html[data-theme="light"] {
  --bg: #f2f5f9;
  --bg-soft: #edf1f6;
  --surface: #ffffff;
  --surface-2: #f8fafc;
  --surface-3: #f0f3f7;
  --surface-4: #e8edf4;
  --border: #d7deea;
  --border-soft: #e8edf3;
  --text: #263143;
  --strong: #111827;
  --muted: #667085;
  --muted-2: #98a2b3;
  --violet: #5967e8;
  --violet-2: #4654d2;
  --violet-soft: rgba(89, 103, 232, 0.10);
  --green: #16855f;
  --green-soft: rgba(22, 133, 95, 0.10);
  --amber: #b36d0f;
  --amber-soft: rgba(179, 109, 15, 0.10);
  --blue: #2879bd;
  --blue-soft: rgba(40, 121, 189, 0.10);
  --red: #c94a5a;
  --red-soft: rgba(201, 74, 90, 0.10);
  --sidebar: #111722;
  --shadow: 0 10px 30px rgba(16, 24, 40, 0.08);
  color-scheme: light;
}

* { box-sizing: border-box; }
html { background: var(--bg); }
body {
  margin: 0;
  min-height: 100vh;
  background:
    radial-gradient(circle at 80% -10%, rgba(124,136,255,.07), transparent 30%),
    var(--bg);
  color: var(--text);
  font-family: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", "Yu Gothic UI", "Yu Gothic", "Hiragino Kaku Gothic ProN", sans-serif;
  font-size: 13px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}
button, input, select, textarea { font: inherit; }
button { cursor: pointer; }
button:disabled { cursor: not-allowed; opacity: .55; }
button:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible {
  outline: 2px solid var(--violet);
  outline-offset: 2px;
}
.icon { width: 18px; height: 18px; display: inline-grid; place-items: center; flex: 0 0 auto; }
.icon svg { width: 100%; height: 100%; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }

.app-shell { min-height: 100vh; display: grid; grid-template-columns: 236px minmax(0, 1fr); }
.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  padding: 18px 14px 16px;
  background: linear-gradient(180deg, #080b11 0%, #090d14 100%);
  border-right: 1px solid #18202d;
  display: flex;
  flex-direction: column;
  z-index: 40;
}
.brand-row { display: flex; align-items: center; gap: 11px; padding: 4px 8px 22px; }
.brand-logo {
  width: 40px; height: 40px; border-radius: 12px; display: grid; place-items: center;
  color: #fff; font-size: 20px; font-weight: 900; letter-spacing: -.03em;
  background: linear-gradient(135deg, #8994ff 0%, #5d69df 65%, #4551c5 100%);
  box-shadow: 0 12px 30px rgba(91, 105, 224, .28), inset 0 1px 0 rgba(255,255,255,.16);
}
.brand-row strong { display: block; color: #fff; font-size: 14px; letter-spacing: .08em; }
.brand-row span { display: block; margin-top: 2px; color: #68758a; font-size: 9px; letter-spacing: .15em; font-weight: 800; }
.sidebar nav { overflow: auto; scrollbar-width: none; }
.sidebar nav::-webkit-scrollbar { display: none; }
.nav-group { margin-bottom: 18px; }
.nav-group-title { display: block; padding: 0 11px 7px; color: #526074; font-size: 9px; font-weight: 800; letter-spacing: .16em; }
.nav-item {
  width: 100%; height: 39px; border: 1px solid transparent; border-radius: 9px; padding: 0 10px;
  display: flex; align-items: center; gap: 10px; background: transparent; color: #a8b2c2; text-align: left;
  font-size: 12px; font-weight: 650; transition: .15s ease;
}
.nav-item .icon { width: 17px; height: 17px; color: #718096; }
.nav-item:hover { background: #121a26; color: #eef2f8; }
.nav-item:hover .icon { color: #aab4ff; }
.nav-item.active {
  background: linear-gradient(90deg, rgba(103,116,235,.22), rgba(103,116,235,.11));
  border-color: rgba(124,136,255,.18); color: #fff; box-shadow: inset 3px 0 0 #7c88ff;
}
.nav-item.active .icon { color: #aab3ff; }
.sidebar-bottom { margin-top: auto; display: grid; gap: 9px; padding: 8px 3px 0; }
.system-card { border: 1px solid #1b2634; border-radius: 10px; padding: 10px; display: flex; align-items: flex-start; gap: 9px; background: #0d131c; }
.system-dot { width: 8px; height: 8px; border-radius: 50%; background: #4fd0a3; box-shadow: 0 0 0 4px rgba(79,208,163,.08); margin-top: 4px; }
.system-card strong { display: block; color: #dce4ef; font-size: 10px; }
.system-card span { display: block; margin-top: 3px; color: #657287; font-size: 9px; }
.data-period { padding: 3px 10px 0; display: flex; align-items: center; justify-content: space-between; color: #657287; font-size: 9px; }
.data-period strong { color: #9ea8b9; font-size: 9px; }

main { min-width: 0; }
.topbar {
  height: 64px; position: sticky; top: 0; z-index: 30; padding: 0 24px;
  display: flex; align-items: center; justify-content: space-between;
  background: color-mix(in srgb, var(--surface) 92%, transparent); border-bottom: 1px solid var(--border);
  backdrop-filter: blur(16px);
}
.topbar-context { display: flex; align-items: center; gap: 10px; min-width: 0; }
.topbar-context > span { width: 32px; height: 32px; display: grid; place-items: center; color: var(--violet); background: var(--violet-soft); border-radius: 9px; }
.topbar-context strong { display: block; color: var(--strong); font-size: 12px; }
.topbar-context small { display: block; color: var(--muted-2); font-size: 9px; margin-top: 2px; }
.top-actions { display: flex; align-items: center; gap: 8px; }
.icon-button, .theme-button {
  height: 34px; border: 1px solid var(--border); border-radius: 9px; background: var(--surface-2); color: var(--muted);
  display: inline-flex; align-items: center; justify-content: center; transition: .15s ease;
}
.icon-button { width: 34px; padding: 0; }
.theme-button { padding: 0 10px; gap: 7px; font-size: 10px; font-weight: 750; }
.icon-button:hover, .theme-button:hover { background: var(--surface-3); color: var(--strong); border-color: color-mix(in srgb, var(--violet) 45%, var(--border)); }
.icon-button.spinning .icon { animation: spin .8s linear infinite; }
.engine-badge { height: 30px; padding: 0 9px; display: inline-flex; align-items: center; gap: 5px; border-radius: 999px; background: var(--green-soft); color: var(--green); border: 1px solid color-mix(in srgb, var(--green) 24%, var(--border)); font-size: 9px; font-weight: 800; }
.engine-badge .icon { width: 13px; height: 13px; }

.content { width: 100%; max-width: 1580px; margin: 0 auto; padding: 24px 28px 46px; }
.page-heading { margin-bottom: 20px; display: flex; justify-content: space-between; align-items: flex-end; gap: 20px; }
.eyebrow { margin-bottom: 5px; color: var(--violet); font-size: 9px; font-weight: 900; letter-spacing: .18em; }
.page-heading h1 { margin: 0; color: var(--strong); font-size: clamp(22px, 2vw, 28px); letter-spacing: -.035em; line-height: 1.18; }
.page-heading p { margin: 7px 0 0; color: var(--muted); font-size: 12px; }
.page-meta { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 7px; }
.meta-pill, .soft-badge { display: inline-flex; align-items: center; gap: 6px; border: 1px solid var(--border); background: var(--surface-2); color: var(--muted); border-radius: 999px; padding: 6px 9px; font-size: 9px; font-weight: 750; white-space: nowrap; }
.meta-pill .icon { width: 13px; height: 13px; }
.meta-pill.success { color: var(--green); background: var(--green-soft); }
.meta-pill.warning { color: var(--amber); background: var(--amber-soft); }

.hero-strip {
  margin-bottom: 14px; padding: 17px 18px; border: 1px solid rgba(124,136,255,.20); border-radius: var(--radius);
  display: flex; align-items: center; justify-content: space-between; gap: 18px;
  background: linear-gradient(120deg, rgba(124,136,255,.13), rgba(100,181,246,.05) 52%, var(--surface) 100%);
  box-shadow: var(--shadow);
}
.hero-strip strong { display: block; margin-top: 4px; color: var(--strong); font-size: 18px; letter-spacing: -.02em; }
.hero-strip p { margin: 4px 0 0; color: var(--muted); font-size: 10px; }
.hero-kicker { color: #98a2ff; font-size: 8px; font-weight: 900; letter-spacing: .18em; }
.primary-action {
  min-height: 38px; border: 0; border-radius: 10px; padding: 0 13px; display: inline-flex; align-items: center; gap: 7px;
  background: linear-gradient(135deg, #7380f4, #5966da); color: #fff; font-size: 10px; font-weight: 800;
  box-shadow: 0 8px 20px rgba(87,101,218,.22); transition: transform .15s ease, filter .15s ease;
}
.primary-action:hover { transform: translateY(-1px); filter: brightness(1.05); }
.primary-action .icon { width: 15px; height: 15px; }
.primary-action.loading .icon:first-child { animation: spin .8s linear infinite; }

.metric-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 11px; margin-bottom: 14px; }
.metric-card {
  position: relative; min-height: 126px; padding: 14px 15px 13px; overflow: hidden;
  background: linear-gradient(180deg, var(--surface), color-mix(in srgb, var(--surface-2) 65%, var(--surface)));
  border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow);
}
.metric-card::after { content: ""; position: absolute; right: -22px; top: -28px; width: 90px; height: 90px; border-radius: 50%; opacity: .48; filter: blur(1px); }
.metric-violet::after { background: var(--violet-soft); }
.metric-green::after { background: var(--green-soft); }
.metric-amber::after { background: var(--amber-soft); }
.metric-blue::after { background: var(--blue-soft); }
.metric-red::after { background: var(--red-soft); }
.metric-top { min-height: 28px; display: flex; align-items: center; justify-content: space-between; }
.metric-icon { width: 28px; height: 28px; border-radius: 8px; display: grid; place-items: center; }
.metric-icon .icon { width: 15px; height: 15px; }
.metric-violet .metric-icon { color: var(--violet); background: var(--violet-soft); }
.metric-green .metric-icon { color: var(--green); background: var(--green-soft); }
.metric-amber .metric-icon { color: var(--amber); background: var(--amber-soft); }
.metric-blue .metric-icon { color: var(--blue); background: var(--blue-soft); }
.metric-red .metric-icon { color: var(--red); background: var(--red-soft); }
.metric-delta { padding: 3px 6px; border-radius: 999px; font-size: 9px; font-weight: 800; }
.metric-delta.up { color: var(--green); background: var(--green-soft); }
.metric-delta.down { color: var(--red); background: var(--red-soft); }
.metric-label { margin-top: 8px; color: var(--muted); font-size: 9px; font-weight: 750; }
.metric-value { margin-top: 5px; color: var(--strong); font-size: clamp(18px, 2vw, 24px); font-weight: 850; line-height: 1.15; letter-spacing: -.03em; overflow-wrap: anywhere; }
.metric-note { margin-top: 7px; color: var(--muted-2); font-size: 9px; }

.panel, .table-shell, .compare-card, .setting-card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow);
}
.panel { overflow: hidden; margin-bottom: 14px; }
.panel-head { min-height: 52px; padding: 11px 14px; display: flex; align-items: center; justify-content: space-between; gap: 12px; background: var(--surface-2); border-bottom: 1px solid var(--border); }
.panel-title-wrap strong { display: block; color: var(--strong); font-size: 12px; }
.panel-title-wrap span { display: block; margin-top: 3px; color: var(--muted); font-size: 9px; }
.panel-head-right { display: flex; align-items: center; gap: 7px; }
.soft-badge { padding: 4px 7px; font-size: 8px; }
.dashboard-grid { display: grid; grid-template-columns: minmax(0, 1.6fr) minmax(280px, .8fr); gap: 11px; margin-bottom: 14px; }
.dashboard-grid .panel { margin-bottom: 0; }
.span-2 { min-width: 0; }
.chart-body { padding: 14px 14px 10px; min-height: 210px; }
.chart-body.large { min-height: 240px; }
.mini-chart { height: 170px; display: grid; grid-template-columns: repeat(12, minmax(24px, 1fr)); align-items: end; gap: 7px; padding-top: 8px; }
.mini-col { min-width: 0; height: 100%; display: flex; flex-direction: column; align-items: center; justify-content: flex-end; gap: 6px; }
.mini-bar-wrap { width: min(22px, 65%); flex: 1; display: flex; align-items: flex-end; justify-content: center; }
.mini-bar { width: 100%; min-height: 4px; border-radius: 6px 6px 2px 2px; background: linear-gradient(180deg, #8a95ff 0%, #5a68da 100%); box-shadow: 0 0 18px rgba(105,119,235,.15); transition: filter .15s ease, transform .15s ease; }
.mini-col:hover .mini-bar { filter: brightness(1.16); transform: scaleX(1.08); }
.mini-col span { color: var(--muted-2); font-size: 8px; white-space: nowrap; }
.ranking-list { padding: 8px 13px 13px; }
.rank-row { display: flex; align-items: center; gap: 10px; padding: 9px 0; border-bottom: 1px solid var(--border-soft); }
.rank-row:last-child { border-bottom: 0; }
.rank-no { width: 23px; color: var(--muted-2); font-size: 9px; font-weight: 850; }
.rank-main { min-width: 0; flex: 1; }
.rank-main > div:first-child { display: flex; justify-content: space-between; gap: 10px; }
.rank-main strong { max-width: 56%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--strong); font-size: 10px; }
.rank-main span { color: var(--text); font-size: 9px; font-variant-numeric: tabular-nums; }
.rank-track { height: 4px; margin-top: 6px; background: var(--surface-3); border-radius: 999px; overflow: hidden; }
.rank-track div { height: 100%; border-radius: inherit; background: linear-gradient(90deg, #6c78eb, #8792ff); }

.quick-grid { padding: 11px; display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.quick-grid button {
  min-height: 78px; border: 1px solid var(--border); border-radius: 11px; padding: 11px 12px;
  display: grid; grid-template-columns: 32px minmax(0, 1fr) 18px; gap: 10px; align-items: center;
  background: var(--surface-2); color: var(--text); text-align: left; transition: .15s ease;
}
.quick-grid button:hover { transform: translateY(-1px); border-color: color-mix(in srgb, var(--violet) 45%, var(--border)); background: var(--surface-3); }
.quick-icon { width: 32px; height: 32px; border-radius: 9px; display: grid; place-items: center; color: var(--violet); background: var(--violet-soft); }
.quick-icon .icon { width: 16px; height: 16px; }
.quick-copy { min-width: 0; }
.quick-copy strong { display: block; color: var(--strong); font-size: 11px; }
.quick-copy span { display: block; margin-top: 4px; color: var(--muted); font-size: 9px; line-height: 1.35; }
.quick-arrow { color: var(--muted-2); }
.quick-arrow .icon { width: 14px; height: 14px; }

.filter-card {
  margin-bottom: 14px; min-height: 68px; padding: 10px 12px; display: flex; align-items: center; gap: 16px;
  border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); box-shadow: var(--shadow);
}
.filter-label { min-width: 68px; padding-right: 12px; border-right: 1px solid var(--border); color: var(--muted-2); font-size: 9px; font-weight: 850; letter-spacing: .08em; }
.filter-controls { flex: 1; display: flex; flex-wrap: wrap; gap: 10px; align-items: flex-end; }
.filter-controls.grow { align-items: flex-end; }
.filter-controls label, .import-meta label { display: flex; flex-direction: column; gap: 4px; }
.filter-controls label span, .import-meta label span { color: var(--muted); font-size: 9px; font-weight: 750; }
.filter-controls label.grow { flex: 1; }
.filter-controls label.grow input { width: 100%; }
.filter-note { min-height: 35px; padding: 0 10px; display: flex; flex-direction: column; justify-content: center; border-left: 1px solid var(--border); }
.filter-note span { color: var(--muted-2); font-size: 8px; }
.filter-note strong { margin-top: 2px; color: var(--text); font-size: 9px; }
select, input {
  min-width: 160px; height: 34px; padding: 0 9px; border: 1px solid var(--border); border-radius: 8px;
  background: var(--surface-2); color: var(--text); outline: none; font-size: 10px; transition: border-color .15s ease, box-shadow .15s ease;
}
select:hover, input:hover { border-color: color-mix(in srgb, var(--violet) 34%, var(--border)); }
select:focus, input:focus, textarea:focus { border-color: var(--violet); box-shadow: 0 0 0 3px rgba(124,136,255,.10); }
.number-input { position: relative; }
.number-input input { padding-right: 25px; width: 110px; min-width: 110px; }
.number-input b { position: absolute; right: 9px; top: 50%; transform: translateY(-50%); color: var(--muted); font-size: 9px; }
.ghost-button { height: 34px; border: 1px solid var(--border); border-radius: 8px; padding: 0 10px; background: var(--surface-2); color: var(--muted); font-size: 9px; font-weight: 750; }
.ghost-button:hover { color: var(--strong); background: var(--surface-3); }

.table-shell { overflow: hidden; margin-bottom: 14px; }
.panel > .table-shell { border: 0; border-radius: 0; box-shadow: none; margin: 0; }
.table-titlebar { min-height: 43px; padding: 0 13px; display: flex; align-items: center; justify-content: space-between; border-bottom: 1px solid var(--border); background: var(--surface-2); }
.table-titlebar strong { color: var(--strong); font-size: 10px; }
.table-titlebar span { color: var(--muted); font-size: 9px; }
.table-scroll { width: 100%; overflow: auto; max-height: 68vh; scrollbar-color: var(--surface-4) transparent; }
table { width: 100%; border-collapse: separate; border-spacing: 0; white-space: nowrap; font-size: 10px; }
th {
  position: sticky; top: 0; z-index: 5; padding: 9px 10px; background: var(--surface-2); color: var(--muted);
  border-bottom: 1px solid var(--border); text-align: left; font-size: 9px; font-weight: 800; letter-spacing: .01em;
}
td { padding: 8px 10px; color: var(--text); border-bottom: 1px solid var(--border-soft); vertical-align: middle; }
tbody tr:nth-child(even) td { background: color-mix(in srgb, var(--surface-2) 54%, transparent); }
tbody tr:hover td { background: var(--surface-3); }
tbody tr:last-child td { border-bottom: 0; }
.right { text-align: right; font-variant-numeric: tabular-nums; }
.table-shell.compact td { padding-top: 7px; padding-bottom: 7px; }
.sticky-first th:first-child, .sticky-first td:first-child { position: sticky; left: 0; z-index: 4; }
.sticky-first th:first-child { z-index: 7; background: var(--surface-2); }
.sticky-first tbody tr td:first-child { background: var(--surface); }
.sticky-first tbody tr:nth-child(even) td:first-child { background: var(--surface-2); }
.sticky-first tbody tr:hover td:first-child { background: var(--surface-3); }
.number-highlight { color: #aab3ff; font-weight: 800; font-variant-numeric: tabular-nums; }
.number-highlight.warm { color: var(--amber); }
.count-badge, .priority-badge, .streak-badge, .month-badge, .status-chip {
  display: inline-flex; align-items: center; justify-content: center; border-radius: 999px; font-size: 8px; font-weight: 850; white-space: nowrap;
}
.count-badge { min-width: 24px; padding: 3px 6px; color: var(--violet); background: var(--violet-soft); }
.priority-badge { width: 22px; height: 22px; color: var(--muted); background: var(--surface-3); }
.priority-badge.top { color: var(--amber); background: var(--amber-soft); }
.streak-badge { padding: 3px 7px; color: var(--green); background: var(--green-soft); }
.month-badge { padding: 3px 7px; color: var(--amber); background: var(--amber-soft); }
.status-chip { gap: 4px; padding: 4px 7px; color: var(--muted); background: var(--surface-3); }
.status-chip.success { color: var(--green); background: var(--green-soft); }
.status-chip .icon { width: 11px; height: 11px; }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; color: var(--muted); }
.empty-state { padding: 36px 20px; display: grid; justify-items: center; text-align: center; }
.empty-icon { width: 38px; height: 38px; border-radius: 50%; display: grid; place-items: center; color: var(--muted-2); background: var(--surface-2); }
.empty-icon .icon { width: 18px; height: 18px; }
.empty-state strong { margin-top: 10px; color: var(--text); font-size: 11px; }
.empty-state span { margin-top: 3px; color: var(--muted-2); font-size: 9px; }

.chip-row { margin: -3px 0 14px; padding: 9px 11px; display: flex; flex-wrap: wrap; align-items: center; gap: 6px; border: 1px solid var(--border); border-radius: 10px; background: var(--surface); }
.chip-label { margin-right: 4px; color: var(--muted-2); font-size: 8px; font-weight: 800; letter-spacing: .08em; }
.data-chip, .brand-pills span { padding: 4px 7px; border-radius: 999px; background: var(--surface-3); color: var(--muted); font-size: 8px; }
.data-chip b, .brand-pills b { margin-left: 4px; color: var(--strong); }
.insight-callout { margin-bottom: 14px; padding: 10px 12px; display: flex; gap: 10px; align-items: flex-start; border: 1px solid color-mix(in srgb, var(--amber) 25%, var(--border)); border-radius: 10px; background: var(--amber-soft); }
.insight-callout > div:first-child { color: var(--amber); }
.insight-callout .icon { width: 16px; height: 16px; }
.insight-callout strong { display: block; color: var(--strong); font-size: 9px; }
.insight-callout span { display: block; margin-top: 2px; color: var(--muted); font-size: 9px; }

.compare-grid { display: grid; grid-template-columns: repeat(3, minmax(340px, 1fr)); gap: 11px; overflow-x: auto; padding-bottom: 2px; }
.compare-card { min-width: 0; overflow: hidden; }
.compare-card.current { border-color: rgba(124,136,255,.35); box-shadow: 0 14px 40px rgba(87,101,218,.12); }
.compare-head { min-height: 76px; padding: 12px 13px; display: flex; justify-content: space-between; gap: 12px; align-items: flex-start; background: var(--surface-2); border-bottom: 1px solid var(--border); }
.compare-label { display: block; color: var(--violet); font-size: 7px; font-weight: 900; letter-spacing: .15em; }
.compare-head strong { display: block; margin-top: 4px; color: var(--strong); font-size: 14px; }
.compare-head small { display: block; margin-top: 2px; color: var(--muted); font-size: 8px; }
.compare-total { text-align: right; }
.compare-total span { display: block; color: var(--muted-2); font-size: 7px; }
.compare-total b { display: block; margin-top: 4px; color: var(--text); font-size: 10px; }
.compare-card .table-shell { border: 0; border-radius: 0; box-shadow: none; margin: 0; }
.compare-card .table-scroll { max-height: 460px; }
.brand-pills { min-height: 45px; padding: 9px 10px; display: flex; flex-wrap: wrap; gap: 5px; border-top: 1px solid var(--border); background: var(--surface-2); }

.tiny-meter { width: 90px; height: 5px; border-radius: 999px; overflow: hidden; background: var(--surface-3); }
.tiny-meter span { display: block; height: 100%; border-radius: inherit; background: linear-gradient(90deg, #6573e6, #8d97ff); }
.section-summary-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; margin-bottom: 14px; }
.section-summary { min-height: 82px; padding: 12px 14px; border: 1px solid var(--border); border-radius: 11px; background: var(--surface); }
.section-summary span { display: block; font-size: 8px; font-weight: 900; letter-spacing: .14em; }
.section-summary strong { display: inline-block; margin-top: 6px; font-size: 22px; color: var(--strong); }
.section-summary small { margin-left: 8px; color: var(--muted); font-size: 9px; }
.section-summary.violet span { color: var(--violet); }
.section-summary.green span { color: var(--green); }

.settings-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 11px; margin-bottom: 14px; }
.setting-card { padding: 13px; }
.setting-head { display: flex; align-items: center; gap: 9px; padding-bottom: 10px; border-bottom: 1px solid var(--border); }
.setting-icon { width: 29px; height: 29px; border-radius: 8px; display: grid; place-items: center; color: var(--violet); background: var(--violet-soft); }
.setting-icon .icon { width: 15px; height: 15px; }
.setting-head strong { color: var(--strong); font-size: 11px; }
.setting-row { min-height: 38px; display: flex; align-items: center; justify-content: space-between; gap: 15px; border-bottom: 1px solid var(--border-soft); }
.setting-row:last-child { border-bottom: 0; }
.setting-row span { color: var(--muted); font-size: 9px; }
.setting-row b { color: var(--text); font-size: 9px; }
.verification-banner { padding: 12px 13px; display: flex; gap: 10px; align-items: flex-start; border: 1px solid color-mix(in srgb, var(--green) 25%, var(--border)); border-radius: 11px; background: var(--green-soft); }
.verification-banner > div:first-child { color: var(--green); }
.verification-banner .icon { width: 17px; height: 17px; }
.verification-banner strong { display: block; color: var(--strong); font-size: 10px; }
.verification-banner span { display: block; margin-top: 3px; color: var(--muted); font-size: 9px; line-height: 1.55; }

.step-strip { margin-bottom: 14px; display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.step { min-height: 60px; padding: 10px 11px; display: flex; align-items: center; gap: 9px; border: 1px solid var(--border); border-radius: 10px; background: var(--surface); }
.step > span { width: 25px; height: 25px; border-radius: 50%; display: grid; place-items: center; background: var(--surface-3); color: var(--muted); font-size: 9px; font-weight: 900; }
.step.active > span { color: #fff; background: var(--violet-2); }
.step strong { display: block; color: var(--strong); font-size: 9px; }
.step small { display: block; color: var(--muted-2); font-size: 8px; margin-top: 2px; }
.import-panel { overflow: hidden; }
.import-meta { padding: 13px; display: grid; grid-template-columns: repeat(3, minmax(160px, 1fr)); gap: 10px; }
.import-meta input, .import-meta select { width: 100%; }
.paste-area { width: 100%; min-height: 330px; resize: vertical; padding: 13px; border: 0; border-bottom: 1px solid var(--border); outline: 0; background: #070b11; color: #eaf0f7; font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 10px; line-height: 1.55; }
html[data-theme="light"] .paste-area { background: #fbfcfe; color: #1f2937; }
.import-preview { min-height: 40px; padding: 8px 12px; display: flex; align-items: center; gap: 8px; background: var(--surface-2); border-bottom: 1px solid var(--border); color: var(--muted); }
.import-preview > span { color: var(--blue); }
.import-preview .icon { width: 15px; height: 15px; }
.import-preview p { margin: 0; font-size: 9px; }
.import-preview.ready { background: var(--green-soft); color: var(--green); }
.import-preview.ready p { color: var(--text); }
.import-actions { min-height: 58px; padding: 10px 12px; display: flex; align-items: center; gap: 12px; }
.import-actions > span { color: var(--muted); font-size: 9px; }

.loading-page, .error-page { min-height: 100vh; display: grid; place-items: center; background: radial-gradient(circle at 50% 15%, rgba(124,136,255,.12), transparent 28%), var(--bg); }
.loading-page { align-content: center; justify-items: center; gap: 7px; color: var(--muted); }
.loading-mark { width: 48px; height: 48px; border-radius: 14px; display: grid; place-items: center; margin-bottom: 5px; background: linear-gradient(135deg, #808cff, #5664dc); color: #fff; font-size: 24px; font-weight: 900; box-shadow: 0 12px 30px rgba(91,105,224,.24); }
.loading-spinner { width: 22px; height: 22px; border-radius: 50%; border: 2px solid var(--surface-3); border-top-color: var(--violet); animation: spin .8s linear infinite; }
.loading-page strong { color: var(--strong); font-size: 12px; }
.loading-page span { font-size: 9px; }
.error-card { width: min(440px, calc(100vw - 30px)); padding: 24px; text-align: center; border: 1px solid var(--border); border-radius: 14px; background: var(--surface); box-shadow: var(--shadow); }
.error-mark { width: 42px; height: 42px; margin: 0 auto 12px; border-radius: 50%; display: grid; place-items: center; background: var(--red-soft); color: var(--red); font-size: 20px; font-weight: 900; }
.error-card h1 { margin: 0; color: var(--strong); font-size: 16px; }
.error-card p { margin: 8px 0 16px; color: var(--muted); font-size: 10px; overflow-wrap: anywhere; }
.error-card button { height: 35px; border: 0; border-radius: 8px; padding: 0 13px; background: var(--violet-2); color: #fff; font-size: 10px; font-weight: 800; }

@keyframes spin { to { transform: rotate(360deg); } }

@media (max-width: 1180px) {
  .metric-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .dashboard-grid { grid-template-columns: 1fr; }
  .quick-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .settings-grid { grid-template-columns: 1fr; }
}

@media (max-width: 820px) {
  .app-shell { grid-template-columns: 1fr; }
  .sidebar { position: static; height: auto; padding: 11px 10px; }
  .brand-row { padding-bottom: 10px; }
  .sidebar nav { display: flex; gap: 6px; overflow-x: auto; padding-bottom: 3px; }
  .nav-group { display: contents; }
  .nav-group-title { display: none; }
  .nav-item { width: auto; min-width: max-content; padding: 0 10px; box-shadow: none; }
  .nav-item.active { box-shadow: inset 0 -2px 0 #7c88ff; }
  .sidebar-bottom { display: none; }
  .topbar { position: sticky; height: 56px; padding: 0 12px; }
  .topbar-context small { display: none; }
  .content { padding: 18px 12px 32px; }
  .page-heading { align-items: flex-start; flex-direction: column; gap: 10px; }
  .page-meta { justify-content: flex-start; }
  .hero-strip { align-items: flex-start; flex-direction: column; }
  .hero-strip .primary-action { width: 100%; justify-content: center; }
  .compare-grid { grid-template-columns: repeat(3, minmax(310px, 1fr)); }
  .import-meta { grid-template-columns: 1fr; }
}

@media (max-width: 560px) {
  .metric-grid, .section-summary-grid, .step-strip { grid-template-columns: 1fr; }
  .quick-grid { grid-template-columns: 1fr; }
  .filter-card { align-items: stretch; flex-direction: column; gap: 8px; }
  .filter-label { border-right: 0; border-bottom: 1px solid var(--border); padding: 0 0 7px; }
  .filter-controls { flex-direction: column; align-items: stretch; }
  .filter-controls label, .filter-controls select, .filter-controls input { width: 100%; }
  .filter-note { border-left: 0; border-top: 1px solid var(--border); padding: 7px 0 0; }
  .top-actions .engine-badge { display: none; }
  .theme-button span { display: none; }
  .mini-chart { gap: 4px; }
  .mini-col span { font-size: 7px; transform: rotate(-40deg); transform-origin: center; margin-top: 6px; }
  .chart-body { padding-bottom: 18px; }
  .page-heading h1 { font-size: 22px; }
}

/* =========================================================
   Spreadsheet-faithful analysis surfaces
   Keep the polished application shell, but preserve the
   original spreadsheet data shapes, column order and blocks.
   ========================================================= */

.sheet-horizontal,
.analysis-sheet-horizontal,
.other-years-scroll,
.month-blocks-scroll,
.sheet-table-scroll {
  overflow: auto;
  scrollbar-color: #596777 transparent;
  scrollbar-width: thin;
}

.sheet-horizontal {
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--panel);
  box-shadow: var(--shadow);
  padding: 12px;
}

.sheet-horizontal-inner {
  display: flex;
  align-items: flex-start;
  gap: 14px;
  width: max-content;
}

.sheet-block {
  flex: 0 0 820px;
  width: 820px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
}

.sheet-title-row {
  display: grid;
  grid-template-columns: 150px 185px 1fr;
  min-height: 44px;
  align-items: center;
  border-bottom: 1px solid var(--border);
  background: var(--panel2);
  color: var(--strong);
}

.sheet-title-row > * {
  padding: 9px 10px;
  border-right: 1px solid var(--border);
  font-size: 12px;
}

.sheet-title-row span {
  white-space: pre-line;
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
}

.sheet-summary-labels,
.sheet-summary-values {
  display: grid;
  grid-template-columns: 120px 120px 130px 90px 120px 120px 150px 54px;
  min-width: 1004px;
  text-align: center;
  font-size: 10px;
}

.sheet-summary-labels {
  background: color-mix(in srgb, var(--panel2) 78%, transparent);
  color: var(--muted);
  font-weight: 800;
}

.sheet-summary-values {
  color: var(--strong);
  font-weight: 800;
  font-variant-numeric: tabular-nums;
}

.sheet-summary-labels span,
.sheet-summary-values span {
  min-height: 27px;
  display: grid;
  place-items: center;
  padding: 5px 7px;
  border-right: 1px solid var(--border2);
  border-bottom: 1px solid var(--border2);
}

.sheet-table {
  width: max-content;
  min-width: 100%;
  border-collapse: collapse;
  white-space: nowrap;
  font-size: 10.5px;
  color: var(--text);
}

.sheet-table th {
  background: #2f6b50 !important;
  color: #fff !important;
  font-weight: 800;
  text-align: center;
  border: 1px solid color-mix(in srgb, #2f6b50 70%, #ffffff 20%);
  padding: 8px 8px;
  line-height: 1.2;
  position: sticky;
  top: 0;
  z-index: 2;
}

.sheet-table td {
  border: 1px solid var(--border2);
  padding: 7px 8px;
  background: var(--panel);
  vertical-align: middle;
}

.sheet-table tbody tr:nth-child(even) td {
  background: var(--panel2);
}

.sheet-table tbody tr:hover td {
  background: var(--panel3);
}

.sheet-table .right { text-align: right; font-variant-numeric: tabular-nums; }
.sheet-table .center { text-align: center; }

.buyer-shape th:nth-child(1), .buyer-shape td:nth-child(1) { min-width: 120px; }
.buyer-shape th:nth-child(2), .buyer-shape td:nth-child(2) { min-width: 135px; }
.buyer-shape th:nth-child(3), .buyer-shape td:nth-child(3) { min-width: 185px; }
.buyer-shape th:nth-child(4), .buyer-shape td:nth-child(4) { min-width: 85px; }
.buyer-shape th:nth-child(5), .buyer-shape td:nth-child(5) { min-width: 105px; }
.buyer-shape th:nth-child(6), .buyer-shape td:nth-child(6) { min-width: 95px; }
.buyer-shape th:nth-child(7), .buyer-shape td:nth-child(7) { min-width: 145px; max-width: 145px; overflow: hidden; text-overflow: ellipsis; }
.buyer-shape th:nth-child(8), .buyer-shape td:nth-child(8) { min-width: 54px; }

.category-cell {
  display: block;
  margin: -7px -8px;
  padding: 7px 8px;
  color: #101820;
  min-height: 28px;
}

.sheet-link {
  color: #5aa7ff;
  text-decoration: underline;
  text-underline-offset: 2px;
}

html[data-theme="light"] .sheet-link { color: #1f5fbf; }

.sheet-summary-gap { height: 30px; }
.brand-summary { width: 260px; min-width: 260px; margin: 0 0 12px 0; }
.brand-summary th:first-child, .brand-summary td:first-child { min-width: 180px; }
.brand-summary th:last-child, .brand-summary td:last-child { min-width: 70px; }

.sheet-condition-bar {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 10px 12px;
  margin-bottom: 12px;
  border: 1px solid var(--border);
  border-radius: 9px;
  background: var(--panel);
  font-size: 11px;
}
.sheet-condition-bar strong { margin-right: 15px; color: var(--strong); }
.sheet-condition-bar b { min-width: 52px; padding: 5px 8px; border-radius: 6px; background: var(--panel2); text-align: center; }

/* Analysis sheet: exactly three 7-col blocks + 2-col brand summaries */
.analysis-sheet-horizontal {
  display: flex;
  align-items: flex-start;
  gap: 14px;
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

.analysis-sheet-block {
  flex: 0 0 1020px;
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
  background: var(--panel);
}

.analysis-sheet-title {
  display: grid;
  grid-template-columns: 140px 190px 1fr 42px;
  min-height: 38px;
  align-items: center;
  background: var(--panel2);
  border-bottom: 1px solid var(--border);
}
.analysis-sheet-title > * { padding: 8px 10px; border-right: 1px solid var(--border); font-size: 11px; }
.analysis-sheet-title .checkbox-off { text-align: center; font-size: 16px; color: var(--muted); }
.analysis-sheet-body { display: grid; grid-template-columns: minmax(0, 1fr) 210px; gap: 18px; align-items: start; }
.analysis-shape th:nth-child(1), .analysis-shape td:nth-child(1) { min-width: 115px; }
.analysis-shape th:nth-child(2), .analysis-shape td:nth-child(2) { min-width: 130px; }
.analysis-shape th:nth-child(3), .analysis-shape td:nth-child(3) { min-width: 180px; }
.analysis-shape th:nth-child(4), .analysis-shape td:nth-child(4) { min-width: 82px; }
.analysis-shape th:nth-child(5), .analysis-shape td:nth-child(5) { min-width: 105px; }
.analysis-shape th:nth-child(6), .analysis-shape td:nth-child(6) { min-width: 92px; }
.analysis-shape th:nth-child(7), .analysis-shape td:nth-child(7) { min-width: 130px; max-width: 130px; overflow: hidden; }
.analysis-summary { min-width: 200px; margin-top: 0; }
.analysis-summary th:first-child, .analysis-summary td:first-child { min-width: 145px; }
.analysis-summary th:last-child, .analysis-summary td:last-child { min-width: 55px; }

/* Monthly popular category sheet: 24 month blocks + all 8 original charts */
.monthly-sheet-head {
  display: flex;
  justify-content: space-between;
  gap: 18px;
  padding: 14px 16px;
  margin-bottom: 12px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--panel);
}
.monthly-sheet-head > div:first-child strong { display:block; color:var(--strong); font-size:13px; margin-bottom:5px; }
.monthly-sheet-head > div:first-child span { display:block; color:var(--muted); font-size:10px; line-height:1.5; }
.threshold-cell { min-width: 180px; display:grid; grid-template-columns:1fr auto; gap:5px 12px; align-content:start; }
.threshold-cell span { grid-column:1/-1; font-size:10px; color:var(--muted); }
.threshold-cell b, .threshold-cell strong { font-size:12px; }
.threshold-cell strong { min-width:44px; text-align:center; padding:4px; background:var(--panel2); border:1px solid var(--border); border-radius:6px; }

.monthly-sheet-layout { display: grid; grid-template-columns: minmax(520px, 0.8fr) minmax(0, 1.2fr); gap: 14px; align-items:start; }
.monthly-charts-column { min-width: 0; }
.buyer-chart-grid { display:grid; grid-template-columns:1fr 1fr; gap:10px; margin-top:10px; }
.sheet-chart { border:1px solid var(--border); border-radius:9px; background:var(--panel); padding:11px 10px 8px; min-width:0; box-shadow:var(--shadow); }
.sheet-chart-title { text-align:center; color:var(--muted); font-size:10px; font-weight:700; margin-bottom:8px; }
.sheet-chart-plot { height:155px; display:flex; align-items:stretch; gap:2px; border-left:1px solid var(--border); border-bottom:1px solid var(--border); padding:6px 4px 0; }
.sheet-chart-col { flex:1 1 0; min-width:8px; display:flex; flex-direction:column; justify-content:flex-end; align-items:center; }
.sheet-chart-bar-area { height:128px; width:100%; display:flex; align-items:flex-end; justify-content:center; }
.sheet-chart-bar { width:72%; min-width:4px; background:linear-gradient(180deg,#6f7df5,#5361d7); border-radius:3px 3px 0 0; }
.sheet-chart-col > span { font-size:7px; color:var(--muted2); white-space:nowrap; transform:rotate(-60deg); transform-origin:center; margin-top:7px; height:15px; }
.chart-wide .sheet-chart-plot { height:190px; }
.chart-wide .sheet-chart-bar-area { height:160px; }

.month-blocks-scroll { border:1px solid var(--border); border-radius:10px; background:var(--panel); padding:10px; max-height:830px; }
.month-blocks-inner { display:flex; gap:12px; width:max-content; align-items:flex-start; }
.month-category-block { width:240px; flex:0 0 240px; }
.month-block-title { text-align:center; font-weight:900; color:var(--strong); background:var(--panel2); border:1px solid var(--border); border-bottom:0; padding:8px; border-radius:7px 7px 0 0; }
.month-shape { min-width:240px; width:240px; }
.month-shape th:first-child, .month-shape td:first-child { width:185px; white-space:normal; }
.month-shape th:last-child, .month-shape td:last-child { width:55px; }

/* Other analysis sheet */
.other-years-scroll { border:1px solid var(--border); border-radius:10px; background:var(--panel); padding:10px; margin-bottom:18px; }
.other-years-inner { display:flex; align-items:flex-start; gap:14px; width:max-content; }
.other-year-block { flex:0 0 auto; border:1px solid var(--border); border-radius:7px; overflow:hidden; }
.other-year-title { min-width:1420px; padding:9px 12px; text-align:center; background:#d9ead3; color:#1b2a20; font-size:11px; font-weight:900; }
.other-shape th:nth-child(1), .other-shape td:nth-child(1) { min-width:115px; }
.other-shape th:nth-child(2), .other-shape td:nth-child(2) { min-width:115px; }
.other-shape th:nth-child(3), .other-shape td:nth-child(3) { min-width:170px; }
.other-shape th:nth-child(4), .other-shape td:nth-child(4) { min-width:55px; }
.other-shape th:nth-child(5), .other-shape td:nth-child(5) { min-width:95px; }
.other-shape th:nth-child(6), .other-shape td:nth-child(6) { min-width:85px; }
.other-shape th:nth-child(7), .other-shape td:nth-child(7) { min-width:95px; }
.other-shape th:nth-child(8), .other-shape td:nth-child(8) { min-width:125px; max-width:125px; overflow:hidden; }
.other-shape th:nth-child(n+9), .other-shape td:nth-child(n+9) { min-width:46px; width:46px; text-align:center; }
.spreadsheet-panel { overflow:hidden; }
.modeling-shape th:nth-child(1), .modeling-shape td:nth-child(1) { min-width:220px; }
.modeling-shape th:nth-child(2), .modeling-shape td:nth-child(2) { min-width:115px; }
.modeling-shape th:nth-child(3), .modeling-shape td:nth-child(3) { min-width:170px; }
.modeling-shape th:nth-child(4), .modeling-shape td:nth-child(4),
.modeling-shape th:nth-child(5), .modeling-shape td:nth-child(5),
.modeling-shape th:nth-child(6), .modeling-shape td:nth-child(6) { min-width:70px; }
.modeling-shape th:nth-child(7), .modeling-shape td:nth-child(7),
.modeling-shape th:nth-child(8), .modeling-shape td:nth-child(8) { min-width:100px; }
.modeling-shape th:nth-child(n+9), .modeling-shape td:nth-child(n+9) { min-width:46px; text-align:center; }
.check-cell { text-align:center; }
.check-cell.checked { background:color-mix(in srgb,#d9ead3 75%,var(--panel)) !important; color:#245b38; font-weight:900; }

/* Yuka exact 23-column shape */
.yuka-condition { display:flex; align-items:center; gap:22px; padding:10px 13px; margin-bottom:12px; border:1px solid var(--border); border-radius:9px; background:var(--panel); font-size:11px; }
.yuka-condition label { display:flex; align-items:center; gap:8px; }
.yuka-condition input { min-width:70px; width:80px; }
.yuka-shape th:nth-child(1), .yuka-shape td:nth-child(1) { min-width:100px; }
.yuka-shape th:nth-child(2), .yuka-shape td:nth-child(2) { min-width:65px; }
.yuka-shape th:nth-child(3), .yuka-shape td:nth-child(3) { min-width:120px; }
.yuka-shape th:nth-child(4), .yuka-shape td:nth-child(4) { min-width:120px; }
.yuka-shape th:nth-child(5), .yuka-shape td:nth-child(5) { min-width:120px; }
.yuka-shape th:nth-child(6), .yuka-shape td:nth-child(6) { min-width:175px; }
.yuka-shape th:nth-child(7), .yuka-shape td:nth-child(7) { min-width:60px; }
.yuka-shape th:nth-child(8), .yuka-shape td:nth-child(8) { min-width:100px; }
.yuka-shape th:nth-child(9), .yuka-shape td:nth-child(9) { min-width:90px; }
.yuka-shape th:nth-child(10), .yuka-shape td:nth-child(10) { min-width:105px; }
.yuka-shape th:nth-child(11), .yuka-shape td:nth-child(11) { min-width:125px; max-width:125px; overflow:hidden; }
.yuka-shape th:nth-child(n+12), .yuka-shape td:nth-child(n+12) { min-width:46px; text-align:center; }
.target-month-cell { background:#fce4e4 !important; color:#762727; font-weight:900; text-align:center; }
.yuka-check { background:#fce4e4 !important; color:#762727 !important; }

/* Source data management input shape */
.source-input-panel { padding:14px; }
.source-meta-grid { display:grid; grid-template-columns:180px 220px 220px; width:max-content; min-width:650px; gap:0; margin-bottom:12px; }
.source-meta-grid > div { min-height:38px; border:1px solid var(--border2); margin-right:-1px; margin-bottom:-1px; padding:6px; display:flex; align-items:center; }
.source-label { font-weight:900; color:var(--strong); background:var(--panel2); font-size:11px; }
.source-meta-grid input, .source-meta-grid select { width:100%; min-width:0; }
.source-header-preview { display:grid; grid-template-columns:130px 150px 190px 180px 180px 135px 230px; width:max-content; min-width:100%; background:#2f6b50; color:#fff; font-size:10px; font-weight:900; }
.source-header-preview span { padding:9px 8px; border-right:1px solid rgba(255,255,255,.2); text-align:center; }
.sheet-paste-area { min-height:330px; border-radius:0; border:1px solid var(--border); border-top:0; }

@media (max-width: 1200px) {
  .monthly-sheet-layout { grid-template-columns:1fr; }
  .buyer-chart-grid { grid-template-columns:1fr 1fr; }
}

@media (max-width: 760px) {
  .sheet-block { flex-basis:760px; width:760px; }
  .analysis-sheet-block { flex-basis:920px; }
  .buyer-chart-grid { grid-template-columns:1fr; }
  .monthly-sheet-head { flex-direction:column; }
  .source-input-panel { overflow:auto; }
}
