/* ============================================================
   储能套利优化分析 · 视觉升级
   字体：Manrope (UI) + IBM Plex Mono (数字)
   主题变量定义在 :root，可通过 data-theme 切换
   ============================================================ */

:root,
[data-theme="aurora"] {
  /* 画布与表层 */
  --bg: oklch(98.5% 0.003 90);
  --surface: #ffffff;
  --surface-2: oklch(97% 0.005 90);
  --surface-3: oklch(94.5% 0.008 90);

  /* 油墨与文本 */
  --ink: oklch(20% 0.02 250);
  --ink-2: oklch(35% 0.018 250);
  --muted: oklch(55% 0.012 250);
  --muted-2: oklch(68% 0.008 250);
  --hairline: oklch(92% 0.005 250);
  --hairline-strong: oklch(86% 0.008 250);

  /* 功能色：充/放/价/警 */
  --price: oklch(48% 0.14 265);          /* 靛蓝 — 现货电价 */
  --price-soft: oklch(48% 0.14 265 / 0.12);
  --charge: oklch(72% 0.13 75);          /* 琥珀 — 充电 */
  --charge-soft: oklch(72% 0.13 75 / 0.18);
  --discharge: oklch(58% 0.11 175);      /* 翡翠 — 放电 */
  --discharge-soft: oklch(58% 0.11 175 / 0.18);
  --soc: oklch(45% 0.025 250);           /* 石板 — SOC */
  --soc-soft: oklch(45% 0.025 250 / 0.10);

  --positive: oklch(55% 0.13 165);
  --negative: oklch(58% 0.18 25);
  --warning: oklch(72% 0.14 70);

  /* 阴影与圆角 */
  --shadow-sm: 0 1px 2px oklch(20% 0.02 250 / 0.04);
  --shadow-md: 0 4px 18px oklch(20% 0.02 250 / 0.06);
  --r-sm: 6px;
  --r-md: 10px;
  --r-lg: 14px;

  /* 字体 */
  --font-sans: "Manrope", "PingFang SC", "Microsoft YaHei", system-ui, -apple-system, sans-serif;
  --font-mono: "IBM Plex Mono", "JetBrains Mono", ui-monospace, "SFMono-Regular", Menlo, monospace;
  --font-display: "Manrope", "PingFang SC", system-ui, sans-serif;
}

/* 编辑级（米白 + 深棕 + 雾蓝） */
[data-theme="editorial"] {
  --bg: oklch(96.5% 0.012 85);
  --surface: oklch(99% 0.008 85);
  --surface-2: oklch(95% 0.013 85);
  --surface-3: oklch(91% 0.018 80);

  --ink: oklch(25% 0.04 50);
  --ink-2: oklch(38% 0.035 50);
  --muted: oklch(55% 0.025 60);
  --muted-2: oklch(68% 0.018 60);
  --hairline: oklch(89% 0.015 70);
  --hairline-strong: oklch(82% 0.022 65);

  --price: oklch(40% 0.09 235);
  --price-soft: oklch(40% 0.09 235 / 0.14);
  --charge: oklch(65% 0.14 55);
  --charge-soft: oklch(65% 0.14 55 / 0.20);
  --discharge: oklch(50% 0.11 195);
  --discharge-soft: oklch(50% 0.11 195 / 0.20);
  --soc: oklch(40% 0.05 60);
  --soc-soft: oklch(40% 0.05 60 / 0.10);

  --positive: oklch(50% 0.12 175);
  --negative: oklch(55% 0.17 30);
}

/* 深色：碳灰 */
[data-theme="carbon"] {
  --bg: oklch(16% 0.012 250);
  --surface: oklch(20% 0.014 250);
  --surface-2: oklch(23% 0.014 250);
  --surface-3: oklch(28% 0.015 250);

  --ink: oklch(96% 0.008 250);
  --ink-2: oklch(85% 0.010 250);
  --muted: oklch(65% 0.013 250);
  --muted-2: oklch(50% 0.012 250);
  --hairline: oklch(30% 0.012 250);
  --hairline-strong: oklch(38% 0.012 250);

  --price: oklch(75% 0.14 240);
  --price-soft: oklch(75% 0.14 240 / 0.18);
  --charge: oklch(78% 0.14 75);
  --charge-soft: oklch(78% 0.14 75 / 0.22);
  --discharge: oklch(74% 0.14 175);
  --discharge-soft: oklch(74% 0.14 175 / 0.22);
  --soc: oklch(70% 0.015 250);
  --soc-soft: oklch(70% 0.015 250 / 0.12);

  --positive: oklch(72% 0.16 165);
  --negative: oklch(70% 0.18 25);
  --warning: oklch(80% 0.15 75);

  --shadow-sm: 0 1px 2px oklch(0% 0 0 / 0.4);
  --shadow-md: 0 4px 18px oklch(0% 0 0 / 0.35);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-sans);
  font-feature-settings: "cv11", "ss03";
  font-variant-numeric: tabular-nums;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body { min-height: 100vh; }

button, input, select {
  font: inherit;
  color: inherit;
}

.mono { font-family: var(--font-mono); font-feature-settings: "zero", "ss01"; }

/* ===================== 顶栏 ===================== */
.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  gap: 18px;
  padding: 14px 28px;
  background: color-mix(in oklch, var(--surface) 88%, transparent);
  border-bottom: 1px solid var(--hairline);
  backdrop-filter: saturate(140%) blur(14px);
}

.brand {
  display: flex;
  align-items: center;
  gap: 14px;
}


.brand-text h1 {
  margin: 0;
  font-size: 15px;
  font-weight: 700;
  letter-spacing: -0.01em;
}
.brand-text p {
  margin: 1px 0 0;
  color: var(--muted);
  font-size: 11px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.topbar-spacer { flex: 1; }

.tag-row {
  display: flex;
  gap: 8px;
  align-items: center;
}

.tag {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 28px;
  padding: 0 10px;
  border-radius: 999px;
  border: 1px solid var(--hairline);
  background: var(--surface);
  color: var(--ink-2);
  font-size: 12px;
  font-weight: 500;
}
.tag .dot {
  width: 6px;
  height: 6px;
  border-radius: 999px;
  background: var(--positive);
}
.tag.muted { color: var(--muted); }
.tag .num { font-family: var(--font-mono); font-weight: 600; color: var(--ink); }

.btn {
  height: 34px;
  padding: 0 14px;
  border-radius: 8px;
  border: 1px solid var(--hairline-strong);
  background: var(--surface);
  color: var(--ink);
  font-weight: 600;
  font-size: 13px;
  cursor: pointer;
  transition: background 120ms ease, border-color 120ms ease, transform 80ms ease;
}
.btn:hover { background: var(--surface-2); }
.btn:active { transform: translateY(1px); }

.btn.primary {
  background: var(--ink);
  border-color: var(--ink);
  color: var(--surface);
}
.btn.primary:hover { background: var(--ink-2); border-color: var(--ink-2); }

.btn.ghost { background: transparent; border-color: transparent; color: var(--muted); }
.btn.ghost:hover { background: var(--surface-2); color: var(--ink); }

/* ===================== 主体 ===================== */
.shell {
  width: min(1480px, calc(100% - 56px));
  margin: 0 auto;
  padding: 28px 0 64px;
}

.section-title {
  display: flex;
  align-items: baseline;
  gap: 10px;
  margin: 0 0 14px;
}
.section-title h2 {
  margin: 0;
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--ink);
}
.section-title .hint {
  font-size: 12px;
  color: var(--muted);
}
.section-title::before {
  content: "";
  width: 4px;
  height: 4px;
  border-radius: 999px;
  background: var(--ink);
  transform: translateY(-2px);
}

/* ===================== KPI 行 ===================== */
.kpi-row {
  display: grid;
  grid-template-columns: 1.4fr 1fr 1fr 1fr 1fr;
  gap: 1px;
  margin-bottom: 22px;
  border: 1px solid var(--hairline);
  border-radius: var(--r-md);
  background: var(--hairline);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
}

.kpi {
  position: relative;
  padding: 20px 22px;
  background: var(--surface);
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.kpi-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.kpi-head .label {
  font-size: 12px;
  color: var(--muted);
  letter-spacing: 0.02em;
}
.kpi-head .pill {
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--muted-2);
  padding: 3px 7px;
  border-radius: 999px;
  background: var(--surface-2);
  border: 1px solid var(--hairline);
}

.kpi-value {
  display: flex;
  align-items: baseline;
  gap: 6px;
  margin-top: -4px;
}
.kpi-value .num {
  font-family: var(--font-mono);
  font-size: 34px;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--ink);
  line-height: 1;
}
.kpi-value .unit {
  color: var(--muted);
  font-size: 12px;
  font-weight: 500;
}

.kpi.hero { background: linear-gradient(180deg, var(--surface), var(--surface-2)); }
.kpi.hero .kpi-value .num { font-size: 44px; }
.kpi.hero .kpi-value .num.positive { color: var(--positive); }

.kpi-foot {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 11.5px;
  color: var(--muted);
}
.kpi-foot .delta {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  padding: 2px 6px;
  border-radius: 4px;
  background: color-mix(in oklch, var(--positive) 12%, transparent);
  color: var(--positive);
  font-weight: 700;
  font-size: 11px;
  font-family: var(--font-mono);
}
.kpi-foot .delta.neg {
  background: color-mix(in oklch, var(--negative) 12%, transparent);
  color: var(--negative);
}

/* sparkline */
.kpi-spark {
  position: absolute;
  right: 0;
  bottom: 0;
  width: 56%;
  height: 38px;
  opacity: 0.7;
  pointer-events: none;
}

/* ===================== 工作台主网格 ===================== */
.workbench {
  display: grid;
  grid-template-columns: minmax(0, 1.85fr) minmax(320px, 0.7fr);
  gap: 22px;
  align-items: start;
}

.card {
  background: var(--surface);
  border: 1px solid var(--hairline);
  border-radius: var(--r-md);
  box-shadow: var(--shadow-sm);
}

.card-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  padding: 20px 22px 0;
}
.card-head .title {
  margin: 0;
  font-size: 15px;
  font-weight: 700;
  letter-spacing: -0.005em;
}
.card-head .sub {
  margin: 5px 0 0;
  font-size: 12px;
  color: var(--muted);
}
.card-head .right { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }

/* time toolbar */
.time-toolbar {
  display: flex;
  align-items: center;
  gap: 14px;
  flex-wrap: wrap;
  padding: 16px 22px 0;
}
.seg {
  display: inline-flex;
  padding: 3px;
  border-radius: 8px;
  background: var(--surface-2);
  border: 1px solid var(--hairline);
}
.seg button {
  height: 28px;
  padding: 0 14px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--muted);
  font-size: 12.5px;
  font-weight: 600;
  cursor: pointer;
}
.seg button.is-active {
  background: var(--surface);
  color: var(--ink);
  box-shadow: var(--shadow-sm);
}

.field-inline {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  color: var(--muted);
}
.field-inline select {
  height: 32px;
  padding: 0 28px 0 10px;
  border-radius: 7px;
  border: 1px solid var(--hairline-strong);
  background: var(--surface);
  color: var(--ink);
  font-family: var(--font-mono);
  font-weight: 600;
  font-size: 12.5px;
}

/* day-strip */
.chip-strip {
  display: flex;
  gap: 6px;
  overflow-x: auto;
  padding: 12px 22px 4px;
  scrollbar-width: thin;
}
.chip-strip::-webkit-scrollbar { height: 6px; }
.chip-strip::-webkit-scrollbar-thumb { background: var(--hairline-strong); border-radius: 999px; }
.chip {
  flex: 0 0 auto;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-width: 56px;
  padding: 6px 10px;
  border-radius: 8px;
  border: 1px solid var(--hairline);
  background: var(--surface);
  color: var(--muted);
  font-size: 11px;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  transition: background 120ms;
}
.chip strong {
  font-family: var(--font-mono);
  font-size: 14px;
  color: var(--ink-2);
  font-weight: 700;
  line-height: 1.1;
}
.chip:hover { background: var(--surface-2); }
.chip.is-active {
  border-color: var(--ink);
  background: var(--ink);
  color: color-mix(in oklch, var(--surface) 80%, transparent);
}
.chip.is-active strong { color: var(--surface); }

/* 主时序：三段堆叠 */
.strategy-lanes {
  padding: 10px 22px 22px;
}
.legend-row {
  display: flex;
  gap: 14px;
  align-items: center;
  padding: 6px 0 4px;
  flex-wrap: wrap;
}
.legend {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 11.5px;
  color: var(--muted);
  font-weight: 500;
}
.legend .swatch {
  width: 14px;
  height: 3px;
  border-radius: 2px;
  background: var(--price);
}
.legend.charge .swatch { background: var(--charge); height: 8px; border-radius: 2px; }
.legend.discharge .swatch { background: var(--discharge); height: 8px; border-radius: 2px; }
.legend.soc .swatch { background: var(--soc); }

.lane {
  position: relative;
  margin-top: 10px;
}
.lane-tag {
  position: absolute;
  top: 8px;
  left: 0;
  z-index: 2;
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 10.5px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  font-weight: 700;
  color: var(--muted-2);
}
.lane-tag .bar {
  width: 14px;
  height: 2px;
  background: var(--ink-2);
  border-radius: 2px;
}
.lane.flow .lane-tag .bar { background: var(--charge); }
.lane.soc .lane-tag .bar { background: var(--soc); }

.lane canvas {
  display: block;
  width: 100% !important;
}
.lane.price canvas { height: 200px !important; }
.lane.flow canvas { height: 150px !important; }
.lane.soc canvas { height: 120px !important; }

/* ===================== 策略侧栏 ===================== */
.side {
  display: grid;
  gap: 14px;
}

.metric-list {
  padding: 18px 22px 22px;
  display: grid;
  gap: 14px;
}
.metric-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px;
  align-items: end;
  padding-bottom: 12px;
  border-bottom: 1px dashed var(--hairline);
}
.metric-row:last-child { border-bottom: 0; padding-bottom: 0; }
.metric-row .label {
  font-size: 12px;
  color: var(--muted);
}
.metric-row .label small {
  display: block;
  margin-top: 3px;
  font-size: 10.5px;
  color: var(--muted-2);
  letter-spacing: 0.02em;
}
.metric-row .val {
  font-family: var(--font-mono);
  font-size: 22px;
  font-weight: 700;
  color: var(--ink);
  line-height: 1;
  letter-spacing: -0.01em;
}
.metric-row .val small {
  font-size: 11px;
  color: var(--muted);
  font-weight: 500;
  margin-left: 4px;
}

.insight-card {
  padding: 14px 16px;
  border-radius: var(--r-sm);
  border-left: 3px solid var(--positive);
  background: color-mix(in oklch, var(--positive) 6%, var(--surface));
}
.insight-card[data-level="warning"] {
  border-left-color: var(--warning);
  background: color-mix(in oklch, var(--warning) 8%, var(--surface));
}
.insight-card[data-level="danger"] {
  border-left-color: var(--negative);
  background: color-mix(in oklch, var(--negative) 8%, var(--surface));
}
.insight-card .title {
  display: block;
  font-size: 12px;
  font-weight: 700;
  margin-bottom: 4px;
  color: var(--ink);
}
.insight-card .body {
  font-size: 12px;
  color: var(--ink-2);
  line-height: 1.5;
}

.insights-stack { padding: 0 22px 18px; display: grid; gap: 10px; }

/* ===================== 分析三图 ===================== */
.analysis-grid {
  display: grid;
  grid-template-columns: 1.2fr 1fr;
  gap: 22px;
  margin-top: 22px;
}
.analysis-grid > .card:last-child { grid-column: 1 / -1; }

.analysis-body {
  padding: 14px 22px 22px;
}
.analysis-body.tall { height: 260px; }
.analysis-body.short { height: 220px; }
.analysis-body canvas { display: block; width: 100% !important; height: 100% !important; }

/* breakdown row of bars */
.breakdown-rows {
  padding: 14px 22px 22px;
  display: grid;
  gap: 14px;
}
.bd-row {
  display: grid;
  grid-template-columns: 110px 1fr 120px;
  align-items: center;
  gap: 14px;
}
.bd-row .label {
  font-size: 13px;
  color: var(--ink-2);
  font-weight: 500;
}
.bd-row .bar {
  height: 22px;
  position: relative;
  background: var(--surface-2);
  border-radius: 4px;
  overflow: hidden;
}
.bd-row .bar-fill {
  position: absolute;
  top: 0;
  bottom: 0;
  border-radius: 4px;
  transition: width 600ms ease;
}
.bd-row .bar-fill.cost { background: var(--charge); right: 50%; }
.bd-row .bar-fill.revenue { background: var(--discharge); left: 50%; }
.bd-row .bar-fill.opex { background: var(--muted-2); right: 50%; }
.bd-row .bar-fill.net { background: var(--price); left: 50%; }
.bd-row .bar-axis {
  position: absolute;
  top: 0; bottom: 0;
  left: 50%;
  width: 1px;
  background: var(--hairline-strong);
}
.bd-row .val {
  font-family: var(--font-mono);
  font-size: 14px;
  font-weight: 700;
  text-align: right;
  color: var(--ink);
}
.bd-row .val.neg { color: var(--charge); }
.bd-row .val.pos { color: var(--discharge); }
.bd-row .val.net { color: var(--price); }

/* ===================== Tweaks 面板 ===================== */
.tweaks-toggle {
  position: fixed;
  right: 22px;
  bottom: 22px;
  z-index: 60;
  width: 44px;
  height: 44px;
  border-radius: 999px;
  border: 1px solid var(--hairline-strong);
  background: var(--surface);
  color: var(--ink);
  display: grid;
  place-items: center;
  cursor: pointer;
  box-shadow: var(--shadow-md);
}
.tweaks-toggle:hover { background: var(--surface-2); }

.tweaks-panel {
  position: fixed;
  right: 22px;
  bottom: 78px;
  z-index: 60;
  width: 280px;
  background: var(--surface);
  border: 1px solid var(--hairline);
  border-radius: var(--r-md);
  box-shadow: var(--shadow-md);
  padding: 16px;
  display: none;
}
.tweaks-panel.is-open { display: block; }
.tweaks-panel h4 {
  margin: 0 0 4px;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}
.tweaks-panel p {
  margin: 0 0 12px;
  font-size: 11.5px;
  color: var(--muted);
}
.tweaks-panel .group {
  margin-bottom: 14px;
}
.tweaks-panel .group:last-child { margin-bottom: 0; }
.tweaks-panel label.row-label {
  display: block;
  font-size: 11px;
  color: var(--muted);
  margin-bottom: 6px;
  font-weight: 600;
  letter-spacing: 0.02em;
}
.theme-grid {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 6px;
}
.theme-swatch {
  cursor: pointer;
  border-radius: 8px;
  border: 1px solid var(--hairline);
  background: var(--surface-2);
  padding: 8px;
  text-align: center;
  font-size: 11px;
  color: var(--ink-2);
  font-weight: 600;
}
.theme-swatch:hover { border-color: var(--hairline-strong); }
.theme-swatch.is-active { border-color: var(--ink); background: var(--surface); }
.theme-swatch .strip {
  display: flex;
  height: 14px;
  border-radius: 3px;
  overflow: hidden;
  margin-bottom: 6px;
}
.theme-swatch .strip span { flex: 1; }

.font-options {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
}
.font-option {
  cursor: pointer;
  border-radius: 8px;
  border: 1px solid var(--hairline);
  background: var(--surface-2);
  padding: 8px 10px;
  font-size: 12px;
  color: var(--ink-2);
  font-weight: 600;
  text-align: left;
}
.font-option .small {
  display: block;
  font-size: 10px;
  color: var(--muted);
  font-weight: 500;
  margin-top: 2px;
}
.font-option.is-active { border-color: var(--ink); background: var(--surface); color: var(--ink); }

/* ===================== Responsive ===================== */
@media (max-width: 1180px) {
  .kpi-row { grid-template-columns: repeat(3, 1fr); }
  .workbench { grid-template-columns: 1fr; }
  .analysis-grid { grid-template-columns: 1fr; }
}
@media (max-width: 720px) {
  .topbar { padding: 12px 16px; flex-wrap: wrap; }
  .shell { width: calc(100% - 28px); padding-top: 18px; }
  .kpi-row { grid-template-columns: 1fr 1fr; }
  .kpi-value .num { font-size: 26px; }
  .kpi.hero .kpi-value .num { font-size: 32px; }
}

/* ===================== 状态指示 ===================== */
#statusTag { transition: background 200ms, border-color 200ms; }
#statusTag[data-tone="success"] { border-color: color-mix(in oklch, var(--positive) 40%, transparent); background: color-mix(in oklch, var(--positive) 8%, var(--surface)); }
#statusTag[data-tone="danger"]  { border-color: color-mix(in oklch, var(--negative) 40%, transparent); background: color-mix(in oklch, var(--negative) 8%, var(--surface)); }
#statusTag[data-tone="idle"]    { border-color: var(--hairline); }
#statusDot { transition: background 200ms; }
#statusTag[data-tone="success"] #statusDot { background: var(--positive); }
#statusTag[data-tone="danger"]  #statusDot { background: var(--negative); }
#statusTag[data-tone="idle"]    #statusDot { background: var(--muted-2); }

/* ===================== 抽屉 ===================== */
.drawer-overlay {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 40;
  background: oklch(0% 0 0 / 0.3);
  backdrop-filter: blur(2px);
}
.drawer-overlay.is-open { display: block; }

.drawer {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  z-index: 50;
  width: min(440px, 100vw);
  background: var(--surface);
  border-left: 1px solid var(--hairline);
  box-shadow: -4px 0 24px oklch(20% 0.02 250 / 0.08);
  display: flex;
  flex-direction: column;
  transform: translateX(100%);
  transition: transform 260ms cubic-bezier(0.4, 0, 0.2, 1);
}
.drawer.is-open { transform: none; }

.drawer-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  padding: 22px 24px;
  border-bottom: 1px solid var(--hairline);
  flex: 0 0 auto;
}
.drawer-header h2 { margin: 0; font-size: 16px; font-weight: 700; }
.drawer-header p  { margin: 4px 0 0; font-size: 12.5px; color: var(--muted); }

.drawer-body {
  flex: 1;
  overflow-y: auto;
  padding: 0 24px 24px;
  scrollbar-width: thin;
}

.drawer-footer {
  padding: 16px 24px;
  border-top: 1px solid var(--hairline);
  flex: 0 0 auto;
}

.btn.full { width: 100%; justify-content: center; display: flex; }

/* ===================== 表单 ===================== */
.form-section { padding-top: 20px; }
.form-section h3 {
  margin: 0 0 14px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
}

.field { margin-bottom: 14px; }
.field label {
  display: block;
  margin-bottom: 6px;
  font-size: 12.5px;
  color: var(--ink-2);
  font-weight: 500;
}
.field input[type="number"],
.field input[type="text"] {
  width: 100%;
  height: 38px;
  padding: 0 12px;
  border-radius: var(--r-sm);
  border: 1px solid var(--hairline-strong);
  background: var(--surface);
  color: var(--ink);
  font-family: var(--font-mono);
  font-size: 13px;
  font-weight: 600;
  outline: none;
  transition: border-color 140ms;
}
.field input:focus { border-color: var(--price); }

/* 电价来源标签 */
.source-tabs {
  display: flex;
  gap: 6px;
  margin-bottom: 16px;
}
.source-tab {
  height: 32px;
  padding: 0 14px;
  border-radius: 8px;
  border: 1px solid var(--hairline);
  background: var(--surface-2);
  color: var(--muted);
  font-size: 12.5px;
  font-weight: 600;
  cursor: pointer;
  transition: background 120ms, color 120ms, border-color 120ms;
}
.source-tab.is-active {
  background: var(--surface);
  color: var(--ink);
  border-color: var(--hairline-strong);
}

/* 文件上传 */
.upload-box { display: grid; gap: 10px; }
.file-picker {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  height: 38px;
  padding: 0 8px 0 12px;
  border-radius: var(--r-sm);
  border: 1px solid var(--hairline-strong);
  background: var(--surface-2);
  cursor: pointer;
  font-size: 12.5px;
  color: var(--muted);
  overflow: hidden;
}
.file-picker input[type="file"] { display: none; }
.file-picker #fileName { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.upload-status { margin: 0; font-size: 12px; color: var(--muted); }

.is-hidden { display: none !important; }

/* 分时电价构建器 */
.tariff-price-grid {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr 1fr;
  gap: 8px;
  margin-bottom: 16px;
}
.tariff-price-card {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 10px;
  border-radius: var(--r-sm);
  border: 1px solid var(--hairline);
  background: var(--surface-2);
  cursor: pointer;
}
.tariff-price-card span { font-size: 11px; color: var(--muted); font-weight: 600; }
.tariff-price-card input {
  width: 100%;
  border: none;
  background: transparent;
  font-family: var(--font-mono);
  font-size: 16px;
  font-weight: 700;
  color: var(--ink);
  outline: none;
  padding: 0;
}
.tariff-price-card em { font-size: 10px; color: var(--muted-2); font-style: normal; }

.tariff-valley { border-color: color-mix(in oklch, oklch(72% 0.13 75) 40%, transparent); }
.tariff-flat   { border-color: color-mix(in oklch, oklch(55% 0.08 265) 40%, transparent); }
.tariff-peak   { border-color: color-mix(in oklch, oklch(58% 0.18 25) 40%, transparent); }
.tariff-sharp  { border-color: color-mix(in oklch, oklch(58% 0.18 0) 40%, transparent); }

.tariff-block { margin-bottom: 16px; }
.tariff-block-head {
  display: flex;
  align-items: baseline;
  gap: 8px;
  margin-bottom: 10px;
}
.tariff-block-head strong { font-size: 12.5px; color: var(--ink-2); font-weight: 700; }
.tariff-block-head span   { font-size: 11.5px; color: var(--muted); }

.month-toggle-grid {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 6px;
}
.month-toggle {
  height: 30px;
  border-radius: 6px;
  border: 1px solid var(--hairline);
  background: var(--surface-2);
  font-size: 12px;
  font-weight: 600;
  color: var(--muted);
  cursor: pointer;
  transition: background 100ms, color 100ms, border-color 100ms;
}
.month-toggle.is-active {
  background: var(--ink);
  color: var(--surface);
  border-color: var(--ink);
}

.tariff-brushes {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  margin-bottom: 10px;
}
.tariff-brush {
  height: 30px;
  padding: 0 12px;
  border-radius: 6px;
  border: 1px solid var(--hairline);
  background: var(--surface-2);
  font-size: 12px;
  font-weight: 600;
  color: var(--muted);
  cursor: pointer;
}

.hour-grid {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 4px;
}
.hour-cell {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  padding: 6px 2px;
  border-radius: 5px;
  border: 1px solid var(--hairline);
  background: var(--surface-2);
  cursor: pointer;
  font-size: 9px;
  color: var(--muted);
  transition: background 100ms, border-color 100ms;
}
.hour-cell span { font-family: var(--font-mono); font-size: 9.5px; color: var(--muted-2); }
.hour-cell strong { font-size: 10px; }
.hour-cell.is-active { background: var(--ink); color: var(--surface); border-color: var(--ink); }
.hour-cell.is-active span { color: oklch(90% 0.01 250); }
/* when inline background overrides the default, inherit the inline color */
.hour-cell[style*="background"] span,
.hour-cell[style*="background"] strong { color: inherit; }

.tariff-summary {
  padding: 12px;
  border-radius: var(--r-sm);
  background: var(--surface-2);
  border: 1px solid var(--hairline);
  font-size: 12px;
  color: var(--muted);
  line-height: 1.8;
  margin-bottom: 12px;
}
.tariff-summary strong { color: var(--ink); }
