:root {
  --color-bg: #f3f6f4;
  --color-surface: #ffffff;
  --color-ink: #12221f;
  --color-muted: #5b6d68;
  --color-line: #d7e3de;
  --color-primary: #0f6b57;
  --color-primary-dark: #0b4f41;
  --color-primary-soft: #e5f5ef;
  --color-accent: #e8940a;
  --color-accent-soft: #fff4de;
  --color-sun: #f6c945;
  --color-success: #1b8a5a;
  --color-danger: #c4452d;
  --color-danger-soft: #fdecea;
  --color-info: #1d6f8a;
  --shadow: 0 18px 50px rgba(18, 34, 31, 0.08);
  --shadow-sm: 0 8px 24px rgba(18, 34, 31, 0.06);
  --radius: 18px;
  --radius-sm: 12px;
  --space-1: 0.35rem;
  --space-2: 0.7rem;
  --space-3: 1.1rem;
  --space-4: 1.6rem;
  --space-5: 2.4rem;
  --font: "Poppins", system-ui, sans-serif;
  --display: "Poppins", system-ui, sans-serif;
  --max: 1120px;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  font-family: var(--font);
  color: var(--color-ink);
  background: var(--color-bg);
  line-height: 1.5;
  min-height: 100vh;
}

.bg-glow {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: -1;
  background:
    radial-gradient(900px 420px at 8% -10%, rgba(246, 201, 69, 0.28), transparent 60%),
    radial-gradient(700px 380px at 100% 0%, rgba(15, 107, 87, 0.18), transparent 55%);
}

h1, h2, h3 {
  font-family: var(--display);
  letter-spacing: -0.03em;
  margin: 0 0 0.4rem;
}

p { margin: 0; }

.site-header {
  background: linear-gradient(135deg, #0b3d3a 0%, #0f6b57 58%, #1b8a5a 100%);
  color: #fff;
  padding: 1.6rem 1.2rem 2.2rem;
}

.header-inner {
  max-width: var(--max);
  margin: 0 auto;
  display: flex;
  gap: var(--space-4);
  align-items: center;
  flex-wrap: wrap;
}

.brand {
  display: flex;
  gap: 0.85rem;
  align-items: center;
  min-width: 220px;
}

.logo svg {
  display: block;
  filter: drop-shadow(0 6px 12px rgba(0, 0, 0, 0.18));
}

.brand-name {
  font-family: var(--display);
  font-weight: 800;
  font-size: 1.15rem;
}

.brand-tag {
  font-size: 0.8rem;
  opacity: 0.78;
}

.header-copy {
  flex: 1;
  min-width: 240px;
}

.header-copy h1 {
  font-size: clamp(1.7rem, 3vw, 2.4rem);
  color: #fff;
}

.header-copy p {
  max-width: 46rem;
  color: rgba(255, 255, 255, 0.86);
}

.app {
  max-width: var(--max);
  margin: -1.2rem auto 3rem;
  padding: 0 1rem;
}

.stepper {
  background: var(--color-surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 0.9rem 1rem;
  margin-bottom: 1rem;
  overflow-x: auto;
}

.stepper-list {
  list-style: none;
  display: flex;
  gap: 0.4rem;
  margin: 0;
  padding: 0;
  min-width: 640px;
}

.stepper-item {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 0.55rem;
  color: var(--color-muted);
  font-weight: 600;
  font-size: 0.88rem;
  position: relative;
  cursor: pointer;
  background: none;
  border: 0;
  font-family: inherit;
  text-align: left;
}

.stepper-item:not(:last-child)::after {
  content: "";
  flex: 1;
  height: 2px;
  background: var(--color-line);
  margin-left: 0.4rem;
}

.step-num {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: #eef3f1;
  font-size: 0.78rem;
  flex-shrink: 0;
}

.stepper-item.is-complete .step-num,
.stepper-item.is-active .step-num {
  background: var(--color-primary);
  color: #fff;
}

.stepper-item.is-active {
  color: var(--color-ink);
}

.stepper-item.is-complete:not(:last-child)::after,
.stepper-item.is-active:not(:last-child)::after {
  background: var(--color-primary);
}

.calculator-card,
.advanced {
  background: var(--color-surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 1.5rem 1.4rem 1.6rem;
  margin-bottom: 1rem;
}

.step-head {
  margin-bottom: var(--space-4);
}

.eyebrow {
  text-transform: uppercase;
  letter-spacing: 0.12em;
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--color-primary);
  margin-bottom: 0.35rem;
}

.step-head p:last-child,
.hint,
.fine-print {
  color: var(--color-muted);
  font-size: 0.92rem;
}

.grid-2,
.grid-3,
.summary-grid,
.options-grid,
.charts-grid,
.split-grid {
  display: grid;
  gap: 1rem;
}

.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }

.field {
  display: flex;
  flex-direction: column;
  gap: 0.38rem;
}

.field label,
.sub-fieldset legend {
  font-weight: 700;
  font-size: 0.88rem;
}

input,
select {
  width: 100%;
  font: inherit;
  color: var(--color-ink);
  background: #f8fbfa;
  border: 1px solid var(--color-line);
  border-radius: 10px;
  padding: 0.72rem 0.8rem;
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
}

input:focus,
select:focus {
  border-color: var(--color-primary);
  box-shadow: 0 0 0 3px rgba(15, 107, 87, 0.15);
  background: #fff;
}

input::placeholder {
  color: var(--color-muted);
  font-weight: 500;
}

.input-affix {
  display: flex;
  align-items: stretch;
}

.input-affix input {
  border-radius: 10px 0 0 10px;
}

.input-affix .prefix + input {
  border-radius: 0 10px 10px 0;
}

.input-affix .prefix {
  border-radius: 10px 0 0 10px;
  border-right: 0;
}

.affix,
.affix-select {
  background: #eef6f2;
  border: 1px solid var(--color-line);
  color: var(--color-muted);
  font-weight: 700;
  font-size: 0.85rem;
  display: grid;
  place-items: center;
  padding: 0 0.8rem;
  white-space: nowrap;
}

.affix:last-child,
.affix-select {
  border-left: 0;
  border-radius: 0 10px 10px 0;
}

.affix-select {
  width: auto;
  min-width: 88px;
}

.bill-card,
.sun-card,
.block-card,
.chart-card,
.panel-spec,
.option-card,
.stat-card {
  background: linear-gradient(180deg, #fbfefc 0%, #f4faf7 100%);
  border: 1px solid var(--color-line);
  border-radius: var(--radius-sm);
  padding: 1rem 1.1rem;
}

.bill-card-head,
.table-head,
.sun-card {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.8rem;
  flex-wrap: wrap;
}

.pill {
  background: var(--color-accent-soft);
  color: #8a5a00;
  font-size: 0.75rem;
  font-weight: 700;
  padding: 0.25rem 0.6rem;
  border-radius: 999px;
}

.bill-rows {
  margin: 0.7rem 0 0;
}

.bill-rows > div,
.kv > div {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.42rem 0;
  border-bottom: 1px dashed var(--color-line);
}

.bill-rows dt,
.kv dt {
  color: var(--color-muted);
}

.bill-rows dd,
.kv dd {
  margin: 0;
  font-weight: 700;
}

.bill-rows .total {
  border-bottom: 0;
  padding-top: 0.7rem;
  font-size: 1.05rem;
}

.sun-value {
  font-size: 1.05rem;
}

.check-inline {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  font-size: 0.88rem;
  font-weight: 600;
}

.check-inline input {
  width: auto;
}

.panel-spec {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 0.8rem;
  margin-top: 1rem;
}

.spec-item span {
  display: block;
  color: var(--color-muted);
  font-size: 0.78rem;
}

.spec-item strong {
  font-size: 1.02rem;
}

.step-actions {
  display: flex;
  justify-content: space-between;
  gap: 0.8rem;
  margin-top: 1.4rem;
}

.btn {
  font: inherit;
  font-weight: 700;
  border: 0;
  cursor: pointer;
  border-radius: 12px;
  padding: 0.78rem 1.15rem;
}

.btn-primary {
  background: linear-gradient(180deg, #14856c, var(--color-primary-dark));
  color: #fff;
  box-shadow: 0 10px 20px rgba(15, 107, 87, 0.25);
}

.btn-primary:hover { filter: brightness(1.05); }

.btn-ghost {
  background: #eef3f1;
  color: var(--color-ink);
}

.btn-sm {
  padding: 0.4rem 0.75rem;
  font-size: 0.85rem;
}

.banner {
  border-radius: 12px;
  padding: 0.85rem 1rem;
  margin-bottom: 1rem;
  font-weight: 600;
}

.banner-error {
  background: var(--color-danger-soft);
  color: var(--color-danger);
}

.banner-ok {
  background: var(--color-primary-soft);
  color: var(--color-success);
}

.banner-warn {
  background: var(--color-danger-soft);
  color: var(--color-danger);
}

.options-grid {
  grid-template-columns: repeat(3, minmax(0, 1fr));
  margin-bottom: 1rem;
}

.option-card {
  cursor: pointer;
  transition: transform 0.15s, box-shadow 0.15s, border-color 0.15s;
}

.option-card:hover { transform: translateY(-2px); }

.option-card.is-selected {
  border-color: var(--color-primary);
  box-shadow: 0 0 0 3px rgba(15, 107, 87, 0.18);
  background: #fff;
}

.option-card .tag {
  display: inline-block;
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--color-primary);
  margin-bottom: 0.3rem;
}

.option-card.is-recommended .tag {
  background: var(--color-accent);
  color: #fff;
  padding: 0.18rem 0.5rem;
  border-radius: 999px;
}

.option-card h3 { font-size: 1.35rem; }

.option-card ul {
  margin: 0.6rem 0 0;
  padding: 0;
  list-style: none;
  color: var(--color-muted);
  font-size: 0.9rem;
}

.option-card li {
  display: flex;
  justify-content: space-between;
  padding: 0.22rem 0;
}

.summary-grid {
  grid-template-columns: repeat(4, minmax(0, 1fr));
  margin: 0.2rem 0 1rem;
}

.stat-card .label {
  color: var(--color-muted);
  font-size: 0.8rem;
  font-weight: 600;
}

.stat-card .value {
  font-family: var(--display);
  font-size: 1.35rem;
  font-weight: 800;
  margin-top: 0.2rem;
}

.split-grid {
  grid-template-columns: 1fr 1fr;
  margin-bottom: 1rem;
}

.charts-grid {
  grid-template-columns: 1fr 1fr;
  margin: 1rem 0;
}

.chart-card {
  display: flex;
  flex-direction: column;
  height: 340px;
}

.chart-card canvas {
  width: 100% !important;
  flex: 1 1 auto;
  min-height: 220px;
}

.inverter-card {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 0.8rem;
}

.table-wrap {
  overflow: auto;
  margin-top: 0.8rem;
  max-height: 420px;
}

.proj-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.85rem;
}

.proj-table th,
.proj-table td {
  padding: 0.5rem 0.55rem;
  text-align: right;
  border-bottom: 1px solid var(--color-line);
  white-space: nowrap;
}

.proj-table th:first-child,
.proj-table td:first-child {
  text-align: left;
}

.proj-table thead th {
  position: sticky;
  top: 0;
  background: #eef6f2;
}

.advanced-toggle {
  width: 100%;
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: transparent;
  border: 0;
  font: inherit;
  font-weight: 800;
  cursor: pointer;
  padding: 0;
}

.advanced-body {
  margin-top: 1rem;
  padding-top: 1rem;
  border-top: 1px solid var(--color-line);
}

.sub-fieldset {
  border: 1px solid var(--color-line);
  border-radius: 12px;
  margin-top: 1rem;
  padding: 0.8rem 1rem 1rem;
}

.site-footer {
  text-align: center;
  color: var(--color-muted);
  font-size: 0.82rem;
  padding: 0 1rem 2rem;
}

.field.has-error input,
.field.has-error select {
  border-color: var(--color-danger);
}

.field-error {
  color: var(--color-danger);
  font-size: 0.8rem;
  font-weight: 600;
}

@media (max-width: 980px) {
  .grid-3,
  .summary-grid,
  .charts-grid,
  .panel-spec,
  .inverter-card {
    grid-template-columns: 1fr 1fr;
  }
}

@media (max-width: 760px) {
  .header-inner { align-items: flex-start; }
  .grid-2,
  .grid-3,
  .summary-grid,
  .options-grid,
  .charts-grid,
  .split-grid,
  .panel-spec,
  .inverter-card {
    grid-template-columns: 1fr;
  }

  .stepper-list { min-width: 0; }
  .step-label { display: none; }
  .stepper-item.is-active .step-label { display: inline; }
  .stepper-list { min-width: auto; }

  .step-actions { flex-direction: column-reverse; }
  .btn { width: 100%; }

  .sun-card { align-items: flex-start; flex-direction: column; }
}

@media (max-width: 480px) {
  .calculator-card,
  .advanced { padding: 1.1rem 0.9rem; }
  .stat-card .value { font-size: 1.2rem; }
}
