/* Solar + EV charging calculator. Builds on style.css tokens; only the calculator's own parts live here. */
:root {
  --sev-s1: #2a78d6;   /* charged the car directly */
  --sev-s2: #eb6834;   /* sent to the grid */
  --sev-line: #45565e; /* car's monthly need */
}
@media (prefers-color-scheme: dark) {
  :root { --sev-s1: #3987e5; --sev-s2: #d95926; --sev-line: #b9c8cf; }
}

/* style.css has no [hidden] rule, and .sev-field sets display:grid, so hidden fields would still show */
.sev-grid-layout [hidden] { display: none !important; }
.sev-grid-layout { display: grid; grid-template-columns: minmax(260px, 330px) minmax(0, 1fr); gap: 28px; align-items: start; margin-top: 24px; }
@media (max-width: 860px) { .sev-grid-layout { grid-template-columns: minmax(0, 1fr); } }

/* ---- form ---- */
.sev-panel { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px 16px 18px; display: grid; gap: 22px; }
.sev-group { display: grid; gap: 12px; }
.sev-group h2 { font-size: 12px; font-weight: 600; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); margin: 0; }
.sev-field { display: grid; gap: 5px; min-width: 0; }
.sev-field label { font-size: 14px; font-weight: 600; }
.sev-hint { font-size: 12.5px; color: var(--muted); line-height: 1.45; margin: 0; }
.sev-hint:empty { display: none; }
.sev-panel select, .sev-panel input[type="number"] {
  font: inherit; font-size: 15px; color: var(--text); background: var(--bg);
  border: 1px solid var(--border); border-radius: 8px; padding: 8px 10px; width: 100%; min-width: 0;
}
.sev-panel select:focus-visible, .sev-panel input:focus-visible, .sev-linkbtn:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.sev-unit { position: relative; }
.sev-unit input { padding-right: 70px; }
.sev-unit span { position: absolute; right: 10px; top: 50%; transform: translateY(-50%); font-size: 12px; color: var(--muted); pointer-events: none; }
.sev-row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.sev-seg { position: relative; display: grid; grid-template-columns: 1fr 1fr; gap: 6px; border: 0; margin: 0; padding: 0; min-width: 0; }
.sev-seg legend { font-size: 14px; font-weight: 600; margin-bottom: 6px; padding: 0; }
.sev-seg input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.sev-seg label { display: grid; gap: 1px; border: 1px solid var(--border); border-radius: 8px; padding: 8px 10px; cursor: pointer; background: var(--bg); font-size: 13.5px; font-weight: 600; line-height: 1.25; }
.sev-seg label small { font-weight: 400; color: var(--muted); font-size: 12px; }
.sev-seg input:checked + label { border-color: var(--accent); background: var(--accent-soft); }
.sev-seg input:focus-visible + label { outline: 2px solid var(--accent); outline-offset: 2px; }
.sev-rule { font-size: 12.5px; line-height: 1.5; background: var(--accent-soft); border: 1px solid var(--border); border-radius: 8px; padding: 9px 11px; margin: 0; }
.sev-rule:empty { display: none; }
.sev-rule strong { font-weight: 600; }
.sev-src { display: block; margin-top: 4px; color: var(--muted); }
.sev-src a { color: var(--muted); }
details.sev-adv summary { cursor: pointer; font-size: 14px; font-weight: 600; color: var(--muted); }
details.sev-adv[open] summary { margin-bottom: 12px; }
details.sev-adv .sev-inner { display: grid; gap: 12px; }

/* ---- results ---- */
.sev-results { display: grid; gap: 22px; min-width: 0; }
.sev-results[aria-busy="true"] { opacity: .55; }
.sev-answer p { margin: 0 0 6px; max-width: 68ch; }
.sev-answer .sev-big { font-size: clamp(19px, 2.4vw, 23px); line-height: 1.3; font-weight: 600; letter-spacing: -0.2px; }
.sev-figs { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); }
.sev-fig { padding: 13px 15px; display: grid; gap: 2px; align-content: start; border-left: 1px solid var(--border); }
.sev-fig:first-child { border-left: 0; }
.sev-fig .k { font-size: 13px; color: var(--muted); }
.sev-fig .v { font-size: 24px; font-weight: 700; letter-spacing: -0.5px; line-height: 1.2; font-variant-numeric: tabular-nums; }
.sev-fig .s { font-size: 12.5px; color: var(--muted); }
@media (max-width: 640px) {
  .sev-figs { grid-template-columns: 1fr 1fr; }
  .sev-fig:nth-child(3) { border-left: 0; }
  .sev-fig:nth-child(n+3) { border-top: 1px solid var(--border); }
}
.sev-flow { display: grid; grid-template-columns: repeat(auto-fit, minmax(128px, 1fr)); gap: 10px 16px; font-size: 13.5px; color: var(--muted); }
.sev-flow div { display: grid; gap: 1px; }
.sev-flow b { font-weight: 600; color: var(--text); font-variant-numeric: tabular-nums; font-size: 15px; }
.sev-card { border: 1px solid var(--border); border-radius: var(--radius); padding: 16px; min-width: 0; }
.sev-card h2 { margin: 0 0 4px; font-size: 18px; }
.sev-card .sev-sub { font-size: 13px; color: var(--muted); margin: 0 0 12px; max-width: 72ch; }
.sev-legend { display: flex; flex-wrap: wrap; gap: 6px 16px; font-size: 12.5px; color: var(--muted); margin-bottom: 8px; }
.sev-legend span { display: inline-flex; align-items: center; gap: 6px; }
.sev-sw { width: 12px; height: 12px; border-radius: 3px; display: inline-block; }
.sev-sw.sev-s1, .sev-tip i.sev-s1 { background: var(--sev-s1); }
.sev-sw.sev-s2, .sev-tip i.sev-s2 { background: var(--sev-s2); }
.sev-sw.sev-l { height: 2px; width: 16px; border-radius: 1px; background: var(--sev-line); position: relative; }
.sev-sw.sev-l::after { content: ""; position: absolute; left: 4px; top: -3px; width: 8px; height: 8px; border-radius: 50%; background: var(--sev-line); }
.sev-chart { position: relative; }
.sev-chart svg { display: block; width: 100%; height: auto; overflow: visible; }
.sev-chart .sev-grid line { stroke: var(--border); stroke-width: 1; }
.sev-chart .sev-axis text { font-size: 11px; fill: var(--muted); }
.sev-chart .sev-s1 { fill: var(--sev-s1); }
.sev-chart .sev-s2 { fill: var(--sev-s2); }
.sev-chart .sev-need { fill: none; stroke: var(--sev-line); stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.sev-chart .sev-dot { fill: var(--sev-line); stroke: var(--bg); stroke-width: 2; }
.sev-chart .sev-hit { fill: transparent; }
.sev-tip { position: absolute; pointer-events: none; background: var(--bg); border: 1px solid var(--border); border-radius: 8px; padding: 8px 10px; font-size: 12.5px; box-shadow: 0 4px 16px rgba(0,0,0,.14); min-width: 180px; z-index: 2; }
.sev-tip b { display: block; font-size: 13px; margin-bottom: 4px; }
.sev-tip div { display: flex; justify-content: space-between; gap: 12px; font-variant-numeric: tabular-nums; }
.sev-tip i { display: inline-block; width: 8px; height: 8px; border-radius: 2px; margin-right: 6px; }
.sev-linkbtn { font: inherit; font-size: 13px; background: none; border: 0; padding: 0; color: var(--accent); cursor: pointer; text-decoration: underline; text-underline-offset: 2px; margin-top: 6px; }
.sev-table { margin-top: 10px; }
#sev-matrix th, #sev-matrix td { padding: 7px 8px; font-size: 13px; }
#sev-matrix th small { display: block; font-weight: 400; font-size: 11px; }
#sev-matrix td.sev-cur { background: var(--accent-soft); font-weight: 700; box-shadow: inset 0 0 0 2px var(--accent); }
.sev-rules td { white-space: normal; vertical-align: top; }
.sev-rules td:first-child { white-space: nowrap; }

/* rules table: stack each state into a block on phones instead of squeezing five columns */
@media (max-width: 640px) {
  .sev-rules { border: 0; }
  .sev-rules table, .sev-rules tbody, .sev-rules tr, .sev-rules td { display: block; width: 100%; }
  .sev-rules thead { display: none; }
  .sev-rules tr { border: 1px solid var(--border); border-radius: var(--radius); padding: 10px 12px; margin-bottom: 10px; }
  .sev-rules td { border: 0; padding: 2px 0; white-space: normal; }
  .sev-rules td:first-child { font-weight: 600; font-size: 15px; }
  .sev-rules tbody tr:hover td { background: none; }
}
