:root {
  color-scheme: light;
  --ink: #142744;
  --muted: #4b607d;
  --edge: #d9e3f1;
  --wash: #eff4fb;
  --navy: #142b51;
  --red: #9e293b;
  --green: #176444;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
body {
  margin: 0;
  background: var(--wash);
  color: var(--ink);
  font: 15px/1.45 "Microsoft YaHei", "PingFang SC", system-ui, sans-serif;
  font-variant-numeric: tabular-nums;
}
h1, p { margin: 0; }
.wrap { width: min(1360px, 100% - 48px); margin-inline: auto; }
.masthead { color: white; background: var(--navy); border-bottom: 3px solid #4588df; }
.mast-row, .mast-actions, .table-meta { display: flex; justify-content: space-between; gap: 16px; align-items: center; }
.mast-row { padding: 24px 0; }
h1 { font-size: clamp(24px, 3vw, 34px); line-height: 1.2; }
.masthead p { color: #d9e6fa; font-size: 14px; margin-top: 8px; }
.stamp { text-align: right; white-space: nowrap; }
.stamp span { display: block; color: #c7d9f7; font-size: 12px; margin-top: 3px; }
button {
  font: inherit;
  font-weight: 700;
  color: white;
  background: #255fab;
  border: 1px solid #8db7ef;
  border-radius: 7px;
  padding: 8px 15px;
  cursor: pointer;
  white-space: nowrap;
}
button:hover { background: #1b4f93; }
button:disabled { opacity: .65; cursor: wait; }
button:focus-visible, .table-scroll:focus-visible { outline: 3px solid #5790e1; outline-offset: 2px; }
main.wrap { padding-block: 16px 26px; }
.desk-nav { display: flex; gap: 5px; margin-bottom: 12px; }
.desk-nav a {
  padding: 7px 12px;
  border: 1px solid transparent;
  border-radius: 6px;
  color: var(--muted);
  text-decoration: none;
  font-size: 14px;
  font-weight: 700;
}
.desk-nav a:hover { background: #e5eefb; }
.desk-nav a[aria-current="page"] { background: #fff; border-color: #c9daee; color: #22548c; }
.desk-nav a:focus-visible, select:focus-visible, .spot-filter input:focus-visible { outline: 3px solid #5790e1; outline-offset: 2px; }
.panel { background: white; border: 1px solid var(--edge); border-radius: 10px; }
.table-meta { padding: 11px 16px; color: var(--muted); font-size: 13px; flex-wrap: wrap; gap: 4px 15px; }
.table-scroll { overflow: auto; border-radius: 0 0 9px 9px; }
table { width: 100%; min-width: 980px; border-spacing: 0; }
th, td { padding: 6px 13px; border-bottom: 1px solid #e6ecf5; white-space: nowrap; }
thead th { background: #e8f0fa; color: #335073; font-size: 13px; }
thead tr:first-child th { border-top: 1px solid var(--edge); }
tbody th { font-weight: 700; }
tbody tr:nth-child(even) { background: #f7faff; }
tbody tr:hover { background: #edf4fe; }
tbody tr:last-child > * { border-bottom: 0; }
.product { text-align: left; }
.product small { padding-left: 8px; font-size: 11px; color: var(--muted); font-weight: 500; }
.market { font-size: 14px; }
.market-sz { border-left: 1px solid var(--edge); }
.number { text-align: right; min-width: 92px; }
.number small { display: block; font-size: 11px; line-height: 1.25; }
.board { background-color: #e6eff933; }
thead .board { background-color: #ddeaf8; }
.top-up { min-width: 128px; }
.supplement { display: flex; justify-content: space-between; gap: 9px; font-size: 13px; }
.supplement + .supplement { margin-top: 3px; }
.supplement span { color: var(--muted); }
.source-button, .detail-close {
  border: 1px solid #c3d6ee;
  background: #f1f6fc;
  color: #22548c;
}
.source-button { margin-block: 3px 2px; padding: 2px 6px; font-size: 11px; line-height: 1.25; border-radius: 4px; }
.source-button:hover, .detail-close:hover { background: #dceafc; }
.amount { display: block; font-size: 15px; font-weight: 700; }
.shortfall { color: var(--red); }
.pending { color: var(--muted); }
.result { text-align: left; }
.decision { font-size: 13px; font-weight: 700; }
.decision.pass { color: var(--green); }
.decision.below { color: var(--red); }
.status { margin-bottom: 10px; padding: 8px 12px; border: 1px solid #bbd1ef; border-radius: 7px; background: #e5efff; color: #254e83; font-size: 13px; }
.status.error { background: #fff4de; border-color: #ead19e; color: #6f470e; }
.notes { margin-top: 10px; color: var(--muted); font-size: 12px; }
.notes p + p { margin-top: 4px; }
.spot-meta { gap: 8px 15px; }
.spot-meta h2 { margin: 0; color: var(--ink); font-size: 17px; }
.spot-detail-panel { margin-top: 14px; }
.spot-filters { display: flex; flex-wrap: wrap; gap: 8px 12px; }
.spot-filter { display: flex; align-items: center; gap: 6px; }
.spot-filter :is(select, input), .forecast-filters select { font: inherit; background: white; color: var(--ink); border: 1px solid #bdcfe5; border-radius: 5px; padding: 3px 6px; }
.spot-filter input { width: 152px; }
.spot-table { min-width: 690px; }
.spot-net-scroll { max-height: 380px; }
.spot-net-table { min-width: 590px; }
.spot-recon-table { min-width: 860px; }
:is(.spot-net-table,.spot-recon-table) thead th { position: sticky; top: 0; }
.spot-recon-warning { color: var(--red); font-weight: 700; }
.spot-net-value { font-weight: 700; }
.net-buy { color: var(--red); }
.net-sell { color: var(--green); }
.spot-table :is(th, td):not(.number) { text-align: left; }
.spot-table small { display: block; padding: 0; color: var(--muted); font-size: 11px; font-weight: 400; }
.spot-side { font-weight: 700; }
.spot-empty { padding: 26px 16px; text-align: center; color: var(--muted); }
.snapshot-basis { display: block; color: var(--muted); }
.workflow-totals { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; margin-bottom: 12px; }
.workflow-totals a { display: flex; align-items: center; justify-content: space-between; gap: 8px; background: white; border: 1px solid var(--edge); border-radius: 8px; padding: 11px 13px; color: var(--ink); text-decoration: none; }
.workflow-totals span { color: var(--muted); font-size: 13px; }
.workflow-totals strong { font-size: 24px; line-height: 1; }
.workflow-totals a:hover { border-color: #83acdf; }
.workflow-totals a:focus-visible { outline: 3px solid #5790e1; outline-offset: 2px; }
.workflow-panel { margin-bottom: 13px; }
.workflow-heading h2 { margin: 0; color: var(--ink); font-size: 18px; }
.workflow-heading p { margin-top: 2px; }
.workflow-heading { flex-wrap: wrap; }
.forecast-filters { display: flex; align-items: center; flex-wrap: wrap; gap: 8px 12px; }
.workflow-filter, .forecast-check { display: flex; align-items: center; gap: 5px; white-space: nowrap; }
.workflow-scroll { max-height: 350px; }
.workflow-table { min-width: 690px; }
.workflow-table :is(th, td):not(.number) { text-align: left; }
.workflow-table thead th { position: sticky; top: 0; z-index: 1; }
.workflow-table small { display: block; font-size: 11px; color: var(--muted); font-weight: 400; }
.ticket-table { min-width: 1320px; }
.ticket-table :is(th,td) { padding-inline: 8px; }
.ticket-table th[scope="row"] { white-space: nowrap; }
.ticket-o32, .ticket-prices { border-left: 1px solid var(--edge); }
.ticket-price-high { background: #fdeced; color: var(--red); }
.ticket-price-high small { color: inherit; font-weight: 700; }
.quantity-summary { color: var(--ink); font-weight: 700; }
.quantity-summary .quantity-flag { color: var(--red); }
.ticket-quantity-diff { background: #fde0e2; color: #942525; font-weight: 700; white-space: nowrap; }
.ticket-quantity-missing { color: var(--muted); white-space: nowrap; }
.ticket-unmatched { padding: 8px 15px; border-top: 1px solid var(--edge); font-size: 13px; }
.ticket-unmatched summary { color: var(--muted); cursor: pointer; }
.ticket-unmatched ul { margin: 6px 0; padding-left: 20px; }
.workflow-amount { font-weight: 700; }
.workflow-actions { white-space: nowrap; }
.workflow-action { font-size: 12px; padding: 3px 6px; margin-right: 4px; }
.workflow-footnote { padding: 8px 15px; color: var(--muted); font-size: 12px; border-top: 1px solid var(--edge); }
.workflow-form { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 9px 12px; padding: 14px 16px; }
.workflow-form label { display: grid; gap: 4px; color: var(--muted); font-size: 13px; }
.workflow-form :is(input:not([type=checkbox]),textarea,select) { width: 100%; min-width: 0; padding: 6px 7px; font: inherit; color: var(--ink); background: white; border: 1px solid #bdcfe5; border-radius: 5px; }
.form-wide { grid-column: 1 / -1; }
.workflow-form .forecast-check, .candidate-list label, .detail-actions, .intake-parse { display: flex; align-items: center; gap: 7px; }
.intake-parse span, .workflow-detail > p { color: var(--muted); font-size: 13px; }
.intake-parse button { font-size: 12px; padding: 4px 7px; }
.workflow-form-error, .workflow-detail .workflow-form-error { color: var(--red); font-size: 13px; }
.workflow-detail { padding: 12px 16px 16px; }
.workflow-detail h3 { margin: 3px 0; font-size: 14px; }
.workflow-detail pre { margin: 4px 0 12px; padding: 8px; background: var(--wash); border-radius: 5px; color: var(--ink); font: inherit; white-space: pre-wrap; overflow-wrap: anywhere; }
.candidate-list { display: grid; gap: 5px; margin-block: 8px; }
.candidate-list label { padding: 5px; font-size: 13px; }
.detail-actions { margin-top: 10px; }
.comment-picking [data-comment-target] { cursor: crosshair; box-shadow: inset 0 0 0 1px #87afe0; }
.comment-picking [data-comment-target]:is(:hover, :focus-visible) { outline: 2px solid #2460aa; outline-offset: -2px; }
.comment-prompt button { font-size: 12px; padding: 2px 8px; }
.comment-dialog { width: min(610px, 100% - 24px); }
.comment-toolbar, .comment-status, .comment-form { padding: 10px 16px; }
.comment-toolbar { display: flex; gap: 8px; flex-wrap: wrap; }
.comment-toolbar button { font-size: 13px; padding: 4px 8px; }
.comment-status { color: var(--muted); font-size: 13px; }
.comment-items { max-height: 43vh; overflow: auto; }
.comment-thread { width: 100%; display: flex; justify-content: space-between; gap: 10px; color: var(--ink); background: white; border: 0; border-top: 1px solid var(--edge); border-radius: 0; padding: 9px 16px; text-align: left; white-space: normal; }
.comment-thread:hover { background: #eaf2fd; }
.comment-thread span { color: var(--muted); white-space: nowrap; }
.comment-entry { padding: 9px 16px; border-top: 1px solid var(--edge); }
.comment-entry-head { display: flex; justify-content: space-between; gap: 10px; margin-bottom: 3px; }
.comment-entry-head time { color: var(--muted); font-size: 12px; white-space: nowrap; }
.comment-entry p { white-space: pre-wrap; overflow-wrap: anywhere; }
.comment-form { display: grid; gap: 8px; border-top: 1px solid var(--edge); }
.comment-form label { display: grid; gap: 3px; color: var(--muted); font-size: 13px; }
.comment-form :is(input, textarea) { width: 100%; color: var(--ink); font: inherit; padding: 6px 8px; border-radius: 5px; border: 1px solid #bacde6; }
.comment-form button { justify-self: end; }
dialog {
  width: min(720px, 100% - 28px);
  max-height: 86vh;
  padding: 0;
  border: 1px solid #c7d8eb;
  border-radius: 10px;
  background: white;
  color: var(--ink);
  box-shadow: 0 14px 56px #0d254c50;
}
dialog::backdrop { background: #10254588; }
.detail-header, .detail-filters { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; padding: 14px 16px; }
.detail-header { border-bottom: 1px solid var(--edge); }
.detail-header h2 { font-size: 20px; margin: 0 0 4px; }
.detail-header p, #holdings-status { color: var(--muted); font-size: 13px; }
.detail-filters { justify-content: flex-start; flex-wrap: wrap; align-items: center; gap: 6px 12px; }
.detail-filters select { font: inherit; max-width: 100%; color: var(--ink); border: 1px solid var(--edge); border-radius: 5px; padding: 4px 8px; }
#holdings-status { padding: 16px; }
.detail-scroll { overflow: auto; max-height: 58vh; }
.detail-scroll table { min-width: 450px; }
.detail-scroll th { position: sticky; top: 0; }
.detail-scroll th, .detail-scroll td { text-align: left; }
.detail-scroll .number { text-align: right; }

@media (max-width: 680px) {
  .wrap { width: calc(100% - 24px); }
  .mast-row { align-items: flex-start; flex-direction: column; gap: 12px; padding: 16px 0; }
  .mast-actions { width: 100%; flex-wrap: wrap; }
  .stamp { text-align: left; }
  th, td { padding-inline: 8px; }
  .product small { display: block; padding-left: 0; }
  tr > .product { position: sticky; left: 0; z-index: 1; background: inherit; }
  thead tr > .product { background: #e8f0fa; }
  tbody tr { background: white; }
  .workflow-totals a { flex-direction: column; align-items: flex-start; }
}
