:root {
  --bg: #f5f7f4;
  --panel: #ffffff;
  --ink: #17201b;
  --muted: #657169;
  --line: #dfe7df;
  --accent: #005dab;
  --accent-dark: #005dab;
  --sun: #d88b19;
  --warn: #b9442b;
  --ok: #005dab;
  --shadow: 0 18px 45px rgba(28, 42, 34, 0.08);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  color: var(--ink);
  background:
    linear-gradient(135deg, rgba(0, 93, 171, 0.08), transparent 42%),
    var(--bg);
  font-family: Inter, "PingFang SC", "Microsoft YaHei", Arial, sans-serif;
}

button,
input,
select {
  font: inherit;
}

.app {
  width: min(1440px, calc(100% - 40px));
  margin: 0 auto;
  padding: 28px 0 40px;
}

.topbar {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 24px;
  margin-bottom: 20px;
}

.eyebrow {
  margin: 0 0 7px;
  color: var(--accent);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

h1,
h2 {
  margin: 0;
  letter-spacing: 0;
}

h1 {
  font-size: clamp(28px, 4vw, 44px);
  line-height: 1.05;
}

h2 {
  font-size: 17px;
  line-height: 1.25;
}

.top-actions {
  min-width: 260px;
}

.top-actions label {
  display: block;
  margin-bottom: 8px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

select,
input {
  width: 100%;
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #fff;
  color: var(--ink);
  padding: 9px 11px;
  outline: none;
  transition: border 0.16s ease, box-shadow 0.16s ease;
}

select:focus,
input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(0, 93, 171, 0.14);
}

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

.metric,
.panel,
.net-grid article {
  background: rgba(255, 255, 255, 0.92);
  border: 1px solid rgba(223, 231, 223, 0.9);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.metric {
  padding: 18px;
  min-height: 136px;
}

.metric span,
.net-grid span {
  display: block;
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

.metric strong {
  display: block;
  margin-top: 10px;
  font-size: clamp(24px, 3vw, 36px);
  line-height: 1.05;
}

.metric small {
  display: block;
  margin-top: 9px;
  color: var(--muted);
  line-height: 1.45;
}

.metric.primary {
  background: #005dab;
  color: #fff;
}

.metric.primary span,
.metric.primary small {
  color: rgba(255, 255, 255, 0.78);
}

.workspace {
  display: grid;
  grid-template-columns: minmax(360px, 0.95fr) minmax(520px, 1.4fr);
  gap: 14px;
  align-items: start;
}

.panel {
  min-width: 0;
  padding: 20px;
}

.input-panel {
  position: sticky;
  top: 14px;
}

.section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}

.ghost {
  min-height: 38px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #f8faf8;
  color: var(--accent-dark);
  padding: 8px 12px;
  cursor: pointer;
  font-weight: 800;
}

.export-button {
  min-height: 38px;
  border: 0;
  border-radius: 7px;
  background: var(--accent);
  color: #fff;
  padding: 8px 14px;
  cursor: pointer;
  font-weight: 800;
}

.export-button:hover {
  background: var(--accent-dark);
}

.lookup-button {
  min-height: 42px;
  border: 0;
  border-radius: 7px;
  background: var(--accent);
  color: #fff;
  padding: 9px 14px;
  cursor: pointer;
  font-weight: 800;
  white-space: nowrap;
}

.lookup-button:hover {
  background: var(--accent-dark);
}

.lookup-button:disabled {
  cursor: wait;
  opacity: 0.65;
}

.location-field,
.location-candidates {
  grid-column: 1 / -1;
}

.input-action {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
}

.fields {
  display: grid;
  min-width: 0;
  gap: 13px;
  margin: 14px 0 24px;
}

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

.fields label,
.input-action {
  min-width: 0;
}

.custom-panel-fields {
  grid-column: 1 / -1;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 13px;
  padding: 13px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8faf8;
}

.custom-panel-fields[hidden] {
  display: none;
}

label span {
  display: block;
  min-height: 18px;
  margin-bottom: 7px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.solar-resource {
  margin: 0 0 24px;
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  padding: 18px 0 4px;
}

.solar-head {
  align-items: flex-start;
  margin-bottom: 10px;
}

.solar-fields {
  grid-template-columns: repeat(2, minmax(0, 1fr));
  margin-bottom: 10px;
}

.source-note {
  margin: 0 0 14px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.5;
}

details {
  border-top: 1px solid var(--line);
  padding-top: 14px;
}

summary {
  cursor: pointer;
  color: var(--accent-dark);
  font-weight: 900;
}

.monthly-inputs {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  margin-top: 14px;
}

.month-edit {
  display: grid;
  grid-template-columns: 52px 1fr 1fr;
  gap: 8px;
  align-items: end;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfb;
}

.month-edit b {
  padding-bottom: 10px;
  color: var(--accent-dark);
}

.project-facts {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
  margin-bottom: 16px;
}

.fact {
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfb;
}

.fact span {
  display: block;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.fact strong {
  display: block;
  margin-top: 7px;
  font-size: 17px;
}

.status {
  display: inline-flex;
  align-items: center;
  min-height: 30px;
  border-radius: 999px;
  padding: 4px 10px;
  background: #eef5ef;
  color: var(--muted);
  font-size: 12px;
  font-weight: 900;
}

.status.ok {
  background: #e9f6ee;
  color: var(--ok);
}

.status.warn {
  background: #fff1ed;
  color: var(--warn);
}

.status.loading {
  background: #fff4df;
  color: #8b5a10;
}

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

th,
td {
  border-bottom: 1px solid var(--line);
  padding: 11px 10px;
  text-align: right;
  white-space: nowrap;
}

th:first-child,
td:first-child {
  text-align: left;
}

th {
  color: var(--muted);
  font-size: 12px;
  font-weight: 900;
}

td {
  font-size: 14px;
}

.scenario-table-wrap,
.monthly-table-wrap {
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  margin-bottom: 18px;
}

.scenario-table tr:last-child td,
.monthly-table tr:last-child td {
  border-bottom: 0;
}

.scenario-table tbody tr.robot td {
  background: rgba(0, 93, 171, 0.08);
  font-weight: 800;
}

.net-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 22px;
}

.net-grid article {
  padding: 15px;
  box-shadow: none;
}

.net-grid strong {
  display: block;
  margin-top: 9px;
  color: var(--accent-dark);
  font-size: 22px;
  line-height: 1.1;
}

.net-grid small {
  display: block;
  margin-top: 7px;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.45;
}

.monthly-table-wrap {
  max-height: 460px;
}

.monthly-table thead {
  position: sticky;
  top: 0;
  background: #fff;
  z-index: 1;
}

.chart-card {
  margin: 12px 0 18px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  padding: 8px;
  overflow: hidden;
}

.chart-tooltip i {
  display: inline-block;
  width: 10px;
  height: 10px;
  border-radius: 50%;
}

.chart-stage {
  position: relative;
  min-width: 0;
  overflow: hidden;
  border-radius: 6px;
}

.chart-stage canvas {
  display: block;
  max-width: 100%;
  touch-action: pan-y;
}

.chart-tooltip {
  position: absolute;
  z-index: 2;
  width: 210px;
  transform: translateX(-50%);
  border: 1px solid var(--line);
  border-radius: 7px;
  background: rgba(255, 255, 255, 0.97);
  box-shadow: 0 10px 28px rgba(28, 42, 34, 0.14);
  padding: 10px;
  pointer-events: none;
}

.chart-tooltip strong {
  display: block;
  margin-bottom: 7px;
}

.chart-tooltip span {
  display: grid;
  grid-template-columns: 10px 1fr auto;
  align-items: center;
  gap: 7px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.8;
}

.chart-tooltip b {
  color: var(--ink);
}

.monthly-details {
  border-top: 0;
  padding-top: 0;
}

.monthly-details .monthly-table-wrap {
  margin-top: 12px;
}

@media (max-width: 1120px) {
  .summary-grid,
  .workspace {
    grid-template-columns: 1fr;
  }

  .input-panel {
    position: static;
  }

  .summary-grid,
  .project-facts,
  .net-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 680px) {
  .app {
    width: min(100% - 24px, 1440px);
    padding-top: 18px;
  }

  .topbar {
    align-items: stretch;
    flex-direction: column;
  }

  .top-actions {
    min-width: 0;
  }

  .fields.two,
  .solar-fields,
  .summary-grid,
  .project-facts,
  .net-grid,
  .monthly-inputs {
    grid-template-columns: 1fr;
  }

  .custom-panel-fields {
    grid-template-columns: 1fr;
  }

  .input-action {
    grid-template-columns: 1fr;
  }

  .panel,
  .metric {
    padding: 16px;
  }
}

/* Professional energy-tool theme */
:root {
  --bg: #070916;
  --panel: #1d2639;
  --ink: #f7f8fb;
  --muted: #aab2c1;
  --line: #354157;
  --accent: #159bd7;
  --accent-dark: #005dab;
  --sun: #f2aa18;
  --warn: #ff7864;
  --ok: #159bd7;
  --shadow: 0 18px 38px rgba(0, 0, 0, 0.28);
}

body {
  background: var(--bg);
}

.app {
  width: min(1480px, calc(100% - 48px));
  padding: 0 0 48px;
}

.topbar {
  align-items: center;
  gap: 16px;
  min-height: 96px;
  margin-bottom: 22px;
  border-bottom: 1px solid var(--line);
}

.brand-mark {
  display: block;
  flex: 0 0 172px;
  width: 172px;
  height: 48px;
  border: 0;
  border-radius: 0;
  background: transparent;
  object-fit: contain;
  object-position: center;
}

.title-block {
  min-width: 0;
}

.eyebrow {
  margin-bottom: 4px;
}

h1 {
  font-size: 26px;
  line-height: 1.2;
}

h2 {
  font-size: 16px;
}

.page-subtitle {
  margin: 5px 0 0;
  color: var(--muted);
  font-size: 12px;
}

.header-badge {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  margin-left: auto;
  border: 1px solid rgba(242, 170, 24, 0.4);
  border-radius: 7px;
  background: rgba(242, 170, 24, 0.1);
  color: #ffd16b;
  padding: 10px 14px;
  font-size: 13px;
  font-weight: 800;
}

.header-badge span {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--sun);
  box-shadow: 0 0 12px rgba(242, 170, 24, 0.75);
}

.language-switch {
  display: inline-grid;
  grid-template-columns: 1fr 1fr;
  gap: 3px;
  margin-left: auto;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #0d1423;
  padding: 3px;
  color: var(--muted);
  cursor: pointer;
}

.language-switch span {
  min-width: 42px;
  border-radius: 5px;
  padding: 7px 9px;
  text-align: center;
  font-size: 12px;
  font-weight: 800;
}

.language-switch span.active {
  background: var(--accent);
  color: #ffffff;
}

select,
input {
  border-color: var(--line);
  background: #0e1626;
  color: var(--ink);
}

select {
  color-scheme: dark;
}

select:focus,
input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(21, 155, 215, 0.2);
}

.metric,
.panel,
.net-grid article {
  border-color: var(--line);
  background: var(--panel);
}

.metric {
  position: relative;
  z-index: 0;
  overflow: hidden;
  min-height: 126px;
  padding: 17px 18px;
  transform: translateY(0) scale(1);
  transform-origin: center;
  transition: transform 180ms ease, border-color 180ms ease, box-shadow 180ms ease;
}

.metric:hover {
  z-index: 2;
  border-color: rgba(21, 155, 215, 0.72);
  box-shadow: 0 22px 44px rgba(0, 0, 0, 0.38), 0 0 0 1px rgba(21, 155, 215, 0.16);
  transform: translateY(-5px) scale(1.025);
}

.metric::before {
  position: absolute;
  top: 0;
  right: 0;
  left: 0;
  height: 3px;
  background: linear-gradient(90deg, #005dab 0%, #159bd7 58%, #35bce9 100%);
  content: "";
}

.metric:nth-child(2)::before,
.metric:nth-child(4)::before {
  background: linear-gradient(90deg, #005dab 0%, #159bd7 58%, #35bce9 100%);
}

.metric:nth-child(3)::before {
  background: linear-gradient(90deg, #005dab 0%, #159bd7 58%, #35bce9 100%);
}

.metric strong {
  color: var(--accent);
  font-size: 28px;
}

.metric.primary {
  border-color: rgba(21, 155, 215, 0.72);
  background: #17283b;
}

.metric.primary::before {
  background: linear-gradient(90deg, #005dab 0%, #159bd7 58%, #35bce9 100%);
}

.metric.primary strong {
  color: var(--accent);
}

.workspace {
  grid-template-columns: minmax(390px, 0.9fr) minmax(620px, 1.55fr);
  gap: 18px;
}

.section-head h2,
.input-panel > h2,
.results-panel > h2 {
  display: flex;
  align-items: center;
  gap: 9px;
}

.section-head h2::before,
.input-panel > h2::before,
.results-panel > h2::before {
  width: 3px;
  height: 16px;
  border-radius: 2px;
  background: var(--accent);
  content: "";
}

.ghost {
  background: transparent;
  color: var(--accent);
}

.export-button,
.lookup-button {
  color: #ffffff;
}

.custom-panel-fields,
.month-edit,
.fact,
.net-grid article {
  background: #121a2a;
}

.status {
  background: rgba(154, 172, 191, 0.12);
}

.status.ok {
  background: rgba(21, 155, 215, 0.16);
}

.status.warn {
  background: rgba(255, 120, 100, 0.12);
}

.status.loading {
  background: rgba(242, 170, 24, 0.12);
  color: #ffd16b;
}

thead {
  background: #121a2a;
}

tbody tr:nth-child(even) td {
  background: rgba(255, 255, 255, 0.025);
}

.scenario-table tbody tr.robot td {
  background: rgba(21, 155, 215, 0.15);
  color: #ffffff;
}

.net-grid strong {
  color: var(--accent);
}

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

.monthly-table thead {
  background: var(--panel);
}

.chart-card,
.chart-stage {
  background: #0e1626;
}

.chart-tooltip {
  background: rgba(7, 9, 22, 0.97);
  box-shadow: 0 10px 28px rgba(0, 0, 0, 0.28);
}

@media (max-width: 1120px) {
  .workspace {
    grid-template-columns: 1fr;
  }

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

@media (max-width: 680px) {
  .app {
    width: min(100% - 24px, 1480px);
  }

  .topbar {
    align-items: center;
    flex-direction: row;
    gap: 10px;
    min-height: 88px;
  }

  .language-switch span {
    min-width: 34px;
    padding: 6px;
  }

  .brand-mark {
    display: block;
    flex-basis: 96px;
    width: 96px;
    height: 34px;
  }

  h1 {
    font-size: 16px;
  }

  .page-subtitle {
    display: none;
  }

  .results-panel .net-grid {
    grid-template-columns: 1fr;
  }
}

@media (prefers-reduced-motion: reduce) {
  .metric {
    transition: none;
  }

  .metric:hover {
    transform: none;
  }
}
