/* ─── CSS Reset ─────────────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

body {
  min-height: 100vh;
  background: linear-gradient(135deg, #e8f5e2 0%, #f5f0e8 60%, #e8eff5 100%);
  font-family: Georgia, 'Times New Roman', serif;
  padding: 16px 12px 48px;
}

input[type=range] { accent-color: #2d6e2d; width: 100%; cursor: pointer; }
input[type=number]::-webkit-inner-spin-button,
input[type=number]::-webkit-outer-spin-button { -webkit-appearance: none; margin: 0; }
input[type=number] { -moz-appearance: textfield; appearance: textfield; }

/* Hidden but accessible (for radio/checkbox tricks) */
.sr-hidden { position: absolute; opacity: 0; width: 0; height: 0; pointer-events: none; }

/* ─── Root & Card ────────────────────────────────────────────────────────────── */
/* max-width = 4 × card-width + 3 × grid-gap + 2 × box-padding-h */
:root { --card-w: 260px; --grid-gap: 10px; --box-ph: 24px; }
.root { max-width: calc(4 * var(--card-w) + 3 * var(--grid-gap) + 2 * var(--box-ph)); margin: 0 auto; }

.card {
  background: rgba(255,255,255,0.93);
  border-radius: 20px;
  box-shadow: 0 8px 40px rgba(0,0,0,0.12);
  overflow: hidden;
}

/* ─── Header ─────────────────────────────────────────────────────────────────── */
.header {
  background: linear-gradient(135deg, #1a4d1a, #2d6e2d);
  padding: 24px 28px 18px;
  color: #fff;
}

.header-top { display: flex; justify-content: space-between; align-items: flex-start; }

.logo-row { display: flex; align-items: center; gap: 10px; margin-bottom: 4px; }
.logo-text { font-size: 22px; font-weight: 700; letter-spacing: 1px; }
.subtitle { font-size: 13px; opacity: 0.75; margin: 0 0 14px; font-style: italic; }

/* Language switcher (compact, in header) */
.lang-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 4px; }

.lang-btn {
  display: flex; align-items: center; gap: 3px;
  background: transparent;
  border: 1px solid rgba(255,255,255,0.25);
  border-radius: 6px; padding: 2px 5px;
  cursor: pointer; color: #fff;
  font-size: 13px; font-family: inherit;
}
.lang-btn.lang-active {
  background: rgba(255,255,255,0.3);
  border-color: rgba(255,255,255,0.7);
}
.lang-label { font-size: 10px; opacity: 0.9; }

/* Progress bar */
.progress-wrap { display: flex; align-items: center; gap: 12px; }
.progress-bar { flex: 1; height: 6px; background: rgba(255,255,255,0.25); border-radius: 3px; overflow: hidden; }
.progress-fill { height: 100%; background: #f0c040; border-radius: 3px; transition: width .4s; }
.progress-label { font-size: 12px; opacity: 0.8; white-space: nowrap; }

/* ─── Box / Content Area ─────────────────────────────────────────────────────── */
.box { padding: 28px 24px; }

.hero-icon { font-size: 48px; text-align: center; margin-bottom: 12px; }
.h2 { font-size: 20px; font-weight: 700; color: #1a2e1a; margin: 1em 0 1em; line-height: 1.3; text-align: center; }
.h3 { font-size: 13px; font-weight: 700; color: #1a2e1a; margin: 20px 0 10px; text-transform: uppercase; letter-spacing: .5px; }
.p { font-size: 14px; color: #444; line-height: 1.6; margin: 0 0 2em; text-align: center; }

/* ─── Info Box ───────────────────────────────────────────────────────────────── */
.info-box {
  background: #e8f5e2;
  border: 1px solid #2d6e2d;
  border-radius: 10px; padding: 12px 14px;
  font-size: 13px; color: #1a2e1a; margin-bottom: 2em; line-height: 1.5;
  display: flex; align-items: center; justify-content: center;
  gap: 8px; text-align: center; flex-wrap: wrap;
}
.info-box-warn {
  background: #fff3cd;
  border: 3px solid #000;
  flex-direction: column;
}
.info-icon { flex-shrink: 0; }
.warn-triangle { text-align: center; margin-bottom: 8px; }
.warn-triangle-sm { display: inline-block; vertical-align: middle; margin-right: 6px; flex-shrink: 0; }

/* ─── Buttons ────────────────────────────────────────────────────────────────── */
.btn {
  border-radius: 10px; padding: 12px 22px; font-size: 15px;
  font-weight: 700; cursor: pointer; font-family: inherit;
  min-height: 44px; display: inline-flex; align-items: center; justify-content: center;
  text-decoration: none; border: none;
}
.btn-primary {
  background: linear-gradient(135deg, #2d6e2d, #1a4d1a);
  color: #fff; box-shadow: 0 4px 12px rgba(26,77,26,.3);
}
.btn-primary:disabled { opacity: 0.4; cursor: not-allowed; }
.btn-secondary {
  background: transparent; color: #2d6e2d;
  border: 2px solid #2d6e2d; padding: 11px 20px; font-size: 14px;
}
.btn-full { width: 100%; margin-bottom: 20px; }

/* ─── Nav Row ────────────────────────────────────────────────────────────────── */
.nav-row { display: flex; justify-content: space-between; align-items: center; margin-top: 10px; }

/* ─── Intro Language Switcher ───────────────────────────────────────────────── */
.intro-lang-row { display: flex; gap: 6px; flex-wrap: wrap; justify-content: center; margin-top: 12px; }
.intro-lang-btn {
  display: flex; align-items: center; gap: 4px;
  border: 2px solid #ddd; border-radius: 8px; padding: 5px 9px;
  cursor: pointer; background: #f9f9f9; color: #1a2e1a;
  font-weight: 700; transition: all .15s; font-family: inherit;
}
.intro-lang-btn.intro-lang-active { border-color: #2d6e2d; background: #e8f5e2; }
.intro-lang-label { font-size: 11px; color: #555; }

/* ─── Season Bar ─────────────────────────────────────────────────────────────── */
.season-bar { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; }
.season-cell {
  border: 2px solid #ccc; border-radius: 10px;
  padding: 7px 4px; text-align: center;
  background: rgba(255,255,255,0.7);
}
.season-cell-label { font-weight: 700; font-size: 10px; margin-bottom: 1px; }
.season-cell-wh { font-weight: 700; font-size: 12px; color: #333; }

/* ─── Usage frequency grid ──────────────────────────────────────────────────── */
.usage-grid {
  display: grid;
  grid-template-columns: 140px 1fr 1fr 1fr;
  gap: 8px;
  margin-bottom: 20px;
  align-items: stretch;
}
.usage-season-label {
  display: flex; align-items: center; gap: 6px;
  font-size: 13px; font-weight: 600; color: #1a2e1a;
  padding-right: 8px;
}

/* ─── Appliance Grid & Cards ─────────────────────────────────────────────────── */
.app-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(var(--card-w), 1fr));
  gap: 10px; margin-top: 2em; margin-bottom: 2em;
}

.app-card-wrap {
  border: 2px solid #e0e0e0;
  border-radius: 12px; padding: 12px;
  background: #fafafa;
  position: relative;
}
.app-card-wrap.app-active {
  border-color: #2d6e2d;
  background: #f0f9f0;
  box-shadow: 0 2px 8px rgba(45,110,45,.15);
}

/* The actual checkbox is hidden; label is the clickable header */
.app-toggle { display: none; }

.app-card-label { display: block; cursor: pointer; }

.app-top { display: flex; align-items: center; gap: 10px; min-height: 44px; padding: 4px 0; }
.app-icon { flex-shrink: 0; }
.app-info { flex: 1; min-width: 0; }
.app-name { font-size: 13px; font-weight: 600; color: #1a2e1a; }
.app-watts { font-size: 11px; color: #888; }

.app-checkmark {
  margin-left: auto; width: 22px; height: 22px;
  border-radius: 50%; flex-shrink: 0;
  border: 2px solid #ccc;
  background: transparent;
  display: flex; align-items: center; justify-content: center;
  font-size: 12px; color: #fff;
}
.app-checkmark.app-checked { border-color: #2d6e2d; background: #2d6e2d; }

/* Controls area (shown when checkbox is checked) */
.app-controls { margin-top: 10px; padding-top: 10px; border-top: 1px solid #e8e8e8; }

/* Qty / Watt rows */
.qty-row { display: grid; grid-template-columns: 1fr 44px 44px 44px; align-items: center; gap: 6px; margin-top: 8px; }
.qty-row .hours-label { overflow: hidden; text-overflow: ellipsis; }
.qty-row-watts { position: relative; padding-bottom: 4px; }
.hours-label { font-size: 11px; color: #666; white-space: nowrap; }
.hours-val { font-size: 12px; font-weight: 700; color: #2d6e2d; min-width: 28px; display: inline-block; }

.qty-btn {
  width: 44px; height: 44px; border-radius: 8px;
  border: 1px solid #2d6e2d; background: #f0f9f0;
  color: #2d6e2d; font-size: 18px; font-weight: 700;
  cursor: pointer; display: flex; align-items: center; justify-content: center;
  flex-shrink: 0; font-family: inherit;
}
.qty-input {
  width: 44px; height: 44px; text-align: center;
  border: 1px solid #ccc; border-radius: 8px;
  font-size: 14px; font-weight: 700; color: #1a2e1a;
  font-family: inherit;
}

/* Hours slider row */
.hours-row { display: flex; align-items: center; gap: 8px; margin-top: 10px; }
.hours-slider { flex: 1; min-width: 0; }
.hours-arrow-btns { display: flex; height: 22px; border-radius: 5px; border: 1px solid #bbb; overflow: hidden; flex-shrink: 0; }
.hours-arrow-btns button {
  width: 22px; height: 22px; border: none; background: #f4f4f4;
  cursor: pointer; padding: 0;
  display: flex; align-items: center; justify-content: center;
  font-size: 10px; color: #444; font-family: inherit;
}
.hours-arrow-btns button:first-child { border-right: 1px solid #bbb; }

/* Season selector */
.season-selector { display: flex; align-items: center; gap: 3px; margin-top: 10px; padding-top: 8px; border-top: 1px solid #e8e8e8; }
.season-divider { width: 1px; align-self: stretch; background: #ccc; margin: 0 1px; flex-shrink: 0; }

.season-btn {
  flex: 1; display: flex; align-items: center; justify-content: center;
  min-height: 44px; padding: 12px 2px;
  border: 2px solid #ddd; border-radius: 6px;
  background: #f4f4f4; color: #666;
  cursor: pointer; transition: all .12s;
  text-decoration: none;
}
.season-btn.season-btn-active { color: #fff; }
.season-btn-all { flex: 2; gap: 2px; }
.season-btn-all.season-all-active { background: #2d6e2d; border-color: #2d6e2d; }
.season-all-sep { width: 1px; height: 12px; background: rgba(255,255,255,0.4); margin: 0 2px; display: inline-block; }

/* ─── Step 2: Voltage choices ─────────────────────────────────────────────────── */
.volt-choices { display: flex; flex-direction: column; gap: 12px; margin-top: 0; margin-bottom: 20px; }

.volt-card {
  border: 2px solid #e0e0e0; border-radius: 14px;
  padding: 16px 18px; cursor: pointer;
  background: #fafafa; text-align: left;
  display: block; transition: all .15s;
}
.volt-card.choice-active,
.volt-radio:checked + .volt-card { border-color: #2d6e2d; background: #f0f9f0; }
.volt-radio:checked + .volt-card .volt-val { color: #2d6e2d; }
.volt-card.choice-recommended { border-color: #2d6e2d; box-shadow: 0 0 0 3px rgba(45,110,45,0.25); }

.volt-header { display: flex; align-items: center; gap: 10px; margin-bottom: 8px; }
.volt-val { font-size: 22px; font-weight: 800; }
.choice-badge { font-size: 11px; color: #2d6e2d; font-weight: 700; background: transparent; }
.badge-sel { display: none; }
.volt-radio:checked + .volt-card .badge-sel { display: inline-block; }
.choice-badges { margin-top: 6px; }
.choice-radio:checked + .choice-card .badge-sel { display: block; }
.choice-headline { font-size: 13px; font-weight: 600; color: #333; margin-bottom: 8px; }
.choice-divider { border: none; border-top: 1px solid #e8e8e8; margin: 8px 0; }
.choice-bullets { font-size: 12px; color: #666; font-style: italic; line-height: 1.7; }

/* ─── Step 3: Autonomy choices ──────────────────────────────────────────────── */
.choice-grid { margin-bottom: 20px; }
.choice-grid-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 10px; }
.choice-grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }

.choice-card {
  border: 2px solid #e0e0e0; border-radius: 14px;
  padding: 18px 12px; cursor: pointer; text-align: center;
  background: #fafafa; transition: all .15s; display: block;
}
.choice-card.choice-active,
.choice-radio:checked + .choice-card { border-color: #2d6e2d; background: #f0f9f0; box-shadow: 0 4px 12px rgba(45,110,45,.2); }
.choice-card.choice-recommended { border-color: #2d6e2d; box-shadow: 0 0 0 3px rgba(45,110,45,0.25); }
.choice-val { font-size: 22px; font-weight: 800; color: #1a2e1a; margin: 6px 0 4px; }
.choice-desc { font-size: 12px; color: #666; line-height: 1.4; }
.choice-title { font-weight: 700; color: #1a2e1a; margin-bottom: 4px; }
.mono-font { font-family: monospace; }

/* ─── Result Cards ───────────────────────────────────────────────────────────── */
.result-header { text-align: center; margin-bottom: 20px; }

.result-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-bottom: 18px; }

.r-card {
  background: #fafafa; border-radius: 12px; padding: 16px;
  border-top: 4px solid #ccc; box-shadow: 0 2px 8px rgba(0,0,0,.06);
}
.r-card-full { grid-column: 1 / -1; }
.r-icon { font-size: 32px; margin-bottom: 6px; }
.r-title { font-size: 11px; text-transform: uppercase; letter-spacing: 1px; color: #888; margin-bottom: 4px; }
.r-value { font-size: 14px; font-weight: 700; margin-bottom: 4px; }
.r-price { font-size: 12px; color: #888; margin-top: 3px; }
.r-detail { font-size: 12px; color: #666; white-space: pre-line; margin-top: 12px; }
.r-warn {
  font-size: 18px; color: #c0620a; background: #fff3e0;
  border-radius: 6px; padding: 1em 8px 1em; margin-top: 8px;
  border: 3px solid #000; display: flex; gap: 1em;
  flex-direction: column; align-items: center; text-align: center;
}

.seasonal-grid { display: grid; grid-template-columns: repeat(4,1fr); gap: 8px; margin-top: 12px; }
.seasonal-cell { border: 2px solid #ccc; border-radius: 10px; padding: 10px 8px; text-align: center; }

/* ─── Price Box ──────────────────────────────────────────────────────────────── */
.price-box {
  background: linear-gradient(135deg, #1a4d1a, #2d6e2d);
  color: #fff; border-radius: 14px; padding: 18px 22px;
  text-align: center; margin-bottom: 18px;
}
.price-label { font-size: 11px; opacity: .8; text-transform: uppercase; letter-spacing: 1px; margin-bottom: 8px; }
.price-value { font-size: 30px; font-weight: 800; margin-bottom: 8px; }
.price-note { font-size: 11px; opacity: .75; line-height: 1.5; }

/* ─── Popup Dialogs ──────────────────────────────────────────────────────────── */
dialog {
  border: none; border-radius: 14px; padding: 32px 28px 24px;
  max-width: 360px; width: 90%; text-align: center;
  box-shadow: 0 8px 40px rgba(0,0,0,0.22);
}
dialog::backdrop { background: rgba(0,0,0,0.45); }
.popup-title { font-size: 26px; font-weight: 800; line-height: 1.5; margin-bottom: .5em; }
.popup-body { font-size: 13px; color: #8b0000; line-height: 1.5; margin-bottom: .3em; }
.popup-btns { display: flex; gap: 12px; justify-content: center; margin-top: 16px; }

/* ─── Elm Modal Overlay ─────────────────────────────────────────────────────── */
.elm-modal-backdrop { position:fixed; inset:0; background:rgba(0,0,0,.45); z-index:100; display:flex; align-items:center; justify-content:center; }
.elm-modal-box { background:#fff; border-radius:8px; padding:24px; max-width:360px; width:90%; text-align:center; box-shadow:0 8px 40px rgba(0,0,0,0.22); }

/* ─── Footer ─────────────────────────────────────────────────────────────────── */
.footer { text-align: center; font-size: 12px; color: #888; font-style: italic; margin-top: 20px; }

/* ─── Responsive ─────────────────────────────────────────────────────────────── */
@media (max-width: 480px) {
  .choice-grid-3 { grid-template-columns: 1fr; }
  .result-grid { grid-template-columns: 1fr; }

  .lang-grid { grid-template-columns: repeat(4, 1fr); }
  .seasonal-grid { grid-template-columns: repeat(2, 1fr); }
}

/* ─── Print styles ───────────────────────────────────────────────────────────── */
@media print {
  @page { margin: 1.5cm; size: A4; }

  body, #root { background: #fff !important; }
  * { box-shadow: none !important; print-color-adjust: exact; }

  .header, .progress-wrap, button,
  .choice-grid, .volt-choices,
  .nav-row { display: none !important; }

  .result-grid { display: grid !important; grid-template-columns: 1fr 1fr; gap: 12px; }
  .result-grid > * { break-inside: avoid; }
  .nav-row { display: none !important; }
}
