:root {
  --bg: #F2F4F1;
  --surface: #FFFFFF;
  --sunk: #F7F8F6;
  --ink: #17211E;
  --ink-2: #3A4743;
  --muted: #68746F;
  --line: #DCE1DC;
  --line-2: #E9ECE8;
  --side: #12201B;
  --side-ink: #C9D6D0;
  --accent: #0F6E5C;
  --accent-ink: #FFFFFF;
  --accent-soft: #E1F0EC;
  /* status */
  --s-queued: #8A948F;
  --s-running: #2D6BD8;
  --s-submitted: #0E8C8C;
  --s-confirmed: #5B55C9;
  --s-live: #23883F;
  --s-human: #B7790E;
  --s-failed: #C2412D;
  --s-skipped: #A9B0AC;
  --radius-s: 6px;
  --radius: 10px;
  --shadow: 0 1px 0 rgba(23, 33, 30, .04), 0 8px 24px -16px rgba(23, 33, 30, .25);
  --font: 'Onest', system-ui, -apple-system, Segoe UI, sans-serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { font: 14px/1.5 var(--font); color: var(--ink); background: var(--bg); font-feature-settings: 'tnum' 1, 'cv11' 1; -webkit-font-smoothing: antialiased; }
[hidden] { display: none !important; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3 { margin: 0; letter-spacing: -.01em; }
h1 { font-size: 24px; font-weight: 650; line-height: 1.2; }
h2 { font-size: 16px; font-weight: 600; }
h3 { font-size: 14px; font-weight: 600; }
.muted { color: var(--muted); }
.small { font-size: 12.5px; }
.num { font-variant-numeric: tabular-nums; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 4px; }
code, .mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12.5px; }

/* ---------- shell ---------- */
.shell { display: grid; grid-template-columns: 232px 1fr; min-height: 100vh; }
.side { background: var(--side); color: var(--side-ink); display: flex; flex-direction: column; padding: 18px 12px; position: sticky; top: 0; height: 100vh; }
.brand { display: flex; align-items: center; gap: 10px; color: #fff; font-size: 15.5px; padding: 4px 10px 22px; }
.brand b { font-weight: 650; }
.brand-dark { color: var(--ink); padding: 0 0 26px; }
.logo { width: 26px; height: 26px; border-radius: 7px; background: var(--accent); position: relative; flex: none; }
.logo::before, .logo::after { content: ''; position: absolute; width: 11px; height: 7px; border: 2.2px solid #fff; border-radius: 5px; top: 9px; }
.logo::before { left: 4px; transform: rotate(-35deg); }
.logo::after { right: 4px; transform: rotate(-35deg); }
nav { display: flex; flex-direction: column; gap: 2px; }
nav a { display: flex; align-items: center; gap: 11px; padding: 8px 10px; border-radius: 7px; color: var(--side-ink); font-weight: 500; }
nav a:hover { background: rgba(255, 255, 255, .06); text-decoration: none; color: #fff; }
nav a.on { background: rgba(255, 255, 255, .1); color: #fff; }
nav i { width: 18px; height: 18px; display: inline-flex; opacity: .85; }
nav .pill { margin-left: auto; background: var(--s-human); color: #fff; font-size: 11.5px; font-weight: 600; padding: 0 7px; border-radius: 9px; line-height: 18px; }
nav .pill:empty { display: none; }
.side-foot { margin-top: auto; display: flex; flex-direction: column; gap: 10px; padding: 0 10px; }
.worker { font-size: 12.5px; line-height: 1.4; padding: 10px; border-radius: 8px; background: rgba(255, 255, 255, .05); }
.worker .dot { display: inline-block; width: 7px; height: 7px; border-radius: 50%; margin-right: 6px; vertical-align: 1px; background: var(--s-queued); }
.worker .dot.go { background: #4CC37A; box-shadow: 0 0 0 3px rgba(76, 195, 122, .18); }
.worker .dot.busy { background: #6FA3FF; animation: pulse 1.4s ease-in-out infinite; }
@keyframes pulse { 50% { box-shadow: 0 0 0 5px rgba(111, 163, 255, .2); } }
@media (prefers-reduced-motion: reduce) { .worker .dot.busy { animation: none; } }
.link-btn { background: none; border: 0; color: var(--side-ink); text-align: left; padding: 0; cursor: pointer; font: inherit; font-size: 12.5px; opacity: .8; }
.link-btn:hover { opacity: 1; text-decoration: underline; }
main { padding: 28px 36px 60px; min-width: 0; outline: none; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 22px; flex-wrap: wrap; }
.page-head p { margin: 4px 0 0; color: var(--muted); max-width: 70ch; }
.actions select { width: auto; min-width: 180px; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }

/* ---------- surfaces ---------- */
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
.panel-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 14px 18px; border-bottom: 1px solid var(--line-2); }
.panel-body { padding: 16px 18px; }
.grid { display: grid; gap: 18px; }
.g-2 { grid-template-columns: minmax(0, 1.7fr) minmax(0, 1fr); }
.g-half { grid-template-columns: 1fr 1fr; }
@media (max-width: 1100px) { .g-2, .g-half { grid-template-columns: 1fr; } }

/* ---------- pipeline (the signature element) ---------- */
.pipeline { padding: 20px 22px 22px; margin-bottom: 18px; }
.pipe-top { display: flex; justify-content: space-between; align-items: baseline; gap: 20px; flex-wrap: wrap; margin-bottom: 18px; }
.pipe-total { font-size: 15px; color: var(--muted); }
.pipe-total b { font-size: 34px; color: var(--ink); font-weight: 650; letter-spacing: -.02em; margin-right: 8px; }
.pipe-strip { display: flex; height: 14px; border-radius: 7px; overflow: hidden; background: var(--line-2); gap: 2px; }
.pipe-strip span { display: block; min-width: 3px; transition: flex-grow .6s ease; }
@media (prefers-reduced-motion: reduce) { .pipe-strip span { transition: none; } }
.pipe-stages { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); margin-top: 16px; }
.stage { padding: 2px 14px 0; border-left: 1px solid var(--line-2); }
.stage:first-child { border-left: 0; padding-left: 0; }
.stage a { color: inherit; }
.stage .v { font-size: 22px; font-weight: 600; letter-spacing: -.01em; }
.stage .l { display: flex; align-items: center; gap: 7px; color: var(--muted); font-size: 12.5px; }
.stage .sw { width: 9px; height: 9px; border-radius: 3px; }
.stage .arrow { color: var(--line); margin-left: auto; }
@media (max-width: 900px) { .pipe-stages { grid-template-columns: repeat(3, 1fr); row-gap: 14px; } .stage:nth-child(4) { border-left: 0; padding-left: 0; } }

.facts { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 0; }
.fact { padding: 14px 18px; border-left: 1px solid var(--line-2); }
.fact:first-child { border-left: 0; }
.fact .v { font-size: 19px; font-weight: 600; }
.fact .l { font-size: 12.5px; color: var(--muted); }
@media (max-width: 900px) { .facts { grid-template-columns: repeat(2, 1fr); } .fact:nth-child(3) { border-left: 0; } }

/* chart */
.chart { width: 100%; height: 190px; display: block; }
.chart .grid-l { stroke: var(--line-2); }
.chart text { fill: var(--muted); font-size: 10.5px; font-family: var(--font); }
.legend { display: flex; gap: 16px; font-size: 12.5px; color: var(--muted); }
.legend i { display: inline-block; width: 9px; height: 9px; border-radius: 3px; margin-right: 6px; vertical-align: -1px; }

/* setup checklist */
.setup li { display: flex; gap: 12px; padding: 11px 0; border-top: 1px solid var(--line-2); align-items: flex-start; }
.setup li:first-child { border-top: 0; padding-top: 2px; }
.setup ul { list-style: none; margin: 0; padding: 0; }
.tick { width: 20px; height: 20px; border-radius: 50%; border: 1.5px solid var(--line); flex: none; margin-top: 1px; display: grid; place-items: center; }
.tick.ok { background: var(--accent); border-color: var(--accent); }
.tick.ok::after { content: ''; width: 8px; height: 4px; border: 2px solid #fff; border-top: 0; border-right: 0; transform: rotate(-45deg) translate(1px, -1px); }

/* ---------- tables ---------- */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th { text-align: left; font-weight: 500; font-size: 12.5px; color: var(--muted); padding: 10px 14px; border-bottom: 1px solid var(--line); background: var(--sunk); white-space: nowrap; position: sticky; top: 0; }
td { padding: 11px 14px; border-bottom: 1px solid var(--line-2); vertical-align: middle; }
tr:last-child td { border-bottom: 0; }
tbody tr:hover td { background: #FAFBF9; }
td.r, th.r { text-align: right; }
.cell-main { font-weight: 550; color: var(--ink); }
.cell-sub { font-size: 12.5px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 340px; }
.ellipsis { max-width: 320px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.site-cell { display: flex; align-items: center; gap: 11px; min-width: 0; }
.fav { width: 28px; height: 28px; border-radius: 7px; background: var(--sunk) center/cover no-repeat; border: 1px solid var(--line-2); flex: none; display: grid; place-items: center; font-weight: 600; font-size: 12px; color: var(--muted); }
.bar { height: 6px; border-radius: 3px; background: var(--line-2); display: flex; overflow: hidden; min-width: 120px; }
.bar span { display: block; }
.empty { padding: 40px 20px; text-align: center; color: var(--muted); }
.empty h3 { color: var(--ink); margin-bottom: 6px; font-size: 15px; }
.empty .btn { margin-top: 14px; }

/* status tag */
.tag { display: inline-flex; align-items: center; gap: 6px; font-size: 12.5px; font-weight: 500; white-space: nowrap; color: var(--ink-2); }
.tag::before { content: ''; width: 8px; height: 8px; border-radius: 50%; background: var(--c, var(--s-queued)); }
.chip { display: inline-block; font-size: 12px; padding: 1px 8px; border-radius: 10px; background: var(--sunk); border: 1px solid var(--line-2); color: var(--ink-2); white-space: nowrap; }
.chip.warn { background: #FBF3E2; border-color: #F0DDB2; color: #7A5208; }
.chip.bad { background: #FBEAE6; border-color: #F1C9BF; color: #8E2C1C; }
.chip.good { background: var(--accent-soft); border-color: #C3E0D8; color: #0B5446; }
.dr { display: inline-block; min-width: 30px; text-align: center; font-weight: 600; font-size: 12.5px; padding: 1px 6px; border-radius: 5px; background: var(--sunk); }
.dr.hi { background: #DFF0E4; color: #18602E; }
.dr.mid { background: #EEF0E0; color: #59601A; }

/* ---------- controls ---------- */
.btn { display: inline-flex; align-items: center; gap: 7px; height: 34px; padding: 0 14px; border-radius: 8px; border: 1px solid var(--line); background: var(--surface); color: var(--ink); font: 500 13.5px var(--font); cursor: pointer; white-space: nowrap; text-decoration: none !important; }
.btn:hover { background: var(--sunk); border-color: #C9D0CA; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.primary:hover { background: #0C5D4E; }
.btn.danger { color: var(--s-failed); }
.btn.ghost { border-color: transparent; background: none; }
.btn.ghost:hover { background: var(--line-2); }
.btn.sm { height: 28px; padding: 0 10px; font-size: 12.5px; border-radius: 7px; }
.btn.wide { width: 100%; justify-content: center; height: 40px; }
.btn[disabled] { opacity: .55; cursor: default; }
.btn .spin { width: 13px; height: 13px; border: 2px solid currentColor; border-right-color: transparent; border-radius: 50%; animation: rot .7s linear infinite; }
@keyframes rot { to { transform: rotate(360deg); } }
input, select, textarea { font: inherit; line-height: 1.3; color: var(--ink); background: var(--surface); border: 1px solid var(--line); border-radius: 8px; padding: 7px 10px; height: 34px; width: 100%; }
select { padding: 0 28px 0 10px; }
input[type=checkbox], input[type=radio] { width: 16px; height: 16px; padding: 0; accent-color: var(--accent); }
textarea { height: auto; min-height: 84px; resize: vertical; line-height: 1.5; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
label { display: block; font-size: 12.5px; font-weight: 500; color: var(--ink-2); }
label > input, label > select, label > textarea { display: block; margin-top: 6px; }
label .hint { font-weight: 400; color: var(--muted); margin-left: 6px; }
.form-row { align-items: end; }
.check { display: flex; flex-direction: row; align-items: center; gap: 9px; font-size: 13.5px; font-weight: 400; color: var(--ink); cursor: pointer; }
.check input { width: 16px; height: 16px; margin: 0; accent-color: var(--accent); }
.form { display: grid; gap: 14px; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.form-error { color: var(--s-failed); font-size: 13px; margin: 0; min-height: 0; }
.filters { display: flex; gap: 8px; flex-wrap: wrap; padding: 12px 14px; border-bottom: 1px solid var(--line-2); align-items: center; }
.filters input, .filters select { width: auto; min-width: 150px; height: 32px; }
.filters input[type=search] { min-width: 240px; }
.filters .grow { flex: 1; }
.seg { display: inline-flex; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; background: var(--surface); }
.seg button { border: 0; background: none; padding: 0 12px; height: 32px; font: 500 13px var(--font); color: var(--muted); cursor: pointer; border-left: 1px solid var(--line-2); }
.seg button:first-child { border-left: 0; }
.seg button.on { background: var(--accent-soft); color: #0B5446; }
.pager { display: flex; justify-content: space-between; align-items: center; padding: 10px 14px; border-top: 1px solid var(--line-2); font-size: 12.5px; color: var(--muted); }
.cats { display: flex; flex-wrap: wrap; gap: 7px; }
.cat-opt { display: inline-flex; flex-direction: row; align-items: center; font-weight: 400; color: var(--ink); gap: 7px; padding: 5px 11px 5px 9px; border: 1px solid var(--line); border-radius: 18px; cursor: pointer; font-size: 13px; background: var(--surface); user-select: none; }
.cat-opt input { display: none; }
.cat-opt::before { content: ''; width: 12px; height: 12px; border-radius: 4px; border: 1.5px solid var(--line); }
.cat-opt.on { border-color: var(--accent); background: var(--accent-soft); }
.cat-opt.on::before { background: var(--accent); border-color: var(--accent); }
.cat-opt small { color: var(--muted); }

/* ---------- human queue (two-pane) ---------- */
.hq { display: grid; grid-template-columns: 360px minmax(0, 1fr); gap: 18px; align-items: start; }
@media (max-width: 1000px) { .hq { grid-template-columns: 1fr; } }
.hq-list { max-height: calc(100vh - 170px); overflow-y: auto; }
.hq-item { display: block; width: 100%; text-align: left; padding: 11px 16px; border: 0; border-bottom: 1px solid var(--line-2); background: none; font: inherit; color: inherit; cursor: pointer; border-left: 3px solid transparent; }
.hq-item:hover { background: var(--sunk); }
.hq-item.on { background: var(--accent-soft); border-left-color: var(--accent); }
.hq-item .row1 { display: flex; justify-content: space-between; gap: 10px; align-items: center; }
.hq-detail { position: sticky; top: 20px; }
.copy-field { display: grid; grid-template-columns: 120px minmax(0, 1fr) auto; gap: 12px; padding: 10px 0; border-top: 1px solid var(--line-2); align-items: start; }
.copy-field:first-child { border-top: 0; }
.copy-field .k { font-size: 12.5px; color: var(--muted); padding-top: 3px; }
.copy-field .v { white-space: pre-wrap; word-break: break-word; }
.copy-btn { height: 26px; font-size: 12px; padding: 0 9px; }
.copy-btn.done { color: var(--accent); border-color: var(--accent); }
.reason { padding: 10px 14px; border-radius: 8px; background: #FBF3E2; color: #6B4807; font-size: 13px; margin-bottom: 14px; }
.kbd { display: inline-block; font-size: 11px; border: 1px solid var(--line); border-bottom-width: 2px; border-radius: 4px; padding: 0 5px; color: var(--muted); background: var(--surface); }
.proof { display: block; max-width: 100%; border: 1px solid var(--line); border-radius: 8px; margin-top: 8px; }
.thumb { width: 54px; height: 34px; object-fit: cover; object-position: top; border-radius: 4px; border: 1px solid var(--line); cursor: zoom-in; display: block; }

/* ---------- drawer / modal / toast ---------- */
.drawer, .modal { position: fixed; inset: 0; z-index: 50; }
.drawer-scrim { position: absolute; inset: 0; background: rgba(18, 32, 27, .38); }
.drawer-panel { position: absolute; right: 0; top: 0; bottom: 0; width: min(640px, 100%); background: var(--surface); box-shadow: -20px 0 50px -20px rgba(0, 0, 0, .3); display: flex; flex-direction: column; animation: slidein .22s ease; }
@keyframes slidein { from { transform: translateX(30px); opacity: 0; } }
@media (prefers-reduced-motion: reduce) { .drawer-panel { animation: none; } }
.drawer-head { padding: 18px 22px; border-bottom: 1px solid var(--line-2); display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.drawer-body { padding: 20px 22px; overflow-y: auto; flex: 1; }
.drawer-foot { padding: 14px 22px; border-top: 1px solid var(--line-2); display: flex; justify-content: flex-end; gap: 8px; }
.modal-panel { position: relative; margin: 6vh auto; width: min(980px, 94%); max-height: 88vh; overflow: auto; background: var(--surface); border-radius: 12px; }
.modal-panel img { width: 100%; display: block; }
.toasts { position: fixed; bottom: 20px; right: 20px; display: flex; flex-direction: column; gap: 8px; z-index: 60; }
.toast { background: var(--side); color: #fff; padding: 11px 16px; border-radius: 9px; box-shadow: var(--shadow); max-width: 380px; font-size: 13.5px; animation: slidein .2s ease; }
.toast.err { background: #7D2416; }

/* ---------- login ---------- */
.login { min-height: 100vh; display: grid; place-items: center; background: var(--side); padding: 20px; }
.login-card { width: min(380px, 100%); background: var(--surface); padding: 32px; border-radius: 14px; display: grid; gap: 14px; }
.login-card h1 { font-size: 22px; }
.login-card p { margin: 0; }

/* activity */
.feed { list-style: none; margin: 0; padding: 0; }
.feed li { display: grid; grid-template-columns: 74px minmax(0, 1fr); gap: 12px; padding: 9px 0; border-top: 1px solid var(--line-2); font-size: 13px; }
.feed li:first-child { border-top: 0; }
.feed .t { color: var(--muted); font-size: 12px; white-space: nowrap; }
.feed .lv-warn { color: #7A5208; }
.feed .lv-error { color: var(--s-failed); }
.kv { display: grid; grid-template-columns: 150px 1fr; gap: 8px 16px; font-size: 13.5px; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; }
.section-gap { margin-top: 18px; }
.split-head { display: flex; justify-content: space-between; align-items: center; gap: 10px; margin-bottom: 10px; }

@media (max-width: 760px) {
  .shell { grid-template-columns: 1fr; }
  .side { position: static; height: auto; flex-direction: row; flex-wrap: wrap; align-items: center; padding: 10px; }
  .brand { padding: 4px 8px; }
  nav { flex-direction: row; overflow-x: auto; width: 100%; }
  nav a { padding: 7px 9px; }
  .side-foot { display: none; }
  main { padding: 20px 16px 40px; }
  .form-row { grid-template-columns: 1fr; }
  .copy-field { grid-template-columns: 1fr auto; }
  .copy-field .k { grid-column: 1 / -1; }
}
