/* ============================================================
   Budget Tracker v5 — Dark Default · Mobile First
   ============================================================ */

@import url('https://fonts.googleapis.com/css2?family=DM+Sans:ital,opsz,wght@0,9..40,300;0,9..40,400;0,9..40,500;0,9..40,600;0,9..40,700;0,9..40,800;1,9..40,400&family=DM+Mono:wght@400;500&display=swap');

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

/* ============================================================
   DARK THEME — DEFAULT (always on)
   ============================================================ */
:root {
  --bg:          #0a0a0e;
  --surface:     #13131a;
  --surface-2:   #1c1c25;
  --surface-3:   #25252f;
  --border:      rgba(255,255,255,.07);
  --border-md:   rgba(255,255,255,.13);
  --text:        #ededf0;
  --text-muted:  #9090a0;
  --text-hint:   #4a4a58;
  --green:       #34d399;
  --green-bg:    rgba(52,211,153,.13);
  --green-light: rgba(52,211,153,.22);
  --red:         #f87171;
  --red-bg:      rgba(248,113,113,.13);
  --amber:       #fbbf24;
  --amber-bg:    rgba(251,191,36,.12);
  --blue:        #60a5fa;
  --blue-bg:     rgba(96,165,250,.12);
  --accent:      #ededf0;
  --accent-fg:   #0a0a0e;
  --accent-hover:#c8c8cf;
  --shadow-sm:   0 1px 3px rgba(0,0,0,.6);
  --shadow:      0 4px 24px rgba(0,0,0,.7);
  --shadow-lg:   0 16px 60px rgba(0,0,0,.85);
  --topbar-bg:   rgba(10,10,14,.92);
  --font:        'DM Sans', system-ui, sans-serif;
  --font-mono:   'DM Mono', monospace;
  --transition:  .16s cubic-bezier(.4,0,.2,1);
  --radius-xs:   4px;
  --radius-sm:   8px;
  --radius-md:   12px;
  --radius-lg:   16px;
  --radius-xl:   22px;
}

/* Force dark on everything */
html, body {
  background: var(--bg);
  color-scheme: dark;
}

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  font-size: 15px;
  line-height: 1.65;
  min-height: 100dvh;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

a { color: inherit; text-decoration: none; }

/* ============================================================
   TOPBAR
   ============================================================ */
.topbar {
  background: var(--topbar-bg);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-bottom: 1px solid var(--border);
  padding: 0 1rem;
  height: 56px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 100;
  gap: 8px;
}

.topbar-brand {
  font-size: 15px;
  font-weight: 700;
  color: var(--text);
  display: flex;
  align-items: center;
  gap: 8px;
  letter-spacing: -.3px;
  flex-shrink: 0;
}
.topbar-brand .brand-icon {
  width: 30px; height: 30px;
  background: var(--accent);
  border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  color: var(--accent-fg);
  flex-shrink: 0;
}
.topbar-brand span { color: var(--text-muted); font-weight: 400; }

.topbar-nav {
  display: flex;
  align-items: center;
  gap: 4px;
  flex-shrink: 0;
}

.nav-link {
  font-size: 13px; font-weight: 500; color: var(--text-muted);
  padding: 5px 10px; border-radius: var(--radius-sm);
  transition: color var(--transition), background var(--transition);
  white-space: nowrap;
}
.nav-link:hover { color: var(--text); background: var(--surface-2); }

/* ============================================================
   CONTAINER
   ============================================================ */
.container    { max-width: 920px;  margin: 0 auto; padding: 1.75rem 1rem; }
.container-sm { max-width: 480px;  margin: 0 auto; padding: 1.75rem 1rem; }
.container-lg { max-width: 1100px; margin: 0 auto; padding: 1.75rem 1rem; }

/* ============================================================
   BUTTONS
   ============================================================ */
.btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 0 14px; height: 38px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-md);
  background: var(--surface); color: var(--text);
  font-family: var(--font); font-size: 13.5px; font-weight: 500;
  cursor: pointer;
  transition: background var(--transition), transform var(--transition), border-color var(--transition), color var(--transition), box-shadow var(--transition);
  white-space: nowrap; line-height: 1;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
  user-select: none;
}
.btn:hover  { background: var(--surface-2); }
.btn:active { transform: scale(.97); }

.btn-primary  { background: var(--accent); color: var(--accent-fg); border-color: var(--accent); }
.btn-primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); }

.btn-outline  { background: transparent; color: var(--text); border-color: var(--border-md); }
.btn-outline:hover { background: var(--surface-2); }

.btn-ghost    { background: transparent; border-color: transparent; color: var(--text-muted); }
.btn-ghost:hover { background: var(--surface-2); color: var(--text); }

.btn-danger   { background: var(--red-bg); color: var(--red); border-color: rgba(248,113,113,.2); }
.btn-danger:hover { filter: brightness(1.15); }

.btn-icon {
  padding: 0; width: 36px; height: 36px;
  justify-content: center; border: none;
  background: transparent; color: var(--text-hint);
  border-radius: var(--radius-sm);
  flex-shrink: 0;
}
.btn-icon:hover { background: var(--surface-2); color: var(--red); }

.btn-sm   { height: 32px; font-size: 12.5px; padding: 0 11px; }
.btn-lg   { height: 46px; font-size: 15px; padding: 0 24px; border-radius: var(--radius-md); }
.btn-full { width: 100%; justify-content: center; }

/* ============================================================
   FORMS
   ============================================================ */
.form-row { display: grid; gap: 12px; margin-bottom: 12px; }
.form-row.cols-2 { grid-template-columns: 1fr 1fr; }
.form-group { display: flex; flex-direction: column; gap: 5px; }

label.form-label {
  font-size: 12.5px; font-weight: 500;
  color: var(--text-muted); letter-spacing: .01em;
}

input[type="text"],
input[type="email"],
input[type="password"],
input[type="number"],
select, textarea {
  width: 100%; height: 44px; padding: 0 13px;
  border: 1.5px solid var(--border-md);
  border-radius: var(--radius-sm);
  background: var(--surface-2); font-family: var(--font);
  font-size: 15px; color: var(--text); outline: none;
  -webkit-appearance: none; appearance: none;
  transition: border-color var(--transition), box-shadow var(--transition);
}
input::placeholder, textarea::placeholder { color: var(--text-hint); }
input:focus, select:focus, textarea:focus {
  border-color: var(--green);
  box-shadow: 0 0 0 3px rgba(52,211,153,.15);
}

.form-error { font-size: 12px; color: var(--red); margin-top: 2px; display: none; }
.form-error.visible { display: block; }
.form-hint  { font-size: 12px; color: var(--text-hint); margin-top: 2px; }

/* ============================================================
   SUMMARY BAR
   ============================================================ */
.summary {
  display: grid; grid-template-columns: repeat(3,1fr);
  gap: 10px; margin-bottom: 1.75rem;
}
.summary-card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius-md); padding: 1rem 1.1rem;
}
.summary-card .s-label {
  font-size: 10.5px; font-weight: 600;
  letter-spacing: .06em; text-transform: uppercase;
  color: var(--text-hint); margin-bottom: 4px;
}
.summary-card .s-value {
  font-size: 18px; font-weight: 700;
  font-family: var(--font-mono); letter-spacing: -.04em;
}
.s-value.green { color: var(--green); }
.s-value.red   { color: var(--red); }

/* ============================================================
   SECTION HEADER
   ============================================================ */
.section-header {
  display: flex; align-items: center;
  justify-content: space-between; margin-bottom: 1rem;
}
.section-title { font-size: 15px; font-weight: 600; letter-spacing: -.1px; }

/* ============================================================
   CARDS GRID
   ============================================================ */
.cards-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 12px;
}
.card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius-lg); padding: 1.125rem 1.25rem;
  cursor: pointer;
  transition: box-shadow var(--transition), transform var(--transition), border-color var(--transition);
  display: block;
  -webkit-tap-highlight-color: transparent;
}
.card:hover  { box-shadow: var(--shadow); border-color: var(--border-md); }
.card:active { transform: scale(.99); }

.card-head  { display: flex; align-items: flex-start; justify-content: space-between; margin-bottom: 10px; }
.card-title { font-size: 14.5px; font-weight: 600; line-height: 1.35; letter-spacing: -.1px; }
.card-meta  { font-size: 11.5px; color: var(--text-muted); margin-top: 2px; }
.card-stats { display: grid; grid-template-columns: 1fr 1fr; gap: 7px; margin-bottom: 12px; }

.stat-box   { background: var(--surface-2); border-radius: var(--radius-sm); padding: 8px 10px; }
.stat-label { font-size: 10px; font-weight: 600; text-transform: uppercase; letter-spacing: .05em; color: var(--text-hint); margin-bottom: 2px; }
.stat-val   { font-size: 14px; font-weight: 700; font-family: var(--font-mono); letter-spacing: -.03em; }

/* ============================================================
   PROGRESS BAR
   ============================================================ */
.progress-wrap {
  background: var(--surface-3); border-radius: 99px;
  height: 5px; overflow: hidden; margin-bottom: 6px;
}
.progress-bar { height: 100%; border-radius: 99px; transition: width .5s ease; }
.bar-ok     { background: var(--green); }
.bar-warn   { background: var(--amber); }
.bar-danger { background: var(--red); }
.pct-row    { display: flex; justify-content: space-between; align-items: center; margin-top: 2px; }

/* ============================================================
   BADGES
   ============================================================ */
.badge {
  display: inline-flex; align-items: center;
  padding: 2px 8px; border-radius: 99px;
  font-size: 11px; font-weight: 600; letter-spacing: .01em;
}
.badge-green { background: var(--green-bg);  color: var(--green); }
.badge-red   { background: var(--red-bg);    color: var(--red); }
.badge-amber { background: var(--amber-bg);  color: var(--amber); }
.badge-blue  { background: var(--blue-bg);   color: var(--blue); }

/* ============================================================
   EMPTY STATE
   ============================================================ */
.empty-state { text-align: center; padding: 3rem 1rem; color: var(--text-muted); }
.empty-state svg { margin-bottom: 12px; opacity: .25; }
.empty-state h3  { font-size: 15px; font-weight: 600; margin-bottom: 5px; color: var(--text); }
.empty-state p   { font-size: 13px; }

/* ============================================================
   MODALS
   ============================================================ */
.modal-backdrop {
  display: none; position: fixed; inset: 0;
  background: rgba(0,0,0,.75); z-index: 200;
  align-items: flex-end; justify-content: center;
  padding: 0; backdrop-filter: blur(6px);
}
.modal-backdrop.open { display: flex; animation: fadeIn .15s ease; }

@keyframes fadeIn  { from { opacity: 0; } to { opacity: 1; } }
@keyframes slideUp { from { opacity: 0; transform: translateY(20px); } to { opacity: 1; transform: translateY(0); } }
@keyframes sheetUp { from { transform: translateY(100%); } to { transform: translateY(0); } }

.modal {
  background: var(--surface); width: 100%; max-width: 460px;
  padding: 1.5rem; border: 1px solid var(--border);
  border-top: 1px solid var(--border-md);
  box-shadow: var(--shadow-lg); animation: sheetUp .25s ease;
  border-radius: var(--radius-xl) var(--radius-xl) 0 0;
  padding-bottom: max(1.5rem, env(safe-area-inset-bottom));
}

.modal-title { font-size: 17px; font-weight: 700; letter-spacing: -.2px; margin-bottom: 1.25rem; }
.modal-footer {
  display: flex; gap: 8px; justify-content: flex-end;
  margin-top: 1.25rem; padding-top: 1rem;
  border-top: 1px solid var(--border);
}

/* ============================================================
   DETAIL PAGE
   ============================================================ */
.detail-back {
  display: inline-flex; align-items: center; gap: 5px;
  font-size: 13px; font-weight: 500; color: var(--text-muted);
  margin-bottom: 1.25rem; padding: 6px 10px;
  border-radius: var(--radius-sm);
  transition: background var(--transition), color var(--transition);
}
.detail-back:hover { color: var(--text); background: var(--surface-2); }

.detail-summary {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius-xl); padding: 1.25rem; margin-bottom: 1.25rem;
}
.detail-title { font-size: 20px; font-weight: 700; letter-spacing: -.4px; }
.detail-sub   { font-size: 12.5px; color: var(--text-muted); margin-bottom: 1.25rem; margin-top: 2px; }
.detail-stats { display: grid; grid-template-columns: repeat(3,1fr); gap: 8px; margin-bottom: 14px; }

.expense-add-box {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius-xl); padding: 1.25rem; margin-bottom: 1.25rem;
}
.expense-add-title { font-size: 14px; font-weight: 600; margin-bottom: 1rem; }

/* ============================================================
   EXPENSE ROWS
   ============================================================ */
.expenses-list { display: flex; flex-direction: column; gap: 7px; }
.expense-row {
  display: flex; align-items: center; gap: 10px;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius-md); padding: 10px 14px;
}
.expense-row:hover { border-color: var(--border-md); }
.expense-desc   { flex: 1; font-size: 13.5px; font-weight: 500; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.expense-date   { font-size: 11px; color: var(--text-hint); white-space: nowrap; flex-shrink: 0; }
.expense-amount { font-size: 13.5px; font-weight: 700; font-family: var(--font-mono); color: var(--red); white-space: nowrap; flex-shrink: 0; }

/* ============================================================
   TOAST
   ============================================================ */
#toast {
  position: fixed; bottom: max(24px, env(safe-area-inset-bottom));
  left: 50%; transform: translateX(-50%) translateY(12px);
  background: var(--surface-3); color: var(--text);
  border: 1px solid var(--border-md);
  padding: 10px 18px; border-radius: var(--radius-md);
  font-size: 13px; font-weight: 500; z-index: 9999;
  opacity: 0; transition: opacity .2s, transform .2s;
  pointer-events: none; white-space: nowrap;
  box-shadow: var(--shadow);
}
#toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ============================================================
   AUTH PAGES
   ============================================================ */
.auth-page {
  min-height: 100dvh; display: flex; align-items: center;
  justify-content: center; background: var(--bg);
  padding: max(1.5rem, env(safe-area-inset-top)) 1rem max(1.5rem, env(safe-area-inset-bottom));
}
.auth-card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius-xl); padding: 2rem 1.5rem;
  width: 100%; max-width: 400px; box-shadow: var(--shadow);
}
.auth-logo { display: flex; align-items: center; gap: 10px; margin-bottom: 1.75rem; }
.auth-logo-icon {
  width: 36px; height: 36px; background: var(--accent);
  border-radius: 10px; display: flex; align-items: center; justify-content: center;
  color: var(--accent-fg);
}
.auth-logo-text { font-size: 17px; font-weight: 700; letter-spacing: -.3px; }
.auth-heading { font-size: 20px; font-weight: 700; letter-spacing: -.3px; margin-bottom: 5px; }
.auth-sub     { font-size: 13.5px; color: var(--text-muted); margin-bottom: 1.5rem; }
.auth-footer  { margin-top: 1.25rem; text-align: center; font-size: 13px; color: var(--text-muted); }
.auth-footer a { color: var(--text); font-weight: 600; }

.password-toggle { position: relative; }
.password-toggle input { padding-right: 44px; }
.password-toggle-btn {
  position: absolute; right: 10px; top: 50%; transform: translateY(-50%);
  background: none; border: none; cursor: pointer; color: var(--text-hint);
  padding: 6px; display: flex; align-items: center;
  -webkit-tap-highlight-color: transparent;
}
.password-toggle-btn:hover { color: var(--text-muted); }

/* ============================================================
   HOME / LANDING PAGE — IMPROVED
   ============================================================ */
.hero-glow {
  position: absolute; top: -100px; left: 50%; transform: translateX(-50%);
  width: min(800px, 120vw); height: 500px;
  background: radial-gradient(ellipse at center,
    rgba(52,211,153,.14) 0%, rgba(96,165,250,.08) 40%, transparent 70%);
  pointer-events: none; z-index: 0;
}

.hero {
  position: relative; padding: 5.5rem 1.25rem 4.5rem;
  text-align: center; max-width: 780px; margin: 0 auto; overflow: visible;
}
.hero > * { position: relative; z-index: 1; }

.hero-badge {
  display: inline-flex; align-items: center; gap: 8px;
  background: var(--surface); border: 1px solid var(--border-md);
  border-radius: 99px; padding: 6px 16px;
  font-size: 12px; font-weight: 500; color: var(--text-muted);
  margin-bottom: 2rem; box-shadow: var(--shadow-sm);
  animation: fadeInUp .5s ease both;
}
.hero-badge .dot { 
  width: 7px; height: 7px; background: var(--green); border-radius: 99px;
  box-shadow: 0 0 8px var(--green);
  animation: pulse 2s ease-in-out infinite;
}
@keyframes pulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: .6; transform: scale(.85); }
}
@keyframes fadeInUp {
  from { opacity: 0; transform: translateY(16px); }
  to   { opacity: 1; transform: translateY(0); }
}

.hero h1 {
  font-size: clamp(2.2rem, 7vw, 3.75rem);
  font-weight: 800; letter-spacing: -.06em;
  line-height: 1.08; color: var(--text); margin-bottom: 1.25rem;
  animation: fadeInUp .5s .1s ease both;
}
.hero h1 em {
  font-style: normal; color: var(--green);
  position: relative;
}
.hero h1 em::after {
  content: ''; position: absolute; bottom: -4px;
  left: 0; right: 0; height: 2px;
  background: linear-gradient(90deg, var(--green), transparent);
  border-radius: 2px; opacity: .5;
}

.hero p {
  font-size: 16px; color: var(--text-muted); line-height: 1.75;
  margin-bottom: 2.25rem; max-width: 520px; margin-left: auto; margin-right: auto;
  animation: fadeInUp .5s .2s ease both;
}

.hero-actions {
  display: flex; align-items: center; justify-content: center;
  gap: 12px; flex-wrap: wrap; margin-bottom: 3rem;
  animation: fadeInUp .5s .3s ease both;
}

.hero-stats {
  display: flex; justify-content: center; gap: 0; flex-wrap: nowrap;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius-xl); box-shadow: var(--shadow-sm);
  max-width: 500px; margin: 0 auto;
  overflow: hidden;
  animation: fadeInUp .5s .4s ease both;
}
.hero-stat { 
  flex: 1; text-align: center; padding: 1.1rem .5rem;
  border-right: 1px solid var(--border);
}
.hero-stat:last-child { border-right: none; }
.hero-stat-val {
  font-size: 20px; font-weight: 800; font-family: var(--font-mono);
  color: var(--text); letter-spacing: -.03em;
}
.hero-stat-label { font-size: 10px; color: var(--text-hint); margin-top: 2px; letter-spacing: .05em; text-transform: uppercase; }

/* FEATURES */
.features { padding: 5rem 1.25rem 5.5rem; max-width: 980px; margin: 0 auto; }
.features-heading { text-align: center; margin-bottom: 3rem; }
.features-heading h2 {
  font-size: clamp(1.6rem, 3.5vw, 2.2rem); font-weight: 800;
  letter-spacing: -.05em; margin-bottom: .5rem; color: var(--text);
}
.features-heading p { font-size: 15px; color: var(--text-muted); }

/* Section divider */
.features-heading::before {
  content: '';
  display: block;
  width: 40px; height: 3px;
  background: var(--green);
  border-radius: 99px;
  margin: 0 auto 1.5rem;
}

.features-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 14px;
}
.feature-card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius-lg); padding: 1.4rem;
  transition: box-shadow var(--transition), border-color var(--transition), transform var(--transition);
  position: relative; overflow: hidden;
}
.feature-card::before {
  content: '';
  position: absolute; top: 0; left: 0; right: 0; height: 2px;
  background: linear-gradient(90deg, var(--green-bg), transparent);
  opacity: 0; transition: opacity var(--transition);
}
.feature-card:hover { 
  box-shadow: var(--shadow); border-color: var(--border-md);
  transform: translateY(-2px);
}
.feature-card:hover::before { opacity: 1; }

.feature-icon {
  width: 44px; height: 44px; background: var(--green-bg);
  border-radius: var(--radius-md); display: flex; align-items: center; justify-content: center;
  margin-bottom: 1rem; color: var(--green);
}
.feature-card h3 { font-size: 15px; font-weight: 600; margin-bottom: 6px; }
.feature-card p  { font-size: 13.5px; color: var(--text-muted); line-height: 1.65; }

/* CTA */
.cta-section {
  margin: 0 1.25rem 5rem;
  background: var(--surface);
  border: 1px solid var(--border-md);
  border-radius: var(--radius-xl); padding: 3.5rem 1.5rem; text-align: center;
  max-width: 900px; margin-left: auto; margin-right: auto;
  position: relative; overflow: hidden;
}
.cta-section::before {
  content: ''; position: absolute; inset: 0;
  background: radial-gradient(ellipse at 50% 0%, rgba(52,211,153,.1) 0%, transparent 65%);
  pointer-events: none;
}
.cta-section::after {
  content: ''; position: absolute; bottom: 0; left: 0; right: 0; height: 1px;
  background: linear-gradient(90deg, transparent, var(--green-bg), transparent);
}
.cta-section h2 {
  font-size: clamp(1.5rem, 3.5vw, 2rem); font-weight: 800;
  color: var(--text); letter-spacing: -.05em; margin-bottom: .6rem;
  position: relative;
}
.cta-section p { font-size: 14.5px; color: var(--text-muted); margin-bottom: 1.75rem; position: relative; }
.cta-section .cta-btns { display: flex; gap: 12px; justify-content: center; flex-wrap: wrap; position: relative; }

/* HOME FOOTER */
.home-footer {
  border-top: 1px solid var(--border); padding: 2rem 1.25rem;
  text-align: center; font-size: 12.5px; color: var(--text-hint);
  padding-bottom: max(2rem, env(safe-area-inset-bottom));
}
.home-footer a { color: var(--text-muted); transition: color var(--transition); }
.home-footer a:hover { color: var(--text); }
.home-footer .footer-links { display: flex; justify-content: center; gap: 20px; margin-bottom: 10px; flex-wrap: wrap; }

/* ============================================================
   STATIC PAGES
   ============================================================ */
.page-hero { padding: 2.5rem 1rem 1.75rem; border-bottom: 1px solid var(--border); margin-bottom: 2rem; }
.page-hero .breadcrumb { font-size: 12px; color: var(--text-hint); margin-bottom: .75rem; }
.page-hero .breadcrumb a { color: var(--text-muted); }
.page-hero h1 { font-size: clamp(1.6rem, 4vw, 2.1rem); font-weight: 800; letter-spacing: -.04em; margin-bottom: 6px; }
.page-hero p  { font-size: 13.5px; color: var(--text-muted); }

.prose h2 { font-size: 17px; font-weight: 700; margin: 2rem 0 .75rem; color: var(--text); }
.prose h2:first-child { margin-top: 0; }
.prose p  { font-size: 14px; color: var(--text-muted); line-height: 1.75; margin-bottom: .875rem; }
.prose ul { margin: .625rem 0 .875rem 1.125rem; }
.prose li { font-size: 14px; color: var(--text-muted); line-height: 1.75; margin-bottom: .3rem; }
.prose strong { color: var(--text); font-weight: 600; }

.prose-layout { display: grid; grid-template-columns: 1fr 220px; gap: 2.5rem; align-items: start; }
.prose-toc {
  position: sticky; top: 72px;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius-lg); padding: 1.1rem;
}
.prose-toc h4 { font-size: 10px; text-transform: uppercase; letter-spacing: .08em; color: var(--text-hint); margin-bottom: .75rem; font-weight: 600; }
.prose-toc ul { list-style: none; }
.prose-toc li + li { margin-top: 3px; }
.prose-toc a { font-size: 12.5px; color: var(--text-muted); display: block; padding: 3px 7px; border-radius: var(--radius-xs); }
.prose-toc a:hover { color: var(--text); background: var(--surface-2); }

/* ============================================================
   USER MENU
   ============================================================ */
.user-menu { display: flex; align-items: center; gap: 7px; }
.user-avatar {
  width: 30px; height: 30px; border-radius: 99px;
  background: var(--surface-3); border: 1.5px solid var(--border-md);
  display: flex; align-items: center; justify-content: center;
  font-size: 11.5px; font-weight: 700; color: var(--text-muted);
  text-transform: uppercase; flex-shrink: 0;
}

/* ============================================================
   ALERTS
   ============================================================ */
.alert {
  padding: 11px 14px; border-radius: var(--radius-md);
  font-size: 13px; font-weight: 500; margin-bottom: 1rem; display: none;
}
.alert.visible { display: block; }
.alert-error   { background: var(--red-bg);   color: var(--red);   border: 1px solid rgba(248,113,113,.2); }
.alert-success { background: var(--green-bg); color: var(--green); border: 1px solid rgba(52,211,153,.2); }

/* ============================================================
   MOBILE — ≤ 600px
   ============================================================ */
@media (max-width: 600px) {
  /* Topbar: hide text nav links only, keep buttons */
  .nav-link { display: none; }
  .topbar-nav { gap: 4px; }
  .topbar-brand span { display: none; }

  /* Larger touch targets */
  .btn-sm { height: 36px; padding: 0 12px; font-size: 13px; }
  .btn-lg { height: 48px; font-size: 15px; padding: 0 20px; }
  input[type="text"], input[type="email"], input[type="password"], input[type="number"], select, textarea {
    height: 48px; font-size: 16px; /* prevents iOS zoom */
  }

  /* Summary: 2+1 layout */
  .summary { grid-template-columns: 1fr 1fr; }
  .summary .summary-card:last-child { grid-column: span 2; }
  .summary-card .s-value { font-size: 16px; }

  /* Cards: single column */
  .cards-grid { grid-template-columns: 1fr; }

  /* Forms: single column */
  .form-row.cols-2 { grid-template-columns: 1fr; }

  /* Detail stats: 2+1 */
  .detail-stats { grid-template-columns: 1fr 1fr; }
  .detail-stats .stat-box:last-child { grid-column: span 2; }

  /* Detail header: stack */
  .detail-header-row { flex-direction: column !important; align-items: flex-start !important; gap: 10px !important; }
  #pdf-download-btn { width: 100% !important; justify-content: center; height: 44px !important; }

  /* Auth */
  .auth-card { padding: 1.5rem 1rem; }

  /* Expense row: show date smaller */
  .expense-date { font-size: 10px; }

  /* Hero */
  .hero { padding: 4rem .875rem 3rem; }
  .hero-stats { max-width: 100%; flex-wrap: wrap; }
  .hero-stat { flex: 1 0 calc(50% - 1px); min-width: 0; }
  .hero-stat:nth-child(3) { border-top: 1px solid var(--border); }
  .hero-stat:nth-child(4) { border-top: 1px solid var(--border); border-right: none; }
  .hero-stat-val { font-size: 18px; }
  .hero-actions { flex-direction: column; align-items: stretch; gap: 10px; }
  .hero-actions .btn { justify-content: center; }

  /* Features */
  .features { padding: 3rem .875rem 4rem; }
  .features-grid { grid-template-columns: 1fr; }

  /* CTA */
  .cta-section { margin: 0 .75rem 3.5rem; padding: 2.25rem 1.25rem; }
  .cta-section .cta-btns { flex-direction: column; align-items: center; }

  /* Prose */
  .prose-layout { grid-template-columns: 1fr; }
  .prose-toc { position: static; }

  /* Container */
  .container, .container-sm, .container-lg { padding: 1.25rem .875rem; }

  /* Footer links smaller on mobile */
  .home-footer .footer-links { gap: 12px; font-size: 13px; }
}

@media (max-width: 380px) {
  .hero h1 { font-size: 1.85rem; }
  .summary-card .s-value { font-size: 14px; }
  .hero-stat-val { font-size: 16px; }
}

/* ============================================================
   TABLET — 601–900px
   ============================================================ */
@media (min-width: 601px) and (max-width: 900px) {
  .container { padding: 1.75rem 1.25rem; }
  .cards-grid { grid-template-columns: repeat(2, 1fr); }
  .features-grid { grid-template-columns: repeat(2, 1fr); }
}

/* ============================================================
   DESKTOP modal — centered
   ============================================================ */
@media (min-width: 601px) {
  .modal-backdrop { align-items: center; padding: 1rem; }
  .modal {
    border-radius: var(--radius-xl);
    animation: slideUp .2s ease;
    padding-bottom: 1.5rem;
  }
}
