:root {
  --bg: #f5f6f8;
  --panel: #fff;
  --text: #1f2933;
  --muted: #667085;
  --line: #d7dde7;
  --blue: #1f6feb;
  --green: #168751;
  --amber: #a86400;
  --red: #b42318;
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--text); font-family: "Segoe UI", "Microsoft YaHei", Arial, sans-serif; line-height: 1.45; }
main { width: min(1380px, calc(100% - 28px)); margin: 0 auto; padding: 24px 0 40px; }
body:has([data-panel="plan"].active) main { width: calc(100% - 28px); }
header { display: flex; justify-content: space-between; gap: 16px; align-items: end; margin-bottom: 14px; }
h1 { margin: 0; font-size: 30px; letter-spacing: 0; }
h2 { margin: 0 0 12px; font-size: 17px; letter-spacing: 0; }
.muted { color: var(--muted); }
.pill { display: inline-flex; align-items: center; gap: 6px; border: 1px solid var(--line); border-radius: 999px; padding: 6px 10px; background: #fff; }
.header-pills { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.job-pill { cursor: pointer; font: inherit; }
.job-pill.running { border-color: var(--green); color: var(--green); animation: pulse 1.6s infinite; }
.job-pill.failed { border-color: var(--red); color: var(--red); }
@keyframes pulse { 0%,100% { box-shadow: 0 0 0 0 rgba(22,135,81,.35); } 50% { box-shadow: 0 0 0 6px rgba(22,135,81,0); } }
.tabs { display: flex; gap: 8px; flex-wrap: wrap; margin: 4px 0 14px; }
.tab-btn { border: 1px solid var(--line); background: #fff; color: var(--muted); border-radius: 8px; padding: 8px 16px; cursor: pointer; font: inherit; }
.tab-btn.active { background: var(--blue); border-color: var(--blue); color: #fff; }
.tab-panel { display: none; }
.tab-panel.active { display: block; }
.grid { display: grid; gap: 12px; }
.cards { grid-template-columns: repeat(10, minmax(0, 1fr)); margin: 16px 0; }
.two { grid-template-columns: minmax(0, .9fr) minmax(0, 1.1fr); }
.card, .panel { background: var(--panel); border: 1px solid var(--line); border-radius: 8px; padding: 14px; }
.card { border-top: 4px solid var(--blue); min-height: 84px; padding: 10px; }
.card.ok { border-top-color: var(--green); }
.card.warn { border-top-color: var(--amber); }
.card.bad { border-top-color: var(--red); }
.card span { display: block; color: var(--muted); font-size: 13px; }
.card strong { display: block; margin-top: 5px; font-size: 22px; }
.card small { color: var(--muted); overflow-wrap: anywhere; }
#remoteQueuedHint { white-space: pre-line; }
.panel { margin: 12px 0; }
label { display: grid; gap: 4px; color: var(--muted); font-size: 13px; }
input { width: 100%; border: 1px solid var(--line); border-radius: 6px; padding: 8px 10px; font: inherit; color: var(--text); }
.form-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; }
.checkbox-label { display: flex; align-items: center; gap: 8px; padding-top: 24px; color: var(--text); }
.checkbox-label input { width: auto; }
.buttons { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 12px; }
button { border: 1px solid var(--line); border-radius: 6px; padding: 9px 12px; background: #fff; color: var(--text); font: inherit; cursor: pointer; }
button.primary { background: var(--blue); border-color: var(--blue); color: #fff; }
button.danger { border-color: #f2b8b5; color: var(--red); }
button:disabled { opacity: .55; cursor: not-allowed; }
.table-wrap { overflow: auto; border: 1px solid var(--line); border-radius: 6px; }
table { width: 100%; min-width: 760px; border-collapse: collapse; font-size: 13px; }
.compact-table table { min-width: 0; }
th, td { text-align: left; padding: 8px 9px; border-bottom: 1px solid #edf0f4; vertical-align: top; }
th { background: #f8fafc; color: #475467; }
tr.best-pass td { background: #ecfdf3; }
.detail-btn { padding: 5px 8px; font-size: 12px; }
code { font-family: Consolas, "Cascadia Mono", monospace; background: #f2f4f7; border: 1px solid #e4e7ec; border-radius: 5px; padding: 2px 5px; overflow-wrap: anywhere; }
.logs { max-height: 190px; overflow: auto; background: #101828; color: #e4e7ec; border-radius: 6px; padding: 10px; font-family: Consolas, monospace; font-size: 12px; white-space: pre-wrap; }
#jobLogs { max-height: 260px; }
.notice { border: 1px solid #b7d4ff; background: #eef5ff; color: #25496f; border-radius: 8px; padding: 10px 12px; margin: 12px 0; }
#dbActivity { white-space: pre-wrap; }
.help-toggle { display: inline-flex; align-items: center; justify-content: center; width: 20px; height: 20px; padding: 0; margin-left: 8px; border-radius: 50%; font-size: 12px; line-height: 1; color: var(--muted); vertical-align: 1px; }
.help-toggle.open { background: #f2f4f7; color: var(--text); border-color: var(--line); }
.help-text { display: none; margin: 0 0 10px; }
.help-text.open { display: block; }
.check-row { display: flex; flex-wrap: wrap; gap: 8px 22px; margin-top: 10px; }
.check-inline { display: flex; align-items: center; gap: 8px; color: var(--text); font-size: 13px; }
.check-inline input { width: auto; }
.plan-top-row { display: flex; gap: 12px; align-items: flex-start; margin: 16px 0 12px; }
.plan-top-row .cards { flex: 0 0 25%; grid-template-columns: 1fr; margin: 0; }
.plan-top-row .cards .card { display: flex; flex-direction: column; justify-content: center; }
.plan-week-panel { flex: 1 1 auto; margin: 0; min-width: 0; }
.plan-week-head { display: flex; align-items: center; flex-wrap: wrap; gap: 8px 14px; margin-bottom: 6px; }
.plan-week-head h2 { margin-bottom: 0; }
.plan-week-summary { font-size: 13px; color: var(--muted); flex: 1 1 auto; }
.plan-week-summary strong { color: var(--text); }
#planWeekChart { overflow-x: auto; }
#planWeekChart svg { min-width: 560px; display: block; }
@media (max-width: 1100px) { .plan-top-row { flex-direction: column; align-items: stretch; } .plan-top-row .cards { grid-template-columns: repeat(3, minmax(0, 1fr)); } .plan-week-panel { flex: 1 1 auto; } }
@media (max-width: 700px) { .plan-top-row .cards { grid-template-columns: 1fr; } }
.tower-line { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; margin-top: 8px; }
.tower-line .line-label { font-size: 12px; color: var(--muted); margin-right: 4px; }
.tower-more { margin-top: 10px; font-size: 13px; }
.tower-more summary { color: var(--blue); cursor: pointer; }
.modal { position: fixed; inset: 0; display: none; align-items: center; justify-content: center; background: rgba(15, 23, 42, .38); padding: 18px; z-index: 20; }
.modal-box { width: min(880px, 100%); max-height: min(760px, 92vh); overflow: auto; background: #fff; border-radius: 8px; border: 1px solid var(--line); padding: 16px; box-shadow: 0 18px 50px rgba(15, 23, 42, .22); }
.modal-head { display: flex; justify-content: space-between; align-items: start; gap: 12px; margin-bottom: 10px; }
.expr { width: 100%; min-height: 220px; resize: vertical; white-space: pre-wrap; word-break: break-word; background: #f8fafc; border: 1px solid var(--line); border-radius: 6px; padding: 10px; font-family: Consolas, "Cascadia Mono", monospace; font-size: 13px; }
.modal-actions { display: none; align-items: center; gap: 10px; margin-top: 12px; }
.message { color: var(--muted); }
.message.bad { color: var(--red); }
.message.ok { color: var(--green); }
.progress { height: 10px; background: #e9edf3; border-radius: 5px; overflow: hidden; margin: 10px 0 6px; }
.progress > i { display: block; height: 100%; width: 0; background: var(--blue); transition: width .4s ease; }
.progress.indeterminate > i { width: 30%; animation: slide 1.2s infinite linear; }
@keyframes slide { from { margin-left: -30%; } to { margin-left: 100%; } }
.badge { display: inline-block; border-radius: 999px; padding: 2px 10px; font-size: 12px; border: 1px solid var(--line); color: var(--muted); }
.badge.running, .badge.queued { border-color: #b7d4ff; color: #25496f; background: #eef5ff; }
.badge.succeeded { border-color: #a6f4c5; color: var(--green); background: #ecfdf3; }
.badge.failed { border-color: #f2b8b5; color: var(--red); background: #fef3f2; }
.badge.cancelled { border-color: #e4e7ec; color: var(--muted); background: #f2f4f7; }
.job-result { background: #f8fafc; border: 1px solid var(--line); border-radius: 6px; padding: 10px; font-size: 12px; overflow: auto; max-height: 220px; white-space: pre-wrap; }
@media (max-width: 1100px) { .cards { grid-template-columns: repeat(5, minmax(0, 1fr)); } .two, .form-grid { grid-template-columns: 1fr; } }
@media (max-width: 700px) { main { width: min(100% - 18px, 1380px); } header { display: block; } .cards { grid-template-columns: 1fr; } }
.impact-cell { white-space: nowrap; }
.impact-result { display: block; margin-top: 4px; font-size: 12px; color: var(--muted); overflow-wrap: anywhere; white-space: normal; }
.impact-result.bad { color: var(--red); }
.impact-btn.disabled { opacity: .6; cursor: default; }
.submission-queue-filters { display: flex; flex-wrap: wrap; align-items: end; gap: 12px; margin: 14px 0; }
#submissionQueuePanel select, .submission-queue-pick { border: 1px solid var(--line); border-radius: 6px; padding: 8px 10px; font: inherit; color: var(--text); background: var(--panel); }
.submission-queue-filters label { min-width: 150px; }
.submission-queue-pager { display: flex; align-items: center; gap: 12px; margin-top: 12px; }
.submission-queue-table table { min-width: 1150px; }
.submission-queue-actions { min-width: 160px; }
.submission-queue-target { min-width: 110px; max-width: 220px; overflow-wrap: anywhere; }
.submission-queue-evidence { margin-top: 5px; max-width: 250px; overflow-wrap: anywhere; white-space: pre-wrap; }
.submission-queue-evidence summary { cursor: pointer; color: var(--muted); }
.submission-queue-discovery { min-width: 150px; }
.submission-queue-discovery select { max-width: 160px; margin-bottom: 5px; }

/* detail modal */
#detailBody { display: grid; gap: 12px; margin-bottom: 12px; }
.detail-section h3 { margin: 0 0 8px; font-size: 12px; color: var(--muted); font-weight: 600; letter-spacing: .05em; }
.stat-row { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px; }
.stat-tile { border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; background: #f8fafc; }
.stat-tile span { display: block; font-size: 12px; color: var(--muted); }
.stat-tile strong { display: block; font-size: 17px; margin-top: 2px; }
.stat-tile.ok { border-color: #a6f4c5; background: #ecfdf3; }
.stat-tile.ok strong { color: var(--green); }
.stat-tile.bad { border-color: #f2b8b5; background: #fef3f2; }
.stat-tile.bad strong { color: var(--red); }
.detail-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px 14px; }
.kv span { display: block; font-size: 12px; color: var(--muted); }
.kv strong { font-size: 13px; font-weight: 600; overflow-wrap: anywhere; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.chip { display: inline-flex; align-items: center; border-radius: 999px; padding: 3px 10px; font-size: 12px; border: 1px solid var(--line); background: #fff; color: var(--muted); font-family: Consolas, "Cascadia Mono", monospace; }
.chip.pass { border-color: #a6f4c5; color: var(--green); background: #ecfdf3; }
.chip.fail { border-color: #f2b8b5; color: var(--red); background: #fef3f2; }
.chip.warn { border-color: #fedf89; color: var(--amber); background: #fffaeb; }
.chip.pend { border-color: #e4e7ec; color: var(--muted); background: #f2f4f7; }
.platform-link { color: var(--blue); }
.error-text { background: #fef3f2; border: 1px solid #f2b8b5; color: var(--red); border-radius: 6px; padding: 10px; font-family: Consolas, monospace; font-size: 12px; white-space: pre-wrap; overflow-wrap: anywhere; max-height: 140px; overflow: auto; margin: 0; }
.expr-caption { margin: 0 0 4px; font-size: 12px; }
@media (max-width: 700px) { .stat-row { grid-template-columns: repeat(2, minmax(0, 1fr)); } .detail-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); } }

/* Overview: key numbers first; supporting evidence opens on demand. */
.overview-health summary { display: flex; justify-content: space-between; gap: 16px; cursor: pointer; }
.overview-health summary > .muted { font-size: 13px; white-space: nowrap; }
.overview-cards { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.overview-cards .card { border-top: 1px solid var(--line); padding: 16px 18px; }
.overview-cards .card strong { font-size: 28px; font-weight: 600; }
.overview-cards small:empty { display: none; }
.overview-heading { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; }
.overview-heading > span { font-size: 12px; }
.inventory-stats { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 16px; margin: 4px 0 18px; }
.inventory-stats span { display: block; color: var(--muted); font-size: 13px; }
.inventory-stats strong { display: block; font-size: 28px; font-weight: 600; margin-top: 6px; }
.overview-detail { font-size: 13px; }
.overview-detail summary { cursor: pointer; color: var(--muted); }
.overview-detail summary > span { margin-left: 8px; }
.overview-detail[open] > summary { margin-bottom: 14px; }
.overview-health[open] .overview-detail { margin-top: 16px; }
#overviewMoreCards { grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); }
.message.warn { color: var(--amber); }
.decision-panel { padding: 18px 22px; }
.decision-panel h2 { margin-bottom: 14px; }
.overview-heading > a { color: var(--muted); font-size: 13px; text-decoration: none; }
.capacity-lanes { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 24px; }
.capacity-lane { min-width: 0; }
.capacity-lane + .capacity-lane { border-left: 1px solid var(--line); padding-left: 24px; }
.lane-title { display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.slot-count { font-size: 32px; font-weight: 600; margin: 8px 0; }
.slot-count > span { font-size: 16px; color: var(--muted); font-weight: 400; }
.lane-metrics { display: grid; grid-template-columns: minmax(0, 1fr); gap: 12px; margin-top: 12px; }
.slot-summary { display: flex; align-items: baseline; flex-wrap: wrap; gap: 4px 14px; }
.slot-summary .slot-count { margin: 0; }
.slot-summary .decision-note { margin-top: 0; }
.daily-quota { min-width: 0; }
.quota-heading { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 4px 10px; font-size: 12px; color: var(--muted); }
.quota-count { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; font-size: 13px; font-variant-numeric: tabular-nums; margin: 6px 0 10px; white-space: nowrap; }
.quota-count > span { display: inline-flex; align-items: baseline; gap: 5px; }
.quota-count > span::before { content: ""; display: inline-block; flex: none; width: 8px; height: 8px; background: currentColor; border-radius: 1px; }
.quota-count strong { font-size: 16px; font-weight: 600; }
.quota-count .quota-submitted { color: var(--green); }
.quota-count .quota-pending { color: var(--blue); }
.quota-count .quota-target { color: var(--muted); }
.quota-count .quota-target::before { width: 2px; height: 11px; background: var(--text); }
.quota-count .quota-target strong { color: var(--text); }
.quota-track { position: relative; display: flex; height: 10px; background: var(--line); }
.quota-segment { display: block; flex: none; height: 100%; }
.quota-segment.quota-submitted { background: var(--green); }
.quota-segment.quota-pending { background: var(--blue); }
.quota-target-marker { position: absolute; top: -3px; bottom: -3px; width: 2px; transform: translateX(-100%); background: var(--text); }
.quota-track.is-stale .quota-segment { opacity: .55; }
.quota-reset { margin-left: auto; color: var(--muted); font-size: 12px; }
.decision-note { font-size: 13px; margin-top: 7px; overflow-wrap: anywhere; }
.daily-funnel { color: var(--muted); font-size: 13px; padding-bottom: 14px; border-bottom: 1px solid var(--line); overflow-wrap: anywhere; line-height: 1.7; }
.validation-totals { display: grid; grid-template-columns: minmax(0, 1.6fr) repeat(4, minmax(0, 1fr)); gap: 12px; margin: 14px 0 8px; }
.validation-totals span { display: block; font-size: 13px; color: var(--muted); }
.validation-totals strong { display: block; font-size: 24px; font-weight: 600; margin-top: 5px; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
.validation-heading { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-top: 14px; }
.validation-funnel { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 16px; margin: 14px 0; }
.validation-funnel span { display: block; font-size: 13px; color: var(--muted); }
.validation-funnel strong { display: block; font-size: 26px; margin-top: 5px; font-weight: 600; }
.plan-choices { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
.plan-choice { display: grid; gap: 5px; margin-top: 14px; font-size: 13px; }
.plan-choice strong { font-size: 22px; font-weight: 600; }
.plan-choice small { font-size: 12px; overflow-wrap: anywhere; }
@media (max-width: 760px) {
  .capacity-lanes { grid-template-columns: 1fr; gap: 18px; }
  .capacity-lane + .capacity-lane { border-left: 0; border-top: 1px solid var(--line); padding: 18px 0 0; }
}
@media (max-width: 700px) {
  .overview-cards, .inventory-stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .overview-heading { flex-wrap: wrap; }
  .plan-choices { grid-template-columns: 1fr; gap: 18px; }
  .decision-panel { padding: 16px; }
  .validation-funnel { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 9px; }
  .validation-totals { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}
@media (max-width: 420px) {
  .slot-count { font-size: 28px; }
  .quota-count { font-size: 12px; }
  .quota-count strong { font-size: 14px; }
  .quota-reset { margin-left: 0; }
}
.plan-income-legend { display: flex; flex-wrap: wrap; gap: 10px 20px; font-size: 13px; color: var(--muted); }
.plan-income-legend span { display: inline-flex; align-items: center; gap: 6px; }
.plan-income-legend i { display: inline-block; width: 11px; height: 11px; background: var(--blue); }
.plan-income-legend .super { background: var(--green); }
.plan-income-legend .submissions { width: 18px; height: 2px; background: var(--muted); }
