/* EV vs Fuel Cost. Colours follow psyphin.co.za (css/style.css there);
   the base is the SA Towing Check / Winch stylesheet, so the tools look the same. */
:root {
  --bg: #020203;
  --surface: #111418;
  --surface-2: #181c21;
  --border: #262c33;
  --text: #e6ebef;
  --text-muted: #9aa4ae;
  --accent: #3fb6ff;
  --accent-strong: #1e8fff;

  /* anything the visitor can change: blue box, blue value, pencil (worked-out figures stay plain) */
  --input-bg: color-mix(in srgb, var(--accent) 12%, var(--surface-2));
  --input-border: color-mix(in srgb, var(--accent) 70%, var(--border));
  --pencil: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16' fill='none' stroke='%233fb6ff' stroke-width='1.6' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M11.2 2.3l2.5 2.5-8.4 8.4-3.2.7.7-3.2z'/%3E%3Cpath d='M9.6 3.9l2.5 2.5'/%3E%3C/svg%3E");

  /* traffic light */
  --pass: #4ade80;
  --warn: #fbbf24;
  --fail: #f87171;
  --info: #3fb6ff;
  --incomplete: #7b8590;

  /* panel accents */
  --legal: #3fb6ff;
  --maker: #c084fc;

  /* chart series (validated for colour-blind separation on --surface-2) */
  --series-1: #3987e5;
  --series-2: #d95926;
  --series-3: #9085e9;
  --series-4: #d55181;
  --series-neutral: #7b8590;

  /* under construction banner */
  --construction: #fbbf24;
  --construction-ink: #1a1405;

  --radius: 14px;
  --max-width: 1100px;
  --font-body: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --font-display: "Rajdhani", "Segoe UI", system-ui, sans-serif;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

/* elements with display rules below must still hide (modes, trailer fields) */
[hidden] {
  display: none !important;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-body);
  font-size: 1rem;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

/* Faint circuit-trace pattern behind the top of the page, the same as
   psyphin.co.za's (css/style.css there); it fades out downwards. */
body::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 1100px;
  z-index: -1;
  pointer-events: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='180' height='180' fill='none'%3E%3Cg stroke='%233fb6ff' stroke-opacity='0.09' stroke-width='1'%3E%3Cpath d='M0 40h46l18 18h44M108 58v42l18 18h54M24 180v-44l18-18h34M180 22h-34L124 0M76 118v-20l-14-14H0M146 180v-26l12-12h22'/%3E%3C/g%3E%3Cg fill='%233fb6ff' fill-opacity='0.16'%3E%3Ccircle cx='108' cy='58' r='2.2'/%3E%3Ccircle cx='76' cy='118' r='2.2'/%3E%3Ccircle cx='146' cy='22' r='2.2'/%3E%3Ccircle cx='146' cy='154' r='2.2'/%3E%3C/g%3E%3C/svg%3E");
  -webkit-mask-image: linear-gradient(to bottom, #000 0%, rgba(0, 0, 0, 0.6) 45%, transparent 100%);
  mask-image: linear-gradient(to bottom, #000 0%, rgba(0, 0, 0, 0.6) 45%, transparent 100%);
}

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

h1,
h2,
h3 {
  font-family: var(--font-display);
  line-height: 1.15;
  margin: 0;
}

.wrap {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 0 16px;
}

.skip-link {
  position: absolute;
  left: -9999px;
}

.skip-link:focus {
  left: 16px;
  top: 16px;
  z-index: 10;
  background: var(--surface);
  padding: 8px 12px;
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

.muted {
  color: var(--text-muted);
}

/* ------------------------------------------------------------ header / footer */
.site-header {
  border-bottom: 1px solid var(--border);
  background: rgba(2, 2, 3, 0.92);
  position: sticky;
  top: 0;
  z-index: 5;
  backdrop-filter: blur(6px);
}

.site-header-inner {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 12px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

/* back link pill: same design as fuel.psyphin.co.za's header link */
.back-link {
  display: inline-flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 4px 10px;
  padding: 8px 16px 8px 12px;
  border: 1px solid rgba(61, 155, 255, 0.45);
  border-radius: 999px;
  background: rgba(61, 155, 255, 0.08);
  color: var(--text);
  font-size: 15px;
  font-weight: 600;
  line-height: 1.3;
  text-decoration: none;
  transition: background-color 0.15s ease, border-color 0.15s ease, box-shadow 0.15s ease;
}

.back-link-arrow {
  color: var(--accent);
  font-size: 17px;
  transition: transform 0.15s ease;
}

.back-link-domain {
  color: var(--text-muted);
  font-weight: 500;
  font-size: 13px;
}

.back-link:hover {
  background: rgba(61, 155, 255, 0.16);
  border-color: var(--accent);
  box-shadow: 0 0 18px rgba(61, 155, 255, 0.25);
}

.back-link:hover .back-link-arrow {
  transform: translateX(-3px);
}

.back-link:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
}

/* phones: the pill, page links and shield share one row, so drop the domain,
   keep the pill on one line and shorten it to "← PsyPhin tools" */
@media (max-width: 480px) {
  .back-link-domain {
    display: none;
  }

  .back-link {
    flex-wrap: nowrap;
    white-space: nowrap;
  }
}

@media (max-width: 420px) {
  .back-link-more {
    display: none;
  }

  .back-link {
    padding: 7px 12px 7px 10px;
    gap: 8px;
    font-size: 14px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .back-link,
  .back-link-arrow {
    transition: none;
  }
}

.nav {
  display: flex;
  gap: 18px;
}

/* page links + PsyPhin shield (a copy of psyphin.co.za's brand-64.png), top right */
.header-end {
  display: flex;
  align-items: center;
  gap: 16px;
}

.brand {
  display: block;
  flex: none;
  border-radius: 6px;
}

.brand img {
  display: block;
  width: 32px;
  height: 32px;
  border-radius: 6px;
}

.brand:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
}

@media (max-width: 420px) {
  .site-header-inner {
    gap: 12px;
  }

  .header-end,
  .nav {
    gap: 12px;
  }

  .nav a {
    font-size: 1rem;
  }

  .brand img {
    width: 28px;
    height: 28px;
  }
}

@media (max-width: 350px) {
  .site-header-inner {
    padding-left: 12px;
    padding-right: 12px;
  }

  .site-header-inner,
  .header-end,
  .nav {
    gap: 8px;
  }

  .back-link {
    padding: 6px 10px 6px 8px;
    gap: 6px;
  }
}

.nav a {
  color: var(--text-muted);
  text-decoration: none;
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 1.05rem;
  letter-spacing: 0.02em;
}

.nav a[aria-current="page"],
.nav a:hover {
  color: var(--accent);
}

.site-footer {
  border-top: 1px solid var(--border);
  margin-top: 48px;
  padding: 20px 0 32px;
  color: var(--text-muted);
  font-size: 0.875rem;
}

.site-footer p {
  margin: 4px 0;
}

/* ------------------------------------------------------------ intro */
.intro {
  padding: 28px 0 8px;
}

.intro h1 {
  font-size: clamp(2rem, 6vw, 2.8rem);
  color: var(--text);
}

.lede {
  max-width: 62ch;
  margin: 10px 0 6px;
  color: var(--text);
}

.privacy {
  margin: 0;
  color: var(--text-muted);
  font-size: 0.875rem;
}


/* ------------------------------------------------------------ header
   The same header as fuel.psyphin.co.za (.brand-bar in its style.css):
   black band with a blue glow, the PsyPhin logo, a blue eyebrow, the title
   and a one-line description. Keep the three in step. */
.brand-bar {
  position: relative;
  background:
    radial-gradient(ellipse 60% 120% at 100% 0%, rgba(61, 155, 255, 0.18), transparent 60%),
    #000000;
  color: #ffffff;
  border-bottom: 1px solid rgba(61, 155, 255, 0.35);
  padding-top: env(safe-area-inset-top, 0px);
}

.brand-nav {
  max-width: 1120px;
  margin: 0 auto;
  padding: 12px 20px 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 10px 16px;
}

.brand-inner {
  max-width: 1120px;
  margin: 0 auto;
  padding: 20px;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 20px 28px;
}

.brand-logo-link {
  flex-shrink: 0;
  display: block;
  border-radius: 8px;
}

.brand-logo-link:focus-visible {
  outline: 2px solid #3d9bff;
  outline-offset: 3px;
}

.brand-logo {
  width: 168px;
  height: auto;
  display: block;
}

.brand-text {
  flex: 1 1 360px;
  min-width: 0;
}

.brand-eyebrow {
  margin: 0 0 6px;
  font-family: var(--font-body);
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: #3d9bff;
}

.brand-bar h1,
.brand-title {
  margin: 0 0 8px;
  font-family: var(--font-body);
  font-size: clamp(24px, 3.2vw, 34px);
  line-height: 1.15;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: #ffffff;
}

.brand-bar .subtitle {
  margin: 0;
  color: #a9b4c2;
  max-width: 62ch;
  font-size: 15px;
  line-height: 1.6;
}

@media (max-width: 760px) {
  .brand-nav {
    padding: 10px 16px 0;
  }

  .brand-inner {
    padding: 16px;
    gap: 14px 18px;
  }

  .brand-logo {
    width: 112px;
  }

  .brand-text {
    flex-basis: 200px;
  }

  .brand-bar .subtitle {
    font-size: 14px;
  }
}

@media print {
  .brand-bar,
  body::before {
    display: none;
  }
}

/* ============================================================ Winch Planning and Sizing additions */

/* ------------------------------------------------------------ under construction (same as the tyre calculator) */
.construction {
  background: repeating-linear-gradient(-45deg, var(--construction) 0 18px, #f59e0b 18px 36px);
  color: var(--construction-ink);
  text-align: center;
  padding: 10px 16px;
  font-size: 0.95rem;
  line-height: 1.4;
}

.construction strong {
  font-family: var(--font-display);
  font-size: 1.1rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  margin-right: 4px;
}

.intro .lede {
  max-width: 70ch;
  margin: 0 0 6px;
}

.intro .privacy a {
  color: var(--text-muted);
}

/* ============================================================ EV vs Fuel Cost additions */
:root {
  --fuel: #f0883e;            /* the fuel car, everywhere */
  --ev: #3fb6ff;              /* the electric car, everywhere */
  --ev-soft: #2a6f99;
  --good: #4ade80;
  --bad: #f87171;
}

.link-button {
  background: none;
  border: 0;
  padding: 0;
  font: inherit;
  color: var(--accent);
  text-decoration: underline;
  cursor: pointer;
}

.key-input {
  display: inline-block;
  padding: 0 6px;
  border: 1px solid var(--input-border);
  background: var(--input-bg);
  border-radius: 5px;
  color: var(--accent);
}

.live-line {
  margin: 8px 0 0;
  font-size: 0.875rem;
  color: var(--text-muted);
  min-height: 1.4em;
}

.live-line a {
  color: var(--text-muted);
}

.live-dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  margin-right: 8px;
  border-radius: 50%;
  background: var(--good);
  box-shadow: 0 0 0 3px rgba(74, 222, 128, 0.2);
  vertical-align: 1px;
}

/* ------------------------------------------------------------ sections */
.block {
  margin-top: 36px;
  scroll-margin-top: 16px;
}

.block-title {
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: clamp(1.5rem, 4vw, 1.9rem);
  margin-bottom: 6px;
}

.block-num {
  display: inline-grid;
  place-items: center;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  border: 1px solid var(--accent);
  color: var(--accent);
  font-size: 1.1rem;
  flex: none;
}

.block-lede {
  margin: 0 0 14px;
  color: var(--text-muted);
  max-width: 75ch;
}

.calc-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1.05fr);
  gap: 20px;
  align-items: start;
  margin-top: 14px;
}

.results {
  position: sticky;
  top: 12px;
  display: grid;
  gap: 14px;
}

@media (max-width: 860px) {
  .calc-layout {
    grid-template-columns: minmax(0, 1fr);
  }

  .results {
    position: static;
  }
}

/* ------------------------------------------------------------ inputs */
.inputs {
  display: grid;
  gap: 14px;
  min-width: 0;
}

fieldset {
  margin: 0;
  padding: 14px 16px 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  min-width: 0;
}

legend {
  padding: 0 6px;
  margin-left: -6px;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 1.15rem;
  letter-spacing: 0.01em;
}

.field {
  margin-top: 10px;
  min-width: 0;
}

.field:first-child {
  margin-top: 4px;
}

.field label,
.field .label {
  display: block;
  font-weight: 600;
  font-size: 0.9rem;
  margin-bottom: 5px;
}

.field-row {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0 12px;
}

/* rows without hints: line the boxes up even when a label wraps */
.field-row--end {
  align-items: end;
}

.field-row--3 {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.field--narrow {
  max-width: 220px;
}

.field--check {
  display: flex;
  align-items: flex-end;
  padding-bottom: 10px;
}

.field .check {
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  margin: 0;
}

.check input {
  width: 18px;
  height: 18px;
  accent-color: var(--accent);
}

/* phones: one field per row (units like "/ litre" need the width); the % trio stays side by side */
@media (max-width: 560px) {
  .field-row {
    grid-template-columns: minmax(0, 1fr);
  }

  .field-row--3 {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .field-row--3 .with-unit > span {
    padding: 0 8px;
  }

  .field-row--3 .with-unit input {
    padding-right: 8px;
    background-image: none;
  }

  .field--check {
    padding-bottom: 0;
  }
}

/* phones: a summary pinned to the bottom while the everyday inputs are on screen */
.quickbar {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 6;
  display: flex;
  justify-content: center;
  gap: 6px 14px;
  flex-wrap: wrap;
  padding: 10px 16px calc(10px + env(safe-area-inset-bottom, 0px));
  background: rgba(17, 20, 24, 0.96);
  border-top: 1px solid var(--border);
  backdrop-filter: blur(6px);
  font-size: 0.88rem;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  text-decoration: none;
  color: var(--text);
}

.quickbar .q-fuel { color: var(--fuel); }
.quickbar .q-ev { color: var(--ev); }
.quickbar .q-save { color: var(--good); }
.quickbar .q-save.bad { color: var(--bad); }

@media (min-width: 861px) {
  .quickbar {
    display: none;
  }
}

.with-unit {
  display: flex;
  align-items: stretch;
  border: 1px solid var(--input-border);
  background: var(--input-bg);
  border-radius: 9px;
  overflow: hidden;
}

.with-unit:focus-within {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}

.with-unit input {
  flex: 1 1 auto;
  min-width: 0;
  width: 100%;
  padding: 9px 30px 9px 10px;
  border: 0;
  background: var(--pencil) no-repeat right 8px center / 14px;
  color: var(--accent);
  font: inherit;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  outline: none;
  -moz-appearance: textfield;
  appearance: textfield;
}

.with-unit input::-webkit-outer-spin-button,
.with-unit input::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}

.with-unit > span {
  display: flex;
  align-items: center;
  padding: 0 10px;
  color: var(--text-muted);
  font-size: 0.85rem;
  white-space: nowrap;
  border-left: 1px solid var(--border);
  background: rgba(0, 0, 0, 0.15);
}

.with-unit > .unit-before {
  padding: 0 0 0 10px;
  border: 0;
  background: none;
  color: var(--accent);
  font-weight: 600;
  font-size: 1rem;
}

.with-unit > .unit-before + input {
  padding-left: 3px;
}

.hint {
  margin: 6px 0 0;
  color: var(--text-muted);
  font-size: 0.82rem;
  line-height: 1.45;
}

.hint a {
  color: var(--text-muted);
}

/* chips: blue when selected (a choice you made) */
.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 2px 0 8px;
}

.chip {
  padding: 7px 13px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface-2);
  color: var(--text);
  font: inherit;
  font-size: 0.9rem;
  font-weight: 500;
  cursor: pointer;
  transition: border-color 0.15s ease, background-color 0.15s ease;
}

.chips--small .chip {
  padding: 5px 11px;
  font-size: 0.82rem;
}

.chip:hover {
  border-color: var(--input-border);
}

.chip[aria-pressed="true"] {
  border-color: var(--accent);
  background: var(--input-bg);
  color: var(--accent);
  font-weight: 600;
}

.chip:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.dot {
  display: inline-block;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  margin-right: 4px;
  vertical-align: 1px;
}

.dot--fuel {
  background: var(--fuel);
}

.dot--ev {
  background: var(--ev);
}

/* charging mix */
.mix {
  display: grid;
  gap: 6px;
}

.mix-row {
  display: grid;
  grid-template-columns: 82px minmax(0, 1fr) 46px;
  align-items: center;
  gap: 10px;
}

.mix-row label {
  font-size: 0.9rem;
  font-weight: 600;
}

.mix-row input[type="range"] {
  width: 100%;
  accent-color: var(--accent);
}

.mix-row output {
  text-align: right;
  color: var(--accent);
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

.mix-bar {
  display: flex;
  height: 8px;
  margin-top: 10px;
  border-radius: 4px;
  overflow: hidden;
  background: var(--surface-2);
}

.mix-seg {
  flex-basis: 0;
}

.mix-seg--home { background: #4ade80; }
.mix-seg--ac { background: #3fb6ff; }
.mix-seg--dc { background: #c084fc; }

/* ------------------------------------------------------------ results */
.result-card {
  padding: 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  min-width: 0;
}

.card-title {
  font-size: 1.15rem;
  margin: 0 0 10px;
}

.headline {
  margin: 0 0 12px;
  font-size: 1.05rem;
  font-weight: 600;
  line-height: 1.4;
}

.tiles {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.tile {
  padding: 12px;
  border-radius: 10px;
  background: var(--surface-2);
  border-top: 3px solid var(--border);
  min-width: 0;
}

.tile--fuel { border-top-color: var(--fuel); }
.tile--ev { border-top-color: var(--ev); }

.tile p {
  margin: 0;
}

.tile-label {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.tile .tile-value {
  font-family: var(--font-display);
  font-size: clamp(1.5rem, 5vw, 2rem);
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  line-height: 1.2;
  margin: 4px 0;
}

.tile--fuel .tile-value { color: var(--fuel); }
.tile--ev .tile-value { color: var(--ev); }

.tile-sub {
  font-size: 0.8rem;
  color: var(--text-muted);
}

.save {
  margin: 12px 0 0;
  font-weight: 600;
}

.save--good { color: var(--good); }
.save--bad { color: var(--bad); }

/* cost per 100 km */
.bars {
  display: grid;
  gap: 8px;
}

.bar-row {
  display: grid;
  grid-template-columns: 140px minmax(0, 1fr) 64px;
  align-items: center;
  gap: 10px;
  font-size: 0.88rem;
}

.bar-row--strong .bar-label {
  font-weight: 700;
  color: var(--text);
}

.bar-label {
  color: var(--text-muted);
}

.bar-track {
  height: 14px;
  background: var(--surface-2);
  border-radius: 4px;
  overflow: hidden;
}

.bar {
  display: block;
  height: 100%;
  border-radius: 4px;
  transition: width 0.3s ease;
}

.bar--fuel { background: var(--fuel); }
.bar--ev { background: var(--ev); }
.bar--ev-soft { background: var(--ev-soft); }

.bar-value {
  text-align: right;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

@media (max-width: 420px) {
  .bar-row {
    grid-template-columns: 112px minmax(0, 1fr) 56px;
    gap: 8px;
    font-size: 0.82rem;
  }
}

.facts {
  margin: 0;
  padding-left: 18px;
  display: grid;
  gap: 8px;
  font-size: 0.92rem;
}

.facts strong {
  color: var(--text);
}

#next-month p {
  margin: 0;
  font-size: 0.92rem;
}

/* charts */
.trip-chart,
.own-chart {
  width: 100%;
  overflow: hidden;
}

.trip-chart svg,
.own-chart svg {
  display: block;
  max-width: 100%;
  height: auto;
}

svg .grid {
  stroke: var(--border);
  stroke-width: 1;
}

svg .axis {
  fill: var(--text-muted);
  font-size: 11px;
  font-family: var(--font-body);
}

svg .reserve {
  fill: rgba(248, 113, 113, 0.12);
}

svg .batt-area {
  fill: rgba(63, 182, 255, 0.14);
}

svg .batt-line {
  fill: none;
  stroke: var(--ev);
  stroke-width: 2.5;
  stroke-linejoin: round;
}

svg .stop-line {
  stroke: #c084fc;
  stroke-dasharray: 3 4;
}

svg .stop-dot {
  fill: #c084fc;
}

svg .stop-label {
  fill: #c084fc;
  font-size: 11px;
  font-weight: 600;
  font-family: var(--font-body);
}

svg .own-line {
  fill: none;
  stroke-width: 2.5;
  stroke-linejoin: round;
}

svg .own-line.own--fuel { stroke: var(--fuel); }
svg .own-line.own--ev { stroke: var(--ev); }
svg .own-dot.own--fuel { fill: var(--fuel); }
svg .own-dot.own--ev { fill: var(--ev); }

svg .be-line {
  stroke: var(--good);
  stroke-dasharray: 4 4;
}

svg .be-label {
  fill: var(--good);
  font-size: 11px;
  font-weight: 600;
  font-family: var(--font-body);
}

.legend {
  display: flex;
  gap: 16px;
  margin-top: 8px;
  font-size: 0.85rem;
  color: var(--text-muted);
}

.legend i {
  display: inline-block;
}

.chargers {
  margin: 0;
  padding-left: 18px;
  display: grid;
  gap: 6px;
  font-size: 0.9rem;
}

.chargers a {
  color: var(--text-muted);
  font-size: 0.82rem;
}

.table-wrap {
  overflow-x: auto;
}

.own-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
  font-variant-numeric: tabular-nums;
}

.own-table th,
.own-table td {
  padding: 7px 8px;
  border-bottom: 1px solid var(--border);
  text-align: right;
  white-space: nowrap;
}

.own-table th[scope="row"],
.own-table thead th:first-child {
  text-align: left;
  font-weight: 500;
  color: var(--text-muted);
}

.own-table thead th {
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.own-table thead th:nth-child(2) { color: var(--fuel); }
.own-table thead th:nth-child(3) { color: var(--ev); }

.own-table tr.total th,
.own-table tr.total td {
  font-weight: 700;
  color: var(--text);
  border-bottom: 0;
}

/* ------------------------------------------------------------ good to know */
.know-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
  gap: 14px;
  margin-top: 14px;
}

.know {
  padding: 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
}

.know h3 {
  font-size: 1.1rem;
  margin-bottom: 6px;
  color: var(--accent);
}

.know p {
  margin: 0;
  font-size: 0.92rem;
  color: var(--text-muted);
}

/* ------------------------------------------------------------ sources */
.sources-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 20px;
  margin-top: 14px;
}

@media (max-width: 760px) {
  .sources-grid {
    grid-template-columns: minmax(0, 1fr);
  }
}

.source-list {
  margin: 0 0 18px;
  padding-left: 18px;
  display: grid;
  gap: 8px;
  font-size: 0.88rem;
  color: var(--text-muted);
}

.source-list strong {
  color: var(--text);
}

.source-list a,
.refs a {
  color: var(--accent);
}

.refs {
  margin: 0;
  padding-left: 22px;
  display: grid;
  gap: 6px;
  font-size: 0.85rem;
  color: var(--text-muted);
  overflow-wrap: anywhere;
}

.disclaimer {
  margin-top: 36px;
  padding: 16px;
  border: 1px solid var(--border);
  border-left: 3px solid var(--warn);
  border-radius: var(--radius);
  background: var(--surface);
  font-size: 0.88rem;
  color: var(--text-muted);
}

.disclaimer h2 {
  font-size: 1.1rem;
  color: var(--text);
  margin-bottom: 6px;
}

.disclaimer p {
  margin: 0;
}

@media (prefers-reduced-motion: reduce) {
  .bar,
  .chip {
    transition: none;
  }
}

@media print {
  .results {
    position: static;
  }

  .construction,
  .chips,
  .mix {
    display: none;
  }
}

/* EV consumption scale: best to worst real-world figure, average marked, yours as a dot */
.scale {
  position: relative;
  height: 40px;
  margin: 12px 4px 0;
}

.scale-track {
  position: relative;
  height: 8px;
  border-radius: 4px;
  background: linear-gradient(to right, #4ade80 0%, #4ade80 18%, #fbbf24 55%, #f87171 85%);
  opacity: 0.85;
}

.scale-tick {
  position: absolute;
  top: -3px;
  width: 2px;
  height: 14px;
  margin-left: -1px;
  background: var(--text-muted);
}

.scale-tick--1 {
  background: var(--text);
}

.scale-you {
  position: absolute;
  top: 50%;
  width: 16px;
  height: 16px;
  margin: -8px 0 0 -8px;
  border-radius: 50%;
  background: var(--accent);
  border: 3px solid var(--bg);
  box-shadow: 0 0 0 2px var(--accent);
}

.scale-label {
  position: absolute;
  top: 16px;
  transform: translateX(-50%);
  font-size: 0.72rem;
  color: var(--text-muted);
  white-space: nowrap;
}

/* best and worst sit at the ends so they never run into the average's label */
.scale-label--0 {
  left: 0 !important;
  transform: none;
}

.scale-label--1 {
  color: var(--text);
}

.scale-label--2 {
  left: auto !important;
  right: 0;
  transform: none;
}

/* "why" panels: folded explanations under a field */
.why {
  margin-top: 8px;
  font-size: 0.85rem;
}

.why summary {
  cursor: pointer;
  color: var(--accent);
  font-weight: 600;
}

.why-body {
  margin-top: 6px;
  padding: 10px 12px;
  border-left: 2px solid var(--border);
  color: var(--text-muted);
}

.why-body p {
  margin: 0 0 8px;
}

.why-body strong {
  color: var(--text);
}

.why-body a {
  color: var(--text-muted);
}

.why-table {
  width: 100%;
  margin: 4px 0 10px;
  border-collapse: collapse;
  font-size: 0.8rem;
  font-variant-numeric: tabular-nums;
}

.why-table th,
.why-table td {
  padding: 4px 6px;
  border-bottom: 1px solid var(--border);
  text-align: right;
  white-space: nowrap;
}

.why-table th[scope="row"],
.why-table thead th:first-child {
  text-align: left;
  white-space: normal;
}

.why-table thead th {
  color: var(--text);
  font-weight: 600;
}

/* phones: just the two percentages, so the table fits without scrolling */
@media (max-width: 480px) {
  .why-table .raw {
    display: none;
  }
}

/* ------------------------------------------------------------ keep or finance: monthly stack */
.stack {
  display: grid;
  gap: 10px;
}

.stack-row {
  display: grid;
  grid-template-columns: 112px minmax(0, 1fr) 72px;
  align-items: center;
  gap: 10px;
  font-size: 0.88rem;
}

.stack-label {
  color: var(--text-muted);
}

.stack-track {
  height: 18px;
  background: var(--surface-2);
  border-radius: 4px;
  overflow: hidden;
}

.stack-bar {
  display: flex;
  height: 100%;
}

.stack-seg {
  height: 100%;
  transition: width 0.3s ease;
}

.stack-seg + .stack-seg {
  box-shadow: inset 2px 0 0 var(--surface);
}

.stack-seg--energy { background: var(--fuel); }
.stack-row:nth-child(2) .stack-seg--energy { background: var(--ev); }
.stack-seg--upkeep { background: #9aa4ae; }
.stack-seg--insurance { background: #fbbf24; }
.stack-seg--instalment { background: #c084fc; }

.stack-value {
  text-align: right;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

.stack-legend {
  flex-wrap: wrap;
  gap: 6px 14px;
  margin-top: 2px;
  font-size: 0.8rem;
}

.sq {
  display: inline-block;
  width: 10px;
  height: 10px;
  border-radius: 2px;
  vertical-align: -1px;
}

/* the legend's energy swatch is split: fuel / electricity */
.sq.stack-seg--energy {
  background: linear-gradient(to right, var(--fuel) 50%, var(--ev) 50%);
}

@media (max-width: 420px) {
  .stack-row {
    grid-template-columns: 92px minmax(0, 1fr) 64px;
    gap: 8px;
    font-size: 0.82rem;
  }
}

@media (prefers-reduced-motion: reduce) {
  .stack-seg {
    transition: none;
  }
}

/* phones: rates like 10.75 need more room than the trip's percentages, so two per row */
@media (max-width: 560px) {
  .field-row--fin {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

/* phones: each bar gets the full width, its label above it */
@media (max-width: 480px) {
  .stack-row {
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 4px 10px;
  }

  .stack-label {
    grid-column: 1 / -1;
  }
}
