:root {
  color-scheme: dark;
  --ink: #e7eef7;
  --muted: #a6b5c7;
  --line: #2a3a4a;
  --line-strong: #40586d;
  --bg: #0a1018;
  --paper: #101a25;
  --paper-raised: #162433;
  --control: #0c1520;
  --navy: #0b121b;
  --navy-raised: #142434;
  --blue: #55e0c3;
  --blue-dark: #97f0dc;
  --blue-soft: #16373c;
  --green: #75dfaf;
  --signal: #67ebd2;
  --amber: #f4c786;
  --red: #ffaaa5;
  --radius: 13px;
  --control-radius: 7px;
  --ease-out: cubic-bezier(.17,.75,.28,1);
  --masthead: 65px;
  --gutter: clamp(16px, 3.1vw, 52px);
  --sans: Geist, Inter, "PingFang SC", "Microsoft YaHei", system-ui, sans-serif;
  --data: "IBM Plex Mono", "SFMono-Regular", Consolas, monospace;
  font-family: var(--sans);
  scrollbar-color: #486277 #101922;
  scroll-padding-top: calc(var(--masthead-offset, var(--masthead)) + 14px);
  color: var(--ink);
  background: var(--bg);
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; min-height: 100dvh; background: radial-gradient(ellipse 75% 700px at 72% -350px, #1a3446 0%, transparent 100%); }
button, input, select { font: inherit; }
a { color: inherit; }
button, a, input, select { -webkit-tap-highlight-color: transparent; }
:focus-visible { outline: 2px solid var(--signal); outline-offset: 3px; }
::selection { background: #9bf1df; color: #102328; }
h1, h2, h3, p { margin: 0; }
h1 { font-size: clamp(27px, 3.2vw, 44px); font-weight: 650; letter-spacing: -.035em; line-height: 1.12; }
h2 { font-size: 16px; font-weight: 660; line-height: 1.45; }
h3 { font-size: 14px; }
p { line-height: 1.55; }
small { font-size: 12px; }

.skip { position: fixed; left: 12px; top: -100px; z-index: 12; padding: 10px; background: var(--paper-raised); }
.skip:focus { top: 8px; }
.brand { display: flex; align-items: center; gap: 12px; color: var(--ink); text-decoration: none; }
.brand strong { font-size: 17px; letter-spacing: .035em; white-space: nowrap; font-weight: 680; }
.brand-mark { display: grid; place-items: center; width: 38px; height: 38px; border: 1px solid #3f625e; border-radius: 10px; background: #142a2f; flex: 0 0 auto; position: relative; }
.brand-mark::before { content: ""; width: 23px; height: 19px; background: var(--signal); clip-path: polygon(0 81%, 30% 81%, 30% 55%, 56% 55%, 56% 30%, 82% 30%, 82% 5%, 100% 5%, 100% 22%, 94% 22%, 94% 45%, 69% 45%, 69% 70%, 43% 70%, 43% 96%, 0 96%); }
nav { display: flex; justify-content: center; align-items: stretch; gap: 6px; min-width: 0; }
nav a { display: flex; align-items: center; justify-content: center; gap: 7px; min-height: 40px; padding: 7px clamp(8px, 1.05vw, 17px); border: 1px solid transparent; border-radius: var(--control-radius); color: var(--muted); font-size: 13px; text-decoration: none; white-space: nowrap; transition: background-color 150ms, color 150ms, border-color 150ms; }
nav a:hover { background: var(--navy-raised); color: var(--ink); }
nav a[aria-current] { color: #acfae8; border-color: #32554f; background: #162d31; font-weight: 650; }
.nav-icon { display: block; width: 14px; height: 14px; flex: 0 0 14px; position: relative; }
.overview-icon { background: linear-gradient(currentColor 0 0) left top / 6px 6px no-repeat,
  linear-gradient(currentColor 0 0) right top / 6px 6px no-repeat,
  linear-gradient(currentColor 0 0) left bottom / 6px 6px no-repeat,
  linear-gradient(currentColor 0 0) right bottom / 6px 6px no-repeat; }
.files-icon { border: 1.5px solid currentColor; border-radius: 2px; }
.files-icon::after { content: ""; position: absolute; inset: 3px 2px; border-block: 1px solid currentColor; }
.clock-icon { border: 1.5px solid currentColor; border-radius: 50%; }
.clock-icon::after { content: ""; position: absolute; width: 4px; height: 4px; left: 5px; top: 2px; border-left: 1px solid currentColor; border-bottom: 1px solid currentColor; }
.results-icon { background: currentColor; clip-path: polygon(0 88%,4% 75%,30% 48%,51% 64%,86% 19%,70% 19%,70% 7%,100% 7%,100% 36%,88% 36%,88% 28%,53% 79%,31% 63%,8% 88%); }
.ai-icon { border: 1px solid currentColor; border-radius: 3px; }
.ai-icon::after { content: ""; position: absolute; inset: 3px; border-inline: 1px solid currentColor; transform: skew(-13deg); }
.dot { width: 7px; height: 7px; display: inline-block; border-radius: 50%; background: var(--green); box-shadow: 0 0 0 3px #76e3ad20; }
.shell { min-width: 0; }
.topbar { position: sticky; top: 0; z-index: 6; min-height: var(--masthead); background: #0c141eee; backdrop-filter: blur(14px); border-bottom: 1px solid var(--line); display: grid; grid-template-columns: minmax(max-content, 1fr) minmax(0, auto) minmax(max-content, 1fr); align-items: center; padding: 10px var(--gutter); gap: 16px; }
.topbar-actions { justify-self: end; display: flex; align-items: center; gap: 12px; }
.history-toolbar { display: flex; align-items: center; gap: 2px; padding: 3px; border: 1px solid var(--line); border-radius: 9px; background: var(--control); }
.history-button { display: grid; place-items: center; width: 32px; height: 32px; padding: 0; border: 0; border-radius: 5px; background: transparent; color: var(--ink); cursor: pointer; }
.history-button:hover:not(:disabled) { color: var(--signal); background: var(--navy-raised); }
.history-button svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.fullscreen-button { width: 38px; height: 38px; }
.fullscreen-button[aria-pressed="true"] { color: var(--signal); }
.local { display: inline-flex; align-items: center; gap: 8px; color: #bfd4e2; white-space: nowrap; font-size: 12px; }
main { padding: 26px var(--gutter) 44px; min-width: 0; }
main:focus { outline: none; }
.pagehead { display: flex; justify-content: space-between; align-items: flex-end; margin: 0 0 19px; gap: 14px; }
.pagehead p { font-size: 13px; margin-top: 9px; color: var(--muted); }
.actions { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; }
.button { min-height: 34px; display: inline-flex; gap: 7px; align-items: center; justify-content: center; white-space: nowrap; padding: 5px 11px; border-radius: var(--control-radius); border: 1px solid transparent; text-decoration: none; cursor: pointer; background: transparent; color: var(--ink); font-size: 13px; font-weight: 650; line-height: 1.4; transition: background-color 140ms, border-color 140ms, transform 120ms var(--ease-out); }
.button:active:not(:disabled) { transform: scale(.975); }
.button.primary { background: var(--blue); color: #092521; border-color: var(--blue); }
.button.primary:hover { background: var(--blue-dark); }
.button.secondary { border-color: var(--line-strong); background: var(--paper-raised); }
.button.secondary:hover, .button.ghost:hover { background: var(--blue-soft); border-color: #538281; }
.button.ghost { color: var(--blue-dark); }
button:disabled, .button.disabled { opacity: .45; cursor: default; }
.subtle { color: var(--muted); font-size: 12px; }
.arrow-icon { width: 14px; height: 12px; position: relative; background: linear-gradient(currentColor,currentColor) left center / 12px 1px no-repeat; }
.arrow-icon::after { content: ""; width: 6px; height: 6px; border: solid currentColor; border-width: 1px 1px 0 0; transform: rotate(45deg); position: absolute; right: 2px; top: 3px; }
.play-icon { width: 12px; height: 12px; background: currentColor; clip-path: polygon(20% 8%, 92% 50%, 20% 92%); }
.panel { background: var(--paper); border: 1px solid var(--line); border-radius: var(--radius); min-width: 0; }
.panel-head { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 10px 14px; padding: 15px 18px; border-bottom: 1px solid var(--line); }
.panel-head p { color: var(--muted); font-size: 12px; margin-top: 3px; }
.result-plot { display: grid; place-items: center; min-height: 236px; padding: 10px 14px 14px; color: var(--muted); font-size: 13px; }
.result-plot img { display: block; width: 100%; height: auto; }

.home-pagehead { align-items: center; }
.home-panel { min-width: 0; border: 1px solid var(--line); border-radius: var(--radius); background: var(--paper); }
.home-config { margin-bottom: 14px; }
.home-config-head, .home-chart-head, .home-provinces-head { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 10px 14px; }
.home-config-head { padding: 10px 16px; border-bottom: 1px solid var(--line); }
.home-config-head h2 { display: flex; align-items: center; gap: 8px; font-size: 15px; }
.home-config-icon { width: 16px; height: 12px; position: relative; color: var(--signal); background: linear-gradient(currentColor 0 0) left 3px / 16px 1px no-repeat, linear-gradient(currentColor 0 0) left 9px / 16px 1px no-repeat; }
.home-config-icon::before, .home-config-icon::after { content: ""; position: absolute; width: 3px; height: 5px; border-radius: 1px; background: currentColor; }
.home-config-icon::before { left: 4px; top: 1px; }
.home-config-icon::after { right: 4px; top: 7px; }
.home-config .primary { padding-inline: 15px; }
.home-config-fields { display: flex; align-items: center; flex-wrap: wrap; padding: 12px 16px; gap: 12px 18px; }
.home-config-basics { display: flex; flex: 0 0 auto; flex-wrap: wrap; align-items: center; gap: 8px 17px; max-width: 100%; }
.home-config-toggles { display: flex; flex: 1 0 auto; justify-content: space-between; align-items: center; gap: 9px 14px; padding-left: 18px; border-left: 1px solid var(--line); }
.home-config-fields label, #home-output-label { color: var(--muted); font-size: 12px; font-weight: 550; }
.home-config-year, .home-config-cores, .home-toggle { display: inline-flex; align-items: center; gap: 7px; white-space: nowrap; }
#config-year { width: 76px; min-height: 33px; padding-block: 4px; font-family: var(--data); }
#config-cores { width: 70px; min-height: 33px; padding: 4px 6px; }
.home-output { display: flex; flex-shrink: 0; align-items: center; gap: 8px; white-space: nowrap; }
.home-output-choices { display: flex; gap: 4px; white-space: nowrap; }
.home-output-choices label { display: inline-flex; min-height: 32px; align-items: center; gap: 5px; padding: 2px 6px; border: 1px solid var(--line); border-radius: 5px; cursor: pointer; }
.home-output-choices label:has(input:checked) { color: var(--blue-dark); background: var(--blue-soft); border-color: #325e5a; }
.home-output-choices input { width: 13px; height: 13px; }
.home-toggle { min-height: 33px; cursor: pointer; }
.home-toggle input { flex-shrink: 0; margin-inline: 0; }
#home-curve-status:empty, .home-chart-message:empty { display: none; }
.home-config .inline-status { padding-inline: 16px; }

.home-system { --curve-color: var(--signal); background: linear-gradient(168deg, #142b3e 0%, #10202d 33%, #0d1824 72%); border-color: #405566; overflow: hidden; }
.home-chart-head { padding: 15px clamp(12px, 2vw, 22px); }
.home-chart-head h2 { font-size: clamp(17px, 1.8vw, 24px); line-height: 1.3; font-weight: 660; }
.home-chart-controls { display: flex; flex-wrap: wrap; align-items: center; gap: 7px 12px; }
.home-chart-controls label { min-width: 0; display: grid; gap: 4px; color: #b8ccde; font-size: 11px; white-space: nowrap; }
.home-chart-controls select { min-height: 36px; padding: 4px 8px; width: auto; max-width: 100%; font-size: 12px; border-color: #40576a; background: #112130; }
.home-chart-controls select:disabled { opacity: .65; }
#home-job { max-width: clamp(188px, 25vw, 354px); }
#home-curve-status { padding: 9px 18px; border-block: 1px solid var(--line); background: #173044; color: #c7dfed; font-size: 13px; }
.home-system-body { display: grid; min-width: 0; }
.home-system-metrics { display: grid; grid-template-columns: 1.08fr 1fr .9fr; margin: 0 clamp(12px, 2vw, 22px); min-width: 0; background: #0b18253d; border-block: 1px solid #5a7b932f; }
.home-system-metrics > div { min-width: 0; padding: 13px clamp(9px, 2vw, 20px); }
.home-system-metrics > div + div { border-left: 1px solid #5a7b9340; }
.home-system-metrics dt { color: #b1c6d8; font-size: 12px; }
.home-system-metrics dd { display: flex; align-items: baseline; flex-wrap: wrap; gap: 3px 9px; margin: 5px 0 0; }
.home-system-metrics strong { font-size: clamp(23px, 3.25vw, 42px); font-weight: 570; line-height: 1.12; letter-spacing: -.035em; color: #effaff; }
.home-system-metrics [data-mean] { color: var(--signal); }
.home-system-metrics [data-peak] { color: var(--amber); }
.home-system-metrics small { color: #b2c6d7; font-family: var(--data); font-size: 11px; }
.home-system-metrics strong, .home-province strong { font-variant-numeric: tabular-nums; }
.home-plot { --plot-height: 143px; min-width: 0; min-height: var(--plot-height); position: relative; }
.home-plot canvas { width: 100%; height: var(--plot-height); display: block; }
.home-system .home-plot { --plot-height: var(--pane-height, clamp(245px, 32vh, 370px)); margin: 10px 22px 5px 11px; }
.home-inspect, .offer-inspect { position: absolute; inset: 11px 12px auto auto; z-index: 2; max-width: calc(100% - 24px); white-space: pre-line; pointer-events: none; background: #162739; border: 1px solid #557088; color: var(--ink); box-shadow: 0 8px 24px #03060c55; padding: 8px 11px; border-radius: var(--control-radius); font-size: 12px; line-height: 1.5; font-variant-numeric: tabular-nums; }
.home-chart-message { position: absolute; inset: 0; display: grid; align-content: center; text-align: center; color: var(--muted); font-size: 13px; pointer-events: none; }

.home-provinces { margin-top: 18px; }
.home-provinces-head { margin-bottom: 8px; }
.home-provinces-head h2 { font-size: 17px; }
.home-province-grid { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 1px; border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; background: var(--line); }
.home-province { border: 0; border-radius: 0; padding: 14px 13px 0; }
.home-province[data-home-region="GD"] { --curve-color: #89b4fb; }
.home-province[data-home-region="GX"] { --curve-color: #67d8ae; }
.home-province[data-home-region="YN"] { --curve-color: #bba5fc; }
.home-province[data-home-region="GZ"] { --curve-color: #f2bb83; }
.home-province[data-home-region="HN"] { --curve-color: #f0a0af; }
.home-province h3 { display: flex; align-items: center; gap: 7px; font-size: 15px; color: var(--ink); }
.home-province h3::before { content: ""; display: inline-block; width: 7px; height: 7px; border-radius: 50%; background: var(--curve-color); }
.home-province p { color: var(--muted); font-size: 11px; }
.home-province .home-capacity { display: flex; flex-wrap: wrap; align-items: baseline; gap: 1px 4px; margin-top: 6px; }
.home-capacity strong { font-size: 14px; font-weight: 650; color: var(--ink); }
.home-capacity small { font-size: 10px; }
.home-province .home-plot { margin: 7px -6px 0; }
.home-province-prices { border-top: 1px solid var(--line); padding: 8px 0 10px; margin: 0; display: grid; gap: 5px; color: var(--muted); font-size: 11px; }
.home-province-prices div { display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; gap: 0 6px; }
.home-province-prices dd { margin: 0; }
.home-province-prices strong { color: var(--ink); font-size: 13px; font-weight: 650; }

.config-body { padding: 17px 18px; display: grid; gap: 9px; }
.config-body label, legend, .filters label, .password-body label { font-size: 13px; font-weight: 650; }
input:not([type="checkbox"]):not([type="file"]), select { border: 1px solid #374c61; border-radius: 6px; min-height: 35px; width: 100%; padding: 6px 9px; color: var(--ink); background: var(--control); min-width: 0; }
input[type="checkbox"] { accent-color: var(--blue); margin: 0; width: 16px; height: 16px; flex-shrink: 0; }
input[role="switch"] { appearance: none; width: 36px; height: 20px; cursor: pointer; border-radius: 12px; background: #42566a; position: relative; transition: background-color 140ms; }
input[role="switch"]::after { content: ""; position: absolute; left: 3px; top: 3px; width: 14px; height: 14px; border-radius: 50%; background: #e7eef7; transition: transform 140ms var(--ease-out); }
input[role="switch"]:checked { background: var(--blue); }
input[role="switch"]:checked::after { background: #0a2925; transform: translateX(16px); }
.config-line { display: flex; justify-content: space-between; align-items: center; gap: 9px; padding: 12px 0; border-bottom: 1px solid #2a3a4a; }
.config-line small { display: block; color: var(--muted); margin-top: 4px; font-weight: 400; }
.config-line.fine { border-bottom: none; padding-bottom: 2px; }
fieldset { border: 0; margin: 0; padding: 0; }
legend { padding: 0; margin: 8px 0 9px; }
.checks { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.checks label { border: 1px solid var(--line); border-radius: 5px; padding: 7px 9px; display: flex; align-items: center; gap: 7px; }
.config-actions { border-top: 1px solid #2a3a4a; padding: 13px 18px; display: flex; gap: 8px; }
.config-actions .primary { flex: 1; }
.inline-status:empty { display: none; }
.inline-status { color: var(--muted); padding: 0 18px 13px; font-size: 12px; }
.editor-layout, .run-layout { display: grid; grid-template-columns: minmax(205px, 252px) minmax(0, 1fr); gap: 16px; align-items: start; }
.file-list { max-height: min(67dvh, 650px); overflow: auto; padding: 8px; }
.file-group { padding: 7px 8px 4px; font-size: 11px; color: var(--muted); font-weight: 700; }
.file-item, .task-item { width: 100%; min-width: 0; text-align: left; display: grid; gap: 3px; border: 1px solid transparent; background: var(--paper); padding: 9px 10px; border-radius: var(--control-radius); cursor: pointer; color: var(--ink); }
.file-item:hover, .task-item:hover, .file-item[aria-pressed="true"], .task-item[aria-pressed="true"] { background: var(--blue-soft); color: var(--blue-dark); border-color: #325e5a; }
.file-item strong { font-size: 12px; font-weight: 650; word-break: break-word; }
.file-item small, .task-item small { color: var(--muted); }
.table-toolbar { display: flex; min-height: 37px; align-items: center; padding: 5px 14px; gap: 10px; border-bottom: 1px solid var(--line); }
.table-toolbar label { font-size: 12px; white-space: nowrap; display: flex; gap: 6px; align-items: center; }
.table-toolbar select { min-height: 27px; padding: 3px 6px; width: auto; }
.settings-price-help { margin: 0; padding: 9px 14px; color: #b3ccde; background: #152c3a; font-size: 13px; }
.settings-price-help p + p { margin-top: 4px; }
.table-scroll { max-height: min(58dvh, 620px); overflow: auto; overscroll-behavior: contain; }
table { border-collapse: separate; border-spacing: 0; min-width: 100%; font-size: 12px; font-variant-numeric: tabular-nums; }
th, td { border-bottom: 1px solid var(--line); border-right: 1px solid var(--line); text-align: left; white-space: nowrap; padding: 8px 10px; }
th:last-child, td:last-child { border-right: 0; }
thead th { background: #17283a; position: sticky; top: 0; z-index: 1; color: #c1d4e9; font-weight: 650; }
tbody th { background: #14202e; color: var(--muted); text-align: right; font-weight: 500; }
tbody tr:nth-child(even) td { background: #121e2b; }
tbody tr:focus-within td { background: #1a323c; }
td.cell { padding: 0; }
td.cell input { border: 0; background: transparent; border-radius: 0; min-height: 32px; width: max(100%, 104px); font-size: 12px; color: inherit; }
td.cell input:focus { outline-offset: -2px; }
td.cell.edited { background: #503c27 !important; }
.pager { display: flex; justify-content: space-between; align-items: center; min-height: 52px; padding: 8px 13px; font-size: 12px; color: var(--muted); border-top: 1px solid var(--line); gap: 10px; }
.pager .button { min-height: 30px; font-size: 12px; }
.empty { color: var(--muted); padding: 25px 16px; font-size: 13px; }
.run-list { padding: 8px; max-height: min(60dvh, 630px); overflow: auto; }
.task-item strong { font-size: 13px; }
.task-item { margin-bottom: 5px; }
.run-body { padding: 18px; }
.progress-label { display: flex; justify-content: space-between; gap: 12px; font-size: 13px; }
progress { accent-color: var(--blue); width: 100%; height: 9px; margin: 10px 0 20px; }
pre { margin: 9px 0 0; min-height: 168px; max-height: 54dvh; overflow: auto; white-space: pre-wrap; overflow-wrap: anywhere; color: #c3dbf2; background: #0a131f; border-radius: 6px; font-size: 12px; padding: 14px; line-height: 1.6; }
.result-grid { display: grid; grid-template-columns: clamp(218px, 18vw, 310px) minmax(0, 1fr); gap: 12px; align-items: start; }
.result-content { display: grid; gap: 11px; min-width: 0; }
.result-controls .panel-head { background: #152231; }
.result-source { display: grid; padding: 10px 11px; gap: 5px; border-bottom: 1px solid var(--line); font-size: 12px; font-weight: 650; }
.result-controls select, .result-controls input[type="date"] { min-height: 31px; border-radius: 4px; padding: 4px 5px; font-size: 12px; font-weight: 500; }
.filters { display: grid; }
.period-controls { display: grid; grid-template-columns: 65px minmax(0, 1fr); gap: 8px; padding: 10px 11px; border-bottom: 1px solid var(--line); }
.period-controls label, #correction-filters label, #report-filters label { display: grid; gap: 5px; font-size: 12px; min-width: 0; }
#correction-filters, #report-filters { padding: 10px 11px; gap: 9px; }
.offer-picker { position: relative; font-size: 13px; }
.offer-picker + .offer-picker { border-top: 1px solid var(--line); }
.offer-picker summary { min-height: 31px; display: flex; align-items: center; gap: 5px; list-style: none; cursor: pointer; padding: 5px 11px; background: #1a2938; font-size: 12px; font-weight: 650; }
.offer-picker summary::-webkit-details-marker { display: none; }
.offer-picker summary::after { content: ""; width: 6px; height: 6px; border-bottom: 1.5px solid currentColor; border-right: 1.5px solid currentColor; transform: rotate(-45deg); flex: 0 0 auto; }
.offer-picker[open] summary::after { transform: translateY(-2px) rotate(45deg); }
.offer-picker summary span { color: var(--blue-dark); font-weight: 550; margin-left: auto; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.offer-picker-menu { max-height: 218px; overflow: auto; padding: 4px 7px; }
.offer-picker-menu label { display: flex; gap: 7px; align-items: center; min-height: 27px; padding: 3px 5px; border-radius: 3px; font-size: 12px; font-weight: 500; cursor: pointer; }
.offer-picker-menu input { width: 13px; height: 13px; }
.offer-picker-menu label:has(input:checked) { background: var(--blue-soft); color: var(--blue-dark); }
.offer-picker-menu label:hover { background: var(--blue-soft); }
.offer-picker-menu small { color: var(--muted); margin-left: auto; }
.chart-switch { display: flex; flex-wrap: wrap; gap: 4px; padding: 5px 8px; background: var(--paper-raised); border-bottom: 1px solid var(--line); border-radius: var(--radius) var(--radius) 0 0; }
.chart-switch button { min-height: 32px; border: 1px solid transparent; border-radius: var(--control-radius); padding: 0 10px; color: var(--muted); background: transparent; font-size: 12px; font-weight: 650; cursor: pointer; }
.chart-switch button:hover { color: var(--blue-dark); }
.chart-switch button[aria-pressed="true"] { color: var(--blue-dark); background: var(--blue-soft); border-color: #325e5a; }
.offer-status { padding: 12px 16px; }
.offer-status:empty { display: none; }
.offer-chart { margin: 7px 12px 0; position: relative; }
.offer-chart canvas { width: 100%; height: clamp(250px, 32vh, 360px); display: block; }
.offer-inspect { position: absolute; top: 38px; right: 18px; max-width: calc(100% - 100px); background: var(--paper); border: 1px solid #405d77; border-radius: 4px; color: var(--ink); font-size: 12px; padding: 5px 8px; pointer-events: none; white-space: pre-line; }
.offer-facts { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); border-top: 1px solid var(--line); }
.offer-facts div { padding: 6px 8px 8px; text-align: center; }
.offer-facts div + div { border-left: 1px solid var(--line); }
.offer-facts span { display: block; color: var(--muted); font-size: 11px; margin-bottom: 3px; }
.offer-facts strong { font-size: clamp(11px, 1.25vw, 15px); font-variant-numeric: tabular-nums; }
.correction-facts { grid-template-columns: repeat(auto-fit, minmax(min(150px, 100%), 1fr)); border-top: 0; background: #152433; }
.correction-facts div { padding: 11px 8px; }
.correction-facts div:last-child { color: var(--blue-dark); background: var(--blue-soft); }
.correction-legend { display: flex; flex-wrap: wrap; gap: 6px 18px; align-items: center; padding: 9px 16px 0; }
.correction-legend label { display: flex; gap: 6px; align-items: center; cursor: pointer; font-size: 12px; }
.correction-legend label:has(input:not(:checked)) { color: var(--muted); }
.correction-legend label:has(input:not(:checked)) canvas { opacity: .4; }
.correction-actual-note { padding: 8px 16px 0; }
.correction-editor { border-top: 1px solid var(--line); }
.correction-editor td.edited-price { background: #503c27; }
.correction-editor td input { width: min(100%, 210px); min-width: 110px; min-height: 28px; font-variant-numeric: tabular-nums; }
.correction-trial-bar { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: 8px 12px; padding: 8px 14px; border-bottom: 1px solid var(--line); }
.report-switch { flex-wrap: wrap; }
.report-chart { margin-bottom: 8px; }
.range-scroll { overflow-x: auto; }
.report-chart canvas { min-width: 720px; height: clamp(365px, 31vw, 525px); }
.report-chart canvas:focus-visible { outline-offset: -2px; }
.report-chart .offer-inspect { z-index: 1; max-height: calc(100% - 46px); overflow: hidden; }
.report-table { margin: 10px 14px 14px; }
.report-table tbody td, .report-table thead th:not(:first-child) { text-align: right; }
.report-table td, .report-table th { font-variant-numeric: tabular-nums; }
.report-table tbody th { background: #172a3b; color: #b3d3e8; }
.report-table tbody tr:nth-child(even) td { background: #111e2d; }
.offer-legend { border-top: 1px solid var(--line); padding: 4px 10px 8px; }
.offer-legend-head { display: flex; justify-content: space-between; align-items: center; min-height: 26px; padding: 0 3px; }
.offer-legend-head .subtle { margin-left: 5px; font-weight: 500; }
#offer-show-charge[aria-pressed="true"] { background: var(--blue-soft); border-color: #325e5a; color: var(--blue-dark); }
#offer-legend-items { list-style: none; margin: 3px 0 0; padding: 0; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 6px; max-height: 224px; overflow: auto; }
.offer-legend-toggle { display: grid; grid-template-columns: 23px minmax(0, 1fr) auto; align-items: center; gap: 6px; width: 100%; padding: 4px 6px; border: 1px solid #354a60; background: #142434; border-radius: 4px; color: var(--ink); cursor: pointer; text-align: left; }
.offer-legend-toggle:hover { background: var(--blue-soft); }
.offer-legend-toggle[aria-pressed="false"] { background: var(--paper); color: var(--muted); }
.offer-legend-toggle[aria-pressed="false"] canvas { opacity: .35; }
.offer-series-name, .offer-series-data { display: block; overflow-wrap: anywhere; }
.offer-series-name { font-size: 12px; font-weight: 650; }
.offer-series-data { font-size: 10px; color: var(--muted); }
.offer-legend-action { color: var(--blue-dark); font-size: 11px; }
.offer-legend.single-visible { display: flex; align-items: center; gap: 9px; }
.offer-legend.single-visible #offer-legend-items { margin: 0; grid-template-columns: auto; }
.offer-legend.single-visible .offer-series-data { display: none; }
.metrics-content { padding: 12px 15px; display: flex; flex-wrap: wrap; gap: 10px; }
.metric { min-width: 160px; padding: 9px 12px; border: 1px solid var(--line); border-radius: 4px; background: #162638; }
.metric > p { color: var(--muted); font-size: 12px; }
.metric strong { display: block; font-size: 26px; font-variant-numeric: tabular-nums; padding: 4px 0; }
.data-toolbar { min-height: 42px; display: flex; justify-content: space-between; gap: 9px; align-items: center; padding: 5px 11px; border-bottom: 1px solid var(--line); }
.data-toolbar label { display: flex; align-items: center; gap: 7px; font-size: 12px; white-space: nowrap; min-width: 0; }
.data-toolbar select { width: auto; max-width: 100%; min-height: 30px; }
.data-toolbar input { min-height: 28px !important; }
.result-table-scroll { max-height: 280px; }
.output-toolbar { flex-wrap: wrap; }
.output-toolbar .actions { margin-inline-start: auto; }
.output-toolbar input[type="checkbox"] { min-height: 0 !important; }
.output-check { width: 3.4rem; text-align: center; }
.output-check input { accent-color: var(--signal); }
.result-data thead th { background: #1a3042; color: #c3dcf0; }
.result-data tbody tr:nth-child(even) td { background: #152433; }
.result-data td, .result-data th { padding: 6px 9px; }
.result-data .actions { flex-wrap: nowrap; }
.result-data .actions .button { min-height: 25px; padding: 3px 7px; font-size: 12px; }
.ai-grid { display: grid; grid-template-columns: minmax(260px, .9fr) minmax(0, 1.6fr); gap: 16px; align-items: start; }
#ai .pagehead [aria-pressed="true"] { background: var(--blue-soft); border-color: #325e5a; color: var(--blue-dark); }
.ai-chat-layout { display: grid; grid-template-columns: minmax(178px, 230px) minmax(0, 1fr); gap: 14px; align-items: start; }
.ai-chat-create, .ai-chat-exports { display: grid; gap: 8px; padding: 12px; }
.ai-chat-exports { border-top: 1px solid #2a3a4a; }
.ai-chat-exports [aria-disabled="true"] { opacity: .48; cursor: default; }
#chat-list { display: grid; gap: 4px; max-height: min(40dvh, 440px); }
#chat-list .empty { padding: 9px 5px; }
.ai-chat-link { width: 100%; min-width: 0; display: grid; gap: 3px; padding: 9px; border: 1px solid transparent; border-radius: 5px; background: transparent; text-align: start; color: var(--ink); cursor: pointer; }
.ai-chat-link:hover { background: #1a2938; }
.ai-chat-link[aria-pressed="true"] { color: var(--blue-dark); border-color: #325e5a; background: var(--blue-soft); }
.ai-chat-link strong { font-size: 13px; text-overflow: ellipsis; white-space: nowrap; overflow: hidden; }
.ai-chat-main > .panel-head > div { min-width: 0; overflow-wrap: anywhere; }
#chat-model-status { max-width: 42%; overflow: hidden; text-overflow: ellipsis; }
.ai-chat-manage { justify-content: flex-end; }
.ai-chat-versions { display: flex; align-items: center; gap: 10px; padding: 7px 14px; font-size: 13px; }
.ai-chat-versions select { width: min(400px, 74%); min-width: 0; }
.ai-chat-edit { justify-content: space-between; background: var(--blue-soft); }
.ai-chat-edit span { color: var(--muted); }
.ai-chat-message[data-role="user"] > .button { margin-top: 4px; padding: 3px 5px; min-height: 26px; }
.ai-chat-messages { display: flex; flex-direction: column; align-items: start; gap: 16px; height: clamp(260px, calc(100dvh - 405px), 680px); overflow: auto; background: #0e1824; padding: 20px; }
.ai-chat-intro { margin: auto; text-align: center; color: var(--muted); font-size: 14px; }
.ai-chat-message { max-width: min(92%, 960px); min-width: 0; border: 1px solid #2a3a4a; border-radius: 6px; background: var(--paper); padding: 10px 13px; overflow-wrap: anywhere; }
.ai-chat-message[data-role="user"] { align-self: flex-end; background: var(--blue-soft); border-color: #355f67; }
.ai-chat-message h3 { color: var(--blue-dark); font-size: 12px; margin-bottom: 4px; }
.ai-chat-content { white-space: pre-wrap; font-size: 14px; line-height: 1.65; }
.ai-chat-reply-actions { margin-top: 8px; border-top: 1px solid #2a3a4a; padding-top: 6px; }
.ai-chat-reply-actions .button { min-height: 28px; padding: 4px 7px; font-size: 12px; }
#chat-form { display: grid; gap: 9px; padding: 12px 14px; border-top: 1px solid #2a3a4a; }
#chat-text { font: inherit; font-size: 14px; padding: 9px 10px; min-width: 0; resize: vertical; border-radius: 5px; border: 1px solid var(--line); color: var(--ink); }
.ai-chat-scope { display: grid; grid-template-columns: minmax(0, 1fr) minmax(105px, 160px); gap: 9px; }
.ai-chat-scope label { display: grid; min-width: 0; gap: 4px; font-size: 12px; font-weight: 650; }
.ai-chat-actions { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.ai-chat-files { display: flex; flex-wrap: wrap; gap: 6px; font-size: 12px; }
.ai-chat-files a, .ai-chat-file { padding: 5px 8px; border: 1px solid var(--line); border-radius: 4px; background: var(--paper); overflow-wrap: anywhere; }
.ai-chat-files a { color: var(--blue-dark); }
.ai-chat-message .ai-chat-files { margin-top: 7px; }
.ai-chat-file { display: flex; align-items: center; min-width: 0; gap: 5px; }
.ai-chat-file .button { min-height: 24px; padding: 3px 5px; font-size: 12px; }
#chat-remote-line { font-size: 12px; overflow-wrap: anywhere; }
#chat-send-status:empty { display: none; }
.ai-stack { display: grid; gap: 14px; min-width: 0; }
.ai-check { display: flex; align-items: flex-start; gap: 8px; line-height: 1.5; }
.ai-check input { margin-top: 2px; }
.ai-badge { padding: 4px 8px; border-radius: 4px; font-size: 12px; font-weight: 650; white-space: nowrap; background: #1c2c3d; color: var(--muted); }
.ai-badge[data-tone="ready"] { background: #193630; color: #a2ebc5; }
.ai-badge[data-tone="error"] { background: #432b36; color: #7b2937; }
.ai-result { padding: 14px; min-height: 112px; }
.ai-proposal { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
.ai-proposal > div { padding: 9px 12px; background: #152b3c; border: 1px solid #30475d; border-radius: 4px; }
.ai-proposal > div:last-child { background: var(--blue-soft); color: var(--blue-dark); }
.ai-proposal small { display: block; line-height: 1.6; }
.ai-proposal strong { font-size: 24px; font-variant-numeric: tabular-nums; }
#ai-proposal-reason { margin: 10px 0; font-size: 13px; white-space: pre-wrap; overflow-wrap: anywhere; }
.ai-table { border: 1px solid var(--line); border-radius: 4px; max-height: 258px; }
.ai-table tbody tr:last-child td { border-bottom: none; }
.ai-result details { margin-top: 12px; }
.ai-result details summary, .ai-endpoints summary { cursor: pointer; font-size: 13px; font-weight: 650; }
.ai-result details .ai-table { margin-top: 8px; }
.ai-result-actions:not(:has(> :not([hidden]))) { display: none; }
.ai-result-actions { margin-top: 12px; }
#ai-history { max-height: 220px; }
.ai-history-item small, #ai-result-meta { overflow-wrap: anywhere; }
.ai-endpoints summary { padding: 13px 14px; }
.ai-endpoint-body { border-top: 1px solid var(--line); padding: 10px 14px 13px; }
.ai-endpoint-body dl { display: grid; grid-template-columns: fit-content(64%) minmax(0, 1fr); gap: 8px 13px; margin: 0 0 13px; font-size: 12px; }
.ai-endpoint-body dt { font-family: ui-monospace, monospace; color: var(--blue-dark); overflow-wrap: anywhere; }
.ai-endpoint-body dd { margin: 0; color: var(--muted); }
dialog { background: var(--paper); width: min(950px, 95vw); max-height: 88dvh; border: 1px solid var(--line); padding: 0; border-radius: 12px; color: var(--ink); box-shadow: 0 16px 60px #10243640; }
dialog::backdrop { background: #0b172a9c; }
dialog[open] { animation: dialog-in 160ms var(--ease-out); }
@keyframes dialog-in {
  from { opacity: 0; transform: translateY(4px) scale(.99); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}
.chat-manage-dialog { width: min(450px, 94vw); }
#input-confirm-dialog { width: min(510px, 94vw); }
#input-confirm-files { max-height: 32vh; overflow: auto; margin: 0; padding-left: 20px; overflow-wrap: anywhere; }
.button.danger { background: var(--paper); border-color: #754551; color: #ffaaa5; }
.button.danger:hover:not(:disabled) { background: #442631; border-color: #ffaaa5; }
#chat-manage-status:empty { display: none; }
#password-dialog { width: min(460px, 95vw); }
.password-body { padding: 16px 18px; display: grid; gap: 10px; }
#archive-name { overflow-wrap: anywhere; font-weight: 650; }
#archive-status { color: var(--muted); font-size: 12px; }
#archive-status:empty { display: none; }
.toast { position: fixed; right: 24px; bottom: 22px; z-index: 18; padding: 12px 16px; max-width: min(480px, 92vw); background: #18354b; color: white; box-shadow: 0 5px 18px #11233b36; border-radius: 6px; font-size: 13px; line-height: 1.5; }
.toast.error { background: #7b2937; }
.visually-hidden { width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0,0,0,0); position: absolute; white-space: nowrap; }

/* Shared records and page-specific layouts */
.editor-layout, .run-layout, .result-grid, .ai-chat-layout {
  grid-template-columns: minmax(220px, 270px) minmax(0, 1fr);
  gap: 16px;
}
.file-panel, .result-controls, .ai-chat-sidebar {
  position: sticky;
  top: calc(var(--masthead-offset, var(--masthead)) + 14px);
  min-width: 0;
}
.file-panel .panel-head, .run-layout > .panel:first-child .panel-head, .ai-chat-sidebar .panel-head { padding-inline: 14px; }
.file-search { display: flex; position: relative; margin: 12px 12px 0; }
.file-search input { padding-inline-start: 32px !important; }
.search-icon { position: absolute; top: 11px; left: 11px; width: 10px; height: 10px; border: 1.4px solid var(--muted); border-radius: 50%; pointer-events: none; }
.search-icon::after { content: ""; position: absolute; width: 5px; height: 1px; top: 7px; left: 7px; background: var(--muted); transform: rotate(45deg); transform-origin: left center; }
.file-list { max-height: min(60dvh, 650px); padding: 7px 9px 11px; }
.file-item { display: grid; grid-template-columns: 19px minmax(0, 1fr); align-items: start; gap: 9px; min-height: 46px; }
.file-glyph { position: relative; align-self: center; width: 14px; height: 17px; margin-inline-start: 2px; border: 1.3px solid #8aa7c0; border-radius: 3px; }
.file-glyph::after { content: ""; position: absolute; inset: 5px 3px; border-block: 1px solid #8aa7c0; }
.file-item[aria-pressed="true"] .file-glyph, .file-item[aria-pressed="true"] .file-glyph::after { border-color: var(--signal); }
.file-caption { min-width: 0; display: grid; gap: 4px; }
.file-caption strong { font-family: var(--data); font-size: 12px; font-weight: 550; }
.file-caption small, .run-task-meta small { font-size: 11px; }
.table-panel #editor-title { font-family: var(--data); overflow-wrap: anywhere; }
.table-panel .table-scroll { max-height: min(62dvh, 720px); }
.table-panel .panel-head > div:first-child { min-width: 0; }
.table-panel tbody td.cell { position: relative; }
.table-panel td.cell input { width: max(100%, 104px); min-height: 37px; }
.table-panel td.cell input[readonly] { cursor: wait; }
.table-panel thead { font-size: 12px; }
td.cell:focus-within input { box-shadow: inset 0 -2px var(--signal); }
.table-toolbar { background: #142333; }
#editor-status { color: #b8d5e8; }
.results-table-scroll, .table-scroll, pre, .ai-chat-messages { scrollbar-width: thin; }

.run-list { padding: 9px; }
.task-item { min-height: 67px; gap: 8px; background: var(--paper); }
.task-item + .task-item { margin-top: 3px; }
.run-task-meta { display: flex; gap: 5px 9px; flex-wrap: wrap; align-items: center; }
.task-status { background: #1b2c3e; border: 1px solid #375167; color: #c1d5e6; font-size: 11px; border-radius: 4px; padding: 2px 6px; line-height: 1.2; white-space: nowrap; }
.task-status[data-status="completed"] { background: #17342e; border-color: #255c4f; color: #a0ecd3; }
.task-status[data-status="queued"] { background: #342d22; border-color: #695639; color: #f4cf92; }
.task-status[data-status="running"] { background: #1b3446; border-color: #37677e; color: #b3dfff; }
.task-status[data-status="failed"], .task-status[data-status="interrupted"] { background: #38262f; border-color: #754551; color: var(--red); }
.run-panel > .panel-head { background: #162e3f; border-radius: var(--radius) var(--radius) 0 0; }

.mean-audit-icon { border: 1px solid currentColor; border-radius: 3px; display: grid; place-items: center; }
.mean-audit-icon::before { content: "÷"; font-size: 12px; line-height: 1; }
.mean-audit-panel + .mean-audit-panel { margin-top: 16px; }
.mean-audit-controls { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(170px, 100%), 1fr)); gap: 12px; padding: 14px; align-items: end; }
.mean-audit-controls label { display: grid; gap: 5px; min-width: 0; font-size: 12px; color: var(--muted); }
.mean-audit-controls label > :is(input, select) { width: 100%; min-width: 0; }
.mean-audit-context { margin: 0 14px 14px; font-size: 12px; }
.mean-audit-metrics { display: grid; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); margin: 0; border-bottom: 1px solid var(--line); }
.mean-audit-metrics div { padding: 12px 16px; }
.mean-audit-metrics dt { color: var(--muted); font-size: 12px; }
.mean-audit-metrics dd { margin: 3px 0 0; font-size: 23px; font-variant-numeric: tabular-nums; }
#mean-audit-metrics div:nth-child(2) dd { color: var(--red); }
#mean-audit-metrics div:nth-child(3) dd, #mean-audit-metrics div:nth-child(4) dd { color: var(--amber); }
.mean-audit-panel table { white-space: nowrap; }
.mean-audit-badge:is([data-kind="zero_zero"], [data-kind="zero_divisor"]) { color: var(--red); background: #38262f; border-color: #754551; }
.mean-audit-badge[data-kind="near_zero"] { color: var(--amber); }
.mean-guide { margin: 0 14px 14px; padding: 10px 12px; border: 1px solid var(--line); border-radius: 8px; }
.mean-guide summary { cursor: pointer; color: var(--muted); }
.mean-guide dl { display: grid; gap: 8px; margin: 12px 0 2px; font-size: 13px; }
.mean-guide dl div { display: grid; grid-template-columns: minmax(85px, 115px) 1fr; gap: 12px; }
.mean-guide dt { font-weight: 600; }
.mean-guide dd { color: var(--muted); margin: 0; }
.mean-confirmed-alert { color: #ffd3d7; background: #40232d; border: 1px solid #8e4b59; }
#mean-audit-alert, .mean-fix-message { margin: 12px 14px; padding: 10px 12px; border-radius: 6px; }
.mean-confirmed-label { color: var(--red); font-weight: 650; }
.mean-trial { min-height: 32px; padding: 3px 10px; }
.mean-preview { scroll-margin-top: 14px; }
.mean-fix-metrics div:nth-child(2) dd, .mean-fix-metrics div:nth-child(4) dd { color: #37d4bd; }
.mean-fix-metrics div:nth-child(3) dd { color: inherit; }
.mean-fix-plan { padding: 12px 16px; font-size: 13px; }
.mean-fix-plan p { margin: 4px 0 0; color: var(--muted); }
.mean-fix-plot { position: relative; margin: 0 14px; border-radius: 8px; overflow: hidden; border: 1px solid var(--line); }
.mean-fix-plot canvas { display: block; width: 100%; height: var(--pane-height, clamp(255px, 38vh, 380px)); }
.mean-fix-legend { display: flex; flex-wrap: wrap; gap: 16px; padding: 9px 14px; font-size: 12px; }
.mean-fix-legend span::before { content: ""; display: inline-block; width: 22px; margin-right: 6px; vertical-align: middle; }
.mean-line-before::before { border-top: 2px dashed #91b8f2; }
.mean-line-after::before { border-top: 2px solid #37d4bd; }
.mean-fix-inspect { pointer-events: none; position: absolute; right: 16px; top: 86px; padding: 8px 12px; white-space: pre; background: #132332; border: 1px solid var(--line); border-radius: 6px; font-size: 12px; }
.mean-fix-actions { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; padding: 10px 14px; font-size: 12px; }
.mean-fix-actions p { margin: 0; }
.mean-selection { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: 12px; padding: 10px 14px; border-bottom: 1px solid var(--line); }
.mean-selection p { margin: 0; font-size: 13px; }
.mean-audit-panel table input[type="checkbox"] { width: 15px; height: 15px; vertical-align: middle; accent-color: #37d4bd; }
.mean-batch-plans { list-style: none; margin: 0; padding: 12px 14px; display: grid; gap: 8px; grid-template-columns: repeat(auto-fit, minmax(min(260px, 100%), 1fr)); }
.mean-batch-plans li { padding: 10px 12px; border: 1px solid var(--line); border-radius: 8px; }
.mean-batch-plans strong { font-size: 13px; }
.mean-batch-plans p { color: var(--muted); font-size: 12px; margin: 5px 0 0; }
#run-title { font-size: clamp(16px, 1.8vw, 22px); }
.run-body { padding: clamp(14px, 2vw, 24px); }
.progress-label { align-items: baseline; }
#run-progress-label { color: var(--signal); font-family: var(--data); font-size: 22px; line-height: 1.1; }
progress { height: 7px; display: block; border: 0; border-radius: 6px; background: #263a4e; }
progress::-webkit-progress-bar { background: #263a4e; border-radius: 6px; }
progress::-webkit-progress-value { background: var(--signal); border-radius: 6px; }
progress::-moz-progress-bar { background: var(--signal); border-radius: 6px; }
.run-stages { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); list-style: none; gap: 12px; margin: 0 0 23px; padding: 0; }
.run-stages li { min-width: 0; display: flex; align-items: center; gap: 7px; color: var(--muted); font-size: 12px; }
.run-stages li::before { content: ""; display: inline-block; flex: 0 0 7px; width: 7px; height: 7px; border: 1px solid #6a8399; border-radius: 50%; }
.run-stages li[data-state="done"]::before { background: var(--signal); border-color: var(--signal); }
.run-stages li[aria-current="step"] { color: var(--ink); font-weight: 650; }
.run-stages li[aria-current="step"]::before { border-color: var(--signal); box-shadow: 0 0 0 3px #67ebd230; }
.run-stages li[data-state="failed"]::before, .run-stages li[data-state="interrupted"]::before { border-color: var(--red); box-shadow: none; }
.log-surface { border: 1px solid var(--line); border-radius: 9px; background: #0a131f; overflow: hidden; }
.log-surface h3 { padding: 10px 13px; color: #c5d9eb; font-size: 13px; font-weight: 630; background: #122235; border-bottom: 1px solid var(--line); }
.log-surface pre { margin: 0; font-family: var(--data); padding: 14px; min-height: 205px; border-radius: 0; }

.result-head { margin-bottom: 12px; }
.report-switch { border: 1px solid var(--line); border-radius: 10px; padding: 5px; width: fit-content; margin-bottom: 14px; background: #111d2b; max-width: 100%; }
.chart-switch button { min-height: 36px; }
.report-switch button { padding-inline: 15px; }
.result-controls { max-height: calc(100dvh - var(--masthead-offset, var(--masthead)) - 30px); overflow: auto; }
.result-controls .panel-head { background: #162b3e; }
.result-source { padding: 13px 12px; color: #cadae8; }
.offer-picker summary { min-height: 39px; }
.offer-picker-menu label { min-height: 31px; margin: 1px 0; }
.chart-panel > div > .panel-head { background: #162433; border-radius: var(--radius) var(--radius) 0 0; }
.offer-chart { margin: 9px 12px 0; border-radius: 9px; overflow: hidden; }
.offer-chart canvas { height: var(--pane-height, clamp(280px, 46dvh, 680px)); }
.report-chart canvas { height: var(--pane-height, clamp(365px, 31vw, 525px)); }
#correction-panel .offer-chart canvas { height: var(--correction-height, clamp(280px, 46dvh, 680px)); }
#result-plot img { height: var(--correction-height, auto); object-fit: contain; }
#means-table { height: var(--pane-height, auto); max-height: var(--pane-height, min(58dvh, 620px)); }
.offer-facts div { padding: 13px 9px; }
.offer-facts strong { display: inline-block; font-family: var(--data); font-size: clamp(11px, 1.2vw, 16px); color: #daf9f1; }
.correction-facts div { text-align: left; padding-inline: clamp(9px, 1.4vw, 17px); }
.correction-facts div:last-child strong { color: var(--signal); }
.offer-legend { padding: 10px 13px; }
.result-data .chart-switch { padding: 5px 8px; }
.report-table th, .report-table td { padding-inline: 12px; }
.report-table tr:hover td { background: #182b3d; }

#ai .pagehead .actions { justify-content: flex-end; }
.ai-chat-layout { grid-template-columns: minmax(218px, 264px) minmax(0, 1fr); gap: 16px; }
.ai-chat-create { padding: 12px 14px 3px; }
.ai-chat-exports { padding: 14px; }
.ai-chat-main { overflow: hidden; }
.ai-chat-main > .panel-head { background: #162b3e; min-height: 57px; }
#chat-model-status { max-width: min(44vw, 290px); }
.ai-chat-messages { background: #0d1722; padding: clamp(12px, 2.2vw, 26px); height: clamp(275px, calc(100dvh - 420px), 700px); }
.ai-chat-message { padding: 12px 15px; border-radius: 10px 10px 10px 4px; }
.ai-chat-message[data-role="user"] { border-radius: 10px 10px 4px 10px; background: #19383d; }
.ai-chat-message[data-role="assistant"] h3 { color: #a5caff; }
.ai-chat-content { color: var(--ink); }
.ai-chat-versions { border-bottom: 1px solid var(--line); }
#chat-form { padding: 14px 16px; background: #152231; }
#chat-text { background: var(--control); border-color: var(--line-strong); padding: 10px 11px; }
#chat-send { min-width: 74px; }
.ai-grid { grid-template-columns: minmax(300px, .95fr) minmax(0, 1.4fr); gap: 16px; }
.ai-stack .panel-head { background: #152738; border-radius: var(--radius) var(--radius) 0 0; }
.ai-badge { border: 1px solid #3a5368; }
.ai-badge[data-tone="error"] { color: var(--red); border-color: #754551; }
.ai-badge[data-tone="ready"] { border-color: #326451; }
dialog { border-color: #526777; box-shadow: 0 26px 90px #030710ad; }
dialog .panel-head { background: #182e40; }
dialog::backdrop { background: #030912ba; }
.button.danger { background: #2b202c; }
.button.danger:hover:not(:disabled) { border-color: #d18a89; }
input::placeholder, textarea::placeholder { color: #8fa4b5; opacity: 1; }

@media (max-width: 1020px) {
  .home-config-toggles { flex: 1 0 100%; flex-wrap: wrap; padding: 6px 0 0; border: 0; border-top: 1px solid var(--line); }
}
@media (max-width: 1360px) {
  .topbar { grid-template-columns: minmax(0, 1fr) auto; gap: 6px 10px; padding-block: 8px; }
  .topbar nav { grid-column: 1 / -1; grid-row: 2; }
  .topbar-actions { grid-column: 2; grid-row: 1; }
}
@media (max-width: 1000px) {
  :root { --gutter: 18px; }
  nav { gap: 3px; }
  nav a { padding-inline: 8px; }
  .editor-layout, .run-layout, .result-grid, .ai-chat-layout { grid-template-columns: minmax(195px, 226px) minmax(0, 1fr); gap: 12px; }
}
@media (max-width: 760px) {
  .topbar nav { justify-content: stretch; display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); }
  nav a { padding: 4px; min-height: 44px; justify-content: center; font-size: 12px; gap: 6px; }
  .editor-layout, .run-layout, .result-grid, .ai-chat-layout, .ai-grid { grid-template-columns: minmax(0, 1fr); }
  .file-panel, .result-controls, .ai-chat-sidebar { position: static; max-height: none; }
  .file-list, .run-list { max-height: 35dvh; }
  .home-province-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .home-chart-controls { flex-basis: 100%; }
  .home-chart-controls select { width: 100%; }
  #home-job { max-width: min(51vw, 410px); }
  #offer-filters, #report-filters { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .period-controls { grid-column: 1 / -1; }
  .offer-picker + .offer-picker { border-top: 0; border-left: 1px solid var(--line); }
  .offer-picker-menu { max-height: 127px; }
  #chat-list { max-height: min(34dvh, 210px); }
  .ai-chat-create, .ai-chat-exports { display: flex; flex-wrap: wrap; align-items: center; }
}
@media (max-width: 520px) {
  :root { --gutter: 11px; }
  .topbar nav { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  nav a { flex-direction: column; gap: 3px; padding: 3px 1px; font-size: 10px; }
  .brand-mark { width: 32px; height: 32px; }
  .brand strong { font-size: 15px; }
  main { padding-block: 20px 30px; }
  .pagehead { flex-wrap: wrap; margin-bottom: 13px; }
  .pagehead p { margin-top: 6px; }
  #ai .pagehead .actions { justify-content: flex-start; }
  .home-config-fields { padding-inline: 12px; }
  .home-config-head { padding-inline: 12px; }
  .home-config-toggles { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0 12px; }
  .topbar-actions .local { display: none; }
  .topbar-actions { gap: 5px; }
  .home-toggle { min-height: 40px; justify-content: space-between; }
  .home-chart-controls { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 7px; }
  .home-chart-controls label:first-child { grid-column: 1 / -1; }
  #home-job { max-width: 100%; }
  .home-system-metrics > div { padding: 10px 6px; overflow-wrap: anywhere; }
  .home-system-metrics dt { font-size: 10px; }
  .home-system-metrics strong { font-size: clamp(14px, 4.4vw, 23px); }
  .home-system-metrics small { font-size: 9px; }
  .home-system-metrics dd { gap: 2px 5px; }
  .home-system .home-plot { --plot-height: var(--pane-height, 220px); margin: 9px 3px 3px; }
  .home-province-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .home-province { padding-inline: 9px; }
  .home-province .home-plot { --plot-height: 138px; margin-inline: -4px; }
  .run-stages { gap: 8px; }
  .run-stages li { font-size: 11px; gap: 5px; }
  .run-stages li::before { width: 5px; height: 5px; flex-basis: 5px; }
  .report-switch { width: 100%; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .report-switch button { padding-inline: 4px; }
  #offer-legend-items { grid-template-columns: 1fr; }
  .offer-legend.single-visible { flex-wrap: wrap; }
  .correction-facts { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .correction-facts div { border-top: 1px solid var(--line); }
  .data-toolbar { flex-wrap: wrap; }
  .ai-chat-scope { grid-template-columns: minmax(0, 1fr) 80px; }
  .ai-chat-message { max-width: 100%; }
  .ai-chat-actions { flex-wrap: wrap; }
  .ai-endpoint-body dl { grid-template-columns: minmax(0, 1fr); gap: 4px; }
  .ai-endpoint-body dd { margin-bottom: 7px; }
  .config-actions { flex-wrap: wrap; }
}
@media (max-width: 440px) {
  .lan-project .topbar-actions { grid-column: 1 / -1; grid-row: 2; }
  .lan-project .topbar nav { grid-row: 3; }
}
@media (prefers-reduced-motion: reduce) {
  .button, nav a, input[role="switch"], input[role="switch"]::after { transition: none; }
  .button:active:not(:disabled) { transform: none; }
  dialog[open] { animation: none; }
}

.curve-tree { min-width: 0; padding: 6px 8px 9px; }
.curve-tree-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 0 4px; font-size: 12px; }
.curve-tree-head .button, .curve-tree-tools .button { min-height: 26px; padding: 2px 6px; font-size: 11px; }
.curve-tree-list, .curve-tree-children { list-style: none; padding: 0; margin: 0; }
.curve-tree-list { max-height: min(560px, 65vh); overflow: auto; }
.curve-tree-children { margin-left: 10px; padding-left: 4px; border-left: 1px solid var(--line); }
.curve-tree-tools { display: flex; align-items: center; flex-wrap: wrap; gap: 3px 8px; padding-left: 12px; }
.curve-tree-grouping { display: inline-flex; align-items: center; gap: 3px; padding: 0; font-size: 11px; }
.curve-tree-grouping input { width: 12px; height: 12px; margin: 0; }
.curve-tree-row { display: flex; align-items: center; gap: 6px; min-height: 30px; padding: 2px 4px; border-radius: 4px; }
.curve-tree-row:has(input:checked) { background: var(--blue-soft); color: var(--blue-dark); }
.curve-tree-row input { flex: 0 0 13px; height: 13px; width: 13px; margin: 0; }
.curve-tree-toggle, .curve-tree-label { flex: 1; min-width: 0; text-align: left; color: inherit; font-size: 12px; }
.curve-tree-toggle { display: flex; align-items: center; justify-content: space-between; padding: 3px 0; gap: 4px; border: 0; background: transparent; cursor: pointer; }
.curve-tree-toggle::after { content: ""; width: 5px; height: 5px; border-right: 1px solid; border-bottom: 1px solid; transform: rotate(-45deg); flex: none; margin-right: 4px; }
.curve-tree-toggle[aria-expanded="true"]::after { transform: rotate(45deg); }
.curve-tree-label { cursor: pointer; overflow-wrap: anywhere; }
.curve-tree-empty { font-size: 12px; color: var(--muted); margin: 5px; }
#offer-filters .curve-tree, #correction-filters .curve-tree { width: 100%; grid-column: 1 / -1; }
.curve-mode { flex: 0 0 auto; }
.curve-mode button { padding: 5px 8px; min-height: 30px; }
.offer-independent { display: grid; gap: 10px; padding: 10px; }
.offer-independent-chart { border: 1px solid var(--line); border-radius: 6px; min-width: 0; }
.offer-independent-title { margin: 2px 8px; font-size: 13px; }

.home-system .home-system-metrics { grid-template-columns: repeat(5, minmax(0, 1fr)); }
.home-system-metrics [data-non-renewable-mean] { color: var(--signal); }
.pane-split {
  --pane-default: 270px;
  grid-template-columns: clamp(192px, var(--pane-width, var(--pane-default)), min(58%, calc(100% - 316px))) 16px minmax(0, 1fr);
  gap: 0;
}
.pane-split.ai-chat-layout { --pane-default: 264px; }
.pane-divider {
  min-width: 0; align-self: stretch; cursor: col-resize; touch-action: none;
  background: linear-gradient(var(--line), var(--line)) center / 1px 100% no-repeat;
}
.pane-divider::after {
  content: ""; display: block; position: sticky; top: calc(var(--masthead-offset, var(--masthead)) + 32px);
  margin: 28px auto 0; width: 4px; height: 30px;
  background: repeating-linear-gradient(to bottom, var(--muted) 0 2px, transparent 2px 6px);
  opacity: .55;
}
.pane-divider:is(:hover, :focus-visible, .pane-dragging) {
  background: linear-gradient(var(--signal), var(--signal)) center / 2px 100% no-repeat;
}
.pane-divider:is(:hover, :focus-visible, .pane-dragging)::after { opacity: 1; }
.pane-divider.pane-divider-row {
  height: 16px; cursor: row-resize;
  background: linear-gradient(var(--line), var(--line)) center / 100% 1px no-repeat;
}
.pane-divider-row::after {
  position: static; width: 30px; height: 4px; margin: 6px auto;
  background: repeating-linear-gradient(to right, var(--muted) 0 2px, transparent 2px 6px);
}
.pane-divider.pane-divider-row:is(:hover, :focus-visible, .pane-dragging) {
  background: linear-gradient(var(--signal), var(--signal)) center / 100% 2px no-repeat;
}
.result-content > .pane-divider-row { margin-block: -11px; }
.template-workspace > .pane-divider-row { margin-block: -14px; }
.home-system + .pane-divider-row:not([hidden]) + .home-provinces { margin-top: 4px; }
.pane-height-scroll { height: var(--pane-height, revert); }
#chat-messages.pane-height-scroll { height: var(--pane-height, clamp(275px, calc(100dvh - 420px), 700px)); }
.pane-height-scroll[style*="--pane-height"] {
  min-height: 0; max-height: none; flex-shrink: 0;
}
@media (max-width: 1000px) {
  .pane-split { --pane-default: 226px; }
  .pane-split.ai-chat-layout { --pane-default: 226px; }
  .home-system .home-system-metrics { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}
@media (max-width: 760px) {
  .pane-split { grid-template-columns: minmax(0, 1fr); gap: 12px; }
  .pane-divider-col { display: none; }
}
@media (max-width: 520px) {
  .home-system .home-system-metrics { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
