:root {
  color-scheme: light;
  --bg: #f5f7f6;
  --surface: #fff;
  --ink: #182522;
  --muted: #61706c;
  --line: #dce4e0;
  --accent: #087967;
  --accent-soft: #e4f3ef;
  --warn: #9c5b17;
  --warn-soft: #fff4e5;
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--ink); font: 14px/1.5 "Microsoft YaHei", system-ui, sans-serif; }
header, main { width: min(100%, 1520px); margin: auto; padding-inline: 28px; }
header { min-height: 68px; display: flex; align-items: center; justify-content: space-between; gap: 16px; border-bottom: 1px solid var(--line); }
main { padding-top: 18px; }
h1 { margin: 0; font-size: 20px; font-weight: 700; }
h2 { margin: 0 0 12px; font-size: 17px; }
h3 { margin: 16px 0 8px; font-size: 14px; }
p { margin: 8px 0; }
.badge { display: inline-block; vertical-align: middle; margin-left: 8px; padding: 3px 7px; border-radius: 3px; background: var(--warn-soft); color: var(--warn); font-size: 11px; font-weight: 600; }
.actions { display: flex; align-items: center; gap: 14px; color: var(--muted); font-variant-numeric: tabular-nums; font-size: 12px; }
button { font: inherit; cursor: pointer; border: 1px solid var(--line); border-radius: 4px; padding: 8px 12px; background: var(--surface); color: var(--ink); }
button:hover { border-color: var(--accent); color: var(--accent); }
button:disabled { opacity: .5; cursor: default; }
button:focus-visible, input:focus-visible, select:focus-visible, summary:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.notice { margin: 0 0 14px; padding: 10px 12px; border-left: 3px solid #c98430; background: var(--warn-soft); color: #684819; font-size: 13px; }
.decision { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 0; margin: 0 0 14px; border-block: 1px solid var(--line); background: var(--surface); }
.decision-item { min-width: 0; padding: 11px 14px; display: grid; gap: 3px; border-right: 1px solid var(--line); }
.decision-item:last-of-type { border-right: 0; }
.decision-item span { color: var(--muted); font-size: 12px; }
.decision-item strong { font-size: 15px; }
.decision-item small { color: var(--muted); font-size: 11px; line-height: 1.4; }
.decision-item[data-tone="blocked"] strong { color: var(--warn); }
.decision-note { grid-column: 1 / -1; margin: 0; padding: 7px 14px; border-top: 1px solid var(--line); color: var(--warn); font-size: 12px; }
.summary { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 10px; }
.pool-card { min-width: 0; height: 78px; padding: 10px 14px; text-align: left; display: grid; grid-template-columns: 1fr auto; grid-template-rows: auto auto; align-content: center; gap: 3px 8px; }
.pool-card.selected { background: var(--accent-soft); border-color: var(--accent); box-shadow: inset 0 3px var(--accent); }
.pool-card span { font-weight: 700; overflow-wrap: anywhere; }
.pool-card strong { grid-row: 1 / span 2; grid-column: 2; align-self: center; font-size: 27px; line-height: 1; font-variant-numeric: tabular-nums; }
.pool-card small { color: var(--muted); font-size: 12px; }
.layout { display: grid; grid-template-columns: 224px minmax(0, 1fr); gap: 24px; margin-top: 20px; align-items: start; }
.layout aside, .workspace-main, #content { min-width: 0; }
.layout aside { border-right: 1px solid var(--line); padding-right: 18px; }
.layout aside h2, #tabs { height: 45px; margin: 0; border-bottom: 1px solid var(--line); }
.layout aside h2 { display: flex; align-items: center; font-size: 14px; }
#tabs { display: flex; gap: 4px; overflow-x: auto; overflow-y: hidden; scrollbar-width: none; }
#tabs::-webkit-scrollbar { display: none; }
#tabs button { border: 0; border-radius: 0; border-bottom: 2px solid transparent; background: transparent; white-space: nowrap; padding: 9px 12px; }
#tabs button.active { border-bottom-color: var(--accent); color: var(--accent); font-weight: 700; }
#content { padding-top: 18px; }
.model { display: grid; grid-template-columns: 28px 1fr; align-items: baseline; gap: 0 4px; min-height: 54px; padding: 7px 0; border-bottom: 1px solid var(--line); font-size: 13px; }
.model b { color: var(--accent); }
.model small { grid-column: 2; color: var(--muted); font-size: 12px; }
.limits { margin-top: 16px; font-size: 12px; }
.limits p { color: var(--muted); }
.panel { margin: 0 0 20px; padding: 0 0 18px; border-bottom: 1px solid var(--line); }
.pool-detail { min-height: 340px; }
.pool-meta { display: flex; gap: 18px; color: var(--muted); font-size: 12px; margin-bottom: 10px; }
.pool-empty { margin: 0 0 16px; padding: 11px 12px; color: var(--warn); background: var(--warn-soft); }
.empty { padding: 34px 16px; color: var(--muted); background: var(--surface); border: 1px solid var(--line); }
.empty strong { display: block; color: var(--ink); }
.table-wrap { overflow-x: auto; background: var(--surface); border: 1px solid var(--line); }
table { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; }
.stock-table, .source-table, .positions-table { table-layout: fixed; }
.stock-table th:nth-child(1), .stock-table td:nth-child(1) { width: 18%; }
.stock-table th:nth-child(2), .stock-table td:nth-child(2) { width: 8%; }
.stock-table th:nth-child(3), .stock-table td:nth-child(3) { width: 11%; }
.stock-table th:nth-child(4), .stock-table td:nth-child(4) { width: 12%; }
.stock-table th:nth-child(5), .stock-table td:nth-child(5) { width: 51%; }
.source-table th:nth-child(1), .source-table td:nth-child(1) { width: 16%; }
.source-table th:nth-child(2), .source-table td:nth-child(2) { width: 18%; }
.source-table th:nth-child(3), .source-table td:nth-child(3) { width: 12%; }
.source-table th:nth-child(4), .source-table td:nth-child(4) { width: 28%; }
.source-table th:nth-child(5), .source-table td:nth-child(5) { width: 26%; }
.positions-table th:nth-child(1), .positions-table td:nth-child(1) { width: 18%; }
.positions-table th:nth-child(2), .positions-table td:nth-child(2) { width: 12%; }
.positions-table th:nth-child(3), .positions-table td:nth-child(3) { width: 12%; }
.positions-table th:nth-child(4), .positions-table td:nth-child(4) { width: 12%; }
.positions-table th:nth-child(5), .positions-table td:nth-child(5) { width: 20%; }
.positions-table th:nth-child(6), .positions-table td:nth-child(6) { width: 26%; }
th, td { padding: 9px 11px; text-align: left; border-bottom: 1px solid #edf0ee; vertical-align: top; }
.stock-table :is(th, td):is(:nth-child(2), :nth-child(3), :nth-child(4)) { text-align: center; }
.source-table :is(th, td):is(:nth-child(3), :nth-child(5)), .positions-table :is(th, td):is(:nth-child(2), :nth-child(5)) { text-align: center; }
.positions-table :is(th, td):is(:nth-child(3), :nth-child(4)) { text-align: right; }
tbody tr:last-child td { border-bottom: 0; }
tbody tr:hover { background: #f4f9f7; }
th { font-size: 12px; color: var(--muted); font-weight: 600; background: #f9fbfa; white-space: nowrap; }
td { font-size: 13px; overflow-wrap: anywhere; }
.stock-table td:not(.reason) { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.stock-open { width: 100%; padding: 0; border: 0; background: transparent; color: var(--accent); text-align: left; font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.stock-open:hover { text-decoration: underline; }
.stock-preview { margin: 12px 0 18px; padding: 0 14px 12px; border: 1px solid var(--line); background: var(--surface); }
.stock-preview h3 { margin: 0 -14px 8px; padding: 10px 14px; border-bottom: 1px solid var(--line); background: #f9fbfa; font-size: 14px; }
.brief-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 0 18px; margin: 0; }
.brief-line { min-width: 0; display: grid; gap: 2px; padding: 7px 0; border-bottom: 1px solid var(--line); }
.brief-line dt { color: var(--muted); font-size: 11px; }
.brief-line dd { margin: 0; color: var(--ink); font-size: 12px; overflow-wrap: anywhere; }
.brief-block { color: var(--warn); font-size: 12px; white-space: normal; }
td.reason { color: var(--muted); }
.reason-content { line-height: 1.45; }
.reason-details { margin: 3px 0 0; }
.reason-details summary { font-size: 12px; }
.reason-details ul { margin: 7px 0 0; padding-left: 18px; }
.reason-details li { margin: 4px 0; color: var(--ink); }
.reason-details small { display: block; color: var(--muted); font: 10px/1.4 Consolas, monospace; overflow-wrap: anywhere; }
details { margin-top: 12px; }
summary { cursor: pointer; color: var(--accent); }
pre { padding: 12px; background: var(--surface); border: 1px solid var(--line); white-space: pre-wrap; overflow-wrap: anywhere; max-height: 400px; overflow: auto; font: 11px/1.6 Consolas, monospace; }
.muted { color: var(--muted); }
.status { color: var(--warn); }
label { display: flex; flex-direction: column; gap: 5px; color: var(--muted); }
input, select { min-width: 0; padding: 9px; border: 1px solid var(--line); border-radius: 3px; background: var(--surface); color: var(--ink); font: inherit; }
.form-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; }
.form-grid button { align-self: end; }
footer { padding: 16px 0 28px; color: var(--muted); border-top: 1px solid var(--line); font-size: 11px; }
.error, .positive { color: #b13d37; }
.negative { color: var(--accent); }
@media (max-width: 1120px) {
  .layout { grid-template-columns: minmax(0, 1fr); gap: 20px; }
  .workspace-main { grid-row: 1; }
  .layout aside { grid-row: 2; border-right: 0; border-top: 1px solid var(--line); padding: 12px 0 0; }
  .layout aside h2 { height: auto; min-height: 35px; border-bottom: 0; }
  #models { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0 16px; }
}
@media (max-width: 650px) {
  header, main { padding-inline: 14px; }
  header { min-height: 72px; }
  h1 { font-size: 17px; }
  .actions { gap: 5px; }
  #clock { display: none; }
  .summary { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
  .decision { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .decision-item:nth-child(2) { border-right: 0; }
  .decision-item:nth-child(-n+2) { border-bottom: 1px solid var(--line); }
  .brief-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0 12px; }
  .pool-card { height: 72px; padding: 9px; }
  .pool-card strong { font-size: 23px; }
  .layout { margin-top: 14px; }
  .form-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .stock-table { min-width: 800px; }
  .source-table { min-width: 760px; }
  .positions-table { min-width: 840px; }
}
