@import url('https://fonts.googleapis.com/css2?family=Playfair+Display:wght@400;500;700&family=DM+Sans:ital,opsz,wght@0,9..40,300;0,9..40,400;0,9..40,500;0,9..40,600;0,9..40,700;1,9..40,400&display=swap');

*, *::before, *::after { margin: 0; padding: 0; box-sizing: border-box; }

:root {
  --bg: #faf8f4;
  --bg-warm: #f5f0e8;
  --surface: #ffffff;
  --surface-alt: #f0ebe2;
  --border: rgba(0,0,0,0.07);
  --border-strong: rgba(0,0,0,0.12);
  --text: #1a1714;
  --text-secondary: #5c5549;
  --text-muted: #9c9488;
  --accent: #e07a3a;
  --accent-light: #f4a261;
  --accent-bg: rgba(224,122,58,0.08);
  --green: #4a9d6e;
  --green-bg: rgba(74,157,110,0.1);
  --red: #d15656;
  --red-bg: rgba(209,86,86,0.1);
  --serif: 'Playfair Display', Georgia, serif;
  --sans: 'DM Sans', -apple-system, sans-serif;
  --radius: 14px;
  --shadow-sm: 0 1px 3px rgba(0,0,0,0.04), 0 1px 2px rgba(0,0,0,0.03);
  --shadow: 0 4px 16px rgba(0,0,0,0.06), 0 1px 3px rgba(0,0,0,0.04);
  --shadow-lg: 0 12px 40px rgba(0,0,0,0.1), 0 4px 12px rgba(0,0,0,0.05);
}

html { font-size: 15px; scroll-behavior: smooth; }

body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--sans);
  line-height: 1.6;
  min-height: 100vh;
  overflow-x: hidden;
}

/* Warm radial accents */
body::before {
  content: '';
  position: fixed;
  top: -300px; right: -200px;
  width: 800px; height: 800px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(224,122,58,0.06) 0%, transparent 70%);
  pointer-events: none;
}
body::after {
  content: '';
  position: fixed;
  bottom: -200px; left: -300px;
  width: 700px; height: 700px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(74,157,110,0.05) 0%, transparent 70%);
  pointer-events: none;
}

/* ═══════════════════════════════════════
   VIEW SWITCHING
   ═══════════════════════════════════════ */
.view { display: none; }
.view.active { display: block; }
.tab-content { display: none; }
.tab-content.active { display: block; }

/* ═══════════════════════════════════════
   LANDING PAGE
   ═══════════════════════════════════════ */
.landing {
  position: relative;
  z-index: 1;
}

/* ── Hero ── */
.l-hero {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 3rem;
  align-items: center;
  max-width: 1200px;
  margin: 0 auto;
  padding: 5rem 3rem 4rem;
  min-height: 92vh;
}

.l-hero-content { max-width: 520px; }

.l-eyebrow {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  font-size: 0.72rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--accent);
  margin-bottom: 1.5rem;
  animation: fadeUp 0.6s cubic-bezier(0.22,1,0.36,1) both;
}
.l-eyebrow svg { flex-shrink: 0; }

.l-title {
  font-family: var(--serif);
  font-size: 4.2rem;
  font-weight: 700;
  letter-spacing: -0.03em;
  color: var(--text);
  line-height: 1.0;
  margin-bottom: 1.2rem;
  animation: fadeUp 0.6s 0.05s cubic-bezier(0.22,1,0.36,1) both;
}
.l-title span { color: var(--accent); }

.l-subtitle {
  font-size: 1.1rem;
  color: var(--text-secondary);
  line-height: 1.65;
  margin-bottom: 2.2rem;
  animation: fadeUp 0.6s 0.1s cubic-bezier(0.22,1,0.36,1) both;
}
.l-subtitle em {
  font-style: normal;
  color: var(--text);
  font-weight: 600;
}

/* Upload zone (landing version) */
.l-upload-zone {
  border: 2px dashed var(--border-strong);
  border-radius: 16px;
  padding: 2rem 1.8rem;
  transition: all 0.25s;
  cursor: pointer;
  background: var(--surface);
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  animation: fadeUp 0.6s 0.15s cubic-bezier(0.22,1,0.36,1) both;
}
.l-upload-zone:hover, .l-upload-zone.dragover {
  border-color: var(--accent);
  background: var(--accent-bg);
  transform: translateY(-2px);
  box-shadow: var(--shadow);
}
.l-upload-zone.dragover { border-style: solid; }
.l-upload-zone .upload-zone-inner {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.5rem;
}
.l-upload-zone.loading .upload-zone-inner { opacity: 0.3; }
.l-upload-zone.loading::after {
  content: 'Processing...';
  position: absolute;
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--accent);
}

.l-upload-icon { color: var(--accent); }
.l-upload-label {
  font-size: 0.9rem;
  font-weight: 500;
  color: var(--text-secondary);
}
.l-upload-btn {
  display: inline-block;
  padding: 0.5rem 1.4rem;
  font-size: 0.82rem;
  font-weight: 600;
  font-family: var(--sans);
  color: white;
  background: var(--accent);
  border: none;
  border-radius: 9px;
  cursor: pointer;
  transition: all 0.2s;
  margin-top: 0.2rem;
}
.l-upload-btn:hover { background: #c96a2e; transform: translateY(-1px); box-shadow: var(--shadow); }

.upload-error {
  margin-top: 0.6rem;
  font-size: 0.8rem;
  color: var(--red);
  font-weight: 500;
  min-height: 1.2em;
  text-align: center;
}

.l-demo-btn {
  display: block;
  margin-top: 0.8rem;
  padding: 0;
  font-size: 0.78rem;
  font-weight: 500;
  font-family: var(--sans);
  color: var(--text-muted);
  background: none;
  border: none;
  cursor: pointer;
  transition: color 0.2s;
  text-align: center;
  width: 100%;
  animation: fadeUp 0.6s 0.2s cubic-bezier(0.22,1,0.36,1) both;
}
.l-demo-btn:hover { color: var(--accent); }

/* Hero visual */
.l-hero-visual {
  display: flex;
  align-items: center;
  justify-content: center;
  animation: fadeUp 0.8s 0.2s cubic-bezier(0.22,1,0.36,1) both;
}
.l-sankey-preview {
  width: 100%;
  max-width: 420px;
  height: auto;
  filter: drop-shadow(0 8px 32px rgba(0,0,0,0.06));
}

/* Animated sankey glow */
@keyframes sankeyPulse {
  0%, 100% { stroke-opacity: 0; }
  50% { stroke-opacity: 0.25; }
}
.l-sankey-glow {
  animation: sankeyPulse 3s ease-in-out infinite;
}

/* ── Privacy Section ── */
.l-privacy {
  background: var(--text);
  color: #f0ebe2;
  padding: 4.5rem 3rem;
}
.l-privacy-inner {
  max-width: 780px;
  margin: 0 auto;
  text-align: center;
}
.l-privacy-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 52px;
  height: 52px;
  border-radius: 50%;
  background: rgba(255,255,255,0.08);
  color: var(--accent-light);
  margin-bottom: 1.5rem;
}
.l-privacy-title {
  font-family: var(--serif);
  font-size: 1.9rem;
  font-weight: 500;
  letter-spacing: -0.02em;
  line-height: 1.3;
  margin-bottom: 1rem;
  color: #f0ebe2;
}
.l-privacy-text {
  font-size: 0.95rem;
  line-height: 1.7;
  color: rgba(240,235,226,0.65);
  max-width: 580px;
  margin: 0 auto 2.5rem;
}
.l-trust-row {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1.5rem;
  text-align: left;
}
.l-trust-item {
  display: flex;
  gap: 0.8rem;
  align-items: flex-start;
}
.l-trust-icon {
  flex-shrink: 0;
  width: 36px;
  height: 36px;
  border-radius: 9px;
  background: rgba(255,255,255,0.06);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--accent-light);
  margin-top: 0.1rem;
}
.l-trust-item strong {
  display: block;
  font-size: 0.82rem;
  font-weight: 600;
  color: #f0ebe2;
  margin-bottom: 0.15rem;
}
.l-trust-item span {
  font-size: 0.76rem;
  color: rgba(240,235,226,0.5);
  line-height: 1.5;
}
.l-trust-item a {
  color: var(--accent-light);
  text-decoration: none;
  font-weight: 500;
}
.l-trust-item a:hover { text-decoration: underline; }

/* ── Features Section ── */
.l-features {
  max-width: 1100px;
  margin: 0 auto;
  padding: 4.5rem 3rem;
}
.l-section-label {
  font-size: 0.68rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.14em;
  color: var(--text-muted);
  margin-bottom: 2.5rem;
}
.l-features-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 2.5rem;
}
.l-feature {
  padding: 0;
}
.l-feature-icon-wrap {
  width: 44px;
  height: 44px;
  border-radius: 12px;
  background: var(--accent-bg);
  color: var(--accent);
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 1.1rem;
}
.l-feature h3 {
  font-family: var(--serif);
  font-size: 1.08rem;
  font-weight: 500;
  margin-bottom: 0.5rem;
  color: var(--text);
}
.l-feature p {
  font-size: 0.82rem;
  line-height: 1.65;
  color: var(--text-muted);
}

/* ── How it works ── */
.l-how {
  max-width: 1100px;
  margin: 0 auto;
  padding: 0 3rem 5rem;
}
.l-steps {
  display: flex;
  align-items: center;
  gap: 0;
}
.l-step {
  flex: 1;
  text-align: center;
  padding: 0 1.5rem;
}
.l-step-num {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--accent);
  color: white;
  font-size: 0.85rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto 0.8rem;
}
.l-step strong {
  display: block;
  font-size: 0.88rem;
  margin-bottom: 0.25rem;
  color: var(--text);
}
.l-step p {
  font-size: 0.78rem;
  color: var(--text-muted);
  line-height: 1.5;
  margin: 0;
}
.l-step-divider {
  flex-shrink: 0;
  width: 48px;
  height: 1px;
  background: var(--border-strong);
  margin-top: -1.2rem;
}

/* ── Footer ── */
.l-footer {
  border-top: 1px solid var(--border);
  padding: 1.5rem 3rem;
}
.l-footer-inner {
  max-width: 1100px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.l-footer-brand {
  font-family: var(--serif);
  font-size: 1rem;
  font-weight: 700;
  color: var(--text);
}
.l-footer-brand span { color: var(--accent); }
.l-footer-links {
  font-size: 0.76rem;
  color: var(--text-muted);
}
.l-footer-links a {
  color: var(--text-secondary);
  text-decoration: none;
  transition: color 0.15s;
}
.l-footer-links a:hover { color: var(--accent); }
.l-footer-sep { margin: 0 0.5rem; }
.l-footer-disclaimer {
  max-width: 1100px;
  margin: 0.8rem auto 0;
  font-size: 0.66rem;
  color: var(--text-muted);
  text-align: center;
  opacity: 0.7;
}

/* ── Landing responsive ── */
@media (max-width: 900px) {
  .l-hero {
    grid-template-columns: 1fr;
    padding: 3rem 1.5rem 2rem;
    min-height: auto;
    gap: 2rem;
  }
  .l-hero-visual { order: -1; }
  .l-title { font-size: 3rem; }
  .l-features-grid { grid-template-columns: repeat(2, 1fr); gap: 2rem; }
  .l-trust-row { grid-template-columns: 1fr; gap: 1rem; }
  .l-steps { flex-direction: column; gap: 0.5rem; }
  .l-step-divider { width: 1px; height: 32px; margin-top: 0; }
  .l-features, .l-how { padding-left: 1.5rem; padding-right: 1.5rem; }
  .l-privacy { padding: 3rem 1.5rem; }
  .l-footer { padding: 1.5rem; }
}
@media (max-width: 600px) {
  .l-features-grid { grid-template-columns: 1fr; }
}
@media (max-width: 500px) {
  .l-title { font-size: 2.5rem; }
  .l-privacy-title { font-size: 1.5rem; }
}

/* ═══════════════════════════════════════
   DASHBOARD LAYOUT
   ═══════════════════════════════════════ */
.container {
  position: relative;
  z-index: 1;
  max-width: 1400px;
  margin: 0 auto;
  padding: 2rem 3rem 5rem;
}

/* Nav */
nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 2rem;
  padding-bottom: 1.2rem;
  border-bottom: 1px solid var(--border);
  gap: 1rem;
}
.logo {
  font-family: var(--serif);
  font-size: 1.2rem;
  font-weight: 700;
  color: var(--text);
  text-decoration: none;
  letter-spacing: -0.02em;
  white-space: nowrap;
}
.logo span { color: var(--accent); }

.nav-links {
  display: flex;
  gap: 0.25rem;
  list-style: none;
  background: var(--surface-alt);
  border-radius: 10px;
  padding: 4px;
}
.nav-links a {
  display: block;
  padding: 0.4rem 1rem;
  font-size: 0.8rem;
  font-weight: 500;
  color: var(--text-secondary);
  text-decoration: none;
  border-radius: 7px;
  transition: all 0.2s;
}
.nav-links a:hover { color: var(--text); background: rgba(255,255,255,0.6); }
.nav-links a.active {
  color: var(--text);
  background: var(--surface);
  box-shadow: var(--shadow-sm);
}

.new-upload-btn {
  padding: 0.4rem 0.9rem;
  font-size: 0.78rem;
  font-weight: 600;
  font-family: var(--sans);
  color: var(--text-muted);
  border: 1px solid var(--border);
  border-radius: 8px;
  background: transparent;
  cursor: pointer;
  transition: all 0.2s;
  white-space: nowrap;
}
.new-upload-btn:hover { color: var(--accent); border-color: var(--accent); background: var(--accent-bg); }

/* Page header */
.page-header {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  margin-bottom: 2rem;
  gap: 1rem;
  flex-wrap: wrap;
}
.page-header h1 {
  font-family: var(--serif);
  font-size: 2.4rem;
  font-weight: 700;
  letter-spacing: -0.03em;
  color: var(--text);
  line-height: 1.1;
}
.year-accent { color: var(--accent); }

/* Year selector */
.year-selector {
  display: flex;
  gap: 0.25rem;
  flex-wrap: wrap;
}
.year-selector button {
  padding: 0.35rem 0.8rem;
  font-size: 0.78rem;
  font-weight: 600;
  font-family: var(--sans);
  border: 1px solid var(--border);
  border-radius: 8px;
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  transition: all 0.2s;
}
.year-selector button:hover { color: var(--text); border-color: var(--border-strong); }
.year-selector button.active {
  background: var(--text);
  color: var(--bg);
  border-color: var(--text);
}

/* Summary */
.summary-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 1rem;
  margin-bottom: 2rem;
}
.summary-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.4rem;
  box-shadow: var(--shadow-sm);
  transition: transform 0.2s, box-shadow 0.2s;
}
.summary-card:hover { transform: translateY(-2px); box-shadow: var(--shadow); }
.summary-card .label {
  font-size: 0.68rem;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--text-muted);
  font-weight: 600;
  margin-bottom: 0.4rem;
}
.summary-card .value {
  font-family: var(--serif);
  font-size: 1.9rem;
  color: var(--text);
  letter-spacing: -0.02em;
  line-height: 1.2;
}
.summary-card .detail {
  font-size: 0.76rem;
  color: var(--text-muted);
  margin-top: 0.2rem;
}
.summary-card .detail em { font-style: normal; color: var(--accent); font-weight: 600; }
.summary-card .change {
  display: inline-flex;
  align-items: center;
  font-size: 0.7rem;
  font-weight: 600;
  padding: 0.12rem 0.45rem;
  border-radius: 20px;
  margin-top: 0.35rem;
}
.change.up { background: var(--red-bg); color: var(--red); }
.change.down { background: var(--green-bg); color: var(--green); }

/* Panel */
.panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.6rem;
  margin-bottom: 1.8rem;
  box-shadow: var(--shadow-sm);
}
.panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1rem;
}
.section-title {
  font-family: var(--serif);
  font-size: 1.25rem;
  font-weight: 500;
  color: var(--text);
}
.quick-link {
  font-size: 0.78rem;
  font-weight: 500;
  color: var(--accent);
  text-decoration: none;
  padding: 0.35rem 0.8rem;
  border: 1px solid rgba(224,122,58,0.25);
  border-radius: 8px;
  background: var(--accent-bg);
  transition: all 0.2s;
}
.quick-link:hover { background: rgba(224,122,58,0.15); border-color: var(--accent); }

/* Grids */
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 1.5rem; margin-bottom: 1.8rem; }
.grid-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 1.5rem; margin-bottom: 1.8rem; }

/* Chart wrappers */
.chart-wrap-md { position: relative; height: 300px; }
.chart-wrap-lg { position: relative; height: 370px; }
.chart-wrap-sm { position: relative; height: 240px; }

/* Category list */
.cat-list { list-style: none; max-height: 340px; overflow-y: auto; }
.cat-list li {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.55rem 0;
  border-bottom: 1px solid var(--border);
  font-size: 0.85rem;
}
.cat-list li:last-child { border-bottom: none; }
.cat-list .cat-name { display: flex; align-items: center; gap: 0.5rem; }
.cat-list .dot { width: 10px; height: 10px; border-radius: 3px; flex-shrink: 0; }
.cat-list .cat-amount { font-weight: 600; font-variant-numeric: tabular-nums; }
.cat-list .cat-pct { color: var(--text-muted); font-size: 0.7rem; margin-left: 0.4rem; }

/* Subcategory bars */
.subcat-group { margin-bottom: 1.4rem; }
.subcat-group-title {
  font-size: 0.72rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--text-muted);
  margin-bottom: 0.4rem;
  display: flex;
  justify-content: space-between;
}
.subcat-bar-row { display: flex; align-items: center; gap: 0.6rem; margin-bottom: 0.25rem; font-size: 0.78rem; }
.subcat-bar-label {
  width: 115px;
  flex-shrink: 0;
  text-align: right;
  color: var(--text-secondary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.subcat-bar-track { flex: 1; height: 18px; background: var(--surface-alt); border-radius: 5px; overflow: hidden; }
.subcat-bar-fill { height: 100%; border-radius: 5px; transition: width 0.8s cubic-bezier(0.22,1,0.36,1); }
.subcat-bar-val {
  width: 65px;
  flex-shrink: 0;
  font-variant-numeric: tabular-nums;
  font-weight: 600;
  font-size: 0.76rem;
}

/* ═══════════════════════════════════════
   SANKEY
   ═══════════════════════════════════════ */
.sankey-container { position: relative; overflow: visible; min-height: 600px; }
.sankey-container svg { display: block; cursor: default; }
.sankey-container .node rect { cursor: pointer; transition: opacity 0.2s; }
.sankey-container .node rect:hover { opacity: 1 !important; }
.sankey-container .node text { font-family: var(--sans); fill: var(--text-secondary); font-weight: 500; pointer-events: none; }
.sankey-container .link { fill: none; transition: stroke-opacity 0.25s; cursor: pointer; }
.sankey-container .link.dimmed { stroke-opacity: 0.04 !important; }
.sankey-container .link.highlighted { stroke-opacity: 0.55 !important; }
.sankey-container .node.dimmed rect { opacity: 0.15 !important; }
.sankey-container .node.dimmed text { opacity: 0.25; }

.legend-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem 1rem;
  margin-bottom: 1.2rem;
  padding-bottom: 0.8rem;
  border-bottom: 1px solid var(--border);
}
.legend-item {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  font-size: 0.72rem;
  color: var(--text-secondary);
  cursor: pointer;
  padding: 0.2rem 0.35rem;
  border-radius: 5px;
  transition: background 0.15s;
}
.legend-item:hover { background: var(--surface-alt); }
.legend-dot { width: 10px; height: 10px; border-radius: 3px; flex-shrink: 0; }

.sankey-hint {
  text-align: center;
  color: var(--text-muted);
  font-size: 0.76rem;
  margin-top: 0.6rem;
}
.sankey-hint span { background: var(--surface-alt); padding: 0.15rem 0.5rem; border-radius: 5px; font-weight: 500; }

/* Tooltip */
.sankey-tooltip {
  position: fixed;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 0.6rem 0.9rem;
  box-shadow: var(--shadow-lg);
  pointer-events: none;
  z-index: 500;
  font-size: 0.78rem;
  opacity: 0;
  transition: opacity 0.15s;
  max-width: 280px;
}
.sankey-tooltip.visible { opacity: 1; }
.tt-label { font-weight: 600; color: var(--text); margin-bottom: 0.15rem; }
.tt-value { color: var(--accent); font-weight: 700; font-size: 0.95rem; }
.tt-detail { color: var(--text-muted); font-size: 0.7rem; margin-top: 0.1rem; }

/* ═══════════════════════════════════════
   MODAL
   ═══════════════════════════════════════ */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(26,23,20,0.4);
  backdrop-filter: blur(8px);
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s;
}
.modal-overlay.open { opacity: 1; pointer-events: auto; }
.modal {
  background: var(--surface);
  border-radius: 18px;
  box-shadow: var(--shadow-lg);
  width: 680px;
  max-width: 92vw;
  max-height: 80vh;
  display: flex;
  flex-direction: column;
  transform: translateY(20px) scale(0.97);
  transition: transform 0.3s cubic-bezier(0.22,1,0.36,1);
}
.modal-overlay.open .modal { transform: translateY(0) scale(1); }
.modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1.3rem 1.6rem 0.8rem;
  border-bottom: 1px solid var(--border);
}
.modal-head h3 { font-family: var(--serif); font-size: 1.15rem; font-weight: 500; }
.modal-total { font-size: 0.8rem; color: var(--text-muted); margin-top: 0.1rem; }
.modal-close {
  width: 30px; height: 30px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: transparent;
  color: var(--text-muted);
  font-size: 1rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s;
}
.modal-close:hover { background: var(--surface-alt); color: var(--text); }
.modal-body { overflow-y: auto; padding: 0.3rem 1.6rem 1.3rem; flex: 1; }

.txn-table { width: 100%; border-collapse: collapse; font-size: 0.8rem; }
.txn-table thead th {
  text-align: left;
  font-size: 0.66rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--text-muted);
  font-weight: 600;
  padding: 0.7rem 0.4rem 0.4rem;
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  background: var(--surface);
}
.txn-table tbody td {
  padding: 0.45rem 0.4rem;
  border-bottom: 1px solid rgba(0,0,0,0.03);
  color: var(--text-secondary);
}
.txn-table tbody tr:hover td { background: var(--accent-bg); }
.txn-table .txn-amount { text-align: right; font-weight: 600; font-variant-numeric: tabular-nums; color: var(--text); }
.txn-table .txn-date { color: var(--text-muted); white-space: nowrap; }

/* ═══════════════════════════════════════
   TRENDS
   ═══════════════════════════════════════ */
.insight-cards { display: grid; grid-template-columns: repeat(3, 1fr); gap: 1rem; margin-bottom: 2rem; }
.insight-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.2rem 1.3rem;
  box-shadow: var(--shadow-sm);
}
.ic-label { font-size: 0.68rem; text-transform: uppercase; letter-spacing: 0.1em; color: var(--text-muted); font-weight: 600; margin-bottom: 0.3rem; }
.ic-value { font-family: var(--serif); font-size: 1.5rem; color: var(--text); }
.ic-detail { font-size: 0.72rem; color: var(--text-muted); margin-top: 0.15rem; }

.cat-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(330px, 1fr)); gap: 1rem; margin-bottom: 2rem; }
.trend-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.3rem;
  box-shadow: var(--shadow-sm);
}
.tc-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 0.8rem; }
.tc-cat { display: flex; align-items: center; gap: 0.4rem; font-weight: 600; font-size: 0.85rem; }
.tc-dot { width: 10px; height: 10px; border-radius: 3px; }
.tc-amount { font-family: var(--serif); font-size: 1.2rem; font-weight: 500; }
.tc-change { font-size: 0.7rem; font-weight: 600; padding: 0.12rem 0.45rem; border-radius: 20px; }
.tc-change.up { background: var(--red-bg); color: var(--red); }
.tc-change.down { background: var(--green-bg); color: var(--green); }

.yoy-table { width: 100%; border-collapse: collapse; font-size: 0.8rem; }
.yoy-table thead th {
  text-align: right;
  font-size: 0.66rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--text-muted);
  font-weight: 600;
  padding: 0.6rem 0.5rem;
  border-bottom: 2px solid var(--border);
}
.yoy-table thead th:first-child { text-align: left; }
.yoy-table tbody td {
  padding: 0.5rem 0.5rem;
  border-bottom: 1px solid var(--border);
  text-align: right;
  font-variant-numeric: tabular-nums;
  color: var(--text-secondary);
}
.yoy-table tbody td:first-child { text-align: left; font-weight: 500; color: var(--text); }
.yoy-table tbody tr:hover td { background: var(--accent-bg); }
.yoy-cell { cursor: pointer; transition: color 0.15s; }
.yoy-cell:hover { color: var(--accent) !important; text-decoration: underline; }
.yoy-table .highlight { font-weight: 700; color: var(--text); }
.change-badge {
  display: inline-block;
  font-size: 0.66rem;
  font-weight: 600;
  padding: 0.08rem 0.35rem;
  border-radius: 4px;
  min-width: 44px;
  text-align: center;
}
.change-badge.up { background: var(--red-bg); color: var(--red); }
.change-badge.down { background: var(--green-bg); color: var(--green); }
.change-badge.na { background: var(--surface-alt); color: var(--text-muted); }

/* Trend toggle */
.trend-toggle {
  display: flex;
  gap: 0.25rem;
  background: var(--surface-alt);
  border-radius: 9px;
  padding: 3px;
}
.trend-toggle-btn {
  padding: 0.3rem 0.85rem;
  font-size: 0.76rem;
  font-weight: 500;
  font-family: var(--sans);
  border: none;
  border-radius: 7px;
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  transition: all 0.2s;
}
.trend-toggle-btn:hover { color: var(--text-secondary); }
.trend-toggle-btn.active {
  background: var(--surface);
  color: var(--text);
  box-shadow: var(--shadow-sm);
  font-weight: 600;
}

/* ═══════════════════════════════════════
   ANIMATIONS
   ═══════════════════════════════════════ */
@keyframes fadeUp {
  from { opacity: 0; transform: translateY(16px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ═══════════════════════════════════════
   RESPONSIVE
   ═══════════════════════════════════════ */
@media (max-width: 1000px) {
  .container { padding: 1.5rem 1.2rem 4rem; }
  .summary-grid { grid-template-columns: repeat(2, 1fr); }
  .grid-2, .grid-3 { grid-template-columns: 1fr; }
  .page-header h1 { font-size: 1.9rem; }
  .insight-cards { grid-template-columns: 1fr; }
}
@media (max-width: 600px) {
  .summary-grid { grid-template-columns: 1fr; }
  .page-header { flex-direction: column; align-items: flex-start; }
  nav { flex-wrap: wrap; }
  .upload-hero h1 { font-size: 2.5rem; }
  .cat-grid { grid-template-columns: 1fr; }
}
