/* ============================================================================
   Пульс — дизайн-система.
   Светлая «карточная» тема: воздух, мягкие тени, крупные понятные цифры.
   Никаких внешних шрифтов и CDN — всё локально.
   ========================================================================== */

:root {
  /* Палитра */
  --bg:            #F4F7FB;
  --bg-soft:       #EDF2F9;
  --surface:       #FFFFFF;
  --border:        #E9EEF5;
  --border-strong: #D8E1EC;

  --text:          #101828;
  --text-2:        #667085;
  --text-3:        #98A2B3;

  --primary:       #2F6FED;
  --primary-dark:  #255FD6;
  --primary-soft:  #EAF1FE;

  --ok:            #12B76A;
  --ok-soft:       #E7F8F0;
  --warn:          #F79009;
  --warn-soft:     #FEF4E6;
  --crit:          #F04438;
  --crit-soft:     #FEECEB;
  --accent:        #22C7E0;
  --accent-soft:   #E4F8FB;
  --violet:        #7A5AF8;
  --violet-soft:   #EFEBFE;

  /* Форма */
  --r-sm: 8px;
  --r-md: 12px;
  --r-lg: 16px;
  --r-xl: 20px;
  --r-full: 999px;

  --shadow-xs: 0 1px 2px rgba(16, 24, 40, .04);
  --shadow-sm: 0 1px 3px rgba(16, 24, 40, .06), 0 1px 2px rgba(16, 24, 40, .04);
  --shadow-md: 0 4px 12px rgba(16, 24, 40, .07);
  --shadow-lg: 0 12px 32px rgba(16, 24, 40, .12);

  --sidebar-w: 248px;
  --header-h: 68px;

  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue",
          Arial, "Noto Sans", "Liberation Sans", sans-serif;
  --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, "Liberation Mono", monospace;
}

* { box-sizing: border-box; }

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

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

a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }

h1, h2, h3, h4 { margin: 0; font-weight: 600; letter-spacing: -.01em; }
h1 { font-size: 24px; }
h2 { font-size: 18px; }
h3 { font-size: 15px; }
p  { margin: 0 0 12px; }
code, pre, .mono { font-family: var(--mono); }

::selection { background: var(--primary-soft); }

/* ─────────────────────────────── Каркас ─────────────────────────────────── */

.layout {
  display: grid;
  grid-template-columns: var(--sidebar-w) 1fr;
  min-height: 100vh;
}

.sidebar {
  background: var(--surface);
  border-right: 1px solid var(--border);
  padding: 20px 14px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 4px 8px 20px;
}
.brand-mark {
  width: 36px; height: 36px;
  flex: 0 0 36px;
  border-radius: 10px;
  display: grid; place-items: center;
  background: linear-gradient(135deg, #2F6FED 0%, #22C7E0 60%, #12B76A 100%);
  box-shadow: var(--shadow-sm);
}
.brand-name { font-weight: 600; font-size: 15px; line-height: 1.2; }
.brand-sub { font-size: 12px; color: var(--text-3); }

.nav-group-title {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--text-3);
  padding: 14px 10px 6px;
  font-weight: 600;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 9px 12px;
  border-radius: var(--r-md);
  color: var(--text-2);
  font-weight: 500;
  cursor: pointer;
  transition: background .14s, color .14s;
  text-decoration: none;
  user-select: none;
}
.nav-item:hover { background: var(--bg-soft); color: var(--text); text-decoration: none; }
.nav-item.active {
  background: var(--primary);
  color: #fff;
  box-shadow: 0 4px 12px rgba(47, 111, 237, .28);
}
.nav-item.active:hover { background: var(--primary); color: #fff; }
.nav-item svg { flex: 0 0 20px; }
.nav-item .nav-badge {
  margin-left: auto;
  background: var(--crit);
  color: #fff;
  font-size: 11px;
  font-weight: 600;
  padding: 1px 7px;
  border-radius: var(--r-full);
}
.nav-item.active .nav-badge { background: rgba(255, 255, 255, .25); }

.sidebar-footer { margin-top: auto; padding-top: 16px; }

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

.topbar {
  height: var(--header-h);
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 0 28px;
  background: rgba(244, 247, 251, .85);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 30;
}
.topbar h1 { font-size: 20px; }
.topbar-sub { color: var(--text-2); font-size: 13px; }
.topbar-actions { margin-left: auto; display: flex; align-items: center; gap: 10px; }

.page { padding: 24px 28px 56px; flex: 1; }
.page-narrow { max-width: 880px; }

/* ─────────────────────────────── Сетки ──────────────────────────────────── */

.grid { display: grid; gap: 16px; }
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.grid-main { grid-template-columns: minmax(0, 1fr) 340px; }
/* Ряд компактных плиток: сам подбирает число колонок, на телефоне — две. */
.grid-tiles { grid-template-columns: repeat(auto-fit, minmax(165px, 1fr)); }
.grid-side { grid-template-columns: 300px minmax(0, 1fr); }
.row { display: flex; align-items: center; gap: 10px; }
.row-between { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.col { display: flex; flex-direction: column; gap: 10px; }
.wrap { flex-wrap: wrap; }
.grow { flex: 1; min-width: 0; }
.spacer { flex: 1; }

/* ─────────────────────────────── Карточки ───────────────────────────────── */

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-xs);
  padding: 18px 20px;
}
.card-flat { box-shadow: none; }
.card-pad-0 { padding: 0; }
.card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 16px;
}
.card-title { font-size: 15px; font-weight: 600; }
.card-sub { font-size: 12px; color: var(--text-3); margin-top: 2px; }
.card-hover { transition: box-shadow .16s, transform .16s, border-color .16s; }
.card-hover:hover { box-shadow: var(--shadow-md); border-color: var(--border-strong); }
.card-link { cursor: pointer; }

/* Плитка статуса сервиса (как в макете: точка + подпись + крупный процент) */
.tile {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  padding: 14px 16px;
  min-width: 0;
}
.tile-label { display: flex; align-items: center; gap: 7px; font-size: 13px; color: var(--text-2); }
.tile-value { font-size: 22px; font-weight: 600; margin-top: 8px; letter-spacing: -.02em; }
.tile-value.ok { color: var(--ok); }
.tile-value.warn { color: var(--warn); }
.tile-value.crit { color: var(--crit); }
.tile-note { font-size: 12px; color: var(--text-3); margin-top: 2px; }

/* KPI-блок: крупное число + мини-график */
.kpi { display: flex; align-items: flex-end; justify-content: space-between; gap: 12px; }
.kpi-value { font-size: 34px; font-weight: 600; letter-spacing: -.03em; line-height: 1; }
.kpi-label { font-size: 13px; color: var(--text-2); }
.kpi-delta { font-size: 12px; font-weight: 500; display: inline-flex; align-items: center; gap: 3px; }
.kpi-delta.up { color: var(--ok); }
.kpi-delta.down { color: var(--crit); }

/* ─────────────────────────────── Индикаторы ─────────────────────────────── */

.dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  flex: 0 0 8px;
  background: var(--text-3);
  display: inline-block;
}
.dot-ok   { background: var(--ok); }
.dot-warn { background: var(--warn); }
.dot-crit { background: var(--crit); }
.dot-info { background: var(--primary); }
.dot-idle { background: var(--text-3); }
.dot-lg { width: 10px; height: 10px; flex-basis: 10px; }
.dot-pulse { position: relative; }
.dot-pulse::after {
  content: ''; position: absolute; inset: -4px;
  border-radius: 50%; border: 2px solid currentColor; opacity: .35;
  animation: pulse 2s ease-out infinite;
}
@keyframes pulse {
  0%   { transform: scale(.7); opacity: .5; }
  100% { transform: scale(1.5); opacity: 0; }
}

.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 3px 10px;
  border-radius: var(--r-full);
  font-size: 12px;
  font-weight: 500;
  background: var(--bg-soft);
  color: var(--text-2);
  white-space: nowrap;
}
.chip-ok    { background: var(--ok-soft);      color: #0A8A50; }
.chip-warn  { background: var(--warn-soft);    color: #B76E00; }
.chip-crit  { background: var(--crit-soft);    color: #C4342B; }
.chip-info  { background: var(--primary-soft); color: var(--primary-dark); }
.chip-violet{ background: var(--violet-soft);  color: #5B3ED6; }
.chip-lg { padding: 5px 12px; font-size: 13px; }

.badge {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 20px; height: 20px; padding: 0 6px;
  border-radius: var(--r-full);
  background: var(--crit); color: #fff;
  font-size: 11px; font-weight: 600;
}

/* Иконка-плитка (цветной квадрат с иконкой) */
.icon-tile {
  width: 38px; height: 38px; flex: 0 0 38px;
  border-radius: var(--r-md);
  display: grid; place-items: center;
  background: var(--primary-soft);
  color: var(--primary);
}
.icon-tile.ok    { background: var(--ok-soft);      color: var(--ok); }
.icon-tile.warn  { background: var(--warn-soft);    color: var(--warn); }
.icon-tile.crit  { background: var(--crit-soft);    color: var(--crit); }
.icon-tile.violet{ background: var(--violet-soft);  color: var(--violet); }
.icon-tile.accent{ background: var(--accent-soft);  color: #0E9BB2; }
.icon-tile.sm { width: 30px; height: 30px; flex-basis: 30px; border-radius: var(--r-sm); }

.avatar {
  width: 30px; height: 30px; flex: 0 0 30px;
  border-radius: 50%;
  display: grid; place-items: center;
  background: var(--primary);
  color: #fff;
  font-size: 12px;
  font-weight: 600;
  user-select: none;
}
.avatar-sm { width: 24px; height: 24px; flex-basis: 24px; font-size: 10px; }
.avatar-lg { width: 44px; height: 44px; flex-basis: 44px; font-size: 16px; }

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

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 9px 16px;
  border-radius: var(--r-md);
  border: 1px solid var(--border-strong);
  background: var(--surface);
  color: var(--text);
  font: inherit;
  font-weight: 500;
  cursor: pointer;
  transition: background .14s, border-color .14s, box-shadow .14s, transform .06s;
  white-space: nowrap;
  text-decoration: none;
}
.btn:hover { background: var(--bg-soft); text-decoration: none; }
.btn:active { transform: translateY(1px); }
.btn:disabled, .btn.disabled { opacity: .5; cursor: not-allowed; transform: none; }

.btn-primary {
  background: var(--primary);
  border-color: var(--primary);
  color: #fff;
  box-shadow: 0 2px 8px rgba(47, 111, 237, .25);
}
.btn-primary:hover { background: var(--primary-dark); border-color: var(--primary-dark); }

.btn-ok   { background: var(--ok);   border-color: var(--ok);   color: #fff; }
.btn-ok:hover { background: #0EA05C; border-color: #0EA05C; }
.btn-crit { background: var(--crit); border-color: var(--crit); color: #fff; }
.btn-crit:hover { background: #DA3B31; border-color: #DA3B31; }

.btn-ghost { border-color: transparent; background: transparent; color: var(--text-2); }
.btn-ghost:hover { background: var(--bg-soft); color: var(--text); }

.btn-sm { padding: 6px 11px; font-size: 13px; border-radius: var(--r-sm); }
.btn-lg { padding: 12px 22px; font-size: 15px; }
.btn-icon { padding: 8px; width: 36px; height: 36px; }
.btn-block { width: 100%; }

.btn-group { display: inline-flex; background: var(--bg-soft); border-radius: var(--r-md); padding: 3px; gap: 2px; }
.btn-group button {
  border: 0; background: transparent; color: var(--text-2);
  font: inherit; font-size: 13px; font-weight: 500;
  padding: 5px 12px; border-radius: var(--r-sm); cursor: pointer;
}
.btn-group button.active { background: var(--surface); color: var(--text); box-shadow: var(--shadow-xs); }

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

.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 16px; }
.field-label { font-size: 13px; font-weight: 500; color: var(--text); }
.field-hint  { font-size: 12px; color: var(--text-3); }
.field-error { font-size: 12px; color: var(--crit); }
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }

.input, .select, .textarea {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--border-strong);
  border-radius: var(--r-md);
  background: var(--surface);
  color: var(--text);
  font: inherit;
  transition: border-color .14s, box-shadow .14s;
}
.input:focus, .select:focus, .textarea:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-soft);
}
.input::placeholder, .textarea::placeholder { color: var(--text-3); }
.input:disabled, .select:disabled { background: var(--bg-soft); color: var(--text-3); }
.textarea { min-height: 90px; resize: vertical; font-family: var(--font); }
.input-mono { font-family: var(--mono); font-size: 13px; }
.select {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%23667085' stroke-width='2' stroke-linecap='round'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 34px;
}

.input-group { display: flex; gap: 8px; align-items: stretch; }
.input-group .input { flex: 1; }

.toggle { display: inline-flex; align-items: center; gap: 10px; cursor: pointer; user-select: none; }
.toggle input { display: none; }
.toggle-track {
  width: 40px; height: 22px; border-radius: var(--r-full);
  background: var(--border-strong); position: relative; transition: background .16s;
  flex: 0 0 40px;
}
.toggle-track::after {
  content: ''; position: absolute; top: 3px; left: 3px;
  width: 16px; height: 16px; border-radius: 50%;
  background: #fff; box-shadow: var(--shadow-xs); transition: transform .16s;
}
.toggle input:checked + .toggle-track { background: var(--primary); }
.toggle input:checked + .toggle-track::after { transform: translateX(18px); }
.toggle-label { font-size: 13px; }

.checkbox { display: inline-flex; align-items: center; gap: 8px; cursor: pointer; font-size: 13px; }
.checkbox input { width: 16px; height: 16px; accent-color: var(--primary); }

.radio-cards { display: grid; gap: 10px; }
.radio-card {
  border: 1px solid var(--border-strong);
  border-radius: var(--r-md);
  padding: 12px 14px;
  cursor: pointer;
  display: flex; gap: 12px; align-items: flex-start;
  transition: border-color .14s, background .14s;
}
.radio-card:hover { border-color: var(--primary); }
/* Выбор показываем только обводкой: кружок переключателя сдвигал бы содержимое.
   Кольцо рисуем тенью, а не толщиной рамки — тогда карточка не «прыгает». */
.radio-card.selected {
  border-color: var(--primary);
  background: var(--primary-soft);
  box-shadow: 0 0 0 1px var(--primary);
}
.radio-card input {
  position: absolute;
  width: 1px; height: 1px;
  opacity: 0;
  margin: 0;
  pointer-events: none;
}
.radio-card:focus-within { box-shadow: 0 0 0 3px var(--primary-soft); }

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

.table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.table th {
  text-align: left;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-3);
  text-transform: uppercase;
  letter-spacing: .04em;
  padding: 10px 14px;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
.table td { padding: 13px 14px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.table tbody tr:last-child td { border-bottom: 0; }
.table tbody tr.clickable { cursor: pointer; }
.table tbody tr.clickable:hover { background: var(--bg-soft); }
.table .num { text-align: right; font-variant-numeric: tabular-nums; }
.table-wrap { overflow-x: auto; }

/* Список событий (лента) */
.feed { display: flex; flex-direction: column; }
.feed-item {
  display: flex;
  gap: 12px;
  padding: 11px 0;
  border-bottom: 1px solid var(--border);
}
.feed-item:last-child { border-bottom: 0; }
.feed-item .dot { margin-top: 6px; }
.feed-title { font-size: 13.5px; font-weight: 500; }
.feed-time { font-size: 12px; color: var(--text-3); margin-top: 2px; }

/* Строка-задача из макета: плитка-иконка, текст, статус, аватар */
.task-row {
  display: flex; align-items: center; gap: 12px;
  padding: 12px; border-radius: var(--r-md);
  transition: background .14s;
}
.task-row:hover { background: var(--bg-soft); }
.task-name { font-weight: 500; font-size: 13.5px; }
.task-sub { font-size: 12px; color: var(--text-3); }

/* Чек-лист (карточка «Анализ кода» из макета) */
.checklist { display: flex; flex-direction: column; gap: 9px; }
.checklist li { display: flex; align-items: center; gap: 9px; font-size: 13.5px; color: var(--text-2); }
.checklist { list-style: none; padding: 0; margin: 0; }
.check-mark { color: var(--ok); flex: 0 0 16px; }

/* ─────────────────────────────── Вкладки ────────────────────────────────── */

.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--border); margin-bottom: 20px; }
.tab {
  padding: 10px 14px;
  font-size: 13.5px;
  font-weight: 500;
  color: var(--text-2);
  cursor: pointer;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  transition: color .14s, border-color .14s;
}
.tab:hover { color: var(--text); }
.tab.active { color: var(--primary); border-bottom-color: var(--primary); }

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

.modal-backdrop {
  position: fixed; inset: 0;
  background: rgba(16, 24, 40, .45);
  backdrop-filter: blur(2px);
  display: grid; place-items: center;
  z-index: 100;
  padding: 24px;
  animation: fade .16s ease-out;
}
.modal {
  background: var(--surface);
  border-radius: var(--r-xl);
  box-shadow: var(--shadow-lg);
  width: 100%;
  max-width: 520px;
  max-height: 88vh;
  display: flex;
  flex-direction: column;
  animation: rise .18s cubic-bezier(.2, .8, .3, 1);
}
.modal-lg { max-width: 760px; }
.modal-head {
  padding: 20px 24px 14px;
  display: flex; align-items: flex-start; justify-content: space-between; gap: 12px;
}
.modal-body { padding: 0 24px; overflow-y: auto; flex: 1; }
.modal-foot {
  padding: 18px 24px 20px;
  display: flex; gap: 10px; justify-content: flex-end;
  border-top: 1px solid var(--border);
  margin-top: 18px;
}
@keyframes fade { from { opacity: 0; } }
@keyframes rise { from { opacity: 0; transform: translateY(12px) scale(.98); } }

/* ─────────────────────────────── Тосты ──────────────────────────────────── */

.toasts {
  position: fixed; top: 20px; right: 20px;
  display: flex; flex-direction: column; gap: 10px;
  z-index: 200;
  pointer-events: none;
}
.toast {
  display: flex; align-items: center; gap: 12px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-lg);
  padding: 14px 18px;
  min-width: 300px;
  max-width: 420px;
  pointer-events: auto;
  animation: slide-in .22s cubic-bezier(.2, .8, .3, 1);
}
.toast.leaving { animation: slide-out .18s ease-in forwards; }
.toast-icon {
  width: 32px; height: 32px; flex: 0 0 32px;
  border-radius: 50%;
  display: grid; place-items: center;
  background: var(--ok); color: #fff;
}
.toast.err .toast-icon  { background: var(--crit); }
.toast.warn .toast-icon { background: var(--warn); }
.toast.info .toast-icon { background: var(--primary); }
.toast-title { font-weight: 600; font-size: 14px; }
.toast-text  { font-size: 12.5px; color: var(--text-2); }
@keyframes slide-in  { from { opacity: 0; transform: translateX(24px); } }
@keyframes slide-out { to   { opacity: 0; transform: translateX(24px); } }

/* Всплывающая подсказка графика (пилюля «CPU 42%») */
.chart-tip {
  position: absolute;
  background: #1D2939;
  color: #fff;
  font-size: 12px;
  font-weight: 500;
  padding: 5px 10px;
  border-radius: var(--r-full);
  pointer-events: none;
  white-space: nowrap;
  transform: translate(-50%, -140%);
  box-shadow: var(--shadow-md);
  z-index: 5;
}
.chart-wrap { position: relative; }
.chart-legend { display: flex; gap: 16px; align-items: center; font-size: 12.5px; color: var(--text-2); }
.chart-legend .dot { width: 7px; height: 7px; flex-basis: 7px; }

/* ────────────────────────── Пустые состояния / загрузка ─────────────────── */

.empty { text-align: center; padding: 48px 24px; color: var(--text-2); }
.empty-icon {
  width: 56px; height: 56px; margin: 0 auto 16px;
  border-radius: var(--r-lg);
  background: var(--bg-soft);
  display: grid; place-items: center;
  color: var(--text-3);
}
.empty-title { font-size: 15px; font-weight: 600; color: var(--text); margin-bottom: 6px; }
.empty-text { font-size: 13.5px; max-width: 420px; margin: 0 auto 18px; }

.skeleton {
  background: linear-gradient(90deg, var(--bg-soft) 25%, #F7FAFD 50%, var(--bg-soft) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.3s infinite;
  border-radius: var(--r-sm);
  height: 14px;
}
@keyframes shimmer { to { background-position: -200% 0; } }

.spinner {
  width: 18px; height: 18px;
  border: 2px solid var(--border-strong);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin .7s linear infinite;
  display: inline-block;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ──────────────────────────── Прочие элементы ───────────────────────────── */

.hr { height: 1px; background: var(--border); border: 0; margin: 18px 0; }

.muted   { color: var(--text-2); }
.dim     { color: var(--text-3); }
.small   { font-size: 12.5px; }
.tiny    { font-size: 11.5px; }
.strong  { font-weight: 600; }
.nowrap  { white-space: nowrap; }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tnum    { font-variant-numeric: tabular-nums; }
.center  { text-align: center; }
.right   { text-align: right; }
.c-ok { color: var(--ok); } .c-warn { color: var(--warn); }
.c-crit { color: var(--crit); } .c-primary { color: var(--primary); }

.mt-0{margin-top:0}.mt-1{margin-top:4px}.mt-2{margin-top:8px}.mt-3{margin-top:12px}
.mt-4{margin-top:16px}.mt-5{margin-top:20px}.mt-6{margin-top:24px}
.mb-0{margin-bottom:0}.mb-1{margin-bottom:4px}.mb-2{margin-bottom:8px}.mb-3{margin-bottom:12px}
.mb-4{margin-bottom:16px}.mb-5{margin-bottom:20px}.mb-6{margin-bottom:24px}
.gap-1{gap:4px}.gap-2{gap:8px}.gap-3{gap:12px}.gap-4{gap:16px}

/* Блок кода: шапка с языком и кнопкой «Копировать», под ней прокручиваемый код.
   Кнопка вынесена из области кода — иначе на однострочном примере она ложится
   поверх текста, а при горизонтальной прокрутке уезжает вместе с ним. */
.code-block {
  background: #0F172A;
  color: #E2E8F0;
  border-radius: var(--r-md);
  padding: 14px 16px;
  font-family: var(--mono);
  font-size: 12.5px;
  line-height: 1.65;
  overflow: hidden;
  position: relative;
  white-space: pre;
  tab-size: 2;
}
.code-block:has(.code-head) { padding: 0; }

.code-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 7px 10px 7px 16px;
  background: rgba(255, 255, 255, .04);
  border-bottom: 1px solid rgba(255, 255, 255, .07);
}
.code-lang {
  font-size: 11px;
  letter-spacing: .05em;
  text-transform: uppercase;
  color: #64748B;
}
.code-body {
  margin: 0;
  padding: 14px 16px;
  overflow-x: auto;
  white-space: pre;
  font: inherit;
  color: inherit;
}
.code-block .k { color: #93C5FD; }   /* ключевые слова */
.code-block .s { color: #86EFAC; }   /* строки */
.code-block .c { color: #64748B; font-style: italic; }  /* комментарии */
.code-block .n { color: #FCD34D; }   /* числа */
.code-block .t { color: #67E8F9; }   /* типы и вызовы */
.code-block .v { color: #F0ABFC; }   /* переменные */
.code-block .p { color: #94A3B8; }   /* пунктуация */
.code-copy {
  background: rgba(255, 255, 255, .1);
  border: 0; color: #CBD5E1;
  padding: 5px 10px; border-radius: var(--r-sm);
  font-size: 11.5px; cursor: pointer; font-family: var(--font);
  white-space: nowrap; flex: 0 0 auto;
}
/* Запасной вариант для блоков без шапки: кнопка в углу, текст её обтекает. */
.code-block:not(:has(.code-head)) .code-copy { position: absolute; top: 10px; right: 10px; }
.code-block:not(:has(.code-head)):has(.code-copy) { padding-right: 108px; }
.code-copy:hover { background: rgba(255, 255, 255, .18); }

.key-box {
  display: flex; align-items: center; gap: 8px;
  background: var(--bg-soft);
  border: 1px dashed var(--border-strong);
  border-radius: var(--r-md);
  padding: 9px 12px;
  font-family: var(--mono);
  font-size: 12.5px;
}

/* Столбчатая диаграмма: ширина столбцов подбирается браузером,
   поэтому скругления не искажаются при растягивании. */
.bar-chart { display: flex; align-items: flex-end; width: 100%; }
.bar-chart i { flex: 1 1 0; min-width: 2px; transition: opacity .12s; }
.bar-chart i:hover { opacity: .7; }

/* Полоса аптайма (столбики за 30 дней / 24 часа) */
.uptime-bar { display: flex; gap: 2px; align-items: flex-end; height: 30px; }
.uptime-bar i {
  flex: 1; min-width: 2px; border-radius: 2px;
  background: var(--ok); height: 100%;
  transition: opacity .12s;
}
.uptime-bar i.down     { background: var(--crit); }
.uptime-bar i.degraded { background: var(--warn); }
.uptime-bar i.none     { background: var(--border); }
.uptime-bar i:hover    { opacity: .65; }

/* Шаги мастера настройки */
.steps { display: flex; align-items: center; gap: 8px; margin-bottom: 28px; }
.step { display: flex; align-items: center; gap: 9px; color: var(--text-3); font-size: 13px; font-weight: 500; }
.step-num {
  width: 26px; height: 26px; border-radius: 50%;
  display: grid; place-items: center;
  background: var(--bg-soft); color: var(--text-3);
  font-size: 12px; font-weight: 600;
}
.step.active { color: var(--text); }
.step.active .step-num { background: var(--primary); color: #fff; }
.step.done .step-num { background: var(--ok-soft); color: var(--ok); }
.step.done { color: var(--text-2); }
.step-line { flex: 1; height: 1px; background: var(--border); min-width: 20px; }

/* Тарифные карточки */
.plan-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: 22px;
  display: flex; flex-direction: column; gap: 14px;
  position: relative;
  transition: border-color .16s, box-shadow .16s, transform .16s;
}
.plan-card:hover { box-shadow: var(--shadow-md); }
.plan-card.popular { border-color: var(--primary); box-shadow: 0 8px 24px rgba(47, 111, 237, .12); }
.plan-card.current { border-color: var(--ok); }
.plan-flag {
  position: absolute; top: -11px; left: 22px;
  background: var(--primary); color: #fff;
  font-size: 11px; font-weight: 600;
  padding: 3px 10px; border-radius: var(--r-full);
}
.plan-card.current .plan-flag { background: var(--ok); }
.plan-price { font-size: 30px; font-weight: 600; letter-spacing: -.03em; }
.plan-price small { font-size: 14px; font-weight: 400; color: var(--text-3); }
.plan-features { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 9px; }
.plan-features li { display: flex; gap: 8px; font-size: 13px; color: var(--text-2); align-items: flex-start; }

/* Индикатор потребления лимита */
.meter { height: 6px; background: var(--bg-soft); border-radius: var(--r-full); overflow: hidden; }
.meter i { display: block; height: 100%; background: var(--primary); border-radius: var(--r-full); transition: width .3s; }
.meter i.warn { background: var(--warn); }
.meter i.crit { background: var(--crit); }

/* Экран входа */
.auth-screen { min-height: 100vh; display: grid; place-items: center; padding: 24px; background: var(--bg); }
.auth-card { width: 100%; max-width: 420px; }
.auth-logo { display: flex; align-items: center; gap: 12px; justify-content: center; margin-bottom: 26px; }

/* Баннер (пробный период, превышение лимита) */
.banner {
  display: flex; align-items: center; gap: 12px;
  padding: 12px 16px;
  border-radius: var(--r-md);
  background: var(--primary-soft);
  color: var(--primary-dark);
  font-size: 13.5px;
  margin-bottom: 18px;
}
.banner.warn { background: var(--warn-soft); color: #B76E00; }
.banner.crit { background: var(--crit-soft); color: #C4342B; }
.banner .btn { margin-left: auto; }

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

@media (max-width: 1200px) {
  .grid-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .grid-main { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 900px) {
  .layout { grid-template-columns: 1fr; }
  .sidebar {
    position: fixed; left: 0; top: 0; bottom: 0;
    width: var(--sidebar-w); z-index: 90;
    transform: translateX(-100%);
    transition: transform .2s;
    box-shadow: var(--shadow-lg);
  }
  .sidebar.open { transform: none; }
  .sidebar-scrim { position: fixed; inset: 0; background: rgba(16,24,40,.35); z-index: 80; }
  .grid-2, .grid-3, .grid-4, .grid-side { grid-template-columns: minmax(0, 1fr); }
  .page { padding: 18px 16px 48px; }
  .field-row { grid-template-columns: 1fr; }

  /* Шапка на узком экране: высота по содержимому, заголовок в одну строку,
     подпись убираем — иначе длинный заголовок обрезается сверху. */
  .topbar {
    height: auto;
    min-height: 58px;
    padding: 10px 14px;
    gap: 10px;
  }
  .topbar > div { min-width: 0; flex: 1; }
  .topbar h1 {
    font-size: 17px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }
  .topbar .topbar-sub { display: none !important; }
  .topbar-actions { gap: 6px; flex-shrink: 0; }
  .topbar-actions .btn { padding: 7px 11px; font-size: 13px; }

  /* Шапка карточки переносится: переключатель диапазона иначе вылезает за край. */
  .card-head { flex-wrap: wrap; row-gap: 10px; }
  .card-head > * { min-width: 0; }
  .btn-group { max-width: 100%; overflow-x: auto; }
  .chart-legend { flex-wrap: wrap; gap: 6px 12px; }
  .tabs { overflow-x: auto; }
  .tab { white-space: nowrap; }

  .steps { flex-wrap: wrap; gap: 6px 10px; }
  .step-line { display: none; }
  .kpi-value { font-size: 28px; }
  .modal-foot { flex-wrap: wrap; }
  .table th, .table td { padding: 10px; }
}
@media (min-width: 901px) {
  .only-mobile { display: none !important; }
}

@media print {
  .sidebar, .topbar-actions, .btn { display: none !important; }
  body { background: #fff; }
}
