/* ── Дизайн-система ───────────────────────────────────────────────────
   Минимализм: узкий иконочный рельс, плотные карточки, один акцент.
   Текста мало — состояние передаётся иконкой, цветом и числом.        */

:root {
  color-scheme: light dark;

  --bg:          #fbfbfc;
  --surface:     #ffffff;
  --surface-2:   #f4f4f6;
  --border:      #e4e4e8;
  --text:        #17171a;
  --text-dim:    #6b6b75;
  --text-faint:  #9a9aa4;

  --accent:      #4f46e5;
  --accent-soft: #eef2ff;

  --ok:          #16a34a;
  --ok-soft:     #e8f7ed;
  --warn:        #d97706;
  --warn-soft:   #fdf3e3;
  --bad:         #dc2626;
  --bad-soft:    #fdeaea;

  --radius:      10px;
  --radius-sm:   7px;
  --rail:        60px;
  --shadow:      0 1px 2px rgba(16, 16, 24, .05), 0 4px 12px rgba(16, 16, 24, .04);

  --mono: ui-monospace, "SF Mono", "JetBrains Mono", Menlo, Consolas, monospace;
  --sans: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg:          #0d0d10;
    --surface:     #151519;
    --surface-2:   #1c1c22;
    --border:      #27272e;
    --text:        #ececf0;
    --text-dim:    #9a9aa6;
    --text-faint:  #6a6a76;

    --accent:      #818cf8;
    --accent-soft: #1e1b3a;

    --ok:          #4ade80;
    --ok-soft:     #12281a;
    --warn:        #fbbf24;
    --warn-soft:   #2a2010;
    --bad:         #f87171;
    --bad-soft:    #2c1416;

    --shadow:      0 1px 2px rgba(0, 0, 0, .4);
  }
}

* { box-sizing: border-box; }

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

a { color: inherit; text-decoration: none; }
svg { display: block; }

/* ── Рельс навигации ────────────────────────────────────────────── */

.rail {
  position: fixed;
  inset: 0 auto 0 0;
  width: var(--rail);
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 14px 0;
  gap: 4px;
  z-index: 20;
}

.rail__mark {
  width: 32px; height: 32px;
  border-radius: 9px;
  background: var(--accent);
  color: #fff;
  display: grid; place-items: center;
  margin-bottom: 14px;
  flex: none;
}

.rail__spacer { flex: 1; }

.rail__link {
  position: relative;
  width: 40px; height: 40px;
  border-radius: var(--radius-sm);
  display: grid; place-items: center;
  color: var(--text-faint);
  transition: background .12s, color .12s;
}
.rail__link:hover { background: var(--surface-2); color: var(--text); }
.rail__link.is-active { background: var(--accent-soft); color: var(--accent); }

.rail__link::after {
  content: attr(data-label);
  position: absolute;
  left: calc(100% + 10px);
  top: 50%;
  transform: translateY(-50%) translateX(-4px);
  background: var(--text);
  color: var(--bg);
  font-size: 12px;
  font-weight: 500;
  padding: 5px 9px;
  border-radius: 6px;
  white-space: nowrap;
  opacity: 0;
  pointer-events: none;
  transition: opacity .12s, transform .12s;
  z-index: 30;
}
.rail__link:hover::after { opacity: 1; transform: translateY(-50%) translateX(0); }

/* ── Каркас страницы ────────────────────────────────────────────── */

.shell { margin-left: var(--rail); min-height: 100vh; }

.topbar {
  height: 56px;
  padding: 0 22px;
  display: flex;
  align-items: center;
  gap: 12px;
  border-bottom: 1px solid var(--border);
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(8px);
  position: sticky; top: 0; z-index: 10;
}

.topbar h1 {
  margin: 0;
  font-size: 15px;
  font-weight: 600;
  letter-spacing: -.01em;
}

.topbar__actions { margin-left: auto; display: flex; gap: 8px; align-items: center; }

.page { padding: 22px; max-width: 1280px; }

/* ── Сетка и карточки ───────────────────────────────────────────── */

.grid { display: grid; gap: 12px; }
.grid--4 { grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); }
.grid--3 { grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); }
.grid--2 { grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); }

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  box-shadow: var(--shadow);
}

.card--link { transition: border-color .12s, transform .12s; }
.card--link:hover { border-color: var(--accent); transform: translateY(-1px); }

.card__head {
  display: flex; align-items: center; gap: 9px;
  margin-bottom: 12px;
}
.card__title { font-size: 13px; font-weight: 600; }
.card__tools { margin-left: auto; display: flex; gap: 6px; }

/* Плитка показателя: иконка, число, короткая подпись */
.tile { display: flex; align-items: center; gap: 13px; }
.tile__icon {
  width: 38px; height: 38px; flex: none;
  border-radius: var(--radius-sm);
  display: grid; place-items: center;
  background: var(--surface-2);
  color: var(--text-dim);
}
.tile__icon--ok   { background: var(--ok-soft);   color: var(--ok); }
.tile__icon--warn { background: var(--warn-soft); color: var(--warn); }
.tile__icon--bad  { background: var(--bad-soft);  color: var(--bad); }
.tile__icon--accent { background: var(--accent-soft); color: var(--accent); }

.tile__value {
  font-size: 21px; font-weight: 650;
  letter-spacing: -.02em; line-height: 1.15;
  font-variant-numeric: tabular-nums;
}
.tile__label { font-size: 11.5px; color: var(--text-dim); }

/* ── Элементы ───────────────────────────────────────────────────── */

.dot {
  width: 7px; height: 7px; border-radius: 50%;
  flex: none; display: inline-block;
  background: var(--text-faint);
}
.dot--ok   { background: var(--ok); box-shadow: 0 0 0 3px var(--ok-soft); }
.dot--warn { background: var(--warn); box-shadow: 0 0 0 3px var(--warn-soft); }
.dot--bad  { background: var(--bad); box-shadow: 0 0 0 3px var(--bad-soft); }

.pill {
  display: inline-flex; align-items: center; gap: 5px;
  font-size: 11px; font-weight: 550;
  padding: 3px 8px; border-radius: 20px;
  background: var(--surface-2); color: var(--text-dim);
  white-space: nowrap;
}
.pill--ok   { background: var(--ok-soft);   color: var(--ok); }
.pill--warn { background: var(--warn-soft); color: var(--warn); }
.pill--bad  { background: var(--bad-soft);  color: var(--bad); }
.pill--accent { background: var(--accent-soft); color: var(--accent); }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  height: 32px; padding: 0 12px;
  font-family: inherit; font-size: 12.5px; font-weight: 550;
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  background: var(--surface); color: var(--text);
  cursor: pointer;
  transition: background .12s, border-color .12s, opacity .12s;
  white-space: nowrap;
}
.btn:hover { background: var(--surface-2); }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn--primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn--primary:hover { background: color-mix(in srgb, var(--accent) 88%, #000); }
.btn--danger { color: var(--bad); }
.btn--danger:hover { background: var(--bad-soft); border-color: var(--bad); }
.btn--icon { width: 32px; padding: 0; }
.btn--sm { height: 27px; padding: 0 9px; font-size: 11.5px; }

.field { display: flex; flex-direction: column; gap: 5px; margin-bottom: 12px; }
.field label { font-size: 12px; font-weight: 550; color: var(--text-dim); }
.field small { font-size: 11px; color: var(--text-faint); }

input[type=text], input[type=password], input[type=email],
input[type=number], textarea, select {
  font-family: inherit; font-size: 13px;
  padding: 8px 10px;
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  background: var(--bg); color: var(--text);
  width: 100%;
}
textarea { resize: vertical; min-height: 88px; font-family: var(--mono); font-size: 12px; }
input:focus, textarea:focus, select:focus {
  outline: none; border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

/* ── Таблица ────────────────────────────────────────────────────── */

.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 12.5px; }
th {
  text-align: left; font-weight: 550; font-size: 11px;
  text-transform: uppercase; letter-spacing: .04em;
  color: var(--text-faint);
  padding: 8px 10px; border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
td { padding: 9px 10px; border-bottom: 1px solid var(--border); vertical-align: middle; }
tr:last-child td { border-bottom: none; }
tbody tr:hover { background: var(--surface-2); }
.num { font-variant-numeric: tabular-nums; text-align: right; }
.mono { font-family: var(--mono); font-size: 11.5px; }

/* ── Прочее ─────────────────────────────────────────────────────── */

.empty {
  padding: 34px 20px; text-align: center;
  color: var(--text-faint);
}
.empty svg { margin: 0 auto 10px; opacity: .45; }
.empty p { margin: 0; font-size: 12.5px; }

.code {
  font-family: var(--mono); font-size: 12px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 11px 13px;
  overflow-x: auto;
  white-space: pre;
  color: var(--text);
}

.note {
  display: flex; gap: 9px; align-items: flex-start;
  padding: 11px 13px; border-radius: var(--radius-sm);
  font-size: 12.5px; line-height: 1.45;
  background: var(--warn-soft); color: var(--warn);
  border: 1px solid color-mix(in srgb, var(--warn) 25%, transparent);
}
.note--bad { background: var(--bad-soft); color: var(--bad); border-color: color-mix(in srgb, var(--bad) 25%, transparent); }
.note--ok  { background: var(--ok-soft);  color: var(--ok);  border-color: color-mix(in srgb, var(--ok) 25%, transparent); }
.note svg { flex: none; margin-top: 1px; }

.bar {
  height: 5px; border-radius: 3px;
  background: var(--surface-2); overflow: hidden;
}
.bar__fill { height: 100%; background: var(--accent); border-radius: 3px; transition: width .3s; }
.bar__fill--ok  { background: var(--ok); }
.bar__fill--bad { background: var(--bad); }

.switch { position: relative; display: inline-block; width: 36px; height: 20px; flex: none; }
.switch input { opacity: 0; width: 0; height: 0; }
.switch__track {
  position: absolute; inset: 0; cursor: pointer;
  background: var(--border); border-radius: 20px; transition: background .16s;
}
.switch__track::before {
  content: ''; position: absolute;
  width: 14px; height: 14px; left: 3px; top: 3px;
  background: #fff; border-radius: 50%; transition: transform .16s;
}
.switch input:checked + .switch__track { background: var(--ok); }
.switch input:checked + .switch__track::before { transform: translateX(16px); }

.stack { display: flex; flex-direction: column; gap: 12px; }
.row { display: flex; align-items: center; gap: 9px; }
.row--wrap { flex-wrap: wrap; }
.spacer { flex: 1; }
.dim { color: var(--text-dim); }
.faint { color: var(--text-faint); }
.small { font-size: 11.5px; }
.center { text-align: center; }

/* ── Вход ───────────────────────────────────────────────────────── */

.auth {
  min-height: 100vh;
  display: grid; place-items: center;
  padding: 20px;
}
.auth__card {
  width: 100%; max-width: 340px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 28px 24px;
  box-shadow: var(--shadow);
}
.auth__mark {
  width: 42px; height: 42px; border-radius: 12px;
  background: var(--accent); color: #fff;
  display: grid; place-items: center;
  margin: 0 auto 16px;
}

/* ── Модальное окно ─────────────────────────────────────────────── */

.modal {
  position: fixed; inset: 0; z-index: 50;
  background: rgba(10, 10, 14, .5);
  display: none; place-items: center;
  padding: 20px;
  backdrop-filter: blur(3px);
}
.modal.is-open { display: grid; }
.modal__card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  width: 100%; max-width: 460px;
  max-height: 86vh; overflow-y: auto;
  padding: 20px;
  box-shadow: 0 20px 50px rgba(0, 0, 0, .25);
}
.modal__head { display: flex; align-items: center; gap: 9px; margin-bottom: 16px; }
.modal__title { font-size: 14px; font-weight: 600; }

@media (max-width: 640px) {
  .page { padding: 14px; }
  .topbar { padding: 0 14px; }
  :root { --rail: 52px; }
}
