/* ClearBudget — responsive dark UI. Mobile-first, no framework. */

:root {
  --bg: #0f172a;
  --bg-elev: #0b1326;
  --surface: #1e293b;
  --surface-2: #243449;
  --text: #e2e8f0;
  --muted: #94a3b8;
  --accent: #2dd4bf;
  --accent-ink: #052e2b;
  --warn: #fbbf24;
  --danger: #f87171;
  --border: #334155;
  --radius: 14px;
  --radius-sm: 10px;
  --shadow: 0 6px 24px rgba(2, 6, 23, 0.45);
  --shadow-sm: 0 2px 8px rgba(2, 6, 23, 0.35);
  --font: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --tap: 44px;
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  font-family: var(--font);
  color: var(--text);
  background:
    radial-gradient(1200px 600px at 50% -200px, #15233f 0%, rgba(21, 35, 63, 0) 60%),
    var(--bg);
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

.wrap {
  width: 100%;
  max-width: 880px;
  margin-inline: auto;
  padding-inline: 20px;
}

a { color: var(--accent); }

/* ---------- Hero ---------- */
.hero {
  padding: 48px 0 28px;
  border-bottom: 1px solid var(--border);
  background: linear-gradient(180deg, rgba(45, 212, 191, 0.06), rgba(45, 212, 191, 0));
}
.brand {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-weight: 800;
  letter-spacing: -0.01em;
  color: var(--accent);
  font-size: 1.05rem;
  margin-bottom: 14px;
}
.brand::before {
  content: "";
  width: 22px;
  height: 22px;
  border-radius: 6px;
  background: var(--accent);
  box-shadow: inset 0 0 0 4px var(--accent-ink);
}
.hero h1 {
  margin: 0 0 12px;
  font-size: clamp(1.8rem, 4.6vw, 2.6rem);
  line-height: 1.12;
  letter-spacing: -0.02em;
  font-weight: 800;
}
.sub {
  margin: 0 0 16px;
  max-width: 60ch;
  color: var(--muted);
  font-size: 1.05rem;
}
.trust {
  display: inline-block;
  margin: 0;
  padding: 7px 13px;
  font-size: 0.84rem;
  color: var(--text);
  background: rgba(45, 212, 191, 0.1);
  border: 1px solid rgba(45, 212, 191, 0.28);
  border-radius: 999px;
}

/* ---------- Layout ---------- */
main.wrap { padding-top: 26px; padding-bottom: 56px; }

.grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 18px;
  margin-bottom: 18px;
}
@media (min-width: 720px) {
  .grid { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: var(--shadow-sm);
}
.card-title {
  margin: 0 0 14px;
  font-size: 1rem;
  font-weight: 700;
  letter-spacing: 0.01em;
  color: var(--text);
}

/* ---------- Form ---------- */
.expense-form { display: grid; gap: 14px; }
.field { display: grid; gap: 6px; }
.field label {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--muted);
}

input[type="text"],
input[type="date"],
input[type="number"],
select {
  width: 100%;
  min-height: var(--tap);
  padding: 10px 12px;
  font: inherit;
  color: var(--text);
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  outline: none;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
  appearance: none;
}
select {
  background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%),
    linear-gradient(135deg, var(--muted) 50%, transparent 50%);
  background-position: calc(100% - 18px) calc(50% - 2px), calc(100% - 13px) calc(50% - 2px);
  background-size: 5px 5px, 5px 5px;
  background-repeat: no-repeat;
  padding-right: 36px;
}
input::placeholder { color: #64748b; }
input[type="text"]:focus,
input[type="date"]:focus,
input[type="number"]:focus,
select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(45, 212, 191, 0.28);
}
input[type="date"] { color-scheme: dark; }

.amount-field input {
  font-size: 1.5rem;
  font-weight: 700;
  letter-spacing: -0.01em;
  min-height: 52px;
}
.note-field input { color: var(--muted); }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: var(--tap);
  padding: 10px 16px;
  font: inherit;
  font-weight: 600;
  color: var(--text);
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: background-color 0.15s ease, border-color 0.15s ease, transform 0.05s ease;
}
.btn:hover { background: #2c3e57; }
.btn:active { transform: translateY(1px); }
.btn:focus-visible {
  outline: none;
  box-shadow: 0 0 0 3px rgba(45, 212, 191, 0.4);
}
.btn.primary {
  width: 100%;
  color: var(--accent-ink);
  background: var(--accent);
  border-color: transparent;
  font-weight: 800;
  font-size: 1rem;
}
.btn.primary:hover { background: #34e3cf; }
.btn.danger {
  color: var(--danger);
  background: transparent;
  border-color: rgba(248, 113, 113, 0.45);
}
.btn.danger:hover { background: rgba(248, 113, 113, 0.12); }

.chip {
  align-self: start;
  justify-self: start;
  min-height: 32px;
  margin-top: 2px;
  padding: 4px 11px;
  font: inherit;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--muted);
  background: transparent;
  border: 1px solid var(--border);
  border-radius: 999px;
  cursor: pointer;
  transition: color 0.15s ease, border-color 0.15s ease;
}
.chip:hover { color: var(--accent); border-color: var(--accent); }

.form-error {
  margin: 0;
  color: var(--danger);
  font-size: 0.85rem;
  font-weight: 600;
}

/* ---------- Budget block ---------- */
.budget-block { margin-bottom: 18px; }
.budget-line {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 8px;
  margin-bottom: 8px;
}
.budget-spent { font-size: 1.05rem; font-weight: 700; }
.budget-of { color: var(--muted); font-size: 0.92rem; }
.budget-edit {
  margin-left: auto;
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--accent);
  background: transparent;
  border: 0;
  cursor: pointer;
  padding: 2px 4px;
  border-radius: 6px;
}
.budget-edit:hover { text-decoration: underline; }
.budget-input { max-width: 140px; min-height: 38px; }

.budget-remaining { font-size: 0.85rem; color: var(--muted); margin-bottom: 8px; }
.budget-remaining.over { color: var(--danger); font-weight: 600; }

.bar {
  height: 12px;
  border-radius: 999px;
  background: var(--bg-elev);
  border: 1px solid var(--border);
  overflow: hidden;
}
.bar-fill {
  height: 100%;
  width: 0;
  border-radius: 999px;
  background: var(--accent);
  transition: width 0.45s cubic-bezier(0.22, 1, 0.36, 1), background-color 0.25s ease;
}
.bar-fill.warn { background: var(--warn); }
.bar-fill.over { background: var(--danger); }

.over-pill {
  display: inline-block;
  margin-left: 8px;
  padding: 2px 9px;
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--danger);
  background: rgba(248, 113, 113, 0.14);
  border: 1px solid rgba(248, 113, 113, 0.4);
  border-radius: 999px;
}
.budget-cta {
  margin: 0;
  color: var(--muted);
  font-size: 0.92rem;
}
.budget-cta .budget-edit { margin-left: 6px; }

/* ---------- Chart + legend ---------- */
.chart {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 200px;
  margin: 4px 0 14px;
}
.chart svg { max-height: 200px; }
.chart-empty {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 100%;
  width: 100%;
  color: var(--muted);
  font-size: 0.9rem;
  text-align: center;
  border: 1px dashed var(--border);
  border-radius: 999px;
  aspect-ratio: 1 / 1;
  max-width: 180px;
  margin-inline: auto;
}

.legend { display: grid; gap: 2px; }
.legend-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 7px 8px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: background-color 0.15s ease;
}
.legend-row:hover { background: var(--surface-2); }
.legend-row.active { background: var(--surface-2); box-shadow: inset 0 0 0 1px var(--border); }
.legend-swatch {
  width: 12px;
  height: 12px;
  border-radius: 3px;
  flex: none;
}
.legend-name { font-size: 0.9rem; }
.legend-amount { margin-left: auto; font-size: 0.9rem; font-weight: 600; }
.legend-pct { color: var(--muted); font-size: 0.8rem; min-width: 3ch; text-align: right; }

/* ---------- Expense list ---------- */
.list-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}
.list-head .card-title { margin: 0; }
.actions { display: flex; gap: 8px; }

.list { display: grid; gap: 2px; }
.month-head {
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--muted);
  padding: 14px 4px 6px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 4px;
}
.row {
  display: grid;
  grid-template-columns: auto 1fr auto auto;
  align-items: center;
  gap: 12px;
  padding: 11px 6px;
  border-bottom: 1px solid rgba(51, 65, 85, 0.5);
}
.row:last-child { border-bottom: 0; }
.row-date { font-size: 0.8rem; color: var(--muted); min-width: 3.2ch; }
.row-main { min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.row-cat {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  font-size: 0.9rem;
  font-weight: 600;
}
.row-dot { width: 9px; height: 9px; border-radius: 50%; flex: none; }
.row-note {
  font-size: 0.8rem;
  color: var(--muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.row-amount { font-weight: 700; font-variant-numeric: tabular-nums; }
.row-del {
  width: 30px;
  height: 30px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 0.95rem;
  color: var(--muted);
  background: transparent;
  border: 0;
  border-radius: 8px;
  cursor: pointer;
  opacity: 0.55;
  transition: color 0.15s ease, background-color 0.15s ease, opacity 0.15s ease;
}
.row:hover .row-del { opacity: 1; }
.row-del:hover { color: var(--danger); background: rgba(248, 113, 113, 0.12); }
.row-del:focus-visible { opacity: 1; outline: none; box-shadow: 0 0 0 3px rgba(248, 113, 113, 0.4); }

.empty {
  text-align: center;
  padding: 26px 12px;
  color: var(--muted);
}
.empty p { margin: 0 0 14px; }

/* ---------- Toast + banner ---------- */
.toast {
  position: fixed;
  left: 50%;
  bottom: 22px;
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 11px 16px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 999px;
  box-shadow: var(--shadow);
  z-index: 50;
  font-size: 0.9rem;
  animation: toast-in 0.2s ease;
}
.toast button {
  font: inherit;
  font-weight: 700;
  color: var(--accent);
  background: transparent;
  border: 0;
  cursor: pointer;
  padding: 2px 4px;
}
@keyframes toast-in {
  from { opacity: 0; transform: translate(-50%, 12px); }
  to { opacity: 1; transform: translate(-50%, 0); }
}

.banner {
  margin: 0 0 16px;
  padding: 11px 14px;
  font-size: 0.88rem;
  color: #1f1300;
  background: var(--warn);
  border-radius: var(--radius-sm);
  font-weight: 600;
}

.notice {
  padding: 12px 14px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--muted);
}

/* ---------- Static SEO content ---------- */
.content {
  margin-top: 40px;
  padding-top: 8px;
  max-width: 68ch;
}
.content h2 {
  font-size: 1.35rem;
  letter-spacing: -0.01em;
  margin: 34px 0 10px;
}
.content p { color: #cbd5e1; }
.content ol { color: #cbd5e1; padding-left: 20px; }
.content ol li { margin-bottom: 6px; }

.compare {
  width: 100%;
  border-collapse: collapse;
  margin: 16px 0 8px;
  font-size: 0.92rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}
.compare th, .compare td {
  padding: 11px 13px;
  text-align: left;
  border-bottom: 1px solid var(--border);
}
.compare thead th {
  background: var(--surface);
  font-weight: 700;
  color: var(--text);
}
.compare thead th:last-child { color: var(--accent); }
.compare tbody tr:nth-child(odd) { background: rgba(30, 41, 59, 0.45); }
.compare tbody td:first-child { font-weight: 600; color: var(--muted); }
.compare tbody td:last-child { color: var(--text); font-weight: 600; }
.compare tr:last-child td { border-bottom: 0; }

.faq { margin: 12px 0 0; }
.faq dt { font-weight: 700; margin-top: 16px; }
.faq dd { margin: 4px 0 0; color: #cbd5e1; }

/* ---------- Footer ---------- */
.site-foot {
  border-top: 1px solid var(--border);
  padding: 26px 0;
  margin-top: 24px;
}
.site-foot p {
  margin: 0;
  color: var(--muted);
  font-size: 0.85rem;
  text-align: center;
}

/* ---------- Motion preferences ---------- */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
  }
}

/* ---------- Guide / article pages ---------- */
.topnav {
  border-bottom: 1px solid var(--border);
  background: var(--bg-elev);
}
.topnav .wrap { display: flex; align-items: center; min-height: 56px; }
.topnav-home {
  display: inline-flex; align-items: center; gap: 8px;
  font-weight: 800; letter-spacing: -0.01em; color: var(--accent);
  text-decoration: none; font-size: 1rem;
}
.topnav-home:hover { text-decoration: underline; }

.crumbs {
  font-size: 0.82rem; color: var(--muted);
  padding: 16px 0 0;
}
.crumbs a { color: var(--muted); }
.crumbs a:hover { color: var(--accent); }

.article { max-width: 72ch; margin-top: 8px; padding-bottom: 8px; }
.article h1 {
  font-size: clamp(1.7rem, 4.2vw, 2.4rem); line-height: 1.15;
  letter-spacing: -0.02em; font-weight: 800; margin: 14px 0 6px;
}
.article .lede { font-size: 1.08rem; color: var(--muted); margin: 0 0 8px; }
.article h2 { font-size: 1.3rem; letter-spacing: -0.01em; margin: 32px 0 10px; }
.article h3 { font-size: 1.05rem; margin: 22px 0 6px; }
.article p, .article li { color: #cbd5e1; }
.article ul, .article ol { padding-left: 20px; }
.article ul li, .article ol li { margin-bottom: 6px; }
.article code {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 0.88em; background: var(--bg-elev);
  border: 1px solid var(--border); border-radius: 6px; padding: 1px 6px;
}

.cta-card {
  margin: 26px 0; padding: 20px; text-align: center;
  background: linear-gradient(180deg, rgba(45,212,191,0.08), rgba(45,212,191,0));
  border: 1px solid rgba(45,212,191,0.28); border-radius: var(--radius);
}
.cta-card p { margin: 0 0 14px; color: var(--text); font-weight: 600; }
.cta-card .btn.primary { width: auto; padding: 12px 22px; }

.related {
  margin: 30px 0 8px; padding-top: 18px; border-top: 1px solid var(--border);
}
.related h2 { margin-top: 0; font-size: 1.1rem; }
.related ul { list-style: none; padding: 0; display: grid; gap: 8px; }
.related a {
  display: block; padding: 12px 14px; border: 1px solid var(--border);
  border-radius: var(--radius-sm); background: var(--surface);
  text-decoration: none; color: var(--text); font-weight: 600;
  transition: border-color 0.15s ease, background-color 0.15s ease;
}
.related a:hover { border-color: var(--accent); background: var(--surface-2); }

/* Homepage guides subsection */
.guides-list { list-style: none; padding: 0; display: grid; gap: 8px; margin: 12px 0 0; }
.guides-list a {
  display: block; padding: 12px 14px; border: 1px solid var(--border);
  border-radius: var(--radius-sm); background: var(--surface);
  text-decoration: none; color: var(--text); font-weight: 600;
  transition: border-color 0.15s ease, background-color 0.15s ease;
}
.guides-list a:hover { border-color: var(--accent); background: var(--surface-2); }
.guides-list a span { display: block; font-weight: 400; font-size: 0.85rem; color: var(--muted); margin-top: 2px; }
