:root {
  --bg: #0b1727;
  --bg-soft: #061020;
  --glow-1: rgba(24, 194, 124, 0.15);
  --glow-2: rgba(245, 183, 0, 0.12);
  --card: #102a43;
  --card-2: #0c2035;
  --accent: #18c27c;
  --accent-2: #f5b700;
  --text: #eef4ff;
  --muted: #9ab4d0;
  --shadow: 0 20px 45px rgba(3, 15, 35, 0.45);
  --radius: 14px;
  --radius-lg: 18px;
  --border: 1px solid rgba(255, 255, 255, 0.08);
}

body[data-season="spring"] {
  --bg: #0c1c2c;
  --bg-soft: #0a1623;
  --glow-1: rgba(65, 201, 163, 0.18);
  --glow-2: rgba(180, 230, 120, 0.14);
  --accent: #41c9a3;
  --accent-2: #b4e678;
}

body[data-season="summer"] {
  --bg: #0f1d2d;
  --bg-soft: #0d1725;
  --glow-1: rgba(255, 186, 73, 0.16);
  --glow-2: rgba(63, 189, 255, 0.14);
  --accent: #f5b700;
  --accent-2: #3fbfff;
}

body[data-season="autumn"] {
  --bg: #16111c;
  --bg-soft: #120d17;
  --glow-1: rgba(255, 126, 51, 0.18);
  --glow-2: rgba(255, 200, 87, 0.12);
  --accent: #ff7e33;
  --accent-2: #ffc857;
}

body[data-season="winter"] {
  --bg: #08101e;
  --bg-soft: #06111f;
  --glow-1: rgba(124, 181, 255, 0.16);
  --glow-2: rgba(187, 215, 255, 0.1);
  --accent: #7cb5ff;
  --accent-2: #c2d8ff;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100vh;
  background: radial-gradient(circle at 20% 20%, var(--glow-1), transparent 35%),
              radial-gradient(circle at 80% 0%, var(--glow-2), transparent 30%),
              linear-gradient(135deg, var(--bg) 0%, var(--bg-soft) 100%);
  color: var(--text);
  font-family: "Space Grotesk", "Manrope", system-ui, -apple-system, sans-serif;
  line-height: 1.5;
  position: relative;
  overflow-x: hidden;
  scrollbar-color: var(--muted) rgba(255, 255, 255, 0.06);
}

.bg-shape {
  position: fixed;
  inset: 0;
  background: radial-gradient(circle at 40% 30%, var(--glow-1), transparent 40%),
              radial-gradient(circle at 80% 70%, var(--glow-2), transparent 35%);
  filter: blur(80px);
  z-index: 0;
}

.grain {
  position: fixed;
  inset: 0;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='160' height='160' viewBox='0 0 160 160'%3E%3Cfilter id='n' x='0' y='0'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.8' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='0.08'/%3E%3C/svg%3E");
  mix-blend-mode: overlay;
  pointer-events: none;
  z-index: 0;
}

.container {
  position: relative;
  z-index: 1;
  width: min(1100px, 92vw);
  margin: 32px auto 80px;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 2;
  backdrop-filter: blur(10px);
  background: rgba(11, 23, 39, 0.75);
  border-bottom: var(--border);
  padding: 14px 32px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  color: var(--text);
}

.top-nav { display: flex; gap: 12px; align-items: center; }
.nav-link { color: var(--muted); text-decoration: none; font-weight: 600; padding: 8px 10px; border-radius: 10px; }
.nav-link:hover { color: var(--text); background: rgba(255, 255, 255, 0.06); }
.nav-link.active { color: var(--text); background: rgba(255, 255, 255, 0.1); border: var(--border); }
.nav-auth { display: none; }
.authenticated .nav-auth { display: inline-flex; }
.authenticated .nav-welcome { display: none; }
.button { text-decoration: none; }

.brand {
  font-weight: 700;
  letter-spacing: 0.5px;
  font-size: 18px;
}

.brand span { color: var(--accent); }

.top-actions { display: flex; gap: 16px; align-items: center; }
.status { display: flex; gap: 8px; align-items: center; color: var(--muted); }
.dot { width: 10px; height: 10px; border-radius: 50%; background: #f86161; box-shadow: 0 0 0 6px rgba(248, 97, 97, 0.15); }
.dot.online { background: var(--accent); box-shadow: 0 0 0 6px rgba(24, 194, 124, 0.18); animation: dotPulse 2s ease-in-out infinite; }

button {
  border: none;
  border-radius: 999px;
  padding: 12px 18px;
  font-weight: 600;
  cursor: pointer;
  background: linear-gradient(135deg, var(--accent), #11a369);
  color: #04101f;
  box-shadow: var(--shadow);
  transition: transform 0.15s ease, box-shadow 0.15s ease, opacity 0.2s ease;
}

button:hover { transform: translateY(-1px); box-shadow: 0 16px 35px rgba(0, 0, 0, 0.45); }
button:active { transform: translateY(0); }
button:disabled { opacity: 0.6; cursor: not-allowed; }

button.ghost {
  background: rgba(255, 255, 255, 0.08);
  color: var(--text);
  box-shadow: none;
  border: var(--border);
}

a.button {
  display: inline-block;
  border-radius: 999px;
  padding: 12px 18px;
  font-weight: 600;
  background: linear-gradient(135deg, var(--accent), #11a369);
  color: #04101f;
  text-decoration: none;
  box-shadow: var(--shadow);
}
a.button:hover { transform: translateY(-1px); box-shadow: 0 16px 35px rgba(0, 0, 0, 0.45); }
a.button:active { transform: translateY(0); }
a.ghost { display: inline-block; }

button.compact { padding: 8px 12px; font-size: 13px; }

main.hero {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
  gap: 28px;
  margin-top: 24px;
}

.hero-copy {
  background: rgba(255, 255, 255, 0.02);
  border: var(--border);
  border-radius: var(--radius-lg);
  padding: 28px;
  box-shadow: var(--shadow);
}

.welcome { grid-template-columns: repeat(auto-fit, minmax(340px, 1fr)); align-items: start; }
.welcome-list { color: var(--text); padding-left: 18px; line-height: 1.6; }
.welcome-actions { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 10px; }
.success-pill { display: inline-flex; padding: 8px 12px; border-radius: 999px; background: rgba(24, 194, 124, 0.14); border: 1px solid rgba(24, 194, 124, 0.4); color: #d8ffe9; margin-top: 10px; }
.alert-pill { position: relative; display: inline-flex; gap: 8px; align-items: center; padding: 10px 16px; border-radius: 999px; background: linear-gradient(135deg, rgba(248,97,97,0.85), rgba(242,155,56,0.85)); color: #fff7f0; border: 1px solid rgba(248,97,97,0.6); font-weight: 800; margin-top: 12px; box-shadow: 0 10px 30px rgba(248, 97, 97, 0.25); animation: alertPulse 2s ease-in-out infinite; letter-spacing: 0.3px; }
.alert-pill::before, .alert-pill::after { content: "★"; color: #ffdfb3; text-shadow: 0 0 8px rgba(248,97,97,0.65); }

.hero h1 { margin: 6px 0 12px; font-size: clamp(28px, 4vw, 40px); }
.lede { color: var(--muted); margin-bottom: 16px; }
.eyebrow { text-transform: uppercase; letter-spacing: 1px; color: var(--accent); font-weight: 700; font-size: 12px; margin: 0 0 4px; }

.pills { display: flex; gap: 10px; flex-wrap: wrap; }
.pills span {
  background: rgba(255, 255, 255, 0.07);
  border-radius: 999px;
  padding: 8px 12px;
  color: var(--text);
  border: var(--border);
  font-size: 13px;
}

.hero-panel {
  background: var(--card);
  border-radius: var(--radius-lg);
  padding: 20px;
  box-shadow: var(--shadow);
  border: var(--border);
}

.import-hero { grid-template-columns: repeat(auto-fit, minmax(340px, 1fr)); }
.import-panel { display: grid; gap: 12px; }
.dropzone {
  border: 2px dashed rgba(255, 255, 255, 0.25);
  border-radius: var(--radius-lg);
  padding: 16px;
  display: flex;
  align-items: center;
  gap: 12px;
  cursor: pointer;
  transition: border-color 0.2s ease, background 0.2s ease;
  background: rgba(255, 255, 255, 0.04);
}
.dropzone.dragging { border-color: var(--accent); background: rgba(24, 194, 124, 0.08); }
.drop-icon { font-size: 26px; }
.import-actions { display: flex; gap: 10px; flex-wrap: wrap; }
.preview-meta { color: var(--muted); }

.panel-heading h2 { margin: 4px 0 0; }
.panel-heading p { margin: 2px 0 12px; color: var(--muted); }

.auth-forms { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 18px; }

.card {
  background: var(--card-2);
  border-radius: var(--radius);
  padding: 16px;
  border: var(--border);
  display: grid;
  gap: 10px;
}

.card.alt { background: rgba(255, 255, 255, 0.03); }

.card-heading { font-weight: 700; font-size: 15px; }

label { display: grid; gap: 6px; font-size: 13px; color: var(--muted); }
input, select {
  width: 100%;
  background: rgba(255, 255, 255, 0.04);
  border: var(--border);
  border-radius: 10px;
  padding: 12px;
  color: var(--text);
  font-size: 15px;
}

.message {
  margin-top: 10px;
  padding: 12px 14px;
  border-radius: 10px;
  background: rgba(248, 97, 97, 0.12);
  color: #fcd5d5;
  border: 1px solid rgba(248, 97, 97, 0.3);
  min-height: 0;
}

.message.success {
  background: rgba(24, 194, 124, 0.14);
  border-color: rgba(24, 194, 124, 0.4);
  color: #d8ffe9;
}

.local-warning {
  display: flex;
  gap: 12px;
  padding: 12px 14px;
  background: rgba(255, 255, 255, 0.04);
  border: var(--border);
  border-radius: 12px;
  box-shadow: var(--shadow);
  margin: 10px 0 16px;
  align-items: flex-start;
}

.local-warning strong { display: block; margin-bottom: 2px; }
.local-warning p { margin: 4px 0 0; color: var(--muted); }

.warn-icon {
  width: 28px;
  height: 28px;
  border-radius: 10px;
  background: rgba(248, 97, 97, 0.16);
  border: 1px solid rgba(248, 97, 97, 0.45);
  color: #ffe4e4;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  flex-shrink: 0;
}

.dashboard.hidden { display: none; }

.section-heading { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; flex-wrap: wrap; margin-bottom: 4px; }
.section-heading h2 { margin: 4px 0 0; font-size: clamp(22px, 3vw, 28px); }
.stacked { display: grid; gap: 6px; font-size: 13px; color: var(--muted); }

.metrics-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 14px;
  margin: 18px 0;
}
.metrics-grid { gap: 18px; }

.metric {
  padding: 18px;
  background: rgba(255, 255, 255, 0.03);
  border-radius: var(--radius);
  border: var(--border);
  box-shadow: var(--shadow);
}

.metric.highlight { background: linear-gradient(135deg, rgba(24, 194, 124, 0.15), rgba(24, 194, 124, 0.05)); border-color: rgba(24, 194, 124, 0.4); }

.metric .label { color: var(--muted); margin: 0 0 6px; }
.metric h3 { margin: 0; font-size: 28px; }
.metric .sub { color: var(--muted); margin: 4px 0 0; }

.coverage-low { color: #f86161; }
.coverage-mid { color: var(--accent-2); }
.coverage-high { color: var(--accent); }

.panels-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); gap: 18px; margin-top: 8px; }
.panel.wide + .panels-grid { margin-top: 18px; }

.panel {
  background: var(--card);
  border-radius: var(--radius-lg);
  padding: 18px;
  border: var(--border);
  box-shadow: var(--shadow);
}

.panel.wide { margin-top: 16px; }
.panel + .panels-grid { margin-top: 18px; }

.panel-heading h3 { margin: 4px 0 0; }
.panel-heading .eyebrow { margin: 0; }

.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 10px; margin: 10px 0 14px; }
.profile-grid { grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); }

.site-footer {
  width: min(1100px, 92vw);
  margin: 30px auto 40px;
  color: var(--muted);
  display: flex;
  justify-content: space-between;
  gap: 12px;
  font-size: 13px;
  padding-top: 12px;
  border-top: var(--border);
  position: relative;
  z-index: 1;
}

.site-footer a {
  color: var(--text);
  text-decoration: underline;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-weight: 700;
}

.panel.collapsed #profileBody { display: none; }

.profile-spacing { margin-bottom: 16px; }
.profile-spacing + .panels-grid { margin-top: 8px; }

.table-wrapper { overflow-x: auto; border-radius: 12px; border: var(--border); background: rgba(255, 255, 255, 0.02); max-height: 260px; overflow-y: auto; }
.table-wrapper.tall { max-height: 360px; }

table { width: 100%; border-collapse: collapse; min-width: 480px; }
th, td { padding: 10px 12px; text-align: left; }
th { font-size: 13px; color: var(--muted); background: rgba(255, 255, 255, 0.03); }
tbody tr:nth-child(odd) { background: rgba(255, 255, 255, 0.02); }
tbody tr:hover { background: rgba(24, 194, 124, 0.06); }

.tag { padding: 6px 10px; border-radius: 999px; font-size: 12px; border: 1px solid rgba(255, 255, 255, 0.1); }

.badge-income { color: #0d8f57; background: rgba(24, 194, 124, 0.12); border-color: rgba(24, 194, 124, 0.4); }
.badge-outcome { color: #e59f2b; background: rgba(245, 183, 0, 0.12); border-color: rgba(245, 183, 0, 0.4); }

.history { display: grid; gap: 10px; }
.history-card {
  display: grid;
  grid-template-columns: 1fr auto auto;
  gap: 10px;
  align-items: center;
  padding: 12px 14px;
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.03);
  border: var(--border);
}

.history .meta { color: var(--muted); font-size: 13px; }

.badge {
  font-weight: 600;
  padding: 6px 10px;
  border-radius: 10px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  background: rgba(255, 255, 255, 0.05);
}

#history .amount { font-weight: 700; }

.note { color: var(--muted); margin: 0 0 6px; font-size: 13px; }
.empty { color: var(--muted); font-size: 14px; padding: 10px 0; }

.status-chip { display: inline-flex; align-items: center; gap: 6px; padding: 6px 10px; border-radius: 12px; font-size: 12px; border: 1px solid rgba(255, 255, 255, 0.15); }
.chip-paid { color: #0d8f57; background: rgba(24, 194, 124, 0.12); border-color: rgba(24, 194, 124, 0.4); }
.chip-unpaid { color: #f29b38; background: rgba(242, 155, 56, 0.12); border-color: rgba(242, 155, 56, 0.4); }
.chip-due { color: #f86161; background: rgba(248, 97, 97, 0.12); border-color: rgba(248, 97, 97, 0.4); }
.due-soon { animation: pulseRed 1.4s ease-in-out infinite; }

.progress { width: 100%; background: rgba(255, 255, 255, 0.06); border-radius: 999px; border: var(--border); height: 18px; overflow: hidden; }
.progress-fill { height: 100%; background: linear-gradient(135deg, var(--accent), var(--accent-2)); color: #04101f; font-weight: 700; font-size: 12px; display: flex; align-items: center; justify-content: center; }
.progress-fill.low { background: linear-gradient(135deg, #f86161, #f29b38); color: #1a0c0c; }
.progress-fill.mid { background: linear-gradient(135deg, #f5b700, #f29b38); color: #1a1200; }
.progress-fill.high { background: linear-gradient(135deg, #18c27c, #11a369); color: #04101f; }

.section-heading.stacked .note { margin: 0; color: var(--muted); }
.goals-preview { margin-top: 8px; }
.panels-grid { gap: 22px; }

.tips-list { display: grid; gap: 10px; }
.tip-card {
  padding: 12px 14px;
  border-radius: var(--radius);
  border: var(--border);
  background: rgba(255, 255, 255, 0.03);
  box-shadow: var(--shadow);
}
.tip-card strong { display: block; margin-bottom: 4px; }
.tip-card p { margin: 0; color: var(--muted); }

.quick-steps { margin: 0; padding-left: 18px; color: var(--muted); display: grid; gap: 4px; }
.quick-steps li { line-height: 1.5; }

.badge-grid {
  display: grid;
  gap: 12px;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  margin-top: 10px;
}

.badge-card {
  padding: 14px;
  border-radius: var(--radius);
  border: var(--border);
  background: rgba(255, 255, 255, 0.03);
  box-shadow: var(--shadow);
  display: grid;
  gap: 6px;
}

.badge-card.locked { opacity: 0.55; border-style: dashed; }
.badge-card.unlocked { background: linear-gradient(135deg, rgba(24, 194, 124, 0.12), rgba(24, 194, 124, 0.04)); }

.badge-header { display: flex; justify-content: space-between; gap: 8px; align-items: center; }
.badge-title { font-weight: 700; }
.badge-tag {
  font-size: 12px;
  padding: 4px 8px;
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  color: var(--muted);
}
.badge-card p { margin: 0; color: var(--muted); }

.badge-grid[style*="display: none"] { display: none !important; }

.badge-grid::-webkit-scrollbar,
.table-wrapper::-webkit-scrollbar,
body::-webkit-scrollbar {
  width: 10px;
  height: 10px;
}

.badge-grid::-webkit-scrollbar-thumb,
.table-wrapper::-webkit-scrollbar-thumb,
body::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.18);
  border-radius: 999px;
}

.badge-grid::-webkit-scrollbar-track,
.table-wrapper::-webkit-scrollbar-track,
body::-webkit-scrollbar-track {
  background: rgba(255, 255, 255, 0.05);
}

@media (max-width: 720px) {
  .topbar { padding: 12px 18px; flex-wrap: wrap; gap: 8px; }
  .top-nav { flex-wrap: wrap; width: 100%; }
  .top-actions { width: 100%; justify-content: space-between; }
  .container { width: 94vw; margin: 20px auto 60px; }
  th, td { font-size: 13px; }
  .history-card { grid-template-columns: 1fr; }
  .filters { width: 100%; }
  .filters input, .filters select { width: 100%; }
  .metrics-grid { grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); }
  .hero { grid-template-columns: 1fr; }
  .panel, .hero-panel, .hero-copy { padding: 16px; }
  .alert-pill { font-size: 13px; padding: 9px 12px; }
  .site-footer { flex-direction: column; align-items: center; text-align: center; gap: 6px; }
}

@media (prefers-reduced-motion: no-preference) {
  .metric, .panel, .hero-copy, .hero-panel { animation: floatIn 0.6s ease both; }
}

@keyframes floatIn {
  from { opacity: 0; transform: translateY(12px); }
  to { opacity: 1; transform: translateY(0); }
}

@keyframes dotPulse {
  0% { box-shadow: 0 0 0 6px rgba(24, 194, 124, 0.18); }
  50% { box-shadow: 0 0 0 10px rgba(24, 194, 124, 0.12); }
  100% { box-shadow: 0 0 0 6px rgba(24, 194, 124, 0.18); }
}

@keyframes pulseRed {
  0% { box-shadow: 0 0 0 0 rgba(248, 97, 97, 0.3); }
  50% { box-shadow: 0 0 0 8px rgba(248, 97, 97, 0.12); }
  100% { box-shadow: 0 0 0 0 rgba(248, 97, 97, 0.3); }
}

@keyframes alertPulse {
  0% { filter: drop-shadow(0 0 0 rgba(248,97,97,0.25)); }
  50% { filter: drop-shadow(0 4px 12px rgba(242,155,56,0.4)); }
  100% { filter: drop-shadow(0 0 0 rgba(248,97,97,0.25)); }
}
