:root {
  color-scheme: light;
  --bg: #f3f5f8;
  --surface: rgba(255,255,255,.88);
  --surface-solid: #ffffff;
  --text: #111827;
  --muted: #667085;
  --line: #e4e7ec;
  --accent: #111827;
  --accent-soft: #eef2f6;
  --good: #16865c;
  --warn: #b7791f;
  --bad: #c2413b;
  --shadow: 0 14px 36px rgba(16,24,40,.07);
  --radius: 22px;
}

* { box-sizing: border-box; }
html { background: var(--bg); }
body {
  margin: 0;
  min-height: 100vh;
  font-family: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--text);
  background:
    radial-gradient(circle at 8% 0%, rgba(255,255,255,.95), transparent 34rem),
    var(--bg);
}
button, select { font: inherit; }
button { cursor: pointer; }

.app-shell { width: min(1320px, 100%); margin: 0 auto; padding: 28px clamp(16px, 3vw, 42px) 48px; }
.topbar { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-bottom: 26px; }
h1 { margin: 3px 0 0; font-size: clamp(28px, 4vw, 44px); letter-spacing: -.04em; }
h2 { margin: 4px 0 0; font-size: 20px; letter-spacing: -.02em; }
.eyebrow { color: var(--muted); font-size: 11px; font-weight: 800; letter-spacing: .16em; text-transform: uppercase; }

.card {
  background: var(--surface);
  border: 1px solid rgba(255,255,255,.9);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  backdrop-filter: blur(16px);
}
.hidden { display: none !important; }

.button { border: 0; border-radius: 14px; padding: 12px 16px; font-weight: 750; }
.button.primary { background: var(--accent); color: white; }
.button.secondary { background: var(--surface-solid); color: var(--text); border: 1px solid var(--line); }
.button:active { transform: translateY(1px); }

.welcome { display: grid; grid-template-columns: auto 1fr; gap: 22px; align-items: center; padding: clamp(22px, 5vw, 42px); min-height: 280px; }
.welcome-icon { width: 78px; height: 78px; border-radius: 24px; display: grid; place-items: center; background: var(--accent); color: #fff; font-size: 34px; font-weight: 800; }
.welcome p { color: var(--muted); max-width: 680px; line-height: 1.6; }
.actions { margin-top: 22px; }
.privacy-note { font-size: 13px; }

.control-row { display: flex; justify-content: space-between; gap: 18px; align-items: flex-end; margin: 4px 0 18px; }
select { margin-top: 5px; border: 1px solid var(--line); border-radius: 13px; padding: 10px 36px 10px 12px; background: var(--surface-solid); color: var(--text); font-weight: 700; }
.file-state { display: flex; align-items: center; gap: 10px; color: var(--muted); text-align: right; }
.file-state strong, .file-state span { display: block; font-size: 12px; }
.status-dot { width: 10px; height: 10px; border-radius: 999px; background: var(--good); box-shadow: 0 0 0 4px rgba(22,134,92,.12); }

.alert { margin: 0 0 18px; padding: 13px 16px; border-radius: 14px; background: #fff8e7; color: #7a5216; border: 1px solid #f1ddb0; font-size: 14px; }

.hero-grid { display: grid; grid-template-columns: 1.35fr repeat(3, 1fr); gap: 16px; }
.kpi { min-height: 150px; padding: 22px; display: flex; flex-direction: column; justify-content: space-between; }
.hero-kpi { background: linear-gradient(145deg, #111827, #273244); color: white; border-color: transparent; }
.hero-kpi .kpi-label, .hero-kpi .kpi-sub { color: rgba(255,255,255,.7); }
.kpi-label { color: var(--muted); font-size: 13px; font-weight: 700; }
.kpi-value { display: block; margin: 7px 0; font-size: clamp(31px, 4.2vw, 48px); letter-spacing: -.055em; font-variant-numeric: tabular-nums; }
.kpi-value.compact { font-size: clamp(26px, 3vw, 36px); }
.kpi-sub { color: var(--muted); font-size: 12px; }
.score-line { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.pill { display: inline-flex; border-radius: 999px; padding: 7px 10px; background: var(--accent-soft); font-size: 12px; font-weight: 800; white-space: nowrap; }
.pill.good { background: #e9f7f1; color: var(--good); }
.pill.warn { background: #fff6dd; color: var(--warn); }
.pill.bad { background: #fff0ee; color: var(--bad); }

.mini-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; margin-top: 14px; }
.mini-kpi { padding: 17px 18px; }
.mini-kpi span { color: var(--muted); display: block; font-size: 12px; margin-bottom: 6px; }
.mini-kpi strong { font-size: 20px; letter-spacing: -.025em; font-variant-numeric: tabular-nums; }

.content-grid { display: grid; grid-template-columns: 1.45fr 1fr; gap: 16px; margin-top: 16px; }
.lower-grid { grid-template-columns: 1.35fr 1fr; }
.panel { padding: 22px; min-height: 330px; }
.panel-head { display: flex; align-items: flex-start; justify-content: space-between; margin-bottom: 18px; }
.chart { min-height: 240px; display: grid; align-items: end; }
.chart svg { width: 100%; height: 245px; overflow: visible; }
.chart-empty { color: var(--muted); display: grid; place-items: center; min-height: 230px; font-size: 14px; }
.axis-label { fill: #98a2b3; font-size: 10px; }
.grid-line { stroke: #edf0f3; stroke-width: 1; }
.trend-line { fill: none; stroke: #111827; stroke-width: 3; stroke-linecap: round; stroke-linejoin: round; }
.trend-area { fill: url(#areaGradient); }
.trend-dot { fill: #111827; stroke: white; stroke-width: 3; }

.allocation { display: grid; gap: 16px; }
.alloc-row { display: grid; gap: 7px; }
.alloc-head { display: flex; justify-content: space-between; gap: 12px; align-items: baseline; }
.alloc-head span { font-size: 13px; font-weight: 700; }
.alloc-head strong { font-size: 13px; font-variant-numeric: tabular-nums; }
.alloc-track { height: 8px; overflow: hidden; border-radius: 999px; background: #eef1f4; }
.alloc-fill { height: 100%; min-width: 0; border-radius: inherit; background: #273244; }
.alloc-meta { color: var(--muted); font-size: 11px; }

.hints { display: grid; gap: 10px; }
.hint { display: flex; gap: 10px; align-items: flex-start; padding: 12px 13px; border-radius: 14px; background: #f8fafb; border: 1px solid #edf0f2; }
.hint-dot { margin-top: 5px; width: 8px; height: 8px; border-radius: 50%; flex: 0 0 auto; }
.hint.good .hint-dot { background: var(--good); }
.hint.warn .hint-dot { background: var(--warn); }
.hint.bad .hint-dot { background: var(--bad); }
.hint p { margin: 0; line-height: 1.45; font-size: 13px; }

.payment-grid { display: grid; gap: 12px; }
.payment-grid > div { padding: 14px; border-radius: 14px; background: #f8fafb; border: 1px solid #edf0f2; }
.payment-grid span { display: block; color: var(--muted); font-size: 12px; margin-bottom: 4px; }
.payment-grid strong { font-size: 22px; font-variant-numeric: tabular-nums; }

footer { display: flex; justify-content: space-between; gap: 16px; align-items: center; color: var(--muted); font-size: 12px; padding: 24px 4px 0; }
.text-button { background: none; border: 0; color: var(--muted); text-decoration: underline; padding: 6px; }
.positive { color: var(--good) !important; }
.negative { color: var(--bad) !important; }

@media (max-width: 1000px) {
  .hero-grid { grid-template-columns: repeat(2, 1fr); }
  .mini-grid { grid-template-columns: repeat(2, 1fr); }
  .content-grid, .lower-grid { grid-template-columns: 1fr; }
}

@media (max-width: 620px) {
  .app-shell { padding-top: max(18px, env(safe-area-inset-top)); }
  .topbar { align-items: flex-start; }
  .topbar .button { padding: 10px 12px; font-size: 13px; }
  .welcome { grid-template-columns: 1fr; }
  .welcome-icon { width: 58px; height: 58px; border-radius: 18px; font-size: 26px; }
  .hero-grid { grid-template-columns: 1fr; }
  .hero-kpi { min-height: 170px; }
  .mini-grid { grid-template-columns: 1fr 1fr; }
  .mini-kpi strong { font-size: 17px; }
  .control-row { align-items: flex-start; }
  .file-state { max-width: 52%; }
  .file-state strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 180px; }
  .panel { padding: 18px; }
  footer { flex-direction: column; align-items: flex-start; }
}
