/* Панель администратора core-api. Без внешних шрифтов и скриптов: всё, что
   нужно странице, отдаёт сам сервис. Цвета — токенами, тёмная тема — по
   настройке системы. */

:root {
  --bg: #f5f6f8;
  --panel: #ffffff;
  --text: #1a1d23;
  --muted: #5f6b7a;
  --line: #e2e5ea;
  --hover: #f0f2f5;
  --accent: #2b59c3;
  --accent-soft: #e8eefc;
  --on-accent: #ffffff;
  --ok: #1e7f4f;
  --ok-soft: #e2f3e9;
  --warn: #8f5b00;
  --warn-soft: #fdf0d8;
  --bad: #b42318;
  --bad-soft: #fde7e5;
  --info: #1d5fa8;
  --info-soft: #e2eefb;
  --violet: #6941c6;
  --violet-soft: #efe9fb;
  --gray-soft: #eceff3;
  --radius: 10px;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f1116;
    --panel: #171a21;
    --text: #e6e8ec;
    --muted: #9aa4b2;
    --line: #2a2f3a;
    --hover: #1e222b;
    --accent: #8aa8ff;
    --accent-soft: #1d2740;
    --on-accent: #0f1116;
    --ok: #5ccf8e;
    --ok-soft: #13291d;
    --warn: #f0b555;
    --warn-soft: #2e2413;
    --bad: #ff8a80;
    --bad-soft: #341a19;
    --info: #7db7ff;
    --info-soft: #152538;
    --violet: #b69cff;
    --violet-soft: #241d38;
    --gray-soft: #232833;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }

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

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

h1 { font-size: 24px; line-height: 1.25; margin: 0; }
h2 { font-size: 16px; margin: 0 0 10px; }

/* --- шапка -------------------------------------------------------------- */

.top {
  display: flex;
  align-items: center;
  gap: 24px;
  padding: 0 24px;
  min-height: 56px;
  background: var(--panel);
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: 0;
  z-index: 1;
}
.brand { font-weight: 650; color: var(--text); white-space: nowrap; }
.brand span { color: var(--muted); font-weight: 400; }
.brand:hover { text-decoration: none; }
.top nav { display: flex; gap: 4px; flex-wrap: wrap; }
.top nav a { padding: 6px 12px; border-radius: 8px; color: var(--muted); }
.top nav a:hover { background: var(--hover); text-decoration: none; }
.top nav a.on { background: var(--accent-soft); color: var(--accent); font-weight: 550; }
.who { margin-left: auto; color: var(--muted); font-size: 13px; }

main { max-width: 1200px; margin: 0 auto; padding: 24px; }
footer { max-width: 1200px; margin: 0 auto; padding: 0 24px 32px; color: var(--muted); font-size: 13px; }

.head { display: flex; align-items: center; gap: 10px 12px; flex-wrap: wrap; margin-bottom: 16px; }
.crumbs { margin: 0 0 8px; font-size: 14px; }
.lead { color: var(--muted); margin: -4px 0 18px; max-width: 80ch; }
.note { color: var(--muted); font-size: 13px; margin: 8px 0 0; max-width: 80ch; }
.muted { color: var(--muted); }
.sub { color: var(--muted); font-size: 12.5px; }
.err { color: var(--bad); }
.count { color: var(--muted); font-weight: 400; font-size: 14px; margin-left: 4px; }
.nowrap { white-space: nowrap; }
.mono { font-family: ui-monospace, "Cascadia Mono", Consolas, monospace; font-size: 12.5px; word-break: break-all; }
section { margin-bottom: 28px; }
ul.plain { margin: 0; padding-left: 20px; color: var(--muted); }
ul.plain li { margin-bottom: 4px; }

.alert {
  margin-left: auto;
  background: var(--warn-soft);
  color: var(--warn);
  padding: 6px 12px;
  border-radius: 8px;
  font-weight: 600;
}

/* --- метки статусов ------------------------------------------------------- */

.chip {
  display: inline-block;
  padding: 2px 9px;
  border-radius: 999px;
  font-size: 12.5px;
  font-weight: 550;
  line-height: 1.5;
  white-space: nowrap;
  background: var(--gray-soft);
  color: var(--muted);
}
.s-transcribing { background: var(--info-soft); color: var(--info); }
.s-transcribed { background: var(--warn-soft); color: var(--warn); }
.s-correcting { background: var(--violet-soft); color: var(--violet); }
.s-confirmed { background: var(--ok-soft); color: var(--ok); }
.s-failed { background: var(--bad-soft); color: var(--bad); }
.s-stuck { background: var(--warn-soft); color: var(--warn); }
.chip.topic { background: var(--accent-soft); color: var(--accent); }

/* --- фильтры -------------------------------------------------------------- */

.filters {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: flex-end;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 12px 16px;
  margin-bottom: 16px;
}
.filters label { display: flex; flex-direction: column; gap: 4px; font-size: 12.5px; color: var(--muted); }
.filters label.check { flex-direction: row; align-items: center; gap: 6px; font-size: 14px; color: var(--text); padding-bottom: 7px; }
select, button {
  font: inherit;
  font-size: 14px;
  padding: 6px 10px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: var(--panel);
  color: var(--text);
  max-width: 100%;
}
button { background: var(--accent); border-color: var(--accent); color: var(--on-accent); cursor: pointer; font-weight: 550; }
button:hover { filter: brightness(1.08); }
.reset { font-size: 14px; padding-bottom: 7px; }

/* --- таблицы -------------------------------------------------------------- */

.table-wrap {
  overflow-x: auto;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}
table { width: 100%; border-collapse: collapse; }
th, td { padding: 10px 12px; text-align: left; border-bottom: 1px solid var(--line); vertical-align: top; }
th {
  font-size: 11.5px;
  text-transform: uppercase;
  letter-spacing: .04em;
  color: var(--muted);
  font-weight: 600;
  white-space: nowrap;
}
tbody tr:last-child td { border-bottom: 0; }
tbody tr:hover { background: var(--hover); }
tr.stuck td:first-child { box-shadow: inset 3px 0 0 var(--warn); }
.num { text-align: right; font-variant-numeric: tabular-nums; }
th.num { text-align: right; }
a.id { font-weight: 650; font-variant-numeric: tabular-nums; }
.bar-col { width: 34%; min-width: 90px; vertical-align: middle; }

.pager { display: flex; gap: 16px; justify-content: center; align-items: center; padding: 16px; color: var(--muted); }
.empty {
  padding: 28px;
  text-align: center;
  color: var(--muted);
  background: var(--panel);
  border: 1px dashed var(--line);
  border-radius: var(--radius);
  margin: 0;
}

/* --- карточка материала --------------------------------------------------- */

.facts {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 200px), 1fr));
  gap: 12px;
  margin: 0 0 24px;
}
.facts > div { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 10px 14px; }
.facts dt { font-size: 11.5px; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
.facts dd { margin: 2px 0 0; }

.steps {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-wrap: wrap;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}
.steps li { flex: 1 1 200px; padding: 12px 16px; border-right: 1px solid var(--line); }
.steps li:last-child { border-right: 0; }
.steps li::before {
  content: "";
  display: block;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--ok);
  margin-bottom: 6px;
}
.steps li.wait::before { background: transparent; box-shadow: inset 0 0 0 2px var(--muted); }
.steps li.bad::before { background: var(--bad); }
.step-title { display: block; font-weight: 600; }
.step-time, .step-note { display: block; color: var(--muted); font-size: 13px; }
.steps li.bad .step-note { color: var(--bad); }
.step-took { display: block; font-size: 13px; }

.transcript {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px 16px;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  max-width: 82ch;
}
.correction { margin-bottom: 12px; }
.correction header { display: flex; gap: 8px; align-items: center; margin-bottom: 6px; font-size: 13px; }
.revision { margin: 8px 0 0 24px; }
.revision header { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-bottom: 6px; font-size: 13px; }
.transcript ins { background: var(--ok-soft); color: var(--ok); text-decoration: none; border-radius: 3px; padding: 0 2px; }
.transcript del { background: var(--bad-soft); color: var(--bad); border-radius: 3px; padding: 0 2px; }

details.tech { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 10px 16px; }
details.tech summary { cursor: pointer; color: var(--muted); }
details.tech dl { display: grid; grid-template-columns: max-content 1fr; gap: 6px 16px; margin: 12px 0 4px; }
details.tech dt { color: var(--muted); font-size: 13px; }
details.tech dd { margin: 0; font-family: ui-monospace, "Cascadia Mono", Consolas, monospace; font-size: 12.5px; word-break: break-all; }

/* --- метрики -------------------------------------------------------------- */

.periods {
  margin-left: auto;
  display: flex;
  gap: 2px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 9px;
  padding: 3px;
}
.periods a { padding: 4px 10px; border-radius: 6px; color: var(--muted); font-size: 14px; }
.periods a:hover { text-decoration: none; background: var(--hover); }
.periods a.on { background: var(--accent-soft); color: var(--accent); font-weight: 550; }

.cards {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 230px), 1fr));
  gap: 12px;
  margin-bottom: 28px;
}
.card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px 16px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.card-title { font-size: 13px; color: var(--muted); }
.card-value { font-size: 26px; font-weight: 650; line-height: 1.2; font-variant-numeric: tabular-nums; }
.card.empty .card-value { font-size: 15px; font-weight: 500; color: var(--muted); padding: 6px 0 5px; }
.card.bad .card-value { color: var(--bad); }
.card-detail { font-size: 12.5px; color: var(--muted); }
.card-link { font-size: 13px; margin-top: 2px; }

.grid2 {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 380px), 1fr));
  gap: 20px;
  margin-bottom: 28px;
}
.grid2 > div { min-width: 0; }
.grid2 .facts { margin-bottom: 0; }

.chart { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; }
.chart svg { width: 100%; height: 130px; display: block; }
.chart rect { fill: var(--accent); }
.chart rect.zero { fill: var(--line); }
.axis { display: flex; justify-content: space-between; gap: 8px; color: var(--muted); font-size: 12px; margin-top: 6px; }

svg.hbar { width: 100%; height: 8px; display: block; margin-top: 7px; }
svg.hbar .track { fill: var(--gray-soft); }
svg.hbar .fill { fill: var(--accent); }

/* --- состояние ------------------------------------------------------------ */

.checks {
  list-style: none;
  margin: 0 0 28px;
  padding: 0;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}
.checks li { display: flex; gap: 12px; align-items: baseline; padding: 12px 16px; border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.checks li:last-child { border-bottom: 0; }
.dot { width: 10px; height: 10px; border-radius: 50%; flex: none; background: var(--ok); }
.dot.bad { background: var(--bad); }
.checks .name { font-weight: 600; min-width: 110px; }
.checks .detail { color: var(--muted); font-size: 14px; overflow-wrap: anywhere; flex: 1 1 240px; }

/* --- вход ----------------------------------------------------------------- */

.login {
  max-width: 460px;
  margin: 48px auto 0;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 28px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.login p { margin: 0; }
.notice { padding: 10px 12px; border-radius: 8px; background: var(--info-soft); color: var(--info); font-size: 14px; }
.notice.bad { background: var(--bad-soft); color: var(--bad); }
.button {
  display: inline-block;
  align-self: flex-start;
  padding: 9px 16px;
  border-radius: 8px;
  background: var(--accent);
  color: var(--on-accent);
  font-weight: 600;
}
.button:hover { text-decoration: none; filter: brightness(1.08); }
.who a { color: var(--muted); text-decoration: underline; }
.notice.ok { background: var(--ok-soft); color: var(--ok); }

/* --- доступ --------------------------------------------------------------- */

.access-form {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 220px), 1fr));
  gap: 12px 16px;
  align-items: start;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 8px;
}
.access-form label { display: flex; flex-direction: column; gap: 4px; font-size: 12.5px; color: var(--muted); }
.access-form button { justify-self: start; margin-top: 21px; }
.access-form + .notice, section > .notice { margin-bottom: 12px; }
input[type="text"], input[type="email"] {
  font: inherit;
  font-size: 14px;
  padding: 6px 10px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: var(--panel);
  color: var(--text);
  width: 100%;
}
.field-error { color: var(--bad); font-size: 12.5px; }

/* --- узкий экран ---------------------------------------------------------- */

@media (max-width: 640px) {
  .login { margin-top: 16px; padding: 20px; }
  .top { padding: 8px 16px; gap: 6px 16px; flex-wrap: wrap; }
  .who { margin-left: 0; }
  main { padding: 16px; }
  footer { padding: 0 16px 24px; }
  .steps li { border-right: 0; border-bottom: 1px solid var(--line); }
  .steps li:last-child { border-bottom: 0; }
  .periods { margin-left: 0; }
  .alert { margin-left: 0; }
}
