:root {
  color-scheme: light;
  --bg: #f3efe6;
  --panel: #fffaf0;
  --ink: #1f2937;
  --muted: #6b7280;
  --line: #d7cfbe;
  --accent: #2f6f5e;
  --accent-strong: #234d41;
  --shadow: 0 20px 60px rgba(31, 41, 55, 0.08);
}

* {
  box-sizing: border-box;
}

html,
body {
  height: 100%;
}

body {
  margin: 0;
  font-family: ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--ink);
  background:
    radial-gradient(circle at top left, rgba(47, 111, 94, 0.12), transparent 28%),
    radial-gradient(circle at top right, rgba(180, 127, 55, 0.14), transparent 26%),
    var(--bg);
  overflow: hidden;
}

.shell {
  width: min(100%, 1800px);
  margin: 0 auto;
  height: 100vh;
  padding: 10px;
  display: grid;
  gap: 10px;
  grid-template-columns: minmax(0, 1fr);
  grid-template-rows: auto auto minmax(0, 1fr);
}

.hero,
.panel {
  background: rgba(255, 250, 240, 0.92);
  border: 1px solid var(--line);
  border-radius: 20px;
  box-shadow: var(--shadow);
  padding: 14px;
  min-width: 0;
  min-height: 0;
  overflow: auto;
}

.hero {
  grid-column: 1;
}

.hero h1 {
  margin: 0 0 8px;
  font-size: clamp(1.5rem, 2vw, 2.2rem);
  line-height: 1;
  max-width: none;
}

.eyebrow {
  margin: 0 0 14px;
  text-transform: uppercase;
  letter-spacing: 0.16em;
  color: var(--accent);
  font-size: 0.76rem;
  font-weight: 700;
}

.lead {
  margin: 0;
  max-width: 100ch;
  color: var(--muted);
  font-size: 0.92rem;
  line-height: 1.35;
}

.status {
  display: inline-flex;
  margin-top: 12px;
  padding: 8px 12px;
  border-radius: 999px;
  background: rgba(47, 111, 94, 0.1);
  color: var(--accent-strong);
  font-weight: 700;
  font-size: 0.9rem;
}

.context-bar {
  display: grid;
  grid-template-columns: minmax(220px, 1.3fr) auto minmax(220px, 1.1fr) auto;
  gap: 12px;
  align-items: end;
  margin-top: 12px;
}

.context-field {
  min-width: 0;
}

.context-actions {
  display: flex;
  gap: 8px;
  justify-content: flex-start;
  align-items: end;
  flex-wrap: wrap;
}

.tabs {
  display: flex;
  gap: 8px;
}

.tab-button {
  background: rgba(255, 255, 255, 0.8);
  color: var(--accent-strong);
  border: 1px solid var(--line);
  padding: 8px 14px;
  font-size: 0.92rem;
}

.tab-button.is-active {
  background: var(--accent);
  color: #fff;
}

.tab-panel.is-hidden {
  display: none;
}

form {
  display: grid;
  gap: 12px;
}

.wizard-progress {
  position: relative;
  display: grid;
  gap: 16px;
  padding: 8px 12px 46px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.7);
}

.wizard-progress__top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.wizard-dots {
  display: inline-flex;
  gap: 8px;
}

.wizard-dot {
  appearance: none;
  border: 0;
  padding: 0;
  width: 13px;
  height: 13px;
  border-radius: 999px;
  background: #c9bea9;
  cursor: pointer;
  box-shadow: inset 0 0 0 1px rgba(31, 41, 55, 0.08);
}

.wizard-dot.is-active {
  background: var(--accent);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.3);
}

.wizard-dot.is-invalid {
  background: #b23b3b;
  box-shadow:
    inset 0 0 0 1px rgba(255, 255, 255, 0.25),
    0 0 0 3px rgba(178, 59, 59, 0.14);
}

.wizard-dot:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 4px;
}

.wizard-progress.has-invalid {
  border-color: rgba(178, 59, 59, 0.32);
}

.wizard-status {
  position: absolute;
  top: calc(100% - 34px);
  left: var(--wizard-status-left, 0px);
  transform: translateX(-50%);
  display: grid;
  justify-items: center;
  gap: 1px;
  min-height: 1.2em;
  color: var(--accent-strong);
  font-size: 0.92rem;
  font-weight: 700;
  pointer-events: none;
}

.wizard-status[data-has-message="false"] {
  display: none;
}

.wizard-status__text {
  white-space: nowrap;
  line-height: 1.1;
  padding: 4px 8px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.92);
  border: 1px solid rgba(47, 111, 94, 0.16);
  box-shadow: 0 8px 20px rgba(31, 41, 55, 0.08);
}

.wizard-status__arrow {
  width: 16px;
  height: 18px;
  position: relative;
}

.wizard-status__arrow::after {
  content: "";
  position: absolute;
  left: 50%;
  top: 1px;
  width: 9px;
  height: 9px;
  border-top: 2px solid currentColor;
  border-right: 2px solid currentColor;
  transform: translateX(-50%) rotate(-45deg);
}

.wizard-status__arrow::before {
  content: "";
  position: absolute;
  left: 50%;
  top: 8px;
  width: 2px;
  height: 8px;
  background: currentColor;
  transform: translateX(-50%);
}

.wizard-step {
  display: none;
  gap: 14px;
}

.wizard-step.is-active {
  display: grid;
}

.wizard-kicker {
  margin: 0;
  text-transform: uppercase;
  letter-spacing: 0.14em;
  color: var(--accent);
  font-size: 0.72rem;
  font-weight: 700;
}

.wizard-step h2 {
  margin: 0;
  font-size: 1rem;
}

.wizard-nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-top: 4px;
}

label {
  display: grid;
  gap: 8px;
  font-size: 0.94rem;
  font-weight: 600;
}

input,
select,
button {
  font: inherit;
}

input,
select {
  width: 100%;
  border: 1px solid var(--line);
  background: #fff;
  border-radius: 12px;
  padding: 10px 12px;
  color: var(--ink);
}

button {
  border: 1px solid transparent;
  border-radius: 999px;
  padding: 9px 14px;
  background: var(--accent);
  color: white;
  cursor: pointer;
  font-weight: 700;
}

button[type="button"] {
  background: #fff;
  color: var(--accent-strong);
  border-color: var(--line);
}

button:hover {
  filter: brightness(0.98);
}

.grid {
  display: grid;
  gap: 12px;
}

.grid.two {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.grid.three {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.section-header {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 8px;
}

.section-header h2 {
  margin: 0;
  font-size: 0.98rem;
}

.section-header p {
  margin: 0;
  color: var(--muted);
  font-size: 0.88rem;
}

.section-note {
  margin: -2px 0 12px;
  color: var(--muted);
  font-size: 0.9rem;
  line-height: 1.45;
}

.module-card {
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 14px;
  background: rgba(255, 255, 255, 0.72);
}

.actions {
  display: flex;
  gap: 12px;
}

.actions.right {
  justify-content: flex-end;
}

.segmented {
  display: inline-flex;
  gap: 6px;
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.68);
}

.segmented button {
  padding: 7px 12px;
  font-size: 0.88rem;
  line-height: 1;
  border-radius: 999px;
  background: transparent;
  color: var(--accent-strong);
  border-color: transparent;
}

.segmented button.is-active {
  background: var(--accent);
  color: #fff;
  border-color: transparent;
}

.analysis-panel {
  display: grid;
  gap: 12px;
}

.analysis-context {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  color: var(--muted);
  font-size: 0.88rem;
}

.analysis-context span {
  padding: 6px 10px;
  border-radius: 999px;
  background: rgba(47, 111, 94, 0.08);
  color: var(--accent-strong);
  font-weight: 600;
}

.analysis-heatmap-card {
  display: grid;
  gap: 8px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.72);
}

.analysis-heatmap {
  display: flex;
  justify-content: center;
  overflow: auto;
}

.analysis-heatmap svg {
  display: block;
  width: min(100%, 620px);
  height: auto;
}

.analysis-legend {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
  color: var(--muted);
  font-size: 0.82rem;
}

.analysis-legend__scale {
  display: flex;
  align-items: center;
  gap: 0;
  width: min(100%, 420px);
  height: 12px;
  border-radius: 999px;
  overflow: hidden;
  border: 1px solid rgba(31, 41, 55, 0.08);
}

.analysis-legend__swatch {
  flex: 1;
  height: 100%;
}

.analysis-summary {
  display: grid;
  gap: 10px;
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

.analysis-summary__card {
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 10px 12px;
  background: rgba(255, 255, 255, 0.72);
}

.analysis-summary__card strong {
  display: block;
  margin-top: 4px;
  font-size: 0.98rem;
}

.analysis-empty {
  padding: 14px;
  border: 1px dashed var(--line);
  border-radius: 14px;
  color: var(--muted);
}

.monthly-profile-actions {
  flex-wrap: wrap;
  justify-content: flex-end;
}

.monthly-profile-actions button.is-active {
  background: var(--accent);
  color: #fff;
  border-color: transparent;
}

.monthly-profile-grid {
  display: grid;
  gap: 10px;
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.monthly-profile-card {
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 10px;
  background: rgba(255, 255, 255, 0.72);
  display: grid;
  gap: 8px;
}

.monthly-profile-card__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.monthly-profile-card__header h4 {
  margin: 0;
  font-size: 0.92rem;
}

.monthly-profile-card__header span {
  padding: 4px 8px;
  border-radius: 999px;
  background: rgba(47, 111, 94, 0.1);
  color: var(--accent-strong);
  font-size: 0.78rem;
  font-weight: 700;
}

.monthly-profile-card label {
  gap: 6px;
  font-size: 0.85rem;
}

.monthly-profile-card input {
  padding: 8px 10px;
}

.monthly-profile-legend {
  display: flex;
  gap: 8px;
  align-items: start;
  padding: 10px 12px;
  border-radius: 14px;
  background: rgba(47, 111, 94, 0.08);
  color: var(--ink);
  line-height: 1.4;
  font-size: 0.88rem;
}

.cluster-wrap {
  display: grid;
  gap: 10px;
}

.cluster-grid {
  display: grid;
  gap: 10px;
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.cluster-card {
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 14px;
  background: rgba(255, 255, 255, 0.72);
  display: grid;
  gap: 10px;
}

.cluster-card__header {
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 10px;
}

.cluster-card h4 {
  margin: 0 0 4px;
  font-size: 1rem;
}

.cluster-card p {
  margin: 0;
  color: var(--muted);
  font-size: 0.88rem;
}

.cluster-card__hours {
  padding: 6px 10px;
  border-radius: 999px;
  background: rgba(47, 111, 94, 0.1);
  color: var(--accent-strong);
  font-size: 0.82rem;
  font-weight: 700;
  white-space: nowrap;
}

.cluster-card__kwh {
  margin-top: 2px;
  color: var(--accent-strong);
  font-size: 0.82rem;
  font-weight: 700;
}

.label-with-help {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.field-help {
  width: 18px;
  height: 18px;
  border: 1px solid rgba(35, 77, 65, 0.25);
  border-radius: 999px;
  background: rgba(47, 111, 94, 0.08);
  color: var(--accent-strong);
  font-size: 0.72rem;
  font-weight: 800;
  line-height: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: help;
  padding: 0;
  transition:
    transform 110ms ease,
    background-color 110ms ease,
    box-shadow 110ms ease,
    border-color 110ms ease;
  touch-action: manipulation;
}

.field-help:hover,
.field-help:focus-visible {
  background: rgba(47, 111, 94, 0.14);
  outline: none;
  box-shadow: 0 0 0 4px rgba(47, 111, 94, 0.12);
  transform: translateY(-1px);
}

.tooltip-layer {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 60;
}

.tooltip-layer.is-visible {
  pointer-events: none;
}

.tooltip-bubble {
  position: fixed;
  max-width: min(360px, calc(100vw - 24px));
  padding: 13px 15px;
  border-radius: 18px;
  background: linear-gradient(180deg, rgba(31, 41, 55, 0.98), rgba(17, 24, 39, 0.98));
  color: #fff;
  box-shadow:
    0 18px 40px rgba(31, 41, 55, 0.24),
    0 2px 0 rgba(255, 255, 255, 0.04) inset;
  border: 1px solid rgba(255, 255, 255, 0.12);
  display: grid;
  gap: 6px;
  opacity: 0;
  transform: translateY(2px) scale(0.98);
  transition:
    opacity 75ms ease-out,
    transform 75ms ease-out;
  will-change: transform, opacity;
}

.tooltip-bubble::after {
  content: '';
  position: absolute;
  left: 50%;
  width: 11px;
  height: 11px;
  background: linear-gradient(180deg, rgba(31, 41, 55, 0.98), rgba(17, 24, 39, 0.98));
  transform: translateX(-50%) rotate(45deg);
  border-right: 1px solid rgba(255, 255, 255, 0.08);
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.tooltip-bubble[data-placement="top"]::after {
  bottom: -6px;
}

.tooltip-bubble[data-placement="bottom"]::after {
  top: -6px;
}

.tooltip-bubble strong {
  font-size: 0.88rem;
  letter-spacing: 0.02em;
}

.tooltip-bubble span {
  font-size: 0.9rem;
  line-height: 1.45;
}

.tooltip-layer.is-visible .tooltip-bubble {
  opacity: 1;
  transform: translateY(0) scale(1);
}

.tooltip-modal {
  width: min(520px, calc(100vw - 24px));
  border: 0;
  border-radius: 20px;
  padding: 0;
  background: linear-gradient(180deg, rgba(31, 41, 55, 0.98), rgba(15, 23, 42, 0.99));
  color: #fff;
  box-shadow:
    0 24px 60px rgba(31, 41, 55, 0.32),
    0 2px 0 rgba(255, 255, 255, 0.03) inset;
  max-height: min(72vh, 560px);
  overflow: auto;
}

.tooltip-modal::backdrop {
  background: rgba(17, 24, 39, 0.5);
  backdrop-filter: blur(4px);
}

.tooltip-modal__header,
.tooltip-modal p,
.tooltip-modal form {
  padding: 14px 16px;
}

.tooltip-modal__header {
  border-bottom: 1px solid rgba(255, 255, 255, 0.12);
}

.tooltip-modal p {
  margin: 0;
  line-height: 1.5;
}

.tooltip-modal form {
  display: flex;
  justify-content: flex-end;
  padding-top: 0;
}

.tooltip-modal button {
  background: linear-gradient(180deg, #fff, #f5f7f9);
  color: var(--accent-strong);
  border: 1px solid rgba(255, 255, 255, 0.18);
  box-shadow: 0 10px 20px rgba(15, 23, 42, 0.12);
}

.cluster-card__hint {
  color: var(--muted);
  font-size: 0.84rem;
  line-height: 1.35;
}

.cluster-legend {
  display: flex;
  gap: 8px;
  align-items: start;
  padding: 10px 12px;
  border-radius: 14px;
  background: rgba(47, 111, 94, 0.08);
  color: var(--ink);
  line-height: 1.4;
}

.project-card {
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 12px;
  background: rgba(255, 255, 255, 0.72);
  display: grid;
  gap: 6px;
}

.project-card h3,
.project-card p {
  margin: 0;
}

.subpanel {
  margin-top: 12px;
  border-top: 1px solid var(--line);
  padding-top: 12px;
  display: grid;
  gap: 12px;
}

.select-label {
  display: grid;
  gap: 8px;
  font-size: 0.94rem;
  font-weight: 600;
}

.detail-card {
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 14px;
  background: rgba(255, 255, 255, 0.72);
}

.history-grid {
  display: grid;
  gap: 12px;
}

.history-card {
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 14px;
  background: rgba(255, 255, 255, 0.72);
  display: grid;
  gap: 12px;
}

.history-card__header {
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 12px;
}

.history-card__actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.history-card__header h3 {
  margin: 0;
  font-size: 1rem;
}

.history-card__meta {
  color: var(--muted);
  font-size: 0.86rem;
  white-space: nowrap;
}

.history-grid__compact {
  grid-template-columns: repeat(4, minmax(0, 1fr));
  margin-bottom: 0;
}

.detail-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  margin-bottom: 12px;
}

.detail-grid strong {
  display: block;
  margin-top: 4px;
  font-size: 0.95rem;
}

.detail-label {
  color: var(--muted);
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.detail-section {
  margin-top: 12px;
}

.detail-section h3 {
  margin: 0 0 8px;
  font-size: 0.92rem;
}

.detail-text {
  margin: 0;
  line-height: 1.45;
}

.detail-list {
  margin: 0;
  padding-left: 18px;
}

.detail-table {
  width: 100%;
  border-collapse: collapse;
}

.detail-table th,
.detail-table td {
  text-align: left;
  padding: 6px 6px;
  border-bottom: 1px solid #eee3cf;
  font-size: 0.84rem;
}

.table-wrap {
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.64);
}

.muted {
  color: var(--muted);
}

@media (max-width: 900px) {
  body {
    overflow: auto;
  }

  .shell {
    height: auto;
    grid-template-columns: 1fr;
    grid-template-rows: auto;
  }

  .grid.two,
  .grid.three {
    grid-template-columns: 1fr;
  }

  .context-bar {
    grid-template-columns: 1fr;
  }

  .detail-grid {
    grid-template-columns: 1fr;
  }

  .history-grid__compact {
    grid-template-columns: 1fr;
  }

  .cluster-grid {
    grid-template-columns: 1fr;
  }

  .analysis-summary {
    grid-template-columns: 1fr 1fr;
  }

  .monthly-profile-grid {
    grid-template-columns: 1fr;
  }

  .wizard-progress,
  .wizard-nav {
    flex-direction: column;
    align-items: stretch;
  }

  .hero,
  .panel {
    overflow: visible;
  }
}
