/* ===== CalculateMoney design system ===== */
:root {
  --page: #f9f9f7;
  --surface: #fcfcfb;
  --ink: #0b0b0b;
  --ink-2: #52514e;
  --ink-muted: #898781;
  --hairline: #e1e0d9;
  --border: rgba(11, 11, 11, 0.10);
  --accent: #2a78d6;
  --accent-strong: #1c5cab;
  --accent-wash: #cde2fb;
  --good: #006300;
  --bad: #d03b3b;
  /* chart roles (read by app.js at render time) */
  --s1: #2a78d6;
  --s2: #1baf7a;
  --s3: #eda100;
  --chart-grid: #e1e0d9;
  --chart-ink: #898781;
  --chart-surface: #fcfcfb;
}
[data-theme="dark"] {
  --page: #0d0d0d;
  --surface: #1a1a19;
  --ink: #ffffff;
  --ink-2: #c3c2b7;
  --ink-muted: #898781;
  --hairline: #2c2c2a;
  --border: rgba(255, 255, 255, 0.10);
  --accent: #3987e5;
  --accent-strong: #6da7ec;
  --accent-wash: #104281;
  --good: #0ca30c;
  --bad: #e66767;
  --s1: #3987e5;
  --s2: #199e70;
  --s3: #c98500;
  --chart-grid: #2c2c2a;
  --chart-ink: #898781;
  --chart-surface: #1a1a19;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  background: var(--page);
  color: var(--ink);
  font-family: system-ui, -apple-system, "Segoe UI", sans-serif;
  line-height: 1.6;
  font-size: 16px;
}
.wrap { max-width: 1080px; margin: 0 auto; padding: 0 1rem; }
.page-pad { padding-top: 1.5rem; padding-bottom: 3rem; }
a { color: var(--accent); }
h1 { font-size: 1.9rem; line-height: 1.25; margin: 0.5rem 0 0.4rem; letter-spacing: -0.01em; }
h2 { font-size: 1.35rem; margin: 2.2rem 0 0.8rem; letter-spacing: -0.01em; }
h3 { font-size: 1.05rem; margin: 1.4rem 0 0.5rem; }
.skip-link { position: absolute; left: -9999px; }
.skip-link:focus { left: 8px; top: 8px; background: var(--surface); padding: 8px 12px; z-index: 100; }

/* ===== Header ===== */
.site-header {
  position: sticky; top: 0; z-index: 50;
  background: var(--surface);
  border-bottom: 1px solid var(--hairline);
}
.header-inner { display: flex; align-items: center; gap: 1.2rem; height: 56px; }
.brand { display: flex; align-items: center; gap: 0.5rem; text-decoration: none; color: var(--ink); font-size: 1.05rem; }
.brand-mark {
  width: 28px; height: 28px; border-radius: 7px;
  background: var(--accent); color: #fff;
  display: inline-flex; align-items: center; justify-content: center;
  font-weight: 700;
}
.brand-name b { color: var(--accent); }
.site-nav { display: flex; gap: 1rem; margin-left: auto; }
.site-nav a { color: var(--ink-2); text-decoration: none; font-size: 0.92rem; font-weight: 500; }
.site-nav a:hover { color: var(--accent); }
.theme-toggle { background: none; border: 1px solid var(--hairline); border-radius: 8px; padding: 4px 9px; cursor: pointer; font-size: 0.95rem; }
@media (max-width: 640px) { .site-nav { display: none; } .theme-toggle { margin-left: auto; } }

/* ===== Breadcrumbs / lede ===== */
.crumbs { font-size: 0.85rem; color: var(--ink-muted); }
.crumbs a { color: var(--ink-muted); }
.lede { color: var(--ink-2); font-size: 1.05rem; margin: 0 0 0.3rem; max-width: 62ch; }
.updated { color: var(--ink-muted); font-size: 0.82rem; margin: 0 0 1.2rem; }

/* ===== Calculator card ===== */
.calc {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 1.4rem;
  display: grid;
  grid-template-columns: minmax(280px, 5fr) minmax(300px, 6fr);
  gap: 1.8rem;
  margin: 1rem 0 1.5rem;
}
@media (max-width: 820px) { .calc { grid-template-columns: 1fr; } }

.field { margin-bottom: 1.1rem; }
.field-head { display: flex; align-items: center; justify-content: space-between; gap: 0.8rem; margin-bottom: 0.35rem; }
.field-head label { font-weight: 600; font-size: 0.92rem; }
.num-wrap { display: inline-flex; align-items: center; gap: 4px; background: var(--page); border: 1px solid var(--hairline); border-radius: 8px; padding: 3px 10px; }
.num-wrap:focus-within { border-color: var(--accent); }
.num-wrap .unit { color: var(--ink-muted); font-size: 0.9rem; }
.num-wrap input {
  width: 110px; border: none; background: transparent; color: var(--ink);
  font: inherit; font-weight: 600; text-align: right; outline: none;
  font-variant-numeric: tabular-nums;
}
.num-wrap input::-webkit-outer-spin-button, .num-wrap input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.num-wrap input[type="number"] { -moz-appearance: textfield; appearance: textfield; }

input[type="range"] {
  width: 100%; height: 5px; border-radius: 4px; margin: 4px 0 0;
  -webkit-appearance: none; appearance: none;
  background: linear-gradient(to right, var(--accent) var(--fill, 50%), var(--hairline) var(--fill, 50%));
  outline-offset: 4px;
}
input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none; width: 18px; height: 18px; border-radius: 50%;
  background: var(--accent); border: 2.5px solid var(--surface);
  box-shadow: 0 1px 4px rgba(0,0,0,0.25); cursor: pointer;
}
input[type="range"]::-moz-range-thumb {
  width: 14px; height: 14px; border-radius: 50%;
  background: var(--accent); border: 2.5px solid var(--surface);
  box-shadow: 0 1px 4px rgba(0,0,0,0.25); cursor: pointer;
}
.range-limits { display: flex; justify-content: space-between; color: var(--ink-muted); font-size: 0.72rem; margin-top: 2px; }

.seg { display: flex; gap: 6px; flex-wrap: wrap; margin: 0.2rem 0 1rem; }
.seg button {
  border: 1px solid var(--hairline); background: var(--page); color: var(--ink-2);
  border-radius: 8px; padding: 5px 12px; font: inherit; font-size: 0.85rem; font-weight: 600; cursor: pointer;
}
.seg button.on { background: var(--accent); border-color: var(--accent); color: #fff; }

select.cm-select, .field select {
  border: 1px solid var(--hairline); background: var(--page); color: var(--ink);
  border-radius: 8px; padding: 6px 10px; font: inherit; font-size: 0.9rem;
}

/* ===== Results ===== */
.results { display: flex; flex-direction: column; gap: 0.9rem; min-width: 0; }
.stat-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); gap: 0.7rem; }
.stat { background: var(--page); border: 1px solid var(--hairline); border-radius: 10px; padding: 0.7rem 0.9rem; }
.stat .k { color: var(--ink-2); font-size: 0.78rem; font-weight: 600; letter-spacing: 0.01em; }
.stat .v { font-size: 1.15rem; font-weight: 700; margin-top: 2px; }
.stat.hero { grid-column: 1 / -1; border-color: var(--accent); background: var(--surface); }
.stat.hero .v { font-size: 1.9rem; color: var(--accent-strong); letter-spacing: -0.01em; }
.stat .sub { color: var(--ink-muted); font-size: 0.78rem; margin-top: 2px; }
.v.pos { color: var(--good); }
.v.neg { color: var(--bad); }

.chart-box { position: relative; height: 240px; }
.chart-note { color: var(--ink-muted); font-size: 0.78rem; margin: 2px 0 0; }

/* ===== Schedule table ===== */
details.sched { border: 1px solid var(--hairline); border-radius: 10px; background: var(--surface); margin: 0 0 1.5rem; }
details.sched > summary { cursor: pointer; padding: 0.8rem 1rem; font-weight: 600; font-size: 0.95rem; }
.sched-scroll { overflow-x: auto; max-height: 420px; overflow-y: auto; }
table.cm-table { width: 100%; border-collapse: collapse; font-size: 0.88rem; }
table.cm-table th {
  text-align: right; padding: 0.6rem 0.9rem; color: var(--ink-2);
  border-bottom: 1px solid var(--hairline); position: sticky; top: 0; background: var(--surface);
  font-size: 0.8rem;
}
table.cm-table td { text-align: right; padding: 0.5rem 0.9rem; border-bottom: 1px solid var(--hairline); font-variant-numeric: tabular-nums; }
table.cm-table th:first-child, table.cm-table td:first-child { text-align: left; }

/* ===== Article content ===== */
.prose, .article { max-width: 72ch; }
.article p, .prose p { color: var(--ink-2); }
.article ul, .prose ul, .article ol, .prose ol { color: var(--ink-2); padding-left: 1.3rem; }
.article li, .prose li { margin: 0.25rem 0; }
.formula {
  background: var(--surface); border: 1px solid var(--hairline); border-left: 3px solid var(--accent);
  border-radius: 8px; padding: 0.8rem 1rem; font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 0.92rem; overflow-x: auto; color: var(--ink);
}
.note {
  background: var(--surface); border: 1px solid var(--hairline); border-radius: 8px;
  padding: 0.7rem 1rem; font-size: 0.9rem; color: var(--ink-2);
}
.article table, .prose table { border-collapse: collapse; font-size: 0.9rem; width: 100%; max-width: 100%; }
.article th, .prose th { text-align: left; padding: 0.5rem 0.8rem; border-bottom: 2px solid var(--hairline); }
.article td, .prose td { padding: 0.45rem 0.8rem; border-bottom: 1px solid var(--hairline); color: var(--ink-2); }
.table-scroll { overflow-x: auto; }

/* ===== FAQ ===== */
.faq-section { max-width: 72ch; }
details.faq { border-bottom: 1px solid var(--hairline); padding: 0.35rem 0; }
details.faq summary { cursor: pointer; font-weight: 600; padding: 0.45rem 0; font-size: 0.97rem; }
details.faq p { color: var(--ink-2); margin: 0.3rem 0 0.7rem; }

/* ===== Cards grid (home + related) ===== */
.card-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 0.9rem; margin: 1rem 0; }
.calc-card {
  display: flex; flex-direction: column; gap: 0.3rem;
  background: var(--surface); border: 1px solid var(--border); border-radius: 12px;
  padding: 1rem 1.1rem; text-decoration: none; color: var(--ink);
  transition: border-color 0.15s, transform 0.15s;
}
.calc-card:hover { border-color: var(--accent); transform: translateY(-2px); }
.calc-card-icon { font-size: 1.4rem; }
.calc-card-name { font-weight: 700; }
.calc-card-short { color: var(--ink-2); font-size: 0.85rem; line-height: 1.45; }

.cat-label { color: var(--ink-muted); font-size: 0.8rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.06em; margin: 1.8rem 0 0.2rem; }

/* ===== Hero (home) ===== */
.hero { padding: 2.5rem 0 1rem; }
.hero h1 { font-size: 2.3rem; max-width: 24ch; }
.hero p { color: var(--ink-2); font-size: 1.1rem; max-width: 56ch; }
@media (max-width: 640px) { .hero h1 { font-size: 1.7rem; } }

/* ===== Buttons / misc ===== */
.btn-ghost {
  border: 1px solid var(--hairline); background: var(--surface); color: var(--ink-2);
  border-radius: 8px; padding: 6px 14px; font: inherit; font-size: 0.85rem; font-weight: 600; cursor: pointer;
}
.btn-ghost:hover { border-color: var(--accent); color: var(--accent); }
.result-actions { display: flex; gap: 0.6rem; align-items: center; }

/* ===== Footer ===== */
.site-footer { border-top: 1px solid var(--hairline); background: var(--surface); margin-top: 2rem; padding: 2rem 0 1.5rem; }
.footer-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 1.5rem; }
.footer-grid h3 { margin: 0 0 0.5rem; font-size: 0.85rem; text-transform: uppercase; letter-spacing: 0.05em; color: var(--ink-muted); }
.footer-grid a { display: block; color: var(--ink-2); text-decoration: none; font-size: 0.9rem; padding: 2px 0; }
.footer-grid a:hover { color: var(--accent); }
.footer-note { color: var(--ink-muted); font-size: 0.8rem; max-width: 90ch; margin-top: 1.5rem; }
.footer-copy { color: var(--ink-muted); font-size: 0.8rem; }

/* ===== Related ===== */
.related-section { margin-top: 1rem; }
