/* Mortgage & Auto Loan Calculator ("Loan Ledger") — public static build for
   doohickeytools.com/mortgage-auto-loan-calculator/
   Plain CSS, no build step. Faithful to the Space's theme tokens. */
/* Hidden elements must stay hidden: .dialog-backdrop sets display:flex,
   which otherwise overrides the browser's built-in [hidden] rule and
   leaves dialogs visible (and unclosable) on load. */
[hidden] { display: none !important; }
:root {
  --bg: #f7f3ea;
  --card: #fffdf6;
  --card2: #ece7d8;
  --ink: #16211b;
  --muted: #5d6a60;
  --line: #d9d2bd;
  --accent: #1d5c3f;
  --accent-soft: #e4efe8;
  --brass: #b8862f;
  --dark-panel: #16211b;
  --red: #e14d2a;
  --red-dark: #c93f20;
  --amber: #f0a832;
  --amber-dark: #d18d1d;
  --radius: 16px;
  --font: "Newsreader", Georgia, "Times New Roman", serif;
  --font-ui: "Newsreader", Georgia, serif;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0e1511;
    --card: #16211b;
    --card2: #1e2b23;
    --ink: #eef3ec;
    --muted: #9db3a4;
    --line: #2c3d31;
    --accent: #4cc38a;
    --accent-soft: #1d3327;
    --brass: #d9a441;
    --dark-panel: #0b100d;
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.5;
}

.page { max-width: 1024px; margin: 0 auto; padding: 20px 20px 48px; }
.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;
}

h2 { font-size: 1.25rem; margin: 0; }
h3 { font-size: 1.05rem; margin: 0 0 12px; }

/* ---------- Header ---------- */
.site-header {
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px; flex-wrap: wrap; margin-bottom: 8px;
}
.brand { display: flex; align-items: center; gap: 10px; font-size: 1.6rem; font-weight: 700; letter-spacing: -0.01em; }
.brand-emoji { font-size: 1.7rem; }
.header-actions { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.pill {
  background: #eef3e6; color: #4c7a34; border: 1px solid #cfdfc0;
  font-size: 0.72rem; font-weight: 700; letter-spacing: 0.08em;
  padding: 4px 10px; border-radius: 999px;
}
.pill.guest { background: #fdf3e3; color: #9a6a12; border-color: #f0d9a8; }
.pill.premium { background: #22252b; color: #ffd97a; border-color: #22252b; }

/* ---------- Buttons ---------- */
.btn {
  font-family: var(--font); font-size: 0.95rem; font-weight: 600;
  border: 1px solid transparent; border-radius: 999px;
  padding: 9px 18px; cursor: pointer; background: var(--card); color: var(--ink);
}
.btn:hover { filter: brightness(0.97); }
.btn:active { transform: translateY(1px); }
.btn-ghost { background: var(--card); border-color: var(--line); }
.btn-dark { background: var(--dark-panel); color: #fff; }
.btn-red { background: var(--red); color: #fff; }
.btn-red:hover { background: var(--red-dark); }
.btn-amber { background: var(--amber); color: #231a05; }
.btn-amber:hover { background: var(--amber-dark); color: #fff; }
.btn-light { background: var(--card); color: var(--ink); }
.btn-small { padding: 6px 12px; font-size: 0.85rem; }

/* ---------- Tabs ---------- */
.tabs {
  display: inline-flex; background: var(--card2); border-radius: 999px; padding: 4px; gap: 2px;
  margin: 12px 0 16px;
}
.tab {
  font-family: var(--font); font-size: 0.95rem; font-weight: 600;
  border: 0; border-radius: 999px; padding: 8px 18px; cursor: pointer;
  background: transparent; color: var(--muted);
}
.tab.active { background: var(--accent); color: #fff; }

/* ---------- Cards & layout ---------- */
.card {
  background: var(--card); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 22px;
  box-shadow: 0 1px 3px rgba(22, 33, 27, 0.05);
}
.layout { display: grid; grid-template-columns: 1fr 1.1fr; gap: 20px; margin-top: 20px; align-items: start; }
.col-left, .col-right { display: flex; flex-direction: column; gap: 20px; min-width: 0; }
@media (max-width: 860px) {
  .layout { grid-template-columns: 1fr; }
  .brand { font-size: 1.35rem; }
}

/* ---------- Hero ---------- */
.hero {
  background: var(--dark-panel); color: #f4f1ea; border-color: var(--dark-panel);
  text-align: center; padding: 28px 22px 22px;
}
.hero-label { margin: 0; color: #c9d4c9; font-size: 0.95rem; letter-spacing: 0.04em; text-transform: uppercase; font-weight: 600; }
.hero-amount {
  color: var(--brass); font-size: 3.2rem; font-weight: 700; letter-spacing: -0.02em;
  line-height: 1.1; font-variant-numeric: tabular-nums; margin-top: 6px;
}
.hero-sub { color: #c9d4c9; margin: 8px 0 0; }
.hero-breakdown { max-width: 460px; margin: 18px auto 0; text-align: left; }
.hero-breakdown .row {
  display: flex; justify-content: space-between; gap: 12px;
  padding: 6px 0; border-bottom: 1px solid rgba(244, 241, 234, 0.14); font-size: 0.98rem;
}
.hero-breakdown .row:last-child { border-bottom: 0; }
.hero-breakdown .row span:last-child { font-variant-numeric: tabular-nums; font-weight: 600; }
.savings-banner {
  max-width: 560px; margin: 18px auto 0; padding: 10px 14px;
  background: #1d5c3f; color: #d9f2e3; border-radius: 10px; font-weight: 600;
}
.hero-stats {
  display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px;
  max-width: 560px; margin: 20px auto 0;
}
.hero-stat { background: rgba(244, 241, 234, 0.07); border-radius: 12px; padding: 12px 8px; }
.hero-stat-value { font-size: 1.3rem; font-weight: 700; font-variant-numeric: tabular-nums; }
.hero-stat-label { color: #c9d4c9; font-size: 0.85rem; margin-top: 2px; }

/* ---------- Inputs ---------- */
.inputs-card h2 { margin-bottom: 16px; }
.field { margin-bottom: 16px; }
.field label { display: block; font-weight: 600; margin-bottom: 6px; }
.money-row { display: flex; align-items: center; gap: 6px; }
.affix { color: var(--muted); font-weight: 600; }
.field input[type="number"], .field select, .save-row input[type="text"] {
  font-family: var(--font); font-size: 1rem;
  border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px;
  background: var(--card); color: var(--ink); width: 100%;
}
.field input[type="number"] { flex: 1; min-width: 0; font-variant-numeric: tabular-nums; }
.field input[type="range"] { width: 100%; margin-top: 8px; accent-color: var(--accent); cursor: pointer; }
.hint { color: var(--muted); font-size: 0.88rem; margin: 6px 0 0; }

/* ---------- Ad slot (exactly one) ---------- */
.ad-slot {
  border: 2px dashed #cfc4ae; border-radius: var(--radius);
  padding: 18px 20px; text-align: center; background: #fffdf8;
}
@media (prefers-color-scheme: dark) {
  .ad-slot { background: #1a241d; border-color: #3a4a3e; }
}
.ad-label { font-size: 0.7rem; font-weight: 800; letter-spacing: 0.14em; color: #a39a86; }
.ad-copy { margin: 10px 0 4px; font-weight: 600; }
.ad-sub { margin: 0 0 10px; color: var(--muted); font-size: 0.9rem; }
.ad-link {
  font-family: var(--font); font-size: 0.92rem; font-weight: 700; color: var(--red);
  background: none; border: 0; cursor: pointer; padding: 0; text-decoration: none;
}
.ad-link:hover { text-decoration: underline; }

/* ---------- Save card ---------- */
.save-card { background: var(--dark-panel); color: #f4f1ea; border-color: var(--dark-panel); }
.save-card h2 { color: #fff; }
.save-text { color: #c9d4c9; margin: 8px 0 16px; }
.save-row { display: flex; gap: 8px; }
.save-row input[type="text"] { flex: 1; min-width: 0; background: #fff; color: #16211b; border-color: transparent; }
.save-message { margin: 10px 0 0; font-size: 0.92rem; }
.save-message.error { color: #ffb59d; }
.save-message.ok { color: #a9e6c3; }
.save-actions { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 16px; }
.save-actions .btn-light { background: #fff; }
.save-actions .btn-ghost { background: transparent; color: #f4f1ea; border-color: rgba(244, 241, 234, 0.4); }

/* ---------- Balance chart & table ---------- */
.balance-card h2 { margin-bottom: 14px; }
.balance-chart { width: 100%; height: 96px; display: block; }
.chart-caption {
  display: flex; justify-content: space-between;
  color: var(--muted); font-size: 0.85rem; margin-top: 6px;
}
.table-head { margin-top: 16px; }
.table-wrap { overflow-x: auto; margin-top: 10px; }
table.schedule { width: 100%; border-collapse: collapse; font-size: 0.92rem; font-variant-numeric: tabular-nums; }
table.schedule th, table.schedule td { padding: 7px 6px; text-align: right; border-bottom: 1px solid var(--line); }
table.schedule th:first-child, table.schedule td:first-child { text-align: left; }
table.schedule th { color: var(--muted); font-weight: 600; font-size: 0.85rem; }
table.schedule tbody tr:last-child td { border-bottom: 0; }

/* ---------- Scenarios ---------- */
.scenarios-head { display: flex; align-items: baseline; justify-content: space-between; }
.scenarios-count { color: var(--muted); font-size: 0.92rem; font-weight: 600; }
.other-kind-note { color: var(--muted); font-size: 0.9rem; margin: 10px 0 0; }
.scenario-list { list-style: none; margin: 14px 0 0; padding: 0; }
.scenario-row {
  display: flex; align-items: center; gap: 10px;
  padding: 12px 2px; border-bottom: 1px solid var(--line);
}
.scenario-row:last-child { border-bottom: 0; }
.scenario-emoji { font-size: 1.25rem; flex: none; }
.scenario-main { flex: 1; min-width: 0; }
.scenario-name {
  font-family: var(--font); font-size: 1rem; font-weight: 600; text-align: left;
  background: none; border: 0; padding: 0; cursor: pointer; color: var(--ink);
  overflow-wrap: anywhere;
}
.scenario-name:hover { text-decoration: underline; }
.scenario-sub { color: var(--muted); font-size: 0.88rem; margin-top: 2px; }
.scenario-right { text-align: right; flex: none; }
.scenario-payment { color: var(--accent); font-weight: 700; font-variant-numeric: tabular-nums; }
.scenario-interest { color: var(--muted); font-size: 0.85rem; }
.scenario-badge {
  flex: none; font-size: 0.62rem; font-weight: 800; letter-spacing: 0.08em;
  background: #fdf3e3; color: #9a6a12; border-radius: 999px; padding: 3px 8px;
}
.scenario-del {
  flex: none; font-family: var(--font); font-size: 1rem; background: none; border: 0;
  cursor: pointer; color: var(--muted); padding: 4px; line-height: 1;
}
.scenario-del:hover { color: var(--ink); }
.empty-state { color: var(--muted); margin: 14px 0 0; }

/* ---------- Dialogs ---------- */
.dialog-backdrop {
  position: fixed; inset: 0; background: rgba(30, 25, 18, 0.55);
  display: flex; align-items: center; justify-content: center;
  padding: 16px; z-index: 50;
}
.dialog {
  position: relative;
  background: #fff; color: #26221c; border-radius: 18px; padding: 26px; width: 100%; max-width: 440px;
  max-height: calc(100vh - 48px); overflow-y: auto;
  box-shadow: 0 18px 50px rgba(0, 0, 0, 0.3);
}
.dialog-wide { max-width: 720px; }
.dialog-x {
  position: absolute; top: 14px; right: 16px;
  font-family: var(--font); font-size: 1.4rem; line-height: 1;
  background: none; border: 0; cursor: pointer; color: #6f6a5e; padding: 4px 8px;
}
.dialog h2 { font-size: 1.4rem; margin-bottom: 6px; color: #26221c; }
.dialog-sub { color: #6f6a5e; margin: 0 0 18px; }
.limit-note {
  background: #fdf3e3; border: 1px solid #f0d9a8; color: #7a5410;
  border-radius: 10px; padding: 10px 14px; margin: 0 0 16px; font-weight: 600;
}
.field { margin-bottom: 14px; }
.field label { display: block; font-weight: 600; margin-bottom: 5px; }
.check { display: flex; align-items: center; gap: 9px; font-weight: 500; margin: 10px 0; cursor: pointer; color: #26221c; }
.check input { width: 18px; height: 18px; accent-color: #1d5c3f; cursor: pointer; }
.dialog-note { color: #6f6a5e; font-size: 0.9rem; margin: 16px 0 6px; }
.preview-on-note { color: #1d5c3f; font-weight: 600; font-size: 0.92rem; margin: 6px 0 0; }
.dialog-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 18px; }

.plans { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
@media (max-width: 640px) { .plans { grid-template-columns: 1fr; } }
.plan {
  border: 1px solid #e8dfcf; border-radius: 14px; padding: 16px;
  display: flex; flex-direction: column; gap: 10px; color: #26221c;
}
.plan-highlight { border: 2px solid var(--amber); background: #fff8f5; }
.plan h3 { margin: 0; color: #26221c; }
.plan-price { font-size: 1.5rem; font-weight: 700; }
.plan-price span { font-size: 0.85rem; font-weight: 500; color: #6f6a5e; }
.plan ul { margin: 0; padding-left: 18px; font-size: 0.92rem; }
.plan ul li { margin-bottom: 5px; }
.plan-cta { margin-top: auto; width: 100%; }
.preview-check { margin-top: 14px; font-weight: 600; }

/* ---------- Site footer ---------- */
.site-footer { text-align: center; margin-top: 28px; font-size: 0.85rem; }
.site-footer a { color: var(--muted); }

/* ---------- Preview banner ---------- */
.preview-banner { background: #fdf3e3; border: 1px solid #f0d9a8; color: #7a5410; border-radius: 10px; padding: 10px 14px; margin: 12px 0; font-size: 0.92rem; display: flex; align-items: center; justify-content: space-between; gap: 12px; }
