:root {
  --bg: #f2f2f0;
  --surface: #ffffff;
  --surface-soft: #fafafa;
  --ink: #0b0b0c;
  --muted: #606067;
  --faint: #909096;
  --line: #e2e2df;
  --line-strong: #cfcfcb;
  --accent: #b8860b;
  --accent-soft: rgba(184, 134, 11, 0.1);
  --green: #1a7f4b;
  --radius: 5px;
  --sidebar: 232px;
}

* { box-sizing: border-box; }

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

body {
  margin: 0;
  min-width: 320px;
  background: var(--bg);
  color: var(--ink);
  font-family: "IBM Plex Sans", sans-serif;
  font-size: 14px;
  line-height: 1.45;
}

button, input { font: inherit; }
button { cursor: pointer; }
a { color: inherit; text-decoration: none; }

.mono { font-family: "IBM Plex Mono", monospace; }
.eyebrow, .nav-heading {
  color: var(--faint);
  font-family: "IBM Plex Sans Condensed", sans-serif;
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

.brand { align-items: center; display: inline-flex; font-size: 16px; font-weight: 600; gap: 9px; }
.brand > span:last-child > span { color: var(--faint); font-weight: 400; }
.brand-mark { display: flex; gap: 3px; height: 20px; align-items: end; }
.brand-mark span { background: var(--ink); display: block; width: 4px; }
.brand-mark span:nth-child(1) { height: 7px; }
.brand-mark span:nth-child(2) { height: 14px; }
.brand-mark span:nth-child(3) { height: 20px; }

.login-body { min-height: 100vh; }
.login-shell { align-items: center; display: flex; justify-content: center; min-height: 100vh; padding: 24px; }
.login-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: 0 1px 2px rgba(11, 11, 12, 0.05);
  display: grid;
  gap: 22px;
  max-width: 408px;
  padding: 34px;
  width: 100%;
}
.login-card .eyebrow { margin: 30px 0 6px; }
.login-card h1 { font-size: 27px; letter-spacing: -0.02em; line-height: 1.12; margin: 0; }
.login-copy { color: var(--muted); margin: 10px 0 0; }
.login-form { display: grid; gap: 7px; }
.login-form label { font-family: "IBM Plex Sans Condensed", sans-serif; font-size: 11px; font-weight: 600; letter-spacing: 0.1em; margin-top: 5px; text-transform: uppercase; }
.login-form input {
  background: var(--surface-soft);
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  font-family: "IBM Plex Mono", monospace;
  padding: 10px 11px;
}
.login-form input:focus { border-color: var(--ink); outline: 2px solid var(--accent-soft); }
.button-primary, .button-secondary {
  border-radius: var(--radius);
  font-weight: 600;
  padding: 10px 13px;
  width: 100%;
}
.button-primary { background: var(--ink); border: 1px solid var(--ink); color: var(--bg); margin-top: 10px; }
.button-secondary { background: var(--surface); border: 1px solid var(--line-strong); color: var(--muted); }
.button-primary:hover, .button-secondary:hover { border-color: var(--ink); opacity: 0.84; }
.form-error { background: #fff0ef; border-left: 3px solid #b4342b; color: #7f201b; font-size: 12px; padding: 8px 10px; }
.login-note { color: var(--faint); font-size: 12px; margin: 0; }
.login-footer { border-top: 1px solid var(--line); color: var(--faint); display: flex; font-family: "IBM Plex Mono", monospace; font-size: 10px; gap: 12px; padding-top: 16px; }

.app-shell { display: grid; grid-template-columns: var(--sidebar) minmax(0, 1fr); min-height: 100vh; }
.sidebar { background: var(--surface); border-right: 1px solid var(--line); display: flex; flex-direction: column; height: 100vh; overflow-y: auto; padding: 18px 10px 12px; position: sticky; top: 0; }
.sidebar .brand { border-bottom: 1px solid var(--line); margin: 0 0 10px; padding: 3px 8px 15px; }
.navigation { display: grid; gap: 2px; }
.nav-heading { margin: 15px 8px 4px; }
.nav-item { border-left: 2px solid transparent; border-radius: 0 var(--radius) var(--radius) 0; color: var(--muted); font-size: 13px; padding: 7px 9px; }
.nav-item:hover { background: var(--surface-soft); color: var(--ink); }
.nav-item.is-active { background: var(--surface-soft); border-left-color: var(--ink); color: var(--ink); font-weight: 600; }
.sidebar-user { align-items: center; border-top: 1px solid var(--line); display: grid; gap: 8px; grid-template-columns: 27px minmax(0, 1fr); margin-top: auto; padding: 12px 5px 0; }
.sidebar-user .avatar { align-items: center; background: var(--ink); border-radius: 3px; color: var(--bg); display: flex; font-family: "IBM Plex Mono", monospace; font-size: 10px; height: 27px; justify-content: center; text-transform: uppercase; width: 27px; }
.sidebar-user strong, .sidebar-user small { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sidebar-user strong { font-size: 11px; font-weight: 600; }
.sidebar-user small { color: var(--faint); font-size: 10px; }
.sidebar-user form { grid-column: 1 / -1; }
.sidebar-user button { background: none; border: 0; color: var(--faint); font-size: 11px; padding: 0; }
.sidebar-user button:hover { color: var(--ink); }

.main-content { max-width: 1540px; min-width: 0; padding: 27px 30px 72px; }
.page-header { align-items: end; display: flex; gap: 18px; justify-content: space-between; margin-bottom: 18px; }
.page-header .eyebrow { margin: 0 0 4px; }
.page-header h1 { font-size: 25px; letter-spacing: -0.025em; line-height: 1.1; margin: 0; }
.page-header p:not(.eyebrow) { color: var(--muted); margin: 5px 0 0; }
.status-chip, .tag { border: 1px solid var(--line-strong); border-radius: 3px; color: var(--faint); font-family: "IBM Plex Mono", monospace; font-size: 10px; padding: 3px 6px; white-space: nowrap; }
.status-chip { border-color: var(--accent); color: var(--accent); }
.workspace-grid { align-items: start; display: grid; gap: 12px; grid-template-columns: minmax(0, 1fr) minmax(270px, 0.34fr); }
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); min-width: 0; }
.panel-wide { min-height: 390px; }
.panel-header { align-items: flex-start; border-bottom: 1px solid var(--line); display: flex; gap: 10px; justify-content: space-between; padding: 13px 15px; }
.panel-header h2 { font-size: 14px; letter-spacing: -0.01em; margin: 0; }
.panel-header p { color: var(--faint); font-family: "IBM Plex Mono", monospace; font-size: 11px; margin: 3px 0 0; }
.filter-row { display: flex; flex-wrap: wrap; gap: 5px; justify-content: end; }
.empty-state { align-items: center; color: var(--muted); display: flex; flex-direction: column; justify-content: center; min-height: 315px; padding: 30px; text-align: center; }
.empty-state h2 { color: var(--ink); font-size: 16px; margin: 14px 0 5px; }
.empty-state p { margin: 0; max-width: 56ch; }
.empty-state.compact { min-height: 145px; }
.empty-mark { align-items: center; border: 1px solid var(--line-strong); border-radius: 3px; color: var(--accent); display: flex; font-family: "IBM Plex Mono", monospace; font-size: 13px; height: 34px; justify-content: center; width: 34px; }
.placeholder-panel { min-height: 440px; }
.detail-list { margin: 0; padding: 0; }
.detail-list div { border-bottom: 1px solid var(--line); display: grid; gap: 8px; grid-template-columns: 1fr auto; padding: 11px 15px; }
.detail-list div:last-child { border-bottom: 0; }
.detail-list dt { color: var(--faint); font-size: 12px; }
.detail-list dd { font-family: "IBM Plex Mono", monospace; font-size: 11px; margin: 0; }

.raw-price-history { display: grid; gap: 12px; }
.control-row { align-items: end; display: flex; flex-wrap: wrap; gap: 16px; justify-content: space-between; }
.control-row .eyebrow { margin: 0 0 6px; }
.zone-tabs, .segmented { display: flex; flex-wrap: wrap; gap: 4px; }
.zone-tab, .segmented button, .export-link {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  color: var(--muted);
  font-family: "IBM Plex Mono", monospace;
  font-size: 11px;
  padding: 6px 10px;
}
.comparison-select { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); color: var(--ink); font-family: "IBM Plex Mono", monospace; font-size: 11px; min-height: 30px; padding: 5px 9px; }
.comparison-time-controls { align-items: end; justify-content: start; }
.comparison-note { color: var(--faint); font-family: "IBM Plex Mono", monospace; font-size: 10px; margin: 0; max-width: 560px; }
.comparison-availability { background: var(--accent-soft); border-left: 2px solid var(--accent); color: var(--ink-2); font-family: "IBM Plex Mono", monospace; font-size: 11px; padding: 9px 12px; }
.forecast-ops-note { align-items: start; background: var(--surface); border: 1px solid var(--line); border-left: 3px solid var(--accent); border-radius: var(--radius); display: grid; gap: 4px 12px; grid-template-columns: max-content 1fr; padding: 10px 13px; }
.forecast-ops-note strong { color: var(--ink); font-family: "IBM Plex Sans Condensed", sans-serif; font-size: 11px; text-transform: uppercase; }
.forecast-ops-note span { color: var(--muted); font-size: 11px; line-height: 1.5; }
.forecast-control-note { color: var(--faint); font-family: "IBM Plex Mono", monospace; font-size: 10px; margin: -6px 0 0; }
.forecast-quality-note { align-items: start; background: var(--surface); border: 1px solid var(--line); border-left: 3px solid var(--accent); border-radius: var(--radius); display: grid; gap: 4px 12px; grid-template-columns: max-content 1fr; padding: 10px 13px; }
.forecast-quality-note strong { color: var(--ink); font-family: "IBM Plex Sans Condensed", sans-serif; font-size: 11px; text-transform: uppercase; }
.forecast-quality-note span { color: var(--muted); font-size: 11px; line-height: 1.5; }
.quality-good { color: var(--pos); }
.quality-average { color: var(--accent); }
.quality-poor { color: var(--neg); font-weight: 600; }
.quality-none { color: var(--faint); }
.quality-selected-row td { background: var(--surface-soft); }
.negative-price-row td, .negative-price-cell { background: var(--neg-soft); color: var(--neg); }
.negative-price-row td:first-child { font-weight: 600; }
.ttf-instrument-note { align-items: start; background: var(--surface); border: 1px solid var(--line); border-left: 3px solid var(--accent); border-radius: var(--radius); display: grid; gap: 4px 12px; grid-template-columns: max-content 1fr; padding: 10px 13px; }
.ttf-instrument-note strong { color: var(--ink); font-family: "IBM Plex Sans Condensed", sans-serif; font-size: 11px; text-transform: uppercase; }
.ttf-instrument-note span { color: var(--muted); font-size: 11px; line-height: 1.5; }
.ttf-instrument-note code { font-family: "IBM Plex Mono", monospace; }
.comparison-matrix { min-width: 540px; }
.comparison-matrix td:not(:first-child), .comparison-matrix th:not(:first-child) { text-align: right; }
.zone-tab:hover, .segmented button:hover, .export-link:hover { border-color: var(--ink); color: var(--ink); }
.zone-tab[aria-pressed="true"], .segmented button[aria-pressed="true"] { background: var(--ink); border-color: var(--ink); color: var(--bg); }
.segmented button:disabled { background: var(--surface-soft); color: var(--faint); cursor: not-allowed; }
.loading-state { color: var(--faint); font-family: "IBM Plex Mono", monospace; font-size: 12px; padding: 28px 0; }
.history-error { margin: 0; }
.metadata-strip { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); display: flex; flex-wrap: wrap; }
.metadata-strip > div { border-right: 1px solid var(--line); display: grid; gap: 2px; padding: 9px 14px; }
.metadata-strip > div:last-child { border-right: 0; }
.metadata-strip span { color: var(--faint); font-size: 10px; text-transform: uppercase; }
.metadata-strip strong { font-family: "IBM Plex Mono", monospace; font-size: 11px; font-weight: 500; }
.chart-wrap { min-height: 360px; padding: 10px 14px 4px; position: relative; }
.raw-price-chart { display: block; height: 360px; overflow: visible; width: 100%; }
.chart-grid-line { stroke: var(--line); stroke-width: 1; }
.chart-zero-line { stroke: var(--muted); stroke-width: 1.25; }
.chart-axis-label { fill: var(--faint); font-family: "IBM Plex Mono", monospace; font-size: 10px; }
.chart-zero-label { fill: var(--muted); font-family: "IBM Plex Mono", monospace; font-size: 10px; }
.chart-line { stroke: var(--ink); stroke-linecap: round; stroke-linejoin: round; stroke-width: 1.6; vector-effect: non-scaling-stroke; }
.chart-crosshair { stroke: var(--accent); stroke-dasharray: 3 3; stroke-width: 1; }
.chart-tooltip { background: var(--surface); border: 1px solid var(--line-strong); border-radius: var(--radius); box-shadow: 0 4px 14px rgba(0, 0, 0, 0.12); display: none; font-family: "IBM Plex Mono", monospace; font-size: 11px; gap: 4px; padding: 8px 10px; pointer-events: none; position: absolute; top: 10px; white-space: nowrap; z-index: 2; }
.chart-tooltip.is-visible { display: grid; }
.chart-tooltip span { color: var(--muted); }
#unavailabilityTooltip { max-width: min(420px, calc(100% - 16px)); white-space: normal; }
.generation-legend { align-items: center; border-bottom: 1px solid var(--line); display: flex; flex-wrap: wrap; gap: 8px 14px; min-height: 34px; padding: 7px 15px; }
.generation-legend span { align-items: center; color: var(--muted); display: inline-flex; font-family: "IBM Plex Mono", monospace; font-size: 10px; gap: 5px; }
.generation-legend i { display: block; height: 9px; width: 9px; }
.unavailability-summary { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); display: grid; grid-template-columns: repeat(5, minmax(130px, 1fr)); overflow-x: auto; }
.unavailability-summary > div { border-right: 1px solid var(--line); display: grid; gap: 3px; min-width: 150px; padding: 9px 14px; }
.unavailability-summary > div:last-child { border-right: 0; }
.unavailability-summary span { color: var(--faint); font-size: 10px; text-transform: uppercase; }
.unavailability-summary strong { font-family: "IBM Plex Mono", monospace; font-size: 11px; font-weight: 500; }
.table-actions { align-items: center; display: flex; flex-wrap: wrap; gap: 5px; justify-content: end; }
.table-note { border-bottom: 1px solid var(--line); color: var(--faint); font-family: "IBM Plex Mono", monospace; font-size: 10px; padding: 8px 14px; }
.history-table-scroll { contain: inline-size; max-height: 490px; max-width: 100%; min-width: 0; overflow: auto; width: 100%; }
.history-table-scroll.is-horizontal { overflow-x: scroll; }
.history-table { border-collapse: collapse; min-width: 790px; width: 100%; }
.history-table th, .history-table td { border-bottom: 1px solid var(--line); padding: 7px 14px; text-align: left; white-space: nowrap; }
.history-table th { background: var(--surface); color: var(--faint); font-family: "IBM Plex Sans Condensed", sans-serif; font-size: 10px; letter-spacing: 0.08em; position: sticky; text-transform: uppercase; top: 0; z-index: 1; }
.history-table td { font-family: "IBM Plex Mono", monospace; font-size: 11px; }
.history-table th:first-child, .history-table td:first-child { text-align: left; }
.horizontal-table { min-width: max-content; width: max-content; }
.horizontal-table th:first-child { left: 0; position: sticky; z-index: 2; }

@media (max-width: 920px) {
  :root { --sidebar: 64px; }
  .sidebar { align-items: center; padding-inline: 6px; }
  .sidebar .brand { justify-content: center; padding-inline: 0; width: 100%; }
  .brand > span:last-child, .nav-heading, .nav-item { font-size: 0; }
  .nav-item { height: 34px; padding: 0; position: relative; width: 100%; }
  .nav-item::after { background: currentColor; border-radius: 50%; content: ""; height: 5px; left: calc(50% - 2.5px); position: absolute; top: calc(50% - 2.5px); width: 5px; }
  .sidebar-user { grid-template-columns: 1fr; justify-items: center; }
  .sidebar-user > span:not(.avatar), .sidebar-user form { display: none; }
  .workspace-grid { grid-template-columns: 1fr; }
  .control-row { align-items: start; flex-direction: column; }
}

@media (max-width: 620px) {
  .app-shell { display: block; }
  .sidebar { bottom: 0; border-right: 0; border-top: 1px solid var(--line); display: block; height: 57px; left: 0; overflow-x: auto; padding: 6px; position: fixed; right: 0; top: auto; z-index: 5; }
  .sidebar .brand, .nav-heading, .sidebar-user { display: none; }
  .navigation { display: flex; min-width: 760px; }
  .nav-item { flex: 0 0 43px; }
  .main-content { padding: 20px 13px 82px; }
  .page-header { align-items: start; flex-direction: column; }
  .status-chip { white-space: normal; }
  .login-shell { padding: 16px; }
  .login-card { padding: 25px; }
  .chart-wrap, .raw-price-chart { height: 310px; min-height: 310px; }
  .metadata-strip > div { border-bottom: 1px solid var(--line); border-right: 0; width: 100%; }
  .metadata-strip > div:last-child { border-bottom: 0; }
  .panel-header { align-items: start; flex-direction: column; }
  .table-actions { justify-content: start; }
}
