* {
  box-sizing: border-box;
}

html,
body {
  max-width: 100%;
  overflow-x: hidden;
}

:root {
  --bg-start: #f6f8fc;
  --bg-end: #e9edf5;
  --surface: #ffffff;
  --surface-soft: #f6f8fc;
  --text: #1b2433;
  --muted: #5d677c;
  --line: #dce3f1;
  --primary: #0b63ce;
  --primary-dark: #084c9d;
  --accent: #0f8a79;
  --good: #11753a;
  --bad: #b3272d;
}

body {
  margin: 0;
  font-family: "Plus Jakarta Sans", "Segoe UI", Tahoma, sans-serif;
  background:
    radial-gradient(circle at 8% 0%, #ffffff 0%, transparent 36%),
    linear-gradient(180deg, var(--bg-start) 0%, var(--bg-end) 100%);
  color: var(--text);
}

img,
svg,
canvas,
video {
  max-width: 100%;
  height: auto;
}

a {
  color: var(--primary);
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
}

.container {
  width: min(1100px, calc(100vw - 20px));
  margin: 0 auto;
}

.topbar {
  background: rgba(255, 255, 255, 0.9);
  border-bottom: 1px solid var(--line);
  box-shadow: 0 2px 12px rgba(20, 38, 69, 0.06);
  backdrop-filter: blur(6px);
}

.topbar-inner {
  min-height: 62px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  font-weight: 700;
  color: #13213a;
}

.brand:hover {
  text-decoration: none;
}

.brand-logo {
  width: 38px;
  height: 38px;
  display: block;
  border-radius: 11px;
  box-shadow: 0 8px 18px rgba(11, 99, 206, 0.24);
}

.brand-copy {
  display: grid;
  line-height: 1.05;
}

.brand-name {
  font-size: 0.98rem;
  letter-spacing: 0.2px;
}

.brand-tagline {
  font-size: 0.72rem;
  color: #66738a;
  font-weight: 600;
}

.nav-link {
  margin-left: 6px;
  font-weight: 600;
}

.topbar-nav {
  display: flex;
  align-items: center;
  gap: 6px;
}

.main {
  padding: 20px 0 32px;
  overflow-x: hidden;
}

.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 14px;
  box-shadow: 0 8px 24px rgba(20, 36, 62, 0.06);
}

.form-card {
  max-width: 520px;
  margin: 0 auto;
}

.stack {
  display: grid;
  gap: 8px;
}

.stack-lg {
  display: grid;
  gap: 14px;
}

.split-grid {
  display: grid;
  gap: 12px;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
}

.grid-cards {
  display: grid;
  gap: 12px;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
}

.inline-form {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.wrap-gap {
  flex-wrap: wrap;
}

label {
  display: grid;
  gap: 6px;
  font-weight: 600;
}

input,
select,
button {
  font: inherit;
}

input,
select {
  width: 100%;
  border: 1px solid #c7d2ea;
  border-radius: 8px;
  padding: 8px;
  background: #fff;
}

textarea {
  width: 100%;
  border: 1px solid #c7d2ea;
  border-radius: 8px;
  padding: 8px;
  background: #fff;
  font: inherit;
  resize: vertical;
}

.btn {
  border: none;
  border-radius: 10px;
  padding: 9px 14px;
  background: linear-gradient(180deg, var(--primary) 0%, var(--primary-dark) 100%);
  color: #fff;
  cursor: pointer;
  font-weight: 700;
  box-shadow: 0 10px 22px rgba(11, 99, 206, 0.22);
}

.btn-small {
  padding: 6px 10px;
  font-size: 0.9rem;
}

.btn:hover {
  background: linear-gradient(180deg, #0a58b7 0%, #063d7d 100%);
}

.btn-ghost {
  background: var(--surface-soft);
  color: #21314d;
  border: 1px solid #d3dcf0;
  box-shadow: none;
}

.btn-ghost:hover {
  background: #edf2fb;
}

.flash {
  border-radius: 10px;
  padding: 10px 12px;
  margin-bottom: 12px;
}

.flash p {
  margin: 4px 0;
}

.flash-error {
  background: #ffe5e8;
  border: 1px solid #ffbac4;
}

.flash-success {
  background: #e6faee;
  border: 1px solid #b4e9c9;
}

.stats {
  display: grid;
  gap: 12px;
  grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
}

.stats dt {
  font-size: 0.82rem;
  color: var(--muted);
}

.stats dd {
  margin: 6px 0 0;
  font-size: 1.1rem;
  font-weight: 700;
}

.good {
  color: var(--good);
}

.bad {
  color: var(--bad);
}

.muted {
  color: var(--muted);
}

.clean-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 8px;
}

.pill {
  display: inline-block;
  font-size: 0.78rem;
  border-radius: 999px;
  padding: 3px 8px;
  border: 1px solid #d1d9ea;
  text-transform: capitalize;
}

.pill.income {
  border-color: #98dcb3;
  background: #ecfbf2;
}

.pill.expense {
  border-color: #ffb4be;
  background: #fff0f3;
}

.pill.goal {
  border-color: #9cc8ff;
  background: #eef5ff;
}

.table-wrap {
  overflow-x: hidden;
}

table thead th {
  font-size: 0.88rem;
  color: #5c6780;
  font-weight: 700;
  background: #f8faff;
}

table tbody tr:hover {
  background: #fbfcff;
}

table {
  width: 100%;
  border-collapse: collapse;
  min-width: 0;
  table-layout: fixed;
}

th,
td {
  border-bottom: 1px solid #e8ecf7;
  padding: 6px;
  text-align: left;
  vertical-align: top;
  overflow-wrap: anywhere;
}

.editable-list-item {
  border: 1px solid #e3e9f7;
  border-radius: 10px;
  padding: 8px;
  display: grid;
  gap: 6px;
  background: #fcfdff;
}

.item-title {
  font-weight: 600;
}

.action-summary {
  cursor: pointer;
  color: var(--primary);
  font-weight: 600;
  font-size: 0.9rem;
}

.compact-form {
  margin-top: 6px;
  gap: 6px;
}

.compact-delete {
  margin-top: 2px;
}

.section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 8px;
}

.section-head h2 {
  margin: 0;
}

.modal-card {
  width: min(460px, 92vw);
  border: 1px solid #dfe6f8;
  border-radius: 14px;
  padding: 12px;
  box-shadow: 0 18px 40px rgba(15, 23, 42, 0.25);
}

.modal-card::backdrop {
  background: rgba(10, 15, 30, 0.42);
}

.modal-close-row {
  display: flex;
  justify-content: flex-end;
  margin-bottom: 4px;
}

.error-box {
  white-space: pre-wrap;
  background: #fff3f4;
  border: 1px solid #ffb4be;
  border-radius: 8px;
  padding: 10px;
}

.budget-tabs-layout {
  display: grid;
  grid-template-columns: 240px minmax(0, 1fr);
  gap: 16px;
  align-items: start;
}

.tabs-sidebar {
  position: sticky;
  top: 12px;
  display: grid;
  gap: 8px;
  padding: 10px;
}

.tab-link {
  display: block;
  border: 1px solid #d4ddf3;
  border-radius: 10px;
  padding: 10px 12px;
  font-weight: 600;
  color: #24304a;
  background: #f8faff;
}

.tab-link:hover {
  text-decoration: none;
  background: #edf2ff;
}

.tab-link.active {
  background: var(--primary);
  color: #fff;
  border-color: var(--primary);
}

.tab-panel-wrap {
  min-width: 0;
}

.analytics-list li {
  border: 1px solid #e6ebfb;
  border-radius: 10px;
  padding: 10px;
}

.analytics-row {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}

.small-text {
  font-size: 0.9rem;
}

.goal-progress-list {
  gap: 10px;
}

.goal-progress-item {
  border: 1px solid #dce7fb;
  border-radius: 10px;
  padding: 10px;
  background: #fcfdff;
}

.goal-progress-track {
  height: 10px;
  border-radius: 999px;
  background: #e8eef8;
  overflow: hidden;
  margin: 8px 0 6px;
}

.goal-progress-fill {
  height: 100%;
  background: linear-gradient(90deg, #1fa971 0%, #0f8a79 100%);
}

.goal-milestones {
  margin-top: 8px;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.goal-milestone {
  border-radius: 999px;
  padding: 3px 8px;
  font-size: 0.78rem;
  font-weight: 700;
  border: 1px solid #d5dfef;
}

.goal-milestone.reached {
  border-color: #8dd6b7;
  background: #eafbf3;
  color: #0f6a43;
}

.goal-milestone.pending {
  border-color: #d8e0f0;
  background: #f3f6fc;
  color: #5a657c;
}

.hero {
  margin-bottom: 14px;
  border: 1px solid #d7dfef;
  background:
    linear-gradient(130deg, rgba(11, 99, 206, 0.08) 0%, rgba(15, 138, 121, 0.08) 100%),
    var(--surface);
}

.hero-grid {
  display: grid;
  grid-template-columns: 1.5fr 1fr;
  gap: 18px;
}

.hero-copy h1 {
  margin: 10px 0 10px;
  font-family: "Libre Baskerville", Georgia, serif;
  line-height: 1.2;
  font-size: clamp(1.6rem, 3vw, 2.4rem);
  color: #10213a;
}

.hero-badge {
  display: inline-block;
  border-radius: 999px;
  border: 1px solid #9ed8ce;
  background: #e8faf6;
  color: #0e6456;
  font-size: 0.76rem;
  font-weight: 800;
  letter-spacing: 0.4px;
  text-transform: uppercase;
  padding: 4px 10px;
}

.hero-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 12px;
}

.hero-note {
  margin-top: 10px;
  font-size: 0.92rem;
  color: #41506c;
}

.hero-panel {
  border: 1px solid #d5deef;
  border-radius: 12px;
  padding: 12px;
  background: #fbfdff;
}

.hero-panel h2 {
  margin: 2px 0 10px;
  font-size: 1rem;
}

.hero-metrics {
  display: grid;
  gap: 8px;
}

.hero-metrics article {
  border: 1px solid #e0e7f5;
  border-radius: 10px;
  padding: 10px;
  background: #fff;
}

.metric-title {
  display: block;
  color: var(--muted);
  font-size: 0.82rem;
  margin-bottom: 2px;
}

.home-feature-grid {
  display: grid;
  gap: 12px;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
}

.feature-card {
  border: 1px solid #d9e2f2;
  transition: transform 0.16s ease, box-shadow 0.16s ease;
}

.feature-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 14px 28px rgba(14, 33, 60, 0.1);
}

.feature-card h3 {
  margin-top: 4px;
  margin-bottom: 6px;
}

.cta-strip {
  margin-top: 14px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  border: 1px solid #d8e0f1;
  background: linear-gradient(90deg, rgba(11, 99, 206, 0.08) 0%, rgba(255, 255, 255, 0.95) 60%);
}

.cta-strip h2 {
  margin: 4px 0 4px;
}

.calculator-hero h1 {
  margin: 8px 0 6px;
  font-family: "Libre Baskerville", Georgia, serif;
}

.calculator-note {
  max-width: 260px;
}

.calculator-layout {
  align-items: start;
}

.calculator-type-grid {
  display: grid;
  gap: 12px;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
}

.calculator-type-selector {
  margin: 0;
  padding: 0;
  border: 0;
}

.calculator-type-selector legend {
  margin-bottom: 8px;
  font-weight: 700;
}

.calculator-type-option {
  display: block;
  cursor: pointer;
}

.calculator-type-option input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.calculator-type-copy {
  display: grid;
  gap: 6px;
}

.calculator-type-title {
  font-size: 1.1rem;
  font-weight: 700;
  color: #10213a;
}

.calculator-hidden {
  display: none;
}

.calculator-type-active {
  border-color: #96bfff;
  background: linear-gradient(180deg, #f7fbff 0%, #eef5ff 100%);
}

.calculator-results {
  min-height: 100%;
}

.calculator-stats {
  grid-template-columns: repeat(2, minmax(130px, 1fr));
}

.faq-item {
  border: 1px solid #d8e1f3;
  border-radius: 10px;
  padding: 10px;
  background: #fcfdff;
}

.faq-item summary {
  cursor: pointer;
  font-weight: 700;
}

.faq-item p {
  margin: 10px 0 0;
}

.contact-honeypot {
  position: absolute;
  left: -9999px;
  width: 1px;
  height: 1px;
  overflow: hidden;
}

.site-footer {
  margin-top: 20px;
  border-top: 1px solid #d6def0;
  background: rgba(255, 255, 255, 0.8);
}

.footer-inner {
  padding: 16px 0 22px;
  display: flex;
  justify-content: space-between;
  gap: 14px;
  flex-wrap: wrap;
}

.footer-brand {
  margin: 0 0 6px;
  font-weight: 800;
}

.footer-nav {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  align-items: center;
}

@media (max-width: 900px) {
  .topbar-inner {
    min-height: unset;
    padding-top: 8px;
    padding-bottom: 8px;
    flex-wrap: wrap;
  }

  .topbar-nav {
    width: 100%;
    justify-content: flex-start;
    flex-wrap: wrap;
    row-gap: 8px;
  }

  .budget-tabs-layout {
    grid-template-columns: 1fr;
  }

  .tabs-sidebar {
    position: static;
    grid-auto-flow: row;
    grid-auto-columns: 1fr;
    overflow-x: visible;
    white-space: normal;
    padding: 8px;
  }

  .hero-grid {
    grid-template-columns: 1fr;
  }

  .cta-strip {
    flex-direction: column;
    align-items: flex-start;
  }

  .calculator-note {
    max-width: none;
  }

  .footer-inner {
    flex-direction: column;
    align-items: flex-start;
  }
}

@media (max-width: 480px) {
  .topbar-inner {
    min-height: 48px;
  }

  .brand {
    gap: 8px;
  }

  .brand-logo {
    width: 32px;
    height: 32px;
  }

  .brand-name {
    font-size: 0.92rem;
  }

  .brand-tagline {
    font-size: 0.68rem;
  }

  .section-head {
    align-items: flex-start;
    flex-direction: column;
  }

  .container {
    width: calc(100vw - 12px);
  }
}

@media (min-width: 1024px) {
  body {
    font-size: 15px;
  }

  .container {
    width: min(1280px, 94vw);
  }

  .tabs-sidebar {
    gap: 6px;
    padding: 8px;
  }

  .tab-link {
    padding: 8px 10px;
  }
}
