:root {
  --bg: #f5f4f2; --card: #ffffff; --fg: #17171a; --muted: #6b6b72; --line: #e4e2de;
  --accent: #ff3d00; --accent-fg: #ffffff; --ok: #1d7a46; --warn: #a15c00; --bad: #b42318;
  --warn-bg: #fff4e0; --bad-bg: #fdecea; --ok-bg: #e8f5ee;
  --radius: 12px; --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}
@media (prefers-color-scheme: dark) {
  :root { --bg: #121214; --card: #1c1c20; --fg: #ececf0; --muted: #9a9aa3; --line: #2e2e34; --warn-bg: #3a2a10; --bad-bg: #3a1614; --ok-bg: #11301f; }
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--fg); font: 15px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; }
a { color: var(--accent); }
header.top { display: flex; justify-content: space-between; align-items: center; padding: 12px 20px; background: var(--card); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 5; }
.brand { font-weight: 800; text-decoration: none; color: var(--fg); }
.brand span { font-weight: 500; color: var(--muted); margin-left: 6px; }
main { max-width: 1180px; margin: 0 auto; padding: 16px; display: grid; gap: 16px; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px 20px; }
.card.narrow { max-width: 420px; margin: 8vh auto; }
h1 { font-size: 22px; margin: 0 0 4px; } h2 { font-size: 17px; margin: 0 0 10px; } h3 { font-size: 15px; margin: 16px 0 8px; }
.section-h { margin: 8px 0; }
details > summary { cursor: pointer; list-style: none; display: flex; gap: 10px; align-items: baseline; }
details > summary h2 { display: inline; margin: 0; }
details > summary::before { content: "▸"; color: var(--muted); } details[open] > summary::before { content: "▾"; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; } .between { justify-content: space-between; } .grow { flex: 1; min-width: 200px; }
.stack { display: grid; gap: 10px; }
.grid2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px 16px; }
.grid3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px; }
.span2 { grid-column: span 2; }
.form label, label { display: grid; gap: 4px; font-size: 13px; color: var(--muted); }
input, select, textarea { font: inherit; color: var(--fg); background: var(--bg); border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; width: 100%; }
input[type=checkbox] { width: auto; }
textarea { resize: vertical; }
button { font: inherit; font-weight: 600; border: 1px solid var(--line); background: var(--card); color: var(--fg); border-radius: 8px; padding: 8px 14px; cursor: pointer; }
button.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-fg); }
button.ghost { background: transparent; }
button.link { border: 0; background: none; color: var(--muted); padding: 0; }
button[disabled] { opacity: .45; cursor: not-allowed; }
.htmx-request button, button.htmx-request { opacity: .6; }
.table { width: 100%; border-collapse: collapse; }
.table th, .table td { text-align: left; padding: 6px 8px; border-bottom: 1px solid var(--line); vertical-align: top; }
.table tr.blocked td { opacity: .6; }
.muted { color: var(--muted); } .small { font-size: 13px; } .mono { font-family: var(--mono); font-size: 12px; }
.chip { display: inline-block; font-size: 12px; font-weight: 600; padding: 1px 8px; border-radius: 999px; background: var(--ok-bg); color: var(--ok); white-space: nowrap; }
.chip.warn { background: var(--warn-bg); color: var(--warn); } .chip.bad { background: var(--bad-bg); color: var(--bad); }
.error { color: var(--bad); } .warn-t { color: var(--warn); } .ok-t { color: var(--ok); font-weight: 700; }
.flash { position: fixed; bottom: 16px; right: 16px; max-width: min(520px, calc(100vw - 32px)); z-index: 10; }
.msg { padding: 10px 14px; border-radius: 10px; box-shadow: 0 6px 24px rgba(0,0,0,.15); white-space: pre-wrap; }
.ok-box { background: var(--ok-bg); color: var(--ok); } .error-box { background: var(--bad-bg); color: var(--bad); }
.stages { list-style: none; padding: 0; margin: 0; display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 10px; }
.stage { border: 1px solid var(--line); border-radius: 10px; padding: 10px; display: grid; gap: 6px; align-content: start; }
.stage.done { border-color: color-mix(in srgb, var(--ok) 40%, var(--line)); }
.stage.failed { border-color: var(--bad); } .stage.stale { border-style: dashed; border-color: var(--warn); }
.stage.running, .stage.queued { border-color: var(--accent); }
.dot { display: inline-block; width: 10px; height: 10px; border-radius: 50%; background: var(--line); margin-right: 4px; }
.dot.done { background: var(--ok); } .dot.failed { background: var(--bad); } .dot.running, .dot.queued { background: var(--accent); } .dot.stale { background: var(--warn); }
.spinner { display: inline-block; width: 10px; height: 10px; border: 2px solid var(--accent); border-right-color: transparent; border-radius: 50%; animation: spin .8s linear infinite; vertical-align: -1px; }
@keyframes spin { to { transform: rotate(360deg); } }
.thumb { width: 72px; height: 72px; object-fit: contain; background: #fff; border: 1px solid var(--line); border-radius: 6px; }
.palette { display: flex; flex-wrap: wrap; gap: 8px; margin: 8px 0; }
.swatch { display: inline-flex; gap: 6px; align-items: center; font-size: 12px; border: 1px solid var(--line); border-radius: 999px; padding: 2px 10px 2px 2px; }
.swatch i { width: 20px; height: 20px; border-radius: 50%; border: 1px solid var(--line); display: inline-block; }
.plan-card { border: 1px solid var(--line); border-radius: 10px; padding: 12px; display: grid; gap: 8px; align-content: start; }
.post-grid { display: grid; grid-template-columns: 380px minmax(0, 1fr); gap: 20px; margin-top: 8px; }
img.phone { width: 360px; max-width: 100%; aspect-ratio: 1080 / 1350; border-radius: 18px; border: 1px solid var(--line); box-shadow: 0 6px 24px rgba(0,0,0,.12); display: block; }
.ref { margin-top: 10px; display: flex; gap: 10px; align-items: center; }
pre.caption { white-space: pre-wrap; font: 14px/1.5 system-ui, sans-serif; background: var(--bg); border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; margin: 0; }
.review { border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; }
.review ul.checks { padding-left: 0; list-style: none; } .findings { padding-left: 18px; }
details.edit { margin-top: 12px; border-top: 1px solid var(--line); padding-top: 10px; }
ul.log { list-style: none; padding: 0; margin: 0; max-height: 220px; overflow: auto; }
code { font-family: var(--mono); font-size: 13px; }
@media (max-width: 860px) {
  .grid2, .grid3, .post-grid { grid-template-columns: 1fr; } .span2 { grid-column: auto; }
  .stages { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  main { padding: 12px 16px; }
  .table { display: block; overflow-x: auto; }
}

/* checkbox labels: box and text on one line */
label:has(> input[type=checkbox]) { display: flex; flex-direction: row-reverse; justify-content: flex-end; align-items: center; gap: 8px; color: var(--fg); }

/* per-row edit panels in source/asset tables */
details.row-edit > summary { font-size: 13px; color: var(--accent); }
details.row-edit[open] { min-width: 260px; }
details.row-edit form { margin-top: 8px; }
button.danger { background: transparent; color: var(--bad); border-color: var(--bad); }

/* busy feedback: any htmx form in flight shows a spinner on its button and blocks a second click */
form.htmx-request button { pointer-events: none; opacity: .75; cursor: progress; }
form.htmx-request button::after { content: ""; display: inline-block; width: 10px; height: 10px; margin-left: 8px; border: 2px solid currentColor; border-right-color: transparent; border-radius: 50%; animation: spin .8s linear infinite; vertical-align: -1px; }
/* upload progress */
.upload-progress { display: flex; align-items: center; gap: 10px; }
.upload-progress[hidden] { display: none; }
.upload-progress progress { width: 220px; height: 10px; accent-color: var(--accent); }

/* read-only view for runs the reviewer does not own: hide every form, keep links and downloads */
.readonly form { display: none !important; }
.readonly-note { border-color: var(--warn); background: var(--warn-bg); color: var(--warn); }

/* ===================== v2 layout: stepper, tabs, folds, help ===================== */
[hidden] { display: none !important; }
main { gap: 14px; }
.run-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 12px; padding: 4px 2px 0; }
.run-head h1 { margin: 0; }
.lead { font-size: 15px; line-height: 1.6; }
.actions { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin-top: 12px; }
.form { display: grid; gap: 12px; }
.small-btn { padding: 5px 10px; font-size: 13px; }
button.big { padding: 11px 18px; font-size: 15px; }
.clamp { overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.empty { text-align: center; padding: 32px 20px; }
.empty h2 { margin-bottom: 6px; }

/* stepper */
.stepper { padding: 14px 16px; }
.steps { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px; }
.step { position: relative; border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; display: grid; gap: 6px; align-content: start; }
.step-head { display: flex; gap: 10px; align-items: center; color: var(--fg); text-decoration: none; }
.step-head:hover strong { text-decoration: underline; }
.step-n { flex: none; width: 26px; height: 26px; border-radius: 50%; display: grid; place-items: center; font-weight: 700; font-size: 13px; background: var(--line); color: var(--fg); }
.step-tool { display: block; }
.step.done { border-color: color-mix(in srgb, var(--ok) 45%, var(--line)); }
.step.done .step-n { background: var(--ok); color: #fff; }
.step.running { border-color: var(--accent); }
.step.running .step-n { background: var(--accent); color: #fff; }
.step.failed { border-color: var(--bad); }
.step.failed .step-n { background: var(--bad); color: #fff; }
.step.stale { border-style: dashed; border-color: var(--warn); }
.step.stale .step-n { background: var(--warn); color: #fff; }
.next-step { margin: 12px 0 0; font-size: 14px; }
.next-step a { color: var(--fg); font-weight: 600; }

/* tabs */
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); overflow-x: auto; scrollbar-width: thin; position: sticky; top: 49px; z-index: 4; background: var(--bg); padding-top: 4px; }
.tabs button { border: 0; border-bottom: 3px solid transparent; border-radius: 0; background: none; padding: 10px 14px; color: var(--muted); white-space: nowrap; }
.tabs button:hover { color: var(--fg); }
.tabs button.active { color: var(--fg); border-bottom-color: var(--accent); }
.tab-badge { display: inline-block; min-width: 18px; padding: 0 6px; margin-left: 4px; border-radius: 999px; background: var(--line); color: var(--fg); font-size: 11px; line-height: 18px; text-align: center; }
.tab-panel { display: grid; gap: 14px; }
.grid-main { display: grid; grid-template-columns: minmax(0, 3fr) minmax(0, 2fr); gap: 14px; align-items: start; }

/* inline help (?) */
details.help { display: inline-block; position: relative; vertical-align: middle; font-size: 13px; font-weight: 400; }
details.help > summary { list-style: none; cursor: pointer; width: 20px; height: 20px; border-radius: 50%; border: 1px solid var(--line); display: grid; place-items: center; color: var(--muted); font-weight: 700; font-size: 12px; }
details.help > summary::-webkit-details-marker { display: none; }
details.help > summary::before { content: none; }
details.help[open] > summary { background: var(--accent); border-color: var(--accent); color: #fff; }
details.help .help-body { position: absolute; z-index: 20; top: 26px; left: -8px; width: min(340px, 80vw); background: var(--card); color: var(--fg); border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; box-shadow: 0 10px 30px rgba(0,0,0,.18); line-height: 1.5; }
details.help-inline > summary { font-size: 13px; color: var(--accent); }
details.help-inline > summary::before { content: none; }

/* folds */
details.fold { border-top: 1px solid var(--line); padding: 10px 0 2px; }
details.fold:first-child { border-top: 0; }
details.fold > summary { display: flex; gap: 8px; align-items: baseline; padding: 2px 0; }
details.fold > .fold-body { padding: 10px 0 6px; display: grid; gap: 10px; }
.form details.fold { margin: 0; }

/* colour inputs with swatch */
.color-field { display: flex; gap: 8px; align-items: center; }
.color-field i { flex: none; width: 28px; height: 28px; border-radius: 6px; border: 1px solid var(--line); }

/* assets as cards */
.assets { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 12px; }
.asset { border: 1px solid var(--line); border-radius: 10px; overflow: hidden; display: grid; grid-template-rows: 140px auto; }
.asset.approved { border-color: color-mix(in srgb, var(--ok) 50%, var(--line)); }
.asset img { width: 100%; height: 140px; object-fit: contain; background: #fff; display: block; }
.asset-meta { padding: 10px; display: grid; gap: 8px; }
.table-wrap { overflow-x: auto; }

/* posts */
.summary-bar { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; padding: 12px 16px; }
.post-head { display: flex; justify-content: space-between; align-items: center; gap: 10px; flex-wrap: wrap; }
.post-head h3 { margin: 0; }
.post-grid { grid-template-columns: 360px minmax(0, 1fr); }
figure { margin: 0; display: grid; gap: 6px; }
.post-actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.post-actions form { display: flex; gap: 8px; align-items: center; }
.post-actions form.approve { flex: 1; min-width: 260px; }
.post-actions form.approve input { flex: 1; }
.plan-card h3 { margin: 4px 0; }

/* delivery */
.checklist { list-style: none; padding: 0; margin: 0 0 12px; display: grid; gap: 8px; }
.checklist li { display: flex; gap: 10px; align-items: center; }
.checklist .tick { flex: none; width: 22px; height: 22px; border-radius: 50%; border: 2px solid var(--line); display: grid; place-items: center; font-size: 13px; font-weight: 700; }
.checklist li.done .tick { background: var(--ok); border-color: var(--ok); color: #fff; }
.checklist li.done { color: var(--muted); }
.busy-note { margin: 8px 0 0; }
.exports { list-style: none; padding: 0; display: grid; gap: 8px; }
.button-link { display: inline-block; padding: 5px 12px; border-radius: 8px; border: 1px solid var(--line); text-decoration: none; color: var(--fg); font-weight: 600; font-size: 13px; }
.button-link.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-fg); }
.narrow-field { width: 110px; }
ul.log { max-height: none; }

@media (max-width: 860px) {
  .steps { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .grid-main, .post-grid { grid-template-columns: 1fr; }
  .tabs { top: 0; }
  .run-head { flex-direction: column; align-items: flex-start; }
}

/* checkerboard behind asset thumbnails so transparency is visible */
.asset img { background-color: #fff; background-image: linear-gradient(45deg, #e6e6e6 25%, transparent 25%), linear-gradient(-45deg, #e6e6e6 25%, transparent 25%), linear-gradient(45deg, transparent 75%, #e6e6e6 75%), linear-gradient(-45deg, transparent 75%, #e6e6e6 75%); background-size: 16px 16px; background-position: 0 0, 0 8px, 8px -8px, -8px 0; }

/* post card v3: per-post steps and numbered blocks */
.post-steps { list-style: none; margin: 4px 0 6px; padding: 0; display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.post-steps li { display: flex; gap: 10px; align-items: center; border: 1px solid var(--line); border-radius: 10px; padding: 8px 10px; }
.post-steps li > span:last-child { display: grid; }
.post-steps .n, .step-label .n { flex: none; width: 24px; height: 24px; border-radius: 50%; display: grid; place-items: center; font-weight: 700; font-size: 12px; background: var(--line); color: var(--fg); }
.post-steps small { display: block; color: var(--muted); font-size: 12px; }
.post-steps li.done { border-color: color-mix(in srgb, var(--ok) 45%, var(--line)); }
.post-steps li.done .n { background: var(--ok); color: #fff; }
.post-steps li.warn { border-color: var(--warn); } .post-steps li.warn .n { background: var(--warn); color: #fff; }
.post-steps li.bad { border-color: var(--bad); } .post-steps li.bad .n { background: var(--bad); color: #fff; }
.post-steps li.busy { border-color: var(--accent); } .post-steps li.busy .n { background: var(--accent); color: #fff; }
.post-figure { position: sticky; top: 110px; align-self: start; }
.post-step-block { border: 1px solid var(--line); border-radius: 12px; padding: 12px 14px; display: grid; gap: 10px; }
.post-step-block details.fold { border-top: 0; padding-top: 0; }
.step-label { display: flex; gap: 8px; align-items: center; font-weight: 700; }
.approve-row { display: flex; gap: 8px; align-items: center; }
.approve-row input { flex: 1; }
.post-busy { display: flex; gap: 10px; align-items: center; padding: 10px 12px; border-radius: 10px; background: color-mix(in srgb, var(--accent) 10%, var(--card)); border: 1px solid var(--accent); font-weight: 600; }
.flash-highlight { animation: hl 1.6s ease-out; }
@keyframes hl { 0% { box-shadow: 0 0 0 4px var(--accent); } 100% { box-shadow: 0 0 0 0 transparent; } }
@media (max-width: 860px) { .post-steps { grid-template-columns: 1fr; } .post-figure { position: static; } }

/* proposal from review findings */
.proposal { border: 1px solid var(--accent); border-radius: 12px; padding: 12px 14px; display: grid; gap: 12px; background: color-mix(in srgb, var(--accent) 5%, var(--card)); }
.proposal label.change { display: grid; gap: 6px; color: var(--fg); border-top: 1px solid var(--line); padding-top: 10px; }
.change-head { display: flex; gap: 8px; align-items: baseline; flex-wrap: wrap; }
.diff { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.diff del, .diff ins { white-space: pre-wrap; text-decoration: none; padding: 8px 10px; border-radius: 8px; font-size: 13px; line-height: 1.45; }
.diff del { background: var(--bad-bg); color: var(--fg); }
.diff ins { background: var(--ok-bg); color: var(--fg); }
.diff del::before { content: "Prije"; display: block; font-size: 11px; font-weight: 700; color: var(--bad); margin-bottom: 4px; }
.diff ins::before { content: "Poslije"; display: block; font-size: 11px; font-weight: 700; color: var(--ok); margin-bottom: 4px; }
@media (max-width: 860px) { .diff { grid-template-columns: 1fr; } }

.share { display: flex; gap: 8px; align-items: center; margin-top: 6px; }
.share input { flex: 1; font-family: var(--mono); font-size: 12px; }
.exports li { display: grid; gap: 4px; }
