:root {
  color-scheme: light;
  --bg: #f7f8fa;
  --surface: #ffffff;
  --surface-soft: #f2f5f7;
  --surface-panel: #fbfcfd;
  --ink: #17201d;
  --muted: #68736f;
  --line: #dce3e0;
  --line-strong: #c5d0cc;
  --accent: #0f766e;
  --accent-strong: #0b5f59;
  --accent-soft: #e1f3f0;
  --signal: #4253b8;
  --signal-soft: #e9ecfb;
  --amber: #a45f19;
  --steel: #53625c;
  --ok: #247447;
  --shadow: 0 10px 24px rgba(25, 36, 32, 0.06);
  --radius: 8px;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: "Noto Sans TC", "PingFang TC", "Microsoft JhengHei", sans-serif;
  color: var(--ink);
  background: var(--bg);
}

button {
  font: inherit;
}

.shell {
  width: min(1440px, calc(100% - 32px));
  margin: 0 auto;
  padding: 16px 0 32px;
  display: grid;
  gap: 12px;
}

.top-region {
  position: sticky;
  top: 0;
  z-index: 10;
  display: grid;
  grid-template-columns: minmax(230px, 0.72fr) minmax(0, 1.28fr);
  grid-template-areas:
    "brand controls"
    "status controls";
  gap: 4px 18px;
  align-items: center;
  padding: 12px 0;
  border-bottom: 1px solid var(--line);
  background: rgba(247, 248, 250, 0.92);
  backdrop-filter: blur(14px);
}

.brand-lockup {
  grid-area: brand;
  display: grid;
  gap: 3px;
  min-width: 0;
}

.command-bar {
  grid-area: controls;
  display: flex;
  justify-content: flex-end;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.view-tabs {
  display: inline-flex;
  gap: 4px;
  padding: 3px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface-soft);
}

.tab-button {
  min-height: 30px;
  border: 0;
  border-radius: calc(var(--radius) - 2px);
  padding: 5px 10px;
  color: var(--muted);
  background: transparent;
  font-size: 0.78rem;
  font-weight: 850;
  cursor: pointer;
}

.tab-button[data-active="true"] {
  color: #ffffff;
  background: var(--ink);
}

.dashboard-view {
  display: none;
}

.dashboard-view[data-active="true"] {
  display: grid;
  gap: 12px;
}

.status-line {
  grid-area: status;
  color: var(--muted);
  font-size: 0.84rem;
  line-height: 1.45;
}

.status-block,
.range-module {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.range-module {
  justify-content: flex-end;
}

.eyebrow {
  margin: 0;
  color: var(--accent-strong);
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  min-width: 0;
  overflow-wrap: anywhere;
  font-size: 1.55rem;
  line-height: 1.15;
  font-weight: 850;
  letter-spacing: 0;
}

h2 {
  font-size: 1rem;
  line-height: 1.25;
  font-weight: 800;
  letter-spacing: 0;
}

.subtle {
  color: var(--muted);
  font-size: 0.82rem;
  line-height: 1.42;
}

.range-caption {
  flex: 0 0 auto;
  color: var(--muted);
  font-size: 0.75rem;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

.range-controls {
  display: flex;
  gap: 6px;
  min-width: 0;
}

#usage-range-controls {
  overflow-x: auto;
  scrollbar-width: none;
}

#usage-range-controls::-webkit-scrollbar {
  display: none;
}

.range-chip {
  flex: 0 0 auto;
  min-height: 32px;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--muted);
  border-radius: var(--radius);
  padding: 6px 10px;
  font-size: 0.8rem;
  font-weight: 800;
  cursor: pointer;
  transition: border-color 140ms ease, background-color 140ms ease, color 140ms ease, box-shadow 140ms ease;
}

.range-chip:hover:not(:disabled),
.range-chip:focus-visible:not(:disabled) {
  border-color: var(--accent);
  color: var(--ink);
  outline: none;
  box-shadow: 0 0 0 3px rgba(15, 118, 110, 0.12);
}

.range-chip[data-active="true"] {
  border-color: var(--accent);
  background: var(--accent);
  color: #ffffff;
}

.range-chip:disabled {
  cursor: wait;
  opacity: 0.6;
}

.badge,
.hero-window {
  display: inline-flex;
  align-items: center;
  min-height: 32px;
  width: fit-content;
  border-radius: var(--radius);
  padding: 6px 10px;
  font-size: 0.8rem;
  font-weight: 800;
  white-space: nowrap;
}

.badge {
  border: 1px solid var(--line);
  background: var(--surface-soft);
  color: var(--steel);
}

.badge.ready {
  border-color: rgba(36, 116, 71, 0.18);
  background: rgba(36, 116, 71, 0.08);
  color: var(--ok);
}

.hero-window {
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--ink);
}

.summary-strip {
  display: grid;
  gap: 8px;
  padding-top: 2px;
}

.summary-head {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 14px;
}

.hero-metrics {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
}

.metric-card,
.panel,
.fold-card {
  border: 1px solid var(--line);
  background: var(--surface);
  box-shadow: var(--shadow);
}

.metric-card {
  display: grid;
  gap: 5px;
  min-height: 94px;
  padding: 13px;
  border-radius: var(--radius);
  border-left: 4px solid var(--accent);
}

.metric-card[data-tone="input"] {
  border-left-color: var(--signal);
}

.metric-card[data-tone="output"] {
  border-left-color: var(--amber);
}

.metric-card[data-tone="events"] {
  border-left-color: var(--steel);
}

.metric-card[data-tone="memory"] {
  border-left-color: var(--signal);
}

.metric-card[data-tone="gpu"] {
  border-left-color: var(--amber);
}

.metric-label {
  color: var(--muted);
  font-size: 0.75rem;
  font-weight: 800;
}

.metric-value {
  min-width: 0;
  overflow-wrap: anywhere;
  font-size: 1.48rem;
  font-weight: 880;
  line-height: 1.1;
  letter-spacing: 0;
}

.metric-hint {
  color: var(--muted);
  font-size: 0.75rem;
  line-height: 1.36;
}

.workspace-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.6fr) minmax(320px, 0.82fr);
  gap: 12px;
  align-items: start;
}

.workspace-side,
.support-grid {
  display: grid;
  gap: 12px;
}

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

.panel {
  border-radius: var(--radius);
  padding: 14px;
}

.panel-primary {
  min-height: 100%;
}

.panel-header {
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
  padding-bottom: 9px;
  border-bottom: 1px solid var(--line);
}

.panel-header-stack {
  align-items: start;
}

.panel-header-stack > div:first-child {
  display: grid;
  gap: 3px;
}

.stack {
  display: grid;
  gap: 8px;
}

.fold-card {
  overflow: hidden;
  border-radius: var(--radius);
  background: var(--surface);
}

.fold-card summary {
  list-style: none;
  cursor: pointer;
}

.fold-card summary::-webkit-details-marker {
  display: none;
}

.fold-summary {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 12px;
  align-items: center;
  padding: 11px;
}

.fold-summary-copy,
.fold-summary-side {
  display: grid;
  gap: 4px;
  min-width: 0;
}

.fold-summary-side {
  justify-items: end;
  text-align: right;
}

.fold-kicker {
  color: var(--accent-strong);
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

.fold-title {
  min-width: 0;
  overflow-wrap: anywhere;
  font-size: 0.96rem;
  line-height: 1.25;
}

.fold-value {
  font-size: 0.92rem;
  font-weight: 850;
  white-space: nowrap;
}

.fold-toggle {
  color: var(--muted);
  font-size: 0.76rem;
  font-weight: 800;
}

.fold-toggle::before {
  content: "展開";
}

.fold-card[open] .fold-toggle::before {
  content: "收合";
}

.fold-content {
  padding: 11px;
  border-top: 1px solid var(--line);
  background: var(--surface-panel);
}

.row-card {
  display: grid;
  gap: 7px;
  padding: 10px 11px;
  border-radius: var(--radius);
  background: var(--surface);
  border: 1px solid var(--line);
}

.row-line {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
}

.row-lead {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.row-rank {
  display: inline-flex;
  min-width: 28px;
  justify-content: center;
  padding: 3px 7px;
  border-radius: var(--radius);
  background: var(--accent-soft);
  color: var(--accent-strong);
  font-size: 0.72rem;
  font-weight: 850;
}

.row-title {
  min-width: 0;
  overflow-wrap: anywhere;
}

.row-value {
  color: var(--ink);
  font-size: 0.86rem;
  font-weight: 850;
  white-space: nowrap;
}

.bar-track {
  overflow: hidden;
  height: 7px;
  border-radius: 999px;
  background: var(--surface-soft);
}

.bar-fill {
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--accent), var(--signal));
}

.bar-fill[data-tone="memory"] {
  background: linear-gradient(90deg, var(--signal), #7b83d6);
}

.bar-fill[data-tone="gpu"] {
  background: linear-gradient(90deg, var(--amber), #d58b31);
}

.resource-row {
  display: grid;
  gap: 7px;
  padding: 10px 11px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
}

.resource-bars {
  display: grid;
  gap: 6px;
}

.resource-bar-line {
  display: grid;
  grid-template-columns: 72px minmax(0, 1fr) 54px;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  font-size: 0.76rem;
  font-weight: 800;
}

.chart-shell,
.sustainability-shell {
  display: grid;
  gap: 10px;
}

.chart-summary {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
}

.chart-stat,
.context-card,
.estimate-card {
  display: grid;
  gap: 5px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface-panel);
}

.chart-stat {
  padding: 10px 11px;
}

.chart-stat-label,
.context-kicker {
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 850;
  letter-spacing: 0;
  text-transform: uppercase;
}

.chart-stat-value,
.context-value {
  min-width: 0;
  overflow-wrap: anywhere;
  font-size: 0.96rem;
  font-weight: 850;
  letter-spacing: 0;
}

.chart-wrap {
  position: relative;
  overflow: hidden;
  border-radius: var(--radius);
  padding: 11px 10px 4px;
  background: #ffffff;
  border: 1px solid var(--line);
}

.chart-svg {
  display: block;
  width: 100%;
  height: auto;
}

.chart-grid-line {
  stroke: #d7dfd9;
  stroke-width: 1;
  stroke-dasharray: 4 8;
}

.chart-grid-label,
.chart-axis-label {
  fill: var(--muted);
  font-size: 11px;
}

.chart-area {
  fill: url(#dailyAreaGradient);
}

.chart-line {
  fill: none;
  stroke: var(--accent);
  stroke-width: 3;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.chart-dot {
  fill: #ffffff;
  stroke: var(--accent);
  stroke-width: 2;
}

.chart-dot.is-peak {
  fill: var(--signal);
  stroke: #ffffff;
}

.chart-dot.is-latest {
  stroke: var(--ok);
}

.chart-hit-zone {
  fill: transparent;
  cursor: crosshair;
}

.chart-tooltip {
  position: absolute;
  min-width: 164px;
  max-width: min(240px, calc(100% - 24px));
  padding: 10px 12px;
  border-radius: var(--radius);
  border: 1px solid rgba(255, 255, 255, 0.14);
  background: rgba(23, 32, 27, 0.94);
  color: #ffffff;
  box-shadow: 0 18px 36px rgba(23, 32, 27, 0.22);
  pointer-events: none;
  opacity: 0;
  transform: translateY(6px);
  transition: opacity 140ms ease, transform 140ms ease;
  z-index: 2;
}

.chart-tooltip[data-visible="true"] {
  opacity: 1;
  transform: translateY(0);
}

.chart-tooltip-date {
  font-size: 0.8rem;
  font-weight: 800;
  color: rgba(226, 243, 239, 0.9);
}

.chart-tooltip-value {
  margin-top: 4px;
  font-size: 1rem;
  font-weight: 850;
}

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

.context-grid {
  margin-bottom: 8px;
}

.context-card {
  padding: 10px 11px;
}

.context-copy {
  color: var(--muted);
  font-size: 0.8rem;
  line-height: 1.42;
}

.estimate-card {
  min-height: 118px;
  padding: 12px;
  border-left: 4px solid var(--accent);
}

.estimate-card[data-tone="carbon"],
.estimate-card[data-tone="output"] {
  border-left-color: var(--amber);
}

.estimate-card[data-tone="total"] {
  border-left-color: var(--signal);
}

.estimate-card[data-tone="input"],
.estimate-card[data-tone="energy"] {
  border-left-color: var(--accent);
}

.estimate-card[data-tone="events"] {
  border-left-color: var(--steel);
}

.estimate-label {
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 850;
}

.estimate-value {
  min-width: 0;
  overflow-wrap: anywhere;
  font-size: 1.46rem;
  font-weight: 880;
  line-height: 1.12;
}

.estimate-range {
  color: var(--accent-strong);
  font-size: 0.82rem;
  font-weight: 800;
}

.estimate-hint {
  color: var(--muted);
  font-size: 0.8rem;
  line-height: 1.42;
}

.thermal-panel {
  background: linear-gradient(180deg, #ffffff 0%, #fbfcfd 100%);
}

.thermal-shell {
  display: grid;
  gap: 10px;
}

.thermal-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(168px, 1fr));
  gap: 8px;
}

.thermal-tile {
  display: grid;
  gap: 9px;
  min-width: 0;
  min-height: 134px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #ffffff;
  box-shadow: 0 8px 18px rgba(25, 36, 32, 0.04);
}

.thermal-tile[data-tone="cool"] {
  border-top: 4px solid var(--accent);
}

.thermal-tile[data-tone="warm"] {
  border-top: 4px solid var(--amber);
}

.thermal-tile[data-tone="hot"] {
  border-top: 4px solid #b43b2a;
}

.thermal-tile[data-tone="missing"] {
  border-top: 4px solid var(--line-strong);
  background: var(--surface-panel);
}

.thermal-tile-head {
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 8px;
  min-width: 0;
}

.thermal-label {
  min-width: 0;
  color: var(--ink);
  font-size: 0.82rem;
  font-weight: 850;
  line-height: 1.25;
  overflow-wrap: anywhere;
}

.thermal-source {
  flex: 0 1 auto;
  max-width: 52%;
  color: var(--muted);
  font-size: 0.68rem;
  font-weight: 800;
  line-height: 1.2;
  text-align: right;
  overflow-wrap: anywhere;
}

.thermal-value {
  min-width: 0;
  overflow-wrap: anywhere;
  font-size: clamp(1.32rem, 1.2rem + 0.35vw, 1.72rem);
  font-weight: 880;
  line-height: 1.05;
  letter-spacing: 0;
}

.thermal-track {
  overflow: hidden;
  height: 9px;
  border-radius: 999px;
  background: var(--surface-soft);
}

.thermal-fill {
  min-width: 2%;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--accent), var(--signal));
}

.thermal-tile[data-tone="warm"] .thermal-fill {
  background: linear-gradient(90deg, var(--amber), #d79643);
}

.thermal-tile[data-tone="hot"] .thermal-fill {
  background: linear-gradient(90deg, #b43b2a, #e27850);
}

.thermal-tile[data-tone="missing"] .thermal-fill {
  background: var(--line-strong);
}

.thermal-meta {
  color: var(--muted);
  font-size: 0.74rem;
  font-weight: 780;
  line-height: 1.35;
}

.thermal-trend {
  display: grid;
  gap: 6px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface-panel);
}

.thermal-trend-title {
  color: var(--muted);
  font-size: 0.74rem;
  font-weight: 850;
  letter-spacing: 0;
  text-transform: uppercase;
}

.thermal-trend-row {
  display: grid;
  grid-template-columns: 92px minmax(88px, 0.7fr) minmax(0, 1.7fr);
  align-items: center;
  gap: 10px;
  min-height: 36px;
  padding: 7px 8px;
  border: 1px solid var(--line);
  border-radius: calc(var(--radius) - 2px);
  background: #ffffff;
}

.thermal-trend-time,
.thermal-trend-value {
  min-width: 0;
  color: var(--muted);
  font-size: 0.74rem;
  font-weight: 800;
  line-height: 1.25;
}

.thermal-trend-value {
  color: var(--steel);
  overflow-wrap: anywhere;
}

.thermal-mini-bars {
  display: grid;
  grid-template-columns: repeat(5, minmax(10px, 1fr));
  align-items: end;
  gap: 5px;
  height: 28px;
  min-width: 0;
}

.thermal-mini {
  width: 100%;
  min-height: 4px;
  border-radius: 999px 999px 2px 2px;
  background: var(--accent);
}

.thermal-mini[data-tone="gpu"] {
  background: var(--amber);
}

.thermal-mini[data-tone="battery"] {
  background: var(--signal);
}

.thermal-mini[data-tone="battery2"] {
  background: #7a63b7;
}

.thermal-mini[data-tone="airport"] {
  background: var(--steel);
}

.thermal-mini[data-tone="selected"] {
  background: #2f8d72;
}

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

.empty-state {
  padding: 12px;
  border-radius: var(--radius);
  color: var(--muted);
  background: var(--surface-soft);
  border: 1px dashed var(--line-strong);
}

@media (max-width: 1120px) {
  .top-region {
    grid-template-columns: 1fr;
    grid-template-areas:
      "brand"
      "controls"
      "status";
  }

  .command-bar,
  .range-module {
    justify-content: flex-start;
  }

  .workspace-grid,
  .support-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 820px) {
  .shell {
    width: min(100% - 22px, 1440px);
    padding-top: 12px;
  }

  .top-region {
    position: static;
  }

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

  .view-tabs {
    width: fit-content;
  }

  .status-block,
  .range-module {
    justify-content: flex-start;
  }

  .hero-metrics,
  .thermal-grid,
  .thermal-fan-grid,
  .chart-summary,
  .sustainability-grid,
  .context-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .panel-header,
  .summary-head {
    flex-direction: column;
    align-items: start;
  }

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

  .fold-summary-side {
    justify-items: start;
    text-align: left;
  }

  .thermal-trend-row {
    grid-template-columns: 86px minmax(74px, 0.8fr) minmax(0, 1.4fr);
  }
}

@media (max-width: 520px) {
  h1 {
    font-size: 1.32rem;
  }

  .hero-metrics,
  .thermal-grid,
  .thermal-fan-grid,
  .chart-summary,
  .sustainability-grid,
  .context-grid {
    grid-template-columns: 1fr;
  }

  .range-module,
  .status-block,
  .row-line {
    align-items: start;
    flex-direction: column;
  }

  .row-value,
  .fold-value {
    white-space: normal;
  }

  .thermal-tile {
    min-height: 118px;
  }

  .thermal-trend-row {
    grid-template-columns: 1fr;
    align-items: start;
  }

  .thermal-mini-bars {
    width: 100%;
  }
}
