:root {
  --navy-900: #0f2438;
  --navy-700: #1b3a5c;
  --navy-500: #2c5480;
  --amber-500: #f5883c;
  --amber-600: #e06f22;
  --green-600: #1e8a5f;
  --red-600: #c0392b;
  --paper: #f7f8fa;
  --ink: #14213d;
  --ink-muted: #5b6479;
  --line: #e1e6ee;
  --card-shadow: 0 10px 30px -16px rgba(15, 36, 56, 0.18);
  --radius: 12px;
  --font-ui: -apple-system, "Segoe UI", system-ui, sans-serif;
  --font-data: ui-monospace, "SF Mono", "Cascadia Mono", Consolas, monospace;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: var(--font-ui);
  background: var(--paper);
  color: var(--ink);
  -webkit-font-smoothing: antialiased;
}

#app {
  padding: 0 0 48px;
  max-width: 1040px;
  margin: 0 auto;
}

/* --- Header ------------------------------------------------------------ */

.app-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  flex-wrap: wrap;
  gap: 16px;
  background: var(--navy-900);
  color: #fff;
  padding: 28px 24px;
  margin-bottom: 24px;
}

.app-header h1 {
  font-size: 24px;
  font-weight: 700;
  letter-spacing: -0.01em;
  margin: 0;
}

.app-hero {
  margin: 0 0 24px;
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--card-shadow);
  line-height: 0;
}

.app-hero img {
  display: block;
  width: 100%;
  height: auto;
}

.app-header-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  position: relative;
  flex-wrap: wrap;
}

.app-header-actions .secondary-button {
  background: transparent;
  border-color: rgba(255, 255, 255, 0.3);
  color: #fff;
}

.app-header-actions .secondary-button:hover {
  background: rgba(255, 255, 255, 0.1);
}

/* --- Buttons ------------------------------------------------------------ */

.secondary-button {
  padding: 9px 16px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--ink);
  cursor: pointer;
  font-size: 13.5px;
  font-weight: 600;
  transition: background 0.15s ease, transform 0.05s ease;
}

.secondary-button:hover {
  background: #eef1f6;
}

.secondary-button:active {
  transform: translateY(1px);
}

.file-label {
  display: inline-flex;
  align-items: center;
}

.primary-button {
  padding: 11px 20px;
  border-radius: 8px;
  border: none;
  background: var(--amber-500);
  color: #fff;
  font-weight: 700;
  font-size: 14px;
  cursor: pointer;
  margin-top: 12px;
  box-shadow: 0 6px 16px -8px rgba(245, 136, 60, 0.6);
  transition: background 0.15s ease, transform 0.05s ease;
}

.primary-button:hover {
  background: var(--amber-600);
}

.primary-button:active {
  transform: translateY(1px);
}

.primary-button:disabled, .secondary-button:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
}

/* --- Wizard step cards --------------------------------------------------- */

.wizard-step {
  background: #fff;
  border-radius: var(--radius);
  padding: 32px;
  box-shadow: var(--card-shadow);
  margin: 0 24px 16px;
}

.wizard-step h2 {
  margin-top: 0;
  font-size: 20px;
  letter-spacing: -0.01em;
}

.wizard-step h3 {
  font-size: 15px;
  font-weight: 700;
  color: var(--navy-900);
  margin: 28px 0 12px;
  padding-left: 12px;
  border-left: 3px solid var(--amber-500);
}

.wizard-step h3:first-of-type {
  margin-top: 4px;
}

.wizard-step h4 {
  font-size: 14px;
  font-weight: 700;
  color: var(--navy-900);
  margin: 20px 0 10px;
}

/* --- Stepper: the signature element -------------------------------------- */

.stepper {
  display: flex;
  align-items: flex-start;
  margin: 0 24px 24px;
  overflow-x: auto;
  padding: 4px 2px;
}

.stepper-item {
  flex: 1;
  min-width: 96px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  border: none;
  background: transparent;
  cursor: pointer;
  padding: 4px 6px;
  position: relative;
}

/* The connecting track: a flat line behind every node except the first,
   recolored per-node below to read as a fill sweeping left-to-right. */
.stepper-item:not(:first-child)::before {
  content: "";
  position: absolute;
  top: 22px;
  left: -50%;
  width: 100%;
  height: 3px;
  background: var(--line);
  z-index: 0;
}

.stepper-item.done:not(:first-child)::before {
  background: var(--green-600);
}

.stepper-item.active:not(:first-child)::before {
  background: linear-gradient(to right, var(--green-600), var(--amber-500));
}

.stepper-icon {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #fff;
  border: 3px solid var(--line);
  color: var(--ink-muted);
  position: relative;
  z-index: 1;
  transition: border-color 0.2s ease, color 0.2s ease, background 0.2s ease;
}

.stepper-icon svg {
  width: 20px;
  height: 20px;
}

.stepper-item.active .stepper-icon {
  border-color: var(--amber-500);
  color: var(--amber-600);
  background: #fff7ef;
  box-shadow: 0 0 0 4px rgba(245, 136, 60, 0.15);
}

.stepper-item.done .stepper-icon {
  border-color: var(--green-600);
  color: #fff;
  background: var(--green-600);
}

.stepper-label {
  font-size: 12px;
  font-weight: 600;
  color: var(--ink-muted);
  text-align: center;
  line-height: 1.3;
}

.stepper-item.active .stepper-label {
  color: var(--navy-900);
}

.stepper-item.done .stepper-label {
  color: var(--green-600);
}

.step-nav {
  display: flex;
  justify-content: space-between;
  margin: 0 24px 40px;
}

.step-nav button:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

/* --- Mode toggle (pill tabs) --------------------------------------------- */

.mode-toggle {
  display: flex;
  gap: 8px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}

.mode-button {
  padding: 9px 18px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--ink);
  cursor: pointer;
  font-size: 13.5px;
  font-weight: 600;
  transition: background 0.15s ease, color 0.15s ease, border-color 0.15s ease;
}

.mode-button:hover {
  border-color: var(--navy-500);
}

.mode-button.active {
  background: var(--navy-900);
  color: #fff;
  border-color: var(--navy-900);
}

/* --- Forms ---------------------------------------------------------------- */

.form-field, .form-grid label {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 13px;
  font-weight: 600;
  color: var(--ink-muted);
  margin-bottom: 12px;
}

.form-field input, .form-field select,
.form-grid input, .form-grid select {
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  font: inherit;
  font-weight: 400;
  color: var(--ink);
  background: #fff;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.form-field input:focus, .form-field select:focus,
.form-grid input:focus, .form-grid select:focus {
  outline: none;
  border-color: var(--amber-500);
  box-shadow: 0 0 0 3px rgba(245, 136, 60, 0.18);
}

.form-grid, .column-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 14px;
  margin-bottom: 12px;
}

.workdays-fieldset {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px 16px;
  margin-bottom: 12px;
}

.workday-checkbox {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  margin-right: 12px;
  font-size: 13px;
}

/* --- Charts / data displays ------------------------------------------------ */

.chart {
  width: 100%;
  height: 260px;
  margin-bottom: 12px;
}

.chart-small {
  height: 180px;
}

#opt-heatmap {
  height: 360px;
}

.fetch-progress {
  width: 100%;
  height: 8px;
  border-radius: 4px;
  background: var(--line);
  overflow: hidden;
  margin: 10px 0;
}

.fetch-progress-bar {
  height: 100%;
  background: var(--amber-500);
  border-radius: 4px;
  transition: width 0.2s ease;
}

.fetch-progress-indeterminate {
  width: 40% !important;
  animation: fetch-progress-slide 1.1s ease-in-out infinite;
}

@keyframes fetch-progress-slide {
  0% { margin-left: -40%; }
  100% { margin-left: 100%; }
}

.validation-list {
  list-style: none;
  padding: 0;
  margin: 12px 0;
}

.validation-list li {
  padding: 8px 12px;
  border-radius: 8px;
  margin-bottom: 4px;
  font-size: 13px;
}

.validation-error {
  background: #fdecea;
  color: var(--red-600);
}

.validation-warning {
  background: #fff4e0;
  color: #8a5a00;
}

.validation-ok {
  color: var(--green-600);
  font-weight: 600;
}

/* --- Price widget ----------------------------------------------------------- */

.price-widget {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  padding: 8px 14px;
  border-radius: 8px;
  border: 1px solid rgba(255, 255, 255, 0.25);
  background: rgba(255, 255, 255, 0.06);
  cursor: pointer;
}

.price-widget-label {
  font-size: 10px;
  color: rgba(255, 255, 255, 0.65);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.price-widget-value {
  font-weight: 700;
  font-family: var(--font-data);
  font-variant-numeric: tabular-nums;
  color: #fff;
}

.price-widget-popup {
  position: absolute;
  top: 100%;
  right: 0;
  margin-top: 8px;
  width: 320px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 12px;
  box-shadow: var(--card-shadow);
  z-index: 10;
  color: var(--ink);
}

/* --- Tables ------------------------------------------------------------------ */

.invoice-table {
  width: 100%;
  border-collapse: collapse;
  margin-bottom: 16px;
  font-size: 13.5px;
}

.invoice-table th {
  text-align: left;
  padding: 8px;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  color: var(--ink-muted);
  border-bottom: 2px solid var(--line);
}

.invoice-table td {
  border-bottom: 1px solid var(--line);
  padding: 9px 8px;
  font-variant-numeric: tabular-nums;
}

.invoice-table input {
  width: 100%;
  padding: 6px;
  border: 1px solid var(--line);
  border-radius: 4px;
  font: inherit;
}

.inv-diff-ok {
  color: var(--green-600);
}

.inv-diff-warning {
  color: var(--red-600);
  font-weight: 600;
}

.invoice-list {
  list-style: none;
  padding: 0;
}

.invoice-list li {
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  margin-bottom: 6px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
}

/* --- Print --------------------------------------------------------------------- */

@media print {
  body, #app {
    background: #fff;
    padding: 0;
    margin: 0;
    max-width: none;
  }
  .app-header, .no-print, input, select, button, .mode-toggle {
    display: none !important;
  }
  #step-consumption, #step-calendar, #step-pvgis, #step-inverter, #step-pricing, #step-optimization {
    display: none !important;
  }
  #step-payback {
    box-shadow: none;
    padding: 0;
    margin: 0;
  }
  .chart {
    height: 400px !important;
  }
}

@media (max-width: 640px) {
  .wizard-step {
    margin: 0 12px 16px;
    padding: 20px;
  }
  .stepper {
    margin: 0 12px 20px;
  }
  .step-nav {
    margin: 0 12px 32px;
  }
  .app-header {
    padding: 20px 16px;
  }
  .app-hero {
    margin: 0 12px 16px;
  }
}
