:root {
  color-scheme: light;
  --font: Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", Arial, sans-serif;
  --ink: #172a24;
  --muted: #51645c;
  --green: #165440;
  --mint: #c9ef9a;
  --line: #dce5df;
  --paper: #fff;
  --base: #f3f6f3;
  --soft: #edf4ee;
  --down: #9c3d31;
  --up: #1c6248;
  --shadow: 0 1px 2px #12262110;
  font-family: var(--font);
  color: var(--ink);
  background: var(--base);
  font-variant-numeric: tabular-nums;
}

*, *::before, *::after { box-sizing: border-box; }
body { margin: 0; min-width: 0; }
button, input, select { font: inherit; }
button { cursor: pointer; }
a { color: var(--green); }
[hidden] { display: none !important; }
::selection { background: #d1f39f; color: var(--ink); }
:focus-visible { outline: 2px solid #226d53; outline-offset: 3px; }
.topbar :focus-visible { outline-color: var(--mint); }
.skip { position: absolute; z-index: 20; left: 16px; top: -60px; padding: 8px 12px; background: white; }
.skip:focus { top: 10px; }

.topbar { background: #142a23; color: #fff; }
.topbar-inner, .page { width: min(1440px, 100% - 64px); margin: 0 auto; }
.topbar-inner { height: 66px; display: flex; align-items: center; justify-content: space-between; gap: 20px; }
.brand { color: #f6faf3; display: inline-flex; gap: 11px; align-items: center; text-decoration: none; font-size: 19px; font-weight: 750; letter-spacing: -.025em; flex: none; }
.brand-mark { width: 30px; height: 30px; border-radius: 9px; display: flex; align-items: flex-end; justify-content: center; gap: 3px; padding: 7px; background: var(--mint); color: #183229; transform: rotate(-6deg); }
.brand-mark i { width: 3px; height: 8px; border-radius: 2px; background: currentColor; }
.brand-mark i:nth-child(2) { height: 12px; }
.brand-mark i:nth-child(3) { height: 16px; }
.brand-sub { margin-left: 7px; color: #bad1c5; font-size: 14px; letter-spacing: 0; font-weight: 550; }
.bar-actions { display: flex; align-items: center; gap: 10px; min-width: 0; }
.scenario-ident { font-size: 13px; color: #d5e4d9; margin-right: 5px; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; max-width: 220px; }

.button { display: inline-flex; align-items: center; justify-content: center; gap: 7px; font-size: 14px; padding: 9px 14px; min-height: 38px; border: 1px solid var(--line); background: white; color: var(--ink); border-radius: 8px; font-weight: 640; text-decoration: none; white-space: nowrap; }
.button:hover { background: #edf4ee; }
.button:disabled { opacity: .5; cursor: default; }
.button-dark { background: #203931; border-color: #476257; color: #f8fbf8; }
.button-dark:hover { background: #315347; }
.button-mint { background: var(--mint); color: #173429; border-color: var(--mint); }
.button-mint:hover { background: #def7bd; }
.button-primary { background: var(--green); color: white; border-color: var(--green); }
.button-primary:hover { background: #234e40; }
.button-quiet { border-color: transparent; background: transparent; }
.button-small { padding: 6px 10px; min-height: 32px; font-size: 13px; }
.block { width: 100%; }

.page-head { display: flex; align-items: flex-end; justify-content: space-between; padding: 30px 0 20px; gap: 16px; }
.page-head h1 { font-size: clamp(2.15rem, 3.2vw, 3.25rem); line-height: 1.04; letter-spacing: -.052em; margin: 0 0 8px; font-weight: 740; }
.page-head p { margin: 0; font-size: 15px; color: var(--muted); line-height: 1.5; }
.head-meta { display: flex; align-items: flex-end; flex-direction: column; gap: 7px; min-height: 46px; padding-bottom: 3px; font-size: 13px; color: var(--muted); text-align: right; }
.badge { display: inline-flex; align-items: center; border-radius: 100px; padding: 5px 10px; font-size: 13px; font-weight: 650; color: #644817; background: #f7eed9; }
.badge-confirmed { color: #225941; background: #e2f2e7; }
.tabs { display: flex; gap: 5px; padding-bottom: 2px; border-bottom: 1px solid var(--line); margin-bottom: 18px; overflow-x: auto; }
.tabs a { white-space: nowrap; color: #495f55; font-size: 14px; font-weight: 660; padding: 10px 15px; border-radius: 8px 8px 0 0; text-decoration: none; }
.tabs a:hover { background: var(--soft); }
.tabs a[aria-current="page"] { color: var(--green); background: #e4efe5; box-shadow: inset 0 -2px #286d52; }

.workbench { display: grid; min-height: calc(100svh - 235px); grid-template-columns: minmax(238px, 276px) minmax(0, 1fr); grid-template-areas: "controls output"; align-items: start; gap: 18px; }
.workbench.has-summary { grid-template-areas: "controls summary" "controls output"; grid-template-rows: auto 1fr; }
.knobs { grid-area: controls; }
#kpi-summary { grid-area: summary; }
#workspace { grid-area: output; min-width: 0; }
.panel { background: var(--paper); border: 1px solid var(--line); border-radius: 13px; box-shadow: var(--shadow); min-width: 0; }
.knobs { padding: 18px; }
h2, h3 { margin: 0; letter-spacing: -.028em; }
h2 { font-size: 19px; font-weight: 720; line-height: 1.2; }
h3 { font-size: 16px; font-weight: 690; line-height: 1.25; }
.knob-head { margin-bottom: 18px; }
.knob-bottom { border-top: 1px solid var(--line); padding-top: 15px; margin-top: 14px; display: grid; gap: 10px; }
.control { margin-bottom: 15px; }
.control-top { display: flex; align-items: center; justify-content: space-between; gap: 6px; min-height: 33px; }
.control label, .field-title { font-size: 14px; font-weight: 615; color: #30463a; }
.control-input { width: 79px; text-align: right; font-weight: 680; }
.control[data-key="count"] .control-input { width: 53px; }
input[type="text"], input[type="date"], select {
  width: 100%; min-width: 0; border: 1px solid #c9d6ce; border-radius: 8px; background-color: #fff; color: var(--ink); min-height: 36px;
  padding: 7px 9px; font-size: 14px; line-height: 1.2;
}
input.control-input { width: 79px; }
.control[data-key="count"] input.control-input { width: 53px; }
input[type="text"]:hover, select:hover { border-color: #879f91; }
input[aria-invalid="true"] { border-color: #ad5144; background: #fff4f1; }
select { appearance: none; padding-right: 29px; white-space: nowrap; text-overflow: ellipsis; background-image: linear-gradient(45deg, transparent 49%, #426658 50%), linear-gradient(135deg, #426658 50%, transparent 51%); background-position: calc(100% - 15px) center, calc(100% - 10px) center; background-size: 5px 5px; background-repeat: no-repeat; }
.control input[type="range"] { appearance: none; display: block; width: 100%; margin: 10px 0 5px; height: 20px; background: transparent; cursor: pointer; }
input[type="range"]::-webkit-slider-runnable-track { height: 5px; border-radius: 4px; background: linear-gradient(to right,#438365 var(--progress,0%),#dce8df var(--progress,0%)); }
input[type="range"]::-webkit-slider-thumb { appearance: none; margin-top: -6px; width: 17px; height: 17px; border: 2px solid white; border-radius: 50%; background: #235d49; box-shadow: 0 0 0 1px #235d49; }
input[type="range"]::-moz-range-track { height: 5px; border-radius: 4px; background: #dce8df; }
input[type="range"]::-moz-range-progress { height: 5px; border-radius: 4px; background: #438365; }
input[type="range"]::-moz-range-thumb { width: 15px; height: 15px; border: 2px solid white; border-radius: 50%; background: #235d49; box-shadow: 0 0 0 1px #235d49; }
.control-scale { display: flex; justify-content: space-between; font-size: 12px; color: var(--muted); }
.field, .knob-bottom label { display: grid; gap: 6px; min-width: 0; }
.knob-note { font-size: 13px; line-height: 1.4; color: var(--muted); margin: 0; }
.presets { display: flex; flex-wrap: wrap; gap: 6px; margin: 7px 0 0; }
.preset { color: #365a48; padding: 4px 8px; background: var(--soft); border: 1px solid #dfe9df; border-radius: 6px; font-size: 12px; font-weight: 680; }
.preset:hover, .preset[aria-pressed="true"] { background: #d9eed8; border-color: #a4c4ae; }
.note { font-size: 13px; color: var(--muted); line-height: 1.45; }

.stack { display: grid; gap: 16px; }
.kpis { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; }
.kpi { padding: 16px 14px 14px; min-height: 106px; }
.kpi.key { background: #eaf3e9; border-color: #d6e5d6; }
.kpi-label { font-size: 13px; color: #42584c; font-weight: 630; line-height: 1.35; }
.kpi-value { margin: 8px 0 6px; font-size: clamp(1.38rem, 2.4vw, 2rem); font-weight: 760; line-height: 1; letter-spacing: -.052em; white-space: nowrap; }
.kpi-unit { font-size: 12px; color: #506357; font-weight: 540; }
.negative { color: var(--down); }
.positive { color: var(--up); }
.panel-head { padding: 16px 17px 12px; display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.panel-head p { margin: 5px 0 0; color: var(--muted); font-size: 13px; line-height: 1.4; }
.segmented { display: flex; gap: 3px; background: var(--soft); border: 1px solid #e0e9e1; border-radius: 8px; padding: 3px; }
.segmented button { appearance: none; border: 1px solid transparent; background: transparent; border-radius: 6px; padding: 5px 8px; font-size: 13px; font-weight: 630; color: #3e5549; }
.segmented button[aria-pressed="true"] { background: white; border-color: #d8e3d9; color: #173c2e; box-shadow: var(--shadow); }
.chart-wrap { position: relative; margin: 0 15px; }
.chart { display: block; width: 100%; height: 226px; touch-action: pan-y; }
.chart-tooltip { position: absolute; pointer-events: none; min-width: 144px; max-width: 210px; padding: 9px 11px; border: 1px solid #b1c8b7; border-radius: 8px; color: var(--ink); background: var(--paper); font-size: 13px; line-height: 1.5; box-shadow: 0 3px 12px #163c261e; z-index: 1; }
.chart-tooltip strong { display: block; font-size: 14px; }
.chart-foot { display: flex; justify-content: space-between; gap: 10px; align-items: center; flex-wrap: wrap; padding: 8px 17px 14px; color: var(--muted); font-size: 13px; border-top: 1px solid #ebf1ec; }
.legend { display: inline-flex; gap: 7px; align-items: center; }
.legend::before { content: ''; width: 12px; height: 3px; border-radius: 2px; background: #267c5b; }
.chart-key { min-width: 24px; color: var(--muted); }

.table-scroll { overflow: auto; max-width: 100%; }
table { width: 100%; border-collapse: collapse; font-size: 14px; line-height: 1.3; }
th, td { padding: 10px 12px; border-bottom: 1px solid #e5ede6; white-space: nowrap; text-align: left; }
th:first-child, td:first-child { padding-left: 17px; }
th:last-child, td:last-child { padding-right: 17px; }
thead th { background: #eef4ee; font-weight: 650; color: #3b5748; font-size: 13px; }
tbody tr:last-child td, tbody tr:last-child th { border-bottom: 0; }
tbody tr:hover { background: #f6f9f6; }
td.number, th.number { text-align: right; }
td strong { font-weight: 680; }
.table-sub { display: block; color: var(--muted); font-size: 12px; margin-top: 3px; }
.pill { display: inline-block; font-size: 12px; font-weight: 670; color: #365849; padding: 4px 7px; border-radius: 6px; background: #ecf2ed; }
.pill.pending { color: #69501e; background: #f8efdb; }
.pill.blocked { color: #813728; background: #f8ebe7; }
.empty { color: var(--muted); padding: 16px 17px; line-height: 1.5; }
.filters { display: flex; flex-wrap: wrap; align-items: end; gap: 10px 15px; padding: 0 17px 14px; }
.filters .field { min-width: 160px; }
.filters .narrow { min-width: 100px; max-width: 115px; }
.check { display: inline-flex; align-items: center; gap: 7px; min-height: 32px; color: #314b3e; font-size: 14px; line-height: 1.3; }
input[type="checkbox"] { width: 16px; height: 16px; margin: 0; accent-color: var(--green); flex: none; }
.stat-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; padding: 0 17px 14px; }
.mini { display: grid; gap: 6px; background: #f3f7f3; padding: 10px; border-radius: 8px; }
.mini span { font-size: 13px; color: var(--muted); }
.mini strong { font-size: 16px; color: var(--ink); }
.heatmap th, .heatmap td { text-align: center; }
.heatmap button { border: 0; color: #253e31; background: transparent; font-weight: 680; border-radius: 5px; font-size: 13px; padding: 4px 2px; min-width: 58px; }
.heatmap th:has(button), .heatmap td { padding-top: 8px; padding-bottom: 8px; }
.heatmap .negative { color: #8d392f; }
.heatmap .positive { color: #1f5b41; }
.heatmap button:hover { text-decoration: underline; }
.section-body { padding: 0 17px 17px; }
.group { padding: 13px 17px; }
.group > summary { cursor: pointer; font-size: 16px; font-weight: 690; }
.group[open] > summary { margin-bottom: 13px; }
.fields { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; }
.field-wide { grid-column: span 2; }
.miner-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; }
.miner-card { border: 1px solid var(--line); border-radius: 10px; padding: 13px; min-width: 0; }
.miner-card .fields { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.miner-card h3 { margin-bottom: 6px; font-size: 15px; }
.miner-card p { margin: 0 0 12px; }
.source-list { display: grid; gap: 7px 14px; grid-template-columns: repeat(2,minmax(0,1fr)); margin: 4px 0 0; padding: 0; list-style: none; }
.source-list li { padding: 8px 0; border-bottom: 1px solid var(--line); line-height: 1.35; }
.source-list a { font-size: 14px; font-weight: 640; }
.source-list span { display: block; margin-top: 3px; font-size: 13px; color: var(--muted); }
.footer { display: flex; justify-content: space-between; gap: 15px; padding: 25px 0; color: #53665b; font-size: 13px; }

dialog { padding: 0; border: 1px solid #cbd9ce; border-radius: 16px; width: min(690px, 100% - 32px); max-height: 92dvh; color: var(--ink); box-shadow: 0 16px 54px #102e2450; }
dialog::backdrop { background: #10251ab0; }
.dialog-head { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 15px 20px; border-bottom: 1px solid var(--line); }
.dialog-content { padding: 17px 20px; }
.dialog-stats { padding: 0 0 9px; gap: 7px; }
.dialog-actions { display: flex; justify-content: flex-end; gap: 8px; flex-wrap: wrap; padding: 12px 20px 16px; border-top: 1px solid var(--line); }
.dialog-content .note { margin: 0 0 12px; }
.site-counts { margin-top: 15px; padding-top: 12px; border-top: 1px solid var(--line); }
.site-counts h3 { margin-bottom: 10px; }
.error-text { color: #9d3328; font-size: 14px; line-height: 1.4; margin: 11px 0 0; }
.scenario-list { padding: 0; margin: 12px 0 0; list-style: none; max-height: 240px; overflow: auto; }
.scenario-list li { display: flex; align-items: center; gap: 7px; border-bottom: 1px solid var(--line); padding: 7px 0; }
.scenario-list li span { flex: 1; overflow-wrap: anywhere; min-width: 0; }
.notice { position: fixed; z-index: 10; bottom: 18px; right: 18px; max-width: min(380px, 100% - 36px); border-radius: 9px; padding: 12px 15px; background: #173b2d; color: white; font-size: 14px; box-shadow: 0 7px 22px #122a2440; }

@media (max-width: 1150px) {
  .topbar-inner, .page { width: calc(100% - 40px); }
  .workbench { grid-template-columns: minmax(205px, 237px) minmax(0, 1fr); gap: 14px; }
  .knobs { padding: 14px; }
  .kpis { gap: 8px; }
  .kpi { padding-left: 11px; padding-right: 10px; }
  .miner-grid { grid-template-columns: 1fr; }
  .miner-card .fields { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}
@media (max-width: 860px) {
  .workbench { grid-template-columns: minmax(0, 1fr); grid-template-areas: "controls" "output"; }
  .workbench.has-summary { grid-template-areas: "summary" "controls" "output"; grid-template-rows: auto auto 1fr; }
  .knobs { padding: 14px 15px 12px; }
  .knob-head { margin-bottom: 10px; }
  #quick-inputs { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 0 14px; }
  .presets { align-self: end; }
  .control { margin-bottom: 7px; }
  .knob-bottom { display: grid; grid-template-columns: 1fr 1fr auto; margin-top: 6px; align-items: end; }
  .knob-note { grid-column: 1 / -1; }
  .kpi-value { font-size: 1.85rem; }
}
@media (max-width: 600px) {
  .topbar-inner, .page { width: calc(100% - 26px); }
  .topbar-inner { height: 56px; gap: 7px; }
  .brand { font-size: 16px; gap: 7px; }
  .brand-sub, .scenario-ident { display: none; }
  .brand-mark { width: 25px; height: 25px; padding: 5px; }
  .bar-actions { gap: 6px; }
  .bar-actions .button { font-size: 13px; padding: 6px 9px; min-height: 34px; }
  .page-head { padding: 21px 0 13px; display: block; }
  .page-head p { font-size: 14px; }
  .head-meta { align-items: center; flex-direction: row; justify-content: space-between; min-height: 27px; margin-top: 10px; font-size: 12px; text-align: left; }
  .tabs a { padding: 9px 10px; font-size: 13px; }
  #quick-inputs { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0 11px; }
  .control label { font-size: 13px; }
  input.control-input { width: 63px; }
  .knob-bottom { grid-template-columns: 1fr 1fr; gap: 8px; }
  .knob-bottom .button, .knob-note { grid-column: 1/-1; }
  .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
  .kpi { min-height: 90px; padding: 12px 10px; }
  .kpi-value { font-size: clamp(1.28rem, 6vw, 1.8rem); margin: 7px 0; }
  .panel-head { padding: 13px 13px 10px; gap: 7px; }
  .chart { height: 192px; }
  .chart-wrap { margin: 0 8px; }
  .chart-foot { padding-left: 12px; padding-right: 12px; }
  .filters, .stat-grid { padding-left: 13px; padding-right: 13px; }
  .stat-grid, .fields, .miner-card .fields { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .source-list { grid-template-columns: 1fr; }
  .footer { font-size: 12px; }
}
