/* ── Design tokens ──────────────────────────────────────────── */
:root {
  --hue: 220;

  /* Light theme */
  --bg: #f4f6fb;
  --bg-card: #ffffff;
  --bg-card2: #f9fafd;
  --border: #e2e6f0;
  --text: #1a1f36;
  --text-2: #5a6270;
  --text-3: #8892a4;
  --accent: #4361ee;
  --accent-2: #7c3aed;
  --shadow: 0 2px 12px rgba(30,40,90,.08);
  --shadow-lg: 0 8px 32px rgba(30,40,90,.12);
  --radius: 14px;
  --radius-sm: 8px;
  --transition: 200ms ease;
}

[data-theme="dark"] {
  --bg: #0f1117;
  --bg-card: #181c27;
  --bg-card2: #1e2333;
  --border: #272d3d;
  --text: #e8ecf5;
  --text-2: #8992a8;
  --text-3: #5a6275;
  --accent: #5c78f5;
  --accent-2: #9b6bf8;
  --shadow: 0 2px 12px rgba(0,0,0,.35);
  --shadow-lg: 0 8px 32px rgba(0,0,0,.45);
}

/* ── Reset ──────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; }
body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  font-size: 15px;
  line-height: 1.5;
  transition: background var(--transition), color var(--transition);
}

/* ── Header ─────────────────────────────────────────────────── */
.site-header {
  position: sticky; top: 0; z-index: 100;
  background: var(--bg-card);
  border-bottom: 1px solid var(--border);
  box-shadow: var(--shadow);
  backdrop-filter: blur(8px);
}
.header-inner {
  max-width: 1280px; margin: 0 auto;
  padding: 0 24px;
  height: 56px;
  display: flex; align-items: center; justify-content: space-between;
}
.brand {
  display: flex; align-items: center; gap: 10px;
  font-weight: 700; font-size: 16px; letter-spacing: -.01em;
  color: var(--accent);
}
.brand-icon { width: 22px; height: 22px; }

.icon-btn {
  width: 38px; height: 38px; border-radius: 50%;
  border: 1px solid var(--border);
  background: var(--bg-card2);
  color: var(--text-2);
  cursor: pointer; display: flex; align-items: center; justify-content: center;
  transition: all var(--transition);
}
.icon-btn:hover { background: var(--accent); color: #fff; border-color: var(--accent); }
.icon-btn svg { width: 17px; height: 17px; }

/* Sun/moon icons toggled via JS class */
.icon-sun { display: none; }
.icon-moon { display: block; }
[data-theme="light"] .icon-sun { display: block; }
[data-theme="light"] .icon-moon { display: none; }

/* ── Main layout ────────────────────────────────────────────── */
main {
  max-width: 1280px; margin: 0 auto;
  padding: 32px 20px 60px;
}

/* ── Upload section ─────────────────────────────────────────── */
.upload-section {
  display: flex; align-items: center; justify-content: center;
  min-height: calc(100vh - 120px);
}
.upload-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  padding: 48px 40px;
  width: 100%; max-width: 520px;
  text-align: center;
  display: flex; flex-direction: column; align-items: center; gap: 20px;
}
.upload-icon-wrap svg {
  width: 56px; height: 56px;
  stroke: var(--accent); opacity: .85;
}
.upload-card h2 {
  font-size: 22px; font-weight: 700; letter-spacing: -.02em;
  color: var(--text);
}
.upload-subtitle {
  font-size: 14px; color: var(--text-2); max-width: 380px; line-height: 1.6;
}

/* Drop zone */
.drop-zone {
  width: 100%; border: 2px dashed var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg-card2);
  cursor: pointer; display: block;
  transition: border-color var(--transition), background var(--transition);
}
.drop-zone:hover, .drop-zone.drag-over {
  border-color: var(--accent); background: color-mix(in srgb, var(--accent) 8%, var(--bg-card2));
}
.drop-zone input[type="file"] {
  position: absolute; width: 1px; height: 1px; opacity: 0; pointer-events: none;
}
.drop-zone-inner {
  padding: 28px 20px;
  display: flex; flex-direction: column; align-items: center; gap: 8px;
  pointer-events: none;
}
.drop-zone-inner svg { width: 32px; height: 32px; stroke: var(--text-3); }
.drop-zone-inner span { font-size: 14px; color: var(--text-2); }
.drop-zone-inner strong { color: var(--accent); }
.file-name { font-size: 13px; color: var(--accent); font-weight: 600; }

/* File list */
.file-list {
  width: 100%; text-align: left;
  background: var(--bg-card2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  overflow: hidden;
}
.file-list-header {
  padding: 10px 14px;
  font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: .06em;
  color: var(--text-3);
  border-bottom: 1px solid var(--border);
}
.file-item {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 14px;
  font-size: 13px; color: var(--text-2);
  border-bottom: 1px solid var(--border);
}
.file-item:last-child { border-bottom: none; }
.file-dot {
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--accent); flex-shrink: 0;
}
.file-item-name { flex: 1; color: var(--text); font-weight: 500; }
.file-item-size { font-size: 12px; color: var(--text-3); }

/* Buttons */
.btn-primary {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 12px 28px;
  background: var(--accent);
  color: #fff;
  border: none; border-radius: 100px;
  font-size: 14px; font-weight: 600; cursor: pointer;
  transition: all var(--transition);
  box-shadow: 0 4px 16px color-mix(in srgb, var(--accent) 35%, transparent);
}
.btn-primary:hover:not(:disabled) {
  transform: translateY(-1px);
  box-shadow: 0 6px 20px color-mix(in srgb, var(--accent) 45%, transparent);
}
.btn-primary:disabled { opacity: .45; cursor: not-allowed; transform: none; }
.btn-primary svg { width: 16px; height: 16px; }

.btn-ghost {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 8px 16px;
  background: transparent; color: var(--text-2);
  border: 1px solid var(--border); border-radius: 100px;
  font-size: 13px; font-weight: 500; cursor: pointer;
  transition: all var(--transition);
}
.btn-ghost:hover { background: var(--bg-card2); color: var(--text); }
.btn-ghost svg { width: 16px; height: 16px; }

/* Error */
.error-msg {
  width: 100%; padding: 12px 16px;
  background: color-mix(in srgb, #ef4444 12%, transparent);
  border: 1px solid color-mix(in srgb, #ef4444 30%, transparent);
  border-radius: var(--radius-sm);
  color: #ef4444; font-size: 13px;
  text-align: left;
}

/* Progress */
.progress-wrap {
  width: 100%; display: flex; flex-direction: column; gap: 8px; align-items: center;
}
.progress-bar {
  width: 100%; height: 6px; background: var(--border); border-radius: 99px; overflow: hidden;
}
#progress-fill {
  height: 100%; width: 0%; background: var(--accent);
  border-radius: 99px;
  transition: width .3s ease;
}
#progress-label { font-size: 13px; color: var(--text-2); }

/* ── Dashboard section ──────────────────────────────────────── */
.dashboard-section { display: flex; flex-direction: column; gap: 24px; }

.dash-topbar {
  display: flex; align-items: center; justify-content: space-between;
  flex-wrap: wrap; gap: 12px;
}

/* Year filter chips */
.year-filters { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.year-chip {
  padding: 6px 14px;
  border: 1.5px solid var(--border);
  border-radius: 100px;
  background: var(--bg-card);
  color: var(--text-2);
  font-size: 13px; font-weight: 600; cursor: pointer;
  transition: all var(--transition);
  user-select: none;
}
.year-chip.active {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
  box-shadow: 0 2px 8px color-mix(in srgb, var(--accent) 35%, transparent);
}
.year-chip:hover:not(.active) { border-color: var(--accent); color: var(--accent); }

/* Summary cards */
.summary-cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 16px;
}
.summary-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px 18px;
  box-shadow: var(--shadow);
  transition: transform var(--transition), box-shadow var(--transition);
}
.summary-card:hover { transform: translateY(-2px); box-shadow: var(--shadow-lg); }
.summary-card-label {
  font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .07em;
  color: var(--text-3); margin-bottom: 8px;
}
.summary-card-value {
  font-size: 30px; font-weight: 800; letter-spacing: -.03em;
  color: var(--text);
  line-height: 1;
}
.summary-card-sub {
  font-size: 12px; color: var(--text-2); margin-top: 4px;
}
.summary-card-accent { color: var(--accent); }

/* Charts grid */
.charts-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(360px, 1fr));
  gap: 20px;
}
.chart-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
  transition: transform var(--transition), box-shadow var(--transition);
}
.chart-card:hover { transform: translateY(-2px); box-shadow: var(--shadow-lg); }
.chart-card.wide { grid-column: 1 / -1; }
.chart-header {
  padding: 18px 20px 0;
  display: flex; align-items: flex-start; justify-content: space-between; gap: 12px;
}
.chart-title {
  font-size: 14px; font-weight: 700; color: var(--text); letter-spacing: -.01em;
}
.chart-subtitle {
  font-size: 12px; color: var(--text-3); margin-top: 2px;
}
.chart-body {
  padding: 16px 20px 20px;
  position: relative;
}
.chart-body canvas { max-height: 280px; }
.chart-card.tall .chart-body canvas { max-height: 380px; }

/* ── Utilities ──────────────────────────────────────────────── */
.hidden { display: none !important; }

/* ── Export button ──────────────────────────────────────────── */
.dash-topbar-right {
  display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
}

.btn-export {
  display: inline-flex; align-items: center; gap: 7px;
  padding: 8px 18px;
  background: var(--bg-card);
  color: var(--text);
  border: 1.5px solid var(--border);
  border-radius: 100px;
  font-size: 13px; font-weight: 600; cursor: pointer;
  transition: all var(--transition);
  white-space: nowrap;
}
.btn-export svg { width: 15px; height: 15px; flex-shrink: 0; }
.btn-export:hover {
  background: var(--accent); color: #fff; border-color: var(--accent);
  box-shadow: 0 3px 12px color-mix(in srgb, var(--accent) 35%, transparent);
}
.btn-export:disabled { opacity: .45; cursor: not-allowed; }

/* ── PDF overlay ────────────────────────────────────────────── */
.pdf-overlay {
  position: fixed; inset: 0; z-index: 1000;
  background: rgba(0,0,0,.55);
  backdrop-filter: blur(4px);
  display: flex; align-items: center; justify-content: center;
}
.pdf-overlay-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  padding: 40px 48px;
  text-align: center;
  display: flex; flex-direction: column; align-items: center; gap: 16px;
  min-width: 260px;
}
.pdf-spinner {
  width: 40px; height: 40px;
  border: 3px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.pdf-overlay-title {
  font-size: 16px; font-weight: 700; color: var(--text);
}
.pdf-overlay-status {
  font-size: 13px; color: var(--text-2);
}
