/*
  ToolkitHQ visual design — instrument-panel cleanup
  Direction: precise, quiet, confident. A well-made measuring device,
  not a SaaS landing page.

  Palette:
    Light: Paper #FFFFFF, Ink #14171C, Slate #6B7280, Hairline #E2E5EA,
           Signal #2951F2, Ledger #147A52 (positive deltas only).
    Dark:  Background #0E1014, Surface #161A20, Hairline #232830,
           Ink #E8EBF0, Slate #9BA3B0, Signal #5B7CFF, Ledger #4DAD7E.

  Typography — exactly three faces, no exceptions:
    Display = Archivo (headings, brand)
    Body    = Inter (paragraphs, labels, UI)
    Numbers = IBM Plex Mono (readouts, stats, code, versions)
    Never add a fourth face. No roman or decorative fallbacks allowed.

  Motion:
    One orchestrated moment: hero readout digits roll into place on load.
    Everything else is still — border/color hover shifts only.
*/

:root {
  /* paper & ink */
  --bg: #FFFFFF;
  --panel: #FFFFFF;
  --text: #14171C;
  --muted: #6B7280;
  --border: #E2E5EA;
  --border-strong: #C9CED6;

  /* signal */
  --accent: #2951F2;
  --accent-2: #1A3FD0;
  --accent-text: #FFFFFF;
  --accent-soft: rgba(41, 81, 242, 0.10);

  /* ledger — reserved for positive deltas/gains in calculator results */
  --ledger: #147A52;

  /* semantic colors */
  --green: var(--ledger);
  --amber: #B45309;
  --red: #B91C1C;
  --link: #2951F2;

  /* surfaces */
  --inset-bg: #F7F8FA;
  --inset-border: #E2E5EA;
  --result-bg: #F7F8FA;
  --result-border: #E2E5EA;
  --ad-bg: #F7F8FA;
  --ad-bg-2: #E2E5EA;
  --upsell-bg: #F7F8FA;
  --upsell-border: #E2E5EA;
  --upsell-closing: #C9CED6;
  --input-bg: #FFFFFF;

  /* plan badges */
  --card-plan-bg: #F7F8FA;
  --card-plan-color: #4B5563;
  --card-plan-freemium-bg: #F7F8FA;
  --card-plan-freemium-color: #2951F2;

  --tool-shadow: rgba(20, 23, 28, 0.04);
  --ip-tot-border: #14171C;
  --gap: 20px;
}

html.dark {
  --bg: #0E1014;
  --panel: #161A20;
  --text: #E8EBF0;
  --muted: #9BA3B0;
  --border: #232830;
  --border-strong: #2E343D;

  --accent: #5B7CFF;
  --accent-2: #7A96FF;
  --accent-text: #0E1014;
  --accent-soft: rgba(91, 124, 255, 0.18);

  --ledger: #4DAD7E;
  --green: var(--ledger);
  --amber: #F59E0B;
  --red: #F87171;
  --link: #5B7CFF;

  --inset-bg: #1A1F26;
  --inset-border: #232830;
  --result-bg: #1A1F26;
  --result-border: #232830;
  --ad-bg: #1A1F26;
  --ad-bg-2: #232830;
  --upsell-bg: #1A1F26;
  --upsell-border: #232830;
  --upsell-closing: #2E343D;
  --input-bg: #0E1014;

  --card-plan-bg: #1A1F26;
  --card-plan-color: #9BA3B0;
  --card-plan-freemium-bg: #1A1F26;
  --card-plan-freemium-color: #5B7CFF;

  --tool-shadow: rgba(0, 0, 0, 0.28);
  --ip-tot-border: #E8EBF0;
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  font-family: Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, sans-serif;
  font-weight: 400;
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  font-size: 15px;
  -webkit-font-smoothing: antialiased;
}

/* Typography */
h1, h2, h3, h4 {
  font-family: Archivo, -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, sans-serif;
  font-weight: 600;
  line-height: 1.15;
  letter-spacing: -0.02em;
  margin: 0;
}

h1 { letter-spacing: -0.03em; }

strong, b { font-weight: 500; }

code, pre, .mono,
.readout, .readout-sm, .readout-lg,
.stat .val,
.result-box,
.calc-display,
.card-readout,
.hero-readout,
.tool-meta-readout,
.invoice-preview,
.invoice-preview table,
table.amort,
.amort,
.hero-calc-key,
.hero-calc-input {
  font-family: "IBM Plex Mono", ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  font-variant-numeric: tabular-nums;
}

/* Links */
a {
  color: var(--link);
  text-decoration: underline;
  text-underline-offset: 2px;
}

a:hover { color: var(--accent-2); }

/* Focus states */
a:focus-visible,
button:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible,
.calc-btn:focus-visible,
.pct-tab:focus-visible,
.hero-calc-btn:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: 2px;
}

/* Header */
.site-header {
  display: flex;
  align-items: center;
  gap: 18px;
  padding: 12px 24px;
  background: var(--panel);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 10;
}

.brand {
  font-family: Archivo, -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, sans-serif;
  font-weight: 700;
  font-size: 19px;
  color: var(--text);
  text-decoration: none;
  letter-spacing: -0.02em;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.brand::before {
  content: "";
  display: inline-block;
  width: 7px;
  height: 7px;
  background: var(--accent);
  margin-right: 4px;
}

.brand span { color: var(--muted); font-weight: 500; }

.site-nav a {
  color: var(--muted);
  text-decoration: none;
  font-size: 14px;
  font-weight: 500;
  padding: 4px 0;
  border-bottom: 1px solid transparent;
}

.site-nav a:hover { color: var(--text); border-bottom-color: var(--border-strong); }

.pro-badge {
  background: var(--panel);
  color: var(--text);
  border: 1px solid var(--border);
  padding: 3px 8px;
  border-radius: 0;
  font-family: "IBM Plex Mono", ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  font-size: 10px;
  font-weight: 500;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.cta {
  background: var(--panel);
  color: var(--muted);
  padding: 7px 14px;
  border-radius: 0;
  font-weight: 500;
  font-size: 13px;
  text-decoration: none;
  border: 1px solid var(--border);
}

.cta:hover {
  background: var(--inset-bg);
  border-color: var(--border-strong);
  color: var(--text);
}

.theme-toggle {
  background: var(--panel);
  color: var(--muted);
  border: 1px solid var(--border);
  border-radius: 0;
  padding: 6px 10px;
  font-size: 11px;
  font-family: "IBM Plex Mono", ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  font-weight: 500;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
}

.theme-toggle:hover { border-color: var(--accent); color: var(--accent); }

.theme-icon { font-family: "Apple Color Emoji", "Segoe UI Emoji", "Noto Color Emoji", system-ui, sans-serif; }

/* Layout */
main { max-width: 1040px; margin: 0 auto; padding: 24px 24px 90px; }

/* Readout motif — the recurring instrument display */
.readout,
.readout-sm,
.readout-lg,
.hero-readout,
.card-readout,
.tool-meta-readout,
.result-box {
  background: var(--inset-bg);
  border: 1px solid var(--inset-border);
  padding: 12px 14px;
  font-family: "IBM Plex Mono", ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  font-variant-numeric: tabular-nums;
  color: var(--text);
}

.readout-sm {
  padding: 6px 8px;
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.readout-lg {
  padding: 16px 18px;
  font-size: 24px;
  font-weight: 500;
}

/* Homepage hero — working instrument */
.hero {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 40px;
  align-items: center;
  padding: 44px 0 36px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 36px;
}

.hero-copy h1 {
  font-size: clamp(34px, 5vw, 54px);
  line-height: 1.0;
  margin: 0 0 14px;
  max-width: 520px;
}

.hero-copy p {
  color: var(--muted);
  margin: 0 0 22px;
  font-size: 16px;
  max-width: 420px;
}

.hero-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 14px;
}

.hero-stat {
  border: 1px solid var(--border);
  padding: 10px 14px;
  min-width: 110px;
}

.hero-stat .hero-stat-label {
  display: block;
  color: var(--muted);
  font-size: 10px;
  font-weight: 500;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  margin-bottom: 2px;
}

.hero-stat .hero-stat-value {
  font-family: "IBM Plex Mono", ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  font-variant-numeric: tabular-nums;
  font-size: 18px;
  font-weight: 500;
  color: var(--text);
}

.hero-instrument {
  border: 1px solid var(--border);
  padding: 18px;
  background: var(--panel);
}

.hero-readout {
  padding: 16px 18px;
  font-size: clamp(22px, 4vw, 32px);
  font-weight: 500;
  text-align: right;
  min-height: 64px;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  overflow: hidden;
  margin-bottom: 12px;
}

.hero-readout.rolling .digit {
  display: inline-block;
  animation: rollIn 0.55s cubic-bezier(0.22, 1, 0.36, 1) both;
}

@keyframes rollIn {
  0% {
    opacity: 0;
    transform: translateY(-0.6em) blur(2px);
    filter: blur(2px);
  }
  100% {
    opacity: 1;
    transform: translateY(0) blur(0);
    filter: blur(0);
  }
}

@media (prefers-reduced-motion: reduce) {
  .hero-readout.rolling .digit {
    animation: none;
  }
}

.hero-calc-input {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--border);
  background: var(--input-bg);
  color: var(--text);
  font-size: 15px;
  margin-bottom: 10px;
}

.hero-calc-input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: inset 0 0 0 1px var(--accent);
}

.hero-calc-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
}

.hero-calc-btn {
  background: var(--panel);
  color: var(--text);
  border: 1px solid var(--border);
  height: 40px;
  font-size: 15px;
  font-weight: 500;
  cursor: pointer;
  font-family: "IBM Plex Mono", ui-monospace, "SF Mono", Menlo, Consolas, monospace;
}

.hero-calc-btn:hover { border-color: var(--border-strong); background: var(--inset-bg); }

.hero-calc-btn.op { color: var(--accent); }

.hero-calc-btn.eq {
  grid-column: span 2;
  background: var(--accent);
  color: var(--accent-text);
  border-color: var(--accent);
}

.hero-calc-btn.eq:hover { background: var(--accent-2); border-color: var(--accent-2); }

.hero-calc-note {
  color: var(--muted);
  font-size: 11px;
  margin: 10px 0 0;
}

@media (max-width: 720px) {
  .hero { grid-template-columns: 1fr; gap: 28px; }
  .hero-instrument { order: -1; }
  .hero-readout { font-size: 26px; min-height: 58px; }
}

@media (max-width: 375px) {
  .hero-instrument { padding: 14px; }
  .hero-calc-grid { gap: 6px; }
  .hero-calc-btn { height: 38px; font-size: 14px; }
  .hero-readout { padding: 12px 14px; font-size: 22px; min-height: 52px; }
}

/* Tool grid homepage */
.tool-grid { display: flex; flex-direction: column; gap: 36px; }

.cat-group { margin-bottom: 0; }

.cat-title {
  font-family: "IBM Plex Mono", ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--muted);
  margin: 0 0 14px;
  font-weight: 500;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--border);
}

.cards {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: var(--gap);
}

.card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 0;
  padding: 18px;
  text-decoration: none;
  color: inherit;
  transition: border-color .15s ease, box-shadow .15s ease;
  display: flex;
  flex-direction: column;
  position: relative;
}

.card:hover {
  border-color: var(--accent);
  box-shadow: 0 1px 3px var(--tool-shadow);
}

/* featured card - first child of first category */
.cat-group:first-of-type .card:first-child {
  flex-direction: row;
  gap: 22px;
  align-items: flex-start;
}

@media (min-width: 561px) {
  .cat-group:first-of-type .card:first-child { grid-column: span 2; }
}

.cat-group:first-of-type .card:first-child .card-body { flex: 1; }

@media (max-width: 560px) {
  .cards { grid-template-columns: 1fr; }
  .cat-group:first-of-type .card:first-child { grid-column: span 1; flex-direction: column; }
}

.card-readout {
  position: absolute;
  top: 14px;
  right: 14px;
  padding: 5px 7px;
  font-size: 10px;
  font-weight: 500;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
  background: var(--inset-bg);
  border: 1px solid var(--inset-border);
}

.card-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 24px;
  min-height: 22px;
}

.card-plan {
  background: var(--card-plan-bg);
  color: var(--card-plan-color);
  padding: 3px 7px;
  border-radius: 0;
  font-family: "IBM Plex Mono", ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  font-size: 9px;
  font-weight: 500;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.card-plan.freemium { background: var(--card-plan-freemium-bg); color: var(--card-plan-freemium-color); }

.card h3 {
  font-size: 18px;
  margin: 0 0 8px;
  color: var(--text);
  font-weight: 600;
}

.card p {
  color: var(--muted);
  font-size: 13px;
  margin: 0 0 14px;
  line-height: 1.55;
  flex: 1;
}

.card-link {
  color: var(--link);
  font-weight: 500;
  font-size: 13px;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.card-link::after {
  content: "\2192";
  transition: transform .15s ease;
}

.card:hover .card-link::after { transform: translateX(3px); }

/* Tool page */
.crumbs {
  color: var(--muted);
  font-size: 12px;
  margin-bottom: 14px;
  font-family: "IBM Plex Mono", ui-monospace, "SF Mono", Menlo, Consolas, monospace;
}

.crumbs a { color: var(--link); text-decoration: none; }
.crumbs a:hover { text-decoration: underline; }

.tool-page h1 {
  font-size: clamp(28px, 5vw, 42px);
  margin: 0 0 10px;
  max-width: 760px;
  font-weight: 600;
}

.tool-header {
  margin-bottom: 22px;
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 12px 18px;
}

.tool-lead {
  font-size: 15px;
  margin: 0;
  max-width: 680px;
  line-height: 1.55;
  flex-basis: 100%;
}

.tool-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
  margin-bottom: 18px;
}

.tool-meta-readout {
  padding: 5px 8px;
  font-size: 10px;
  font-weight: 500;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
}

.tool-meta-readout.category { color: var(--text); }

.tool-layout {
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.tool-widget {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 0;
  padding: 26px;
  box-shadow: 0 1px 2px var(--tool-shadow);
}

/* Upsell */
.upsell {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  background: var(--upsell-bg);
  border: 1px solid var(--upsell-border);
  border-left: 3px solid var(--accent);
  border-radius: 0;
  padding: 16px 20px;
}

.upsell.bot { margin-top: 26px; border-color: var(--upsell-closing); border-left-color: var(--accent); }

.upsell strong { color: var(--text); font-weight: 500; }

.upsell p { margin: 4px 0 0; }

.upsell button {
  background: var(--panel);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 0;
  padding: 9px 18px;
  font-weight: 500;
  font-size: 14px;
  cursor: pointer;
  white-space: nowrap;
}

.upsell button:hover { background: var(--inset-bg); border-color: var(--accent); color: var(--accent); }

@media (max-width: 560px) {
  .upsell { flex-direction: column; align-items: flex-start; }
  .upsell button { width: 100%; text-align: center; }
}

.muted { color: var(--muted); font-size: 13px; }

/* Briefing (SEO content) */
.briefing { margin-top: 38px; }

.briefing-placeholder {
  background: var(--inset-bg);
  border: 1px dashed var(--border-strong);
  border-radius: 0;
  padding: 18px 22px;
  color: var(--muted);
  font-size: 14px;
}

.briefing-placeholder code {
  background: var(--panel);
  padding: 1px 5px;
  border-radius: 0;
  border: 1px solid var(--border);
  font-size: 12px;
}

.briefing h2 {
  font-size: 24px;
  margin: 34px 0 12px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--border);
}

.briefing h3 {
  font-size: 17px;
  margin: 24px 0 8px;
}

.briefing p, .briefing ul, .briefing ol, .briefing li { font-size: 15px; }

.briefing ul, .briefing ol { padding-left: 24px; }

.briefing li { margin: 6px 0; }

.briefing strong { color: var(--text); font-weight: 500; }

.briefing a { color: var(--link); }

/* Related + ad + footer */
.related { margin-top: 42px; }

.related h2 {
  font-size: 18px;
  border-bottom: 1px solid var(--border);
  padding-bottom: 8px;
}

.related-list {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 16px;
}

.related-link {
  padding: 8px 14px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 0;
  text-decoration: none;
  color: var(--text);
  font-size: 13px;
  font-weight: 500;
  transition: border-color .15s ease;
}

.related-link:hover { border-color: var(--accent); color: var(--link); }

.ad-slot {
  margin: 32px 0;
  min-height: 90px;
  background: var(--ad-bg);
  border: 1px solid var(--border);
  border-radius: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
}

.ad-slot::before {
  content: "";
  position: absolute;
  inset: 8px;
  border: 1px dashed var(--ad-bg-2);
  pointer-events: none;
}

.ad-label {
  color: var(--muted);
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  font-weight: 500;
  font-family: "IBM Plex Mono", ui-monospace, "SF Mono", Menlo, Consolas, monospace;
}

.site-footer {
  color: var(--muted);
  font-size: 13px;
  padding: 24px;
  border-top: 1px solid var(--border);
  background: var(--panel);
}

.footer-inner {
  max-width: 1040px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.footer-note { max-width: 480px; line-height: 1.5; }

.footer-main { display: flex; flex-direction: column; gap: 10px; }

.footer-links { display: flex; gap: 16px; flex-wrap: wrap; }

.footer-links a {
  color: var(--muted);
  font-size: 13px;
  text-decoration: none;
}

.footer-links a:hover { color: var(--link); text-decoration: underline; }

@media (max-width: 560px) {
  .footer-inner { flex-direction: column; align-items: flex-start; }
}

/* Forms inside tool widgets */
.field { margin-bottom: 16px; }

.field label {
  display: block;
  font-size: 13px;
  font-weight: 500;
  margin-bottom: 5px;
  color: var(--text);
}

.field input, .field select, .field textarea {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 0;
  font-size: 15px;
  background: var(--input-bg);
  color: var(--text);
  font-family: inherit;
}

.field input:focus, .field select:focus, .field textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: inset 0 0 0 1px var(--accent);
}

.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }

@media (max-width: 560px) { .grid-2 { grid-template-columns: 1fr; } }

.btn {
  background: var(--accent);
  color: var(--accent-text);
  border: 1px solid var(--accent);
  padding: 10px 20px;
  border-radius: 0;
  font-weight: 500;
  font-size: 15px;
  cursor: pointer;
}

.btn:hover { background: var(--accent-2); border-color: var(--accent-2); }

.btn.secondary {
  background: transparent;
  color: var(--text);
  border: 1px solid var(--border);
}

.btn.secondary:hover { border-color: var(--border-strong); background: var(--inset-bg); }

.result-box {
  background: var(--result-bg);
  border: 1px solid var(--result-border);
  border-radius: 0;
  padding: 18px 22px;
  margin-top: 20px;
}

.result-box h3 { margin: 0 0 14px; font-size: 20px; color: var(--text); }

.result-box h4 {
  font-family: Archivo, -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, sans-serif;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
  margin: 18px 0 8px;
  font-weight: 600;
}

.stat {
  display: inline-block;
  margin-right: 26px;
  margin-bottom: 10px;
}

.stat .lbl {
  color: var(--muted);
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-weight: 500;
}

.stat .val { font-size: 24px; font-weight: 500; color: var(--text); }

.stat .val.positive { color: var(--ledger); }

/* Auto-loan "Saved with extra" is always a positive delta → Ledger green.
   The JS can't be edited, so we target its fixed position in the result box. */
.result-box > div.stat:nth-last-of-type(1):nth-of-type(7) .val { color: var(--ledger); }

table.amort {
  width: 100%;
  border-collapse: collapse;
  margin-top: 14px;
  font-size: 13px;
}

table.amort th, table.amort td {
  padding: 8px 10px;
  text-align: right;
  border-bottom: 1px solid var(--border);
}

table.amort th { background: var(--inset-bg); font-weight: 600; }

table.amort th:nth-child(1), table.amort td:nth-child(1) { text-align: left; }

/* Invoice preview */
.invoice-preview {
  background: var(--input-bg);
  border: 1px solid var(--border);
  border-radius: 0;
  padding: 32px;
  margin-top: 22px;
}

.invoice-preview .ip-top { display: flex; justify-content: space-between; margin-bottom: 28px; gap: 20px; }

.invoice-preview .ip-label {
  color: var(--muted);
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-weight: 500;
}

.invoice-preview h2 { margin: 0; font-size: 32px; }

.invoice-preview table { width: 100%; border-collapse: collapse; margin-top: 14px; }

.invoice-preview th, .invoice-preview td {
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
  text-align: right;
}

.invoice-preview th { background: var(--inset-bg); text-align: right; font-size: 13px; }

.invoice-preview td:first-child, .invoice-preview th:first-child { text-align: left; }

.invoice-preview .ip-tot { display: flex; justify-content: flex-end; margin-top: 16px; }

.invoice-preview .ip-tot-row { display: flex; justify-content: space-between; min-width: 240px; padding: 4px 0; }

.invoice-preview .ip-tot-row.grand { border-top: 2px solid var(--ip-tot-border); margin-top: 6px; font-weight: 700; font-size: 18px; }

/* 404 */
.not-found { text-align: left; padding: 80px 0; max-width: 520px; }

.not-found h1 {
  font-size: 88px;
  color: var(--text);
  margin: 0 0 12px;
  line-height: 1;
  font-family: "IBM Plex Mono", ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  font-variant-numeric: tabular-nums;
}

.not-found p { color: var(--muted); font-size: 18px; margin: 0 0 24px; }

/* Basic calculator */
.calc { max-width: 320px; margin: 0 auto; }

.calc-display {
  background: var(--inset-bg);
  border: 1px solid var(--border);
  border-radius: 0;
  min-height: 64px;
  padding: 16px 18px;
  margin-bottom: 14px;
  text-align: right;
  font-size: 32px;
  font-weight: 500;
  overflow: hidden;
  color: var(--text);
}

.calc-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; }

.calc-btn {
  background: var(--panel);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 0;
  height: 54px;
  font-size: 19px;
  font-weight: 500;
  cursor: pointer;
  user-select: none;
  transition: background .1s, border .1s;
  font-family: "IBM Plex Mono", ui-monospace, "SF Mono", Menlo, Consolas, monospace;
}

.calc-btn:hover { border-color: var(--border-strong); background: var(--inset-bg); }

.calc-btn:active { transform: translateY(1px); }

.calc-btn.num { background: var(--input-bg); }

.calc-btn.op { color: var(--accent); }

.calc-btn.fn { color: var(--red); }

.calc-btn.eq {
  grid-column: 4 / 5;
  background: var(--accent);
  color: var(--accent-text);
  border-color: var(--accent);
  border-radius: 0;
}

.calc-btn.eq:hover { background: var(--accent-2); border-color: var(--accent-2); color: var(--accent-text); }

/* Pythagorean */
.pythag-svg {
  display: block;
  margin: 22px auto 0;
  max-width: 220px;
  width: 100%;
  height: auto;
}

.pythag-svg text { font-family: Archivo, -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, sans-serif; }

/* Percentage tabs */
.pct-mode-tabs { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 18px; }

.pct-tab {
  background: var(--panel);
  color: var(--muted);
  border: 1px solid var(--border);
  border-radius: 0;
  padding: 8px 16px;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: .15s all;
  font-family: inherit;
}

.pct-tab:hover { color: var(--text); border-color: var(--border-strong); }

.pct-tab.active { background: var(--accent); color: var(--accent-text); border-color: var(--accent); }

.pct-form { display: block; }

/* Shared utils: history panel + result actions + print isolation */
.tkhq-result-actions { display: flex; gap: 10px; margin-top: 14px; }

.tkhq-pulse { animation: tkhq-pulse .6s ease; }
@keyframes tkhq-pulse { 0% { background: var(--accent-soft); } 100% { background: transparent; } }

.tkhq-history {
  margin-top: 28px;
  border-top: 1px solid var(--border);
  padding-top: 16px;
}

.tkhq-history-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
}

.tkhq-history-title {
  font-family: "IBM Plex Mono", ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
  font-weight: 500;
}

.tkhq-history-clear {
  background: none;
  border: 1px solid var(--border);
  color: var(--muted);
  font-size: 11px;
  padding: 3px 10px;
  cursor: pointer;
  font-family: inherit;
  border-radius: 0;
}

.tkhq-history-clear:hover { color: var(--red); border-color: var(--red); }

.tkhq-history-list {
  list-style: none;
  margin: 0;
  padding: 0;
}

.tkhq-history-empty { color: var(--muted); font-size: 13px; padding: 8px 0; }

.tkhq-history-item {
  display: grid;
  grid-template-columns: 28px 1fr auto;
  align-items: baseline;
  gap: 12px;
  padding: 8px 0;
  border-bottom: 1px solid var(--border);
  font-size: 13px;
}

.tkhq-history-item:last-child { border-bottom: none; }

.tkhq-history-idx {
  font-family: "IBM Plex Mono", ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  font-variant-numeric: tabular-nums;
  color: var(--muted);
  font-size: 11px;
}

.tkhq-history-main { display: flex; flex-direction: column; gap: 2px; min-width: 0; }

.tkhq-history-label {
  font-weight: 500;
  color: var(--text);
  font-family: "IBM Plex Mono", ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  font-variant-numeric: tabular-nums;
}

.tkhq-history-summary { color: var(--muted); font-size: 12px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.tkhq-history-ts {
  font-family: "IBM Plex Mono", ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  font-size: 11px;
  color: var(--muted);
  white-space: nowrap;
}

/* BMI band gauge (instrument-panel precedent — SVG, print-friendly) */
.bmi-gauge { display: block; margin-top: 18px; width: 100%; max-width: 480px; }

.bmi-gauge .band { stroke: var(--border); stroke-width: 1; }

.bmi-gauge .marker { fill: var(--accent); }

.bmi-gauge .marker-line { stroke: var(--accent); stroke-width: 2; }

.bmi-gauge text {
  font-family: "IBM Plex Mono", ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  font-size: 10px;
  fill: var(--muted);
}

.bmi-gauge .marker-label { fill: var(--accent); font-weight: 600; }

/* Macro donut SVG (uses two colors only, no rainbow) */
.macro-donut { display: block; margin: 8px auto 0; max-width: 160px; width: 100%; }

.macro-donut .arc { stroke: var(--bg); stroke-width: 2; }

.macro-donut .arc-protein { fill: var(--accent); }
.macro-donut .arc-fat { fill: var(--ledger); }
.macro-donut .arc-carb { fill: var(--muted); }

.macro-donut .center-label {
  text-anchor: middle;
  font-family: "IBM Plex Mono", ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  font-size: 11px;
  fill: var(--muted);
}

.donut-legend { display: flex; flex-wrap: wrap; gap: 12px 18px; margin: 10px 0 0; padding: 0; list-style: none; font-size: 13px; }

.donut-legend li { display: flex; align-items: center; gap: 6px; }

.donut-legend .sw { width: 10px; height: 10px; border-radius: 50%; display: inline-block; }
.donut-legend .sw-protein { background: var(--accent); }
.donut-legend .sw-fat { background: var(--ledger); }
.donut-legend .sw-carb { background: var(--muted); }

/* Print */
@media print {
  .site-header, .site-footer, .ad-slot, .upsell, .related, .crumbs, .briefing, .no-print { display: none !important; }
  body { background: #fff; color: #000; }
  .tool-widget { border: 1px solid #ccc; box-shadow: none; }
  /* When body.tkhq-printing is active (TKHQ.printWidget), isolate the print target. */
  body.tkhq-printing > main > * { display: none !important; }
  body.tkhq-printing .tool-page { padding: 0 !important; }
  body.tkhq-printing .tkhq-print-target,
  body.tkhq-printing .tkhq-print-target * { display: revert !important; }
  body.tkhq-printing .tkhq-print-target { display: block !important; border: none !important; }
}
