/* ============================================================
   Abo-Tracker — "Midnight Ledger"
   Warm dark editorial fintech. Gold accent, Fraunces + Hanken Grotesk.
   ============================================================ */

/* --- Fonts (self-hosted, variable) --- */
@font-face {
  font-family: 'Fraunces';
  font-style: normal;
  font-weight: 100 900;
  font-display: swap;
  src: url('/vendor/fonts/fraunces-wght-normal.woff2') format('woff2-variations');
}
@font-face {
  font-family: 'Fraunces';
  font-style: italic;
  font-weight: 100 900;
  font-display: swap;
  src: url('/vendor/fonts/fraunces-wght-italic.woff2') format('woff2-variations');
}
@font-face {
  font-family: 'Hanken Grotesk';
  font-style: normal;
  font-weight: 100 900;
  font-display: swap;
  src: url('/vendor/fonts/hanken-grotesk-wght-normal.woff2') format('woff2-variations');
}

:root {
  --bg: #100e0b;
  --bg-deep: #0a0907;
  --surface: #19161200;          /* base, overridden below */
  --card: #1a1713;
  --card-hi: #221d17;
  --border: rgba(245, 240, 230, 0.09);
  --border-hi: rgba(245, 240, 230, 0.18);

  --text: #f4eee2;
  --text-dim: #b6ae9f;
  --text-faint: #837c6e;

  --gold: #f0c14b;
  --gold-deep: #d6a232;
  --gold-soft: rgba(240, 193, 75, 0.13);
  --danger: #e8836c;
  --danger-soft: rgba(232, 131, 108, 0.14);
  --ok: #a9c08a;

  --font-display: 'Fraunces', Georgia, 'Times New Roman', serif;
  --font-body: 'Hanken Grotesk', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;

  --radius: 18px;
  --radius-sm: 11px;
  --shadow: 0 1px 0 rgba(255,255,255,0.03) inset, 0 18px 40px -22px rgba(0,0,0,0.8);
  --ring: 0 0 0 3px rgba(240, 193, 75, 0.22);
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  font-family: var(--font-body);
  font-weight: 400;
  color: var(--text);
  background-color: var(--bg);
  background-image:
    radial-gradient(1000px 520px at 82% -10%, rgba(240, 193, 75, 0.12), transparent 60%),
    radial-gradient(760px 620px at 2% 108%, rgba(176, 138, 166, 0.07), transparent 55%);
  background-attachment: fixed;
  background-repeat: no-repeat;
  min-height: 100vh;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  letter-spacing: 0.005em;
}

/* Fine grain overlay for atmosphere */
body::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  opacity: 0.5;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='160' height='160'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='2' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='0.04'/%3E%3C/svg%3E");
}

a { color: var(--gold); text-decoration: none; }
a:hover { color: var(--text); }

::selection { background: var(--gold-soft); color: var(--text); }

/* ---------------- Topbar ---------------- */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 32px;
  border-bottom: 1px solid var(--border);
  background: rgba(16, 14, 11, 0.72);
  backdrop-filter: saturate(140%) blur(14px);
  -webkit-backdrop-filter: saturate(140%) blur(14px);
  position: sticky;
  top: 0;
  z-index: 20;
}
.brand {
  display: inline-flex;
  align-items: center;
  gap: 11px;
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 1.28rem;
  letter-spacing: -0.01em;
  color: var(--text);
}
.brand:hover { color: var(--text); }
.brand .coin {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: radial-gradient(circle at 32% 28%, #ffe9a8, var(--gold) 42%, var(--gold-deep) 100%);
  box-shadow: 0 0 0 1px rgba(255,255,255,0.25) inset, 0 0 18px -2px rgba(240,193,75,0.7);
  flex: none;
}
.brand .accent { color: var(--gold); }
.topnav { display: flex; align-items: center; gap: 16px; }
.user {
  color: var(--text-dim);
  font-size: 0.86rem;
  letter-spacing: 0.01em;
}

/* ---------------- Layout ---------------- */
.container { max-width: 1100px; margin: 0 auto; padding: 40px 32px 72px; }
.footer {
  text-align: center;
  color: var(--text-faint);
  font-size: 0.8rem;
  letter-spacing: 0.04em;
  padding: 28px;
}

.page-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 26px;
}
.page-head h1 {
  margin: 0;
  font-family: var(--font-display);
  font-weight: 540;
  font-size: clamp(1.9rem, 4vw, 2.6rem);
  letter-spacing: -0.02em;
  line-height: 1.05;
}
.eyebrow {
  display: inline-block;
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--gold);
  margin-bottom: 10px;
}
.muted { color: var(--text-dim); margin: 4px 0 0; }
.muted.center { text-align: center; }

/* ---------------- Buttons ---------------- */
.btn {
  --b: transparent;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding: 11px 19px;
  border-radius: 100px;
  border: 1px solid var(--b);
  font-family: var(--font-body);
  font-size: 0.9rem;
  font-weight: 600;
  letter-spacing: 0.01em;
  cursor: pointer;
  background: transparent;
  color: var(--text);
  transition: transform 0.18s cubic-bezier(.2,.7,.2,1), background 0.18s, border-color 0.18s, color 0.18s, box-shadow 0.18s;
}
.btn:hover { text-decoration: none; transform: translateY(-1px); }
.btn:active { transform: translateY(0); }
.btn-primary {
  background: linear-gradient(180deg, #f6cd63, var(--gold-deep));
  color: #2a1f06;
  box-shadow: 0 10px 26px -12px rgba(240,193,75,0.8);
}
.btn-primary:hover { color: #2a1f06; box-shadow: 0 14px 30px -10px rgba(240,193,75,0.95); }
.btn-ghost { border-color: var(--border-hi); color: var(--text-dim); }
.btn-ghost:hover { color: var(--text); border-color: var(--text-dim); background: rgba(255,255,255,0.03); }
.btn-danger { border-color: var(--danger-soft); color: var(--danger); }
.btn-danger:hover { background: var(--danger); color: #2a1009; border-color: var(--danger); }
.btn-small { padding: 7px 13px; font-size: 0.8rem; }
.btn-block { width: 100%; }
.inline { display: inline; }

/* ---------------- Hero ---------------- */
.hero {
  display: grid;
  grid-template-columns: 1.15fr 0.85fr;
  gap: 10px;
  align-items: center;
  background:
    radial-gradient(120% 140% at 100% 0%, rgba(240,193,75,0.10), transparent 55%),
    linear-gradient(180deg, var(--card-hi), var(--card));
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 34px 36px;
  margin-bottom: 18px;
  overflow: hidden;
}
.hero-left { min-width: 0; }
.hero-number {
  margin: 0;
  font-family: var(--font-display);
  font-weight: 560;
  font-size: clamp(3rem, 8vw, 5.2rem);
  line-height: 0.96;
  letter-spacing: -0.03em;
  color: var(--text);
  font-variant-numeric: tabular-nums;
}
.hero-sub { margin: 16px 0 0; color: var(--text-dim); font-size: 1rem; }
.hero-sub strong { color: var(--text); font-weight: 600; }
.hero-right { position: relative; height: 230px; }
.hero-empty {
  display: flex; align-items: center; justify-content: center;
  height: 100%; color: var(--text-faint); font-style: italic;
  font-family: var(--font-display);
}

/* ---------------- Panels ---------------- */
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; margin-bottom: 18px; }
.panel {
  background: linear-gradient(180deg, var(--card-hi), var(--card));
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 26px 28px;
  transition: border-color 0.25s, transform 0.25s;
}
.panel:hover { border-color: var(--border-hi); }
.panel h2 {
  margin: 0 0 18px;
  font-family: var(--font-display);
  font-weight: 520;
  font-size: 1.18rem;
  letter-spacing: -0.01em;
}
.chart-box { position: relative; height: 100%; min-height: 200px; }

/* category breakdown */
.cat-list { list-style: none; margin: 0; padding: 0; }
.cat-list li { padding: 13px 0; border-top: 1px solid var(--border); }
.cat-list li:first-child { border-top: none; }
.cat-row { display: flex; align-items: center; gap: 11px; font-size: 0.95rem; }
.cat-dot { width: 10px; height: 10px; border-radius: 3px; flex: none; }
.cat-name { flex: 1; color: var(--text); }
.cat-amount { font-weight: 600; color: var(--text-dim); font-variant-numeric: tabular-nums; white-space: nowrap; }
.cat-bar { height: 4px; border-radius: 4px; background: rgba(255,255,255,0.06); margin-top: 9px; overflow: hidden; }
.cat-bar > span { display: block; height: 100%; border-radius: 4px; }

/* upcoming payments */
.upcoming { list-style: none; margin: 0; padding: 0; }
.upcoming li {
  display: flex; align-items: center; gap: 14px;
  padding: 13px 0; border-top: 1px solid var(--border);
}
.upcoming li:first-child { border-top: none; }
.up-date {
  font-variant-numeric: tabular-nums;
  color: var(--text-faint);
  font-size: 0.82rem;
  min-width: 86px;
}
.up-name { flex: 1; font-weight: 600; }
.up-amount { color: var(--text-dim); font-variant-numeric: tabular-nums; white-space: nowrap; }
.up-days {
  font-size: 0.72rem;
  color: var(--gold);
  background: var(--gold-soft);
  padding: 2px 8px;
  border-radius: 100px;
  white-space: nowrap;
}

/* ---------------- Table ---------------- */
.panel.table-panel { padding-top: 24px; }
.table-wrap { overflow-x: auto; margin: 0 -6px; }
.abo-table { width: 100%; border-collapse: collapse; font-size: 0.92rem; }
.abo-table th {
  text-align: left;
  color: var(--text-faint);
  font-weight: 600;
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  padding: 0 14px 14px;
  border-bottom: 1px solid var(--border);
}
.abo-table td { padding: 15px 14px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.abo-table tbody tr { transition: background 0.18s; }
.abo-table tbody tr:hover { background: rgba(255,255,255,0.025); }
.abo-table tr:last-child td { border-bottom: none; }
.abo-table .num { text-align: right; font-variant-numeric: tabular-nums; }
.abo-table .name-cell { display: flex; align-items: center; gap: 11px; }
.abo-table .name-cell strong { font-weight: 600; }
.abo-table tr.inactive td { color: var(--text-faint); }
.abo-table tr.inactive .name-cell strong { color: var(--text-dim); }
.abo-table .actions { white-space: nowrap; text-align: right; }
.abo-table .actions .btn { margin-left: 6px; }
.dot-pill { width: 9px; height: 9px; border-radius: 50%; flex: none; }

.badge {
  display: inline-block;
  padding: 3px 11px;
  border-radius: 100px;
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.02em;
}
.badge-on { background: rgba(169, 192, 138, 0.16); color: var(--ok); }
.badge-off { background: rgba(245,240,230,0.07); color: var(--text-faint); }
.badge-warn { background: var(--gold-soft); color: var(--gold); }

.cycle-tag { color: var(--text-dim); }

/* ---------------- Auth / form cards ---------------- */
.auth-wrap { display: flex; align-items: center; justify-content: center; min-height: calc(100vh - 200px); }
.auth-card, .form-card {
  background: linear-gradient(180deg, var(--card-hi), var(--card));
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow), 0 0 70px -30px rgba(240,193,75,0.4);
  padding: 38px 36px;
}
.auth-card { width: 100%; max-width: 410px; }
.form-card { max-width: 600px; margin: 8px auto; }
.auth-card .eyebrow { margin-bottom: 14px; }
.auth-card h1, .form-card h1 {
  margin: 0 0 8px;
  font-family: var(--font-display);
  font-weight: 540;
  font-size: 1.85rem;
  letter-spacing: -0.02em;
}
.auth-card > .muted { margin-bottom: 22px; }
.form-card > .muted { margin-bottom: 24px; }

form label {
  display: block;
  margin-bottom: 16px;
  font-size: 0.82rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  color: var(--text-dim);
}
form input[type="text"],
form input[type="email"],
form input[type="password"],
form input[type="number"],
form input[type="date"],
form select {
  width: 100%;
  margin-top: 8px;
  padding: 12px 14px;
  border: 1px solid var(--border-hi);
  border-radius: var(--radius-sm);
  font-family: var(--font-body);
  font-size: 0.98rem;
  font-weight: 450;
  color: var(--text);
  background: rgba(10, 9, 7, 0.55);
  transition: border-color 0.18s, box-shadow 0.18s, background 0.18s;
}
form input::placeholder { color: var(--text-faint); }
form input:focus, form select:focus {
  outline: none;
  border-color: var(--gold);
  box-shadow: var(--ring);
  background: rgba(10, 9, 7, 0.8);
}
form select {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' fill='none' stroke='%23b6ae9f' stroke-width='2'%3E%3Cpath d='M3 5l4 4 4-4'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 14px center;
  padding-right: 38px;
}
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.label-hint { color: var(--text-faint); font-weight: 400; }
.field-hint {
  display: block;
  margin-top: 7px;
  font-size: 0.78rem;
  font-weight: 400;
  letter-spacing: 0;
  line-height: 1.4;
  color: var(--text-faint);
}
label.checkbox {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 500;
  color: var(--text);
  font-size: 0.95rem;
  letter-spacing: 0;
  margin-bottom: 22px;
  cursor: pointer;
}
label.checkbox input { width: auto; margin: 0; accent-color: var(--gold); width: 17px; height: 17px; }
.form-actions { display: flex; gap: 12px; margin-top: 4px; }

/* ---------------- Alerts ---------------- */
.alert {
  padding: 12px 15px;
  border-radius: var(--radius-sm);
  font-size: 0.9rem;
  margin: 0 0 18px;
}
.alert-error { background: var(--danger-soft); color: #f0a690; border: 1px solid rgba(232,131,108,0.28); }

/* ---------------- Reveal animation ---------------- */
@keyframes rise {
  from { opacity: 0; transform: translateY(16px); }
  to   { opacity: 1; transform: none; }
}
.reveal { animation: rise 0.65s cubic-bezier(.2,.7,.2,1) both; }
.d1 { animation-delay: 0.04s; }
.d2 { animation-delay: 0.11s; }
.d3 { animation-delay: 0.19s; }
.d4 { animation-delay: 0.27s; }
.d5 { animation-delay: 0.35s; }

@media (prefers-reduced-motion: reduce) {
  .reveal { animation: none; }
  html { scroll-behavior: auto; }
}

/* ---------------- Responsive ---------------- */
@media (max-width: 820px) {
  .container { padding: 28px 20px 56px; }
  .topbar { padding: 16px 20px; }
  .hero { grid-template-columns: 1fr; padding: 28px 24px; }
  .hero-right { height: 220px; margin-top: 18px; }
  .grid-2 { grid-template-columns: 1fr; }
  .form-row { grid-template-columns: 1fr; }
  .page-head { flex-direction: column; align-items: stretch; gap: 14px; }
  .user { display: none; }
}
