/* ============================================================
   Voltwise — styles
   Palette: paper, surface, ink, sun (daytime energy),
   night (battery energy), leaf (savings / OK), alert.
   ============================================================ */

:root {
  --paper: #ffffff;
  --surface: #f2f4f7;
  --line: #dde2ea;
  --ink: #18212f;
  --ink-2: #4a5568;
  --ink-3: #6b7685;
  --sun: #f2b705;
  --sun-soft: #fff4cc;
  --night: #26346b;
  --night-soft: #e6e9f5;
  --leaf: #1e7f55;
  --leaf-soft: #e3f3eb;
  --alert: #b42318;
  --alert-soft: #fdecea;
  --focus: #2f6fed;

  --display: "Bricolage Grotesque", "Segoe UI", system-ui, sans-serif;
  --body: "Manrope", "Segoe UI", system-ui, sans-serif;

  --r-sm: 6px;
  --r-md: 10px;
  --r-lg: 16px;
  --gutter: 16px;
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }
@media (prefers-reduced-motion: reduce) { html { scroll-behavior: auto; } * { transition: none !important; } }

body {
  margin: 0;
  background: var(--surface);
  color: var(--ink);
  font: 16px/1.55 var(--body);
  font-variant-numeric: tabular-nums;
}

h1, h2, h3 { font-family: var(--display); line-height: 1.15; margin: 0; }
h1 { font-size: clamp(1.9rem, 4.5vw, 3rem); font-weight: 700; letter-spacing: -0.02em; max-width: 18ch; }
h2 { font-size: 1.25rem; font-weight: 700; }
h3 { font-size: 1.05rem; font-weight: 700; }
p { margin: 0; }
a { color: var(--night); }

:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; border-radius: 4px; }

.wrap { max-width: 1240px; margin: 0 auto; padding: 0 var(--gutter); }
.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.skip { position: absolute; left: -999px; top: 8px; background: var(--paper); padding: 8px 12px; z-index: 50; }
.skip:focus { left: 8px; }

/* ── Masthead ─────────────────────────────── */
.masthead { background: var(--paper); border-bottom: 1px solid var(--line); }
.masthead-row { display: flex; align-items: center; justify-content: space-between; height: 60px; gap: 12px; }
.brand { display: flex; align-items: center; gap: 10px; text-decoration: none; color: var(--ink); font-family: var(--display); font-weight: 700; font-size: 1.1rem; }
.brand img { border-radius: 6px; }
.brand-sub { color: var(--ink-3); font-weight: 500; }

.mode { display: inline-flex; background: var(--surface); border-radius: 999px; padding: 3px; }
.mode button { border: 0; background: transparent; font: 600 0.9rem var(--body); color: var(--ink-2); padding: 6px 14px; border-radius: 999px; cursor: pointer; }
.mode button[aria-checked="true"] { background: var(--ink); color: var(--paper); }

body:not(.expert) .expert-only { display: none !important; }

/* ── Intro ────────────────────────────────── */
.intro { padding-top: 40px; padding-bottom: 28px; }
.lede { margin-top: 14px; font-size: 1.08rem; color: var(--ink-2); max-width: 62ch; }

/* ── Layout ───────────────────────────────── */
.layout { display: grid; grid-template-columns: minmax(0, 1fr) 400px; gap: 24px; align-items: start; }
.inputs, .plan { min-width: 0; }
@media (max-width: 1020px) { .layout { grid-template-columns: 1fr; } }

.block { background: var(--paper); border-radius: var(--r-lg); padding: 22px; margin-bottom: 16px; border: 1px solid var(--line); }
.block > h2, .block-head { margin-bottom: 14px; }
.block-head { display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; gap: 8px 16px; }
.block-actions { display: flex; gap: 16px; flex-wrap: wrap; }

.field-row { display: flex; flex-wrap: wrap; gap: 14px; }
.field-row + .field-row { margin-top: 14px; }
.field { display: flex; flex-direction: column; gap: 6px; min-width: 150px; border: 0; padding: 0; margin: 0; }
.field.grow { flex: 1 1 220px; }
.field > span, .field > legend { font-size: 0.88rem; font-weight: 600; color: var(--ink-2); padding: 0; }
input, select { font: inherit; color: var(--ink); }
.field input, .field select, .search input {
  border: 1px solid var(--line); border-radius: var(--r-sm); padding: 10px 12px; background: var(--paper); width: 100%;
}
.hint { margin-top: 8px; font-size: 0.88rem; color: var(--ink-3); max-width: 70ch; }

.seg { display: inline-flex; border: 1px solid var(--line); border-radius: var(--r-sm); overflow: hidden; }
.seg label { position: relative; }
.seg input { position: absolute; opacity: 0; inset: 0; cursor: pointer; }
.seg span { display: block; padding: 9px 16px; font-weight: 600; color: var(--ink-2); }
.seg input:checked + span { background: var(--ink); color: var(--paper); }
.seg input:focus-visible + span { outline: 3px solid var(--focus); outline-offset: -3px; }

button { font: inherit; cursor: pointer; }
.link { background: none; border: 0; padding: 0; color: var(--night); font-weight: 600; text-decoration: underline; text-underline-offset: 3px; font-size: 0.93rem; }
.primary { background: var(--ink); color: var(--paper); border: 0; border-radius: var(--r-sm); padding: 11px 18px; font-weight: 700; }
.primary:hover { background: #2a3547; }
.ghost { background: var(--paper); border: 1px dashed #b8c0cc; border-radius: var(--r-sm); padding: 9px 14px; font-weight: 600; color: var(--ink-2); }
.ghost:hover { border-color: var(--ink-2); color: var(--ink); }

/* ── Device picker ────────────────────────── */
.picker { background: var(--surface); border-radius: var(--r-md); padding: 14px; margin-bottom: 18px; }
.search input { background: var(--paper); }
.chips { display: flex; gap: 6px; overflow-x: auto; padding: 12px 0 10px; scrollbar-width: thin; }
.chips button { flex: none; border: 1px solid var(--line); background: var(--paper); border-radius: 999px; padding: 5px 12px; font-size: 0.86rem; font-weight: 600; color: var(--ink-2); }
.chips button[aria-selected="true"] { background: var(--night); border-color: var(--night); color: var(--paper); }
.catalog { list-style: none; margin: 0 0 12px; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 6px; max-height: 300px; overflow-y: auto; }
.catalog button { width: 100%; text-align: left; background: var(--paper); border: 1px solid var(--line); border-radius: var(--r-sm); padding: 8px 10px; display: flex; justify-content: space-between; gap: 8px; align-items: baseline; }
.catalog button:hover { border-color: var(--ink-3); }
.catalog .w { color: var(--ink-3); font-size: 0.82rem; white-space: nowrap; }
.catalog .count { background: var(--night); color: #fff; border-radius: 999px; font-size: 0.75rem; padding: 0 7px; margin-left: 6px; }

/* ── Loads table ──────────────────────────── */
.loads-wrap { overflow-x: auto; position: relative; }
.loads { width: 100%; border-collapse: collapse; font-size: 0.93rem; }
.loads th { text-align: left; font-size: 0.8rem; font-weight: 600; color: var(--ink-3); padding: 6px 6px; border-bottom: 1px solid var(--line); white-space: nowrap; }
.loads td { padding: 6px; border-bottom: 1px solid var(--surface); vertical-align: middle; }
.loads .num { text-align: right; }
.loads input, .loads select { border: 1px solid transparent; border-radius: 4px; padding: 5px 6px; background: var(--surface); width: 100%; }
.loads input[type="number"] { width: 72px; text-align: right; }
.loads input:hover, .loads select:hover { border-color: var(--line); }
.loads input.name { min-width: 150px; background: transparent; font-weight: 600; }
body.expert .loads input.name { min-width: 190px; }
.loads select { min-width: 140px; }
.loads .tip { display: block; font-size: 0.78rem; color: var(--ink-3); padding-left: 7px; max-width: 46ch; }
.loads .wh { font-weight: 700; white-space: nowrap; }
.loads .when-dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-right: 6px; vertical-align: middle; }
.remove { background: none; border: 0; color: var(--ink-3); font-size: 1.2rem; line-height: 1; padding: 4px 8px; border-radius: 4px; }
.remove:hover { color: var(--alert); background: var(--alert-soft); }
.empty { padding: 18px 4px; color: var(--ink-3); }
.loads tfoot td { font-weight: 700; border-bottom: 0; padding-top: 10px; }

.advanced { margin-top: 16px; border-top: 1px solid var(--line); padding-top: 12px; }
.advanced summary { font-weight: 700; cursor: pointer; }
.grid-settings { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 12px; margin-top: 12px; }
.grid-settings .field { min-width: 0; }
.grid-settings small { color: var(--ink-3); font-size: 0.78rem; }

/* ── Plan sheet (the live result) ─────────── */
.plan { position: sticky; top: 16px; }
@media (max-width: 1020px) { .plan { position: static; } }
.sheet { background: var(--paper); border-radius: var(--r-lg); border: 1px solid var(--line); padding: 22px; }
.plan-kicker { color: var(--ink-2); font-size: 0.95rem; }
.plan-kicker strong { font-family: var(--display); font-size: 2.1rem; color: var(--ink); display: block; line-height: 1.1; letter-spacing: -0.01em; }

/* The day / night bar — the one bold element */
.daynight { margin: 18px 0 6px; }
.dn-bar { display: flex; height: 54px; border-radius: var(--r-md); overflow: hidden; background: var(--surface); }
.dn-day, .dn-night { display: flex; align-items: center; padding: 0 12px; font-weight: 700; font-size: 0.9rem; min-width: 0; white-space: nowrap; transition: flex-basis 0.4s ease; }
.dn-day { background: var(--sun); color: #3a2c00; }
.dn-night { background: var(--night); color: #fff; justify-content: flex-end; }
.dn-legend { display: flex; justify-content: space-between; gap: 12px; font-size: 0.82rem; color: var(--ink-3); margin-top: 6px; }

.spec { display: grid; grid-template-columns: auto 1fr; margin: 18px 0 0; border-top: 1px solid var(--line); }
.spec dt, .spec dd { padding: 12px 0; border-bottom: 1px solid var(--line); margin: 0; }
.spec dt { color: var(--ink-2); font-size: 0.92rem; padding-right: 14px; }
.spec dd { text-align: right; }
.spec .big { font-family: var(--display); font-size: 1.35rem; font-weight: 700; display: block; }
.spec .sub { font-size: 0.82rem; color: var(--ink-3); display: block; }

.price { margin-top: 18px; background: var(--surface); border-radius: var(--r-md); padding: 14px 16px; }
.price .amount { font-family: var(--display); font-size: 1.6rem; font-weight: 700; }
.price .sub { color: var(--ink-3); font-size: 0.84rem; }
.price .save { margin-top: 8px; color: var(--leaf); font-weight: 600; font-size: 0.92rem; }

.warnings { list-style: none; padding: 0; margin: 14px 0 0; display: grid; gap: 8px; }
.warnings li { font-size: 0.88rem; padding: 10px 12px; border-radius: var(--r-sm); border-left: 4px solid; }
.warnings .info { background: var(--night-soft); border-color: var(--night); }
.warnings .warn { background: var(--sun-soft); border-color: var(--sun); }
.warnings .danger { background: var(--alert-soft); border-color: var(--alert); }

.plan-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 14px; margin-top: 18px; }

/* ── Report ───────────────────────────────── */
.report { margin-top: 28px; margin-bottom: 40px; }
.tabs { display: flex; gap: 4px; overflow-x: auto; border-bottom: 2px solid var(--line); }
.tabs button { flex: none; border: 0; background: none; padding: 12px 16px; font-weight: 700; color: var(--ink-3); border-bottom: 3px solid transparent; margin-bottom: -2px; }
.tabs button[aria-selected="true"] { color: var(--ink); border-color: var(--night); }
.tabpanel { background: var(--paper); border: 1px solid var(--line); border-top: 0; border-radius: 0 0 var(--r-lg) var(--r-lg); padding: 24px; }
.tabpanel h3 { margin: 22px 0 10px; }
.tabpanel h3:first-child { margin-top: 0; }
.tabpanel p, .tabpanel li { max-width: 78ch; }

.shop { width: 100%; border-collapse: collapse; }
.shop th, .shop td { text-align: left; padding: 12px 10px; border-bottom: 1px solid var(--line); vertical-align: top; }
.shop th { font-size: 0.82rem; color: var(--ink-3); font-weight: 600; }
.shop td:first-child { font-weight: 700; width: 18%; }
.shop .money { text-align: right; white-space: nowrap; }
.shop tfoot td { font-weight: 700; }
.shop ul { margin: 0; padding-left: 18px; }

.checklist { list-style: none; padding: 0; margin: 0; display: grid; gap: 4px; }
.checklist label { display: flex; gap: 10px; align-items: flex-start; padding: 8px 10px; border-radius: var(--r-sm); cursor: pointer; }
.checklist label:hover { background: var(--surface); }
.checklist input { margin-top: 4px; width: 18px; height: 18px; accent-color: var(--leaf); flex: none; }
.checklist input:checked + span { color: var(--ink-3); text-decoration: line-through; }
.checklist .why { display: block; color: var(--ink-3); font-size: 0.86rem; }
.red-flags li { margin-bottom: 6px; }

.workings { width: 100%; border-collapse: collapse; font-size: 0.93rem; }
.workings th { text-align: left; font-family: var(--display); font-size: 1rem; padding: 18px 8px 6px; }
.workings td { padding: 7px 8px; border-bottom: 1px solid var(--surface); vertical-align: top; }
.workings td:last-child { text-align: right; font-weight: 700; white-space: nowrap; }
.workings .f { color: var(--ink-2); }

.sources { padding-left: 20px; }
.sources li { margin-bottom: 10px; }
.sources .use { display: block; color: var(--ink-3); font-size: 0.88rem; }

/* ── Footer & mobile bar ──────────────────── */
.foot { color: var(--ink-3); font-size: 0.86rem; padding-bottom: 90px; display: grid; gap: 6px; }
.mobile-bar { display: none; }
@media (max-width: 1020px) {
  .mobile-bar {
    display: flex; justify-content: space-between; gap: 12px; position: fixed; left: 0; right: 0; bottom: 0; z-index: 20;
    background: var(--ink); color: #fff; text-decoration: none; padding: 10px var(--gutter); font-weight: 600; font-size: 0.88rem;
    flex-wrap: wrap; row-gap: 2px;
  }
  .mobile-bar span { min-width: 0; }
  .mobile-bar span:last-child { white-space: nowrap; }
  .mobile-bar b { font-family: var(--display); }
}

dialog { border: 0; border-radius: var(--r-lg); padding: 24px; width: min(480px, calc(100% - 32px)); }
dialog::backdrop { background: rgba(24, 33, 47, 0.45); }
dialog form { display: grid; gap: 14px; }
.check { display: flex; gap: 10px; align-items: flex-start; font-size: 0.93rem; }
.dialog-actions { display: flex; justify-content: flex-end; gap: 10px; }

@media (max-width: 560px) {
  .block, .sheet, .tabpanel { padding: 16px; }
  .loads input.name { min-width: 104px; }
  .loads input[type="number"] { width: 52px; }
  .loads td, .loads th { padding: 6px 3px; }
  .shop td:first-child { width: auto; }
  .shop thead { display: none; }
  .shop tr { display: block; border-bottom: 1px solid var(--line); padding: 8px 0; }
  .shop td { display: block; border: 0; padding: 4px 0; }
  .shop .money { text-align: left; }
}

/* ── Print: the report becomes a clean document ── */
.print-only { display: none; }
@media print {
  @page { margin: 14mm; }
  body { background: #fff; font-size: 11pt; }
  .masthead, .intro .lede, .inputs .picker, .block-actions, .plan-actions, .tabs, .mobile-bar, .skip, .remove,
  .advanced, .prefs, dialog { display: none !important; }
  .print-only { display: block; }
  .layout { display: block; }
  .plan { position: static; }
  .sheet, .block, .tabpanel { border: 0; padding: 0; margin-bottom: 14px; }
  .tabpanel[hidden] { display: block !important; }
  #tab-sources, #tab-workings { break-before: page; }
  .dn-day, .dn-night { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  .loads input, .loads select { background: none; border: 0; padding: 0; appearance: none; }
  a { color: inherit; text-decoration: none; }
}

/* Powered by mmiri28: shared badge across mmiri28 apps; opens mmiri28.com in a new tab */
.powered { display: inline-flex; align-items: center; gap: 9px; padding: 6px 14px 6px 9px; border: 1px solid var(--line); border-radius: 999px; color: var(--ink); text-decoration: none; background: var(--paper); }
.powered:hover { border-color: var(--night); }
.powered svg { flex: none; }
.powered span { display: flex; flex-direction: column; line-height: 1.15; }
.powered small { font-size: 0.625rem; letter-spacing: 0.08em; text-transform: uppercase; color: var(--ink-3, #5b6573); }
.powered b { font-size: 0.875rem; }
