:root {
  --navy: #071a52;
  --blue: #1746d1;
  --blue-soft: #edf3ff;
  --ink: #172033;
  --muted: #687386;
  --line: #e2e7ef;
  --surface: #ffffff;
  --canvas: #f4f7fb;
  --green: #138a5b;
  --red: #c43e3e;
  --shadow: 0 8px 28px rgba(26, 43, 79, .07);
}

* { box-sizing: border-box; }
body { margin: 0; color: var(--ink); background: var(--canvas); font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif; }
button, input, select { font: inherit; }
button { cursor: pointer; }
.topbar { color: white; background: linear-gradient(115deg, #06133f, #092d83); border-bottom: 3px solid #2f68ff; }
.topbar-inner, main { width: min(1380px, calc(100% - 40px)); margin: auto; }
.topbar-inner { min-height: 78px; display: flex; align-items: center; justify-content: space-between; gap: 24px; }
.brand, .user-area, .panel-heading, .welcome { display: flex; align-items: center; }
.brand { gap: 12px; }
.brand-mark { width: 42px; height: 42px; display: grid; place-items: center; border-radius: 12px; background: white; color: var(--blue); font-weight: 900; font-size: 22px; }
h1 { margin: 1px 0 0; font-size: 20px; letter-spacing: -.02em; }
.eyebrow { margin: 0; color: #aebfe9; font-size: 10px; font-weight: 800; letter-spacing: .16em; text-transform: uppercase; }
.eyebrow.blue { color: var(--blue); }
.user-area { gap: 10px; font-size: 13px; }
.user-area div { display: grid; }
.user-area small { color: #b9c7e8; margin-top: 2px; }
.status-dot { width: 9px; height: 9px; border-radius: 50%; background: #55d79b; box-shadow: 0 0 0 4px rgba(85, 215, 155, .14); }
.outline { border: 1px solid rgba(255,255,255,.35); color: white; background: transparent; border-radius: 8px; padding: 8px 12px; margin-left: 8px; }
.outline.dark { color: var(--blue); border-color: #b9c9f1; }
main { padding: 30px 0 60px; }
.welcome { justify-content: space-between; margin-bottom: 22px; }
.welcome h2 { margin: 4px 0; font-size: 28px; letter-spacing: -.03em; }
.welcome p:not(.eyebrow) { margin: 0; color: var(--muted); }
.period-pill, .badge { border: 1px solid #d7e1f7; background: #fff; color: #52627b; border-radius: 999px; padding: 8px 12px; font-size: 12px; }
.period-pill span { color: var(--green); }
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: 14px; box-shadow: var(--shadow); }
.filters { display: grid; grid-template-columns: repeat(5, 1fr) auto; align-items: end; gap: 12px; padding: 16px; }
.field { display: grid; gap: 6px; }
.field label { font-size: 11px; font-weight: 750; color: #526079; }
select, input[type="date"] { width: 100%; padding: 10px 11px; border: 1px solid #ccd5e2; border-radius: 8px; color: var(--ink); background: white; }
.primary, .file-button { border: 0; border-radius: 8px; padding: 11px 18px; color: white; background: linear-gradient(135deg, #1646cf, #0b2f96); font-weight: 700; }
.kpi-grid { display: grid; grid-template-columns: repeat(5, 1fr); gap: 14px; margin: 14px 0 18px; }
.kpi { min-height: 116px; padding: 18px; display: flex; align-items: center; gap: 13px; }
.kpi-icon { flex: 0 0 44px; height: 44px; display: grid; place-items: center; border-radius: 12px; background: var(--blue-soft); color: var(--blue); font-size: 12px; font-weight: 900; }
.kpi-icon.grand { color: #7c3aed; background: #f2edff; }
.kpi-icon.bills { color: #b66b00; background: #fff5df; }
.kpi-icon.traffic { color: #00848d; background: #e4f8f7; }
.kpi-icon.basket { color: #b52b57; background: #ffedf3; }
.kpi div { min-width: 0; display: grid; }
.kpi small { color: var(--muted); font-weight: 650; }
.kpi strong { margin: 4px 0 3px; font-size: clamp(18px, 1.55vw, 24px); letter-spacing: -.04em; white-space: nowrap; }
.kpi em { color: var(--green); font-size: 11px; font-style: normal; }
.kpi em.negative { color: var(--red); }
.tabs { display: flex; gap: 6px; margin-bottom: 14px; border-bottom: 1px solid #d7deea; }
.tab { border: 0; border-bottom: 3px solid transparent; background: transparent; color: var(--muted); padding: 11px 16px; font-weight: 700; }
.tab.active { color: var(--blue); border-bottom-color: var(--blue); }
.page { display: none; }
.page.active { display: block; }
.content-grid { display: grid; grid-template-columns: 1.72fr .8fr; gap: 14px; margin-bottom: 14px; }
.content-grid.equal { grid-template-columns: 1fr 1fr; }
.chart-panel, .insights, .page > .panel { padding: 20px; }
.panel-heading { justify-content: space-between; gap: 16px; margin-bottom: 15px; }
h3 { margin: 3px 0 0; font-size: 16px; }
.legend { display: flex; align-items: center; gap: 6px; color: var(--muted); font-size: 11px; }
.legend i { width: 8px; height: 8px; border-radius: 50%; background: var(--blue); }
.legend i:nth-child(2) { background: #aebbd4; margin-left: 6px; }
.chart-controls { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 6px; }
.seg { border: 1px solid #ccd5e2; border-radius: 7px; padding: 6px 10px; color: #526079; background: white; font-size: 11px; font-weight: 800; }
.seg.active { color: white; border-color: #1646cf; background: #1646cf; }
.badge { color: #8a5a00; background: #fff8e8; border-color: #f4dfad; }
.chart { min-height: 286px; position: relative; }
.chart.large { min-height: 350px; }
.chart svg { width: 100%; height: 286px; display: block; overflow: visible; }
.chart.large svg { height: 350px; }
.chart text { fill: #748096; font-size: 11px; }
.gridline { stroke: #e8ecf3; stroke-width: 1; }
.latest-line { fill: none; stroke: var(--blue); stroke-width: 3; }
.previous-line { fill: none; stroke: #aebbd4; stroke-width: 2; stroke-dasharray: 5 5; }
.series-line { fill: none; stroke-width: 2.5; }
.series-line.average { stroke: #9aa8bf; stroke-width: 2; stroke-dasharray: 6 5; }
.point { fill: white; stroke: var(--blue); stroke-width: 3; }
.previous-point { fill: white; stroke: #aebbd4; stroke-width: 2; }
.series-point { fill: white; stroke-width: 2.5; }
.point-label { fill: #10214c !important; font-size: 10px !important; font-weight: 800; paint-order: stroke; stroke: white; stroke-width: 4px; stroke-linejoin: round; }
.point-label.previous { fill: #7e8ba2 !important; }
.series-label { font-size: 10px !important; font-weight: 800; paint-order: stroke; stroke: white; stroke-width: 4px; stroke-linejoin: round; }
.series-value-label { font-size: 9px !important; font-weight: 800; paint-order: stroke; stroke: white; stroke-width: 4px; stroke-linejoin: round; }
.hit-point { fill: transparent; stroke: transparent; cursor: pointer; pointer-events: all; }
.chart-tooltip { position: absolute; z-index: 5; width: 206px; padding: 10px 11px; color: white; background: #10214c; border-radius: 8px; box-shadow: 0 14px 32px rgba(16,33,76,.24); font-size: 11px; pointer-events: none; }
.chart-tooltip strong, .chart-tooltip span, .chart-tooltip code { display: block; }
.chart-tooltip strong { font-size: 13px; margin-bottom: 3px; }
.chart-tooltip span { color: #c7d4f4; margin-bottom: 6px; }
.chart-tooltip code { white-space: normal; word-break: break-word; color: #eaf0ff; font-family: ui-monospace, SFMono-Regular, Consolas, monospace; font-size: 10px; line-height: 1.35; }
.bar { fill: #2c57d5; rx: 5; }
.bar.alt { fill: #7d9bea; }
.hit-bar { fill: transparent; stroke: transparent; cursor: pointer; pointer-events: all; }
.line-toggles { max-width: 520px; }
.line-toggles .seg { border-left-width: 5px; }
.insights ul { margin: 4px 0 18px; padding: 0; list-style: none; }
.insights li { padding: 12px 0 12px 25px; border-bottom: 1px solid var(--line); position: relative; font-size: 13px; line-height: 1.45; }
.insights li::before { content: "↗"; position: absolute; left: 0; top: 12px; color: var(--blue); font-weight: 900; }
.coming-soon { display: grid; gap: 4px; padding: 13px; border-radius: 10px; color: #465676; background: var(--blue-soft); font-size: 12px; }
.coming-soon strong { color: var(--blue); }
.assistant-box { display: grid; gap: 10px; padding: 13px; border-radius: 10px; background: var(--blue-soft); }
.assistant-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.assistant-head div { display: grid; gap: 2px; }
.assistant-head strong { color: var(--blue); font-size: 13px; }
.assistant-head span:not(.badge) { color: #526079; font-size: 11px; }
.ai-badge { padding: 5px 8px; font-size: 10px; }
.quick-prompts { display: flex; flex-wrap: wrap; gap: 6px; }
.quick-prompts button { border: 1px solid #c9d8f6; border-radius: 7px; padding: 6px 8px; color: #1746d1; background: white; font-size: 11px; font-weight: 750; }
.assistant-answer { min-height: 96px; max-height: 220px; overflow: auto; padding: 11px; border: 1px solid #d6e2fb; border-radius: 8px; color: #26354f; background: white; font-size: 12px; line-height: 1.45; white-space: pre-wrap; }
.assistant-answer.error { color: var(--red); border-color: #f3bbbb; background: #fff7f7; }
.assistant-input { display: grid; grid-template-columns: 1fr auto; gap: 8px; align-items: stretch; }
.assistant-input textarea { width: 100%; resize: vertical; min-height: 42px; max-height: 120px; padding: 9px 10px; border: 1px solid #ccd5e2; border-radius: 8px; color: var(--ink); background: white; }
.assistant-input .primary { padding-inline: 14px; }
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th, td { text-align: left; padding: 13px 12px; border-bottom: 1px solid var(--line); white-space: nowrap; }
th { color: var(--muted); background: #f7f9fc; font-size: 11px; text-transform: uppercase; letter-spacing: .05em; }
td:nth-child(n+2), th:nth-child(n+2) { text-align: right; }
.upload-grid { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 14px; }
.upload-card { min-height: 250px; padding: 26px; display: flex; flex-direction: column; align-items: flex-start; }
.upload-icon { width: 48px; height: 48px; display: grid; place-items: center; background: var(--blue-soft); color: var(--blue); border-radius: 13px; font-weight: 900; }
.upload-card h3 { margin-top: 20px; }
.upload-card p { max-width: 480px; color: var(--muted); line-height: 1.5; }
.file-button { display: inline-block; margin-top: auto; cursor: pointer; }
.file-button input { display: none; }
.file-status { margin-top: 10px; color: var(--muted); }
.file-status.error { color: var(--red); }
.upload-preview { width: 100%; margin: 16px 0; padding: 14px; border: 1px solid #c9d8f6; border-radius: 10px; background: var(--blue-soft); }
.upload-preview dl { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; margin: 0; }
.upload-preview dl div { display: grid; gap: 2px; }
.upload-preview dt { color: var(--muted); font-size: 10px; font-weight: 800; text-transform: uppercase; letter-spacing: .06em; }
.upload-preview dd { margin: 0; color: var(--ink); font-size: 13px; font-weight: 750; }
.validation-success { margin: 12px 0 0 !important; color: var(--green) !important; font-size: 12px; }
.upload-card .primary { margin-top: 2px; }
.upload-card .primary:disabled { cursor: wait; opacity: .65; }
.import-history-card { align-items: stretch; }
.import-history { width: 100%; display: grid; gap: 8px; margin-top: 8px; }
.import-item { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 11px 0; border-bottom: 1px solid var(--line); font-size: 11px; }
.import-item > div { display: grid; gap: 3px; min-width: 0; }
.import-item > div:last-child { justify-items: end; white-space: nowrap; }
.import-item strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 12px; }
.import-item span, .empty-state { color: var(--muted); }
.import-item b { padding: 3px 7px; border-radius: 999px; font-size: 9px; text-transform: uppercase; }
.status-completed { color: #08734a; background: #dff7ec; }
.status-processing { color: #795713; background: #fff3cf; }
.status-failed { color: var(--red); background: #fee7e7; }
.empty-state { padding: 24px 0; text-align: center; font-size: 12px; }
.notice { margin-top: 14px; padding: 14px 16px; border: 1px solid #f0d89d; color: #795713; background: #fff9e9; border-radius: 10px; font-size: 13px; }
.staff-grid { display: grid; grid-template-columns: .72fr 1.28fr; gap: 14px; margin-bottom: 14px; }
.staff-card { padding: 20px; }
.staff-form { display: grid; gap: 12px; }
.staff-form .primary { margin-top: 4px; }
.form-status { margin: 13px 0 0; color: var(--muted); font-size: 12px; line-height: 1.45; }
.form-status.error { color: var(--red); }
.inline-select { min-width: 120px; padding: 7px 9px; font-size: 12px; }
.access-status { display: inline-flex; align-items: center; justify-content: center; min-width: 72px; padding: 4px 8px; border-radius: 999px; font-size: 10px; font-weight: 850; text-transform: uppercase; }
.access-status.active { color: #08734a; background: #dff7ec; }
.access-status.inactive { color: #795713; background: #fff3cf; }
td strong, td small { display: block; }
td small { margin-top: 2px; color: var(--muted); font-size: 11px; }
.link-button { border: 0; padding: 4px 6px; color: var(--blue); background: transparent; font-size: 11px; font-weight: 800; }
.link-button.danger { color: var(--red); }
.toast { position: fixed; right: 22px; bottom: 22px; transform: translateY(90px); opacity: 0; padding: 13px 16px; color: white; background: #16254c; border-radius: 9px; box-shadow: 0 12px 40px rgba(0,0,0,.18); transition: .25s ease; }
.toast.show { transform: translateY(0); opacity: 1; }
.hidden { display: none !important; }
.auth-screen { min-height: 100vh; display: grid; grid-template-columns: minmax(420px, .82fr) 1.18fr; background: white; }
.auth-card { width: min(440px, calc(100% - 48px)); margin: auto; padding: 42px 0; }
.auth-brand { display: flex; align-items: center; gap: 12px; color: white; background: var(--navy); border-radius: 14px; padding: 13px 16px; }
.auth-copy { margin: 62px 0 26px; }
.auth-copy h2 { margin: 8px 0; font-size: 34px; letter-spacing: -.04em; }
.auth-copy p:not(.eyebrow), .auth-message { color: var(--muted); line-height: 1.5; }
.google-button { width: 100%; display: flex; align-items: center; justify-content: center; gap: 12px; padding: 13px 16px; border: 1px solid #cbd5e1; border-radius: 9px; color: var(--ink); background: white; font-weight: 750; box-shadow: 0 2px 5px rgba(15,23,42,.05); }
.google-button:hover { background: #f8fafc; }
.google-mark { color: #174ea6; font-size: 18px; font-weight: 900; }
.auth-message { margin: 14px 0; text-align: center; font-size: 12px; }
.auth-message.error { color: var(--red); }
.demo-access { margin-top: 30px; padding: 14px; border: 1px dashed #b8c7e5; border-radius: 10px; background: var(--blue-soft); }
.demo-access > div:first-child { display: grid; gap: 3px; color: var(--blue); font-size: 12px; font-weight: 800; }
.demo-access small { color: var(--muted); font-weight: 500; }
.demo-buttons { display: grid; grid-template-columns: repeat(3, 1fr); gap: 7px; margin-top: 12px; }
.demo-buttons button { border: 1px solid #b9c9ef; border-radius: 7px; color: var(--blue); background: white; padding: 8px; font-size: 12px; font-weight: 750; }
.auth-aside { display: flex; flex-direction: column; justify-content: center; padding: 10%; color: white; background: radial-gradient(circle at 90% 10%, #2459db, transparent 28%), linear-gradient(145deg, #07153f, #0a2f87); }
.auth-aside > div { max-width: 620px; }
.auth-aside h2 { margin: 14px 0 18px; max-width: 570px; font-size: clamp(36px, 4vw, 62px); line-height: 1.02; letter-spacing: -.05em; }
.auth-aside p:not(.eyebrow) { max-width: 540px; color: #c4d0ed; font-size: 17px; line-height: 1.6; }
.auth-aside ul { display: grid; gap: 18px; margin: 55px 0 0; padding: 0; list-style: none; }
.auth-aside li { display: grid; gap: 4px; padding-left: 20px; border-left: 2px solid #4f7ff1; }
.auth-aside li span { color: #b7c5e7; font-size: 13px; }

@media (max-width: 1050px) {
  .filters { grid-template-columns: repeat(3, 1fr); }
  .kpi-grid { grid-template-columns: repeat(2, 1fr); }
  .content-grid, .content-grid.equal { grid-template-columns: 1fr; }
}
@media (max-width: 680px) {
  .topbar-inner, main { width: min(100% - 24px, 1380px); }
  .topbar-inner { padding: 12px 0; }
  .user-area > div, .status-dot { display: none; }
  .welcome { align-items: flex-start; gap: 15px; flex-direction: column; }
  .filters, .kpi-grid, .upload-grid, .staff-grid { grid-template-columns: 1fr; }
  .tabs { overflow-x: auto; }
  .tab { white-space: nowrap; }
  .auth-screen { grid-template-columns: 1fr; }
  .auth-aside { display: none; }
  .auth-card { width: min(440px, calc(100% - 32px)); }
}
