/* Salesbox Shelf IR — демо. Светлая и тёмная темы через токены. */
:root {
  --bg: #f4f5f7; --surface: #ffffff; --surface-2: #f0f1f4; --line: #e3e5ea;
  --text: #15181d; --muted: #6b7280; --accent: #2f6fed; --accent-ink: #ffffff;
  --ok: #1f9d55; --bad: #d64545; --warn: #d9900f; --info: #5b6bf5;
  --shadow: 0 1px 2px rgba(16, 24, 40, .06), 0 8px 24px -12px rgba(16, 24, 40, .18);
  --radius: 14px; --mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
}
:root[data-theme="dark"] {
  --bg: #0f1115; --surface: #171a21; --surface-2: #1f232c; --line: #2a2f3a;
  --text: #e8eaee; --muted: #8b93a1; --accent: #5b8def; --accent-ink: #0b0d12;
  --ok: #34c37a; --bad: #ef5f5f; --warn: #f0ad2d; --info: #8b96ff;
  --shadow: 0 1px 2px rgba(0, 0, 0, .4), 0 12px 32px -16px rgba(0, 0, 0, .7);
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0f1115; --surface: #171a21; --surface-2: #1f232c; --line: #2a2f3a;
    --text: #e8eaee; --muted: #8b93a1; --accent: #5b8def; --accent-ink: #0b0d12;
    --ok: #34c37a; --bad: #ef5f5f; --warn: #f0ad2d; --info: #8b96ff;
    --shadow: 0 1px 2px rgba(0, 0, 0, .4), 0 12px 32px -16px rgba(0, 0, 0, .7);
  }
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--text);
  font: 15px/1.5 -apple-system, "Inter", "Segoe UI", Roboto, system-ui, sans-serif; }
a { color: inherit; text-decoration: none; }
button { font: inherit; cursor: pointer; border: 1px solid var(--line); background: var(--surface);
  color: var(--text); border-radius: 10px; padding: 9px 14px; transition: background .15s, transform .05s; }
button:hover { background: var(--surface-2); }
button:active { transform: translateY(1px); }
button:disabled { opacity: .5; cursor: default; }
button.primary { background: var(--accent); color: var(--accent-ink); border-color: transparent; font-weight: 600; }
button.primary:hover { filter: brightness(1.07); background: var(--accent); }
button.ghost { background: transparent; }
button.link { background: none; border: 0; padding: 0; color: var(--accent); font-weight: 500; }
input, select { font: inherit; color: var(--text); background: var(--surface); border: 1px solid var(--line);
  border-radius: 10px; padding: 8px 10px; min-width: 0; }
input:focus, select:focus { outline: 2px solid color-mix(in srgb, var(--accent) 45%, transparent); outline-offset: 1px; }
.muted { color: var(--muted); } .small { font-size: 13px; } .mono { font-family: var(--mono); }
[hidden] { display: none !important; }

/* ── шапка ── */
.top { position: sticky; top: 0; z-index: 10; display: flex; align-items: center; gap: 24px; padding: 12px 24px;
  background: color-mix(in srgb, var(--surface) 88%, transparent); backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line); }
.brand { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 17px; }
.brand small { font-weight: 500; color: var(--muted); margin-left: 8px; font-size: 12px; }
.logo { width: 26px; height: 26px; border-radius: 8px;
  background: linear-gradient(135deg, var(--accent), var(--info)); box-shadow: inset 0 0 0 2px rgba(255,255,255,.25); }
.tabs { display: flex; gap: 4px; }
.tabs a { padding: 7px 12px; border-radius: 9px; color: var(--muted); font-weight: 500; }
.tabs a.active { background: var(--surface-2); color: var(--text); }
.top-right { margin-left: auto; display: flex; gap: 6px; }

/* ── страницы ── */
main { max-width: 1180px; margin: 0 auto; padding: 24px 16px 60px; display: grid; gap: 16px; }
.hero h1 { font-size: 26px; margin: 8px 0 6px; letter-spacing: -.01em; }
.hero p { margin: 0; max-width: 720px; }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px 20px; box-shadow: var(--shadow); }
.row { display: flex; align-items: center; gap: 12px; } .row.between { justify-content: space-between; }
.row.end { justify-content: flex-end; } .row.center { justify-content: center; } .row.wrap { flex-wrap: wrap; } .gap { gap: 14px; }
.field { display: grid; gap: 4px; font-size: 13px; color: var(--muted); }
.field input, .field select { color: var(--text); }
.meta-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 12px; margin: 14px 0; }

/* ── загрузка ── */
.drop { border: 2px dashed var(--line); text-align: center; padding: 36px 20px; transition: border-color .15s, background .15s; }
.drop.over { border-color: var(--accent); background: color-mix(in srgb, var(--accent) 6%, var(--surface)); }
.drop-icon { font-size: 34px; color: var(--accent); margin-bottom: 8px; }
.drop-preview img { max-height: 380px; max-width: 100%; border-radius: 10px; }
.preview-meta { display: flex; justify-content: center; gap: 14px; margin-top: 10px; color: var(--muted); font-size: 13px; }

/* ── прогресс ── */
.progress-head { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 10px; }
.bar { height: 6px; border-radius: 6px; background: var(--surface-2); overflow: hidden; }
.bar-fill { height: 100%; width: 0; background: linear-gradient(90deg, var(--accent), var(--info)); transition: width .4s ease; }
.timeline { list-style: none; margin: 18px 0 0; padding: 0; display: grid; gap: 0; }
.step { display: grid; grid-template-columns: 28px 1fr auto; gap: 12px; align-items: start; padding: 10px 0; position: relative; }
.step + .step::before { content: ""; position: absolute; left: 13px; top: -14px; height: 24px; border-left: 2px solid var(--line); }
.dot { width: 26px; height: 26px; border-radius: 50%; border: 2px solid var(--line); display: grid; place-items: center;
  font-size: 13px; color: var(--muted); background: var(--surface); transition: all .25s; }
.step.running .dot { border-color: var(--accent); color: var(--accent); animation: pulse 1.1s ease-in-out infinite; }
.step.done .dot { border-color: var(--ok); background: var(--ok); color: #fff; }
.step.skipped .dot { border-style: dashed; }
.step.failed .dot { border-color: var(--bad); background: var(--bad); color: #fff; }
@keyframes pulse { 0%, 100% { box-shadow: 0 0 0 0 color-mix(in srgb, var(--accent) 40%, transparent); } 50% { box-shadow: 0 0 0 7px transparent; } }
.step-name { font-weight: 600; } .step-sum { color: var(--muted); font-size: 13px; }
.step-ms { color: var(--muted); font-size: 13px; font-variant-numeric: tabular-nums; }

/* ── результат ── */
.grid { display: grid; gap: 16px; grid-template-columns: 1fr; }
@media (min-width: 900px) { .grid.two { grid-template-columns: 1.4fr 1fr; } .grid.three { grid-template-columns: repeat(3, 1fr); } }
.verdict { display: flex; gap: 20px; align-items: center; flex-wrap: wrap; }
.verdict .status { font-size: 30px; font-weight: 800; letter-spacing: -.02em; }
.verdict.approved .status { color: var(--ok); } .verdict.not_approved .status { color: var(--bad); } .verdict.retake .status { color: var(--warn); }
.ring { --p: 0; --c: var(--accent); width: 86px; height: 86px; border-radius: 50%; display: grid; place-items: center; font-weight: 700;
  background: conic-gradient(var(--c) calc(var(--p) * 1%), var(--surface-2) 0); position: relative; }
.ring::after { content: ""; position: absolute; inset: 9px; border-radius: 50%; background: var(--surface); }
.ring span { position: relative; z-index: 1; font-size: 15px; }
.ring-wrap { display: grid; justify-items: center; gap: 4px; font-size: 12px; color: var(--muted); }
.reasons { display: flex; gap: 6px; flex-wrap: wrap; }
.chip { font-size: 12px; padding: 3px 9px; border-radius: 999px; background: var(--surface-2); color: var(--muted); }
.chip.bad { background: color-mix(in srgb, var(--bad) 14%, transparent); color: var(--bad); }
.chip.warn { background: color-mix(in srgb, var(--warn) 16%, transparent); color: var(--warn); }
.notice { border-left: 4px solid var(--warn); padding: 10px 14px; background: color-mix(in srgb, var(--warn) 10%, var(--surface)); border-radius: 8px; }

.stage { position: relative; background: #0b0d12; border-radius: 12px; overflow: hidden; }
.stage img { display: block; width: 100%; height: auto; }
.stage canvas { position: absolute; inset: 0; width: 100%; height: 100%; }
.layers { display: flex; gap: 10px; flex-wrap: wrap; margin: 10px 0 0; font-size: 13px; }
.layers label { display: flex; align-items: center; gap: 6px; cursor: pointer; }
.tip { position: absolute; pointer-events: none; background: color-mix(in srgb, var(--surface) 95%, transparent); border: 1px solid var(--line);
  border-radius: 8px; padding: 6px 9px; font-size: 12px; box-shadow: var(--shadow); max-width: 260px; z-index: 2; }
.tip b { display: block; }

.bars { display: grid; gap: 7px; }
.bar-row { display: grid; grid-template-columns: 110px 1fr 36px; align-items: center; gap: 10px; font-size: 13px; }
.bar-row .track { height: 10px; border-radius: 6px; background: var(--surface-2); overflow: hidden; }
.bar-row .fill { height: 100%; border-radius: 6px; }
.bar-row .n { text-align: right; font-variant-numeric: tabular-nums; }

table { width: 100%; border-collapse: collapse; font-size: 13px; }
th, td { text-align: left; padding: 7px 8px; border-bottom: 1px solid var(--line); vertical-align: top; }
th { color: var(--muted); font-weight: 600; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
tr.diff td { background: color-mix(in srgb, var(--bad) 8%, transparent); }
.slot { display: inline-block; width: 10px; height: 14px; border-radius: 3px; margin-right: 2px; vertical-align: middle; }
.slot.ok { background: var(--ok); } .slot.missing { background: var(--bad); } .slot.misplaced, .slot.wrong_shelf { background: var(--warn); }
.slot.extra { background: var(--info); } .slot.needs_review { background: var(--muted); }

.timing { display: flex; height: 12px; border-radius: 6px; overflow: hidden; background: var(--surface-2); }
.timing span { height: 100%; } .legend { display: flex; gap: 14px; flex-wrap: wrap; font-size: 12px; color: var(--muted); margin-top: 8px; }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 2px; margin-right: 5px; vertical-align: -1px; }
.kv { display: grid; grid-template-columns: auto 1fr; gap: 4px 14px; font-size: 13px; }
.kv dt { color: var(--muted); } .kv dd { margin: 0; }

details.raw summary { cursor: pointer; font-weight: 600; }
pre.json { max-height: 420px; overflow: auto; background: var(--surface-2); border-radius: 10px; padding: 12px; font: 12px/1.45 var(--mono); }
.j-k { color: var(--info); } .j-s { color: var(--ok); } .j-n { color: var(--warn); } .j-b { color: var(--bad); }

/* ── история ── */
.history { display: grid; gap: 10px; }
.h-item { display: grid; grid-template-columns: 84px 1fr auto; gap: 14px; align-items: center; padding: 10px 12px; cursor: pointer; transition: background .15s; }
.h-item:hover { background: var(--surface-2); }
.h-item img { width: 84px; height: 64px; object-fit: cover; border-radius: 8px; background: var(--surface-2); }
.h-item .h-main { display: grid; gap: 2px; }
.h-item .h-meta { font-size: 12px; color: var(--muted); }
.pill { font-size: 12px; font-weight: 600; padding: 4px 10px; border-radius: 999px; }
.pill.approved { background: color-mix(in srgb, var(--ok) 16%, transparent); color: var(--ok); }
.pill.not_approved { background: color-mix(in srgb, var(--bad) 14%, transparent); color: var(--bad); }
.pill.retake { background: color-mix(in srgb, var(--warn) 16%, transparent); color: var(--warn); }
.pill.processing { background: var(--surface-2); color: var(--muted); } .pill.failed { background: color-mix(in srgb, var(--bad) 14%, transparent); color: var(--bad); }

.toast { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); background: var(--text); color: var(--bg);
  padding: 10px 16px; border-radius: 10px; box-shadow: var(--shadow); z-index: 20; font-size: 14px; }
h2 { font-size: 15px; margin: 0 0 10px; color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: .04em; }
