/* Оформление CRM. Тёмная вертикальная панель слева, светлое рабочее поле —
   так рабочая область остаётся спокойной, а навигация не спорит с данными. */
:root {
  color-scheme: light;
  --ink: #14161a;
  --ink-soft: #5b6270;
  --ink-faint: #8b93a1;
  --line: #e3e6eb;
  --bg: #f6f7f9;
  --card: #ffffff;
  --rail: #14161a;
  --rail-ink: #a7aebb;
  --accent: #2f6bff;
  --accent-ink: #ffffff;
  --danger: #c02b32;
  --danger-bg: #fdf1f1;
  --ok: #157347;
  --radius: 10px;
  --rail-w: 52px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: Onest, "Segoe UI", system-ui, -apple-system, sans-serif;
  font-size: 14px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
}

code, .mono { font-family: "IBM Plex Mono", ui-monospace, SFMono-Regular, monospace; }

/* ── Вход ─────────────────────────────────────────────────────────── */
.auth {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
}

.auth-card {
  width: 100%;
  max-width: 380px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 28px;
  box-shadow: 0 1px 2px rgba(20, 22, 26, .04), 0 8px 24px rgba(20, 22, 26, .06);
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 22px;
}

.brand-mark {
  width: 30px; height: 30px;
  border-radius: 8px;
  background: var(--rail);
  color: #fff;
  display: grid; place-items: center;
  font-size: 12px; font-weight: 600; letter-spacing: .04em;
}

.brand-name { font-weight: 600; letter-spacing: -.01em; }
.brand-sub { color: var(--ink-faint); font-size: 12px; }

h1 { font-size: 19px; font-weight: 600; letter-spacing: -.01em; margin: 0 0 4px; }
.lede { color: var(--ink-soft); margin: 0 0 20px; font-size: 13px; }

label { display: block; font-size: 12px; color: var(--ink-soft); margin-bottom: 5px; }

input[type=text], input[type=password] {
  width: 100%;
  padding: 9px 11px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  font: inherit;
}

input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(47, 107, 255, .14);
}

.field { margin-bottom: 14px; }

button {
  width: 100%;
  padding: 10px 14px;
  border: 0;
  border-radius: 8px;
  background: var(--accent);
  color: var(--accent-ink);
  font: inherit;
  font-weight: 500;
  cursor: pointer;
}

button:hover { background: #2559d8; }
button.ghost { background: transparent; color: var(--ink-soft); border: 1px solid var(--line); }
button.ghost:hover { background: var(--bg); }

.error {
  background: var(--danger-bg);
  border: 1px solid #f3d2d3;
  color: var(--danger);
  border-radius: 8px;
  padding: 9px 11px;
  font-size: 13px;
  margin-bottom: 16px;
}

.notice {
  background: #f1f6ff;
  border: 1px solid #d6e2ff;
  color: #23448f;
  border-radius: 8px;
  padding: 9px 11px;
  font-size: 13px;
  margin-bottom: 16px;
}

.foot { margin-top: 18px; color: var(--ink-faint); font-size: 12px; text-align: center; }

/* Выбор организации после входа */
.choice {
  display: flex; width: 100%; text-align: left; gap: 10px;
  align-items: center; justify-content: flex-start;
  background: #fff; color: var(--ink);
  border: 1px solid var(--line); margin-bottom: 8px;
}
.choice:hover { background: var(--bg); border-color: #cdd3dc; }
.choice-role { color: var(--ink-faint); font-size: 12px; }

/* ── Каркас приложения ────────────────────────────────────────────── */
.shell { display: grid; grid-template-columns: var(--rail-w) 1fr; min-height: 100vh; }

.rail {
  background: var(--rail);
  color: var(--rail-ink);
  display: flex; flex-direction: column; align-items: center;
  padding: 12px 0; gap: 6px;
}

.rail a {
  width: 34px; height: 34px;
  display: grid; place-items: center;
  border-radius: 8px;
  color: var(--rail-ink); text-decoration: none; font-size: 15px;
}
.rail a:hover { background: rgba(255,255,255,.08); color: #fff; }
.rail a.on { background: rgba(255,255,255,.14); color: #fff; }
.rail .spacer { flex: 1; }

.main { padding: 0; }

.topbar {
  display: flex; align-items: center; justify-content: space-between;
  gap: 16px; padding: 14px 22px;
  background: var(--card); border-bottom: 1px solid var(--line);
}

.who { font-size: 13px; }
.who b { font-weight: 600; }
.who span { color: var(--ink-faint); }

.content { padding: 22px; max-width: 980px; }

.card {
  background: var(--card); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 20px; margin-bottom: 16px;
}

.badge {
  display: inline-block; padding: 2px 8px; border-radius: 999px;
  font-size: 11px; background: #eef1f5; color: var(--ink-soft);
}
.badge.hq { background: #14161a; color: #fff; }

dl.facts { display: grid; grid-template-columns: 170px 1fr; gap: 8px 16px; margin: 0; }
dl.facts dt { color: var(--ink-faint); font-size: 13px; }
dl.facts dd { margin: 0; }

.inline-form { max-width: 380px; }
.inline-form button { width: auto; padding: 8px 16px; }

@media (max-width: 640px) {
  .shell { grid-template-columns: 1fr; }
  .rail { flex-direction: row; padding: 8px 12px; }
  .rail .spacer { flex: 1; }
  dl.facts { grid-template-columns: 1fr; gap: 2px 0; }
  dl.facts dd { margin-bottom: 10px; }
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme=light]) {
    color-scheme: dark;
    --ink: #e8eaee; --ink-soft: #a2a9b6; --ink-faint: #79808d;
    --line: #2a2e36; --bg: #0f1114; --card: #171a1f; --rail: #090a0c;
    --danger-bg: #2a1618;
  }
  :root:not([data-theme=light]) input[type=text],
  :root:not([data-theme=light]) input[type=password],
  :root:not([data-theme=light]) .choice { background: #1d2127; }
}
