/* arp-precision UI - drafting-table palette: slate ink rail, cool vellum canvas, verdigris accent */
:root {
  --ink: #18222c;
  --ink-2: #3b4855;
  --muted: #6a7785;
  --line: #cfd7dc;
  --line-2: #e2e8eb;
  --paper: #f2f5f4;
  --sheet: #ffffff;
  --rail: #1d2a35;
  --rail-ink: #c9d4dc;
  --rail-dim: #7f909e;
  --accent: #2c7a6b;
  --accent-ink: #ffffff;
  --accent-soft: #dcefe9;
  --warn: #9a6512;
  --warn-soft: #fbefd9;
  --bad: #b3261e;
  --bad-soft: #fbe3e1;
  --ok: #2c7a6b;
  --radius: 6px;
  --font: "IBM Plex Sans", -apple-system, "Segoe UI", system-ui, sans-serif;
  --mono: "IBM Plex Mono", ui-monospace, Menlo, monospace;
}
@media (prefers-color-scheme: dark) {
  :root {
    --ink: #e4eaee; --ink-2: #bcc7cf; --muted: #8b98a4; --line: #34424e; --line-2: #2a3640;
    --paper: #141c23; --sheet: #1b252e; --rail: #0f161c; --accent: #4fae9a; --accent-ink: #0c1a16;
    --accent-soft: #183630; --warn: #e0a94a; --warn-soft: #332714; --bad: #ef7b72; --bad-soft: #3a1e1c;
  }
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { font: 15px/1.5 var(--font); color: var(--ink); background: var(--paper); -webkit-font-smoothing: antialiased; }
button, input { font: inherit; color: inherit; }
code, .mono { font-family: var(--mono); font-size: .86em; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
[hidden] { display: none !important; }

.app { display: grid; grid-template-columns: 264px 1fr; min-height: 100vh; }

/* ------------------------------------------------------------------ rail */
.rail { background: var(--rail); color: var(--rail-ink); padding: 22px 16px; display: flex; flex-direction: column; gap: 28px;
  position: sticky; top: 0; height: 100vh; }
.brand { display: flex; gap: 12px; align-items: center; padding: 0 6px; }
.brand-mark { width: 34px; height: 34px; color: #8fd1c2; flex: none; }
.brand strong { display: block; font-size: 17px; color: #fff; letter-spacing: .01em; }
.brand span { font-size: 12px; color: var(--rail-dim); }
.steps { display: flex; flex-direction: column; gap: 2px; position: relative; }
.steps::before { content: ""; position: absolute; left: 21px; top: 22px; bottom: 22px; border-left: 1px dashed #3d4f5d; }
.step { display: flex; gap: 12px; align-items: flex-start; width: 100%; text-align: left; background: none; border: 0;
  padding: 10px 8px; border-radius: var(--radius); cursor: pointer; color: var(--rail-ink); position: relative; }
.step b { width: 26px; height: 26px; flex: none; display: grid; place-items: center; border-radius: 50%; font-size: 13px;
  background: var(--rail); border: 1px solid #4a5d6b; color: var(--rail-ink); z-index: 1; }
.step span { display: flex; flex-direction: column; font-weight: 500; }
.step small { font-weight: 400; color: var(--rail-dim); font-size: 12px; max-width: 180px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.step:hover { background: #26343f; }
.step.on { background: #263744; }
.step.on b { background: #8fd1c2; border-color: #8fd1c2; color: #10221d; }
.step.running small { color: #f2c46d; }
.rail-foot { margin-top: auto; font-size: 12px; color: var(--rail-dim); display: flex; flex-direction: column; gap: 6px; padding: 0 6px; }
.rail-foot .k { color: var(--rail-ink); }
.dot { display: inline-block; width: 7px; height: 7px; border-radius: 50%; margin-right: 6px; vertical-align: 1px; background: var(--rail-dim); }
.dot.ok { background: #62c4a8; } .dot.bad { background: #ef7b72; } .dot.warn { background: #e0a94a; }

/* ------------------------------------------------------------------ main */
.main { padding: 34px 44px 60px; max-width: 1280px; width: 100%; min-width: 0; }
.view-head { margin-bottom: 22px; }
.view-head h1 { font-size: 30px; line-height: 1.15; margin: 0 0 6px; font-weight: 600; letter-spacing: -.01em; }
.view-head p { margin: 0; color: var(--muted); max-width: 70ch; }
h3 { font-size: 15px; margin: 0 0 12px; font-weight: 600; }
.muted { color: var(--muted); font-size: 13px; }
.hint { color: var(--muted); font-size: 13px; margin: 10px 2px 18px; max-width: 80ch; }
.empty { color: var(--muted); font-size: 14px; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.cols { display: grid; grid-template-columns: minmax(240px, 1fr) 2fr; gap: 18px; margin-top: 22px; }
.panel { background: var(--sheet); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px 20px; }

.btn { border: 1px solid var(--line); background: var(--sheet); padding: 8px 14px; border-radius: var(--radius); cursor: pointer;
  font-weight: 500; font-size: 14px; white-space: nowrap; }
a.btn { text-decoration: none; color: inherit; display: inline-block; }
a.btn.primary { color: var(--accent-ink); }
.btn:hover { border-color: var(--ink-2); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.primary:hover { filter: brightness(1.07); }
.btn.danger { color: var(--bad); border-color: var(--bad); background: transparent; }
.btn.big { padding: 12px 26px; font-size: 15px; }
.btn:disabled { opacity: .45; cursor: not-allowed; filter: none; }
.btn.small { padding: 4px 10px; font-size: 13px; }
input[type=text] { flex: 1; min-width: 240px; padding: 9px 12px; border: 1px solid var(--line); border-radius: var(--radius);
  background: var(--sheet); font-family: var(--mono); font-size: 13px; }

/* the drop zone: a sheet with dimension lines - the one bold element */
.drop { position: relative; border: 1.5px dashed #9fb0ba; border-radius: 4px; background: var(--sheet);
  background-image: linear-gradient(var(--line-2) 1px, transparent 1px), linear-gradient(90deg, var(--line-2) 1px, transparent 1px);
  background-size: 28px 28px; background-position: -1px -1px; padding: 46px 40px; min-height: 260px; display: grid; place-items: center;
  transition: border-color .15s, background-color .15s; }
.drop.over { border-color: var(--accent); background-color: var(--accent-soft); }
.drop-dim { position: absolute; left: 34px; right: 34px; top: 10px; height: 18px; width: calc(100% - 68px); color: #8aa0ad; }
.drop-dim.bottom { top: auto; bottom: 10px; }
.drop-body { text-align: center; background: var(--sheet); padding: 18px 28px; border-radius: 4px; }
.drop-body h2 { font-size: 26px; margin: 0 0 6px; font-weight: 600; letter-spacing: -.01em; }
.drop-body p { margin: 0 0 18px; color: var(--muted); }
.drop-actions { display: flex; gap: 14px; align-items: center; justify-content: center; flex-wrap: wrap; }
.or { color: var(--muted); font-size: 13px; }
.path-row { margin-bottom: 4px; }

.plist { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 4px; }
.plist button { width: 100%; text-align: left; border: 1px solid transparent; background: none; padding: 8px 10px; border-radius: var(--radius);
  cursor: pointer; display: flex; justify-content: space-between; gap: 8px; }
.plist button:hover, .plist button.on { border-color: var(--line); background: var(--paper); }
.plist small { color: var(--muted); }

.kv { display: grid; grid-template-columns: max-content 1fr; gap: 6px 18px; font-size: 14px; margin: 0; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; overflow-wrap: anywhere; }
.state { display: inline-flex; align-items: center; gap: 6px; font-weight: 500; }
.state.ok { color: var(--ok); } .state.bad { color: var(--bad); } .state.warn { color: var(--warn); }
.msgs { margin: 14px 0 0; padding: 0; list-style: none; display: flex; flex-direction: column; gap: 6px; font-size: 13.5px; }
.msgs li { padding: 8px 12px; border-radius: var(--radius); }
.msgs .bad { background: var(--bad-soft); color: var(--bad); }
.msgs .warn { background: var(--warn-soft); color: var(--warn); }
.files { margin-top: 14px; max-height: 220px; overflow: auto; border-top: 1px solid var(--line-2); font-size: 13px; }
.files div { display: flex; justify-content: space-between; padding: 5px 0; border-bottom: 1px solid var(--line-2); gap: 12px; }

/* ------------------------------------------------------------------ stages */
.stage-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; align-items: start; }
.stage { background: var(--sheet); border: 1px solid var(--line); border-radius: var(--radius); }
.stage.sel { border-color: var(--accent); box-shadow: inset 3px 0 0 var(--accent); }
.stage.blocked { opacity: .55; }
.stage-head { display: flex; gap: 12px; padding: 16px 18px; cursor: pointer; align-items: flex-start; }
.stage-head input { margin-top: 4px; accent-color: var(--accent); width: 16px; height: 16px; }
.stage-head b { display: block; font-size: 16px; }
.stage-head small { color: var(--muted); font-size: 13px; }
.tag { font-weight: 600; width: 24px; height: 24px; border: 1px solid var(--line); border-radius: 4px; display: grid; place-items: center;
  font-size: 13px; color: var(--ink-2); flex: none; }
.stage.paid .tag { border-color: var(--warn); color: var(--warn); }
.stage-body { padding: 0 18px 16px 54px; display: flex; flex-direction: column; gap: 12px; }
.stage:not(.sel) .stage-body { display: none; }
.field { display: flex; flex-direction: column; gap: 6px; }
.flabel { font-size: 13px; color: var(--muted); }
.seg { display: inline-flex; border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.seg button { border: 0; background: var(--sheet); padding: 6px 14px; cursor: pointer; font-size: 13.5px; border-right: 1px solid var(--line); }
.seg button:last-child { border-right: 0; }
.seg button.on { background: var(--ink); color: var(--sheet); }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { border: 1px solid var(--line); background: var(--sheet); padding: 4px 10px; border-radius: 999px; font-size: 12.5px; cursor: pointer; }
.chip.on { background: var(--accent-soft); border-color: var(--accent); color: var(--ink); }
.chip.na { opacity: .45; }
.chip .mk { color: var(--ok); margin-left: 4px; }
.check { display: inline-flex; gap: 8px; align-items: center; font-size: 13.5px; cursor: pointer; }
.check input { accent-color: var(--accent); }
.settings-box { font-size: 13px; background: var(--paper); border: 1px solid var(--line-2); border-radius: var(--radius); padding: 10px 12px; }
.settings-box .kv { font-size: 13px; }
.interp { margin-top: 16px; display: flex; flex-direction: column; gap: 12px; }
.plan { margin-top: 16px; }
.cmd { font-family: var(--mono); font-size: 12.5px; background: var(--paper); border: 1px solid var(--line-2); border-radius: var(--radius);
  padding: 9px 12px; overflow-x: auto; white-space: pre; margin: 6px 0 12px; }
.planstep { margin-bottom: 4px; font-weight: 500; }
.note { font-size: 13px; color: var(--ink-2); margin: 4px 0; }
.err { color: var(--bad); font-size: 14px; }
.actions { display: flex; justify-content: flex-end; margin-top: 18px; gap: 10px; }

/* ------------------------------------------------------------------ run */
.run-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 16px; flex-wrap: wrap; }
.run-meta { display: flex; gap: 14px; align-items: center; }
.clock { font-family: var(--mono); font-size: 22px; color: var(--ink-2); }
.progress { height: 6px; background: var(--line-2); border-radius: 3px; overflow: hidden; position: relative; }
.progress .bar { height: 100%; width: 0; background: var(--accent); transition: width .4s; }
.progress.indet .bar { width: 30%; position: absolute; animation: indet 1.4s ease-in-out infinite; }
@keyframes indet { from { left: -30%; } to { left: 100%; } }
@media (prefers-reduced-motion: reduce) { .progress.indet .bar { animation: none; width: 100%; opacity: .35; } }
.progress.done .bar { width: 100%; }
.progress.failed .bar { width: 100%; background: var(--bad); }
.progress-label { font-size: 13px; color: var(--muted); margin: 8px 0 18px; min-height: 1.2em; }
.joblist { list-style: none; margin: 0 0 18px; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.joblist li { background: var(--sheet); border: 1px solid var(--line); border-radius: var(--radius); padding: 10px 14px;
  display: grid; grid-template-columns: 22px minmax(0, 1fr) auto; gap: 10px; align-items: start; }
.joblist .cmd { margin: 6px 0 0; }
.badge { font-size: 12px; padding: 2px 8px; border-radius: 999px; background: var(--line-2); color: var(--ink-2); white-space: nowrap; }
.badge.succeeded, .badge.accepted_automatically, .badge.accepted_manually, .badge.pass { background: var(--accent-soft); color: var(--ok); }
.badge.warnings, .badge.uncertain, .badge.needs_manual_review, .badge.running { background: var(--warn-soft); color: var(--warn); }
.badge.failed, .badge.cancelled, .badge.flagged { background: var(--bad-soft); color: var(--bad); }
.ico { width: 18px; height: 18px; margin-top: 2px; }
.summary h3 { margin-bottom: 8px; }
.summary ul { margin: 6px 0 0; padding-left: 18px; font-size: 13.5px; }
.logbar { display: flex; gap: 16px; align-items: center; margin-top: 10px; flex-wrap: wrap; }
.logbar h3 { margin: 0; }
.log { background: #0f171d; color: #c8d3da; font: 12.5px/1.55 var(--mono); padding: 14px 16px; border-radius: var(--radius);
  height: 420px; overflow: auto; white-space: pre-wrap; word-break: break-word; margin: 8px 0 0; }
.log .w { color: #f2c46d; } .log .e { color: #ff8b80; } .log .c { color: #8fd1c2; } .log .u { color: #9fb2c0; }

/* ------------------------------------------------------------------ results */
.dl { display: flex; gap: 8px; flex-wrap: wrap; }
.tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--line); margin-bottom: 18px; overflow-x: auto; }
.tabs button { border: 0; background: none; padding: 9px 14px; cursor: pointer; color: var(--muted); border-bottom: 2px solid transparent;
  margin-bottom: -1px; white-space: nowrap; font-weight: 500; }
.tabs button.on { color: var(--ink); border-bottom-color: var(--accent); }
.tabs .cnt { font-size: 11px; color: var(--muted); margin-left: 4px; }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 14px; }
.tile { background: var(--sheet); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; display: flex; flex-direction: column; }
.tile img { width: 100%; aspect-ratio: 3 / 2; object-fit: contain; background: var(--paper); cursor: zoom-in; display: block; }
.tile .cap { padding: 8px 10px; font-size: 13px; display: flex; justify-content: space-between; gap: 8px; align-items: center; }
.tile .cap small { color: var(--muted); }
.sheet-tile img { aspect-ratio: 1.414; background: #fff; }
.section-title { display: flex; justify-content: space-between; align-items: baseline; margin: 22px 0 10px; }
.section-title h3 { margin: 0; }
.vcard { background: var(--sheet); border: 1px solid var(--line); border-radius: var(--radius); margin-bottom: 14px; }
.vcard-head { display: flex; justify-content: space-between; gap: 12px; align-items: center; padding: 12px 16px; border-bottom: 1px solid var(--line-2); flex-wrap: wrap; }
.vcard-head b { font-size: 15px; }
.vcard-imgs { display: grid; grid-template-columns: 1fr 1fr; gap: 1px; background: var(--line-2); }
.vcard-imgs figure { margin: 0; background: var(--sheet); }
.vcard-imgs img { width: 100%; aspect-ratio: 3 / 2; object-fit: contain; display: block; background: var(--paper); cursor: zoom-in; }
.vcard-imgs figcaption { font-size: 12px; color: var(--muted); padding: 6px 10px; }
.vcard-body { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; padding: 14px 16px; font-size: 13.5px; }
.cats { display: flex; flex-wrap: wrap; gap: 6px; }
.reflist { margin: 4px 0 0; padding-left: 18px; }
.vcard-foot { display: flex; gap: 10px; padding: 0 16px 14px; flex-wrap: wrap; align-items: center; }
.md { background: var(--sheet); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px 22px; font-size: 14px; overflow-x: auto; }
.md table { border-collapse: collapse; font-size: 12.5px; margin: 8px 0 16px; }
.md td, .md th { border: 1px solid var(--line-2); padding: 4px 8px; text-align: left; vertical-align: top; }
.md h1 { font-size: 20px; } .md h2 { font-size: 16px; margin-top: 22px; }
.stats { display: flex; gap: 10px; flex-wrap: wrap; margin: 10px 0 16px; }
.stat { border: 1px solid var(--line); border-radius: var(--radius); padding: 8px 14px; background: var(--sheet); font-size: 13px; }
.stat b { display: block; font-size: 20px; font-weight: 600; }
.disc { margin: 0; padding: 0; list-style: none; display: flex; flex-direction: column; gap: 6px; font-size: 13.5px; }
.disc li { border-left: 3px solid var(--warn); padding: 6px 10px; background: var(--sheet); }
.link { color: var(--accent); cursor: pointer; text-decoration: underline; background: none; border: 0; padding: 0; font-size: inherit; }

/* ------------------------------------------------------------------ dialog / lightbox / toast */
.dlg { border: 1px solid var(--line); border-radius: 8px; padding: 0; width: min(760px, 94vw); background: var(--sheet); color: var(--ink); }
.dlg::backdrop { background: rgba(15, 23, 29, .55); }
.dlg-in { padding: 22px 24px; }
.dlg h2 { margin: 0 0 6px; font-size: 21px; }
.dlg .thumbs { display: grid; grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); gap: 8px; margin: 12px 0; max-height: 300px; overflow: auto; }
.dlg .thumbs figure { margin: 0; font-size: 11.5px; color: var(--muted); }
.dlg .thumbs img { width: 100%; aspect-ratio: 3 / 2; object-fit: cover; border: 1px solid var(--line-2); }
.dlg-actions { display: flex; justify-content: flex-end; gap: 10px; padding: 14px 24px; border-top: 1px solid var(--line-2); background: var(--paper); }
.lightbox { position: fixed; inset: 0; background: rgba(10, 15, 19, .9); display: grid; place-items: center; z-index: 50; cursor: zoom-out; padding: 30px; }
.lightbox img { max-width: 100%; max-height: calc(100vh - 90px); background: #fff; }
.lightbox p { color: #c8d3da; margin: 10px 0 0; text-align: center; font-size: 13px; }
.toast { position: fixed; bottom: 22px; right: 22px; background: var(--ink); color: var(--sheet); padding: 10px 16px; border-radius: var(--radius); font-size: 14px; z-index: 60; max-width: 460px; }

@media (max-width: 900px) {
  .app { grid-template-columns: 1fr; }
  .rail { position: static; height: auto; flex-direction: row; flex-wrap: wrap; gap: 12px; }
  .steps { flex-direction: row; overflow-x: auto; max-width: 100%; } .steps::before { display: none; } .rail-foot { display: none; }
  .view-head h1 { font-size: 24px; overflow-wrap: anywhere; } .run-head { align-items: flex-start; }
  .step small { display: none; }
  .main { padding: 22px 16px 40px; }
  .cols, .stage-grid, .vcard-body, .vcard-imgs { grid-template-columns: 1fr; }
}

/* cost table */
.tbl { width: 100%; border-collapse: collapse; margin: 12px 0; font-size: 13px; }
.tbl th, .tbl td { text-align: left; padding: 6px 8px; border-bottom: 1px solid var(--line, rgba(127,127,127,.25)); }
.tbl th { font-weight: 600; color: var(--muted); }
.tbl td:last-child, .tbl th:last-child { text-align: right; font-variant-numeric: tabular-nums; }

/* compare views: Blender vs AI */
.cmp-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(420px, 1fr)); gap: 16px; }
.cmp-card { background: #fff; border: 1px solid #e2e6ea; border-radius: 10px; padding: 10px; display: flex; flex-direction: column; gap: 8px; }
.cmp-card > img, .cmp-side img { width: 100%; border-radius: 6px; cursor: zoom-in; display: block; }
.cmp-side { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.cmp { position: relative; width: 100%; aspect-ratio: 3 / 2; overflow: hidden; border-radius: 6px; background: #000; }
.cmp img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.cmp .cmp-line { position: absolute; top: 0; bottom: 0; width: 2px; background: #fff; box-shadow: 0 0 4px #000; pointer-events: none; }
.cmp .cmp-r { position: absolute; left: 0; right: 0; bottom: 8px; width: calc(100% - 20px); margin: 0 10px; }
.tile.flagged { outline: 2px solid #e0a43a; }

/* Accounts and administration */
[hidden] { display: none !important; }
.auth-screen { min-height: 100vh; display: grid; place-items: center; padding: 24px; }
.auth-card { width: min(460px, 100%); }
.auth-card label, .account-form label { display: grid; gap: 8px; margin: 18px 0; }
.auth-card input, .account-form input { width: 100%; padding: 12px; border: 1px solid #aaa; border-radius: 4px; background: #fff; color: #222; }
.account-box { display: grid; gap: 8px; padding: 18px; overflow-wrap: anywhere; }
.account-box small { opacity: .7; }
.account-form { max-width: 640px; margin-bottom: 24px; }
.debug-banner { border: 2px solid #b76500; background: #fff3cd; color: #4d3500; padding: 14px; margin-bottom: 24px; display: flex; flex-wrap: wrap; align-items: center; gap: 14px; }
.admin-counts { display: grid; grid-template-columns: repeat(auto-fit,minmax(140px,1fr)); gap: 14px; margin: 24px 0; }
.admin-counts strong { display: block; font-size: 30px; }
.account-table { overflow-x: auto; margin-bottom: 30px; }
.account-table table { width: 100%; border-collapse: collapse; font-size: 14px; }
.account-table th, .account-table td { text-align: left; padding: 12px; border-bottom: 1px solid #d5d5d5; vertical-align: top; }
.account-table pre { white-space: pre-wrap; overflow-wrap: anywhere; max-width: 650px; max-height: 280px; overflow: auto; font-size: 12px; }
.account-form::backdrop { background: #0008; }

.account-box .btn { color: #243c49; }

/* Keep generated credentials visible in a centered, scrollable admin dialog. */
dialog.user-management-dialog { width: min(640px, calc(100vw - 32px)); max-height: calc(100dvh - 48px); margin: auto; overflow-y: auto; }
