:root {
  --bg: #f3f6f4;
  --surface: #ffffff;
  --surface-alt: #f8faf8;
  --text: #16201b;
  --muted: #647069;
  --line: #d8e1dc;
  --primary: #176f5d;
  --accent: #2f5e9e;
  --warn: #a85812;
  --danger: #b3261e;
  --ready-bg: #e8f5f0;
  --warn-bg: #fff2dc;
  --danger-bg: #fff0ee;
  --empty-bg: #edf1ef;
  --shadow: 0 16px 34px rgba(32, 42, 36, .08);
}

* { box-sizing: border-box; }
html { color: var(--text); background: var(--bg); }
body { margin: 0; font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif; font-size: 16px; line-height: 1.5; }
main { width: min(1440px, calc(100% - 32px)); margin: 0 auto; padding: 28px 0 44px; }
.topbar { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; margin-bottom: 18px; }
.top-actions { display: flex; align-items: center; gap: 10px; }
h1 { margin: 0; font-size: 3rem; line-height: 1.02; letter-spacing: 0; }
h2 { margin: 0; font-size: 1rem; line-height: 1.2; }
p { margin: 6px 0 0; color: var(--muted); }
a { color: var(--accent); }
button { min-height: 44px; padding: 0 16px; border: 1px solid var(--primary); border-radius: 8px; background: var(--primary); color: #fff; font-weight: 800; cursor: pointer; }
button:focus-visible, a:focus-visible { outline: 3px solid rgba(23, 111, 93, .28); outline-offset: 2px; }
.eyebrow { margin: 0 0 6px; color: var(--primary); font-weight: 850; text-transform: uppercase; font-size: .8rem; }
.metric-grid { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 10px; margin-bottom: 14px; }
.metric-card, .panel { background: var(--surface); border: 1px solid var(--line); border-radius: 8px; box-shadow: var(--shadow); }
.metric-card { padding: 14px; min-height: 94px; }
.metric-card > span:first-child { display: block; font-size: 1.8rem; line-height: 1; font-weight: 900; overflow-wrap: anywhere; }
.metric-card.danger { background: var(--danger-bg); border-color: #efb4ad; }
.metric-label { display: block; margin-top: 8px; color: var(--muted); }
.status-line { min-height: 24px; color: var(--muted); font-size: .95rem; margin-bottom: 14px; }
.status-line.error { color: var(--danger); }
.action-panel { display: flex; align-items: center; justify-content: space-between; gap: 14px; margin: 14px 0; padding: 16px; background: #fff8e8; border: 1px solid #e5bd73; border-radius: 8px; box-shadow: var(--shadow); }
.action-panel h2 { font-size: 1.35rem; }
.action-meta { display: flex; align-items: center; justify-content: flex-end; gap: 8px; flex-wrap: wrap; }
.command-pill { display: inline-flex; align-items: center; max-width: 520px; min-height: 28px; padding: 3px 10px; border-radius: 8px; background: var(--surface); border: 1px solid var(--line); color: var(--text); font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace; font-size: .82rem; overflow-wrap: anywhere; }
.command-pill.full { display: flex; max-width: none; margin-top: 8px; }
.packet-copy { max-height: 220px; overflow: auto; white-space: pre-wrap; margin: 10px 0 0; padding: 12px; border-radius: 8px; background: var(--surface-alt); border: 1px solid var(--line); color: var(--text); font: inherit; font-size: .92rem; }
.dashboard-grid { display: grid; grid-template-columns: minmax(0, 1.7fr) minmax(320px, .9fr); gap: 14px; margin-top: 14px; }
.dashboard-grid.compact { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.panel { padding: 16px; margin-top: 14px; }
.dashboard-grid .panel { margin-top: 0; }
.panel-large { min-height: 286px; }
.panel-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; margin-bottom: 12px; }
.meta-pill { display: inline-flex; align-items: center; min-height: 28px; padding: 0 10px; border-radius: 999px; background: var(--surface-alt); border: 1px solid var(--line); color: var(--muted); font-size: .82rem; font-weight: 800; white-space: nowrap; }
.stage-list, .plain-list, .draft-list, .packet-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; }
.stage-list { grid-template-columns: repeat(7, minmax(0, 1fr)); }
.stage { min-height: 148px; border: 1px solid var(--line); border-radius: 8px; padding: 12px; background: var(--empty-bg); display: grid; align-content: space-between; gap: 12px; }
.stage.ready { background: var(--ready-bg); border-color: #b8d8cf; }
.stage.blocked { background: var(--danger-bg); border-color: #efb4ad; }
.stage-top { display: flex; justify-content: space-between; gap: 8px; }
.stage-id { font-weight: 900; color: var(--primary); }
.stage-count { font-size: 1.45rem; line-height: 1; font-weight: 900; }
.stage-label, .item-title { font-weight: 850; }
.stage-detail, .stage-time, .list-detail, .preview { color: var(--muted); font-size: .9rem; }
.plain-list li, .draft-list li, .packet-list li { border-top: 1px solid var(--line); padding-top: 10px; }
.plain-list li:first-child, .draft-list li:first-child, .packet-list li:first-child { border-top: 0; padding-top: 0; }
.badge { display: inline-flex; align-items: center; min-height: 24px; color: #fff; background: var(--accent); padding: 2px 8px; border-radius: 999px; font-size: .78rem; font-weight: 800; }
.badge.warn { background: var(--warn); }
.badge.danger { background: var(--danger); }
.badge.ready { background: var(--primary); }
.muted { color: var(--muted); }
.bar-list { display: grid; gap: 9px; margin-top: 12px; }
.bar-row { display: grid; grid-template-columns: minmax(84px, 1fr) minmax(110px, 1.3fr) 42px; align-items: center; gap: 8px; min-height: 28px; }
.bar-name { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--text); font-weight: 750; }
.bar-track { height: 9px; background: #e3ebe7; border-radius: 999px; overflow: hidden; }
.bar-fill { height: 100%; width: 0; background: var(--primary); border-radius: inherit; }
.bar-count { color: var(--muted); font-size: .88rem; text-align: right; font-weight: 800; }
.draft-meta { display: flex; gap: 8px; flex-wrap: wrap; margin: 6px 0; }
.preview { margin-top: 6px; max-height: 4.3em; overflow: hidden; }
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; min-width: 840px; }
th, td { padding: 11px 8px; border-top: 1px solid var(--line); text-align: left; vertical-align: top; }
th { color: var(--muted); font-size: .85rem; }

@media (max-width: 1180px) {
  .metric-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .dashboard-grid, .dashboard-grid.compact { grid-template-columns: 1fr 1fr; }
  .stage-list { grid-template-columns: repeat(4, minmax(0, 1fr)); }
}

@media (max-width: 760px) {
  main { width: min(100% - 20px, 720px); padding-top: 18px; }
  .topbar, .panel-heading, .action-panel { display: block; }
  .top-actions { margin-top: 14px; }
  .action-meta { justify-content: flex-start; margin-top: 12px; }
  button { width: 100%; }
  .metric-grid, .dashboard-grid, .dashboard-grid.compact, .stage-list { grid-template-columns: 1fr; }
  h1 { font-size: 1.7rem; }
  .table-wrap { overflow-x: visible; }
  table { min-width: 0; }
  thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
  tbody, tr, td { display: block; }
  tr { border-top: 1px solid var(--line); padding: 10px 0; }
  td { display: grid; grid-template-columns: 82px minmax(0, 1fr); gap: 8px; border-top: 0; padding: 4px 0; }
  td::before { content: attr(data-label); color: var(--muted); font-weight: 800; }
}
