/* KinLedger Tools - one shared stylesheet. No web fonts, no external files. */
:root {
  --bg: #fbfaf7;
  --surface: #ffffff;
  --text: #1d2a33;
  --muted: #55646f;
  --line: #d9d5cb;
  --accent: #1f5f66;
  --accent-text: #ffffff;
  --accent-soft: #e4f0f0;
  --warn-bg: #fdf0d5;
  --warn-text: #5c3d00;
  --bad-bg: #fbe3e0;
  --bad-text: #7a1f14;
  --ok-bg: #e2f1e4;
  --ok-text: #1e4d27;
  --focus: #0b57d0;
  --radius: 8px;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #15191c;
    --surface: #1d2327;
    --text: #e8e6e0;
    --muted: #a9b3ba;
    --line: #3a444a;
    --accent: #7cc4c9;
    --accent-text: #0f2326;
    --accent-soft: #223539;
    --warn-bg: #3b3012;
    --warn-text: #f1dca0;
    --bad-bg: #432421;
    --bad-text: #f6c3bc;
    --ok-bg: #1f3a25;
    --ok-text: #bfe3c5;
    --focus: #8ab4f8;
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 17px/1.6 system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}
.wrap { max-width: 780px; margin: 0 auto; padding: 0 16px; }
a { color: var(--accent); text-underline-offset: 2px; }
a:hover { text-decoration-thickness: 2px; }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; border-radius: 3px; }

.skip { position: absolute; left: -999px; top: 0; background: var(--surface); padding: 8px 12px; z-index: 10; }
.skip:focus { left: 8px; top: 8px; }

/* header and footer */
.site-header { border-bottom: 1px solid var(--line); background: var(--surface); }
.site-header .wrap { display: flex; flex-wrap: wrap; gap: 8px 24px; align-items: baseline; justify-content: space-between; padding-top: 14px; padding-bottom: 14px; }
.brand { font-weight: 700; font-size: 1.15rem; color: var(--text); text-decoration: none; }
.brand span { color: var(--accent); }
.site-header nav { display: flex; flex-wrap: wrap; gap: 4px 18px; font-size: 0.95rem; }
.site-footer { border-top: 1px solid var(--line); margin-top: 56px; padding: 24px 0 40px; color: var(--muted); font-size: 0.9rem; }
.site-footer nav { display: flex; flex-wrap: wrap; gap: 4px 18px; margin-bottom: 10px; }
.site-footer p { margin: 6px 0; }

/* text */
h1 { font-size: 1.85rem; line-height: 1.25; margin: 32px 0 12px; }
h2 { font-size: 1.3rem; line-height: 1.3; margin: 40px 0 10px; }
h3 { font-size: 1.05rem; margin: 22px 0 6px; }
p, ul, ol { margin: 0 0 14px; }
li { margin-bottom: 4px; }
.lead { font-size: 1.08rem; color: var(--muted); margin-bottom: 20px; }
.small { font-size: 0.9rem; color: var(--muted); }
.updated { font-size: 0.9rem; color: var(--muted); }
.sr-only { position: absolute !important; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* cards on the home page */
.tool-list { list-style: none; padding: 0; margin: 20px 0; display: grid; gap: 14px; }
.tool-list li { margin: 0; }
.tool-card { display: block; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px 18px; text-decoration: none; color: var(--text); }
.tool-card:hover { border-color: var(--accent); }
.tool-card strong { display: block; font-size: 1.1rem; color: var(--accent); margin-bottom: 4px; }

/* calculator */
.calc { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; margin: 20px 0; }
.calc h2 { margin-top: 0; }
.calc h3:first-child { margin-top: 0; }
.field { margin: 0 0 14px; }
.field label, .cell label { display: block; font-weight: 600; font-size: 0.95rem; margin-bottom: 4px; }
.field .hint, .cell .hint { font-weight: 400; color: var(--muted); }
input[type="date"], input[type="text"], input[type="number"], select {
  font: inherit; color: var(--text); background: var(--bg);
  border: 1px solid var(--muted); border-radius: 6px; padding: 8px 10px; min-height: 44px; width: 100%; max-width: 100%;
}
input[type="checkbox"] { width: 22px; height: 22px; accent-color: var(--accent); }
.fmt { display: block; font-size: 0.85rem; color: var(--muted); min-height: 1.3em; }
.fmt.bad { color: var(--bad-text); background: var(--bad-bg); border-radius: 4px; padding: 0 6px; }
.two { display: grid; gap: 0 16px; grid-template-columns: 1fr; }
@media (min-width: 640px) { .two { grid-template-columns: 1fr 1fr; } }

.rows { margin: 8px 0; }
.row { border: 1px solid var(--line); border-radius: var(--radius); padding: 10px 12px 6px; margin-bottom: 10px; display: grid; gap: 0 12px; grid-template-columns: 1fr; position: relative; }
.row .cell { margin-bottom: 8px; }
.row .actions { margin-bottom: 8px; }
.row-msg { grid-column: 1 / -1; font-size: 0.88rem; color: var(--warn-text); background: var(--warn-bg); border-radius: 6px; padding: 4px 8px; margin: 0 0 8px; }
.row-msg:empty { display: none; }
.row-msg.problem { color: var(--bad-text); background: var(--bad-bg); }
@media (min-width: 700px) {
  .row.cols-3 { grid-template-columns: 1fr 1fr 1.3fr auto; align-items: start; }
  .row.cols-2 { grid-template-columns: 1fr 1fr auto; align-items: start; }
  .row.cols-spt { grid-template-columns: 1fr 1fr 1.1fr auto; align-items: start; }
  .rows .row:not(:first-child) .cell:not(.check-cell) label { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
  .rows .row:not(:first-child) .fmt { min-height: 1.3em; }
  .row .actions { padding-top: 26px; }
  .rows .row:first-child .check-cell { padding-top: 26px; }
  .rows .row:not(:first-child) .actions { padding-top: 0; }
}
.check-cell { display: flex; align-items: center; gap: 8px; min-height: 44px; }
.check-cell label { margin: 0; font-weight: 400; }

button, .btn {
  font: inherit; font-weight: 600; cursor: pointer; min-height: 44px; padding: 8px 16px;
  border-radius: 6px; border: 1px solid var(--accent); background: var(--surface); color: var(--accent); text-decoration: none; display: inline-block;
}
button:hover, .btn:hover { background: var(--accent-soft); }
button.primary, .btn.primary { background: var(--accent); color: var(--accent-text); }
button.primary:hover, .btn.primary:hover { filter: brightness(1.1); background: var(--accent); }
button[disabled] { opacity: 0.5; cursor: not-allowed; }
button.link { border: none; background: none; min-height: 44px; padding: 8px 4px; text-decoration: underline; }
.toolbar { display: flex; flex-wrap: wrap; gap: 10px; margin: 12px 0 0; }

/* results */
.results { margin-top: 18px; border-top: 1px solid var(--line); padding-top: 14px; }
.results h3 { margin-top: 0; }
.big { display: grid; gap: 10px; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); margin: 10px 0 14px; }
.big div { background: var(--accent-soft); border-radius: var(--radius); padding: 10px 12px; }
.big .num { display: block; font-size: 1.7rem; font-weight: 700; line-height: 1.2; }
.big .lbl { font-size: 0.85rem; color: var(--muted); }
dl.kv { margin: 0 0 12px; display: grid; grid-template-columns: 1fr; gap: 0; }
dl.kv dt { font-weight: 600; margin-top: 8px; }
dl.kv dd { margin: 0; }
@media (min-width: 640px) {
  dl.kv { grid-template-columns: minmax(220px, 40%) 1fr; column-gap: 16px; }
  dl.kv dt { margin-top: 0; padding: 6px 0; border-bottom: 1px solid var(--line); }
  dl.kv dd { padding: 6px 0; border-bottom: 1px solid var(--line); }
}
.status { border-radius: var(--radius); padding: 10px 14px; margin: 10px 0; font-weight: 600; }
.status.ok { background: var(--ok-bg); color: var(--ok-text); }
.status.warn { background: var(--warn-bg); color: var(--warn-text); }
.status.bad { background: var(--bad-bg); color: var(--bad-text); }
.status.info { background: var(--accent-soft); color: var(--text); }
.notes { font-size: 0.92rem; color: var(--muted); }
.notes li { margin-bottom: 4px; }

table { border-collapse: collapse; width: 100%; margin: 10px 0 16px; font-size: 0.95rem; }
th, td { border: 1px solid var(--line); padding: 7px 9px; text-align: left; vertical-align: top; }
th { background: var(--accent-soft); }
.table-scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; }

/* worked example, FAQ, how it works, call to action */
.example, .how { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 18px; margin: 16px 0; }
.example h3, .how h3 { margin-top: 0; }
details.faq { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 0 16px; margin-bottom: 10px; }
details.faq summary { cursor: pointer; font-weight: 600; padding: 12px 0; min-height: 44px; }
details.faq[open] summary { border-bottom: 1px solid var(--line); margin-bottom: 10px; }
.cta { background: var(--accent-soft); border: 1px solid var(--accent); border-radius: var(--radius); padding: 18px 20px; margin: 40px 0 0; }
.cta p { margin-bottom: 12px; }
.cta p:last-child { margin-bottom: 0; }
.notice { border-left: 4px solid var(--accent); background: var(--surface); padding: 10px 14px; margin: 16px 0; border-radius: 0 var(--radius) var(--radius) 0; }
.crumbs { font-size: 0.9rem; margin-top: 18px; color: var(--muted); }

@media print {
  .site-header nav, .site-footer nav, .toolbar, .cta, .actions, .skip { display: none; }
  body { background: #fff; color: #000; }
}
@media (prefers-reduced-motion: reduce) { * { scroll-behavior: auto !important; transition: none !important; } }
