/* ── Дизайн-система портала ─────────────────────────────────────── */
:root {
  --bg: #f4f6fb;
  --surface: #ffffff;
  --surface-2: #fafbfe;
  --line: #e4e8f2;
  --line-strong: #cfd6e6;
  --text: #131a2b;
  --muted: #6b7590;
  --brand: #4338ca;
  --brand-soft: #eef0ff;
  --ok: #087f5b;
  --ok-soft: #e4f6ef;
  --warn: #a8620a;
  --warn-soft: #fdf1de;
  --danger: #c02626;
  --danger-soft: #fdeaea;
  --info: #0b6bcb;
  --info-soft: #e7f1fd;
  --radius: 14px;
  --radius-sm: 9px;
  --shadow: 0 1px 2px rgba(20, 30, 60, .06), 0 8px 24px rgba(20, 30, 60, .06);
  --shadow-sm: 0 1px 2px rgba(20, 30, 60, .07);
  --font: "Inter", "Segoe UI", system-ui, -apple-system, "Helvetica Neue", Arial, sans-serif;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.5;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}

a { color: var(--brand); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3 { margin: 0 0 4px; line-height: 1.25; letter-spacing: -.015em; }
h1 { font-size: 26px; font-weight: 700; }
h2 { font-size: 19px; font-weight: 650; }
h3 { font-size: 16px; font-weight: 650; }
p { margin: 0 0 10px; }

/* ── Каркас ─────────────────────────────────────────────────────── */
.layout { display: flex; min-height: 100vh; }

.sidebar {
  width: 254px;
  flex: 0 0 254px;
  background: #10152a;
  color: #c6cde3;
  padding: 18px 14px 24px;
  display: flex;
  flex-direction: column;
  gap: 18px;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
}
.brand { display: flex; align-items: center; gap: 10px; padding: 4px 8px 12px; }
.brand-mark {
  width: 34px; height: 34px; border-radius: 10px;
  background: linear-gradient(135deg, #6366f1, #22d3ee);
  display: grid; place-items: center; font-weight: 800; color: #fff; font-size: 15px;
}
.brand-text { font-weight: 700; color: #fff; font-size: 15px; line-height: 1.2; }
.brand-text small { display: block; font-weight: 500; font-size: 11.5px; color: #8b95b5; }

.nav-group { display: flex; flex-direction: column; gap: 2px; }
.nav-title {
  font-size: 10.5px; text-transform: uppercase; letter-spacing: .09em;
  color: #6c769b; padding: 4px 10px; font-weight: 700;
}
.nav-link {
  display: flex; align-items: center; gap: 9px;
  padding: 8px 10px; border-radius: 9px;
  color: #c6cde3; font-size: 14px; font-weight: 500;
}
.nav-link:hover { background: rgba(255,255,255,.06); text-decoration: none; color: #fff; }
.nav-link.active { background: var(--brand); color: #fff; }
.nav-link .tag {
  margin-left: auto; font-size: 11px; font-weight: 700;
  background: rgba(255,255,255,.12); padding: 1px 7px; border-radius: 20px;
}
.nav-link.active .tag { background: rgba(255,255,255,.22); }
.nav-scheme { font-size: 10px; font-weight: 800; letter-spacing: .04em; opacity: .55; }

.sidebar-foot { margin-top: auto; border-top: 1px solid rgba(255,255,255,.09); padding-top: 12px; }
.who { font-size: 13px; color: #fff; font-weight: 600; }
.who small { display: block; color: #8b95b5; font-weight: 500; }

.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar {
  background: var(--surface);
  border-bottom: 1px solid var(--line);
  padding: 14px 26px;
  display: flex; align-items: center; gap: 16px; flex-wrap: wrap;
  position: sticky; top: 0; z-index: 20;
}
.topbar .spacer { flex: 1; }
.content { padding: 22px 26px 60px; max-width: 1440px; width: 100%; }

/* ── Карточки и сетки ───────────────────────────────────────────── */
.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  padding: 16px 18px;
}
.card + .card { margin-top: 16px; }
.card-head { display: flex; align-items: center; gap: 12px; margin-bottom: 12px; flex-wrap: wrap; }
.card-head .spacer { flex: 1; }
.grid { display: grid; gap: 14px; }
.grid-3 { grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); }
.grid-4 { grid-template-columns: repeat(auto-fill, minmax(215px, 1fr)); }
.row { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.stack { display: flex; flex-direction: column; gap: 4px; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.tiny { font-size: 12px; }
.nowrap { white-space: nowrap; }
.right { text-align: right; }
.center { text-align: center; }

/* ── Плашки каналов ─────────────────────────────────────────────── */
.channel-card {
  display: block; background: var(--surface);
  border: 1px solid var(--line); border-radius: var(--radius);
  padding: 15px 16px; box-shadow: var(--shadow-sm);
  transition: transform .12s ease, box-shadow .12s ease, border-color .12s ease;
  color: inherit;
}
.channel-card:hover { text-decoration: none; transform: translateY(-2px); box-shadow: var(--shadow); border-color: var(--line-strong); }
.channel-card .top { display: flex; align-items: center; gap: 8px; margin-bottom: 10px; }
.channel-name { font-weight: 680; font-size: 15.5px; }
.channel-metrics { display: flex; gap: 14px; margin: 12px 0 8px; }
.metric-value { font-size: 21px; font-weight: 720; letter-spacing: -.02em; }
.metric-label { font-size: 11.5px; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }

/* ── Значки ─────────────────────────────────────────────────────── */
.badge {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 2.5px 9px; border-radius: 20px;
  font-size: 12px; font-weight: 640; white-space: nowrap;
  background: var(--surface-2); color: var(--muted); border: 1px solid var(--line);
}
.badge.brand { background: var(--brand-soft); color: var(--brand); border-color: #dcdffb; }
.badge.ok { background: var(--ok-soft); color: var(--ok); border-color: #c7ecdd; }
.badge.warn { background: var(--warn-soft); color: var(--warn); border-color: #f6e0bd; }
.badge.danger { background: var(--danger-soft); color: var(--danger); border-color: #f7cfcf; }
.badge.info { background: var(--info-soft); color: var(--info); border-color: #cfe3fa; }
.badge.solid-danger { background: var(--danger); color: #fff; border-color: transparent; }
.scheme-chip {
  font-size: 10.5px; font-weight: 800; letter-spacing: .06em;
  padding: 2px 7px; border-radius: 6px; background: #111a33; color: #fff;
}
.scheme-chip.fbo { background: #0b6bcb; }
.scheme-chip.fbs { background: #6d28d9; }
.mp-chip { font-size: 11px; font-weight: 700; color: var(--muted); }

/* ── Прогресс ───────────────────────────────────────────────────── */
.bar { height: 8px; border-radius: 20px; background: #eaeef7; overflow: hidden; }
.bar > span { display: block; height: 100%; border-radius: 20px; background: var(--brand); transition: width .3s ease; }
.bar.ok > span { background: var(--ok); }
.bar.warn > span { background: #e08a17; }
.bar.danger > span { background: var(--danger); }
.bar.slim { height: 6px; }

/* ── Таблицы ────────────────────────────────────────────────────── */
.table-wrap { overflow-x: auto; border-radius: var(--radius-sm); }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th {
  text-align: left; font-size: 11.5px; text-transform: uppercase; letter-spacing: .05em;
  color: var(--muted); font-weight: 700; padding: 9px 10px;
  border-bottom: 1px solid var(--line); background: var(--surface-2); white-space: nowrap;
}
td { padding: 10px; border-bottom: 1px solid var(--line); vertical-align: middle; }
tbody tr:hover { background: #fbfcff; }
tbody tr.done-row { background: #f6fbf9; }
tbody tr.problem-row { background: #fff8f8; }
.art { font-weight: 640; }
.size-chip {
  display: inline-block; min-width: 34px; text-align: center;
  padding: 1px 7px; border-radius: 6px; background: var(--surface-2);
  border: 1px solid var(--line); font-size: 12.5px; font-weight: 600;
}

/* ── Формы и кнопки ─────────────────────────────────────────────── */
label { font-size: 12.5px; font-weight: 600; color: var(--muted); display: block; margin-bottom: 4px; }
input[type=text], input[type=password], input[type=number], input[type=date],
input[type=datetime-local], input[type=search], select, textarea {
  width: 100%; padding: 8px 11px; font: inherit; font-size: 14px;
  border: 1px solid var(--line-strong); border-radius: var(--radius-sm);
  background: #fff; color: var(--text); outline: none;
}
input:focus, select:focus, textarea:focus { border-color: var(--brand); box-shadow: 0 0 0 3px rgba(67,56,202,.12); }
textarea { min-height: 90px; resize: vertical; font-family: ui-monospace, "Cascadia Mono", Consolas, monospace; font-size: 13px; }
.field { margin-bottom: 12px; }
.field-row { display: grid; gap: 12px; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); }
.qty-input { width: 92px; text-align: center; font-weight: 700; font-size: 15px; }
input[type=file] { font-size: 13px; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  padding: 8px 15px; border-radius: var(--radius-sm); border: 1px solid var(--line-strong);
  background: #fff; color: var(--text); font: inherit; font-size: 14px; font-weight: 600;
  cursor: pointer; transition: background .12s ease, border-color .12s ease, transform .08s ease;
}
.btn:hover { background: var(--surface-2); text-decoration: none; }
.btn:active { transform: translateY(1px); }
.btn.primary { background: var(--brand); border-color: var(--brand); color: #fff; }
.btn.primary:hover { background: #3b31b4; }
.btn.success { background: var(--ok); border-color: var(--ok); color: #fff; }
.btn.success:hover { background: #06674a; }
.btn.ghost { background: transparent; border-color: transparent; color: var(--muted); }
.btn.ghost:hover { background: var(--surface-2); color: var(--text); }
.btn.danger { color: var(--danger); border-color: #f0c9c9; background: #fff; }
.btn.danger:hover { background: var(--danger-soft); }
.btn.sm { padding: 5px 10px; font-size: 13px; }
.btn.lg { padding: 11px 20px; font-size: 15px; }
.btn.block { width: 100%; }

.tabs { display: flex; gap: 6px; flex-wrap: wrap; }
.tab {
  padding: 7px 14px; border-radius: 20px; font-size: 13.5px; font-weight: 620;
  border: 1px solid var(--line-strong); background: #fff; color: var(--muted); cursor: pointer;
}
.tab:hover { text-decoration: none; background: var(--surface-2); color: var(--text); }
.tab.active { background: var(--brand); border-color: var(--brand); color: #fff; }

.pill-group { display: flex; flex-wrap: wrap; gap: 8px; }
.pill {
  border: 1.5px solid var(--line-strong); background: #fff; border-radius: 12px;
  padding: 10px 14px; cursor: pointer; text-align: left; font: inherit;
  display: flex; flex-direction: column; gap: 3px; min-width: 165px;
  transition: border-color .12s ease, background .12s ease;
}
.pill:hover { border-color: var(--brand); }
.pill.active { border-color: var(--brand); background: var(--brand-soft); }
.pill strong { font-size: 14px; font-weight: 680; }
.pill span { font-size: 11.5px; color: var(--muted); }

.alert { padding: 11px 14px; border-radius: var(--radius-sm); font-size: 14px; margin-bottom: 14px; }
.alert.error { background: var(--danger-soft); color: var(--danger); border: 1px solid #f7cfcf; }
.alert.info { background: var(--info-soft); color: var(--info); border: 1px solid #cfe3fa; }
.alert.ok { background: var(--ok-soft); color: var(--ok); border: 1px solid #c7ecdd; }

.empty { text-align: center; padding: 44px 20px; color: var(--muted); }
.empty .big { font-size: 40px; margin-bottom: 8px; }

details.box { border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 10px 14px; background: var(--surface-2); }
details.box summary { cursor: pointer; font-weight: 640; font-size: 14px; }
details.box[open] { background: #fff; }
details.box[open] summary { margin-bottom: 12px; }

.timeline { display: flex; flex-direction: column; gap: 10px; max-height: 420px; overflow-y: auto; }
.timeline .entry { display: flex; gap: 10px; font-size: 13.5px; }
.timeline .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--line-strong); margin-top: 6px; flex: 0 0 8px; }
.timeline .entry.progress .dot { background: var(--ok); }
.timeline .entry.problem .dot { background: var(--danger); }
.timeline .entry.status .dot { background: var(--info); }

/* ── Сканирование ───────────────────────────────────────────────── */
.scan-grid { display: grid; gap: 16px; grid-template-columns: minmax(0, 1.1fr) minmax(0, 1fr); align-items: start; }
@media (max-width: 1100px) { .scan-grid { grid-template-columns: 1fr; } }

.scan-panel #scan-input {
  font-size: 22px; padding: 16px 18px; font-weight: 600; letter-spacing: .02em;
  border: 2px solid var(--brand); border-radius: 12px; background: var(--brand-soft);
}
.scan-panel #scan-input:focus { background: #fff; box-shadow: 0 0 0 4px rgba(67,56,202,.16); }

.scan-result {
  margin-top: 14px; padding: 18px; border-radius: 12px;
  background: var(--surface-2); border: 1px solid var(--line);
  min-height: 92px; display: flex; flex-direction: column; justify-content: center;
}
.scan-result-title { font-size: 21px; font-weight: 700; letter-spacing: -.02em; }
.scan-result-sub { font-size: 14px; color: var(--muted); margin-top: 3px; }
.scan-result.ok { background: var(--ok-soft); border-color: #c7ecdd; }
.scan-result.ok .scan-result-title { color: var(--ok); }
.scan-result.warn { background: var(--warn-soft); border-color: #f6e0bd; }
.scan-result.warn .scan-result-title { color: var(--warn); }
.scan-result.error { background: var(--danger-soft); border-color: #f7cfcf; }
.scan-result.error .scan-result-title { color: var(--danger); }

.mode-btn.active { background: var(--brand); border-color: var(--brand); color: #fff; }
.log-text { font-size: 13.5px; }

/* ── Экран входа ────────────────────────────────────────────────── */
.login-wrap { min-height: 100vh; display: grid; place-items: center; padding: 20px;
  background: radial-gradient(1100px 520px at 15% -5%, #2a3260 0%, #10152a 55%, #0a0e1c 100%); }
.login-card { width: 100%; max-width: 390px; background: #fff; border-radius: 18px; padding: 30px 28px; box-shadow: 0 22px 60px rgba(0,0,0,.32); }

/* ── Печать ─────────────────────────────────────────────────────── */
@media print {
  .sidebar, .topbar, .no-print { display: none !important; }
  .content { padding: 0; }
  .card { box-shadow: none; border: none; }
  body { background: #fff; font-size: 12px; }
}

/* ── Адаптив ────────────────────────────────────────────────────── */
@media (max-width: 900px) {
  .layout { flex-direction: column; }
  .sidebar { width: 100%; flex: none; height: auto; position: static; flex-direction: column; }
  .content { padding: 16px 14px 50px; }
  .topbar { padding: 12px 14px; }
}
