/* =========================================================================
   Ledger — design system
   "Precision instrument" aesthetic: cool paper, ink structure,
   emerald = growth, clay = debt, monospace figures as the signature.
   ========================================================================= */

:root {
  --bg:        #eef2f0;
  --paper:     #ffffff;
  --ink:       #15191b;
  --ink-soft:  #47514e;
  --muted:     #79827f;
  --line:      #e1e6e3;
  --line-soft: #edf0ee;

  --green:      #0e7c5a;
  --green-deep: #0a5f45;
  --green-tint: #e4f1eb;
  --green-ink:  #0c2a20;   /* dark sections */

  --clay:      #bc4a30;
  --clay-tint: #f7e8e3;
  --gold:      #b0822b;
  --gold-tint: #f4ecda;

  --radius:    14px;
  --radius-sm: 9px;
  --shadow:    0 1px 2px rgba(20,30,26,.04), 0 8px 24px rgba(20,30,26,.06);
  --shadow-lg: 0 2px 6px rgba(20,30,26,.06), 0 24px 56px rgba(20,30,26,.10);

  --font-display: "Space Grotesk", ui-sans-serif, system-ui, sans-serif;
  --font-body:    "Inter", ui-sans-serif, system-ui, -apple-system, sans-serif;
  --font-mono:    "JetBrains Mono", ui-monospace, "SF Mono", Menlo, monospace;

  --maxw: 1140px;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-body);
  font-size: 16px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  * { animation-duration: .001ms !important; transition-duration: .001ms !important; }
}

h1, h2, h3, h4 { font-family: var(--font-display); font-weight: 600; line-height: 1.12; letter-spacing: -0.02em; margin: 0; }
a { color: var(--green-deep); text-decoration: none; }
a:hover { text-decoration: underline; }
.wrap { max-width: var(--maxw); margin: 0 auto; padding: 0 24px; }

/* tabular figures everywhere numbers matter */
.mono { font-family: var(--font-mono); font-variant-numeric: tabular-nums; letter-spacing: -0.01em; }

/* ---------- header / nav ---------- */
.site-header {
  position: sticky; top: 0; z-index: 50;
  background: rgba(238,242,240,.82);
  backdrop-filter: saturate(140%) blur(10px);
  border-bottom: 1px solid var(--line);
}
.nav { display: flex; align-items: center; gap: 28px; height: 64px; }
.brand { display: flex; align-items: center; gap: 10px; font-family: var(--font-display); font-weight: 700; font-size: 18px; letter-spacing: -0.03em; color: var(--ink); }
.brand:hover { text-decoration: none; }
.brand .glyph {
  width: 26px; height: 26px; border-radius: 7px;
  background: var(--green-ink); position: relative; flex: none;
}
.brand .glyph::before, .brand .glyph::after {
  content: ""; position: absolute; left: 6px; right: 6px; height: 2px; border-radius: 2px; background: var(--green-tint);
}
.brand .glyph::before { top: 9px; opacity: .55; }
.brand .glyph::after  { top: 15px; width: 8px; right: auto; background: var(--gold); }
.nav-links { display: flex; gap: 22px; margin-left: auto; align-items: center; }
.nav-links a { color: var(--ink-soft); font-size: 14.5px; font-weight: 500; }
.nav-links a:hover { color: var(--ink); text-decoration: none; }
.nav-links a.active { color: var(--green-deep); }
.nav-toggle { display: none; margin-left: auto; background: none; border: 1px solid var(--line); border-radius: 8px; width: 40px; height: 38px; cursor: pointer; align-items: center; justify-content: center; }
.nav-toggle span { width: 16px; height: 2px; background: var(--ink); position: relative; }
.nav-toggle span::before, .nav-toggle span::after { content:""; position:absolute; left:0; width:16px; height:2px; background:var(--ink); }
.nav-toggle span::before { top:-5px; } .nav-toggle span::after { top:5px; }

@media (max-width: 820px) {
  .nav-toggle { display: flex; }
  .nav-links {
    position: absolute; top: 64px; left: 0; right: 0;
    flex-direction: column; align-items: flex-start; gap: 0;
    background: var(--paper); border-bottom: 1px solid var(--line);
    padding: 8px 24px 16px; margin: 0; display: none;
  }
  .nav-links.open { display: flex; }
  .nav-links a { padding: 10px 0; width: 100%; border-bottom: 1px solid var(--line-soft); }
}

/* ---------- buttons ---------- */
.btn {
  display: inline-flex; align-items: center; gap: 8px; justify-content: center;
  font-family: var(--font-body); font-weight: 600; font-size: 15px;
  padding: 12px 20px; border-radius: 10px; border: 1px solid transparent; cursor: pointer;
  transition: transform .08s ease, background .15s ease, box-shadow .15s ease;
}
.btn:hover { text-decoration: none; }
.btn:active { transform: translateY(1px); }
.btn-primary { background: var(--green); color: #fff; }
.btn-primary:hover { background: var(--green-deep); }
.btn-ghost { background: var(--paper); color: var(--ink); border-color: var(--line); }
.btn-ghost:hover { border-color: #cdd5d1; }
.btn-sm { padding: 8px 14px; font-size: 13.5px; border-radius: 8px; }

/* ---------- hero (home) ---------- */
.hero { padding: 72px 0 40px; }
.eyebrow { font-family: var(--font-mono); font-size: 12.5px; letter-spacing: .14em; text-transform: uppercase; color: var(--green-deep); margin-bottom: 18px; }
.hero h1 { font-size: clamp(38px, 6vw, 62px); letter-spacing: -0.035em; max-width: 16ch; }
.hero h1 em { font-style: normal; color: var(--green); }
.hero p.lead { font-size: clamp(17px, 2.2vw, 20px); color: var(--ink-soft); max-width: 56ch; margin: 22px 0 0; }
.hero-actions { display: flex; gap: 12px; margin-top: 30px; flex-wrap: wrap; }
.hero-meta { display: flex; gap: 30px; margin-top: 44px; flex-wrap: wrap; }
.hero-meta .stat .n { font-family: var(--font-mono); font-size: 26px; font-weight: 500; color: var(--ink); }
.hero-meta .stat .l { font-size: 13px; color: var(--muted); margin-top: 2px; }

/* ---------- tool grid (home) ---------- */
.section { padding: 56px 0; }
.section-head { display: flex; align-items: baseline; justify-content: space-between; gap: 16px; margin-bottom: 28px; flex-wrap: wrap; }
.section-head h2 { font-size: clamp(24px, 3.4vw, 34px); }
.section-head .tag { font-family: var(--font-mono); font-size: 12.5px; color: var(--muted); letter-spacing: .04em; }

.tool-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 18px; }
@media (max-width: 900px) { .tool-grid { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 600px) { .tool-grid { grid-template-columns: 1fr; } }

.tool-card {
  background: var(--paper); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 22px 22px 20px; display: flex; flex-direction: column; gap: 10px;
  transition: transform .12s ease, box-shadow .15s ease, border-color .15s ease;
  position: relative; overflow: hidden;
}
.tool-card:hover { transform: translateY(-3px); box-shadow: var(--shadow); border-color: #d2dad6; text-decoration: none; }
.tool-card .ic { width: 38px; height: 38px; border-radius: 10px; background: var(--green-tint); color: var(--green-deep); display: flex; align-items: center; justify-content: center; }
.tool-card .ic svg { width: 20px; height: 20px; }
.tool-card h3 { font-size: 18px; color: var(--ink); }
.tool-card p { font-size: 14px; color: var(--ink-soft); margin: 0; line-height: 1.5; }
.tool-card .go { font-family: var(--font-mono); font-size: 12.5px; color: var(--green-deep); margin-top: auto; padding-top: 6px; display: inline-flex; align-items: center; gap: 6px; }
.badge { position: absolute; top: 16px; right: 16px; font-family: var(--font-mono); font-size: 10.5px; letter-spacing: .08em; text-transform: uppercase; padding: 3px 8px; border-radius: 999px; }
.badge.popular { background: var(--green-ink); color: var(--green-tint); }
.badge.niche { background: var(--gold-tint); color: var(--gold); border: 1px solid #e7d9b6; }

/* ---------- tool page layout ---------- */
.tool-hero { padding: 40px 0 8px; }
.crumb { font-family: var(--font-mono); font-size: 12.5px; color: var(--muted); margin-bottom: 14px; }
.crumb a { color: var(--muted); }
.tool-hero h1 { font-size: clamp(30px, 4.6vw, 44px); }
.tool-hero p { color: var(--ink-soft); max-width: 60ch; margin: 14px 0 0; font-size: 17px; }

.calc { display: grid; grid-template-columns: minmax(0, 1.05fr) minmax(0, 1fr); gap: 22px; padding: 28px 0 8px; align-items: start; }
@media (max-width: 880px) { .calc { grid-template-columns: 1fr; } }

.panel { background: var(--paper); border: 1px solid var(--line); border-radius: var(--radius); padding: 24px; }
.panel.sticky { position: sticky; top: 88px; }
@media (max-width: 880px) { .panel.sticky { position: static; } }
.panel h2.panel-title { font-size: 14px; font-family: var(--font-mono); font-weight: 500; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); margin-bottom: 20px; }

/* ---------- form controls ---------- */
.field { margin-bottom: 20px; }
.field:last-child { margin-bottom: 0; }
.field label { display: flex; justify-content: space-between; align-items: baseline; font-size: 14px; font-weight: 500; color: var(--ink-soft); margin-bottom: 8px; gap: 10px; }
.field label .hint { font-weight: 400; color: var(--muted); font-size: 12.5px; }

.input-affix { display: flex; align-items: center; border: 1px solid var(--line); border-radius: var(--radius-sm); background: #fff; transition: border-color .15s ease, box-shadow .15s ease; overflow: hidden; }
.input-affix:focus-within { border-color: var(--green); box-shadow: 0 0 0 3px var(--green-tint); }
.input-affix .affix { padding: 0 12px; color: var(--muted); font-family: var(--font-mono); font-size: 14px; background: #fafbfb; align-self: stretch; display: flex; align-items: center; border-right: 1px solid var(--line); }
.input-affix .affix.suffix { border-right: none; border-left: 1px solid var(--line); }
.input-affix input {
  border: none; outline: none; width: 100%; padding: 12px 12px; font-family: var(--font-mono);
  font-size: 15.5px; color: var(--ink); background: transparent; font-variant-numeric: tabular-nums;
}
.input-affix input::-webkit-outer-spin-button, .input-affix input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.input-affix input[type=number] { -moz-appearance: textfield; }

select.control {
  width: 100%; padding: 11px 12px; border: 1px solid var(--line); border-radius: var(--radius-sm);
  background: #fff; font-family: var(--font-body); font-size: 15px; color: var(--ink); cursor: pointer;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1l5 5 5-5' stroke='%2379827f' stroke-width='1.6' fill='none' stroke-linecap='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 12px center;
}
select.control:focus { outline: none; border-color: var(--green); box-shadow: 0 0 0 3px var(--green-tint); }

/* range slider */
input[type=range] { -webkit-appearance: none; appearance: none; width: 100%; height: 4px; border-radius: 4px; background: var(--line); margin-top: 12px; cursor: pointer; }
input[type=range]::-webkit-slider-thumb { -webkit-appearance: none; width: 20px; height: 20px; border-radius: 50%; background: var(--green); border: 3px solid #fff; box-shadow: 0 1px 4px rgba(14,124,90,.4); cursor: pointer; }
input[type=range]::-moz-range-thumb { width: 16px; height: 16px; border-radius: 50%; background: var(--green); border: 3px solid #fff; box-shadow: 0 1px 4px rgba(14,124,90,.4); cursor: pointer; }
input[type=range]:focus { outline: none; }
input[type=range]:focus-visible::-webkit-slider-thumb { box-shadow: 0 0 0 4px var(--green-tint); }

/* segmented toggle */
.segmented { display: inline-flex; background: #f1f4f2; border-radius: 10px; padding: 4px; gap: 4px; width: 100%; }
.segmented button {
  flex: 1; border: none; background: transparent; padding: 9px 12px; border-radius: 7px; cursor: pointer;
  font-family: var(--font-body); font-size: 13.5px; font-weight: 600; color: var(--ink-soft); transition: all .12s ease;
}
.segmented button.on { background: #fff; color: var(--green-deep); box-shadow: 0 1px 2px rgba(20,30,26,.08); }

/* ---------- results ---------- */
.result-figure { padding-bottom: 18px; border-bottom: 2px solid var(--ink); margin-bottom: 22px; }
.result-figure .rlabel { font-size: 13px; color: var(--muted); font-weight: 500; margin-bottom: 6px; }
.result-figure .rvalue { font-family: var(--font-mono); font-size: clamp(34px, 6vw, 46px); font-weight: 600; letter-spacing: -0.03em; color: var(--ink); line-height: 1; }
.result-figure .rvalue.pos { color: var(--green-deep); }
.result-figure .rvalue.neg { color: var(--clay); }
.result-figure .rsub { font-size: 13.5px; color: var(--ink-soft); margin-top: 8px; }

.stat-rows { display: flex; flex-direction: column; }
.stat-row { display: flex; justify-content: space-between; align-items: center; padding: 11px 0; border-bottom: 1px solid var(--line-soft); gap: 16px; }
.stat-row:last-child { border-bottom: none; }
.stat-row .k { font-size: 14px; color: var(--ink-soft); display: flex; align-items: center; gap: 8px; }
.stat-row .k .dot { width: 9px; height: 9px; border-radius: 2px; flex: none; }
.stat-row .v { font-family: var(--font-mono); font-size: 15px; font-weight: 500; color: var(--ink); font-variant-numeric: tabular-nums; }
.stat-row .v.green { color: var(--green-deep); }
.stat-row .v.clay { color: var(--clay); }

/* composition bar */
.compbar { display: flex; height: 12px; border-radius: 6px; overflow: hidden; margin: 4px 0 18px; background: var(--line); }
.compbar span { height: 100%; display: block; }

.note { font-size: 12.5px; color: var(--muted); line-height: 1.5; margin-top: 16px; padding-top: 14px; border-top: 1px solid var(--line-soft); }

/* callout (coasting / feasibility) */
.callout { border-radius: var(--radius-sm); padding: 14px 16px; font-size: 14px; margin-bottom: 20px; display: flex; gap: 10px; align-items: flex-start; }
.callout.good { background: var(--green-tint); color: var(--green-deep); }
.callout.warn { background: var(--clay-tint); color: var(--clay); }
.callout svg { flex: none; margin-top: 1px; }

/* ---------- chart ---------- */
.chart-wrap { margin-top: 20px; }
.chart-wrap svg { width: 100%; height: auto; display: block; }
.chart-legend { display: flex; gap: 18px; margin-top: 10px; flex-wrap: wrap; }
.chart-legend .li { display: flex; align-items: center; gap: 7px; font-size: 12.5px; color: var(--ink-soft); }
.chart-legend .sw { width: 12px; height: 12px; border-radius: 3px; }

/* ---------- schedule table ---------- */
.table-toggle { margin-top: 8px; }
details.schedule { margin-top: 22px; border: 1px solid var(--line); border-radius: var(--radius-sm); overflow: hidden; background: #fff; }
details.schedule > summary { cursor: pointer; padding: 14px 18px; font-weight: 600; font-size: 14px; list-style: none; display: flex; justify-content: space-between; align-items: center; }
details.schedule > summary::-webkit-details-marker { display: none; }
details.schedule > summary::after { content: "＋"; color: var(--muted); font-family: var(--font-mono); }
details.schedule[open] > summary::after { content: "－"; }
.table-scroll { max-height: 360px; overflow: auto; border-top: 1px solid var(--line); }
table.sched { width: 100%; border-collapse: collapse; font-size: 13px; }
table.sched th, table.sched td { padding: 9px 18px; text-align: right; font-family: var(--font-mono); font-variant-numeric: tabular-nums; white-space: nowrap; }
table.sched th { position: sticky; top: 0; background: #fafbfb; color: var(--muted); font-weight: 500; text-align: right; border-bottom: 1px solid var(--line); font-size: 11.5px; letter-spacing: .04em; text-transform: uppercase; }
table.sched th:first-child, table.sched td:first-child { text-align: left; }
table.sched tbody tr:nth-child(even) { background: #fafcfb; }

/* ---------- content blocks (SEO copy) ---------- */
.prose { max-width: 70ch; margin: 0 auto; padding: 8px 0 0; }
.prose h2 { font-size: 26px; margin: 40px 0 14px; }
.prose h3 { font-size: 19px; margin: 28px 0 10px; }
.prose p { color: var(--ink-soft); margin: 0 0 14px; }
.prose ul { color: var(--ink-soft); padding-left: 20px; margin: 0 0 16px; }
.prose li { margin-bottom: 7px; }
.faq { border-top: 1px solid var(--line); margin-top: 8px; }
.faq details { border-bottom: 1px solid var(--line); padding: 4px 0; }
.faq summary { cursor: pointer; padding: 16px 0; font-weight: 600; font-family: var(--font-display); font-size: 17px; list-style: none; display: flex; justify-content: space-between; gap: 16px; }
.faq summary::-webkit-details-marker { display: none; }
.faq summary::after { content: "＋"; color: var(--green); font-family: var(--font-mono); }
.faq details[open] summary::after { content: "－"; }
.faq details p { color: var(--ink-soft); padding: 0 0 16px; margin: 0; max-width: 68ch; }

/* related tools strip */
.related { display: grid; grid-template-columns: repeat(3,1fr); gap: 14px; margin-top: 16px; }
@media (max-width: 700px){ .related { grid-template-columns: 1fr; } }
.related a { background: var(--paper); border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 16px; display: block; }
.related a:hover { border-color: #cdd5d1; text-decoration: none; }
.related a .t { font-weight: 600; color: var(--ink); font-size: 15px; }
.related a .d { font-size: 13px; color: var(--muted); margin-top: 4px; }

/* ---------- footer ---------- */
.site-footer { background: var(--green-ink); color: #c9d8d0; margin-top: 64px; padding: 56px 0 32px; }
.footer-grid { display: grid; grid-template-columns: 1.4fr 1fr 1fr; gap: 36px; }
@media (max-width: 700px){ .footer-grid { grid-template-columns: 1fr; gap: 28px; } }
.site-footer .brand { color: #fff; }
.site-footer .brand .glyph { background: #fff; }
.site-footer .brand .glyph::before { background: var(--green-ink); }
.site-footer .brand .glyph::after { background: var(--gold); }
.site-footer p.tag { color: #8ca99b; font-size: 13.5px; margin: 14px 0 0; max-width: 36ch; }
.site-footer h4 { color: #fff; font-size: 13px; font-family: var(--font-mono); letter-spacing: .08em; text-transform: uppercase; font-weight: 500; margin-bottom: 14px; }
.site-footer ul { list-style: none; padding: 0; margin: 0; }
.site-footer li { margin-bottom: 9px; }
.site-footer a { color: #c9d8d0; font-size: 14px; }
.site-footer a:hover { color: #fff; }
.footer-bottom { border-top: 1px solid rgba(255,255,255,.12); margin-top: 40px; padding-top: 22px; display: flex; justify-content: space-between; gap: 16px; flex-wrap: wrap; font-size: 12.5px; color: #7e9a8c; }
.disclaimer { font-size: 12px; color: #7e9a8c; max-width: 80ch; line-height: 1.6; }

/* utilities */
.center { text-align: center; }
.muted { color: var(--muted); }
:focus-visible { outline: 2px solid var(--green); outline-offset: 2px; border-radius: 4px; }

/* ---------- debt rows ---------- */
.debt-row { display: grid; grid-template-columns: 1.4fr 1fr 0.8fr 1fr auto; gap: 8px; align-items: end; margin-bottom: 12px; }
.debt-row .mini label { font-size: 11.5px; color: var(--muted); display: block; margin-bottom: 4px; font-weight: 500; }
.debt-row .mini input { width: 100%; border: 1px solid var(--line); border-radius: 8px; padding: 9px 10px; font-family: var(--font-mono); font-size: 13.5px; color: var(--ink); outline: none; }
.debt-row .mini input:focus { border-color: var(--green); box-shadow: 0 0 0 3px var(--green-tint); }
.debt-row .mini input[type=text] { font-family: var(--font-body); }
.debt-row .rm { border: 1px solid var(--line); background: #fff; border-radius: 8px; width: 38px; height: 38px; cursor: pointer; color: var(--muted); font-size: 18px; line-height: 1; display:flex;align-items:center;justify-content:center; }
.debt-row .rm:hover { color: var(--clay); border-color: var(--clay); }
@media (max-width: 560px){ .debt-row { grid-template-columns: 1fr 1fr; } .debt-row .rm{ width:100%; height:34px; } }
.order-list { counter-reset: d; list-style: none; padding: 0; margin: 12px 0 0; }
.order-list li { display:flex; justify-content:space-between; align-items:center; padding: 11px 0; border-bottom: 1px solid var(--line-soft); font-size: 14px; }
.order-list li::before { counter-increment: d; content: counter(d); font-family: var(--font-mono); font-size: 12px; color:#fff; background: var(--green); width: 22px; height: 22px; border-radius: 50%; display:inline-flex;align-items:center;justify-content:center; margin-right: 10px; flex:none; }
.order-list .nm { flex: 1; color: var(--ink); }
.order-list .mo { font-family: var(--font-mono); color: var(--muted); font-size: 13px; }
