/* ============ HabitPulse v2 — merged premium design ============ */
:root {
  --bg: #0a0e1a;
  --bg-soft: #111827;
  --card: #151d2e;
  --card-2: #1a2337;
  --border: #263252;
  --text: #eef2ff;
  --text-dim: #93a3c4;
  --primary: #22d3ee;
  --primary-2: #34d399;
  --grad-nav: linear-gradient(90deg, #4c1d95 0%, #6d28d9 45%, #7c3aed 100%);
  --grad-btn: linear-gradient(90deg, #10b981, #06b6d4);
  --green: #22c55e;
  --red: #ef4444;
  --amber: #f59e0b;
  --purple: #8b5cf6;
  --radius: 16px;
  --shadow: 0 10px 40px rgba(0, 0, 0, 0.45);
}

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

body {
  font-family: 'Inter', system-ui, sans-serif;
  background: radial-gradient(1000px 500px at 85% -5%, rgba(109, 40, 217, 0.18), transparent),
              radial-gradient(800px 400px at 0% 100%, rgba(6, 182, 212, 0.08), transparent),
              var(--bg);
  color: var(--text);
  min-height: 100vh;
}

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

/* ---------- Topbar (purple gradient, like merged design) ---------- */
.topbar {
  position: sticky; top: 0; z-index: 50;
  background: var(--grad-nav);
  box-shadow: 0 4px 24px rgba(76, 29, 149, 0.5);
}
.topbar-inner {
  width: 100%; margin: 0 auto; padding: 10px 40px;
  display: flex; align-items: center; gap: 14px;
}
/* Brand: icon on top, text below */
.brand { display: flex; flex-direction: column; align-items: center; gap: 2px; min-width: 110px; }
.brand .brand-top { font-size: 26px; line-height: 1; color: var(--primary);
  filter: drop-shadow(0 0 10px rgba(34, 211, 238, 0.45)); }
.brand .brand-text { font-size: 17px; font-weight: 800; letter-spacing: -0.3px; color: #fff; white-space: nowrap; }
.brand .brand-text span { color: var(--primary); }
.topbar nav { display: flex; gap: 2px; margin-left: auto; flex-wrap: nowrap; justify-content: center; overflow-x: auto; }
.topbar nav button {
  background: transparent; border: none; color: rgba(255,255,255,0.85); font-family: inherit; font-size: 13.5px;
  font-weight: 600; padding: 8px 12px; border-radius: 10px; cursor: pointer; transition: 0.2s;
  display: inline-flex; align-items: center; justify-content: center; gap: 6px; white-space: nowrap; flex: 0 0 auto;
}
.topbar nav button:hover { color: #fff; background: rgba(255,255,255,0.12); }
.topbar nav button.active { color: var(--primary); background: rgba(255,255,255,0.14); }
.user-chip { display: flex; align-items: center; gap: 10px; padding-left: 14px; border-left: 1px solid rgba(255,255,255,0.18); flex: 0 0 auto; }
.user-chip .who { text-align: right; line-height: 1.2; }
.user-chip .who .nm { color: var(--primary); font-weight: 700; font-size: 13.5px; }
.user-chip .who .rl { color: rgba(255,255,255,0.6); font-size: 11px; }
.avatar {
  width: 36px; height: 36px; border-radius: 50%; background: linear-gradient(135deg, #10b981, #06b6d4);
  display: flex; align-items: center; justify-content: center; font-weight: 700; font-size: 14px; color: #fff;
}
.btn-logout {
  background: rgba(239, 68, 68, 0.18); border: 1px solid rgba(239, 68, 68, 0.4); color: #fca5a5;
  padding: 8px 14px; border-radius: 10px; font-family: inherit; font-size: 13px; font-weight: 600; cursor: pointer;
}
.btn-logout:hover { background: rgba(239, 68, 68, 0.3); color: #fff; }

/* ---------- Layout ---------- */
.container { width: 100%; margin: 0 auto; padding: 32px 40px 60px; }
.page-head { margin-bottom: 26px; }
.page-title { font-size: 26px; font-weight: 800; letter-spacing: -0.5px; display: flex; align-items: center; gap: 10px; }
.page-sub { color: var(--text-dim); font-size: 14.5px; margin-top: 4px; }

/* ---------- Cards & stat tiles (icon style from other app) ---------- */
.card { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); padding: 22px; }
.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 16px; margin-bottom: 24px; }
.planner-totals {
  position: sticky; top: var(--planner-sticky-top, 80px); z-index: 45;
  padding: 10px 0; margin: 0 0 24px; background: var(--bg);
}
.stat-card { border-radius: var(--radius); padding: 18px 20px; border: 1px solid; display: flex; justify-content: space-between; align-items: center; }
.stat-card .stat-label { font-size: 13px; font-weight: 600; opacity: 0.9; }
.stat-card .stat-value { font-size: 26px; font-weight: 800; margin-top: 4px; letter-spacing: -0.5px; }
.stat-card .stat-icon { font-size: 30px; opacity: 0.9; }
.stat-green { background: rgba(16, 185, 129, 0.1); border-color: rgba(16, 185, 129, 0.35); }
.stat-green .stat-label, .stat-green .stat-icon { color: var(--green); }
.stat-red { background: rgba(239, 68, 68, 0.1); border-color: rgba(239, 68, 68, 0.35); }
.stat-red .stat-label, .stat-red .stat-icon { color: var(--red); }
.stat-purple { background: rgba(139, 92, 246, 0.1); border-color: rgba(139, 92, 246, 0.35); }
.stat-purple .stat-label, .stat-purple .stat-icon { color: var(--purple); }
.stat-amber { background: rgba(245, 158, 11, 0.1); border-color: rgba(245, 158, 11, 0.35); }
.stat-amber .stat-label, .stat-amber .stat-icon { color: var(--amber); }
.stat-cyan { background: rgba(34, 211, 238, 0.1); border-color: rgba(34, 211, 238, 0.35); }
.stat-cyan .stat-label, .stat-cyan .stat-icon { color: var(--primary); }

/* ---------- Buttons & forms ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 11px 20px; border: none; border-radius: 11px; font-size: 14px; font-weight: 700;
  font-family: inherit; cursor: pointer; transition: transform 0.1s, filter 0.2s; color: #fff;
  background: var(--grad-btn);
}
.btn:hover { filter: brightness(1.12); }
.btn:active { transform: scale(0.98); }
.btn-danger { background: var(--red); }
.btn-ghost { background: transparent; border: 1px solid var(--border); color: var(--text); }
.btn-sm { padding: 7px 13px; font-size: 12.5px; border-radius: 9px; }
.form-group { margin-bottom: 16px; }
.form-group label { display: block; font-size: 13px; font-weight: 600; margin-bottom: 6px; color: var(--text-dim); }
input, select {
  padding: 11px 14px; background: var(--bg-soft); border: 1px solid var(--border);
  border-radius: 10px; color: var(--text); font-size: 14px; font-family: inherit; outline: none;
  transition: border-color 0.2s;
}
input:focus, select:focus { border-color: var(--primary); }
.error-msg { background: rgba(239, 68, 68, 0.12); color: #fca5a5; padding: 10px 12px; border-radius: 10px; font-size: 13px; margin-bottom: 14px; display: none; }
.error-msg.show { display: block; }
.auth-notice { background: rgba(34, 197, 94, 0.12); color: var(--green); padding: 10px 12px; border-radius: 10px; font-size: 13px; margin-bottom: 14px; }
.auth-notice[hidden] { display: none; }

/* ---------- Auth ---------- */
.auth-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 20px; }
.auth-card { width: 100%; max-width: 420px; background: var(--card); border: 1px solid var(--border); border-radius: 22px; padding: 38px; box-shadow: var(--shadow); }
.auth-logo { text-align: center; margin-bottom: 24px; }
.auth-logo .logo-mark { font-size: 44px; color: var(--primary); }
.auth-logo h1 { font-size: 27px; font-weight: 800; }
.auth-logo h1 span { color: var(--primary); }
.auth-logo p { color: var(--text-dim); font-size: 13px; margin-top: 4px; }
.auth-switch { text-align: center; margin-top: 18px; font-size: 14px; color: var(--text-dim); }
.auth-card input { width: 100%; }
.captcha-question { color: var(--text); font-weight: 700; margin: 8px 0; }
.captcha-answer-row { display: flex; gap: 8px; }
.captcha-answer-row input { flex: 1; }
.captcha-answer-row button { flex: 0 0 48px; }

/* ---------- Dashboard extras ---------- */
.dash-grid { align-items: start; }
.today-row { display: flex; justify-content: space-between; align-items: center; padding: 11px 4px; border-bottom: 1px solid var(--border); font-size: 14px; }
.today-row:last-of-type { border-bottom: none; }
.today-name { font-weight: 600; }
.snap-row { display: flex; justify-content: space-between; font-size: 13.5px; padding: 8px 0; border-bottom: 1px dashed var(--border); }
.snap-row:last-of-type { border-bottom: none; }
.dash-note { margin-top: 12px; font-size: 12.5px; color: var(--text-dim); background: var(--bg-soft); border-radius: 10px; padding: 10px 12px; line-height: 1.5; }
.dash-note b { color: var(--primary); }

/* ---------- Month nav ---------- */
.month-nav { display: flex; align-items: center; gap: 14px; margin-bottom: 20px; flex-wrap: wrap; }
.month-nav h2 { font-size: 19px; font-weight: 800; min-width: 180px; text-align: center; }
.month-nav button.nav-arrow {
  background: var(--card-2); border: 1px solid var(--border); color: var(--text); width: 36px; height: 36px;
  border-radius: 10px; cursor: pointer; font-size: 16px; transition: 0.2s;
}
.month-nav button.nav-arrow:hover { border-color: var(--primary); }

/* ---------- Habit grid ---------- */
.grid-card { overflow-x: auto; }
.legend { display: flex; gap: 18px; align-items: center; font-size: 12.5px; color: var(--text-dim); margin-bottom: 14px; flex-wrap: wrap; }
.legend .dot { width: 12px; height: 12px; border-radius: 4px; display: inline-block; margin-right: 6px; vertical-align: -1px; }
table.habit-grid { border-collapse: separate; border-spacing: 3px; width: 100%; }
table.habit-grid th { font-size: 11px; color: var(--text-dim); font-weight: 600; padding: 4px; }
table.habit-grid th.habit-name { text-align: left; font-size: 13.5px; color: var(--text); padding-right: 14px; min-width: 150px; }
.day-btn {
  width: 30px; height: 30px; border-radius: 8px; border: 1px solid var(--border); background: var(--bg-soft);
  cursor: pointer; font-size: 10px; color: var(--text-dim); font-family: inherit; transition: 0.15s;
}
.day-btn:hover { border-color: var(--primary); z-index: 2; }
.day-btn.done { background: var(--green); border-color: var(--green); color: #04220f; font-weight: 700; }
.day-btn.missed { background: var(--red); border-color: var(--red); color: #2a0505; font-weight: 700; }
.day-btn.today { outline: 2px solid var(--primary); outline-offset: 1px; }
.day-btn.future { border-style: dashed; }
.day-btn.future.none { color: var(--text-dim); }
.day-cell-content { position: relative; width: 30px; margin: auto; }
.day-hover-options {
  position: absolute; z-index: 5; top: 50%; left: 50%; display: flex; gap: 3px;
  padding: 5px; border: 1px solid var(--border); border-radius: 9px;
  background: var(--card); box-shadow: 0 4px 12px rgba(0,0,0,.5);
  opacity: 0; visibility: hidden; pointer-events: none;
  transform: translate(-50%, -45%); transition: opacity 0.12s, transform 0.12s, visibility 0.12s;
}
.day-cell-content.picker-open .day-hover-options {
  opacity: 1; visibility: visible; pointer-events: auto; transform: translate(-50%, -50%);
}
.day-choice {
  flex: 0 0 24px; width: 24px; height: 26px; padding: 0; border: 1px solid var(--card);
  border-radius: 6px; font-size: 12px; line-height: 24px; text-align: center; cursor: pointer; color: #fff;
  box-shadow: 0 1px 3px rgba(0,0,0,.45);
}
.day-choice.done { background: var(--green); }
.day-choice.missed { background: var(--red); }
.day-choice.clear { background: var(--bg-soft); color: var(--text); }
.habit-sort-row { display: flex; align-items: center; gap: 10px; margin-bottom: 14px; color: var(--text-dim); font-size: 13px; flex-wrap: wrap; }
.habit-sort-row select { padding: 8px 10px; }
.tracker-heading-form { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin: 0 0 14px; }
.tracker-heading-form[hidden] { display: none; }
.tracker-heading-form label { color: var(--text-dim); font-size: 13px; }
.tracker-heading-form input { min-width: 220px; padding: 8px 10px; }
.tracker-section-row td { padding: 8px 4px 3px; }
.tracker-section-heading { display: flex; align-items: center; gap: 10px; min-height: 30px; color: var(--primary); }
.draggable-section { cursor: default; }
.section-drag-handle { color: var(--text-dim); cursor: grab; font-size: 17px; line-height: 1; }
.draggable-section:active .section-drag-handle { cursor: grabbing; }
.tracker-section-row.drop-section .tracker-section-heading { border-radius: 8px; }
.tracker-section-row.drop-section:hover .tracker-section-heading { background: var(--bg-soft); }
.tracker-section-row.drag-target .tracker-section-heading { background: var(--bg-soft); outline: 1px dashed var(--primary); }
.tracker-section-actions { display: flex; gap: 4px; margin-left: auto; }
.tracker-section-actions .icon-btn { background: transparent; border: 1px solid var(--border); border-radius: 7px; color: var(--text-dim); cursor: pointer; padding: 3px 7px; font-size: 11px; }
.tracker-section-actions .icon-btn:hover { color: var(--text); border-color: var(--primary); }
.tracker-section-divider { display: block; width: 100%; border-top: 1px dashed var(--border); }
.tracker-section-row.separator td { padding-top: 12px; padding-bottom: 4px; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; }
.habit-row.draggable-habit { cursor: grab; }
.habit-row.draggable-habit:active { cursor: grabbing; }
.habit-row { transition: background-color 0.18s ease; }
.habit-row > td { transition: background-color 0.18s ease; }
.habit-row:hover { background-color: rgba(34, 211, 238, 0.08); }
.habit-row:hover > td { background-color: rgba(34, 211, 238, 0.08); }
.habit-row.dragging { opacity: .45; }
.tracker-section-row.dragging { opacity: .45; }
.habit-row.drag-target td { background: var(--bg-soft); }
.habit-title { display: flex; align-items: center; gap: 7px; font-weight: 700; }
.drag-handle { color: var(--text-dim); cursor: grab; font-size: 17px; line-height: 1; }
.sticky-date-header {
  position: fixed; z-index: 45; display: none; overflow: hidden; pointer-events: none;
  background: var(--card); border-bottom: 1px solid var(--border); box-shadow: 0 5px 12px rgba(0,0,0,.32);
}
.sticky-date-table { table-layout: fixed; margin: 0; }
.sticky-date-table th { position: static !important; background: var(--card); }
.habit-actions { display: flex; gap: 6px; }
.habit-actions .icon-btn { background: transparent; border: 1px solid var(--border); border-radius: 7px; color: var(--text-dim); cursor: pointer; padding: 4px 8px; font-size: 12px; }
.habit-actions .icon-btn:hover { color: var(--text); border-color: var(--primary); }
.add-row { display: flex; gap: 10px; margin-top: 18px; flex-wrap: wrap; }
.add-row input { flex: 1; min-width: 160px; }
.add-row .penalty-input { max-width: 130px; flex: 0 0 auto; }

/* ---------- Purchases ---------- */
.purchase-card { margin-bottom: 18px; }
.purchase-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; flex-wrap: wrap; }
.purchase-name { font-size: 18px; font-weight: 800; display: flex; align-items: center; gap: 9px; }
.purchase-meta { color: var(--text-dim); font-size: 12.5px; margin-top: 3px; }
.planner-amounts { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; margin-top: 14px; }
.planner-amounts > div { display: flex; flex-direction: column; gap: 4px; padding: 10px 12px; border-radius: 10px; background: var(--bg-soft); }
.planner-amounts span { color: var(--text-dim); font-size: 11px; text-transform: uppercase; letter-spacing: 0.5px; }
.planner-amounts strong { font-size: 16px; font-variant-numeric: tabular-nums; }
.countdown-box { text-align: right; }
.countdown-days { font-size: 24px; font-weight: 800; color: var(--primary); }
.countdown-label { font-size: 11.5px; color: var(--text-dim); text-transform: uppercase; letter-spacing: 0.6px; }
.countdown-time { font-size: 12.5px; color: var(--amber); font-weight: 700; margin-top: 2px; font-variant-numeric: tabular-nums; }
.daily-price-banner {
  margin: 16px 0; padding: 14px 18px; border-radius: 12px; display: flex; align-items: center; gap: 14px; flex-wrap: wrap;
  background: linear-gradient(90deg, rgba(34, 211, 238, 0.12), rgba(139, 92, 246, 0.12));
  border: 1px solid rgba(34, 211, 238, 0.3);
}
.daily-price-banner .amount { font-size: 24px; font-weight: 800; color: var(--primary); }
.daily-price-banner .lbl { font-size: 12px; color: var(--text-dim); text-transform: uppercase; letter-spacing: 0.6px; }
.progress-track { height: 12px; background: var(--bg-soft); border-radius: 8px; overflow: hidden; margin: 14px 0 6px; }
.progress-fill { height: 100%; border-radius: 8px; background: var(--grad-btn); transition: width 0.6s; }
.pdays { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 14px; overflow: visible; }
.pday-wrap { position: relative; }
.pday {
  width: 38px; height: 38px; border-radius: 9px; border: 1px solid var(--border); background: var(--bg-soft);
  cursor: pointer; font-family: inherit; font-size: 12px; color: var(--text-dim); transition: 0.15s; position: relative;
}
.pday:hover { transform: scale(1.1); border-color: var(--primary); z-index: 2; }
.pday.saved { background: var(--green); border-color: var(--green); color: #04220f; font-weight: 800; }
.pday.missed { background: rgba(239, 68, 68, 0.18); border-color: rgba(239, 68, 68, 0.5); color: var(--red); font-weight: 800; }
.pday.today { outline: 2px solid var(--primary); outline-offset: 1px; }
.pday.future { opacity: 0.85; cursor: pointer; border-style: dashed; }
.pday.expired { opacity: 0.3; cursor: not-allowed; }
.pday-picker {
  position: absolute; z-index: 8; bottom: calc(100% + 7px); left: 50%;
  display: flex; gap: 4px; padding: 5px;
  border: 1px solid var(--border); border-radius: 9px;
  background: var(--card); box-shadow: 0 4px 12px rgba(0,0,0,.5);
  opacity: 0; visibility: hidden; pointer-events: none;
  transform: translate(-50%, 4px); transition: opacity .12s, transform .12s, visibility .12s;
}
.pday-wrap.picker-open { z-index: 7; }
.pday-wrap.picker-open .pday-picker {
  opacity: 1; visibility: visible; pointer-events: auto; transform: translate(-50%, 0);
}
.pday-choice {
  width: 28px; height: 28px; padding: 0; border: 1px solid var(--border);
  border-radius: 6px; cursor: pointer; color: white; font: inherit; font-size: 13px;
}
.pday-choice.saved { background: var(--green); color: #04220f; }
.pday-choice.missed { background: var(--red); color: #2a0505; }
.pday-choice.unmarked { background: var(--bg-soft); color: var(--text); }
.include-future-toggle {
  display: flex; align-items: center; gap: 10px; width: fit-content; margin: 0 0 18px;
  padding: 10px 14px; color: var(--text-dim); background: var(--card);
  border: 1px solid var(--border); border-radius: 10px; font-size: 13px; cursor: pointer;
}
.include-future-toggle input { width: 17px; height: 17px; accent-color: var(--primary); }

/* ---------- Reports & graphs ---------- */
.report-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
@media (max-width: 920px) { .report-grid { grid-template-columns: 1fr; } }
.section-title { font-size: 15.5px; font-weight: 800; margin-bottom: 16px; display: flex; align-items: center; gap: 8px; }
.graph-wrap { width: 100%; overflow-x: auto; }
.bar-row { display: flex; align-items: center; gap: 10px; margin-bottom: 12px; font-size: 13px; }
.bar-row .bar-name { min-width: 120px; font-weight: 600; }
.bar-track { flex: 1; height: 10px; background: var(--bg-soft); border-radius: 6px; overflow: hidden; }
.bar-fill { height: 100%; border-radius: 6px; background: var(--green); transition: width 0.5s; }
.bar-fill.bad { background: var(--red); }
.bar-pct { min-width: 44px; text-align: right; color: var(--text-dim); font-size: 12px; }
.suggestion { display: flex; gap: 10px; padding: 12px 14px; background: var(--bg-soft); border-radius: 11px; margin-bottom: 10px; font-size: 13.5px; line-height: 1.5; }
.data-table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.data-table th, .data-table td { padding: 10px 12px; text-align: left; border-bottom: 1px solid var(--border); }
.data-table th { color: var(--text-dim); font-size: 11.5px; text-transform: uppercase; letter-spacing: 0.5px; }
.data-table tr:hover td { background: var(--bg-soft); }
.badge { display: inline-block; padding: 3px 10px; border-radius: 20px; font-size: 11.5px; font-weight: 700; }
.badge.green { background: rgba(34, 197, 94, 0.15); color: var(--green); }
.badge.red { background: rgba(239, 68, 68, 0.15); color: var(--red); }
.badge.amber { background: rgba(245, 158, 11, 0.15); color: var(--amber); }
.badge.cyan { background: rgba(34, 211, 238, 0.15); color: var(--primary); }

/* ---------- Admin ---------- */
.admin-table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.admin-table th, .admin-table td { padding: 11px 12px; text-align: left; border-bottom: 1px solid var(--border); white-space: nowrap; }
.admin-table th { color: var(--text-dim); font-size: 11.5px; text-transform: uppercase; letter-spacing: 0.5px; }
.admin-table tr:hover td { background: var(--bg-soft); }
.admin-table .actions { display: flex; gap: 6px; flex-wrap: wrap; }
.admin-create-user { display: flex; align-items: end; gap: 10px; flex-wrap: wrap; }
.admin-create-user > input { flex: 1 1 170px; min-width: 150px; }
.admin-create-user label { display: flex; flex-direction: column; gap: 5px; color: var(--text-dim); font-size: 12px; }
.admin-create-user label input { padding: 8px 10px; }
.account-backup-actions { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.account-backup-actions label { cursor: pointer; }
.admin-mark-filter { display: flex; align-items: center; gap: 10px; margin: 0 0 12px; font-size: 13px; color: var(--text-dim); }
.admin-mark-filter select { max-width: 100%; }
.recent-marks-scroll { max-height: 500px; overflow: auto; }
.recent-marks-scroll .admin-table { min-width: 560px; }
.role-badge { font-size: 10.5px; font-weight: 800; padding: 3px 9px; border-radius: 20px; text-transform: uppercase; letter-spacing: 0.5px; }
.role-badge.master { background: rgba(245, 158, 11, 0.18); color: var(--amber); }
.role-badge.user { background: rgba(34, 211, 238, 0.18); color: var(--primary); }
.status-badge { font-size: 11px; font-weight: 700; }
.status-badge.active { color: var(--green); }
.status-badge.suspended { color: var(--red); }
.status-badge.pending { color: var(--amber); }

/* ---------- Settings ---------- */
.settings-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
@media (max-width: 800px) { .settings-grid { grid-template-columns: 1fr; } }
.settings-grid input { width: 100%; }

/* ---------- Modal ---------- */
.modal-overlay { position: fixed; inset: 0; background: rgba(0,0,0,0.7); z-index: 90; display: flex; align-items: center; justify-content: center; padding: 20px; }
.modal-card { width: 100%; max-width: 860px; max-height: 88vh; overflow-y: auto; }

/* ---------- Toast ---------- */
#toast { position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%) translateY(20px); background: var(--card-2); border: 1px solid var(--border); color: var(--text); padding: 12px 22px; border-radius: 12px; font-size: 14px; box-shadow: var(--shadow); opacity: 0; pointer-events: none; transition: 0.3s; z-index: 100; max-width: 90vw; }
#toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ---------- Footer (3-column, merged design) ---------- */
.footer { background: var(--bg-soft); border-top: 1px solid var(--border); margin-top: 40px; }
.footer-inner { width: 100%; margin: 0 auto; padding: 36px 40px 20px; display: grid; grid-template-columns: 1.4fr 1fr 1fr; gap: 32px; }
.footer .f-brand { font-size: 19px; font-weight: 800; display: flex; align-items: center; gap: 8px; }
.footer .f-brand span { color: var(--primary); }
.footer .f-desc { color: var(--text-dim); font-size: 13px; line-height: 1.7; margin-top: 10px; max-width: 320px; }
.footer h4 { font-size: 14px; font-weight: 800; margin-bottom: 12px; }
.footer ul { list-style: none; }
.footer ul li { color: var(--text-dim); font-size: 13px; margin-bottom: 8px; }
.f-dev-btn { display: inline-flex; align-items: center; gap: 8px; background: var(--grad-btn); color: #fff; padding: 10px 18px; border-radius: 10px; font-weight: 700; font-size: 13.5px; }
.f-dev-btn:hover { text-decoration: none; filter: brightness(1.1); }
.footer-bottom { border-top: 1px solid var(--border); }
.footer-bottom-inner { width: 100%; margin: 0 auto; padding: 16px 40px; text-align: center; color: var(--text-dim); font-size: 12.5px; }
.footer-bottom-inner b { color: var(--primary); }

.empty-state { text-align: center; padding: 44px 20px; color: var(--text-dim); }
.empty-state .icon { font-size: 42px; margin-bottom: 12px; }

@media (max-width: 980px) {
  .report-grid { grid-template-columns: 1fr; }
}
@media (max-width: 860px) {
  .topbar-inner { flex-wrap: wrap; padding: 10px 14px; row-gap: 8px; }
  .brand { flex-direction: row; min-width: auto; gap: 8px; }
  .brand .brand-top { font-size: 22px; }
  .brand .brand-text { font-size: 16px; }
  .topbar nav { order: 3; width: 100%; overflow-x: auto; margin-left: 0; justify-content: flex-start; flex-wrap: nowrap; padding-bottom: 4px; }
  .topbar nav button { padding: 8px 13px; font-size: 13px; }
  .user-chip { margin-left: auto; }
  .user-chip .who { display: none; }
  .container { padding: 22px 20px 40px; }
  .topbar-inner { padding: 10px 20px; }
  .footer-inner { padding: 30px 20px 16px; }
  .page-title { font-size: 21px; }
  .footer-inner { grid-template-columns: 1fr; gap: 24px; }
  .stat-grid { grid-template-columns: repeat(2, 1fr); }
  .day-btn { width: 26px; height: 26px; font-size: 9px; }
  .add-row input { min-width: 130px; }
  .purchase-head { flex-direction: column; }
  .countdown-box { text-align: left; }
}
@media (max-width: 480px) {
  .stat-grid { grid-template-columns: 1fr 1fr; gap: 10px; }
  .planner-amounts { grid-template-columns: 1fr; }
  .stat-card { padding: 14px; }
  .stat-card .stat-value { font-size: 20px; }
  .stat-card .stat-icon { font-size: 22px; }
  .grid-card { padding: 14px; }
  .month-nav h2 { min-width: 130px; font-size: 16px; }
  .pday { width: 32px; height: 32px; font-size: 11px; }
  .bar-row .bar-name { min-width: 90px; font-size: 12px; }
}
