:root {
  --bg: #f4f5f7;
  --card: #ffffff;
  --ink: #1f2328;
  --muted: #6b7280;
  --line: #e5e7eb;
  --primary: #1f6feb;
  --accent: #0f766e;
  --warn-bg: #fff7ed;
  --warn-ink: #9a3412;
  --ok: #15803d;
  --bad: #b91c1c;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}
* { box-sizing: border-box; }
body { margin: 0; font: 14px/1.45 system-ui, -apple-system, Segoe UI, Roboto, sans-serif; color: var(--ink); background: var(--bg); }
.topbar { display: flex; justify-content: space-between; align-items: center; padding: 10px 20px; background: #111827; color: #fff; }
.brand { font-weight: 600; font-size: 16px; }
.brand .muted { font-weight: 400; margin-left: 8px; color: #9ca3af; }
.topright { display: flex; flex-direction: column; align-items: flex-end; gap: 2px; }
.status { font-size: 13px; }
.admin { font-size: 12px; }
.admin button { font-size: 12px; padding: 2px 8px; margin-left: 6px; }
.po-box { margin: 8px 0 12px; }
.po-box .box { background: #eff6ff; border: 1px solid #bfdbfe; border-radius: 8px; padding: 10px 12px; }
.po-box .box.bad { background: #fef2f2; border-color: #fecaca; }
.po-box ul { margin: 6px 0 0 18px; padding: 0; }
.po-box .check { margin-top: 6px; }
.po-box .check.bad { color: var(--bad); }
.status.ok { color: #86efac; }
.status.bad { color: #fca5a5; }
.muted { color: var(--muted); }
.layout { display: grid; grid-template-columns: 300px 1fr; gap: 16px; padding: 16px 20px; align-items: start; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: 10px; padding: 14px; margin-bottom: 16px; }
.card h2 { margin: 0 0 10px; font-size: 13px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); }
.dropzone { display: flex; flex-direction: column; align-items: center; gap: 4px; padding: 26px 12px; border: 2px dashed #c7cdd6; border-radius: 10px; cursor: pointer; text-align: center; }
.dropzone.over { border-color: var(--primary); background: #eff6ff; }
.pick { margin-top: 10px; }
.pick summary { cursor: pointer; color: var(--primary); }
.list { list-style: none; margin: 8px 0 0; padding: 0; max-height: 320px; overflow: auto; }
.list li { padding: 7px 8px; border-radius: 6px; cursor: pointer; display: flex; justify-content: space-between; gap: 8px; }
.list li:hover { background: #f1f5f9; }
.list li.active { background: #e0ecff; }
.list .sub { color: var(--muted); font-size: 12px; white-space: nowrap; }
.content { min-height: 60vh; }
.empty { padding: 60px; text-align: center; background: var(--card); border: 1px solid var(--line); border-radius: 10px; }
.job { background: var(--card); border: 1px solid var(--line); border-radius: 10px; padding: 18px; }
.job-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; }
.doc-title { margin: 0; font-size: 20px; }
.doc-meta { margin-top: 4px; }
.state-pill { padding: 4px 10px; border-radius: 999px; background: #e5e7eb; font-size: 12px; font-weight: 600; white-space: nowrap; }
.state-pill.busy { background: #dbeafe; color: #1d4ed8; }
.state-pill.error { background: #fee2e2; color: var(--bad); }
.warnings { margin: 12px 0; }
.warnings div { background: var(--warn-bg); color: var(--warn-ink); padding: 6px 10px; border-radius: 6px; margin-bottom: 4px; font-size: 13px; }
.actions { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin: 12px 0; }
button { font: inherit; padding: 7px 12px; border-radius: 7px; border: 1px solid #c7cdd6; background: #fff; cursor: pointer; }
button:hover:not(:disabled) { background: #f1f5f9; }
button:disabled { opacity: .5; cursor: default; }
button.primary { background: var(--primary); border-color: var(--primary); color: #fff; }
button.primary:hover:not(:disabled) { background: #1a5fd0; }
button.accent { background: var(--accent); border-color: var(--accent); color: #fff; }
button.accent:hover:not(:disabled) { background: #0b5f59; }
.opt { font-size: 13px; color: var(--muted); margin-left: 6px; }
.csv-box { margin: 8px 0 12px; }
.csv-box .box { background: #ecfdf5; border: 1px solid #a7f3d0; border-radius: 8px; padding: 10px 12px; }
.csv-box .box.problems { background: var(--warn-bg); border-color: #fed7aa; }
.csv-box ol { margin: 6px 0 0 18px; padding: 0; }
.csv-box a { color: var(--primary); }
table.lines { width: 100%; border-collapse: collapse; font-size: 13px; }
table.lines th, table.lines td { text-align: left; padding: 6px 8px; border-bottom: 1px solid var(--line); vertical-align: top; }
table.lines th { font-size: 12px; color: var(--muted); font-weight: 600; }
table.lines .num { text-align: right; }
.tag { display: inline-block; padding: 1px 7px; border-radius: 999px; font-size: 11px; font-weight: 600; white-space: nowrap; }
.tag.matched { background: #dcfce7; color: var(--ok); }
.tag.created { background: #dbeafe; color: #1d4ed8; }
.tag.unmatched { background: #fee2e2; color: var(--bad); }
.tag.skipped { background: #f3f4f6; color: var(--muted); }
.tag.pending { background: #f3f4f6; color: var(--muted); }
.cands { margin-top: 4px; font-size: 12px; color: var(--muted); }
.logbox { margin-top: 14px; }
.logbox summary { cursor: pointer; color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: .04em; }
.log { background: #0f172a; color: #cbd5e1; padding: 10px 12px; border-radius: 8px; max-height: 260px; overflow: auto; font: 12px/1.5 var(--mono); white-space: pre-wrap; margin: 8px 0 0; }
.mono { font-family: var(--mono); font-size: 12px; }
.toast { position: fixed; right: 20px; bottom: 20px; background: #111827; color: #fff; padding: 10px 14px; border-radius: 8px; box-shadow: 0 6px 20px rgba(0,0,0,.25); max-width: 420px; }
.toast.bad { background: var(--bad); }
@media (max-width: 900px) { .layout { grid-template-columns: 1fr; } }

/* login page */
.login-body { display: flex; align-items: center; justify-content: center; min-height: 100vh; }
.login { width: 360px; max-width: calc(100vw - 32px); display: flex; flex-direction: column; gap: 10px; }
.login h1 { margin: 0; font-size: 22px; }
.login p { margin: 0 0 6px; }
.login label { font-size: 13px; color: var(--muted); margin-bottom: -6px; }
.login input { font: inherit; padding: 8px 10px; border: 1px solid #c7cdd6; border-radius: 7px; color: var(--ink); }
.login-error { background: #fef2f2; color: var(--bad); border: 1px solid #fecaca; border-radius: 7px; padding: 8px 10px; font-size: 13px; }
#logout button { font-size: 11px; padding: 1px 7px; margin-top: 2px; }

/* remote sign-in relay */
.relay { position: fixed; inset: 0; background: rgba(15, 23, 42, .6); display: flex; align-items: center; justify-content: center; z-index: 50; }
.relay[hidden] { display: none; }
.relay-panel { background: var(--card); border-radius: 12px; padding: 14px; width: min(1320px, calc(100vw - 24px)); max-height: calc(100vh - 24px); display: flex; flex-direction: column; gap: 8px; box-shadow: 0 20px 60px rgba(0,0,0,.4); }
.relay-head { display: flex; align-items: center; gap: 10px; }
.relay-head .spacer { flex: 1; }
.relay-help { margin: 0; font-size: 12px; }
.relay-screen { overflow: auto; border: 1px solid var(--line); border-radius: 8px; background: #000; }
.relay-screen { position: relative; }
.relay-screen img { display: block; width: 100%; height: auto; cursor: crosshair; }
.relay-screen img.live { box-shadow: inset 0 0 0 2px var(--primary); }
/* Invisible field that receives the keyboard while the remote screen is active. */
.relay-sink { position: absolute; left: 0; top: 0; width: 1px; height: 1px; opacity: 0; border: 0; padding: 0; }
.relay-paste { display: flex; gap: 6px; }
.relay-paste input { flex: 1; font: inherit; padding: 6px 10px; border: 1px solid #c7cdd6; border-radius: 7px; }
