:root {
  color-scheme: light;
  --ink: #1c2430;
  --muted: #5c6b7a;
  --line: #d5dde6;
  --paper: #f4f7f5;
  --card: #fff;
  --accent: #0b6e4f;
  --accent-soft: #e7f2ec;
  --danger: #9d2c2c;
  --shadow: 0 1px 2px rgba(16, 38, 28, .05), 0 10px 28px rgba(16, 38, 28, .06);
  --radius: 14px;
  --space: 8px;
  --font: "Noto Sans SC", "PingFang SC", "Microsoft YaHei", sans-serif;
}
* { box-sizing: border-box; }
/* Chrome leaves the hidden attribute on SVG as display:inline. The icon
   sprite then keeps the default 300×150 box and pushes the shell down. */
svg[hidden] { display: none !important; }
body {
  margin: 0;
  font: 16px/1.55 var(--font);
  color: var(--ink);
  background: var(--paper);
}
a { color: var(--accent); }
h1, h2, h3 { letter-spacing: -0.01em; }
h1 { font-size: 1.6rem; margin: 0 0 8px; }
h2 { font-size: 1.15rem; }
.shell { display: flex; min-height: 100vh; align-items: stretch; }
.side {
  width: 240px;
  flex: none;
  background: #10261c;
  color: #e7f2ec;
  padding: 18px 12px 28px;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow: auto;
}
.side .brand { color: #fff; display: block; padding: 4px 10px 16px; text-decoration: none; font-size: 1.05rem; }
.side nav { display: flex; flex-direction: column; gap: 2px; }
.nav-label {
  margin: 16px 10px 6px;
  font-size: 12px;
  letter-spacing: .04em;
  color: #9fb5a8;
}
.side nav a {
  color: #e7f2ec;
  text-decoration: none;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  border-radius: 10px;
}
.side nav a:hover, .side nav a.active { background: rgba(255, 255, 255, .1); }
.workspace { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.guest .shell { display: block; }
.guest .workspace { min-height: 100vh; }
header.top {
  display: flex;
  justify-content: flex-end;
  gap: 16px;
  align-items: center;
  padding: 10px 20px;
  background: rgba(255, 255, 255, .92);
  color: var(--ink);
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: 0;
  z-index: 4;
}
header.top a { color: var(--ink); text-decoration: none; }
.brand { font-weight: 700; }
header.top nav { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; justify-content: flex-end; }
header.top form { margin: 0; }
.button, button, header.top button {
  font: inherit;
  border: 1px solid var(--line);
  background: var(--card);
  color: var(--ink);
  border-radius: 10px;
  padding: 8px 14px;
  cursor: pointer;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
}
button.primary, .button.primary, button[type="submit"]:not(.secondary):not(.danger):not(.ghost) {
  background: var(--accent);
  color: #fff;
  border-color: transparent;
}
button.secondary, .button.secondary, button.ghost, header.top button {
  background: transparent;
  color: var(--ink);
  border-color: var(--line);
}
button.danger, button.danger[type="submit"] {
  background: #fff;
  color: var(--danger);
  border-color: #e7c4c4;
}
.guest header.top { justify-content: space-between; background: #10261c; color: #fff; }
.guest header.top a, .guest header.top .brand { color: #fff; }
.guest main { max-width: 460px; }
main { width: min(1120px, 100%); margin: 0 auto; padding: 24px 20px 48px; min-width: 0; }
.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 18px 20px;
  margin-bottom: 16px;
  box-shadow: var(--shadow);
  min-width: 0;
}
.ico { width: 18px; height: 18px; flex: none; }
.next-step {
  margin: 12px 0 4px;
  padding: 14px 16px;
  border-radius: 12px;
  background: var(--accent-soft);
  border: 1px solid #b7d7c8;
  position: sticky;
  top: 58px;
  z-index: 3;
}
.next-step p { margin: 0 0 6px; }
.next-step form { margin: 8px 0 0; }
.todo-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.todo-list li {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 12px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #fff;
}
.todo-list li span { flex: 1; min-width: 12rem; }
.empty {
  margin: 8px 0;
  padding: 22px 12px;
  text-align: center;
  color: var(--muted);
  border: 1px dashed var(--line);
  border-radius: 12px;
  background: #f8fbf9;
}
.narrow { max-width: 460px; }
.row { display: flex; justify-content: space-between; align-items: center; gap: 12px; }
label { display: block; margin: 10px 0; }
input, textarea, select {
  display: block;
  width: 100%;
  margin-top: 4px;
  font: inherit;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fff;
  color: var(--ink);
}
table { width: 100%; border-collapse: separate; border-spacing: 0; }
th, td { text-align: left; padding: 10px 8px; border-bottom: 1px solid var(--line); vertical-align: top; }
thead th { position: sticky; top: 0; background: #f8fbf9; z-index: 1; font-size: 13px; }
tbody tr:nth-child(even) { background: #f7faf8; }
tbody tr:hover { background: #eef6f2; }
caption { caption-side: top; text-align: left; font-weight: 600; padding: 0 0 6px; }
.sheet { overflow: auto; max-height: 28rem; max-width: 100%; min-width: 0; border: 1px solid var(--line); border-radius: 12px; }
pre {
  max-width: 100%;
  overflow-x: auto;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}
table:focus { outline: 2px solid var(--accent); outline-offset: 2px; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
button[aria-busy="true"] { cursor: progress; }
.hint, .who { color: var(--muted); }
.error { color: var(--danger); }
button.danger { color: var(--danger); }
.drop {
  border: 2px dashed #b7d7c8;
  border-radius: 14px;
  padding: 28px;
  text-align: center;
  background: #f3faf6;
}
.drop.over { border-color: var(--accent); background: #e5f6ee; }
.drop .folder { display: inline-block; margin-top: 8px; cursor: pointer; }
#upload-overall { margin-top: 12px; }
.bar { height: 8px; background: var(--line); border-radius: 99px; overflow: hidden; margin-top: 4px; }
.bar span { display: block; height: 100%; background: var(--accent); width: 0; }
svg.trend { width: 240px; height: 48px; color: var(--accent); display: block; }
pre.inventory {
  white-space: pre-wrap;
  word-break: break-word;
  background: #0f1720;
  color: #e8eef5;
  padding: 12px;
  border-radius: 8px;
  max-height: 480px;
  overflow: auto;
}
.phase { font-size: 14px; color: var(--muted); }
.timeline { list-style: none; margin: 0; padding: 0; }
.timeline > li { border-left: 3px solid var(--accent); padding: 8px 12px; margin: 12px 0; }
.timeline > li.stale { border-left-color: #b58105; background: #fff8e8; }
.timeline > li.violation { border-left-color: #a33; background: #fdecec; }
.rule-off { opacity: 0.55; }
.check.pass { color: var(--muted); }
.check.skipped { color: var(--muted); }
.timeline header { display: flex; flex-wrap: wrap; gap: 8px; align-items: baseline; }
.actions, .progress { list-style: none; display: flex; flex-wrap: wrap; gap: 16px; margin: 0; padding: 0; }
.progress li { flex: 1 1 140px; display: flex; flex-direction: column; align-items: flex-start; gap: 6px; min-width: 140px; border-top: 4px solid var(--line); padding-top: 8px; }
.progress li[data-status="done"], .progress li[data-status="running"] { border-top-color: var(--accent); }
.progress li[data-status="queued"] { border-top-color: #f0c14a; }
.progress li[data-status="failed"] { border-top-color: var(--danger); }
.progress form { margin: 0; }
.progress time, .progress .detail { color: var(--muted); font-size: 14px; }
.step-no { display: inline-block; width: 1.4em; height: 1.4em; margin-right: 4px; border-radius: 99px; background: #e7f2ec; text-align: center; font-size: 13px; }
.below-floor { background: #f6d6d6; border-radius: 8px; padding: 8px; }
.actions li { display: flex; flex-direction: column; align-items: flex-start; gap: 6px; min-width: 180px; }
.actions form { margin: 0; }
.actions time, .actions .detail { color: var(--muted); font-size: 14px; }
.tag { display: inline-block; font-size: 12px; padding: 1px 6px; border-radius: 99px; background: #e7f2ec; }
.tag.status-queued { background: #e7eef6; }
.tag.status-running { background: #f6e3b0; }
.tag.status-done { background: #e7f2ec; }
.tag.status-failed { background: #f6d6d6; }
.tag.status-idle { background: #eef1f4; }
button:disabled { opacity: 0.45; cursor: not-allowed; }
.bell { position: relative; }
.bell .count { display: inline-block; min-width: 1.2em; margin-left: 4px; padding: 0 6px; border-radius: 99px; background: #f0c14a; color: #1c2430; font-size: 12px; text-align: center; }
.kpis, .split { display: flex; flex-wrap: wrap; gap: 12px; }
.kpis > div, .kpis > a.kpi, .split > div { flex: 1 1 160px; border: 1px solid var(--line); border-radius: 12px; padding: 12px 14px; background: #f3faf6; box-shadow: var(--shadow); }
.kpis > a.kpi { color: inherit; text-decoration: none; }
.kpis strong { display: block; font-size: 22px; }
form.finder input { width: 9rem; color: var(--ink); background: #fff; }
progress { width: 5rem; height: 0.7rem; vertical-align: middle; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.chips a { border: 1px solid var(--line); border-radius: 99px; padding: 6px 12px; background: #fff; text-decoration: none; }
.tree, .tree ul { list-style: none; padding-left: 16px; }
.tree details > summary { cursor: pointer; list-style: none; }
.tree details > summary::-webkit-details-marker { display: none; }
.tree details > summary::before { content: "+"; display: inline-block; width: 1.2em; font-weight: 700; }
.tree details[open] > summary::before { content: "−"; }
.chips a.active { background: #e7f2ec; }
.preview-image { max-width: 100%; }
.preview-frame { width: 100%; height: 480px; border: 1px solid var(--line); border-radius: 8px; }
.issues { list-style: none; padding: 0; }
.issues li { border-top: 1px solid var(--line); padding: 10px 0; }
.issues form { display: inline-flex; gap: 8px; align-items: center; margin: 4px 12px 0 0; }
.gap { font-weight: 600; }
.facts { width: 100%; margin: 8px 0 16px; }
.process { margin-top: 18px; }
.process h3 { margin-bottom: 8px; }
.sev-red { color: var(--danger); }
.tag.sev-yellow, .sev-yellow > p:first-child { color: #8a5a00; }
.tag.sev-green, .sev-green > p:first-child { color: var(--accent); }
.overdue { color: var(--danger); font-weight: 600; }
.tag.sev-red { background: #f6d6d6; }
.tag.sev-yellow { background: #f6e3b0; }
.tag.sev-green { background: #e7f2ec; }
.tag.eye { background: #f6e3b0; color: #8a5a00; }
.tag.sure { background: #e7f2ec; }
.min-price, tr.min-price, td.min-price { background: #e5f6ee; }
.actions-inline { display: flex; gap: 8px; align-items: center; }
.actions-inline form { margin: 0; }
.chart-box { position: relative; height: 260px; max-width: none; margin: 8px 0 16px; }
.chart-box.tall { height: 280px; }
canvas.chart { width: 100%; height: 100%; background: #fff; border: 1px solid var(--line); border-radius: 12px; }
.file-tabs > .tabs { margin-bottom: 0; }
.file-tabs > .tabs a { text-decoration: none; border: 1px solid var(--line); border-radius: 8px 8px 0 0; padding: 6px 12px; background: #fff; }
.file-tabs:not(:has(#deliverables:target)) > .tabs a[href="#inventory"],
.file-tabs:has(#deliverables:target) > .tabs a[href="#deliverables"] { background: #e7f2ec; }
.file-tabs > .tab-panel { display: none; }
.file-tabs:not(:has(#deliverables:target)) > #inventory,
.file-tabs > #deliverables:target { display: block; }
.tag.warn { background: #f6e3b0; }
.pair { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.item { border-top: 1px solid var(--line); margin-top: 8px; padding-top: 8px; }
.calcs { margin: 4px 0; }
.check { display: flex; align-items: center; gap: 8px; }
.check input { width: auto; }
.guide { background: transparent; border: none; border-left: 3px solid var(--accent); border-radius: 0; padding: 2px 14px; margin: 0 0 16px; }
.guide h2 { font-size: 1rem; margin: 0 0 6px; }
.guide p { margin: 4px 0; }
html[data-theme="dark"] {
  color-scheme: dark;
  --ink: #e8eef5;
  --muted: #a8b3c0;
  --line: #2c3a44;
  --paper: #10161c;
  --card: #182028;
  --accent: #3dbe8c;
  --accent-soft: #16352a;
  --danger: #f0a8a8;
  --shadow: 0 10px 28px rgba(0, 0, 0, .35);
}
html[data-theme="dark"] .side { background: #0c1210; }
html[data-theme="dark"] header.top { background: rgba(16, 22, 28, .94); }
html[data-theme="dark"] header.top a,
html[data-theme="dark"] header.top button,
html[data-theme="dark"] .who { color: var(--ink); }
html[data-theme="dark"] thead th,
html[data-theme="dark"] .empty,
html[data-theme="dark"] .todo-list li,
html[data-theme="dark"] canvas.chart,
html[data-theme="dark"] input,
html[data-theme="dark"] textarea,
html[data-theme="dark"] select { background: #121a20; color: var(--ink); }
html[data-theme="dark"] tbody tr:nth-child(even) { background: #1c262e; }
html[data-theme="dark"] tbody tr:hover { background: #243038; }
html[data-theme="dark"] .kpis > div,
html[data-theme="dark"] .kpis > a.kpi,
html[data-theme="dark"] .split > div,
html[data-theme="dark"] .drop,
html[data-theme="dark"] .chips a,
html[data-theme="dark"] .file-tabs > .tabs a,
html[data-theme="dark"] button.danger,
html[data-theme="dark"] button.danger[type="submit"] { background: #121a20; color: var(--ink); }
html[data-theme="dark"] .chips a.active,
html[data-theme="dark"] .step-no,
html[data-theme="dark"] .file-tabs:not(:has(#deliverables:target)) > .tabs a[href="#inventory"],
html[data-theme="dark"] .file-tabs:has(#deliverables:target) > .tabs a[href="#deliverables"] { background: #1e3a2e; color: var(--ink); }
html[data-theme="dark"] .min-price,
html[data-theme="dark"] tr.min-price,
html[data-theme="dark"] td.min-price,
html[data-theme="dark"] .tag.min-price { background: #16352a; color: var(--ink); }
html[data-theme="dark"] .tag.eye { background: #3a3014; color: #f6e3b0; }
html[data-theme="dark"] .tag.sure { background: #16352a; color: var(--ink); }
html[data-theme="dark"] .next-step { border-color: #245c45; }
html[data-theme="dark"] .timeline > li.stale { background: #2a2414; }
html[data-theme="dark"] .timeline > li.violation,
html[data-theme="dark"] .below-floor { background: #3a1c1c; }
html[data-theme="dark"] button.danger,
html[data-theme="dark"] button.danger[type="submit"] { color: var(--danger); }
form.filters {
  display: flex;
  flex-wrap: wrap;
  gap: 12px 16px;
  align-items: flex-end;
  margin: 8px 0 16px;
}
form.filters label { margin: 0; flex: 1 1 180px; }
form.filters button { margin-bottom: 1px; }
td > input, td > select { width: 100%; max-width: 9rem; }
td textarea { width: 100%; max-width: none; min-width: 12rem; }
form.filters label.check { flex: 0 1 auto; }
form.filters a.button, form.filters .button { margin-bottom: 1px; }
form.sticky-save > button[type="submit"] { position: sticky; bottom: 12px; z-index: 2; box-shadow: var(--shadow); }
article + article { border-top: 1px solid var(--line); margin-top: 16px; padding-top: 12px; }
.card li > form { display: inline-flex; margin: 4px 8px 4px 0; }
#closeout li { display: flex; flex-wrap: wrap; gap: 8px 12px; align-items: center; padding: 8px 0; border-bottom: 1px solid var(--line); }
#closeout li form { margin: 0; }
details.fold { margin-top: 14px; }
details.fold > summary { cursor: pointer; font-weight: 600; }
details.fold[open] > summary { margin-bottom: 8px; }
.progress li[data-status="queued"] .tag,
.progress li[data-status="running"] .tag { animation: pulse 1.4s ease-in-out infinite; }
@keyframes pulse { 50% { opacity: .55; } }
@media (max-width: 640px) {
  header.top { flex-direction: column; align-items: flex-start; }
  header.top nav { width: 100%; }
  .row { flex-direction: column; align-items: flex-start; }
  .pair { grid-template-columns: 1fr; }
  .shell { display: block; }
  .side { position: static; width: auto; height: auto; }
  .side nav { flex-direction: row; flex-wrap: wrap; }
  .nav-label { width: 100%; }
  main { padding: 16px 12px 32px; }
  .kpis > div, .kpis > a.kpi, .split > div { flex-basis: 100%; }
  #todos li, #alerts, #brief, #dash-clients { overflow-wrap: anywhere; }
  #dash-filters label, #dash-filters input, form.finder input { display: block; width: 100%; }
  .chart-box { height: 180px; max-width: 100%; }
}
