/* Page styles. Colours, spacing and type live in css/tokens.css; the names
 * below are kept as local aliases so this sheet reads unchanged. */
:root { --bg:#0f1115; --card:#1a1d24; --fg:#e6e8eb; --muted:#9aa3af; --accent:#4f8cff; --err:#ff6b6b; --border:#2a2e37; }
* { box-sizing: border-box; }
body { margin:0; background:var(--bg); color:var(--fg); font:14px/1.5 system-ui, sans-serif; }
header { padding:16px 24px; border-bottom:1px solid var(--border); }
header h1 { margin:0 0 8px; font-size:18px; }
nav { display:flex; gap:16px; align-items:center; }
nav a { color:var(--muted); text-decoration:none; padding:4px 0; }
nav a.active { color:var(--fg); border-bottom:2px solid var(--accent); }
nav .spacer { flex:1; }
nav form.logout { margin:0; }
nav form.logout button { background:none; border:none; color:var(--muted); padding:4px 0; font:inherit; }
nav form.logout button:hover { color:var(--fg); }
/* The sign-in form: one narrow card in the middle of the screen. */
.login-page main { min-height:100vh; display:flex; align-items:center; justify-content:center; padding:16px; }
.login-card { width:100%; max-width:340px; display:flex; flex-direction:column; gap:14px; margin:0; }
.login-card h1 { margin:0 0 4px; font-size:18px; }
.login-card .err { margin:0; }
main { padding:24px; max-width:1100px; margin:0 auto; }
.card { background:var(--card); border:1px solid var(--border); border-radius:10px; padding:18px; margin-bottom:20px; }
.card h2 { margin:0 0 14px; font-size:15px; }
.row { display:flex; gap:14px; flex-wrap:wrap; align-items:flex-end; margin-bottom:12px; }
label { display:flex; flex-direction:column; gap:4px; font-size:12px; color:var(--muted); }
label.grow { flex:1; min-width:220px; }
/* A group of controls under one caption — the day pager. Inside a label the
   column layout stacks every button full-width; this keeps them in one line. */
.day-nav { display:flex; gap:4px; align-items:center; }
.day-nav button { padding:8px 10px; }
input, select, textarea { background:#11141a; color:var(--fg); border:1px solid var(--border); border-radius:6px; padding:8px; font:inherit; }
/* The console is dark; without this the browser paints its own parts of a
   native control for a light page — a black calendar icon on a black field. */
input[type="date"] { color-scheme: dark; }
textarea { width:100%; resize:vertical; }
button { background:#262b34; color:var(--fg); border:1px solid var(--border); border-radius:6px; padding:8px 14px; cursor:pointer; }
button:hover { border-color:var(--accent); }
button.primary { background:var(--accent); border-color:var(--accent); color:#fff; }
button:disabled { opacity:.5; cursor:not-allowed; }
pre { white-space:pre-wrap; word-break:break-word; background:#11141a; padding:14px; border-radius:8px; border:1px solid var(--border); }
.meta { color:var(--muted); margin-bottom:10px; }
.gen-image { max-width:100%; border-radius:8px; margin-top:10px; }
table { width:100%; border-collapse:collapse; font-size:13px; }
th, td { text-align:left; padding:7px 8px; border-bottom:1px solid var(--border); }
th { color:var(--muted); font-weight:600; }
td.trunc { max-width:280px; overflow:hidden; text-overflow:ellipsis; white-space:nowrap; }
th.num, td.num { text-align:right; font-variant-numeric:tabular-nums; font-family:ui-monospace, "SF Mono", Menlo, monospace; white-space:nowrap; }
.hint { color:var(--muted); font-size:12px; margin:0 0 12px; }
.err { color:var(--err); }
.ok { color:var(--ok, #4ade80); }
.warn { color:var(--warn, #fbbf24); }
.muted { color:var(--muted); }
.mono { font-family:var(--font-mono, ui-monospace, Menlo, monospace); }
/* The failure text opens under its own row: an error the operator cannot read
   is an error they cannot act on. */
td.log-error { color:var(--muted); background:#15181f; font-size:12px; }
a { color:var(--accent); }
:focus-visible { outline:2px solid var(--accent); outline-offset:2px; }
#toast { position:fixed; bottom:24px; right:24px; background:#262b34; border:1px solid var(--border); padding:12px 18px; border-radius:8px; opacity:0; transform:translateY(8px); transition:.2s; pointer-events:none; }
#toast.show { opacity:1; transform:none; }
#toast.error { border-color:var(--err); color:var(--err); }

/* --- wave 1: run screen, inspector, model card ------------------------- */

/* Two columns on a desktop, one below 1100 (§15): the result goes straight
   under the form rather than off the side of the screen. */
.run-layout, .models-layout { display:grid; gap:20px; grid-template-columns:minmax(420px,1fr) 1fr; align-items:start; }
@media (max-width:1100px) { .run-layout, .models-layout { grid-template-columns:1fr; } }
main { max-width:1600px; }

fieldset.block { border:1px solid var(--border); border-radius:var(--radius,6px); padding:12px 14px; margin:0 0 14px; }
fieldset.block legend { color:var(--muted); font-size:12px; padding:0 6px; display:flex; gap:10px; align-items:center; }
/* The explanation of a term is visible text under its control, not a tooltip. */
.under { color:var(--muted); font-size:11px; line-height:1.35; }
.under.warn { color:var(--warn,#fbbf24); }
.under.ok { color:var(--ok,#4ade80); }

.segmented { display:inline-flex; border:1px solid var(--border); border-radius:var(--radius,6px); overflow:hidden; }
.seg { background:transparent; border:0; border-radius:0; padding:3px 10px; font-size:12px; }
.seg.active { background:var(--accent); color:#fff; }

.actions { align-items:center; }
.actions .spacer { flex:1; }
button .est { opacity:.85; font-variant-numeric:tabular-nums; }

/* Plan */
.plan { border:1px dashed var(--border-strong,#3a414c); border-radius:var(--radius,6px); padding:12px 14px; margin-bottom:14px; }
.plan-head { display:flex; gap:12px; align-items:baseline; }
.plan-head h3 { margin:0; font-size:14px; }
.candidates { margin-top:10px; font-size:12px; }
.candidates tr.muted td { opacity:.6; }
.plan-verdict { margin:10px 0 0; }

/* Inspector */
.inspector { display:flex; flex-direction:column; gap:10px; }
.insp-summary { display:flex; gap:12px; align-items:center; flex-wrap:wrap; }
.insp-pair { color:var(--muted); }
.chip { padding:2px 8px; border-radius:10px; border:1px solid currentColor; font-size:12px; }
.tabs { display:flex; gap:2px; border-bottom:1px solid var(--border); }
.tab { background:transparent; border:0; border-bottom:2px solid transparent; border-radius:0; padding:6px 12px; color:var(--muted); }
.tab.active { color:var(--fg); border-bottom-color:var(--accent); }
.tab-pane { min-height:80px; }
.pane-head { display:flex; justify-content:flex-end; gap:10px; align-items:center; }
button.small { padding:2px 8px; font-size:11px; }
/* One message of a request history: the role reads as a label, the content as text. */
.insp-message { display:flex; gap:8px; align-items:flex-start; margin:4px 0; }
.insp-message pre { margin:0; flex:1; }

/* Timeline: two levels, attempts and the HTTP retries inside them. */
.timeline { font-size:12px; }
.tl-head { display:flex; justify-content:space-between; color:var(--muted); border-bottom:1px solid var(--border); padding-bottom:4px; margin-bottom:6px; }
.tl-step, .tl-retry { display:grid; grid-template-columns:90px 260px 1fr; gap:10px; padding:2px 0; }
.tl-retry { padding-left:24px; grid-template-columns:66px 160px 1fr; color:var(--muted); }
.tl-nested { border-left:1px solid var(--border); margin-left:10px; }
.tl-at { color:var(--muted); }

/* JSON viewer */
.json-view { font-family:var(--font-mono,monospace); font-size:12px; line-height:1.5; }
.json-view details { padding-left:12px; }
.json-view summary { cursor:pointer; margin-left:-12px; }
.json-body { border-left:1px solid var(--border); padding-left:10px; }
.json-key { color:var(--accent); cursor:pointer; }
.json-string { color:var(--ok,#4ade80); }
.json-number { color:var(--warn,#fbbf24); }
.json-boolean, .json-null { color:var(--info,#60a5fa); }
.json-punct, .json-count { color:var(--muted); }
.json-block-head { display:flex; justify-content:space-between; align-items:center; }
.json-block-head h4 { margin:8px 0; font-size:13px; }

/* Key-value tables */
table.kv { width:100%; font-size:12px; }
table.kv th { width:38%; text-align:left; color:var(--muted); font-weight:400; vertical-align:top; }

/* A run in flight: the elapsed clock and the timeline as it fills. */
.live { border:1px solid var(--accent); border-radius:var(--radius,6px); padding:10px 14px; margin-bottom:14px; }
.live-head { display:flex; justify-content:space-between; margin:0 0 8px; font-size:12px; }
button.danger { border-color:var(--err); color:var(--err); }
button.linkish { background:transparent; border:0; padding:0 0 0 8px; font-size:11px; color:var(--muted); text-decoration:underline; }

/* Multi-model mode: chips of models, then a row per run. */
.chips { display:flex; gap:6px; flex-wrap:wrap; margin:6px 0; }
.chips .chip { display:inline-flex; gap:6px; align-items:center; }
.chip-x { background:transparent; border:0; padding:0; color:var(--muted); font-size:13px; line-height:1; }
table.multi { width:100%; font-size:12px; margin-bottom:14px; }
table.multi tbody tr { cursor:pointer; }
table.multi td { padding:3px 6px; border-bottom:1px solid var(--border); }

/* Session feed */
.feed { display:flex; gap:8px; flex-wrap:wrap; }
.feed-item { display:flex; gap:8px; align-items:center; font-size:12px; }
.feed-item.ok { border-color:var(--ok,#4ade80); }
.feed-item.err { border-color:var(--err); }

/* Model card */
.model-card { position:sticky; top:16px; }
#models tbody tr, #projects tbody tr { cursor:pointer; }
#models tbody tr.selected, #projects tbody tr.selected { background:#1f2430; }
/* «Проекты»: sub-headings inside a card block, and the token shown once. */
fieldset.block h4 { margin:14px 0 6px; font-size:12px; color:var(--muted); font-weight:600; }
fieldset.block table { width:100%; margin-bottom:8px; }
/* Fields with a line of explanation under them: aligned by their captions,
   not by their bottoms, or a field without a hint sinks below its neighbour. */
.row.fields { align-items:flex-start; }
.under + .row { margin-top:12px; }
.row.fields > label { flex:1 1 220px; min-width:0; }
.row.fields input, .row.fields select { width:100%; box-sizing:border-box; }
#issued-token { user-select:all; white-space:pre-wrap; word-break:break-all; margin:8px 0; }
.price-field { margin-bottom:10px; }
.price-field textarea { display:block; width:100%; box-sizing:border-box; font:inherit; resize:vertical; }
.hint.description { white-space:pre-line; }
/* One row per chosen file on «Прогон»: the name, then what it is for. */
.file-roles { margin-top:8px; }
.file-role { display:flex; align-items:center; gap:8px; margin-bottom:6px; }
.file-role span { flex:1; overflow:hidden; text-overflow:ellipsis; white-space:nowrap; }

/* Attachment roles: a block of its own, because it is not a price and reading
   it as one is how `garm_img` ends up in a rate field. */
.input-map { border-top:1px solid var(--border); margin-top:16px; padding-top:8px; }
.input-map input { width:100%; }
.input-unit { display:flex; align-items:center; gap:0; }
.input-unit input { border-top-right-radius:0; border-bottom-right-radius:0; flex:1; }
/* The unit lives inside the field: a price is where an order-of-magnitude slip
   is both easiest to make and most expensive. */
.input-unit .unit { border:1px solid var(--border); border-left:0; border-top-right-radius:6px; border-bottom-right-radius:6px; padding:8px 10px; color:var(--muted); background:#11141a; }

/* Overview tiles */
.tiles { display:grid; gap:16px; grid-template-columns:repeat(auto-fit,minmax(220px,1fr)); }
.tile .big { font-size:26px; margin:6px 0; }
#steps li { margin-bottom:10px; }

.sync-report { border-top:1px solid var(--border); padding-top:8px; margin-top:8px; font-size:12px; }
.sync-report h4 { margin:0 0 4px; }

/* The entry window over the journal. A native dialog: the table stays put
   underneath, Esc closes, and the browser handles focus. */
.detail-dialog { background:var(--card); color:var(--fg); border:1px solid var(--border);
  border-radius:10px; padding:18px; width:min(1200px, 96vw); max-height:92vh; overflow:auto; }
.detail-dialog::backdrop { background:rgba(0,0,0,.6); }
.dialog-head { align-items:center; }
.dialog-head h2 { margin:0; font-size:15px; }
/* ▲ ▼ next to the number: small, square, obviously a pair. */
.nav-btn { padding:4px 9px; font-size:12px; line-height:1; }
/* The pictures a run carried, under the head: which side each came from is
   written on it, because two photos of one run otherwise read the same. */
.thumbs { display:flex; gap:10px; flex-wrap:wrap; margin:4px 0 10px; }
.thumb { display:flex; flex-direction:column; gap:3px; text-decoration:none; color:var(--muted); font-size:11px; }
.thumb img { height:96px; width:auto; max-width:200px; object-fit:cover; border-radius:6px; border:1px solid var(--border); background:#11141a; }
.thumb:hover img { border-color:var(--accent); }

/* «Картинки»: a grid of cards, one picture each, the entry under it. */
.gallery { display:grid; gap:14px; grid-template-columns:repeat(auto-fill, minmax(220px, 1fr)); }
.shot { margin:0; background:#11141a; border:1px solid var(--border); border-radius:8px; overflow:hidden; display:flex; flex-direction:column; }
.shot-pic { display:block; aspect-ratio:1 / 1; overflow:hidden; min-height:0; background:#0c0e12; }
.shot-pic img { width:100%; height:100%; object-fit:contain; display:block; }
.shot figcaption { padding:8px 10px; font-size:12px; display:flex; flex-direction:column; gap:3px; }
.shot-head { display:flex; gap:8px; align-items:center; flex-wrap:wrap; }
.shot-head .chip { font-size:11px; padding:1px 7px; }
.shot-meta, .shot-text { overflow:hidden; text-overflow:ellipsis; }
.shot-meta { white-space:nowrap; font-size:11px; }
.shot-text { display:-webkit-box; -webkit-line-clamp:3; -webkit-box-orient:vertical; line-height:1.35; }

/* Spend screen: four different kinds of money, kept visibly apart. */
.totals-head { display:flex; gap:10px; align-items:baseline; margin-bottom:8px; }
.totals-head b { font-size:20px; }
.totals-list { list-style:none; padding:0; margin:0; font-size:12px; }
.totals-list li { display:grid; grid-template-columns:220px 130px 1fr auto; gap:10px; padding:2px 0; }
.spark { display:flex; align-items:flex-end; gap:2px; height:44px; margin:14px 0; }
.spark-bar { width:8px; background:var(--accent); opacity:.7; border-radius:2px 2px 0 0; }
.spark-bar:hover { opacity:1; }

/* Models: facets on the left, table, card on the right. */
.models-layout.three { grid-template-columns:220px minmax(0,1fr) 340px; }
@media (max-width:1400px) { .models-layout.three { grid-template-columns:200px minmax(0,1fr); } }
@media (max-width:1100px) { .models-layout.three { grid-template-columns:1fr; } }
.facets { font-size:12px; position:sticky; top:16px; }
.facet-group { margin-bottom:14px; }
.facet-group h4 { margin:0 0 6px; color:var(--muted); font-size:11px; text-transform:uppercase; }
.facet { display:grid; grid-template-columns:auto 1fr auto; gap:6px; align-items:center; padding:1px 0; }
.undo-bar { position:fixed; bottom:24px; left:24px; display:flex; gap:12px; align-items:center;
  background:#262b34; border:1px solid var(--border); padding:10px 16px; border-radius:8px; }
.work-list { margin:0; padding-left:18px; }
.work-list li { margin-bottom:4px; }
