/* Панель администратора напрямую.рф — по макету «05 · Админка». Без фреймворков и CDN. */
:root {
  --sidebar: #191b2e;
  --sidebar-line: #2b2e48;
  --nav: #cbd3e0;
  --bg: #f4f6f9;
  --card: #ffffff;
  --line: #dce2ec;
  --control: #8b99ad;
  --ink: #122033;
  --muted: #526074;
  --accent: #315bd8;
  --accent-soft: #edf2ff;
  --danger: #b42318;
  --danger-soft: #fff0ee;
  --success: #16734f;
  --success-soft: #e8f5ee;
  --warn: #8a5700;
  --warn-soft: #fff5df;
  --radius: 10px;
  --font: Inter, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

* { box-sizing: border-box; }
html { font-family: var(--font); color: var(--ink); background: var(--bg); }
body { margin: 0; min-height: 100vh; font-size: 14px; line-height: 20px; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 28px; line-height: 36px; margin: 0; font-weight: 700; }
h2 { font-size: 18px; line-height: 26px; margin: 0; font-weight: 600; }
h3 { font-size: 15px; line-height: 22px; margin: 0; font-weight: 600; }
p { margin: 0; }
code, .mono { font-family: Menlo, ui-monospace, monospace; font-size: 12px; }

/* ── каркас ─────────────────────────────────────────────── */
.shell { display: grid; grid-template-columns: 264px 1fr; min-height: 100vh; }
.sidebar {
  position: sticky; top: 0; height: 100vh; overflow-y: auto;
  display: flex; flex-direction: column; gap: 4px;
  background: var(--sidebar); color: var(--nav); padding: 16px;
}
.brand { display: flex; align-items: center; gap: 12px; padding: 4px 8px 16px; color: #fff; }
.brand-mark {
  width: 40px; height: 40px; border-radius: 10px; display: grid; place-items: center;
  font-size: 20px; font-weight: 600; background: linear-gradient(145deg, #416dde, #2445ae);
}
.brand-name { font-size: 18px; line-height: 24px; font-weight: 600; }
.brand-sub { font-size: 10px; line-height: 14px; font-weight: 500; color: var(--nav); text-transform: uppercase; }
.nav-title { padding: 14px 12px 4px; font-size: 11px; font-weight: 600; letter-spacing: .04em; text-transform: uppercase; color: #8d97ad; }
.nav-link {
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  height: 40px; padding: 0 12px; border-radius: 8px; color: var(--nav); font-weight: 500;
}
.nav-link:hover { background: rgba(255, 255, 255, .06); text-decoration: none; }
.nav-link.active { background: var(--accent); color: #fff; }
.nav-badge { background: rgba(255,255,255,.14); border-radius: 999px; padding: 0 8px; font-size: 11px; line-height: 18px; }
.sidebar-foot { margin-top: auto; display: flex; flex-direction: column; gap: 10px; padding-top: 16px; }
.secure-note { display: flex; align-items: center; gap: 8px; padding: 0 12px; font-size: 12px; color: var(--nav); }
.dot { width: 8px; height: 8px; border-radius: 50%; background: #9fca6a; }
.account {
  display: flex; align-items: center; gap: 10px; padding: 10px 12px; border: 1px solid var(--sidebar-line);
  border-radius: 10px; color: #fff;
}
.avatar {
  width: 32px; height: 32px; border-radius: 8px; display: grid; place-items: center; flex: none;
  background: linear-gradient(145deg, #416dde, #2445ae); color: #fff; font-weight: 600; font-size: 12px;
}
.account-name { font-weight: 600; font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.account-role { font-size: 11px; color: var(--nav); }
.logout {
  display: flex; align-items: center; justify-content: center; gap: 8px; width: 100%; height: 38px; padding: 0 12px;
  border: 1px solid var(--sidebar-line); border-radius: 10px; background: transparent; color: var(--nav);
  font: inherit; font-size: 13px; font-weight: 500; cursor: pointer; transition: background .15s, color .15s, border-color .15s;
}
.logout:hover { background: rgba(255, 255, 255, .07); color: #fff; border-color: #3d4163; }
.logout:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.logout svg { width: 16px; height: 16px; flex: none; }

.main { min-width: 0; display: flex; flex-direction: column; }
.topbar {
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  padding: 16px 32px; background: var(--bg);
}
.topbar-search { display: flex; gap: 12px; flex: 1; max-width: 560px; }
.topbar-user { display: flex; align-items: center; gap: 10px; text-align: right; font-size: 12px; }
.topbar-user strong { display: block; font-size: 13px; }
.content { padding: 8px 32px 48px; display: flex; flex-direction: column; gap: 20px; max-width: 1336px; width: 100%; }
.page-head { display: flex; flex-direction: column; gap: 4px; }
.page-sub { color: var(--muted); font-size: 12px; }

/* ── карточки и сетка ───────────────────────────────────── */
.card { background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 20px; display: flex; flex-direction: column; gap: 16px; }
.card h2 { margin-bottom: 0; }
.grid-4 { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; }
.grid-2 { display: grid; grid-template-columns: repeat(2, 1fr); gap: 16px; }
.split { display: grid; grid-template-columns: minmax(0, 2fr) minmax(0, 1fr); gap: 20px; align-items: start; }
.stat { background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 16px 20px; display: flex; flex-direction: column; gap: 6px; }
.stat-label { font-size: 12px; font-weight: 500; color: var(--muted); }
.stat-value { font-size: 32px; line-height: 40px; font-weight: 600; }
.stat-note { font-size: 11px; color: var(--muted); border-top: 1px solid var(--line); padding-top: 6px; margin-top: 4px; }
.stat-value.danger { color: var(--danger); }
.stat-value.accent { color: var(--accent); }

/* ── формы ──────────────────────────────────────────────── */
input[type="text"], input[type="search"], input[type="email"], input[type="password"], input[type="number"],
input[type="date"], select, textarea {
  width: 100%; height: 40px; padding: 0 12px; background: #fff; color: var(--ink);
  border: 1px solid var(--control); border-radius: 8px; font: inherit;
}
textarea { height: auto; min-height: 96px; padding: 10px 12px; resize: vertical; }
input:focus, select:focus, textarea:focus { outline: 2px solid rgba(49, 91, 216, .3); border-color: var(--accent); }
label { display: flex; flex-direction: column; gap: 6px; font-size: 12px; font-weight: 500; color: var(--muted); }
.filters { display: flex; flex-wrap: wrap; gap: 12px; align-items: end; }
.filters label { min-width: 160px; flex: 1; }
.form-stack { display: flex; flex-direction: column; gap: 12px; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px; height: 36px; padding: 0 14px;
  border-radius: 8px; border: 1px solid var(--accent); background: var(--accent); color: #fff;
  font: inherit; font-weight: 600; cursor: pointer; white-space: nowrap;
}
.btn:hover { filter: brightness(1.08); text-decoration: none; }
.btn.secondary { background: #fff; color: var(--accent); }
.btn.danger { background: var(--danger); border-color: var(--danger); }
.btn.danger-outline { background: #fff; color: var(--danger); border-color: var(--danger); }
.btn.small { height: 30px; padding: 0 10px; font-size: 12px; }
.btn.block { width: 100%; }
.actions { display: flex; flex-wrap: wrap; gap: 8px; }

/* ── таблицы ────────────────────────────────────────────── */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th {
  text-align: left; font-size: 11px; line-height: 16px; font-weight: 600; color: var(--muted);
  background: var(--bg); padding: 10px 12px; white-space: nowrap;
}
td { padding: 12px; border-top: 1px solid var(--line); vertical-align: middle; }
tr.is-open td { background: var(--accent-soft); }
td.num, th.num { text-align: right; }
.empty { padding: 24px; text-align: center; color: var(--muted); }
.pager { display: flex; align-items: center; justify-content: space-between; gap: 12px; font-size: 12px; color: var(--muted); }

/* ── значки ─────────────────────────────────────────────── */
.badge { display: inline-block; padding: 2px 8px; border-radius: 6px; font-size: 11px; line-height: 16px; font-weight: 600; background: var(--bg); color: var(--muted); }
.badge.ok { background: var(--success-soft); color: var(--success); }
.badge.warn { background: var(--warn-soft); color: var(--warn); }
.badge.bad { background: var(--danger-soft); color: var(--danger); }
.badge.info { background: var(--accent-soft); color: var(--accent); }
.stars { color: #e0a200; letter-spacing: 1px; }

/* ── сообщения ──────────────────────────────────────────── */
.flash { padding: 12px 16px; border-radius: 8px; font-weight: 500; background: var(--success-soft); color: var(--success); }
.flash.error { background: var(--danger-soft); color: var(--danger); }
.flash-inline { margin-top: 10px; font-size: 14px; padding: 10px 12px; }
.note { padding: 12px 16px; border-radius: 8px; font-size: 12px; background: var(--accent-soft); color: var(--muted); }
.note.warn { background: var(--warn-soft); color: var(--warn); }
.note.bad { background: var(--danger-soft); color: var(--danger); }

/* ── списки «ключ — значение» и столбики оценок ─────────── */
.kv { display: grid; grid-template-columns: 140px 1fr; gap: 10px 16px; font-size: 13px; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; font-weight: 500; overflow-wrap: anywhere; }
.bars { display: flex; flex-direction: column; gap: 8px; }
.bar-row { display: grid; grid-template-columns: 28px 1fr 28px; gap: 8px; align-items: center; font-size: 12px; color: var(--muted); }
.bar { height: 6px; background: var(--line); border-radius: 999px; overflow: hidden; }
.bar > span { display: block; height: 100%; background: var(--accent); border-radius: 999px; }
.bar > span.w0 { width: 0; } .bar > span.w10 { width: 10%; } .bar > span.w20 { width: 20%; } .bar > span.w30 { width: 30%; }
.bar > span.w40 { width: 40%; } .bar > span.w50 { width: 50%; } .bar > span.w60 { width: 60%; } .bar > span.w70 { width: 70%; }
.bar > span.w80 { width: 80%; } .bar > span.w90 { width: 90%; } .bar > span.w100 { width: 100%; }
.quote { background: var(--bg); border: 1px solid var(--line); border-radius: 8px; padding: 12px; white-space: pre-wrap; }
.timeline { display: flex; flex-direction: column; gap: 8px; font-size: 13px; }
.timeline li { display: grid; grid-template-columns: 90px 1fr; gap: 12px; }
ul.plain { list-style: none; margin: 0; padding: 0; }

/* ── вход ───────────────────────────────────────────────── */
.login { min-height: 100vh; display: grid; place-items: center; padding: 24px; }
.login-card { width: 100%; max-width: 440px; }
.login-lock { display: flex; align-items: center; gap: 12px; }

.htmx-request { opacity: .6; }

@media (max-width: 1100px) {
  .grid-4 { grid-template-columns: repeat(2, 1fr); }
  .split { grid-template-columns: 1fr; }
}
@media (max-width: 820px) {
  .shell { grid-template-columns: 1fr; }
  .sidebar { position: static; height: auto; }
  .content, .topbar { padding-left: 16px; padding-right: 16px; }
  .grid-3, .grid-2 { grid-template-columns: 1fr; }
}

.bar-row.wide { grid-template-columns: 96px 1fr 170px; }

/* ── оболочка по макету: иконки меню, нижняя строка, заголовок с действием ───────── */
.nav-label { display: flex; align-items: center; gap: 12px; }
.nav-icon { flex: none; opacity: .85; }
.nav-link.active .nav-icon { opacity: 1; }
.foot {
  display: flex; justify-content: space-between; gap: 16px; padding: 12px 32px 24px; font-size: 11px; color: var(--muted);
}
.foot .dot { display: inline-block; margin-right: 6px; background: #526074; }
.page-top { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; }
.stat-value { color: #3d4860; }
.stat-value.danger { color: var(--danger); }
.stat-value.accent { color: var(--accent); }
.selected td { background: var(--accent-soft); }
.detail-grid { display: grid; grid-template-columns: minmax(0, 1.6fr) minmax(0, 1fr); gap: 20px; align-items: start; }
.chip { display: inline-block; padding: 2px 8px; border-radius: 6px; font-size: 11px; background: var(--warn-soft); color: var(--warn); font-weight: 600; }
.chip.ok { background: var(--success-soft); color: var(--success); }
.chip.bad { background: var(--danger-soft); color: var(--danger); }
.chip.info { background: var(--accent-soft); color: var(--accent); }
@media (max-width: 1100px) { .detail-grid { grid-template-columns: 1fr; } }

/* Плавные переходы между страницами (MPA view transitions + hx-boost). */
@view-transition { navigation: auto; }
::view-transition-old(root), ::view-transition-new(root) { animation-duration: 0.18s; }
@media (prefers-reduced-motion: reduce) {
  ::view-transition-group(*), ::view-transition-old(*), ::view-transition-new(*) { animation: none !important; }
}

/* Строки таблиц, открывающиеся целиком по клику. */
tr[data-row-link] { cursor: pointer; transition: background-color 0.12s ease; }
tr[data-row-link]:hover { background: rgba(49, 91, 216, 0.06); }
tr[data-row-link]:hover .row-title { text-decoration: underline; }
a.row-title { color: inherit; text-decoration: none; }
a.row-title:focus-visible { outline: 2px solid #315bd8; outline-offset: 2px; border-radius: 4px; }

[hidden] { display: none !important; }

label.is-disabled { opacity: .55; }
label.is-disabled input { background: #e9ecf1; color: #8a93a3; cursor: not-allowed; }

/* Флажок: квадрат справа от текста, в одну строку. */
label.check { flex-direction: row-reverse; justify-content: flex-end; align-items: center; gap: 8px; font-size: 14px; color: var(--ink); }
label.check input[type="checkbox"] { width: 16px; height: 16px; min-height: 0; margin: 0; flex: none; accent-color: var(--accent); }
.is-disabled { opacity: .55; }
.is-disabled input, .is-disabled select { background: #e9ecf1; color: #8a93a3; cursor: not-allowed; }

/* Полосы прокрутки не рисуются: страница, меню и таблицы прокручиваются как обычно. */
html, .sidebar, .table-wrap, textarea { scrollbar-width: none; -ms-overflow-style: none; }
html::-webkit-scrollbar, .sidebar::-webkit-scrollbar, .table-wrap::-webkit-scrollbar, textarea::-webkit-scrollbar { display: none; width: 0; height: 0; }
