/* PULT — тёмная тема служебного пульта.
   Палитра построена на «чернильном» сине-графитовом фоне: он спокойнее
   нейтрально-чёрного при работе весь день. Акцент — барвинковый синий,
   состояния — мятный / янтарный / розовый. Моноширинный шрифт несёт
   служебные данные: логины, ключи, адреса, время. */

:root {
  --ink: #0c1017;
  --ink-2: #10151e;
  --panel: #161c27;
  --panel-2: #1b2331;
  --line: #262f3f;
  --line-soft: #1f2836;
  --text: #e7ecf5;
  --text-2: #b6c1d4;
  --muted: #7f8da5;
  --accent: #5b8cff;
  --accent-2: #7fa5ff;
  --accent-soft: rgba(91, 140, 255, 0.14);
  --mint: #3ed9a4;
  --amber: #ffc062;
  --rose: #ff6b84;

  --r-sm: 6px;
  --r: 10px;
  --r-lg: 16px;
  --pad: 20px;

  --display: 'Space Grotesk', 'Segoe UI', sans-serif;
  --body: 'IBM Plex Sans', -apple-system, 'Segoe UI', sans-serif;
  --mono: 'JetBrains Mono', ui-monospace, 'SFMono-Regular', Consolas, monospace;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  min-height: 100%;
}

body {
  background: var(--ink);
  color: var(--text);
  font-family: var(--body);
  font-size: 15px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

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

h1, h2, h3, h4 { font-family: var(--display); font-weight: 600; margin: 0; letter-spacing: -0.01em; }

.mono { font-family: var(--mono); font-size: 0.86em; }
.muted { color: var(--muted); }
.nowrap { white-space: nowrap; }
.block { display: block; }
.right { text-align: right; }

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: 4px;
}

/* ── Фирменный знак ─────────────────────────────────────────── */

.mark {
  width: 26px;
  height: 26px;
  border-radius: 8px;
  background:
    radial-gradient(circle at 50% 50%, var(--ink) 0 3px, transparent 3.5px),
    linear-gradient(140deg, var(--accent) 0%, #8f6bff 100%);
  box-shadow: 0 0 0 1px rgba(91, 140, 255, 0.35), 0 6px 18px rgba(91, 140, 255, 0.22);
  flex: none;
}
.mark-lg { width: 40px; height: 40px; border-radius: 12px; }

/* ── Экран входа ────────────────────────────────────────────── */

.body-auth {
  background:
    radial-gradient(900px 600px at 12% -10%, rgba(91, 140, 255, 0.16), transparent 60%),
    radial-gradient(700px 500px at 100% 100%, rgba(143, 107, 255, 0.12), transparent 55%),
    var(--ink);
}

.auth {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 1.05fr 0.95fr;
  gap: 0;
  align-items: stretch;
}

.auth-side {
  padding: clamp(28px, 5vw, 64px);
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 34px;
  border-right: 1px solid var(--line-soft);
}

.auth-brand { display: flex; gap: 16px; align-items: flex-start; }

.eyebrow {
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--muted);
  margin: 0 0 6px;
}

.auth-logo {
  font-size: clamp(40px, 7vw, 68px);
  line-height: 1;
  letter-spacing: -0.03em;
  font-weight: 700;
  margin: 0;
}

.auth-tagline { color: var(--text-2); margin: 8px 0 0; font-size: 16px; }

/* Сигнатурный элемент: «шина площадок» — служебная ведомость подключений,
   она же живёт в шапке приложения. */
.ledger {
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  background: linear-gradient(180deg, rgba(27, 35, 49, 0.75), rgba(18, 24, 34, 0.75));
  padding: 14px 16px;
  max-width: 460px;
}

.ledger-head {
  font-family: var(--mono);
  font-size: 10.5px;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--muted);
  margin: 0 0 10px;
}

.ledger-row {
  display: grid;
  grid-template-columns: 10px 92px 1fr auto;
  align-items: center;
  gap: 12px;
  padding: 9px 0;
  border-top: 1px solid var(--line-soft);
  font-size: 13px;
}
.ledger-row:first-of-type { border-top: 0; }

.ledger-key { font-family: var(--mono); color: var(--text); }
.ledger-note { color: var(--muted); font-size: 12.5px; }
.ledger-state {
  font-family: var(--mono);
  font-size: 11px;
  color: var(--amber);
  letter-spacing: 0.04em;
}

.dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--amber);
  box-shadow: 0 0 0 3px rgba(255, 192, 98, 0.14);
  display: inline-block;
  flex: none;
}

.auth-foot { color: var(--muted); max-width: 460px; margin: 0; font-size: 14px; }

.auth-form-wrap {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: clamp(28px, 5vw, 64px);
}

.auth-card {
  width: 100%;
  max-width: 400px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  padding: 30px;
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.45);
}

.auth-title { font-size: 24px; }
.auth-sub { color: var(--muted); margin: 6px 0 22px; font-size: 14px; }
.auth-hint { color: var(--muted); font-size: 12.5px; margin: 20px 0 0; line-height: 1.5; }

/* ── Формы ──────────────────────────────────────────────────── */

.form { display: flex; flex-direction: column; gap: 16px; }

.field { display: flex; flex-direction: column; gap: 7px; }

.field-label {
  font-size: 12px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
  font-weight: 500;
}

.field-hint { font-size: 12px; color: var(--muted); }

.input {
  width: 100%;
  background: var(--ink-2);
  border: 1px solid var(--line);
  border-radius: var(--r);
  color: var(--text);
  font-family: var(--body);
  font-size: 15px;
  padding: 11px 13px;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
.input:hover { border-color: #33405492; }
.input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}
.input:disabled { color: var(--muted); background: #0e131b; }
.input-mono { font-family: var(--mono); font-size: 14px; letter-spacing: 0.02em; }

select.input { appearance: none; cursor: pointer; padding-right: 34px;
  background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%),
                    linear-gradient(135deg, var(--muted) 50%, transparent 50%);
  background-position: right 16px center, right 11px center;
  background-size: 5px 5px, 5px 5px;
  background-repeat: no-repeat;
}

.input-row { position: relative; display: block; }
.input-row .input { padding-right: 84px; }

.peek {
  position: absolute;
  right: 6px;
  top: 50%;
  transform: translateY(-50%);
  background: none;
  border: 0;
  color: var(--muted);
  font-family: var(--mono);
  font-size: 11px;
  cursor: pointer;
  padding: 6px 8px;
  border-radius: var(--r-sm);
}
.peek:hover { color: var(--accent-2); background: var(--accent-soft); }

.form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
  gap: 16px;
}

.perms {
  border: 1px solid var(--line);
  border-radius: var(--r);
  padding: 14px 16px 16px;
  margin: 0;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
  gap: 10px 18px;
}
.perms legend {
  font-size: 12px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
  padding: 0 6px;
}

.check { display: flex; gap: 10px; align-items: flex-start; cursor: pointer; font-size: 14px; }
.check input { margin-top: 4px; accent-color: var(--accent); width: 15px; height: 15px; }
.check span { display: flex; flex-direction: column; }
.check em { color: var(--muted); font-style: normal; font-size: 12px; }

/* ── Кнопки ─────────────────────────────────────────────────── */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border: 1px solid transparent;
  border-radius: var(--r);
  padding: 10px 16px;
  font-family: var(--body);
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.15s ease, border-color 0.15s ease, color 0.15s ease;
  white-space: nowrap;
}

.btn-primary {
  background: var(--accent);
  color: #071021;
  font-weight: 600;
}
.btn-primary:hover { background: var(--accent-2); color: #071021; }

.btn-ghost {
  background: transparent;
  border-color: var(--line);
  color: var(--text-2);
}
.btn-ghost:hover { border-color: #3a465c; color: var(--text); background: #1a2130; }

.btn-danger { background: transparent; border-color: #4a2733; color: var(--rose); }
.btn-danger:hover { background: rgba(255, 107, 132, 0.1); border-color: var(--rose); }

.btn-block { width: 100%; }
.btn-sm { padding: 7px 11px; font-size: 13px; }

/* ── Каркас приложения ──────────────────────────────────────── */

.body-app { background: var(--ink); }

.shell { display: grid; grid-template-columns: 248px 1fr; min-height: 100vh; }

.side {
  background: var(--ink-2);
  border-right: 1px solid var(--line-soft);
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 18px 14px;
  position: sticky;
  top: 0;
  height: 100vh;
}

.side-brand { display: flex; align-items: center; gap: 11px; padding: 4px 8px 14px; }
.mark-text { display: flex; flex-direction: column; line-height: 1.2; }
.mark-text strong { font-family: var(--display); font-size: 17px; letter-spacing: 0.02em; }
.mark-text em { font-style: normal; font-size: 11px; color: var(--muted); }

.side-nav { display: flex; flex-direction: column; gap: 2px; flex: 1; overflow-y: auto; }

.nav-label {
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: #5d6a80;
  margin: 16px 0 6px;
  padding-left: 12px;
}

.nav-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 9px 12px;
  border-radius: var(--r);
  color: var(--text-2);
  font-size: 14.5px;
  border-left: 2px solid transparent;
}
a.nav-item:hover { background: #182031; color: var(--text); }
.nav-item.is-active {
  background: var(--accent-soft);
  color: #cddcff;
  border-left-color: var(--accent);
}
.nav-item.is-soon { color: #5f6b80; cursor: default; }

.nav-tag {
  font-family: var(--mono);
  font-style: normal;
  font-size: 10px;
  letter-spacing: 0.06em;
  color: #566076;
  border: 1px solid var(--line-soft);
  border-radius: 999px;
  padding: 1px 7px;
}

.side-user { border-top: 1px solid var(--line-soft); padding-top: 12px; display: grid; gap: 8px; }

.who { display: flex; align-items: center; gap: 10px; padding: 8px; border-radius: var(--r); color: var(--text); }
.who:hover { background: #182031; color: var(--text); }
.who.is-active { background: var(--accent-soft); }
.who-text { display: flex; flex-direction: column; line-height: 1.25; min-width: 0; }
.who-text strong { font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.who-text em { font-style: normal; font-size: 11.5px; color: var(--muted); }

.who-mark {
  width: 32px;
  height: 32px;
  border-radius: 9px;
  background: #202a3b;
  border: 1px solid var(--line);
  display: grid;
  place-items: center;
  font-family: var(--mono);
  font-size: 12px;
  color: var(--accent-2);
  flex: none;
}
.who-mark.sm { width: 28px; height: 28px; font-size: 11px; }

.main { display: flex; flex-direction: column; min-width: 0; }

.topbar {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 14px 26px;
  border-bottom: 1px solid var(--line-soft);
  background: rgba(12, 16, 23, 0.86);
  backdrop-filter: blur(8px);
  position: sticky;
  top: 0;
  z-index: 5;
}

.topbar-title { font-size: 15px; font-weight: 500; color: var(--text-2); flex: 1; }

.bus { display: flex; gap: 6px; flex-wrap: wrap; }

.bus-item {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  font-family: var(--mono);
  font-size: 11px;
  color: var(--muted);
  border: 1px solid var(--line-soft);
  border-radius: 999px;
  padding: 4px 11px;
}
.bus-item.is-online { color: var(--mint); border-color: rgba(62, 217, 164, 0.3); }
.bus-item.is-online .dot { background: var(--mint); box-shadow: 0 0 0 3px rgba(62, 217, 164, 0.14); }

.burger { display: none; }

.content {
  padding: 26px;
  display: flex;
  flex-direction: column;
  gap: 18px;
  max-width: 1180px;
  width: 100%;
}

.hello { display: flex; flex-direction: column; gap: 6px; }
.page-title { font-size: 26px; }
.page-sub { color: var(--muted); margin: 0; max-width: 70ch; }

.section-head {
  font-size: 12px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--muted);
  font-family: var(--mono);
  font-weight: 500;
  margin-top: 10px;
}

.sub-head { font-size: 14px; margin: 22px 0 10px; }

/* ── Панели, карточки, таблицы ──────────────────────────────── */

.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  overflow: hidden;
}
.panel-pad { padding: var(--pad); }
.panel-head { padding: 16px 20px; border-bottom: 1px solid var(--line-soft); font-size: 14px; }
.narrow { max-width: 460px; }

.cols { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; align-items: start; }

.grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); gap: 14px; }

.card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  padding: 16px 18px 14px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  transition: border-color 0.15s ease;
}
.card:hover { border-color: #34405a; }
.card.is-locked { opacity: 0.55; }

.card-head { display: flex; justify-content: space-between; align-items: center; gap: 10px; }
.card-key { font-family: var(--mono); font-size: 11px; color: var(--muted); letter-spacing: 0.06em; }
.card-title { font-size: 18px; }
.card-note { color: var(--text-2); font-size: 13.5px; margin: 0; }
.card-foot { margin-top: 8px; padding-top: 10px; border-top: 1px solid var(--line-soft); font-size: 12.5px; }

.tag {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-family: var(--mono);
  font-size: 10.5px;
  color: var(--amber);
  border: 1px solid rgba(255, 192, 98, 0.25);
  border-radius: 999px;
  padding: 3px 9px;
}
.tag.is-online { color: var(--mint); border-color: rgba(62, 217, 164, 0.3); }
.tag.is-online .dot { background: var(--mint); box-shadow: 0 0 0 3px rgba(62, 217, 164, 0.14); }

.stat-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 14px; }
.stat {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  padding: 16px 18px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.stat-num { font-family: var(--display); font-size: 30px; font-weight: 600; line-height: 1.1; }
.stat-label { color: var(--muted); font-size: 12.5px; }

.table { width: 100%; border-collapse: collapse; font-size: 14px; }
.table th {
  text-align: left;
  font-size: 11px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--muted);
  font-weight: 500;
  padding: 12px 16px;
  border-bottom: 1px solid var(--line);
  background: var(--panel-2);
}
.table td { padding: 13px 16px; border-top: 1px solid var(--line-soft); vertical-align: top; }
.table tbody tr:first-child td { border-top: 0; }
.table tbody tr:hover { background: #1a2231; }
.table tr.is-off { opacity: 0.55; }
.table th.right, .table td.right { text-align: right; }

.who-cell { display: flex; align-items: center; gap: 10px; }
.who-cell b { font-weight: 600; display: block; }
.who-cell em { font-style: normal; }

.row-actions { display: flex; gap: 6px; flex-wrap: wrap; justify-content: flex-end; align-items: center; }
.row-edit td { background: #131a26; }
.form-inline { padding: 6px 0 4px; }

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

.chips { display: flex; gap: 6px; flex-wrap: wrap; margin: 0; }
.chip {
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 2px 9px;
  color: var(--text-2);
  font-size: 11.5px;
}

.badge {
  display: inline-block;
  font-size: 11px;
  border-radius: 999px;
  padding: 3px 10px;
  border: 1px solid var(--line);
  color: var(--text-2);
  margin-right: 4px;
}
.badge.is-admin { color: var(--accent-2); border-color: rgba(91, 140, 255, 0.35); background: var(--accent-soft); }
.badge.is-worker { color: var(--text-2); }
.badge.is-off { color: var(--rose); border-color: rgba(255, 107, 132, 0.3); }
.badge.is-wait { color: var(--amber); border-color: rgba(255, 192, 98, 0.3); }

.facts { display: grid; gap: 2px; margin: 0; }
.facts > div { display: grid; grid-template-columns: 170px 1fr; gap: 12px; padding: 9px 0; border-top: 1px solid var(--line-soft); }
.facts > div:first-child { border-top: 0; }
.facts dt { color: var(--muted); font-size: 13px; }
.facts dd { margin: 0; }

.filter { display: flex; gap: 14px; align-items: flex-end; flex-wrap: wrap; }
.field-row { min-width: 240px; }
.pager { display: flex; gap: 12px; align-items: center; }

/* ── Сообщения ──────────────────────────────────────────────── */

.flash-stack { display: flex; flex-direction: column; gap: 8px; }

.flash {
  margin: 0;
  padding: 11px 15px;
  border-radius: var(--r);
  font-size: 14px;
  border: 1px solid var(--line);
  background: var(--panel);
}
.flash.is-ok { border-color: rgba(62, 217, 164, 0.35); color: #b6f0da; background: rgba(62, 217, 164, 0.08); }
.flash.is-error { border-color: rgba(255, 107, 132, 0.4); color: #ffc3ce; background: rgba(255, 107, 132, 0.08); }

.issue {
  border: 1px solid rgba(91, 140, 255, 0.4);
  background: linear-gradient(180deg, rgba(91, 140, 255, 0.12), rgba(91, 140, 255, 0.04));
  border-radius: var(--r-lg);
  padding: 18px 20px;
}
.issue-head { font-family: var(--display); font-size: 16px; font-weight: 600; margin: 0 0 4px; }
.issue-body { color: var(--text-2); font-size: 13.5px; margin: 0 0 14px; max-width: 70ch; }
.issue-creds { display: flex; gap: 22px; align-items: center; flex-wrap: wrap; }
.cred { display: flex; flex-direction: column; gap: 2px; }
.cred em { font-style: normal; font-size: 11px; letter-spacing: 0.12em; text-transform: uppercase; color: var(--muted); }
.cred b { font-size: 16px; letter-spacing: 0.04em; }

/* ── Экран ошибки ───────────────────────────────────────────── */

.center { min-height: 100vh; display: grid; place-items: center; padding: 24px; }
.error-card {
  max-width: 440px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  padding: 32px;
  text-align: center;
}
.error-code { font-size: 12px; color: var(--muted); letter-spacing: 0.3em; }
.error-title { font-size: 24px; margin: 8px 0 10px; }
.error-text { color: var(--text-2); margin: 0 0 22px; }
.error-card .row-actions { justify-content: center; }

/* ── Адаптив ────────────────────────────────────────────────── */

@media (max-width: 900px) {
  .auth { grid-template-columns: 1fr; }
  .auth-side { border-right: 0; border-bottom: 1px solid var(--line-soft); padding-bottom: 34px; }
  .cols { grid-template-columns: 1fr; }
}

@media (max-width: 760px) {
  .shell { grid-template-columns: 1fr; }

  .side {
    position: fixed;
    inset: 0 auto 0 0;
    width: 260px;
    z-index: 20;
    transform: translateX(-100%);
    transition: transform 0.18s ease;
    box-shadow: 24px 0 60px rgba(0, 0, 0, 0.5);
  }
  .nav-toggle:checked ~ .side { transform: translateX(0); }

  .burger {
    display: flex;
    flex-direction: column;
    justify-content: center;
    gap: 4px;
    width: 34px;
    height: 34px;
    padding: 8px;
    border: 1px solid var(--line);
    border-radius: var(--r-sm);
    cursor: pointer;
  }
  .burger span { display: block; height: 1.5px; background: var(--text-2); border-radius: 2px; }

  .topbar { padding: 12px 16px; }
  .bus { display: none; }
  .content { padding: 18px 16px 40px; }
  .table { font-size: 13px; }
  .table th, .table td { padding: 10px 12px; }
  .row-actions { justify-content: flex-start; }
  .facts > div { grid-template-columns: 1fr; gap: 2px; }
}

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation: none !important; }
}
