:root {
  --bg: #f4f6fa;
  --surface: #ffffff;
  --line: #e5e9f0;
  --line-soft: #eef1f6;
  --text: #151b26;
  --muted: #68738a;
  --primary: #3565e5;
  --primary-hover: #2a53c4;
  --primary-soft: #eaf0fe;
  --ok: #177a3d;
  --ok-bg: #e4f5ea;
  --warn: #9a6212;
  --warn-bg: #fdf3de;
  --danger: #c2362f;
  --danger-bg: #fdeae9;
  --info: #2b53c2;
  --info-bg: #e9effc;
  --radius: 12px;
  --shadow: 0 1px 2px rgba(16, 24, 40, 0.05), 0 1px 3px rgba(16, 24, 40, 0.06);
}

* { box-sizing: border-box; }
html { font-size: 15px; }
body {
  margin: 0;
  font-family: system-ui, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  line-height: 1.45;
  color: var(--text);
  background: var(--bg);
}
.container { max-width: 1180px; margin: 0 auto; padding: 0 20px; }
main.container { padding-top: 26px; padding-bottom: 70px; }
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: none; }
h1 { font-size: 22px; font-weight: 700; margin: 0 0 4px; letter-spacing: -0.01em; }
h2 { font-size: 16px; font-weight: 650; margin: 24px 0 10px; }
h3 { font-size: 14px; font-weight: 650; margin: 16px 0 6px; }
code, pre, .stat-num, .variant-number { font-variant-numeric: tabular-nums; }

/* ---------- Навигация ---------- */
.nav { background: var(--surface); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 20; }
.nav-inner { display: flex; align-items: center; gap: 4px; height: 56px; flex-wrap: wrap; }
.brand { display: flex; align-items: center; gap: 8px; font-weight: 700; font-size: 15px; color: var(--text); margin-right: 18px; white-space: nowrap; }
.brand::before { content: ""; width: 10px; height: 10px; border-radius: 3px; background: var(--primary); display: inline-block; }
.nav a.navlink {
  color: #4b5563; font-size: 14px; font-weight: 500;
  padding: 7px 12px; border-radius: 8px; white-space: nowrap;
}
.nav a.navlink:hover { background: #eef1f6; color: var(--text); }
.nav-user { margin-left: auto; color: var(--muted); font-size: 13px; padding: 0 10px; white-space: nowrap; }
.nav a.plain { color: #4b5563; font-size: 13.5px; font-weight: 500; padding: 6px 10px; border-radius: 8px; }
.nav a.plain:hover { background: #eef1f6; }

/* ---------- Кнопки ---------- */
.btn, .btn button, button {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  font: inherit; font-size: 14px; font-weight: 600;
  padding: 8px 15px; border-radius: 9px; border: 1px solid transparent;
  cursor: pointer; text-decoration: none; line-height: 1.2; white-space: nowrap;
  transition: background 0.12s, border-color 0.12s;
}
.btn { background: var(--primary); color: #fff; border-color: var(--primary); }
.btn:hover { background: var(--primary-hover); border-color: var(--primary-hover); text-decoration: none; }
.btn.ghost { background: var(--surface); color: var(--text); border-color: #cfd6e0; }
.btn.ghost:hover { background: #f6f8fb; border-color: #b7c0ce; }
.btn.danger { background: var(--surface); color: var(--danger); border-color: #eac2bd; }
.btn.danger:hover { background: var(--danger-bg); border-color: #e0a7a2; }
.btn.danger.fill, .btn.sm.danger.fill { background: var(--danger); color: #fff; border-color: var(--danger); }
.btn.sm { padding: 5px 11px; font-size: 13px; border-radius: 8px; }
.btn:disabled { opacity: 0.55; cursor: default; }
.linkbtn { font-size: 13.5px; font-weight: 600; }
.linkbtn:hover { text-decoration: underline; }

/* ---------- Карточки, сетки ---------- */
.card {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 18px 20px; margin-bottom: 16px;
}
.card-t { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; margin-bottom: 14px; flex-wrap: wrap; }
.card-t h2 { margin: 0 0 2px; }
.card-t .sub, .card .sub { color: var(--muted); font-size: 13px; margin: 2px 0 0; max-width: 62ch; }
.cols { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; align-items: start; }
.cols > * { min-width: 0; }
.two { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; align-items: start; }
@media (max-width: 920px) { .cols, .two { grid-template-columns: 1fr; } }

.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 14px; margin: 0 0 20px; flex-wrap: wrap; }
.page-head .sub { color: var(--muted); font-size: 13.5px; margin-top: 4px; display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.head-actions { display: flex; gap: 10px; flex-wrap: wrap; }

.grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 14px; margin-bottom: 16px; }
.stat { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 14px 16px; display: block; color: var(--text); }
a.stat:hover { border-color: #c9d4ea; color: var(--text); }
.stat-num { font-size: 26px; font-weight: 750; letter-spacing: -0.02em; line-height: 1.1; }
.stat-label { color: var(--muted); font-size: 13px; margin-top: 3px; }
.stat-link { color: var(--muted); font-size: 12.5px; font-weight: 600; display: inline-block; margin-top: 8px; }
a.stat:hover .stat-link { color: var(--primary); }

/* ---------- Таблицы ---------- */
.table-card { padding: 0; overflow-x: auto; }
.table-head { padding: 14px 18px 0; }
table { width: 100%; border-collapse: collapse; background: var(--surface); font-size: 14px; }
th, td { text-align: left; padding: 10px 14px; border-bottom: 1px solid var(--line-soft); vertical-align: middle; }
th {
  font-size: 11.5px; font-weight: 650; text-transform: uppercase; letter-spacing: 0.03em;
  color: var(--muted); background: #fafbfd; white-space: nowrap;
}
tbody tr:hover { background: #f8fafd; }
tbody tr:last-child td { border-bottom: none; }
td.num { color: var(--muted); font-size: 13px; white-space: nowrap; }
.cell-main { font-weight: 600; }
.cell-sub { color: var(--muted); font-size: 12.5px; margin-top: 1px; }
.table-foot {
  display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
  padding: 12px 18px; border-top: 1px solid var(--line-soft); background: #fafbfd;
  border-radius: 0 0 var(--radius) var(--radius);
}
td input, td select { width: auto; }

/* ---------- Формы ---------- */
label { font-size: 13px; color: #45506a; font-weight: 550; display: inline-flex; align-items: center; gap: 8px; }
.field { margin-bottom: 14px; }
.field > label { display: block; margin-bottom: 6px; }
input, select, textarea {
  font: inherit; font-size: 14px; color: var(--text);
  padding: 8px 11px; border: 1px solid #cfd6e0; border-radius: 9px; background: var(--surface);
  width: 100%; max-width: 100%;
}
input:focus, select:focus, textarea:focus {
  outline: none; border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(53, 101, 229, 0.14);
}
input[type="checkbox"] { width: auto; }
input[type="file"] { border-style: dashed; padding: 3px 6px; background: #fbfcfe; }
select.level-select {
  padding: 4px 8px; font-size: 13px; border-radius: 8px; font-weight: 550;
  border-color: #cfd6e0; cursor: pointer;
}
.w-90 { width: 90px; flex: none; }
.w-120 { width: 120px; flex: none; }
.w-280 { width: 280px; flex: none; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin: 10px 0; }
.row.no-margin { margin: 0; }
.inline { display: inline-flex; align-items: center; gap: 6px; margin: 0; }
.inline input, .inline select { width: auto; }
.confirm-row { align-items: flex-start !important; }
.confirm-row input { margin-top: 4px; }
.hint { color: var(--muted); font-size: 12.5px; }

/* ---------- Бейджи, статусы ---------- */
.badge {
  display: inline-flex; align-items: center;
  padding: 2px 9px; border-radius: 999px; font-size: 12px; font-weight: 600;
  background: #eceff4; color: #45506a; white-space: nowrap; line-height: 1.5;
}
.badge.ok { background: var(--ok-bg); color: var(--ok); }
.badge.warn { background: var(--warn-bg); color: var(--warn); }
.badge.err { background: var(--danger-bg); color: var(--danger); }
.badge.info { background: var(--info-bg); color: var(--info); }
.variant-number { font-size: 15px; font-weight: 700; }

.flash, .error {
  padding: 11px 15px; border-radius: 10px; margin-bottom: 16px; font-size: 14px;
  display: flex; align-items: flex-start; gap: 8px;
}
.flash { background: var(--ok-bg); border: 1px solid #bfe3ca; color: var(--ok); }
.error { background: var(--danger-bg); border: 1px solid #efc4c1; color: var(--danger); }

/* ---------- Разное ---------- */
.muted { color: var(--muted); }
.muted-2 { color: var(--muted); font-size: 12.5px; }
.nowrap { white-space: nowrap; }
pre {
  background: #10192e; color: #dce6f5; padding: 13px 15px; border-radius: 10px;
  overflow: auto; font-size: 13px; line-height: 1.5;
  font-family: ui-monospace, "Cascadia Mono", Consolas, monospace; margin: 8px 0;
}
pre.plain { background: #f5f7fa; color: #242c3b; border: 1px solid var(--line-soft); }
.timer {
  font: 700 30px/1.2 ui-monospace, Consolas, monospace;
  text-align: center; padding: 14px; border-radius: 10px;
  background: #10192e; color: #fff; margin: 10px 0;
}
.timer.over { background: var(--danger); }
.js-timer.countdown {
  display: inline-block; min-width: 64px; text-align: center;
  font-weight: 700; font-family: ui-monospace, Consolas, monospace; font-size: 15px;
  background: var(--info-bg); color: var(--info); padding: 4px 10px; border-radius: 8px;
}
.js-timer.countdown.over { background: var(--danger-bg); color: var(--danger); }
.auth-card { max-width: 430px; margin: 48px auto; background: var(--surface); border: 1px solid var(--line); border-radius: 14px; box-shadow: var(--shadow); padding: 26px 28px; }
details summary { cursor: pointer; color: var(--primary); font-size: 13.5px; font-weight: 600; }
details { margin: 10px 0; }

/* ---------- Вкладки ---------- */
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin: 4px 0 18px; flex-wrap: wrap; }
.tab {
  padding: 8px 14px; border-radius: 9px 9px 0 0; font-size: 14px; font-weight: 600;
  color: var(--muted); border: 1px solid transparent; border-bottom: none; cursor: pointer;
}
.tab:hover { color: var(--text); }
.tab.active { color: var(--primary); background: var(--surface); border-color: var(--line); position: relative; top: 1px; }
.tab.active::after { content: ""; display: block; height: 2px; background: var(--surface); position: relative; top: 9px; }
