/* Electric vs petrol car cost: page styles on top of the shared style.css.
   The cc- rules are a copy of the true cost of car ownership page's (car.css), so the two pages
   look alike without one depending on the other. The ev- rules are this page's own.
   Car colours: petrol rust, diesel ochre, hybrid slate, plug-in hybrid plum, electric evergreen. */


:root {
  --cc-dep: #bd3c1c; --cc-int: #d58b74; --cc-fuel: #b8862a; --cc-ins: #4d6079; --cc-up: #9aa9be; --cc-fee: #b5ab95;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) { --cc-dep: #d4735b; --cc-int: #a65a45; --cc-fuel: #c9a159; --cc-ins: #93a5bc; --cc-up: #5f6f88; --cc-fee: #77705f; }
}
:root[data-theme="dark"] { --cc-dep: #d4735b; --cc-int: #a65a45; --cc-fuel: #c9a159; --cc-ins: #93a5bc; --cc-up: #5f6f88; --cc-fee: #77705f; }

.cc-head { padding-block: 24px 4px; }
.cc-head h1 { font-size: var(--step-3); margin-top: 6px; }

.cc-work { display: grid; grid-template-columns: minmax(0, 1fr) 370px; gap: 28px 40px; align-items: start; padding-top: 16px; }
.cc-stage { display: grid; min-width: 0; }

.cc-answer { display: grid; gap: 2px; justify-items: start; }
.cc-answer .label { font-size: 0.8rem; font-weight: 600; color: var(--muted); }
.cc-answer .big { font-size: clamp(2.6rem, 2rem + 2.4vw, 4rem); }
.cc-answer .big small { font-size: 0.3em; margin-left: 6px; }
.cc-answer-line { color: var(--muted); font-size: 0.93rem; max-width: 62ch; margin-top: 6px; }
.cc-answer-line strong { color: var(--ink); font-weight: 600; }

.cc-figure { margin: 0; padding-top: 12px; }
.cc-legend-row { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: 6px 24px; padding-top: 8px; }
.cc-legend-row .hint { font-size: 0.8rem; }
.cc-legend-row .legend { gap: 4px 14px; }
.cc-key { display: inline-flex; align-items: center; gap: 6px; }
.cc-sw { width: 11px; height: 11px; border-radius: 2px; display: inline-block; flex: none; }
.c-dep { --c: var(--cc-dep); } .c-int { --c: var(--cc-int); } .c-fuel { --c: var(--cc-fuel); }
.c-ins { --c: var(--cc-ins); } .c-up { --c: var(--cc-up); } .c-fee { --c: var(--cc-fee); }
.cc-sw, .cc-bar-fill { background: var(--c); }

/* chart marks */
.chart-box .cc-seg-r { fill: var(--c); stroke: var(--paper); stroke-width: 1; }
.chart-box .cc-total { font-size: 11px; font-weight: 600; fill: var(--muted); }
.chart-box .cc-avg { stroke: var(--ink); stroke-width: 1.2; stroke-dasharray: 4 4; }
.chart-box .cc-avg-label { font-family: var(--font-body); font-style: normal; font-size: 12.5px; font-weight: 600; fill: var(--ink); }
.chart-box .cc-lab-v { font-size: 12px; font-weight: 700; fill: var(--ink); }
.chart-box .cc-lab-s { font-size: 11px; fill: var(--muted); }
.chart-box .cc-lab-tick { stroke: var(--muted); stroke-width: 1; }
.chart-box .cc-hi { fill: var(--ink); fill-opacity: 0.06; }
.chart-box .cc-halo { paint-order: stroke; stroke: var(--paper); stroke-width: 4px; stroke-linejoin: round; }
.tip .t-sw { display: inline-flex; align-items: center; gap: 6px; }
.tip .t-total { border-top: 1px solid var(--line); margin-top: 4px; padding-top: 5px; font-weight: 600; }
.tip .t-total span:first-child { color: var(--ink); }

/* stats */
.cc-stats { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); margin-top: 22px; border-top: 1px solid var(--ink); border-bottom: 1px solid var(--line); }
.cc-stat { padding: 12px 16px 14px 0; display: grid; gap: 2px; align-content: start; min-width: 0; }
.cc-stat + .cc-stat { padding-left: 16px; border-left: 1px solid var(--line); }
.cc-stat .label { font-size: 0.76rem; font-weight: 600; color: var(--muted); }
.cc-stat .v { font-family: var(--font-display); font-weight: 500; font-size: 1.5rem; font-variant-numeric: lining-nums tabular-nums; line-height: 1.2; overflow-wrap: anywhere; }
.cc-stat .sub { font-size: 0.8rem; color: var(--muted); font-variant-numeric: tabular-nums; }
.cc-stat .sub.is-warn { color: var(--rust); font-weight: 600; }

/* inputs */
.cc-panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px 18px; display: grid; gap: 4px; min-width: 0; position: sticky; top: 12px; }
.cc-panel-head { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding-bottom: 12px; }
.cc-panel-head h2 { flex: none; font-size: 1.3rem; white-space: nowrap; }
.cc-panel-head .btn-row { flex: 0 1 auto; flex-wrap: nowrap; gap: 4px; min-width: 0; justify-content: flex-end; }
.cc-panel-head .inline-field { min-width: 0; flex: 0 1 auto; }
.cc-panel-head .inline-field select { max-width: 10rem; width: 100%; min-width: 0; }
.cc-panel-head .btn-ghost { padding-inline: 6px; }
.cc-form { display: grid; border-top: 1px solid var(--ink); }
.cc-group { border: 0; margin: 0; padding: 12px 0; display: grid; gap: 8px; min-width: 0; align-content: start; }
.cc-group + .cc-group { border-top: 1px solid var(--line); }
.cc-group:last-child { padding-bottom: 6px; }
.cc-group legend { float: left; padding: 0; font-family: var(--font-display); font-size: 1.05rem; }
.cc-group > legend { width: 100%; }
.cc-group legend + * { clear: both; }
.cc-legend-line { display: flex; justify-content: space-between; align-items: center; gap: 10px; }
.cc-legend-line legend { float: none; width: auto; }
.cc-seg { display: inline-flex; border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.cc-seg button { border: 0; background: var(--paper); color: var(--muted); font-weight: 600; font-size: 0.78rem; cursor: pointer; padding: 5px 9px; white-space: nowrap; }
.cc-seg button + button { border-left: 1px solid var(--line); }
.cc-seg button:hover { color: var(--ink); }
.cc-seg button[aria-pressed="true"] { background: var(--gold-soft); color: var(--gold); }
.cc-seg button:focus-visible { outline: 2px solid var(--focus); outline-offset: -2px; }
.cc-row3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px 10px; }
.cc-row3 .field label { font-size: 0.8rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cc-group .hint { font-size: 0.8rem; }
.cc-panel .privacy { margin-top: 6px; }
.cc-panel input[type="text"] { min-height: 40px; }
.cc-panel .pct input { padding-right: 46px; }
.cc-panel .pct span { font-size: 0.85rem; }
.cc-errs:empty { display: none; }
.cc-errs { display: grid; }

/* sections */
.cc-section { padding-top: 64px; }
.cc-section-head { display: grid; gap: 8px; margin-bottom: 14px; }
.cc-msg { font-size: 1.05rem; max-width: 70ch; }
.cc-msg b { font-weight: 700; }
.cc-msg .c-own { color: var(--rust); }

/* where each km goes */
.cc-ledger { display: grid; border-top: 1px solid var(--ink); max-width: 900px; font-variant-numeric: tabular-nums; }
.cc-lr { display: grid; grid-template-columns: minmax(9rem, 13rem) minmax(0, 1fr) 6.5rem 7.5rem; gap: 6px 16px; align-items: center; padding: 9px 0; border-bottom: 1px solid var(--line); }
.cc-lr.cc-lr-head { padding: 7px 0; font-size: 0.76rem; font-weight: 600; color: var(--muted); }
.cc-lr .n { display: inline-flex; align-items: center; gap: 8px; font-weight: 600; }
.cc-lr .r { text-align: right; white-space: nowrap; }
.cc-lr .pk { font-family: var(--font-display); font-size: 1.08rem; }
.cc-bar { height: 12px; background: var(--grid); border-radius: 2px; overflow: hidden; display: flex; align-items: center; }
.cc-bar-fill { height: 100%; border-radius: 2px; }
.cc-bar-cell { display: flex; align-items: center; gap: 10px; min-width: 0; }
.cc-bar-cell .cc-bar { flex: 1; }
.cc-bar-cell .pc { font-size: 0.8rem; color: var(--muted); width: 2.6rem; text-align: right; flex: none; }
.cc-lr.cc-lr-total { border-bottom: 1px solid var(--ink); font-weight: 700; }
.cc-lr.cc-lr-total .pk { font-weight: 600; }

/* year by year */
.cc-yt-scroll { overflow-x: auto; margin-top: 8px; }
.cc-yt { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; font-size: 0.93rem; border-top: 1px solid var(--ink); }
.cc-yt th, .cc-yt td { padding: 7px 12px 7px 0; border-bottom: 1px solid var(--line); text-align: right; white-space: nowrap; }
.cc-yt th:first-child, .cc-yt td:first-child { text-align: left; }
.cc-yt thead th { font-size: 0.76rem; color: var(--muted); font-weight: 600; }
.cc-yt tbody th { font-weight: 600; }
.cc-yt td.z { color: var(--muted); }
.cc-yt td.t { font-weight: 600; }
.cc-yt tfoot th, .cc-yt tfoot td { font-weight: 700; border-bottom: 1px solid var(--ink); }
.cc-yt-note { margin-top: 10px; }

@media (max-width: 1200px) and (min-width: 961px) { .cc-work { grid-template-columns: minmax(0, 1fr) 350px; gap: 28px; } }
@media (max-width: 960px) {
  .cc-work { grid-template-columns: minmax(0, 1fr); gap: 0; }
  .cc-stage { display: contents; }
  .cc-answer { order: 1; }
  .cc-stage .cc-figure { order: 2; }
  .cc-panel { order: 3; margin-top: 18px; position: static; }
  .cc-stats { order: 4; margin-top: 28px; }
}
@media (max-width: 960px) and (min-width: 700px) {
  .cc-form { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); column-gap: 20px; }
  .cc-form .cc-group:first-child { grid-row: span 2; }
  .cc-form .cc-group:nth-child(2) { border-top: 0; }
  .cc-form .cc-group:nth-child(n+2) { border-left: 1px solid var(--line); padding-left: 20px; }
}
@media (max-width: 640px) {
  .cc-stats { grid-template-columns: minmax(0, 1fr); }
  .cc-stat + .cc-stat { padding-left: 0; border-left: 0; border-top: 1px solid var(--line); }
  .cc-stat { grid-template-columns: minmax(0, 1fr) auto; align-items: baseline; column-gap: 12px; padding-right: 0; }
  .cc-stat .label { grid-column: 1; }
  .cc-stat .v { grid-column: 2; grid-row: 1 / span 2; text-align: right; font-size: 1.3rem; }
  .cc-stat .sub { grid-column: 1; grid-row: 2; }
  .cc-lr { grid-template-columns: minmax(0, 1fr) 5rem 5.6rem; grid-template-areas: "n pk tot" "bar bar bar"; gap: 6px 10px; }
  .cc-lr .n { grid-area: n; } .cc-lr .pk { grid-area: pk; } .cc-lr .tot { grid-area: tot; } .cc-lr .cc-bar-cell { grid-area: bar; }
  .cc-lr.cc-lr-head { grid-template-areas: "n pk tot"; }
  .cc-lr.cc-lr-head .cc-bar-cell, .cc-lr.cc-lr-total .cc-bar-cell { display: none; }
  .cc-lr.cc-lr-total { grid-template-areas: "n pk tot"; }
}
@media (max-width: 600px) {
  .cc-head { padding-block: 16px 0; }
  .cc-head .eyebrow { display: none; }
  .cc-head h1 { font-size: 1.4rem; }
  .cc-answer .label { font-size: 0.76rem; }
  .cc-answer .big { font-size: 2.3rem; }
  .cc-answer .big small { font-size: 0.4em; }
  .cc-answer-line { font-size: 0.86rem; }
  .cc-answer-line .cc-more { display: none; }
  .cc-figure { padding-top: 6px; }
  .cc-hover-hint { display: none; }
  .cc-panel { padding: 14px; margin-inline: -4px; }
  .cc-panel-head h2 { font-size: 1.2rem; }
  .cc-panel-head { padding-bottom: 10px; }
  .cc-section { padding-top: 52px; }
  .cc-yt { font-size: 0.84rem; }
  .cc-yt th, .cc-yt td { padding-right: 9px; }
  .cc-seg button { padding: 5px 7px; }
}
.cc-yt tr.cc-yt-sum th, .cc-yt tr.cc-yt-sum td { font-weight: 700; border-top: 1px solid var(--ink); border-bottom: 1px solid var(--ink); }
body.cc-has-errors .cc-answer, body.cc-has-errors .cc-figure, body.cc-has-errors .cc-stats, body.cc-has-errors #where, body.cc-has-errors #years { opacity: 0.4; transition: opacity 0.15s; }

/* Tighter panel on desktop, so all the inputs fit beside the chart on one screen. */
@media (min-width: 961px) {
  .cc-panel { padding-top: 12px; }
  .cc-panel-head { padding-bottom: 8px; }
  .cc-group { padding: 9px 0; gap: 6px; }
  .cc-group .hint { font-size: 0.76rem; line-height: 1.4; }
}

/* ---------- electric vs petrol ---------- */
:root { --ev-petrol: #bd3c1c; --ev-diesel: #8a6418; --ev-hybrid: #4d6079; --ev-phev: #7d4f86; --ev-electric: #1f4732; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) { --ev-petrol: #d4735b; --ev-diesel: #c9a159; --ev-hybrid: #93a5bc; --ev-phev: #c8a0d2; --ev-electric: #94c4a1; }
}
:root[data-theme="dark"] { --ev-petrol: #d4735b; --ev-diesel: #c9a159; --ev-hybrid: #93a5bc; --ev-phev: #c8a0d2; --ev-electric: #94c4a1; }
.ev-petrol { --c: var(--ev-petrol); } .ev-diesel { --c: var(--ev-diesel); } .ev-hybrid { --c: var(--ev-hybrid); }
.ev-phev { --c: var(--ev-phev); } .ev-electric { --c: var(--ev-electric); }
.ev-chip { width: 11px; height: 11px; border-radius: 50%; display: inline-block; flex: none; background: var(--c); }

/* chart */
.chart-box .ev-line { fill: none; stroke: var(--c); stroke-width: 2.2; stroke-linejoin: round; stroke-linecap: round; }
.chart-box .ev-line.ev-best { stroke-width: 3; }
.chart-box .ev-line.ev-base { stroke-width: 1.8; }
.chart-box .ev-a-more { fill: var(--rust); fill-opacity: 0.1; }
.chart-box .ev-a-less { fill: var(--gold-area); fill-opacity: 0.16; }
.chart-box .ev-end { fill: var(--c); stroke: var(--paper); stroke-width: 1.5; }
.chart-box .ev-hover { fill: var(--c); stroke: var(--paper); stroke-width: 2; }
.chart-box .ev-cursor { stroke: var(--ink); stroke-width: 1; stroke-dasharray: 3 3; opacity: 0.6; }
.chart-box .ev-cross { fill: var(--paper); stroke: var(--ink); stroke-width: 1.4; }
.chart-box .ev-cross-key-dot { stroke-width: 2.2; }
.chart-box .ev-cross-l { font-size: 12px; font-weight: 700; fill: var(--ink); }
.chart-box [class*="ev-t-"] tspan:first-child { fill: var(--c); }
.ev-t-petrol { --c: var(--ev-petrol); } .ev-t-diesel { --c: var(--ev-diesel); } .ev-t-hybrid { --c: var(--ev-hybrid); }
.ev-t-phev { --c: var(--ev-phev); } .ev-t-electric { --c: var(--ev-electric); }
.ev-cross-key { width: 10px; height: 10px; border-radius: 50%; border: 2px solid var(--ink); background: var(--paper); display: inline-block; box-sizing: border-box; }
.tip .ev-t-best span:last-child { font-weight: 700; }
.tip .ev-t-gap { border-top: 1px solid var(--line); margin-top: 4px; padding-top: 5px; }
.tip .ev-t-gap span:last-child { font-weight: 600; }

/* stats: one per car */
.ev-stats { grid-template-columns: repeat(var(--n, 3), minmax(0, 1fr)); }
.ev-stats .label { display: inline-flex; align-items: center; gap: 6px; }

/* picking cars */
.ev-pick { display: flex; flex-wrap: wrap; gap: 6px; }
.ev-pick button { display: inline-flex; align-items: center; gap: 6px; border: 1px solid var(--line); background: var(--paper); color: var(--muted); font: inherit; font-size: 0.82rem; font-weight: 600; padding: 5px 10px; cursor: pointer; border-radius: 999px; }
.ev-pick button .ev-chip { background: transparent; box-shadow: inset 0 0 0 1.5px var(--c); }
.ev-pick button[aria-pressed="true"] { color: var(--ink); border-color: var(--c); background: var(--surface); }
.ev-pick button[aria-pressed="true"] .ev-chip { background: var(--c); }
.ev-pick button:hover { color: var(--ink); }
.ev-pick button:focus-visible { outline: 2px solid var(--focus); outline-offset: 1px; }
.ev-pick-msg:empty { display: none; }
.ev-pick-msg { color: var(--rust); }
.ev-row2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.cc-row3 .field[hidden] { display: none; }

/* the cars, folded away */
.ev-details { display: block; }
.ev-details > summary { cursor: pointer; list-style: none; display: flex; flex-wrap: wrap; align-items: baseline; gap: 2px 10px; padding-right: 22px; position: relative; }
.ev-details > summary::-webkit-details-marker { display: none; }
.ev-details > summary::after { content: ""; position: absolute; right: 4px; top: 7px; width: 7px; height: 7px; border-right: 1.5px solid var(--ink); border-bottom: 1.5px solid var(--ink); transform: rotate(45deg); transition: transform 0.15s; }
.ev-details[open] > summary::after { transform: rotate(-135deg); top: 10px; }
.ev-sum-t { font-family: var(--font-display); font-size: 1.05rem; }
.ev-sum-s { font-size: 0.8rem; color: var(--muted); }
.ev-cars-wrap { margin-top: 10px; overflow-x: auto; }
.ev-details .hint { margin-top: 8px; font-size: 0.78rem; }
.ev-cars { width: 100%; border-collapse: collapse; table-layout: fixed; }
.ev-cars th, .ev-cars td { padding: 3px 0 3px 4px; vertical-align: middle; }
.ev-cars thead th { font-size: 0.72rem; font-weight: 600; text-align: left; padding-bottom: 4px; vertical-align: bottom; line-height: 1.2; }
.ev-cars thead th:first-child { width: 5.2rem; padding-left: 0; }
.ev-cars thead .ev-chip { display: block; width: 9px; height: 9px; margin-bottom: 3px; }
.ev-th { display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ev-cars tbody th { text-align: left; font-weight: 600; font-size: 0.76rem; padding-left: 0; line-height: 1.2; }
.ev-rl { display: block; }
.ev-ru { display: block; font-weight: 400; color: var(--muted); font-size: 0.7rem; white-space: nowrap; }
.cc-panel .ev-cars input[type="text"] { width: 100%; min-height: 34px; padding: 4px 4px; font-size: 0.82rem; font-variant-numeric: tabular-nums; letter-spacing: -0.01em; }
.ev-cars td.ev-na { color: var(--muted); text-align: center; font-size: 0.85rem; }
.ev-errs:empty { display: none; }
.ev-errs { margin-top: 4px; }

/* what each km costs */
.ev-bd-legend { margin-bottom: 10px; gap: 4px 14px; }
.ev-bd { display: grid; border-top: 1px solid var(--ink); max-width: 900px; }
.ev-bd-row { padding: 12px 0 10px; border-bottom: 1px solid var(--line); display: grid; gap: 6px; }
.ev-bd-head { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; }
.ev-bd-head .n { display: inline-flex; align-items: center; gap: 8px; font-weight: 600; }
.ev-bd-tot { font-family: var(--font-display); font-size: 1.2rem; font-variant-numeric: lining-nums tabular-nums; }
.ev-bd-tot small { font-family: var(--font-body); font-size: 0.78rem; color: var(--muted); margin-left: 4px; }
.ev-bd-bar { display: flex; height: 22px; gap: 1px; }
.ev-seg { background: var(--c); display: flex; align-items: center; justify-content: center; min-width: 1px; overflow: hidden; }
.ev-seg-v { font-size: 0.72rem; font-weight: 600; color: var(--paper); white-space: nowrap; font-variant-numeric: tabular-nums; }
.ev-seg.c-up .ev-seg-v, .ev-seg.c-fee .ev-seg-v { color: var(--ink); }
.ev-bd-words { font-size: 0.8rem; color: var(--muted); font-variant-numeric: tabular-nums; margin: 0; }
body.cc-has-errors #stats { opacity: 0.4; }

@media (max-width: 640px) {
  .ev-stats { grid-template-columns: minmax(0, 1fr); }
  .ev-seg-v { font-size: 0.66rem; }
}

/* Keep the currency picker readable: it used to shrink to an empty box once Share joined Reset.
   When "Your numbers" and the buttons don't fit on one line, the buttons move under the title. */
.cc-panel-head { flex-wrap: wrap; row-gap: 8px; }
.cc-panel-head .btn-row { flex: 0 0 auto; max-width: 100%; flex-wrap: wrap; row-gap: 6px; }
.cc-panel-head .inline-field { flex: 0 0 auto; }
.cc-panel-head .inline-field select { width: 8rem; min-width: 8rem; max-width: 8rem; }
