/* FirePage — партнёрский портал (partners.firepage.ru).
   Палитра, типографика и ритм — из дизайн-артефакта «Партнёрский кабинет»
   (design/Partners cabinet design). Четвёртая приватная поверхность рядом с
   витриной, кабинетом и бэкофисом: тот же приём со своим хостом и сессией,
   своя навигация и presentation layer (ADR-FIREPAGE-0019 §2).
   Шрифты self-hosted и идентичны остальным поверхностям (Manrope — текст,
   Inter — заголовки, IBM Plex Mono — коды, адреса и суммы). */

@font-face {
  font-family: 'Manrope';
  src: url('fonts/Manrope-cyrillic.woff2') format('woff2-variations');
  font-weight: 200 800;
  font-style: normal;
  font-display: swap;
  unicode-range: U+0301, U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116, U+20BD;
}
@font-face {
  font-family: 'Manrope';
  src: url('fonts/Manrope-latin.woff2') format('woff2-variations');
  font-weight: 200 800;
  font-style: normal;
  font-display: swap;
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+2000-206F, U+2074, U+20AC, U+2122, U+2212, U+FEFF, U+FFFD;
}
@font-face {
  font-family: 'InterVar';
  src: url('fonts/Inter-cyrillic.woff2') format('woff2-variations');
  font-weight: 100 900;
  font-style: normal;
  font-display: swap;
  unicode-range: U+0301, U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116, U+20BD;
}
@font-face {
  font-family: 'InterVar';
  src: url('fonts/Inter-latin.woff2') format('woff2-variations');
  font-weight: 100 900;
  font-style: normal;
  font-display: swap;
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+2000-206F, U+2074, U+20AC, U+2122, U+2190-2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: 'IBM Plex Mono';
  src: url('fonts/IBMPlexMono-400-cyrillic.woff2') format('woff2');
  font-weight: 400;
  font-style: normal;
  font-display: swap;
  unicode-range: U+0301, U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116;
}
@font-face {
  font-family: 'IBM Plex Mono';
  src: url('fonts/IBMPlexMono-400-latin.woff2') format('woff2');
  font-weight: 400;
  font-style: normal;
  font-display: swap;
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+2000-206F, U+20AC, U+2122, U+2212, U+FEFF, U+FFFD;
}
@font-face {
  font-family: 'IBM Plex Mono';
  src: url('fonts/IBMPlexMono-500-cyrillic.woff2') format('woff2');
  font-weight: 500;
  font-style: normal;
  font-display: swap;
  unicode-range: U+0301, U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116;
}
@font-face {
  font-family: 'IBM Plex Mono';
  src: url('fonts/IBMPlexMono-500-latin.woff2') format('woff2');
  font-weight: 500;
  font-style: normal;
  font-display: swap;
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+2000-206F, U+20AC, U+2122, U+2212, U+FEFF, U+FFFD;
}

:root {
  /* Палитра из макета: A — акцент (фиолетовый), OK/WA/BA — статусы. */
  --accent: #7C5CF2;
  --accent-hover: #6A4BD8;
  --accent-soft: #EFEBFE;
  --accent-border: #C9B8F8;
  --ok: #1F7A43;
  --ok-bg: #F5FAF6;
  --wa: #B26A11;
  --wa-bg: #FDF7EF;
  --ba: #C03E53;
  --ba-bg: #FCEFF1;
  --ink: #22212A;
  --ink-2: #3A3846;
  --muted: #8F8D99;
  --muted-2: #7A7886;
  --line: #E6E3EE;
  --line-2: #EDECF2;
  --line-3: #F4F3F7;
  --card: #FFFFFF;
  --bg: #F4F3F7;
  --hover: #FAFAFC;
}

*, *::before, *::after { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: 'Manrope', system-ui, sans-serif;
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3 {
  margin: 0;
  font-family: 'InterVar', 'Inter', system-ui, sans-serif;
  font-weight: 700;
  letter-spacing: -0.025em;
}
p { margin: 0; }
a { color: var(--accent); text-decoration: none; }
a:hover { color: var(--accent-hover); }
button { font: inherit; cursor: pointer; }
input, select, textarea { font: inherit; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.mono { font-family: 'IBM Plex Mono', ui-monospace, monospace; }
.tnum { font-variant-numeric: tabular-nums; }

/* ─── Кнопки ─── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding: 8px 14px;
  border-radius: 9px;
  border: 1px solid var(--line-3);
  background: var(--card);
  color: var(--ink-2);
  font-size: 13px;
  font-weight: 500;
  white-space: nowrap;
}
.btn:hover { background: var(--bg); }
.btn-primary {
  border-color: transparent;
  background: var(--accent);
  color: #fff;
  font-weight: 600;
}
.btn-primary:hover { background: var(--accent-hover); }
.btn-lg { padding: 11px 15px; font-size: 13.5px; }
.btn-block { width: 100%; }
.btn-sm { padding: 5px 11px; font-size: 12.5px; }

/* ─── Сообщения (django messages) ─── */
.messages { display: grid; gap: 8px; margin-bottom: 16px; }
.messages .msg {
  padding: 10px 14px;
  border-radius: 9px;
  font-size: 13px;
  border: 1px solid var(--line-2);
  background: var(--card);
}
.messages .msg.error { border-color: var(--ba-bg); background: var(--ba-bg); color: var(--ba); }
.messages .msg.success { border-color: var(--ok-bg); background: var(--ok-bg); color: var(--ok); }

/* ═══════════════ Экран авторизации (auth) ═══════════════ */
.auth-wrap {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 40px 20px;
}
.auth-card { width: 100%; max-width: 420px; }
.auth-brand {
  display: flex;
  align-items: center;
  gap: 9px;
  margin-bottom: 22px;
  font-weight: 700;
  letter-spacing: -0.01em;
}
.auth-brand img { height: 24px; width: auto; display: block; }
.auth-tag {
  font-weight: 500;
  font-size: 11px;
  color: var(--muted);
  border: 1px solid var(--line);
  border-radius: 5px;
  padding: 1px 5px;
  letter-spacing: 0.04em;
}
.auth-box {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 13px;
  padding: 24px;
}
.auth-box h1 { font-size: 20px; margin-bottom: 6px; }
.auth-note { font-size: 13px; color: var(--muted); line-height: 1.55; margin-bottom: 18px; }

.field { display: grid; gap: 7px; margin-bottom: 14px; }
.field label { font-size: 13px; font-weight: 600; color: var(--ink-2); }
.input, .input-textarea, .input-mono {
  width: 100%;
  padding: 10px 13px;
  font-size: 14px;
  color: var(--ink);
  background: var(--card);
  border: 1px solid #DEDBE7;
  border-radius: 9px;
}
.input-mono { font-family: 'IBM Plex Mono', ui-monospace, monospace; }
.input-textarea { resize: vertical; }
.auth-hint { font-size: 12.5px; color: var(--muted); margin-top: 12px; line-height: 1.5; }
.auth-foot {
  border-top: 1px solid var(--line);
  margin-top: 16px;
  padding-top: 14px;
  font-size: 13px;
  color: var(--muted-2);
}
.auth-foot a { font-weight: 600; }
.auth-host {
  margin-top: 14px;
  text-align: center;
  font-size: 12.5px;
  color: #A3A1AD;
  font-family: 'IBM Plex Mono', ui-monospace, monospace;
}
.auth-back { margin-top: 18px; text-align: center; }
.auth-back a { font-size: 12.5px; color: var(--muted); }

/* Экран «ссылка отправлена»: подтверждение адреса. */
.auth-ok {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: var(--ok-bg);
  color: var(--ok);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 22px;
  margin: 0 auto 18px;
}
.auth-email {
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 9px;
  padding: 10px 13px;
  font-family: 'IBM Plex Mono', ui-monospace, monospace;
  font-size: 14px;
  margin: 8px 0 20px;
  word-break: break-all;
}

/* ═══════════════ Shell портала ═══════════════ */
.shell {
  display: grid;
  grid-template-columns: 236px minmax(0, 1fr);
  min-height: 100vh;
  align-items: start;
}

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  background: var(--card);
  border-right: 1px solid var(--line);
  padding: 18px 14px 22px;
  display: flex;
  flex-direction: column;
  gap: 18px;
  min-width: 0;
}
.sidebar .brand {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 0 6px;
  color: var(--ink);
  font-weight: 700;
  letter-spacing: -0.01em;
}
.sidebar .brand img { height: 24px; width: auto; display: block; }
.sidebar .brand .auth-tag { margin-left: auto; }

.search-trigger {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  padding: 8px 10px;
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 9px;
  color: var(--muted);
  font-size: 13px;
  text-align: left;
}
.search-trigger kbd {
  margin-left: auto;
  font-family: 'IBM Plex Mono', ui-monospace, monospace;
  font-size: 11px;
  color: #A3A1AD;
}

.nav { display: grid; gap: 2px; }
.nav a {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 8px 10px;
  border-radius: 9px;
  font-size: 14px;
  color: var(--ink-2);
  font-weight: 500;
}
.nav a:hover { background: var(--bg); color: var(--ink); }
.nav a.is-active { background: var(--line-2); color: var(--ink); font-weight: 600; }
.nav a .label { flex: 1; min-width: 0; }
.nav a .count {
  flex: none;
  font-family: 'IBM Plex Mono', ui-monospace, monospace;
  font-size: 11.5px;
  padding: 1px 6px;
  border-radius: 999px;
  color: var(--muted);
}
.nav a.is-active .count { background: var(--card); }

.sidebar-foot { margin-top: auto; display: grid; gap: 10px; min-width: 0; }
.sidebar-links { display: flex; gap: 6px; flex-wrap: wrap; }
.sidebar-links a {
  font-size: 11.5px;
  color: #A3A1AD;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 2px 7px;
}
.level-box {
  padding: 12px;
  background: var(--bg);
  border-radius: 10px;
}
.level-box .cap { font-size: 12px; color: var(--muted); margin-bottom: 6px; }
.level-box .cur { display: flex; align-items: center; gap: 7px; font-size: 12.5px; font-weight: 600; }
.level-box .dot { width: 7px; height: 7px; border-radius: 50%; display: block; background: var(--accent); }
.level-box .sub { font-size: 12px; color: var(--muted); margin-top: 4px; }
.whoami {
  border-top: 1px solid var(--line);
  padding-top: 11px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  min-width: 0;
}
.whoami .who-ellipsis { min-width: 0; overflow: hidden; }
.whoami .label { font-size: 12px; color: var(--muted); }
.whoami .who {
  font-size: 12.5px;
  font-family: 'IBM Plex Mono', ui-monospace, monospace;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ─── Main ─── */
.main { min-width: 0; padding: 0 0 80px; }
.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 13px clamp(16px, 2.4vw, 28px);
  background: rgba(244, 243, 247, 0.92);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--line);
}
.topbar .titles { flex: 1; min-width: 0; display: flex; align-items: baseline; gap: 10px; }
.topbar h1 { font-size: 19px; font-weight: 700; }
.topbar .subtitle {
  font-size: 13px;
  color: var(--muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.content { padding: 22px clamp(16px, 2.4vw, 28px) 0; max-width: 1480px; }

/* ═══════════════ Компоненты данных ═══════════════ */
.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 13px;
  overflow: hidden;
}
.card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--line-2);
}
.card-head h2 { font-size: 14px; }
.card-head .head-note { font-size: 12.5px; color: var(--muted); }
.card-body { padding: 16px; }

/* Статус-пилюли. */
.pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 3px 9px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
  white-space: nowrap;
  background: var(--line-2);
  color: var(--ink-2);
}
.pill.ok { background: var(--ok-bg); color: var(--ok); }
.pill.wa { background: var(--wa-bg); color: var(--wa); }
.pill.ba { background: var(--ba-bg); color: var(--ba); }
.pill.accent { background: var(--accent-soft); color: var(--accent); }
.pill .dot { width: 8px; height: 8px; border-radius: 50%; display: block; }
.pill .dot.ok { background: var(--ok); }
.pill .dot.wa { background: var(--wa); }
.pill .dot.muted { background: var(--muted); }

/* KPI-полоса: несколько одинаковых ячеек через разделители. */
.kpi {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(168px, 1fr));
  gap: 1px;
  background: var(--line);
  border: 1px solid var(--line);
  border-radius: 12px;
  overflow: hidden;
}
.kpi .cell { background: var(--card); padding: 13px 15px; }
.kpi .cell .cap { font-size: 12px; color: var(--muted); margin-bottom: 5px; }
.kpi .cell .val { display: flex; align-items: baseline; gap: 7px; }
.kpi .cell .val b { font-size: 23px; font-weight: 700; letter-spacing: -0.03em; font-variant-numeric: tabular-nums; }
.kpi .cell .val .unit { font-size: 12px; color: var(--muted); }

/* Таблица-сетка с горизонтальной прокруткой на узких экранах. */
.table-scroll { overflow-x: auto; }
.table-grid {
  display: grid;
  gap: 14px;
  align-items: center;
  min-width: 820px;
}
.table-head {
  padding: 10px 16px;
  background: var(--hover);
  border-bottom: 1px solid var(--line);
  font-size: 11.5px;
  font-weight: 700;
  letter-spacing: 0.05em;
  color: var(--muted);
}
.table-row {
  padding: 11px 16px;
  border-bottom: 1px solid var(--line-3);
  font-size: 13px;
}
.table-row:last-child { border-bottom: 0; }
.r { text-align: right; }

@media (max-width: 1100px) {
  .shell { grid-template-columns: minmax(0,1fr); }
  .sidebar { position: static; height: auto; }
}

/* ─── Палитра поиска ⌘K ─── */
.palette {
  width: min(560px, 92vw);
  border: 1px solid var(--line);
  border-radius: 13px;
  padding: 0;
  background: var(--card);
  color: var(--ink);
  box-shadow: 0 12px 40px rgba(34, 33, 42, 0.18);
}
.palette::backdrop { background: rgba(34, 33, 42, 0.32); }
.palette-input {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 16px;
  border-bottom: 1px solid var(--line);
}
.palette-input .palette-icon { color: var(--muted); font-size: 18px; }
.palette-input input {
  flex: 1;
  border: 0;
  outline: 0;
  font-size: 15px;
  background: transparent;
  color: var(--ink);
}
.palette-input kbd {
  font-family: 'IBM Plex Mono', ui-monospace, monospace;
  font-size: 11px;
  color: var(--muted);
}
#palette-results { max-height: 360px; overflow-y: auto; }
.palette-row {
  padding: 10px 16px;
  border-bottom: 1px solid var(--line-3);
  font-size: 13px;
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}
.palette-row:last-child { border-bottom: 0; }
.palette-row.muted { color: var(--muted); justify-content: center; }
.palette-foot {
  padding: 9px 16px;
  border-top: 1px solid var(--line);
  font-size: 11.5px;
  color: var(--muted);
}

