:root {
  --navy: #0f2742;
  --navy-2: #1b3a5c;
  --sun: #f5a400;
  --sun-2: #ffc94d;
  --sun-soft: #fff6df;
  --green: #138a52;
  --green-soft: #e6f6ee;
  --red: #b4372c;
  --text: #1c2430;
  --muted: #5d6877;
  --line: #e3e7ed;
  --bg: #f7f8fa;
  --card: #ffffff;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(15, 39, 66, 0.06), 0 4px 16px rgba(15, 39, 66, 0.06);
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; scroll-padding-top: 72px; }
body {
  margin: 0;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  color: var(--text);
  background: var(--bg);
  line-height: 1.55;
  font-size: 16px;
}
h1, h2, h3 { line-height: 1.2; color: var(--navy); margin: 0 0 0.5em; }
h1 { font-size: clamp(1.8rem, 4.5vw, 2.8rem); letter-spacing: -0.02em; }
h2 { font-size: clamp(1.35rem, 3vw, 1.75rem); }
h3 { font-size: 1.1rem; }
p { margin: 0 0 0.8em; }
a { color: var(--navy-2); }
.muted { color: var(--muted); }
.small { font-size: 0.875rem; }
[hidden] { display: none !important; }

.container { width: min(1120px, 100% - 32px); margin-inline: auto; }
.container.narrow { width: min(760px, 100% - 32px); }

/* Header */
.site-header {
  position: sticky; top: 0; z-index: 20;
  background: rgba(255, 255, 255, 0.92);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--line);
}
.header-inner { display: flex; align-items: center; justify-content: space-between; height: 60px; }
.logo { display: flex; align-items: center; gap: 8px; font-size: 1.15rem; color: var(--navy); text-decoration: none; }
.logo b { color: var(--sun); }
.logo-sun {
  width: 22px; height: 22px; border-radius: 50%;
  background: radial-gradient(circle, var(--sun-2) 40%, var(--sun) 41%);
  box-shadow: 0 0 0 3px var(--sun-soft);
}
.nav { display: flex; gap: 18px; }
.nav a { text-decoration: none; color: var(--muted); font-weight: 500; font-size: 0.95rem; }
.nav a:hover { color: var(--navy); }

/* Hero */
.hero {
  background: linear-gradient(160deg, var(--navy) 0%, var(--navy-2) 100%);
  color: #fff;
  padding: 56px 0 64px;
}
.hero h1 { color: #fff; }
.hero-eyebrow { text-transform: uppercase; letter-spacing: 0.08em; font-size: 0.8rem; font-weight: 700; color: var(--sun-2); margin-bottom: 10px; }
.hero .lead { font-size: 1.1rem; color: #d7e2ef; max-width: 56ch; }
.hero-inner { display: grid; gap: 32px; align-items: center; }
.hero-note { font-size: 0.85rem; color: #a9bbd0; margin-top: 12px; }
.hero-card {
  background: #fff; color: var(--text);
  border-radius: var(--radius); padding: 24px;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.25);
  max-width: 340px;
}
.hero-stat { display: flex; justify-content: space-between; align-items: baseline; }
.hero-stat span { color: var(--muted); }
.hero-stat b { font-size: 1.6rem; color: var(--navy); }
.hero-stat.good b { color: var(--green); }
.hero-arrow { text-align: center; color: var(--sun); font-size: 1.5rem; }
@media (min-width: 860px) {
  .hero-inner { grid-template-columns: 1fr 1.1fr; }
}

/* 2.5D isometric scenes */
.hero-visual { position: relative; }
.scene {
  position: relative; overflow: hidden; border-radius: var(--radius);
  background: linear-gradient(180deg, #7cc4ef 0%, #e4f4fb 100%);
  user-select: none;
  isolation: isolate;
}
.scene-stage { position: absolute; inset: 0; }
.scene-stage svg { width: 100%; height: 100%; display: block; }
.scene-hero { height: 420px; box-shadow: 0 24px 60px rgba(0, 0, 0, 0.35), inset 0 0 0 1px rgba(255, 255, 255, 0.12); }
.scene-result { height: 380px; }

/* energy flows */
.scene .flow { opacity: 0; transition: opacity 0.8s ease; }
.scene .flow.on { opacity: 1; }
.scene .flow .dash { stroke-dasharray: 1 9; animation: flow-dash 0.7s linear infinite; }
@keyframes flow-dash { to { stroke-dashoffset: -10; } }

/* clouds drift */
.scene .cloud { animation: cloud-drift 38s ease-in-out infinite alternate; }
.scene .cloud.c2 { animation-duration: 52s; animation-direction: alternate-reverse; }
@keyframes cloud-drift { from { translate: -40px 0; } to { translate: 40px 0; } }

/* labels */
.scene-labels { position: absolute; inset: 0; pointer-events: none; }
.scene-label {
  position: absolute; transform: translate(-50%, -100%);
  background: rgba(255, 255, 255, 0.94); color: var(--navy);
  font-size: 0.74rem; font-weight: 600; white-space: nowrap;
  padding: 4px 9px; border-radius: 99px;
  box-shadow: 0 4px 14px rgba(15, 39, 66, 0.18);
  margin-top: -8px;
}
.scene-label::after {
  content: ""; position: absolute; left: 50%; bottom: -4px; width: 8px; height: 8px;
  background: inherit; transform: translateX(-50%) rotate(45deg); border-radius: 1px;
}
.scene-label:empty { display: none; }
.scene-label b { color: var(--sun); font-weight: 800; }
.scene-label .lbl-pct { color: var(--green); font-variant-numeric: tabular-nums; }
@media (max-width: 560px) {
  .scene-label { font-size: 0.66rem; padding: 3px 7px; }
  .scene-label.minor { display: none; }
}
@media (prefers-reduced-motion: reduce) {
  .scene .flow .dash, .scene .cloud { animation: none; }
}
/* HUD: time with the battery right under it (fixed left column), caption on the right.
   A long caption wraps inside its own pill and never moves the battery. */
.scene-hud {
  position: absolute; bottom: 12px; left: 12px; right: 12px;
  display: grid; grid-template-columns: max-content minmax(0, 1fr);
  grid-template-areas: "clock status" "batt status";
  gap: 6px 8px; align-items: end; pointer-events: none; z-index: 2;
  opacity: 0; transition: opacity 0.4s;
}
.scene-hud .clock { grid-area: clock; }
.scene-hud .batt { grid-area: batt; }
.scene-hud .status { grid-area: status; justify-self: start; align-self: end; border-radius: 14px; font-size: 0.86rem; font-weight: 600; }
.scene-hud .status.swap { animation: caption-in 0.35s ease-out; }
@keyframes caption-in { from { opacity: 0; transform: translateY(4px); } }
@media (prefers-reduced-motion: reduce) { .scene-hud .status.swap { animation: none; } }
.scene-hud .clock, .scene-hud .batt { text-align: center; white-space: nowrap; min-width: 92px; box-sizing: border-box; }
.scene.ready .scene-hud { opacity: 1; }
.scene-hud span {
  background: rgba(15, 39, 66, 0.82); color: #fff; backdrop-filter: blur(4px);
  font-size: 0.8rem; padding: 5px 10px; border-radius: 99px; line-height: 1.3;
  border: 1px solid rgba(255, 255, 255, 0.16); box-shadow: 0 4px 14px rgba(0, 0, 0, 0.18);
}
.scene-hud .clock { font-weight: 700; color: var(--sun-2); font-variant-numeric: tabular-nums; }
.scene-hud .batt { background: rgba(19, 138, 82, 0.9); font-variant-numeric: tabular-nums; }
.hero-proof {
  display: inline-flex; align-items: center; gap: 16px; margin-top: 22px;
  padding: 12px 18px; border-radius: 14px;
  background: rgba(255, 255, 255, 0.06); border: 1px solid rgba(255, 255, 255, 0.12);
}
.hero-proof div { display: flex; flex-direction: column; }
.hero-proof span { font-size: 0.75rem; color: #a9bbd0; }
.hero-proof b { font-size: 1.25rem; color: #fff; }
.hero-proof .good b { color: #5ee0a0; }
.hero-proof-arrow { color: var(--sun); font-size: 1.3rem; }
@media (max-width: 859px) {
  .scene-hero { height: 320px; }
}
.scene-card-head { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: baseline; gap: 4px 12px; margin-bottom: 10px; }
.scene-card-head h3 { margin: 0; }
.scene-legend { display: flex; flex-wrap: wrap; gap: 14px; margin-top: 10px; font-size: 0.85rem; color: var(--muted); }
.scene-legend span { display: inline-flex; align-items: center; gap: 6px; }
.dot { width: 10px; height: 10px; border-radius: 50%; display: inline-block; }
.dot.solar { background: #ffb81c; box-shadow: 0 0 6px #ffb81c; }
.dot.battery { background: #22c55e; box-shadow: 0 0 6px #22c55e; }
.dot.grid { background: #3b8cff; box-shadow: 0 0 6px #3b8cff; }

/* Buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center;
  border: 0; border-radius: 10px; padding: 11px 20px;
  font: inherit; font-weight: 600; cursor: pointer; text-decoration: none;
  transition: transform 0.05s, background 0.15s;
}
.btn:active { transform: translateY(1px); }
.btn-lg { padding: 14px 28px; font-size: 1.05rem; }
.btn-primary { background: var(--sun); color: var(--navy); }
.btn-primary:hover { background: var(--sun-2); }
.btn-secondary { background: var(--navy); color: #fff; }
.btn-secondary:hover { background: var(--navy-2); }
.btn-ghost { background: transparent; color: var(--navy); border: 1px solid var(--line); }
.btn-ghost:hover { background: #fff; }
:focus-visible { outline: 3px solid var(--sun); outline-offset: 2px; }

/* Sections */
.section { padding: 56px 0; }
.section.alt { background: #fff; border-block: 1px solid var(--line); }
.section-title { text-align: center; margin-bottom: 28px; }
.section-sub { margin-top: 40px; }

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 24px;
  box-shadow: var(--shadow);
}
.card + .card { margin-top: 16px; }

/* Stepper */
.stepper {
  list-style: none; padding: 0; margin: 0 0 20px;
  display: flex; gap: 6px; counter-reset: step;
}
.stepper li {
  flex: 1; counter-increment: step;
  font-size: 0.8rem; color: var(--muted); text-align: center;
  padding-top: 10px; border-top: 4px solid var(--line);
}
.stepper li::before { content: counter(step) ". "; }
.stepper li.done { border-color: var(--green); color: var(--green); }
.stepper li.active { border-color: var(--sun); color: var(--navy); font-weight: 700; }
.stepper li.skipped { opacity: 0.4; text-decoration: line-through; }

/* Choices */
.choice-grid { display: grid; gap: 10px; margin: 16px 0 20px; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); }
.choice {
  text-align: left; font: inherit; cursor: pointer;
  background: #fff; border: 2px solid var(--line); border-radius: 12px;
  padding: 14px 16px; display: flex; flex-direction: column; gap: 4px;
  transition: border-color 0.15s, background 0.15s;
}
.choice:hover { border-color: var(--sun-2); }
.choice[aria-pressed="true"] { border-color: var(--sun); background: var(--sun-soft); }
.choice b { color: var(--navy); }
.choice em { font-style: normal; font-size: 0.8rem; font-weight: 600; color: var(--sun); text-transform: uppercase; letter-spacing: 0.03em; }
.choice span { font-size: 0.88rem; color: var(--muted); }

/* Fields */
.field-row { display: grid; gap: 16px; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); }
.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 14px; }
.field > span { font-weight: 600; font-size: 0.92rem; color: var(--navy); display: flex; align-items: center; gap: 6px; }
input[type="number"], select {
  font: inherit; padding: 10px 12px; border: 1px solid #cdd4de; border-radius: 10px; background: #fff; width: 100%;
}
input[type="range"] { width: 100%; accent-color: var(--sun); }
.input-prefix { display: flex; align-items: center; border: 1px solid #cdd4de; border-radius: 10px; background: #fff; padding-left: 12px; max-width: 280px; }
.input-prefix input { border: 0; font-size: 1.3rem; font-weight: 700; color: var(--navy); }
.input-prefix input:focus { outline: none; }
.input-prefix:focus-within { outline: 3px solid var(--sun); }
.check { display: flex; gap: 10px; align-items: flex-start; margin: 8px 0 4px; cursor: pointer; }
.check input { margin-top: 4px; width: 18px; height: 18px; accent-color: var(--sun); flex: none; }

.tip {
  width: 20px; height: 20px; border-radius: 50%; border: 0;
  background: var(--line); color: var(--navy); font-size: 0.75rem; font-weight: 700;
  cursor: help; padding: 0; flex: none;
}
.tooltip {
  position: absolute; z-index: 50;
  background: var(--navy); color: #fff; font-size: 0.85rem;
  padding: 10px 12px; border-radius: 10px; box-shadow: var(--shadow);
}

.step-actions { display: flex; justify-content: space-between; margin-top: 24px; gap: 12px; }

/* Tabs */
.tabs { display: flex; gap: 6px; background: var(--bg); padding: 4px; border-radius: 12px; margin: 12px 0 18px; width: fit-content; max-width: 100%; }
.tab { font: inherit; font-size: 0.92rem; border: 0; background: transparent; padding: 8px 14px; border-radius: 9px; cursor: pointer; color: var(--muted); font-weight: 600; }
.tab.active { background: #fff; color: var(--navy); box-shadow: var(--shadow); }

/* Appliances */
.appliance-list { display: grid; gap: 6px; max-height: 440px; overflow-y: auto; padding-right: 4px; }
.appliance {
  display: grid; grid-template-columns: 1fr auto; gap: 8px 12px; align-items: center;
  padding: 8px 12px; border: 1px solid var(--line); border-radius: 10px; background: #fff;
}
.appliance.on { border-color: var(--sun-2); background: var(--sun-soft); }
.ap-name { display: flex; flex-direction: column; font-size: 0.92rem; }
.ap-name span { color: var(--muted); font-size: 0.8rem; }
.check-inline { flex-direction: row; gap: 10px; align-items: center; cursor: pointer; }
.check-inline input { width: 18px; height: 18px; accent-color: var(--sun); }
.check-inline > span { display: flex; flex-direction: column; }
.ap-hours { grid-column: 1 / -1; font-size: 0.82rem; color: var(--muted); display: flex; align-items: center; gap: 6px; }
.ap-hours input { width: 72px; padding: 4px 8px; }
@media (min-width: 640px) {
  .appliance:has(.ap-hours) { grid-template-columns: 1fr auto 150px; }
  .ap-hours { grid-column: auto; }
}
.qty { display: flex; align-items: center; gap: 4px; }
.qty button { width: 30px; height: 30px; border-radius: 8px; border: 1px solid #cdd4de; background: #fff; font-size: 1.1rem; cursor: pointer; color: var(--navy); }
.qty span { min-width: 24px; text-align: center; font-weight: 700; }
.estimate-box {
  display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: 12px;
  background: var(--navy); color: #fff; padding: 14px 16px; border-radius: 12px; margin-top: 14px;
}
.estimate-box b { color: var(--sun-2); }

/* Results */
.results-layout { display: grid; gap: 16px; }
@media (min-width: 960px) {
  .results-layout { grid-template-columns: 1fr 320px; align-items: start; }
  .tweak-panel { position: sticky; top: 76px; }
}
.result-hero { background: linear-gradient(135deg, var(--navy), var(--navy-2)); color: #fff; border: 0; }
.result-hero h2 { color: #fff; font-size: clamp(1.6rem, 4vw, 2.2rem); }
.result-hero .muted { color: #b9c8da; }
.eyebrow { text-transform: uppercase; letter-spacing: 0.06em; font-size: 0.8rem; color: var(--sun-2); font-weight: 700; margin-bottom: 4px; }
.price-range { font-size: clamp(1.4rem, 3.5vw, 1.9rem); font-weight: 800; color: var(--sun-2); margin-bottom: 4px; }
.warning { background: #fff1ef; color: var(--red); border-radius: 8px; padding: 8px 12px; font-size: 0.9rem; margin: 10px 0 0; }

.kpi-grid { display: grid; gap: 10px; grid-template-columns: repeat(2, 1fr); margin: 16px 0; }
@media (min-width: 640px) { .kpi-grid { grid-template-columns: repeat(3, 1fr); } }
.kpi { background: #fff; border: 1px solid var(--line); border-radius: 12px; padding: 14px 16px; display: flex; flex-direction: column; }
.kpi span { font-size: 0.82rem; color: var(--muted); }
.kpi b { font-size: 1.3rem; color: var(--navy); }
.kpi.good { background: var(--green-soft); border-color: #bfe6d1; }
.kpi.good b { color: var(--green); }

.plain-list { padding-left: 20px; margin: 0; }
.plain-list li { margin-bottom: 8px; }

.cost-table { width: 100%; border-collapse: collapse; font-size: 0.92rem; }
.cost-table td { padding: 10px 6px; border-bottom: 1px solid var(--line); vertical-align: top; }
.cost-table td:last-child { text-align: right; font-weight: 600; white-space: nowrap; }
.live-info { margin: 12px 0 0; }
.cost-table tfoot td { border: 0; font-weight: 800; font-size: 1.05rem; color: var(--navy); padding-top: 14px; }
@media (max-width: 560px) {
  .cost-table td:nth-child(2) { display: none; }
}

.bar-chart { display: grid; gap: 10px; margin-bottom: 12px; }
.bar-row { display: grid; grid-template-columns: 140px 1fr 90px; gap: 10px; align-items: center; font-size: 0.88rem; }
.bar-row b { text-align: right; }
.bar { background: var(--bg); border-radius: 6px; height: 14px; overflow: hidden; }
.bar i { display: block; height: 100%; border-radius: 6px; transition: width 0.3s; }
.bar i.usage { background: #8a97a8; }
.bar i.solar { background: var(--sun); }
.bar i.used { background: var(--green); }
.bar i.export { background: #3a7bd5; }
.bar i.waste { background: #e0a39d; }
@media (max-width: 480px) { .bar-row { grid-template-columns: 100px 1fr 70px; font-size: 0.8rem; } }

.result-actions { display: flex; flex-wrap: wrap; gap: 10px; justify-content: flex-end; margin-top: 16px; }
.result-actions .btn-reset { margin-right: auto; }
.link-btn {
  display: block; width: 100%; margin-top: 16px; padding: 10px 0 0; border: 0; border-top: 1px solid var(--line);
  background: none; font: inherit; font-size: 0.9rem; font-weight: 600; color: var(--navy-2); cursor: pointer; text-align: left;
}
.link-btn:hover { color: var(--sun); }

.pkg-choices { display: grid; gap: 8px; margin-bottom: 16px; }
.pkg {
  text-align: left; font: inherit; cursor: pointer; padding: 10px 12px;
  border: 2px solid var(--line); border-radius: 10px; background: #fff;
  display: flex; flex-direction: column;
}
.pkg span { font-size: 0.8rem; color: var(--muted); }
.pkg[aria-pressed="true"] { border-color: var(--sun); background: var(--sun-soft); }

/* Battery mode segmented control */
.seg { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.seg button {
  font: inherit; font-size: 0.82rem; font-weight: 600; cursor: pointer; padding: 8px 6px;
  border: 2px solid var(--line); border-radius: 10px; background: #fff; color: var(--navy);
}
.seg button[aria-pressed="true"] { border-color: var(--sun); background: var(--sun-soft); }

/* Why isn't my bill ₱0 */
.why-card { border-left: 4px solid var(--sun); margin-bottom: 16px; }
.why-table { width: 100%; border-collapse: collapse; font-size: 0.92rem; }
.why-table td { padding: 8px 4px; border-bottom: 1px solid var(--line); }
.why-table td:last-child { text-align: right; font-weight: 700; white-space: nowrap; }
.why-table .good { color: var(--green); }
.why-sub { font-weight: 700; color: var(--navy); margin: 14px 0 6px; }
.why-tips { padding-left: 18px; margin: 0; }
.why-tips li { margin-bottom: 10px; }
.why-tips .btn { margin-top: 6px; display: flex; width: fit-content; }
.btn-sm { padding: 6px 12px; font-size: 0.85rem; border-radius: 8px; }

/* "Best value" tip under the coverage slider */
.value-hint {
  margin: -4px 0 14px; padding: 10px 12px; border-radius: 10px;
  background: var(--sun-soft); border: 1px solid #f6d98a; color: #6b4b00;
  font-size: 0.84rem; line-height: 1.45;
}
.link-inline {
  display: inline; border: 0; background: none; padding: 0; margin-left: 2px;
  font: inherit; font-weight: 700; color: var(--navy-2); text-decoration: underline; cursor: pointer;
}
.link-inline:hover { color: var(--sun); }

/* Confirmation modal */
.modal {
  border: 0; border-radius: 18px; padding: 28px 26px 22px; width: min(420px, calc(100% - 32px));
  box-shadow: 0 24px 70px rgba(15, 39, 66, 0.35); text-align: center; color: var(--text);
}
.modal::backdrop { background: rgba(15, 39, 66, 0.55); backdrop-filter: blur(2px); }
.modal[open] { animation: modal-in 0.18s ease-out; }
@keyframes modal-in { from { opacity: 0; transform: translateY(8px) scale(0.98); } }
.modal h2 { font-size: 1.3rem; margin-bottom: 8px; }
.modal p { margin: 0 0 8px; }
.modal-icon {
  width: 48px; height: 48px; margin: 0 auto 12px; border-radius: 50%;
  display: grid; place-items: center; font-size: 1.5rem; font-weight: 700;
  background: var(--sun-soft); color: var(--sun);
}
.modal-actions { display: flex; gap: 10px; justify-content: center; margin-top: 18px; flex-wrap: wrap; }
.modal-actions .btn { flex: 1 1 140px; }
@media (prefers-reduced-motion: reduce) { .modal[open] { animation: none; } }

/* Learn */
.learn-grid { display: grid; gap: 16px; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); }
.learn-grid .card + .card { margin-top: 0; }
.tag { display: inline-block; font-size: 0.72rem; background: var(--sun-soft); color: #9a6700; padding: 2px 8px; border-radius: 99px; vertical-align: middle; margin-left: 6px; }
.glossary { display: grid; gap: 12px; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); margin: 0; }
.glossary div { background: var(--bg); border-radius: 12px; padding: 14px 16px; }
.glossary dt { font-weight: 700; color: var(--navy); }
.glossary dd { margin: 4px 0 0; color: var(--muted); font-size: 0.92rem; }

/* FAQ */
details { background: #fff; border: 1px solid var(--line); border-radius: 12px; padding: 14px 18px; margin-bottom: 10px; }
summary { cursor: pointer; font-weight: 600; color: var(--navy); }
details p { margin: 10px 0 0; color: var(--muted); }

/* Footer */
.site-footer { background: var(--navy); color: #c9d6e5; padding: 32px 0; }
.site-footer .muted { color: #8ea3bb; }

@media (max-width: 520px) {
  .nav { gap: 12px; }
  .nav a { font-size: 0.85rem; }
  .card { padding: 18px; }
  .stepper li { font-size: 0.7rem; }
}

/* Print: only the results */
@media print {
  .site-header, .hero, #learn, #faq, .site-footer, .stepper, .tweak-panel, .result-actions, .tooltip, .scene-card { display: none !important; }
  body { background: #fff; }
  .section { padding: 0; }
  .card, .kpi { box-shadow: none; break-inside: avoid; }
  .result-hero { background: #fff; color: var(--text); border: 1px solid var(--line); }
  .result-hero h2, .price-range { color: var(--navy); }
  .results-layout { grid-template-columns: 1fr; }
}
