/* ─── Reset & Base ─────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; }

:root {
  --ink: #1a1a2e;
  --ink-light: #4a4a68;
  --ink-muted: #8e8ea0;
  --bg: #f7f8fc;
  --surface: #ffffff;
  --border: #e8e9f0;
  --border-light: #f0f1f5;
  --accent: #6366f1;
  --accent-light: #a5b4fc;
  --accent-bg: #eef2ff;
  --green: #10b981;
  --green-bg: #ecfdf5;
  --amber: #f59e0b;
  --amber-bg: #fffbeb;
  --red: #ef4444;
  --red-bg: #fef2f2;
  --blue: #3b82f6;
  --blue-bg: #eff6ff;
  --radius: 12px;
  --radius-sm: 8px;
  --shadow: 0 1px 3px rgba(0,0,0,0.06), 0 1px 2px rgba(0,0,0,0.04);
  --shadow-md: 0 4px 6px rgba(0,0,0,0.05), 0 2px 4px rgba(0,0,0,0.04);
  --shadow-lg: 0 10px 15px rgba(0,0,0,0.06), 0 4px 6px rgba(0,0,0,0.04);
  --font: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--ink);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

/* ─── Nav ──────────────────────────────────────────────── */
nav {
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: var(--ink);
  padding: 0 1.5rem;
  height: 56px;
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: 0 2px 8px rgba(0,0,0,0.15);
}

nav .brand {
  color: #fff;
  text-decoration: none;
  font-weight: 700;
  font-size: 1.05rem;
  letter-spacing: -0.02em;
}

nav .brand span {
  color: var(--accent-light);
  font-weight: 400;
}

nav .links {
  display: flex;
  gap: 0.25rem;
}

nav .links a {
  color: rgba(255,255,255,0.65);
  text-decoration: none;
  font-size: 0.875rem;
  font-weight: 500;
  padding: 0.4rem 0.75rem;
  border-radius: var(--radius-sm);
  transition: all 0.15s ease;
}

nav .links a:hover {
  color: #fff;
  background: rgba(255,255,255,0.1);
}

/* ─── Main ─────────────────────────────────────────────── */
main {
  max-width: 860px;
  margin: 0 auto;
  padding: 1.5rem 1.25rem 3rem;
}

/* ─── Headings ─────────────────────────────────────────── */
h1 {
  font-size: 1.5rem;
  font-weight: 700;
  letter-spacing: -0.03em;
  margin: 0 0 1rem;
  color: var(--ink);
}

h2 {
  font-size: 1rem;
  font-weight: 600;
  letter-spacing: -0.01em;
  margin: 1.5rem 0 0.75rem;
  color: var(--ink);
}

h3 {
  font-size: 0.8rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--ink-muted);
  margin: 0 0 0.5rem;
}

/* ─── Cards ────────────────────────────────────────────── */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem;
  margin-bottom: 1rem;
  box-shadow: var(--shadow);
  transition: box-shadow 0.2s ease;
}

.card:hover {
  box-shadow: var(--shadow-md);
}

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
  gap: 1rem;
}

/* ─── Tables ───────────────────────────────────────────── */
table {
  width: 100%;
  border-collapse: collapse;
}

thead th {
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--ink-muted);
  padding: 0 0.5rem 0.6rem;
  border-bottom: 2px solid var(--border);
  text-align: left;
}

thead th.num { text-align: right; }

td {
  padding: 0.65rem 0.5rem;
  border-bottom: 1px solid var(--border-light);
  font-size: 0.9rem;
}

.num {
  text-align: right;
  font-variant-numeric: tabular-nums;
  font-feature-settings: "tnum";
}

.highlight td {
  font-weight: 700;
  font-size: 0.95rem;
  border-bottom: none;
  padding-top: 0.8rem;
  padding-bottom: 0.2rem;
}

.split-head td {
  color: var(--ink-muted);
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  padding-top: 0.9rem;
  border-bottom: none;
}

.muted td { border-bottom: none; }

/* ─── Status Colors ────────────────────────────────────── */
.ok { color: var(--green); }
.warn { color: var(--amber); }
.error { color: var(--red); background: var(--red-bg, #fee2e2); padding: 0.4rem 0.6rem; border-radius: 0.4rem; display: inline-block; }

/* ─── Login Page ───────────────────────────────────────── */
body.login-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: radial-gradient(1000px 600px at 70% -10%, var(--accent-bg, rgba(99,102,241,.08)), transparent),
              var(--bg);
}

.login-card {
  background: var(--card-bg);
  border: 1px solid var(--border-light);
  border-radius: 1rem;
  box-shadow: var(--shadow);
  padding: 2.25rem;
  width: min(92vw, 380px);
}

.login-card h1 { margin: 0.25rem 0 1.25rem; font-size: 1.4rem; }

.centered { text-align: center; justify-content: center; }

/* ─── Big Numbers ──────────────────────────────────────── */
.big {
  font-size: 1.75rem;
  font-weight: 700;
  letter-spacing: -0.03em;
  color: var(--ink);
  margin: 0.25rem 0;
  line-height: 1.2;
}

.muted {
  color: var(--ink-muted);
  font-size: 0.8rem;
  line-height: 1.5;
}

.hint {
  color: var(--ink-muted);
  font-size: 0.8rem;
  margin-top: 0.75rem;
  line-height: 1.5;
}

/* ─── Progress Bars ────────────────────────────────────── */
.bar {
  background: var(--border);
  border-radius: 999px;
  height: 8px;
  overflow: hidden;
  margin: 0.5rem 0;
}

.fill {
  height: 100%;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--accent), var(--accent-light));
  transition: width 0.4s ease;
}

.fill.green { background: linear-gradient(90deg, var(--green), #34d399); }
.fill.amber { background: linear-gradient(90deg, var(--amber), #fbbf24); }
.fill.red { background: linear-gradient(90deg, var(--red), #f87171); }

/* ─── Row / Key-Value ──────────────────────────────────── */
.row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.35rem 0;
  font-size: 0.875rem;
}

.row + .row { border-top: 1px solid var(--border-light); }

/* ─── Forms ────────────────────────────────────────────── */
form.stack label {
  display: block;
  margin-bottom: 1rem;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--ink-light);
}

input, select, button {
  font-family: var(--font);
  font-size: 0.9rem;
}

input, select {
  padding: 0.6rem 0.75rem;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--ink);
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
  width: 100%;
}

input:focus, select:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-bg);
}

form.stack input { width: 100%; margin-top: 0.25rem; }

.inline {
  display: flex;
  gap: 0.5rem;
  align-items: center;
  margin: 0.5rem 0;
}

.inline input { flex: 1; }

/* ─── Buttons ──────────────────────────────────────────── */
button {
  font-family: var(--font);
  font-weight: 600;
  font-size: 0.875rem;
  padding: 0.55rem 1rem;
  border-radius: var(--radius-sm);
  border: 1.5px solid var(--border);
  background: var(--surface);
  color: var(--ink);
  cursor: pointer;
  transition: all 0.15s ease;
}

button:hover {
  background: var(--bg);
  border-color: var(--ink-muted);
}

button:active {
  transform: scale(0.98);
}

button.primary {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
  width: 100%;
}

button.primary:hover {
  background: #5558e6;
  border-color: #5558e6;
}

button.danger {
  background: var(--red-bg);
  color: var(--red);
  border-color: #fecaca;
}

button.danger:hover {
  background: #fecaca;
}

button.small {
  padding: 0.4rem 0.75rem;
  font-size: 0.8rem;
}

.actions {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
  margin-top: 1rem;
}

.actions button { flex: 1; }

label.checkbox {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  font-weight: 600;
  font-size: 0.9rem;
  cursor: pointer;
}

input[type="checkbox"] {
  width: 1.15rem;
  height: 1.15rem;
  accent-color: var(--accent);
}

/* ─── Goal Styles ──────────────────────────────────────── */
.goal-meta {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 0.5rem;
}

.goal-meta span:first-child {
  font-weight: 600;
  font-size: 0.9rem;
}

.goal-status {
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  padding: 0.15rem 0.5rem;
  border-radius: 999px;
  line-height: 1.4;
}

.goal-status.active { background: var(--green-bg); color: var(--green); }
.goal-status.paused { background: var(--amber-bg); color: var(--amber); }
.goal-status.completed { background: var(--blue-bg); color: var(--blue); }

.goal-actions {
  display: flex;
  gap: 0.35rem;
  flex-wrap: wrap;
  margin-top: 0.75rem;
  padding-top: 0.75rem;
  border-top: 1px solid var(--border-light);
}

.goal-actions button { flex: 1; font-size: 0.8rem; padding: 0.35rem 0.5rem; }

/* ─── Due Box ──────────────────────────────────────────── */
.due-box {
  background: var(--accent-bg);
  border: 1.5px solid var(--accent-light);
  color: var(--accent);
  border-radius: var(--radius-sm);
  padding: 0.6rem 0.75rem;
  margin: 0.6rem 0;
  font-size: 0.8rem;
  font-weight: 500;
}

.due-box.overdue, .due-box.warn {
  background: var(--red-bg);
  border-color: #fecaca;
  color: var(--red);
}

.due-box .warn { color: var(--amber); }

/* ─── Pay Form ─────────────────────────────────────────── */
.pay-form {
  display: flex;
  gap: 0.4rem;
  margin: 0.5rem 0;
}

.pay-form input {
  flex: 1;
  min-width: 0;
  font-size: 0.85rem;
  padding: 0.5rem 0.6rem;
}

.pay-form input[type="number"] { flex: 1.4; }

.pay-form button.primary-pay {
  background: var(--green);
  color: #fff;
  border-color: var(--green);
  font-size: 0.85rem;
  font-weight: 600;
  white-space: nowrap;
  padding: 0.5rem 1rem;
}

.pay-form button.primary-pay:hover {
  background: #059669;
  border-color: #059669;
}

/* ─── Payment Chips ────────────────────────────────────── */
.payment-log {
  display: flex;
  flex-wrap: wrap;
  gap: 0.3rem;
  align-items: center;
  margin: 0.6rem 0 0;
  padding-top: 0.6rem;
  border-top: 1px solid var(--border-light);
}

.payment-log .muted {
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.pay-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  background: var(--green-bg);
  border: 1px solid #a7f3d0;
  color: #065f46;
  border-radius: 999px;
  padding: 0.2rem 0.55rem;
  font-size: 0.78rem;
  font-weight: 500;
}

.pay-chip form { margin: 0; }

.pay-chip button.no-border {
  border: none;
  background: none;
  padding: 0 0.2rem;
  font-size: 0.85rem;
  color: var(--ink-muted);
  cursor: pointer;
}

.pay-chip button.no-border:hover { color: var(--red); }

/* ─── Links ────────────────────────────────────────────── */
a {
  color: var(--accent);
  text-decoration: none;
  font-weight: 500;
  transition: color 0.15s ease;
}

a:hover { color: #4f46e5; text-decoration: underline; }

/* ─── Utility ──────────────────────────────────────────── */
.card > p.hint:last-child { margin-top: 1rem; }

/* ─── Responsive ───────────────────────────────────────── */
@media (max-width: 640px) {
  nav { padding: 0 1rem; }
  nav .links a { margin-left: 0; padding: 0.35rem 0.5rem; font-size: 0.8rem; }
  main { padding: 1rem 0.75rem 2rem; }
  .grid { grid-template-columns: 1fr; }
  .big { font-size: 1.4rem; }
  table { font-size: 0.85rem; }
  td, th { padding: 0.5rem 0.35rem; }
}
