:root {
  --bg: #f7f7f5;
  --panel: #ffffff;
  --border: #e2e0da;
  --border-strong: #cfccc3;
  --text: #23211c;
  --muted: #6f6a5f;
  --accent: #2f5d50;
  --accent-soft: #e8f0ed;
  --high: #a8342a;
  --high-soft: #fbeceb;
  --medium: #9a6410;
  --medium-soft: #fdf3e3;
  --info: #2f5d50;
  --info-soft: #e8f0ed;
  --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, monospace;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font: 14px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  color: var(--text);
  background: var(--bg);
}

header {
  display: flex; align-items: baseline; gap: 16px;
  padding: 12px 20px;
  background: var(--panel);
  border-bottom: 1px solid var(--border);
  position: sticky; top: 0; z-index: 20;
}
header h1 { font-size: 15px; margin: 0; font-weight: 600; letter-spacing: -0.01em; }
header .sub { color: var(--muted); font-size: 12px; }
header nav { margin-left: auto; display: flex; gap: 8px; }

button {
  font: inherit; cursor: pointer;
  border: 1px solid var(--border-strong); background: var(--panel);
  color: var(--text); border-radius: 6px; padding: 5px 11px;
}
button:hover:not(:disabled) { border-color: var(--accent); color: var(--accent); }
button:disabled { opacity: 0.45; cursor: not-allowed; }
button.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
button.primary:hover:not(:disabled) { background: #26483e; color: #fff; }
button.ghost { border-color: transparent; color: var(--muted); padding: 4px 7px; }
button.ghost:hover { background: var(--bg); }
button.danger { border-color: var(--high); color: var(--high); }
button.danger:hover:not(:disabled) { background: var(--high); border-color: var(--high); color: #fff; }

.layout { display: grid; grid-template-columns: 250px 1fr; min-height: calc(100vh - 49px); }

aside {
  border-right: 1px solid var(--border);
  background: var(--panel);
  padding: 14px; overflow-y: auto;
  max-height: calc(100vh - 49px); position: sticky; top: 49px;
}

.drop {
  border: 1.5px dashed var(--border-strong); border-radius: 8px;
  padding: 18px 12px; text-align: center; color: var(--muted);
  font-size: 12.5px; cursor: pointer; transition: 0.12s;
}
.drop:hover, .drop.over { border-color: var(--accent); background: var(--accent-soft); color: var(--accent); }

.doc-list { margin-top: 14px; display: flex; flex-direction: column; gap: 2px; }
.doc {
  padding: 7px 9px; border-radius: 6px; cursor: pointer;
  display: flex; flex-direction: column; gap: 2px;
}
.doc:hover { background: var(--bg); }
.doc.active { background: var(--accent-soft); }
.doc .name { font-size: 12.5px; font-weight: 500; word-break: break-all; }
.doc .meta { font-size: 11px; color: var(--muted); }
.doc-head { display: flex; gap: 4px; align-items: flex-start; }
.doc .del {
  border: 0; background: transparent; color: var(--muted);
  font-size: 15px; line-height: 1; padding: 1px 5px; border-radius: 4px; opacity: 0;
}
.doc:hover .del, .doc.active .del { opacity: 0.6; }
.doc .del:hover { opacity: 1; color: var(--high); background: var(--high-soft); }
@media (hover: none) { .doc .del { opacity: 0.6; } }
.doc.confirm { background: var(--high-soft); cursor: default; }
.doc.confirm .name { color: var(--high); }

main { padding: 18px 20px 60px; overflow-x: hidden; max-width: 1500px; }

.empty { color: var(--muted); padding: 60px 20px; text-align: center; }

.strip { display: flex; gap: 8px; overflow-x: auto; padding: 4px 0 10px; }
.thumb {
  flex: 0 0 auto; width: 74px; border: 2px solid transparent;
  border-radius: 6px; cursor: pointer; background: var(--panel); padding: 3px;
  position: relative;
}
.thumb img { width: 100%; display: block; border-radius: 3px; }
.thumb.active { border-color: var(--accent); }
.thumb .no { font-size: 10px; color: var(--muted); text-align: center; padding-top: 2px; }
.thumb .dot {
  position: absolute; top: 5px; right: 5px; width: 7px; height: 7px; border-radius: 50%;
}

.cols { display: grid; grid-template-columns: minmax(320px, 42%) 1fr; gap: 18px; align-items: start; }
@media (max-width: 1050px) { .cols { grid-template-columns: 1fr; } }

.card {
  background: var(--panel); border: 1px solid var(--border);
  border-radius: 8px; padding: 14px; margin-bottom: 14px;
}
.card h3 {
  margin: 0 0 10px; font-size: 12px; text-transform: uppercase;
  letter-spacing: 0.05em; color: var(--muted); font-weight: 600;
}

.viewer img { width: 100%; border-radius: 5px; border: 1px solid var(--border); display: block; }
.seg { display: inline-flex; border: 1px solid var(--border-strong); border-radius: 6px; overflow: hidden; }
.seg button { border: 0; border-radius: 0; padding: 4px 10px; font-size: 12.5px; background: var(--panel); }
.seg button.on { background: var(--accent); color: #fff; }
.seg button + button { border-left: 1px solid var(--border-strong); }

table.kv { width: 100%; border-collapse: collapse; font-size: 12.5px; }
table.kv td { padding: 3px 0; vertical-align: top; }
table.kv td:first-child { color: var(--muted); width: 52%; }
table.kv td:last-child { font-family: var(--mono); text-align: right; }

.score { font-size: 26px; font-weight: 600; font-family: var(--mono); line-height: 1; }
.score small { font-size: 12px; font-weight: 400; color: var(--muted); font-family: inherit; }

.note { border-radius: 6px; padding: 7px 10px; font-size: 12.5px; margin-bottom: 6px; }
.note.high { background: var(--high-soft); color: var(--high); }
.note.medium { background: var(--medium-soft); color: var(--medium); }
.note.info { background: var(--info-soft); color: var(--info); }
.note.low { background: var(--bg); color: var(--muted); }
.note code { font-family: var(--mono); font-size: 11.5px; }

.engines { display: flex; flex-direction: column; gap: 3px; margin-bottom: 12px; }
.eng { display: flex; align-items: flex-start; gap: 8px; padding: 5px 7px; border-radius: 6px; font-size: 13px; }
.eng:hover { background: var(--bg); }
.eng.off { opacity: 0.5; }
.eng input { margin-top: 3px; }
.eng .t { font-weight: 500; }
.eng .d { font-size: 11.5px; color: var(--muted); }
.eng .cloud { font-size: 10px; background: var(--medium-soft); color: var(--medium); padding: 1px 5px; border-radius: 3px; }

.tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--border); margin-bottom: 12px; flex-wrap: wrap; }
.tabs button {
  border: 0; border-bottom: 2px solid transparent; border-radius: 0;
  padding: 6px 11px; color: var(--muted); font-size: 13px;
}
.tabs button.on { color: var(--text); border-bottom-color: var(--accent); font-weight: 500; }
.tabs .badge { font-size: 10px; padding: 0 4px; border-radius: 3px; margin-left: 4px; }

.out { font-size: 13px; overflow-x: auto; }
.out table { border-collapse: collapse; margin: 10px 0; font-size: 12px; width: auto; }
.out th, .out td { border: 1px solid var(--border-strong); padding: 3px 7px; text-align: left; }
.out th { background: var(--bg); font-weight: 600; }
.out td.num, .out th.num { text-align: right; font-family: var(--mono); }
.out pre { white-space: pre-wrap; word-break: break-word; font-family: var(--mono); font-size: 12px; margin: 0; }
.out h1, .out h2, .out h3 { font-size: 14px; margin: 12px 0 6px; }

.matrix { border-collapse: collapse; font-size: 12px; font-family: var(--mono); }
.matrix th, .matrix td { border: 1px solid var(--border); padding: 4px 8px; text-align: right; }
.matrix th { background: var(--bg); font-weight: 500; text-align: left; }

.diff { font-size: 12.5px; line-height: 1.8; }
.diff .eq { color: var(--muted); }
.diff .del { background: var(--high-soft); color: var(--high); text-decoration: line-through; padding: 1px 2px; border-radius: 2px; }
.diff .ins { background: var(--info-soft); color: var(--info); padding: 1px 2px; border-radius: 2px; }

textarea {
  width: 100%; min-height: 300px; font-family: var(--mono); font-size: 12px;
  border: 1px solid var(--border-strong); border-radius: 6px; padding: 9px; resize: vertical;
}

.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.spacer { flex: 1; }
.muted { color: var(--muted); font-size: 12.5px; }
.mono { font-family: var(--mono); }

.toast {
  position: fixed; bottom: 18px; left: 50%; transform: translateX(-50%);
  background: var(--text); color: #fff; padding: 9px 16px; border-radius: 7px;
  font-size: 13px; z-index: 100; max-width: 80vw;
}
.toast.err { background: var(--high); }

.spin {
  display: inline-block; width: 11px; height: 11px; border: 2px solid var(--border-strong);
  border-top-color: var(--accent); border-radius: 50%; animation: sp 0.7s linear infinite;
}
@keyframes sp { to { transform: rotate(360deg); } }

.report { border-collapse: collapse; width: 100%; font-size: 12.5px; }
.report th, .report td { border-bottom: 1px solid var(--border); padding: 7px 9px; text-align: right; }
.report th { text-align: right; color: var(--muted); font-weight: 600; font-size: 11.5px;
             text-transform: uppercase; letter-spacing: 0.04em; }
.report th:first-child, .report td:first-child { text-align: left; }
.report td { font-family: var(--mono); }
.report td:first-child { font-family: inherit; font-weight: 500; }
.report tr:hover td { background: var(--bg); }

/* --- вердикт маршрутизации и очередь проверки --- */

.verdict {
  border-left: 3px solid var(--border);
  background: var(--bg);
  border-radius: 0 6px 6px 0;
  padding: 8px 11px;
  margin-bottom: 12px;
}
.verdict.ok { border-left-color: var(--accent); }
.verdict.medium { border-left-color: var(--medium); }
.verdict.high { border-left-color: var(--high); }
.verdict .reasons {
  margin: 5px 0 0;
  padding-left: 18px;
  font-size: 11.5px;
  color: var(--muted);
}
.verdict .reasons li { margin-top: 2px; }

.tag {
  font-size: 10.5px;
  padding: 1px 6px;
  border-radius: 9px;
  background: var(--border);
  color: var(--muted);
}

.queue { display: flex; flex-direction: column; gap: 6px; }
.queue-row {
  border: 1px solid var(--border);
  border-left-width: 3px;
  border-radius: 0 6px 6px 0;
  padding: 9px 11px;
  cursor: pointer;
  background: var(--panel);
}
.queue-row:hover { border-color: var(--accent); }
.queue-row.ok { border-left-color: var(--accent); }
.queue-row.medium { border-left-color: var(--medium); }
.queue-row.high { border-left-color: var(--high); }

/* --- полоса состояния: что считается прямо сейчас --- */

.progress {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 60;
  background: var(--panel); border-top: 1px solid var(--border);
  box-shadow: 0 -2px 10px rgba(0, 0, 0, 0.05);
  padding: 7px 16px; display: flex; flex-direction: column; gap: 5px;
  max-height: 40vh; overflow-y: auto;
}
.job { display: flex; align-items: center; gap: 10px; font-size: 12.5px; }
.job .job-text { width: 30%; min-width: 150px; max-width: 330px; }
.job .job-name { font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.job .job-sub { font-size: 11px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.job .job-meta { font-size: 11.5px; color: var(--muted); white-space: nowrap; }
.job .mark { font-weight: 600; width: 11px; text-align: center; }
.job .mark.ok { color: var(--accent); }
.job .mark.bad { color: var(--high); }

.track {
  flex: 1; min-width: 60px; height: 6px; border-radius: 4px;
  background: var(--bg); border: 1px solid var(--border); overflow: hidden;
}
.track i { display: block; height: 100%; width: 0; background: var(--accent); transition: width 0.3s; }
.track.err i { background: var(--high); }
.track.wait i { width: 28%; animation: slide 1.2s ease-in-out infinite; }
@keyframes slide { from { margin-left: -28%; } to { margin-left: 100%; } }

/* Полоса перекрывает низ страницы — освобождаем его, пока она видна. */
body.has-progress main { padding-bottom: 96px; }
body.has-progress .toast { bottom: 76px; }
