:root {
  --bg: #f6f7f9; --surface: #ffffff; --surface-2: #f0f2f5; --border: #e2e5ea;
  --text: #16191d; --muted: #66707c; --accent: #2457d6; --accent-soft: #e6edfc;
  --ok: #1f8a4c; --ok-soft: #e3f4ea; --warn: #b26b00; --warn-soft: #fbf0dc;
  --bad: #c0362c; --bad-soft: #fbe5e3; --radius: 10px;
  --mono: ui-monospace, SFMono-Regular, Menlo, monospace;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f1216; --surface: #171b21; --surface-2: #1e232b; --border: #2a313b;
    --text: #e7eaee; --muted: #8b95a1; --accent: #6f9bff; --accent-soft: #1d2a47;
    --ok: #4cc27f; --ok-soft: #15301f; --warn: #e3a645; --warn-soft: #33270f;
    --bad: #ef6f64; --bad-soft: #3a1a17; color-scheme: dark;
  }
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--text);
  font: 14px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", Inter, sans-serif; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
header { background: var(--surface); border-bottom: 1px solid var(--border); position: sticky; top: 0; z-index: 5; }
.bar { max-width: 1280px; margin: 0 auto; padding: 0 20px; display: flex; align-items: center; gap: 24px; height: 54px; }
.brand { font-weight: 700; letter-spacing: -.01em; }
.brand small { color: var(--muted); font-weight: 500; margin-left: 6px; }
nav { display: flex; gap: 4px; }
nav a { padding: 6px 12px; border-radius: 8px; color: var(--muted); font-weight: 500; }
nav a:hover { background: var(--surface-2); text-decoration: none; }
nav a.on { background: var(--accent-soft); color: var(--accent); }
main { max-width: 1280px; margin: 0 auto; padding: 24px 20px 64px; }
h1 { font-size: 20px; margin: 0 0 16px; letter-spacing: -.01em; }
h2 { font-size: 15px; margin: 0; }
.section { margin-top: 28px; }
.section-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px; gap: 12px; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.mono { font-family: var(--mono); font-size: 12px; }
.num { font-variant-numeric: tabular-nums; text-align: right; }

.flash { background: var(--accent-soft); color: var(--accent); padding: 10px 14px; border-radius: var(--radius); margin-bottom: 16px; }

.pipeline { display: grid; grid-template-columns: repeat(4, 1fr); gap: 0; background: var(--surface);
  border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; }
.stage { padding: 16px 18px; border-right: 1px solid var(--border); position: relative; }
.stage:last-child { border-right: 0; }
.stage .label { color: var(--muted); font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: .04em; }
.stage .value { font-size: 30px; font-weight: 700; font-variant-numeric: tabular-nums; letter-spacing: -.02em; margin: 2px 0; }
.stage .hint { color: var(--muted); font-size: 12px; }
.stage.dim .value { color: var(--muted); }

.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 10px; margin-top: 10px; }
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 12px 14px; }
.card .label { color: var(--muted); font-size: 12px; }
.card .value { font-size: 20px; font-weight: 650; font-variant-numeric: tabular-nums; }
.card .hint { color: var(--muted); font-size: 12px; }

.daily { display: flex; align-items: flex-end; gap: 4px; height: 70px; }
.daily div { flex: 1; background: var(--accent); border-radius: 3px 3px 0 0; min-height: 2px; opacity: .85; }
.daily-labels { display: flex; justify-content: space-between; color: var(--muted); font-size: 11px; margin-top: 4px; }

.agents { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.agent { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 12px 14px; display: flex; flex-direction: column; gap: 8px; min-width: 0; }
.agent .top { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.log { background: var(--surface-2); border-radius: 6px; padding: 8px; font-family: var(--mono); font-size: 11px;
  line-height: 1.45; color: var(--muted); height: 104px; overflow: hidden; white-space: pre; text-overflow: ellipsis; }
.log div { overflow: hidden; text-overflow: ellipsis; }

.badge { display: inline-block; padding: 1px 8px; border-radius: 999px; font-size: 12px; font-weight: 600; white-space: nowrap; }
.b-ok { background: var(--ok-soft); color: var(--ok); }
.b-warn { background: var(--warn-soft); color: var(--warn); }
.b-bad { background: var(--bad-soft); color: var(--bad); }
.b-muted { background: var(--surface-2); color: var(--muted); }
.b-accent { background: var(--accent-soft); color: var(--accent); }

.btn { display: inline-flex; align-items: center; gap: 6px; border: 1px solid var(--border); background: var(--surface);
  color: var(--text); border-radius: 8px; padding: 6px 12px; font: inherit; font-weight: 500; cursor: pointer; }
.btn:hover { background: var(--surface-2); text-decoration: none; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.primary:hover { filter: brightness(1.08); }
.btn.sm { padding: 2px 8px; font-size: 12px; }
.btn.danger { color: var(--bad); }
.actions { display: flex; gap: 4px; flex-wrap: wrap; }

.table-wrap { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { padding: 8px 12px; border-bottom: 1px solid var(--border); text-align: left; vertical-align: middle; }
th { font-size: 12px; color: var(--muted); font-weight: 600; background: var(--surface-2); white-space: nowrap; }
tr:last-child td { border-bottom: 0; }
td.trunc { max-width: 220px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.progress { height: 6px; background: var(--surface-2); border-radius: 999px; overflow: hidden; min-width: 90px; }
.progress div { height: 100%; background: var(--accent); }
.progress.done div { background: var(--ok); }

form.grid { display: grid; gap: 18px; max-width: 760px; }
.field label.title { display: block; font-weight: 600; margin-bottom: 6px; }
.field .help { color: var(--muted); font-size: 12px; margin-top: 4px; }
input[type=text], input[type=number], select { font: inherit; color: var(--text); background: var(--surface);
  border: 1px solid var(--border); border-radius: 8px; padding: 7px 10px; }
input:focus, select:focus { outline: 2px solid var(--accent-soft); border-color: var(--accent); }
.checks { display: flex; flex-wrap: wrap; gap: 6px; }
.check { display: inline-flex; align-items: center; gap: 6px; padding: 6px 10px; border: 1px solid var(--border);
  border-radius: 8px; background: var(--surface); cursor: pointer; user-select: none; }
.check:has(input:checked) { border-color: var(--accent); background: var(--accent-soft); }
.check .muted { font-size: 12px; }
.estimate { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 12px 14px; }
.filters { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-bottom: 12px; }
.pager { display: flex; gap: 8px; align-items: center; justify-content: flex-end; margin-top: 10px; }
.cat-block { margin-bottom: 18px; }
.two-col { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.htmx-request .spin, .spin.htmx-request { opacity: .5; }

@media (max-width: 900px) {
  .pipeline { grid-template-columns: 1fr 1fr; }
  .stage:nth-child(2) { border-right: 0; }
  .stage:nth-child(-n+2) { border-bottom: 1px solid var(--border); }
  .agents, .two-col { grid-template-columns: 1fr; }
  .bar { gap: 12px; overflow-x: auto; }
}
td.num, td.nowrap, .brand, nav a { white-space: nowrap; }
form.grid > div:last-child { display: flex; align-items: center; gap: 12px; }
@media (max-width: 600px) { .brand small { display: none; } main { padding: 16px 16px 48px; } }
.me { margin-left: auto; display: flex; align-items: center; gap: 8px; font-size: 13px; white-space: nowrap; }
.me form { margin: 0; }
.flash.err { background: var(--bad-soft); color: var(--bad); }
.login { display: grid; place-items: center; min-height: 60vh; }
.login-card { max-width: 440px; padding: 28px; display: grid; gap: 12px; }
.login-card h1 { margin: 0; }
.btn.block { justify-content: center; padding: 10px 14px; font-size: 15px; }
.actions form { margin: 0; }
.env-live { background: var(--ok-soft); color: var(--ok); }
.env-local { background: var(--warn-soft); color: var(--warn); }
.brand .badge { margin-left: 8px; vertical-align: 1px; }
.captcha-box { margin-bottom: 16px; }
.screen-wrap { max-width: 100%; border: 1px solid var(--border); border-radius: 8px; background: var(--surface-2); min-height: 120px; overflow: hidden; }
.screen-wrap.zoomed { overflow: auto; max-height: 78vh; }
.screen-inner { position: relative; display: inline-block; vertical-align: top; }
.screen { display: block; max-width: 100%; max-height: 72vh; width: auto; height: auto; cursor: crosshair; user-select: none; }
.screen-wrap.zoomed .screen { max-width: none; max-height: none; height: auto; }
.zoom { display: inline-flex; gap: 4px; align-items: center; }
.zoom-label { min-width: 64px; justify-content: center; font-variant-numeric: tabular-nums; }
.click-dot { position: absolute; width: 18px; height: 18px; margin: -9px 0 0 -9px; border-radius: 50%; border: 3px solid var(--accent); background: rgba(36, 87, 214, .25); pointer-events: none; }
.captcha-controls { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin: 10px 0 6px; }
.captcha-controls form.js-type { display: flex; gap: 6px; }
.captcha-controls input[type=text] { min-width: 280px; }
