/* AllBusiness — design system */
:root {
  --bg: #fdfcf8;
  --bg-elev: #ffffff;
  --bg-soft: #f4f1ea;
  --fg: #1a1a1a;
  --fg-muted: #555;
  --fg-faint: #888;
  --rule: #e3ddd0;
  --rule-strong: #c9c0ad;
  --accent: #8a3a14;
  --accent-soft: #f3e7df;
  --link: #8a3a14;
  --link-hover: #5a2509;
  --pos: #1d6b3a;
  --neg: #9a1d1d;
  --code-bg: #f1ede2;
  --focus: #1f6feb;
  --serif: Charter, "Bitstream Charter", "Sitka Text", Cambria, Georgia, serif;
  --sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
  --maxw-prose: 680px;
  --maxw-tool: 960px;
  --maxw-wide: 1100px;
  --radius: 4px;
  --shadow: 0 1px 2px rgba(0,0,0,.04), 0 4px 12px rgba(0,0,0,.04);
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #14130f;
    --bg-elev: #1c1b16;
    --bg-soft: #23211b;
    --fg: #ebe7dc;
    --fg-muted: #b6b0a1;
    --fg-faint: #8a8470;
    --rule: #34322a;
    --rule-strong: #4d493d;
    --accent: #e3a07a;
    --accent-soft: #2d211a;
    --link: #e3a07a;
    --link-hover: #f2c5a8;
    --pos: #6cc28d;
    --neg: #e07b7b;
    --code-bg: #23211b;
    --focus: #58a6ff;
  }
}
[data-theme="dark"] {
  --bg: #14130f;
  --bg-elev: #1c1b16;
  --bg-soft: #23211b;
  --fg: #ebe7dc;
  --fg-muted: #b6b0a1;
  --fg-faint: #8a8470;
  --rule: #34322a;
  --rule-strong: #4d493d;
  --accent: #e3a07a;
  --accent-soft: #2d211a;
  --link: #e3a07a;
  --link-hover: #f2c5a8;
  --pos: #6cc28d;
  --neg: #e07b7b;
  --code-bg: #23211b;
  --focus: #58a6ff;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--fg);
  font-family: var(--serif);
  font-size: 18px;
  line-height: 1.65;
  font-feature-settings: "kern", "liga", "onum";
  text-rendering: optimizeLegibility;
}
img, svg { max-width: 100%; height: auto; }
a { color: var(--link); text-decoration: underline; text-underline-offset: 2px; text-decoration-thickness: 1px; }
a:hover { color: var(--link-hover); text-decoration-thickness: 2px; }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; border-radius: 2px; }

/* Skip link */
.skip { position: absolute; left: -9999px; top: 0; background: var(--fg); color: var(--bg); padding: .5rem 1rem; z-index: 100; }
.skip:focus { left: 1rem; top: 1rem; }

/* Header */
.site-header {
  position: sticky; top: 0; z-index: 50;
  background: var(--bg-elev);
  border-bottom: 1px solid var(--rule);
  font-family: var(--sans);
  font-size: 15px;
}
.nav-wrap {
  max-width: var(--maxw-wide);
  margin: 0 auto;
  padding: .75rem 1.25rem;
  display: flex;
  align-items: center;
  gap: 1.25rem;
}
.brand {
  font-weight: 700;
  font-family: var(--serif);
  font-size: 19px;
  letter-spacing: -.01em;
  color: var(--fg);
  text-decoration: none;
  white-space: nowrap;
}
.brand:hover { color: var(--accent); }
.brand .dot { color: var(--accent); }
.nav-links {
  display: flex; gap: 1rem; align-items: center;
  list-style: none; padding: 0; margin: 0;
}
.nav-links a {
  color: var(--fg-muted);
  text-decoration: none;
  padding: .25rem .25rem;
}
.nav-links a:hover, .nav-links a[aria-current="page"] { color: var(--fg); }
.nav-spacer { flex: 1; }
.search-trigger {
  background: var(--bg-soft);
  border: 1px solid var(--rule);
  color: var(--fg-muted);
  padding: .35rem .7rem;
  border-radius: var(--radius);
  font-family: var(--sans);
  font-size: 14px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: .5rem;
  min-width: 180px;
}
.search-trigger:hover { border-color: var(--rule-strong); color: var(--fg); }
.search-trigger kbd {
  background: var(--bg-elev);
  border: 1px solid var(--rule);
  border-radius: 3px;
  padding: 0 .35rem;
  font-size: 12px;
  font-family: var(--mono);
  margin-left: auto;
}
.theme-toggle {
  background: transparent;
  border: 1px solid var(--rule);
  color: var(--fg-muted);
  width: 34px; height: 34px;
  border-radius: var(--radius);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.theme-toggle:hover { border-color: var(--rule-strong); color: var(--fg); }
.theme-toggle svg { width: 16px; height: 16px; }

@media (max-width: 720px) {
  .nav-links { display: none; }
  .search-trigger { min-width: 0; }
  .search-trigger .hint { display: none; }
}

/* Main layout */
main { display: block; }
.container {
  max-width: var(--maxw-prose);
  margin: 0 auto;
  padding: 2.5rem 1.25rem 4rem;
}
.container.tool { max-width: var(--maxw-tool); }
.container.wide { max-width: var(--maxw-wide); }

/* Breadcrumbs */
.crumbs {
  font-family: var(--sans);
  font-size: 13px;
  color: var(--fg-faint);
  margin-bottom: 1.25rem;
  list-style: none; padding: 0; display: flex; flex-wrap: wrap; gap: .35rem;
}
.crumbs li:not(:last-child)::after { content: "›"; padding-left: .35rem; color: var(--fg-faint); }
.crumbs a { color: var(--fg-muted); text-decoration: none; }
.crumbs a:hover { color: var(--accent); text-decoration: underline; }

/* Typography */
h1, h2, h3, h4 {
  font-family: var(--serif);
  font-weight: 700;
  letter-spacing: -.015em;
  line-height: 1.25;
  color: var(--fg);
}
h1 { font-size: 2.1rem; margin: 0 0 .5rem; }
h2 { font-size: 1.5rem; margin: 2.4rem 0 .75rem; padding-top: .25rem; }
h3 { font-size: 1.2rem; margin: 1.8rem 0 .5rem; }
h4 { font-size: 1.02rem; margin: 1.4rem 0 .35rem; text-transform: uppercase; letter-spacing: .04em; color: var(--fg-muted); }
.lede { font-size: 1.15rem; color: var(--fg-muted); margin: 0 0 1.5rem; }
p { margin: 0 0 1rem; }
ul, ol { padding-left: 1.4rem; margin: 0 0 1rem; }
li { margin-bottom: .35rem; }
strong { color: var(--fg); font-weight: 700; }
hr { border: 0; border-top: 1px solid var(--rule); margin: 2rem 0; }
blockquote {
  margin: 1.25rem 0;
  padding: .25rem 0 .25rem 1rem;
  border-left: 3px solid var(--rule-strong);
  color: var(--fg-muted);
  font-style: italic;
}
code, kbd, samp {
  font-family: var(--mono);
  font-size: .92em;
  background: var(--code-bg);
  padding: .1em .35em;
  border-radius: 3px;
}
pre {
  background: var(--code-bg);
  padding: 1rem;
  border-radius: var(--radius);
  overflow-x: auto;
  font-size: .92rem;
  line-height: 1.55;
}
pre code { background: transparent; padding: 0; }

table {
  width: 100%;
  border-collapse: collapse;
  margin: 1.25rem 0;
  font-size: .95rem;
  font-family: var(--sans);
}
th, td {
  padding: .55rem .75rem;
  text-align: left;
  border-bottom: 1px solid var(--rule);
}
th { font-weight: 600; color: var(--fg); background: var(--bg-soft); }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; font-family: var(--mono); }

/* Callouts */
.callout {
  background: var(--bg-soft);
  border: 1px solid var(--rule);
  border-left: 3px solid var(--accent);
  padding: 1rem 1.1rem;
  border-radius: var(--radius);
  margin: 1.25rem 0;
  font-family: var(--sans);
  font-size: .95rem;
}
.callout h4 { margin: 0 0 .35rem; text-transform: none; letter-spacing: 0; color: var(--accent); font-family: var(--sans); font-size: .85rem; font-weight: 700; }
.callout p:last-child { margin-bottom: 0; }

.formula {
  background: var(--code-bg);
  border: 1px solid var(--rule);
  border-radius: var(--radius);
  padding: .9rem 1.1rem;
  margin: 1rem 0;
  font-family: var(--mono);
  font-size: .95rem;
  overflow-x: auto;
}
.formula em { color: var(--accent); font-style: normal; font-weight: 600; }

/* Cards (index pages) */
.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 1rem;
  margin: 1.5rem 0;
  padding: 0;
  list-style: none;
}
.card {
  background: var(--bg-elev);
  border: 1px solid var(--rule);
  border-radius: var(--radius);
  padding: 1rem 1.1rem;
  transition: border-color .15s, transform .15s;
}
.card:hover { border-color: var(--rule-strong); }
.card a { text-decoration: none; color: var(--fg); font-family: var(--serif); font-weight: 700; font-size: 1.05rem; }
.card a:hover { color: var(--accent); }
.card p { font-family: var(--sans); font-size: .9rem; color: var(--fg-muted); margin: .35rem 0 0; line-height: 1.5; }

/* Section navigation on index pages */
.section-jump {
  display: flex; flex-wrap: wrap; gap: .35rem;
  font-family: var(--sans); font-size: 13px;
  margin-bottom: 1.5rem;
}
.section-jump a {
  padding: .25rem .65rem;
  background: var(--bg-soft);
  border: 1px solid var(--rule);
  border-radius: 999px;
  text-decoration: none;
  color: var(--fg-muted);
}
.section-jump a:hover { color: var(--fg); border-color: var(--rule-strong); }

/* Calculator UI */
.calc {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 1.5rem;
  background: var(--bg-elev);
  border: 1px solid var(--rule);
  border-radius: var(--radius);
  padding: 1.5rem;
  margin: 1.5rem 0;
  font-family: var(--sans);
}
.calc-inputs, .calc-results { min-width: 0; }
.calc-inputs h3, .calc-results h3 {
  font-size: .8rem; text-transform: uppercase; letter-spacing: .08em;
  color: var(--fg-muted); margin: 0 0 1rem; font-family: var(--sans);
  border-bottom: 1px solid var(--rule); padding-bottom: .5rem;
}
.field { margin-bottom: 1rem; }
.field label {
  display: block;
  font-size: 13px;
  color: var(--fg-muted);
  margin-bottom: .25rem;
  font-weight: 500;
}
.field .input-wrap {
  display: flex;
  align-items: stretch;
  border: 1px solid var(--rule);
  border-radius: var(--radius);
  background: var(--bg);
  overflow: hidden;
}
.field .input-wrap:focus-within { border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent-soft); }
.field input[type="number"], .field input[type="text"], .field select {
  flex: 1;
  border: 0;
  background: transparent;
  color: var(--fg);
  font: inherit;
  font-family: var(--mono);
  font-size: 15px;
  padding: .55rem .7rem;
  min-width: 0;
  width: 100%;
  -moz-appearance: textfield;
}
.field input[type="number"]::-webkit-outer-spin-button,
.field input[type="number"]::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.field .unit {
  background: var(--bg-soft);
  color: var(--fg-muted);
  padding: .55rem .7rem;
  font-size: 13px;
  font-family: var(--sans);
  border-left: 1px solid var(--rule);
  white-space: nowrap;
  display: flex; align-items: center;
}
.field select { padding-right: 1.5rem; cursor: pointer; appearance: none; background: var(--bg) url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 12'><path fill='%23888' d='M6 8L2 4h8z'/></svg>") no-repeat right .5rem center / 12px; }
.field .hint { font-size: 12px; color: var(--fg-faint); margin-top: .25rem; display: block; }

.btn-row { display: flex; flex-wrap: wrap; gap: .5rem; margin-top: 1rem; }
button.btn, a.btn {
  display: inline-flex; align-items: center; gap: .35rem;
  background: var(--bg-soft);
  border: 1px solid var(--rule);
  color: var(--fg);
  padding: .45rem .9rem;
  border-radius: var(--radius);
  font: inherit;
  font-family: var(--sans);
  font-size: 13px;
  cursor: pointer;
  text-decoration: none;
}
button.btn:hover, a.btn:hover { border-color: var(--rule-strong); background: var(--bg-elev); }
button.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
button.btn.primary:hover { background: var(--link-hover); border-color: var(--link-hover); color: #fff; }

.result {
  margin-bottom: 1rem;
  padding-bottom: 1rem;
  border-bottom: 1px dashed var(--rule);
}
.result:last-child { border-bottom: 0; padding-bottom: 0; }
.result .label {
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--fg-muted);
  display: block;
  margin-bottom: .15rem;
}
.result .value {
  font-family: var(--mono);
  font-size: 1.6rem;
  font-weight: 600;
  color: var(--fg);
  font-variant-numeric: tabular-nums;
  display: block;
}
.result .value.pos { color: var(--pos); }
.result .value.neg { color: var(--neg); }
.result .sub {
  font-size: 12px;
  color: var(--fg-faint);
  margin-top: .15rem;
  font-family: var(--sans);
  display: block;
}

@media (max-width: 720px) {
  .calc { grid-template-columns: 1fr; padding: 1.25rem; }
}

/* Schedule table for amortization etc. */
.schedule {
  max-height: 360px;
  overflow-y: auto;
  border: 1px solid var(--rule);
  border-radius: var(--radius);
  margin-top: 1rem;
}
.schedule table { margin: 0; font-size: 13px; }
.schedule th { position: sticky; top: 0; z-index: 1; }

/* Diagram container */
figure.diagram {
  margin: 1.5rem 0;
  padding: 1rem;
  background: var(--bg-elev);
  border: 1px solid var(--rule);
  border-radius: var(--radius);
  text-align: center;
}
figure.diagram svg { max-width: 100%; height: auto; }
figure.diagram figcaption {
  font-family: var(--sans);
  font-size: 13px;
  color: var(--fg-muted);
  margin-top: .75rem;
}
.diagram svg text { font-family: var(--sans); fill: var(--fg); }
.diagram svg .ax { stroke: var(--rule-strong); }
.diagram svg .box { fill: var(--bg-soft); stroke: var(--rule-strong); stroke-width: 1; }
.diagram svg .box-accent { fill: var(--accent-soft); stroke: var(--accent); stroke-width: 1; }
.diagram svg .lbl { font-size: 13px; }
.diagram svg .lbl-sm { font-size: 11px; fill: var(--fg-muted); }

/* Glossary terms */
.term {
  margin: 1.5rem 0 1.5rem;
  padding-top: 1.25rem;
  border-top: 1px solid var(--rule);
}
.term:first-of-type { border-top: 0; padding-top: 0; }
.term h3 {
  margin: 0 0 .25rem;
  font-size: 1.25rem;
  scroll-margin-top: 80px;
}
.term .meta {
  font-family: var(--sans);
  font-size: 12px;
  color: var(--fg-faint);
  margin-bottom: .5rem;
  text-transform: uppercase;
  letter-spacing: .05em;
}
.term .meta a { color: var(--fg-faint); text-decoration: none; margin-left: .5rem; }
.term .meta a:hover { color: var(--accent); }

.toc {
  background: var(--bg-soft);
  border: 1px solid var(--rule);
  border-radius: var(--radius);
  padding: 1rem 1.25rem;
  margin-bottom: 2rem;
  font-family: var(--sans);
  font-size: 14px;
}
.toc h2 { margin: 0 0 .5rem; font-size: .85rem; text-transform: uppercase; letter-spacing: .08em; color: var(--fg-muted); font-family: var(--sans); }
.toc ul { columns: 2; column-gap: 1.5rem; padding-left: 1.2rem; margin: 0; }
.toc li { margin-bottom: .2rem; break-inside: avoid; }
@media (max-width: 600px) { .toc ul { columns: 1; } }

/* Related */
.related {
  margin-top: 3rem;
  padding-top: 1.5rem;
  border-top: 1px solid var(--rule);
}
.related h2 { margin-top: 0; font-size: 1rem; text-transform: uppercase; letter-spacing: .06em; color: var(--fg-muted); font-family: var(--sans); }
.related ul { list-style: none; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: .5rem 1.25rem; font-family: var(--sans); font-size: 14px; }
.related li { margin: 0; }
.related a { text-decoration: none; }
.related a:hover { text-decoration: underline; }

/* Search dialog */
.search-dialog {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.45);
  z-index: 100;
  display: none;
  align-items: flex-start;
  justify-content: center;
  padding: 5vh 1rem 0;
}
.search-dialog.open { display: flex; }
.search-panel {
  background: var(--bg-elev);
  border: 1px solid var(--rule);
  border-radius: 6px;
  width: 100%;
  max-width: 580px;
  box-shadow: var(--shadow);
  overflow: hidden;
  font-family: var(--sans);
}
.search-panel input {
  width: 100%;
  border: 0;
  border-bottom: 1px solid var(--rule);
  background: transparent;
  color: var(--fg);
  font: inherit;
  font-size: 16px;
  padding: 1rem 1.25rem;
  outline: none;
}
.search-results { max-height: 60vh; overflow-y: auto; padding: .25rem 0; }
.search-results:empty::before {
  content: "Type to search calculators, frameworks, and terms.";
  color: var(--fg-faint);
  font-size: 14px;
  display: block;
  padding: 1rem 1.25rem;
}
.search-results a {
  display: block;
  padding: .65rem 1.25rem;
  text-decoration: none;
  color: var(--fg);
  border-bottom: 1px solid var(--rule);
}
.search-results a:last-child { border-bottom: 0; }
.search-results a:hover, .search-results a.active { background: var(--bg-soft); }
.search-results .res-title { font-weight: 600; font-size: 14px; }
.search-results .res-crumb { font-size: 11px; color: var(--fg-faint); text-transform: uppercase; letter-spacing: .05em; margin-bottom: .15rem; }
.search-results .res-desc { font-size: 13px; color: var(--fg-muted); margin-top: .15rem; line-height: 1.4; }
.search-empty { padding: 1rem 1.25rem; color: var(--fg-faint); font-size: 14px; }

/* Footer */
.site-footer {
  border-top: 1px solid var(--rule);
  padding: 2rem 1.25rem;
  font-family: var(--sans);
  font-size: 13px;
  color: var(--fg-muted);
  text-align: center;
}
.site-footer a { color: var(--fg-muted); }
.site-footer .links { display: flex; flex-wrap: wrap; gap: 1rem; justify-content: center; margin-bottom: .5rem; }

/* Hero on homepage */
.hero {
  padding: 3rem 0 2rem;
  border-bottom: 1px solid var(--rule);
  margin-bottom: 2rem;
}
.hero h1 { font-size: 2.6rem; margin-bottom: .5rem; }
.hero .lede { font-size: 1.25rem; max-width: 580px; }
.home-search {
  margin-top: 1.25rem;
  display: flex;
  gap: .5rem;
  max-width: 480px;
}
.home-search input {
  flex: 1;
  padding: .7rem 1rem;
  border: 1px solid var(--rule);
  border-radius: var(--radius);
  background: var(--bg-elev);
  color: var(--fg);
  font: inherit;
  font-family: var(--sans);
  font-size: 16px;
}
.home-search input:focus { border-color: var(--accent); outline: none; box-shadow: 0 0 0 2px var(--accent-soft); }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; animation-iteration-count: 1 !important; transition-duration: 0.01ms !important; scroll-behavior: auto !important; }
}

/* Print */
@media print {
  .site-header, .site-footer, .related, .btn-row, .search-dialog { display: none !important; }
  body { font-size: 12pt; color: #000; background: #fff; }
  a { color: #000; text-decoration: underline; }
}
