:root {
  --bg: #f7f4ed;
  --surface: #ffffff;
  --surface-soft: #fbf7ef;
  --ink: #171717;
  --muted: #66645f;
  --line: #e8dfd1;
  --accent: #0f766e;
  --accent-dark: #0a4f49;
  --accent-soft: #dff5f1;
  --warning: #b45309;
  --danger: #b42318;
  --success: #15803d;
  --shadow: 0 20px 50px rgba(38, 28, 12, 0.08);
  --radius: 24px;
  --radius-sm: 14px;
  --max: 1180px;
  --font: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  font-family: var(--font);
  color: var(--ink);
  background:
    radial-gradient(circle at top left, rgba(15,118,110,0.10), transparent 30rem),
    radial-gradient(circle at top right, rgba(180,83,9,0.08), transparent 24rem),
    var(--bg);
  min-height: 100vh;
}

a { color: inherit; text-decoration: none; }
button, input, select { font: inherit; }
button { cursor: pointer; }

.app-shell { width: min(var(--max), calc(100% - 32px)); margin: 0 auto; }
.topbar {
  position: sticky;
  top: 0;
  z-index: 50;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  margin: 16px 0 24px;
  padding: 12px 14px;
  border: 1px solid rgba(232, 223, 209, 0.88);
  background: rgba(255,255,255,0.84);
  backdrop-filter: blur(18px);
  border-radius: 999px;
  box-shadow: 0 12px 34px rgba(38, 28, 12, 0.08);
}
.brand { display: inline-flex; align-items: center; gap: 12px; min-width: max-content; }
.brand-mark {
  width: 42px; height: 42px; border-radius: 50%;
  display: grid; place-items: center;
  background: linear-gradient(135deg, var(--accent), #14b8a6);
  color: #fff; font-weight: 900; box-shadow: inset 0 -8px 20px rgba(0,0,0,0.12);
}
.brand strong { display: block; letter-spacing: -0.03em; font-size: 1.05rem; }
.brand small { display: block; color: var(--muted); font-size: 0.72rem; margin-top: 1px; }
.main-nav { display: flex; align-items: center; gap: 4px; flex-wrap: wrap; justify-content: flex-end; }
.main-nav a {
  padding: 10px 12px;
  border-radius: 999px;
  color: #38342d;
  font-size: 0.9rem;
  transition: 0.18s ease;
}
.main-nav a:hover, .main-nav a.active { background: var(--accent-soft); color: var(--accent-dark); }
.menu-toggle { display: none; border: 0; background: var(--accent); color: #fff; border-radius: 999px; width: 42px; height: 42px; }

main { display: grid; gap: 20px; }
.route-view { display: none; }
.route-view.visible { display: block; }
.section-card, .mini-panel, .hero {
  background: rgba(255,255,255,0.92);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}
.section-card, .mini-panel { padding: 24px; }
.hero { display: grid; grid-template-columns: minmax(0, 1.4fr) minmax(280px, 0.6fr); gap: 22px; align-items: stretch; padding: 28px; }
.hero-text { display: flex; flex-direction: column; justify-content: center; }
.eyebrow { margin: 0 0 8px; text-transform: uppercase; letter-spacing: 0.12em; color: var(--accent-dark); font-size: 0.75rem; font-weight: 800; }
h1, h2, h3, p { margin-top: 0; }
h1 { font-size: clamp(2.1rem, 4vw, 4.4rem); line-height: 0.98; letter-spacing: -0.07em; margin-bottom: 16px; }
h2 { font-size: clamp(1.35rem, 2vw, 2rem); letter-spacing: -0.045em; margin-bottom: 4px; }
h3 { letter-spacing: -0.03em; margin-bottom: 8px; }
.hero p { color: var(--muted); font-size: 1.05rem; max-width: 760px; line-height: 1.7; }
.hero-actions, .button-row { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.hero-panel {
  background: linear-gradient(160deg, #092f2b, #0f766e 58%, #14b8a6);
  color: white;
  border-radius: 22px;
  padding: 22px;
  min-height: 320px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  box-shadow: inset 0 0 0 1px rgba(255,255,255,0.16);
}
.month-selector label { display: block; color: rgba(255,255,255,0.75); font-size: 0.82rem; margin-bottom: 6px; }
.month-selector input { width: 100%; border: 0; border-radius: 14px; padding: 12px 14px; }
.score-ring {
  width: 180px; height: 180px; border-radius: 50%;
  display: grid; place-items: center; align-self: center;
  border: 14px solid rgba(255,255,255,0.24);
  background: radial-gradient(circle, rgba(255,255,255,0.12), rgba(255,255,255,0.02));
  text-align: center;
}
.score-ring span { display: block; font-size: 3rem; font-weight: 900; letter-spacing: -0.08em; }
.score-ring small { display: block; max-width: 110px; font-weight: 700; color: rgba(255,255,255,0.8); }
.hero-panel .muted { color: rgba(255,255,255,0.78); }

.btn {
  border: 1px solid transparent;
  padding: 12px 16px;
  border-radius: 999px;
  background: #fff;
  color: var(--ink);
  font-weight: 800;
  transition: transform 0.18s ease, box-shadow 0.18s ease, background 0.18s ease;
  box-shadow: 0 8px 24px rgba(38, 28, 12, 0.08);
}
.btn:hover { transform: translateY(-1px); }
.btn.primary { background: var(--accent); color: #fff; }
.btn.ghost { background: var(--surface-soft); border-color: var(--line); color: var(--accent-dark); }
.btn.small { padding: 9px 12px; font-size: 0.82rem; }
.btn.danger { color: #fff; background: var(--danger); }

.kpi-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 14px; margin-bottom: 20px; }
.kpi-card {
  background: rgba(255,255,255,0.92);
  border: 1px solid var(--line);
  border-radius: 20px;
  padding: 20px;
  box-shadow: 0 12px 34px rgba(38, 28, 12, 0.06);
}
.kpi-card span, .kpi-card small { color: var(--muted); }
.kpi-card span { font-size: 0.88rem; }
.kpi-card strong { display: block; margin: 10px 0 4px; font-size: clamp(1.35rem, 2.5vw, 2.05rem); letter-spacing: -0.05em; }
.grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 20px; margin-bottom: 20px; }
.section-heading { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; margin-bottom: 18px; }
.muted { color: var(--muted); line-height: 1.65; }
.wide-copy { max-width: 900px; }
canvas { width: 100%; height: auto; max-height: 340px; }
.progress-list { display: grid; gap: 14px; }
.progress-row { display: grid; gap: 6px; }
.progress-meta { display: flex; justify-content: space-between; gap: 12px; font-size: 0.9rem; }
.progress-track { height: 12px; background: #eee7dc; border-radius: 999px; overflow: hidden; }
.progress-fill { height: 100%; background: linear-gradient(90deg, var(--accent), #14b8a6); border-radius: inherit; width: 0%; }
.progress-fill.over { background: linear-gradient(90deg, #dc2626, #f97316); }
.check-list { display: grid; gap: 12px; padding: 0; margin: 0; list-style: none; }
.check-list li { padding: 12px 14px; border-radius: 14px; background: var(--surface-soft); border: 1px solid var(--line); line-height: 1.5; }
.check-list li::before { content: "✓"; color: var(--accent); font-weight: 900; margin-right: 8px; }

.form-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px; align-items: end; margin-bottom: 22px; }
.form-grid.single-column { grid-template-columns: 1fr; }
label { display: grid; gap: 7px; font-weight: 800; font-size: 0.85rem; color: #35302a; }
input, select {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 12px 13px;
  background: #fff;
  color: var(--ink);
  outline: none;
}
input:focus, select:focus { border-color: var(--accent); box-shadow: 0 0 0 4px var(--accent-soft); }
.table-tools { display: flex; gap: 12px; margin: 8px 0 14px; }
.table-wrap { overflow: auto; border: 1px solid var(--line); border-radius: 18px; background: white; }
table { width: 100%; border-collapse: collapse; min-width: 760px; }
th, td { padding: 13px 14px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; }
th { background: var(--surface-soft); color: #4f473e; font-size: 0.84rem; }
td { color: #2b2722; }
.numeric { text-align: right; }
.badge { display: inline-flex; align-items: center; padding: 5px 9px; border-radius: 999px; font-weight: 800; font-size: 0.78rem; }
.badge.income { color: var(--success); background: #dcfce7; }
.badge.expense { color: var(--danger); background: #fee2e2; }
.badge.asset { color: var(--accent-dark); background: var(--accent-soft); }
.badge.liability { color: var(--danger); background: #fee2e2; }
.icon-btn { border: 0; background: #fff2f2; color: var(--danger); padding: 8px 10px; border-radius: 10px; font-weight: 900; cursor: pointer; }

.form-actions { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }
.hidden { display: none !important; }
.tx-action-buttons { display: inline-flex; gap: 8px; justify-content: flex-end; align-items: center; flex-wrap: wrap; }
.icon-btn.edit-btn { background: var(--accent-soft); color: var(--accent-dark); min-width: 58px; }

.budget-editor { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
.budget-item { display: grid; grid-template-columns: 1fr 170px; align-items: center; gap: 14px; padding: 14px; border: 1px solid var(--line); border-radius: 18px; background: #fff; }
.budget-item strong { display: block; }
.budget-item small { color: var(--muted); }

.kpi-list { display: grid; gap: 12px; }
.kpi-list div { display: flex; justify-content: space-between; gap: 14px; padding: 12px 0; border-bottom: 1px solid var(--line); }
.kpi-list span { color: var(--muted); }
.goal-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; }
.goal-card { border: 1px solid var(--line); border-radius: 20px; padding: 18px; background: #fff; }
.goal-card h3 { display: flex; justify-content: space-between; gap: 10px; }
.goal-card .priority { font-size: 0.72rem; padding: 4px 8px; border-radius: 999px; background: var(--accent-soft); color: var(--accent-dark); white-space: nowrap; }
.result-box { margin-top: 14px; padding: 16px; border-radius: 18px; background: var(--surface-soft); border: 1px solid var(--line); color: #2d2923; line-height: 1.6; }
.feature-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; }
.feature-grid article { padding: 18px; border: 1px solid var(--line); border-radius: 20px; background: #fff; }
.feature-grid p { color: var(--muted); line-height: 1.6; margin-bottom: 0; }

.floating-panel {
  position: fixed;
  right: 18px;
  bottom: 18px;
  display: flex;
  gap: 8px;
  background: rgba(255,255,255,0.88);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 8px;
  box-shadow: var(--shadow);
  backdrop-filter: blur(14px);
  z-index: 60;
}
.file-label { display: inline-flex; align-items: center; }
footer { padding: 28px 0 94px; color: var(--muted); text-align: center; font-size: 0.9rem; }
.empty-state { padding: 28px; text-align: center; color: var(--muted); }
.positive { color: var(--success); }
.negative { color: var(--danger); }



.wisdom-banner {
  display: grid;
  grid-template-columns: minmax(0, 1.2fr) minmax(220px, 0.8fr);
  gap: 20px;
  align-items: center;
  padding: 22px 24px;
  margin-bottom: 20px;
  background: linear-gradient(135deg, rgba(255,255,255,0.94), rgba(223,245,241,0.92));
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}
.wisdom-copy h2 {
  margin: 0 0 10px;
  font-size: clamp(1.35rem, 2vw, 2rem);
}
.wisdom-copy p { margin-bottom: 10px; }
.wisdom-quote {
  color: #25413d;
  font-size: 1.02rem;
  line-height: 1.7;
}
.wisdom-tip {
  color: var(--muted);
  line-height: 1.65;
}
.wisdom-author {
  display: inline-flex;
  margin-top: 4px;
  font-weight: 800;
  color: var(--accent-dark);
}
.wisdom-media {
  display: flex;
  justify-content: center;
  align-items: center;
}
.wisdom-media img {
  max-width: 100%;
  width: min(100%, 320px);
  height: auto;
  filter: drop-shadow(0 18px 28px rgba(15,118,110,0.14));
}
.auth-card .wisdom-banner,
.section-card .wisdom-banner {
  margin-top: 18px;
}


.daily-quote-card {
  margin-top: 14px;
  padding: 14px 16px;
  border: 1px solid rgba(15,118,110,0.18);
  border-radius: 18px;
  background: rgba(255,255,255,0.78);
}
.daily-quote-card span {
  display: block;
  color: var(--accent-dark);
  font-size: 0.76rem;
  font-weight: 900;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  margin-bottom: 6px;
}
.daily-quote-card strong {
  display: block;
  line-height: 1.55;
  color: #1f3f39;
}
.daily-quote-card small {
  display: block;
  margin-top: 6px;
  color: var(--muted);
  font-weight: 700;
}
.coach-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
}
.coach-card {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 20px;
  padding: 18px;
  box-shadow: 0 10px 28px rgba(38, 28, 12, 0.05);
}
.coach-card span {
  display: inline-flex;
  padding: 5px 9px;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent-dark);
  font-size: 0.74rem;
  font-weight: 900;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-bottom: 10px;
}
.coach-card h3 { margin-bottom: 8px; }
.coach-card p { color: var(--muted); line-height: 1.6; margin-bottom: 10px; }
.coach-card strong { color: var(--ink); }
.resource-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 16px;
}
.resource-card {
  display: grid;
  gap: 10px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 20px;
  padding: 18px;
  min-height: 220px;
}
.resource-card .resource-icon {
  width: 48px;
  height: 48px;
  display: grid;
  place-items: center;
  border-radius: 16px;
  background: var(--accent-soft);
  color: var(--accent-dark);
  font-size: 1.4rem;
}
.resource-card p { color: var(--muted); line-height: 1.6; }
.resource-card a { color: var(--accent-dark); font-weight: 900; }
.article-list {
  display: grid;
  gap: 18px;
}
.article-card {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 22px;
  padding: 22px;
  box-shadow: 0 10px 28px rgba(38, 28, 12, 0.05);
}
.article-card h2 { margin-bottom: 10px; }
.article-card p, .article-card li { color: var(--muted); line-height: 1.7; }
.article-card ul { margin-bottom: 0; }

@media (max-width: 980px) {
  .app-shell { width: min(100% - 24px, var(--max)); }
  .topbar { border-radius: 28px; align-items: flex-start; }
  .menu-toggle { display: inline-grid; place-items: center; flex: 0 0 auto; }
  .main-nav {
    position: absolute;
    left: 0; right: 0; top: calc(100% + 8px);
    display: none;
    flex-direction: column;
    align-items: stretch;
    background: rgba(255,255,255,0.98);
    border: 1px solid var(--line);
    border-radius: 24px;
    padding: 10px;
    box-shadow: var(--shadow);
  }
  .main-nav.open { display: flex; }
  .main-nav a { width: 100%; }
  .hero, .grid-2, .wisdom-banner { grid-template-columns: 1fr; }
  .kpi-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .form-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .goal-grid, .feature-grid, .coach-grid, .resource-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .budget-editor { grid-template-columns: 1fr; }
}

@media (max-width: 640px) {
  .app-shell { width: min(100% - 18px, var(--max)); }
  .brand small { display: none; }
  .hero, .section-card, .mini-panel { padding: 18px; border-radius: 20px; }
  h1 { font-size: 2.25rem; }
  .kpi-grid, .form-grid, .goal-grid, .feature-grid, .coach-grid, .resource-grid { grid-template-columns: 1fr; }
  .section-heading { flex-direction: column; }
  .table-tools { flex-direction: column; }
  .budget-item { grid-template-columns: 1fr; }
  .floating-panel { left: 8px; right: 8px; bottom: 8px; border-radius: 24px; flex-wrap: wrap; justify-content: center; }
  .floating-panel .btn { flex: 1; min-width: 100px; }
  footer { padding-bottom: 126px; }
}

@media print {
  .topbar, .floating-panel, .mobile-bottom-nav, .btn, footer { display: none !important; }
  .route-view { display: block !important; }
  body { background: #fff; }
  .section-card, .mini-panel, .kpi-card, .hero { box-shadow: none; }
}
.hero.route-view.visible { display: grid; }

/* Authentication, profile and admin screens */
.account-menu {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: flex-end;
}
.account-user {
  font-size: 0.82rem;
  color: var(--muted);
  padding: 8px 10px;
  background: var(--surface-soft);
  border: 1px solid var(--line);
  border-radius: 999px;
}
.auth-page {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
}
.auth-card {
  width: min(100%, 480px);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 28px;
}
.wide-auth-card { width: min(100%, 980px); }
.auth-brand { margin-bottom: 22px; }
.auth-card h1 { margin: 0 0 8px; font-size: clamp(1.8rem, 4vw, 2.6rem); }
.auth-card h2 { margin: 0 0 14px; font-size: 1.2rem; }
.auth-form {
  display: grid;
  gap: 14px;
  margin-top: 20px;
}
.auth-form label {
  display: grid;
  gap: 6px;
  font-weight: 700;
  color: var(--ink);
}
.auth-form input,
.auth-form select {
  width: 100%;
  border: 1px solid var(--line);
  background: var(--surface-soft);
  border-radius: 14px;
  padding: 12px 14px;
  color: var(--ink);
}
.auth-links {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin-top: 18px;
  font-weight: 700;
  color: var(--accent-dark);
}
.alert {
  padding: 12px 14px;
  border-radius: 14px;
  margin: 14px 0;
  border: 1px solid var(--line);
  background: var(--surface-soft);
}
.alert.success { border-color: rgba(21, 128, 61, 0.25); color: var(--success); background: rgba(21, 128, 61, 0.08); }
.alert.danger { border-color: rgba(180, 35, 24, 0.25); color: var(--danger); background: rgba(180, 35, 24, 0.08); }
.small { font-size: 0.85rem; }
.admin-shell { padding-bottom: 40px; }
.admin-create-form { margin-top: 16px; }
.admin-actions {
  display: grid;
  grid-template-columns: repeat(2, max-content) minmax(180px, 1fr);
  gap: 8px;
  align-items: center;
}
.admin-actions form { margin: 0; }
.inline-password-form {
  display: flex;
  gap: 6px;
  align-items: center;
}
.inline-password-form input {
  width: 130px;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 8px;
  background: var(--surface-soft);
}

@media (max-width: 860px) {
  .topbar { align-items: flex-start; }
  .account-menu { width: 100%; justify-content: flex-start; }
  .admin-actions { grid-template-columns: 1fr; }
  .inline-password-form { flex-direction: column; align-items: stretch; }
  .inline-password-form input { width: 100%; }
}

/* Mobile UX upgrade: touch-first navigation, forms and tables */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 44px;
  line-height: 1.2;
  -webkit-tap-highlight-color: transparent;
}

input,
select,
textarea,
button,
.btn {
  touch-action: manipulation;
}

.mobile-bottom-nav {
  display: none;
}

@media (max-width: 980px) {
  .topbar {
    flex-wrap: wrap;
    gap: 10px;
    padding: 10px;
    top: 8px;
  }

  .brand {
    flex: 1 1 calc(100% - 58px);
    min-width: 0;
  }

  .brand span:last-child {
    min-width: 0;
  }

  .brand strong,
  .brand small {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .menu-toggle {
    flex: 0 0 44px;
    min-height: 44px;
    font-size: 1.25rem;
  }

  .main-nav {
    max-height: min(72vh, 520px);
    overflow-y: auto;
    overscroll-behavior: contain;
    padding: 12px;
  }

  .main-nav a {
    min-height: 48px;
    display: flex;
    align-items: center;
    padding: 13px 16px;
    font-weight: 800;
  }

  .account-menu {
    order: 4;
    width: 100%;
    justify-content: flex-start;
    flex-wrap: nowrap;
    overflow-x: auto;
    padding: 2px 0 4px;
    scrollbar-width: none;
    -webkit-overflow-scrolling: touch;
  }

  .account-menu::-webkit-scrollbar { display: none; }
  .account-menu .btn,
  .account-menu .account-user { flex: 0 0 auto; }

  .wisdom-media img { width: min(100%, 240px); }
  .hero-panel { min-height: 260px; }
  .score-ring { width: 150px; height: 150px; border-width: 12px; }
  .score-ring span { font-size: 2.55rem; }
}

@media (max-width: 760px) {
  html { scroll-padding-top: 112px; }

  body {
    padding-bottom: calc(72px + env(safe-area-inset-bottom));
  }

  .app-shell { width: min(100% - 18px, var(--max)); }

  .mobile-bottom-nav {
    position: fixed;
    left: 8px;
    right: 8px;
    bottom: calc(8px + env(safe-area-inset-bottom));
    z-index: 80;
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 4px;
    padding: 6px;
    border: 1px solid rgba(232, 223, 209, 0.92);
    border-radius: 22px;
    background: rgba(255,255,255,0.96);
    box-shadow: 0 14px 40px rgba(38, 28, 12, 0.16);
    backdrop-filter: blur(18px);
  }

  .mobile-bottom-nav a {
    min-height: 54px;
    display: grid;
    place-items: center;
    gap: 2px;
    padding: 5px 2px;
    border-radius: 16px;
    color: var(--muted);
    font-weight: 900;
    -webkit-tap-highlight-color: transparent;
  }

  .mobile-bottom-nav a span {
    font-size: 1.12rem;
    line-height: 1;
  }

  .mobile-bottom-nav a small {
    font-size: 0.68rem;
    line-height: 1;
  }

  .mobile-bottom-nav a.active {
    background: var(--accent-soft);
    color: var(--accent-dark);
  }

  .floating-panel {
    position: static;
    margin-top: 18px;
    border-radius: 22px;
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    background: rgba(255,255,255,0.92);
  }

  .floating-panel .btn {
    min-width: 0;
    width: 100%;
    padding-inline: 10px;
    white-space: nowrap;
  }

  footer { padding-bottom: 92px; }

  .hero,
  .section-card,
  .mini-panel,
  .auth-card,
  .article-card,
  .resource-card,
  .goal-card,
  .coach-card,
  .kpi-card {
    border-radius: 20px;
  }

  .hero {
    gap: 16px;
  }

  .hero p,
  .muted,
  .article-card p,
  .article-card li {
    line-height: 1.58;
  }

  .hero-actions,
  .button-row,
  .auth-links {
    width: 100%;
    display: grid;
    grid-template-columns: 1fr;
  }

  .section-card .button-row .btn,
  .hero-actions .btn,
  form .btn,
  .section-heading > .btn {
    width: 100%;
  }

  .section-heading {
    gap: 12px;
  }

  .kpi-card {
    padding: 16px;
  }

  .kpi-card strong {
    font-size: 1.35rem;
    overflow-wrap: anywhere;
  }

  .form-grid,
  .auth-form {
    gap: 12px;
  }

  label {
    font-size: 0.82rem;
  }

  input,
  select {
    min-height: 48px;
    border-radius: 13px;
    font-size: 16px;
  }

  .table-wrap {
    overflow: visible;
    border: 0;
    background: transparent;
  }

  table,
  thead,
  tbody,
  tr,
  td {
    display: block;
    width: 100%;
  }

  table {
    min-width: 0;
    border-collapse: separate;
    border-spacing: 0;
  }

  thead { display: none; }

  tbody {
    display: grid;
    gap: 12px;
  }

  tr {
    background: #fff;
    border: 1px solid var(--line);
    border-radius: 18px;
    padding: 8px 12px;
    box-shadow: 0 10px 26px rgba(38, 28, 12, 0.05);
  }

  td {
    display: grid;
    grid-template-columns: minmax(88px, 34%) 1fr;
    gap: 10px;
    align-items: center;
    border-bottom: 1px solid rgba(232, 223, 209, 0.72);
    padding: 11px 0;
    text-align: right;
    overflow-wrap: anywhere;
  }

  td:last-child { border-bottom: 0; }

  td::before {
    content: attr(data-label);
    color: var(--muted);
    font-weight: 900;
    font-size: 0.78rem;
    text-align: left;
    text-transform: uppercase;
    letter-spacing: 0.04em;
  }

  td.numeric { text-align: right; }

  td.empty-state,
  .empty-state {
    display: block;
    text-align: center;
  }

  td.empty-state::before { content: none; }

  .icon-btn {
    min-width: 44px;
    min-height: 40px;
    justify-self: end;
  }

  .budget-item {
    padding: 14px;
  }

  .budget-item input {
    text-align: right;
  }

  .goal-card h3 {
    align-items: flex-start;
  }

  .resource-card,
  .article-card {
    min-height: auto;
  }

  canvas {
    max-height: 260px;
  }
}

@media (max-width: 480px) {
  .topbar {
    margin: 10px 0 16px;
    border-radius: 24px;
  }

  .brand-mark {
    width: 38px;
    height: 38px;
  }

  .brand strong { font-size: 0.98rem; }
  .account-user { display: none; }

  .hero,
  .section-card,
  .mini-panel,
  .auth-card,
  .article-card {
    padding: 16px;
  }

  h1 {
    font-size: clamp(1.75rem, 9vw, 2.1rem);
    letter-spacing: -0.055em;
    line-height: 1.04;
  }

  h2 {
    font-size: clamp(1.18rem, 6vw, 1.45rem);
  }

  .eyebrow {
    font-size: 0.68rem;
    letter-spacing: 0.1em;
  }

  .wisdom-banner {
    padding: 16px;
    gap: 10px;
  }

  .wisdom-media {
    display: none;
  }

  .hero-panel {
    min-height: 230px;
    padding: 18px;
  }

  .score-ring {
    width: 132px;
    height: 132px;
    border-width: 10px;
  }

  .score-ring span { font-size: 2.2rem; }

  .floating-panel {
    grid-template-columns: 1fr;
  }

  td {
    grid-template-columns: 1fr;
    text-align: left;
  }

  td.numeric {
    text-align: left;
  }

  .icon-btn {
    justify-self: start;
  }
}

/* Bills and uploaded statements */
.bill-upload-layout {
  display: grid;
  grid-template-columns: minmax(0, 1.7fr) minmax(260px, 0.7fr);
  gap: 18px;
  align-items: start;
  margin: 18px 0 20px;
}

.bill-form .file-drop-label {
  grid-column: span 2;
}


.bill-form .form-section-title,
.bill-form .form-wide {
  grid-column: 1 / -1;
}

.bill-form .form-section-title {
  margin: 4px 0 -2px;
  padding: 10px 12px;
  border-radius: 14px;
  background: var(--surface-soft);
  border: 1px solid var(--line);
  color: var(--accent-dark);
  font-weight: 900;
  font-size: 0.82rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.bill-form textarea {
  width: 100%;
  border: 1px solid var(--line);
  background: var(--surface-soft);
  border-radius: 14px;
  padding: 12px 14px;
  color: var(--ink);
  resize: vertical;
  min-height: 72px;
}

.file-drop-label input[type="file"] {
  padding: 16px;
  border-style: dashed;
  background: var(--surface-soft);
}

.file-drop-label small,
.bill-form label small,
td small {
  display: block;
  margin-top: 4px;
  color: var(--muted);
  font-weight: 600;
  font-size: 0.76rem;
  line-height: 1.35;
}

.bill-info-panel {
  background: linear-gradient(160deg, #092f2b, #0f766e 62%, #14b8a6);
  color: #fff;
  border-radius: 22px;
  padding: 20px;
  box-shadow: inset 0 0 0 1px rgba(255,255,255,0.16);
}

.bill-info-panel h3 { color: #fff; }
.bill-info-panel .check-list li {
  background: rgba(255,255,255,0.12);
  border-color: rgba(255,255,255,0.18);
  color: rgba(255,255,255,0.92);
}
.bill-info-panel .check-list li::before { color: #bbf7d0; }
.compact-list { gap: 9px; }
.compact-list li { padding: 10px 12px; }

.bill-summary-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
  margin: 16px 0 14px;
}

.bill-summary-grid article {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 16px;
  box-shadow: 0 10px 24px rgba(38, 28, 12, 0.05);
}

.bill-summary-grid span {
  display: block;
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 800;
}

.bill-summary-grid strong {
  display: block;
  margin-top: 6px;
  font-size: 1.55rem;
  letter-spacing: -0.05em;
}

.bill-tools {
  display: grid;
  grid-template-columns: minmax(220px, 1fr) minmax(150px, 0.35fr) minmax(170px, 0.45fr);
}

.badge.bill-type {
  color: var(--accent-dark);
  background: var(--accent-soft);
}

.badge.status-pending,
.badge.status-review {
  color: #92400e;
  background: #fef3c7;
}

.badge.status-paid {
  color: var(--success);
  background: #dcfce7;
}

.badge.status-partial {
  color: #1d4ed8;
  background: #dbeafe;
}

.badge.status-archived {
  color: #475569;
  background: #e2e8f0;
}

.table-link {
  color: var(--accent-dark);
  font-weight: 900;
  text-decoration: underline;
  text-underline-offset: 3px;
}

.bill-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  align-items: center;
}

.bill-actions .btn.small {
  min-height: 36px;
  padding: 7px 10px;
  box-shadow: none;
}

@media (max-width: 980px) {
  .bill-upload-layout { grid-template-columns: 1fr; }
  .bill-form .file-drop-label { grid-column: auto; }
}

@media (max-width: 760px) {
  .mobile-bottom-nav { grid-template-columns: repeat(6, 1fr); }
  .mobile-bottom-nav a small { font-size: 0.62rem; }
  .bill-summary-grid { grid-template-columns: 1fr; }
  .bill-tools { grid-template-columns: 1fr; }
  .bill-actions {
    justify-content: flex-start;
    flex-wrap: wrap;
  }
}

/* Copy-paste PDF transaction importer */
.form-wide { grid-column: 1 / -1; }
.compact-heading { margin-bottom: 10px; }
.paste-import-panel {
  margin: 18px 0 20px;
  padding: 20px;
  border: 1px solid var(--line);
  border-radius: 22px;
  background: linear-gradient(135deg, rgba(255,255,255,0.96), rgba(223,245,241,0.58));
  box-shadow: 0 12px 34px rgba(38, 28, 12, 0.06);
}
.paste-transaction-form {
  margin-top: 14px;
  margin-bottom: 0;
}
.paste-transaction-form textarea {
  width: 100%;
  border: 1px solid var(--line);
  background: #fff;
  border-radius: 14px;
  padding: 12px 14px;
  color: var(--ink);
  resize: vertical;
  min-height: 180px;
  line-height: 1.45;
}
.paste-transaction-form label small {
  display: block;
  margin-top: 4px;
  color: var(--muted);
  font-weight: 600;
  font-size: 0.76rem;
  line-height: 1.35;
}
@media (max-width: 760px) {
  .paste-import-panel { padding: 16px; }
  .paste-transaction-form textarea { min-height: 220px; }
}


/* Debt management, debt-free planning and recurring expenses */
.dashboard-detail-grid { margin-top: -4px; }
.mini-dashboard-panel .kpi-list strong { text-align: right; overflow-wrap: anywhere; }
.recurring-summary-grid article,
.debt-summary-grid article { min-height: 104px; }
.badge.status-active { color: var(--success); background: #dcfce7; }
.badge.status-paused { color: #475569; background: #e2e8f0; }
.badge.status-closed { color: #475569; background: #e2e8f0; }
.badge.priority-high { color: var(--danger); background: #fee2e2; }
.badge.priority-medium { color: #92400e; background: #fef3c7; }
.badge.priority-low { color: var(--success); background: #dcfce7; }
.debt-priority-list { display: grid; gap: 12px; }
.debt-priority-card {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 4px 12px;
  align-items: start;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: var(--surface-soft);
}
.debt-priority-card span {
  grid-row: span 2;
  display: inline-grid;
  place-items: center;
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background: var(--accent);
  color: #fff;
  font-weight: 900;
}
.debt-priority-card h3 { margin: 0; }
.debt-priority-card p { margin: 0; color: var(--muted); line-height: 1.45; }

@media (max-width: 760px) {
  .dashboard-detail-grid { margin-top: 0; }
  .mini-dashboard-panel .kpi-list div { align-items: flex-start; }
  .mini-dashboard-panel .kpi-list strong { max-width: 58%; }
  .debt-priority-card { grid-template-columns: 1fr; }
  .debt-priority-card span { grid-row: auto; }
}
