/* =========================================================================
   XPNP — единая дизайн-система (тёмная тема).
   Все страницы строятся только на переменных ниже. Не задавайте цвета
   напрямую в шаблонах — добавляйте/используйте токены.
   ========================================================================= */

:root {
  /* --- фоны слоями --- */
  --bg: #0b0d12;
  --surface: #12151c;
  --surface-raised: #171b24;
  --overlay: #1c2130;

  /* --- границы --- */
  --border: rgba(255, 255, 255, 0.08);
  --border-strong: rgba(255, 255, 255, 0.16);
  --border-accent: rgba(99, 102, 241, 0.55);

  /* --- текст --- */
  --text: #e7eaf0;
  --text-secondary: #a5adbe;
  --text-muted: #6c7488;

  /* --- фирменный акцент --- */
  --accent: #6366f1;
  --accent-strong: #4f46e5;
  --accent-soft: rgba(99, 102, 241, 0.16);
  --accent-text: #ffffff;
  --accent-gradient: linear-gradient(135deg, #6366f1 0%, #8b5cf6 100%);

  /* --- семантика --- */
  --success: #34d399;
  --success-soft: rgba(52, 211, 153, 0.14);
  --warning: #fbbf24;
  --warning-soft: rgba(251, 191, 36, 0.14);
  --danger: #f87171;
  --danger-soft: rgba(248, 113, 113, 0.14);
  --info: #60a5fa;
  --info-soft: rgba(96, 165, 250, 0.14);

  /* --- геометрия --- */
  --radius-sm: 8px;
  --radius: 12px;
  --radius-lg: 14px;
  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-5: 24px;
  --space-6: 32px;

  /* --- тени/подсветка --- */
  --shadow-1: 0 1px 2px rgba(0, 0, 0, 0.35);
  --shadow-2: 0 12px 32px rgba(0, 0, 0, 0.45);
  --inner-hl: inset 0 1px 0 rgba(255, 255, 255, 0.04);

  /* --- типографика --- */
  --font: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue",
    Arial, sans-serif;
  --mono: "JetBrains Mono", ui-monospace, SFMono-Regular, "Cascadia Mono",
    Consolas, "Liberation Mono", monospace;

  --sidebar-w: 264px;
  --topbar-h: 60px;
  --focus: 0 0 0 3px rgba(99, 102, 241, 0.45);
}

* { box-sizing: border-box; }

html, body { margin: 0; padding: 0; }

body {
  background:
    radial-gradient(900px 500px at 100% -10%, rgba(99, 102, 241, 0.10), transparent 60%),
    radial-gradient(700px 400px at -10% 0%, rgba(139, 92, 246, 0.07), transparent 55%),
    var(--bg);
  background-attachment: fixed;
  color: var(--text);
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
:focus-visible { outline: none; box-shadow: var(--focus); border-radius: var(--radius-sm); }

/* числа, токены, hwid — моноширинные и табличные */
.mono, code, kbd, samp, .tabular { font-family: var(--mono); font-variant-numeric: tabular-nums; }
.mono { font-size: 12.5px; }
.tnum { font-variant-numeric: tabular-nums; }

h1, h2, h3, h4 { font-weight: 650; letter-spacing: -0.01em; margin: 0; }
h1 { font-size: 24px; }
h2 { font-size: 20px; }
h3 { font-size: 16px; }
p { margin: 0; }

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

.sidebar {
  position: sticky; top: 0; height: 100vh;
  display: flex; flex-direction: column;
  background: linear-gradient(180deg, var(--surface) 0%, #0e1118 100%);
  border-right: 1px solid var(--border);
  padding: var(--space-4) var(--space-3);
  z-index: 40;
}
.sidebar__brand {
  display: flex; align-items: center; gap: 10px;
  padding: var(--space-2) var(--space-3) var(--space-4);
}
.sidebar__logo {
  width: 34px; height: 34px; border-radius: 10px; flex: none;
  background: var(--accent-gradient);
  display: grid; place-items: center; color: #fff;
  box-shadow: var(--inner-hl);
}
.sidebar__title { font-weight: 700; font-size: 15px; color: var(--text); }
.sidebar__sub { font-size: 11px; color: var(--text-muted); }
.sidebar__group { margin-top: var(--space-4); }
.sidebar__group-label {
  font-size: 11px; text-transform: uppercase; letter-spacing: 0.08em;
  color: var(--text-muted); padding: 0 var(--space-3) var(--space-2);
}
.nav { display: flex; flex-direction: column; gap: 2px; }
.nav a {
  display: flex; align-items: center; gap: 10px;
  padding: 9px var(--space-3); border-radius: var(--radius-sm);
  color: var(--text-secondary); font-weight: 500; font-size: 13.5px;
  border: 1px solid transparent;
}
.nav a svg { width: 18px; height: 18px; flex: none; opacity: 0.9; }
.nav a:hover { background: var(--surface-raised); color: var(--text); text-decoration: none; }
.nav a.on {
  background: var(--accent-soft); color: #c7c9ff;
  border-color: var(--border-accent);
}
.nav a.on svg { color: #a5a8ff; opacity: 1; }
.sidebar__foot { margin-top: auto; padding-top: var(--space-4); border-top: 1px solid var(--border); }
.sidebar__status { display: flex; align-items: center; gap: 8px; padding: 6px var(--space-3); color: var(--text-secondary); font-size: 12.5px; }

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

.topbar {
  position: sticky; top: 0; z-index: 30;
  height: var(--topbar-h); display: flex; align-items: center; gap: var(--space-3);
  padding: 0 var(--space-5);
  background: rgba(11, 13, 18, 0.82);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border);
}
.topbar__toggle { display: none; }
.breadcrumbs { display: flex; align-items: center; gap: 8px; color: var(--text-muted); font-size: 13px; flex: 1; min-width: 0; }
.breadcrumbs a { color: var(--text-secondary); }
.breadcrumbs .sep { opacity: 0.5; }
.breadcrumbs .current { color: var(--text); font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.topbar__actions { display: flex; align-items: center; gap: var(--space-2); margin-left: auto; }

.search {
  position: relative; display: flex; align-items: center;
}
.search svg { position: absolute; left: 10px; width: 16px; height: 16px; color: var(--text-muted); pointer-events: none; }
.search input { padding-left: 32px; width: 220px; }
.search kbd { position: absolute; right: 8px; }

.page { padding: var(--space-5); max-width: 1280px; width: 100%; margin: 0 auto; }
.page-head { display: flex; align-items: flex-start; gap: var(--space-4); margin-bottom: var(--space-5); }
.page-head__text { flex: 1; min-width: 0; }
.page-head__desc { color: var(--text-secondary); margin-top: 4px; }
.page-head__actions { display: flex; gap: var(--space-2); flex-wrap: wrap; }

.section { margin-top: var(--space-6); }
.section-head { display: flex; align-items: center; gap: var(--space-3); margin-bottom: var(--space-3); }
.section-head h2 { font-size: 17px; }
.section-head__actions { margin-left: auto; display: flex; gap: var(--space-2); }

/* ============================= buttons ============================= */
.btn {
  --btn-bg: var(--surface-raised);
  --btn-bd: var(--border-strong);
  --btn-fg: var(--text);
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 38px; padding: 0 14px;
  background: var(--btn-bg); color: var(--btn-fg);
  border: 1px solid var(--btn-bd); border-radius: var(--radius-sm);
  font-family: inherit; font-size: 13.5px; font-weight: 600; cursor: pointer;
  text-decoration: none; white-space: nowrap;
  transition: background 140ms ease, border-color 140ms ease, transform 140ms ease, opacity 140ms ease;
}
.btn svg { width: 16px; height: 16px; }
.btn:hover { border-color: var(--border-accent); text-decoration: none; }
.btn:active { transform: translateY(1px); }
.btn[disabled], .btn.is-disabled { opacity: 0.5; cursor: not-allowed; transform: none; }

.btn-primary { --btn-bg: var(--accent-gradient); --btn-bd: transparent; --btn-fg: var(--accent-text); box-shadow: var(--inner-hl); }
.btn-primary:hover { filter: brightness(1.08); }
.btn-secondary { --btn-bg: var(--surface-raised); }
.btn-ghost { --btn-bg: transparent; --btn-bd: transparent; --btn-fg: var(--text-secondary); }
.btn-ghost:hover { --btn-bg: var(--surface-raised); --btn-fg: var(--text); border-color: transparent; }
.btn-danger { --btn-bg: var(--danger-soft); --btn-bd: transparent; --btn-fg: #fca5a5; }
.btn-danger:hover { --btn-bg: rgba(248, 113, 113, 0.22); border-color: transparent; }
.btn-sm { min-height: 30px; padding: 0 10px; font-size: 12.5px; border-radius: 8px; }
.btn-sm svg { width: 14px; height: 14px; }
.btn-lg { min-height: 46px; padding: 0 20px; font-size: 15px; border-radius: 10px; }
.btn-icon { padding: 0; width: 38px; min-height: 38px; }
.btn-icon.btn-sm { width: 30px; min-height: 30px; }

.btn.is-loading { color: transparent !important; pointer-events: none; position: relative; }
.btn.is-loading::after {
  content: ""; position: absolute; inset: 0; margin: auto;
  width: 16px; height: 16px; border-radius: 50%;
  border: 2px solid rgba(255, 255, 255, 0.35); border-top-color: #fff;
  animation: spin 0.7s linear infinite;
}

/* ============================= forms ============================= */
.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: var(--space-3); }
.field > label, .label { font-size: 12.5px; font-weight: 600; color: var(--text-secondary); }
.field .hint { font-size: 12px; color: var(--text-muted); }
input, select, textarea {
  font-family: inherit; font-size: 13.5px; color: var(--text);
  background: #0e1118; border: 1px solid var(--border-strong); border-radius: var(--radius-sm);
  padding: 9px 11px; width: 100%; min-height: 38px;
  transition: border-color 140ms ease, box-shadow 140ms ease;
}
input::placeholder, textarea::placeholder { color: var(--text-muted); }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--accent); box-shadow: var(--focus); }
textarea { resize: vertical; min-height: 90px; }
select { cursor: pointer; }
input[type="checkbox"], input[type="radio"] { width: auto; min-height: 0; }

.row { display: flex; gap: var(--space-2); flex-wrap: wrap; align-items: center; }
.row-2 { display: grid; grid-template-columns: 1fr 1fr; gap: var(--space-3); }
.row-form { display: flex; gap: var(--space-2); flex-wrap: wrap; align-items: flex-end; }
.row-form .field { margin-bottom: 0; flex: 1 1 180px; }

/* toggle switch */
.toggle { display: inline-flex; align-items: center; gap: 10px; cursor: pointer; user-select: none; }
.toggle input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.toggle__track {
  width: 40px; height: 22px; border-radius: 999px; background: var(--overlay);
  border: 1px solid var(--border-strong); position: relative; transition: background 140ms ease;
  flex: none;
}
.toggle__track::after {
  content: ""; position: absolute; top: 2px; left: 2px; width: 16px; height: 16px;
  border-radius: 50%; background: var(--text-muted); transition: transform 140ms ease, background 140ms ease;
}
.toggle input:checked + .toggle__track { background: var(--accent-soft); border-color: var(--border-accent); }
.toggle input:checked + .toggle__track::after { transform: translateX(18px); background: var(--accent); }
.toggle input:focus-visible + .toggle__track { box-shadow: var(--focus); }

.check { display: flex; align-items: center; gap: 8px; font-size: 13.5px; }
.check input {
  appearance: none; width: 18px; height: 18px; min-height: 0; border-radius: 5px;
  border: 1px solid var(--border-strong); background: #0e1118; cursor: pointer; position: relative;
}
.check input:checked { background: var(--accent); border-color: var(--accent); }
.check input:checked::after {
  content: ""; position: absolute; left: 5px; top: 2px; width: 5px; height: 9px;
  border: solid #fff; border-width: 0 2px 2px 0; transform: rotate(45deg);
}

/* ============================= cards ============================= */
.card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); box-shadow: var(--shadow-1), var(--inner-hl);
}
.card-pad { padding: var(--space-4); }
.card-head { display: flex; align-items: center; gap: var(--space-3); padding: var(--space-4); border-bottom: 1px solid var(--border); }
.card-head h3 { font-size: 15px; }
.card-body { padding: var(--space-4); }

.metrics { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: var(--space-3); }
.metric { padding: var(--space-4); display: flex; gap: var(--space-3); align-items: flex-start; }
.metric__icon {
  width: 38px; height: 38px; border-radius: 10px; flex: none;
  display: grid; place-items: center; background: var(--accent-soft); color: #a5a8ff;
}
.metric__icon svg { width: 19px; height: 19px; }
.metric__num { font-size: 26px; font-weight: 700; line-height: 1.1; font-variant-numeric: tabular-nums; }
.metric__label { color: var(--text-secondary); font-size: 12.5px; margin-top: 2px; }
.metric__sub { color: var(--text-muted); font-size: 12px; margin-top: 4px; }
.metric--warn .metric__icon { background: var(--warning-soft); color: var(--warning); }
.metric--danger .metric__icon { background: var(--danger-soft); color: var(--danger); }
.metric--success .metric__icon { background: var(--success-soft); color: var(--success); }

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

/* ============================= badges ============================= */
.badge {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 3px 9px; border-radius: 999px; font-size: 12px; font-weight: 600;
  white-space: nowrap; border: 1px solid transparent; line-height: 1.5;
}
.badge .dot { width: 6px; height: 6px; border-radius: 50%; background: currentColor; flex: none; }
.badge-on, .badge-success { background: var(--success-soft); color: var(--success); border-color: rgba(52, 211, 153, 0.25); }
.badge-off { background: var(--overlay); color: var(--text-muted); border-color: var(--border); }
.badge-warn { background: var(--warning-soft); color: var(--warning); border-color: rgba(251, 191, 36, 0.25); }
.badge-error { background: var(--danger-soft); color: var(--danger); border-color: rgba(248, 113, 113, 0.25); }
.badge-info { background: var(--info-soft); color: var(--info); border-color: rgba(96, 165, 250, 0.25); }
.badge-accent { background: var(--accent-soft); color: #a5a8ff; border-color: var(--border-accent); }
.badge[role="button"] { cursor: pointer; }
.badge[role="button"]:hover { filter: brightness(1.15); }

.method { font-family: var(--mono); font-size: 11.5px; font-weight: 700; letter-spacing: 0.03em; padding: 3px 8px; border-radius: 6px; }
.method-get { background: rgba(52, 211, 153, 0.14); color: #6ee7b7; }
.method-post { background: rgba(96, 165, 250, 0.16); color: #93c5fd; }
.method-patch { background: rgba(251, 191, 36, 0.16); color: #fcd34d; }
.method-put { background: rgba(251, 146, 60, 0.16); color: #fdba74; }
.method-delete { background: rgba(248, 113, 113, 0.16); color: #fca5a5; }

/* ============================= tables ============================= */
.table-wrap { overflow-x: auto; border-radius: var(--radius); border: 1px solid var(--border); background: var(--surface); }
.table { width: 100%; border-collapse: collapse; }
.table th, .table td { text-align: left; padding: 11px 14px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.table th {
  position: sticky; top: 0; z-index: 2; background: var(--surface-raised);
  font-size: 11.5px; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.05em; font-weight: 600;
}
.table tbody tr { transition: background 120ms ease; }
.table tbody tr:hover { background: var(--surface-raised); }
.table tr:last-child td { border-bottom: none; }
.table td.actions { text-align: right; white-space: nowrap; }
.table .muted, .muted { color: var(--text-secondary); }
.small { font-size: 12px; }
.tiny { font-size: 11px; }
.nowrap { white-space: nowrap; }

/* ============================= progress ============================= */
.progress { height: 6px; border-radius: 999px; background: var(--overlay); overflow: hidden; min-width: 60px; }
.progress__bar { height: 100%; border-radius: 999px; background: var(--accent-gradient); transition: width 200ms ease; }
.progress--warn .progress__bar { background: linear-gradient(135deg, #fbbf24, #f59e0b); }
.progress--danger .progress__bar { background: linear-gradient(135deg, #f87171, #ef4444); }
.progress--success .progress__bar { background: linear-gradient(135deg, #34d399, #10b981); }
.progress-row { display: flex; align-items: center; gap: 8px; }
.progress-row .progress { flex: 1; }

/* ============================= tabs ============================= */
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--border); margin-bottom: var(--space-4); overflow-x: auto; }
.tabs button, .tabs a {
  appearance: none; background: none; border: none; border-bottom: 2px solid transparent;
  color: var(--text-secondary); font: inherit; font-weight: 600; font-size: 13.5px;
  padding: 10px 14px; cursor: pointer; white-space: nowrap; margin-bottom: -1px;
}
.tabs button:hover, .tabs a:hover { color: var(--text); text-decoration: none; }
.tabs button.on, .tabs a.on { color: var(--text); border-bottom-color: var(--accent); }
.tab-panel { display: none; }
.tab-panel.on { display: block; animation: fade 160ms ease; }

/* ============================= modal ============================= */
.modal-backdrop {
  position: fixed; inset: 0; z-index: 100; display: none;
  background: rgba(4, 6, 10, 0.66); backdrop-filter: blur(2px);
  align-items: center; justify-content: center; padding: var(--space-4);
  overflow-y: auto;
}
.modal-backdrop.on { display: flex; animation: fade 140ms ease; }
.modal {
  width: 100%; max-width: 480px; background: var(--surface-raised);
  border: 1px solid var(--border-strong); border-radius: var(--radius-lg);
  box-shadow: var(--shadow-2); animation: pop 160ms ease;
  max-height: calc(100vh - 2 * var(--space-4));
  max-height: calc(100dvh - 2 * var(--space-4));
  overflow-y: auto; overscroll-behavior: contain;
}
.modal__head { padding: var(--space-4) var(--space-5); border-bottom: 1px solid var(--border); display: flex; align-items: center; gap: var(--space-3); }
.modal__head h3 { font-size: 16px; }
.modal__body { padding: var(--space-5); color: var(--text-secondary); }
.modal__body strong { color: var(--text); }
.modal__foot { padding: var(--space-4) var(--space-5); border-top: 1px solid var(--border); display: flex; gap: var(--space-2); justify-content: flex-end; }

/* ============================= toast ============================= */
.toasts { position: fixed; right: var(--space-5); bottom: var(--space-5); z-index: 200; display: flex; flex-direction: column; gap: var(--space-2); max-width: min(380px, calc(100vw - 32px)); }
.toast {
  display: flex; align-items: flex-start; gap: 10px;
  background: var(--surface-raised); border: 1px solid var(--border-strong);
  border-left: 3px solid var(--accent);
  border-radius: var(--radius-sm); padding: 11px 13px; box-shadow: var(--shadow-2);
  animation: slidein 180ms ease; color: var(--text); font-size: 13.5px;
}
.toast svg { width: 18px; height: 18px; flex: none; margin-top: 1px; }
.toast--success { border-left-color: var(--success); }
.toast--success svg { color: var(--success); }
.toast--error { border-left-color: var(--danger); }
.toast--error svg { color: var(--danger); }
.toast--info { border-left-color: var(--info); }
.toast--info svg { color: var(--info); }
.toast--warn { border-left-color: var(--warning); }
.toast--warn svg { color: var(--warning); }
.toast.out { animation: fadeout 160ms ease forwards; }

/* ============================= misc ============================= */
.steps { list-style: none; padding: 0; margin: 8px 0 0; display: flex; flex-direction: column; gap: 10px; }
.steps li { display: flex; gap: 10px; align-items: flex-start; color: var(--text-secondary); font-size: 13.5px; }
.steps__n { width: 22px; height: 22px; border-radius: 50%; background: var(--accent-soft); color: #a5a8ff; display: grid; place-items: center; font-size: 12px; font-weight: 700; flex: none; }

.qr-area { display: inline-flex; align-items: center; justify-content: center; background: #fff; border-radius: var(--radius); padding: 12px; min-width: 234px; min-height: 234px; }
.qr-area img { display: block; border-radius: 6px; max-width: 100%; height: auto; }

.maskable.is-masked { color: transparent; text-shadow: 0 0 8px rgba(231, 234, 240, 0.85); user-select: none; }

.menu { position: relative; display: inline-block; }
.menu__list { background: var(--surface-raised); border: 1px solid var(--border-strong); border-radius: 10px; padding: 4px; min-width: 210px; box-shadow: var(--shadow-2); }
.menu__list[hidden] { display: none; }
.menu__list a, .menu__list button { display: flex; gap: 8px; align-items: center; width: 100%; padding: 8px 10px; border-radius: 7px; color: var(--text); font-size: 13px; background: none; border: none; text-align: left; cursor: pointer; font-family: inherit; }
.menu__list a:hover, .menu__list button:hover { background: var(--overlay); text-decoration: none; }
.menu__list svg { width: 15px; height: 15px; color: var(--text-muted); flex: none; }
.menu__list .danger { color: #fca5a5; }
.menu__list .danger svg { color: #fca5a5; }
.menu__list .danger:hover { background: var(--danger-soft); }
.menu__sep { height: 1px; background: var(--border); margin: 4px 6px; }
.menu-portal { position: fixed; z-index: 300; }
.menu-portal .menu__list { animation: pop 120ms ease; }
.menu-scrim { position: fixed; inset: 0; z-index: 290; background: transparent; }
.menu-portal.is-sheet { left: 0; right: 0; bottom: 0; }
.menu-portal.is-sheet .menu__list { min-width: 0; width: 100%; border-radius: 16px 16px 0 0; padding: 10px; }
.menu-portal.is-sheet .menu__list a, .menu-portal.is-sheet .menu__list button { padding: 13px 12px; font-size: 14.5px; }

/* ============================= secret value ============================= */
.secret { display: flex; align-items: center; gap: var(--space-2); min-width: 0; max-width: 100%; }
.secret__value { flex: 1 1 auto; min-width: 0; font-family: var(--mono); font-size: 12.5px; background: #0e1118; border: 1px solid var(--border-strong); border-radius: 8px; padding: 8px 11px; color: var(--text-secondary); }
.secret__value.is-one-line { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.secret__value.is-wrap { white-space: normal; overflow-wrap: anywhere; }
.secret__actions { display: flex; gap: 6px; flex: none; }

/* ============================= command palette ============================= */
.palette-backdrop { position: fixed; inset: 0; z-index: 250; display: none; background: rgba(4, 6, 10, 0.62); backdrop-filter: blur(2px); align-items: flex-start; justify-content: center; padding: 10vh var(--space-4) var(--space-4); }
.palette-backdrop.on { display: flex; animation: fade 120ms ease; }
.palette { width: 100%; max-width: 640px; background: var(--surface-raised); border: 1px solid var(--border-strong); border-radius: 14px; box-shadow: var(--shadow-2); overflow: hidden; animation: pop 140ms ease; }
.palette__input { width: 100%; border: 0; border-bottom: 1px solid var(--border); background: transparent; color: var(--text); font-family: inherit; font-size: 15px; padding: 16px 18px; outline: none; }
.palette__list { max-height: min(52vh, 420px); overflow-y: auto; padding: 6px; }
.palette__group { font-size: 11px; text-transform: uppercase; letter-spacing: 0.07em; color: var(--text-muted); padding: 10px 12px 4px; }
.palette__item { display: flex; align-items: center; gap: 10px; width: 100%; padding: 9px 12px; border-radius: 9px; color: var(--text); background: none; border: 0; text-align: left; cursor: pointer; font-family: inherit; font-size: 13.5px; }
.palette__item svg { width: 16px; height: 16px; color: var(--text-muted); flex: none; }
.palette__item .sub { color: var(--text-muted); font-size: 12px; margin-left: auto; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 48%; }
.palette__item.on { background: var(--accent-soft); }
.palette__item mark { background: transparent; color: #c7c9ff; font-weight: 600; }
.palette__empty { padding: 22px; text-align: center; color: var(--text-muted); font-size: 13px; }
.palette__foot { display: flex; gap: 16px; padding: 8px 14px; border-top: 1px solid var(--border); color: var(--text-muted); font-size: 11.5px; }


.code-inline, code {
  background: var(--overlay); border: 1px solid var(--border);
  padding: 1px 6px; border-radius: 6px; font-size: 12.5px;
}
.copybox {
  display: flex; align-items: center; gap: var(--space-2);
  background: #0e1118; border: 1px solid var(--border-strong); border-radius: var(--radius-sm);
  padding: 4px 4px 4px 12px;
}
.copybox code { background: none; border: none; padding: 0; flex: 1; min-width: 0; overflow-x: auto; white-space: nowrap; font-size: 13px; }
.copybox--wrap code { white-space: normal; word-break: break-all; }

.alert { display: flex; gap: 10px; padding: 12px 14px; border-radius: var(--radius-sm); font-size: 13.5px; border: 1px solid transparent; }
.alert svg { width: 18px; height: 18px; flex: none; margin-top: 1px; }
.alert--danger { background: var(--danger-soft); color: #fca5a5; border-color: rgba(248, 113, 113, 0.3); }
.alert--warning { background: var(--warning-soft); color: #fcd34d; border-color: rgba(251, 191, 36, 0.3); }
.alert--info { background: var(--info-soft); color: #93c5fd; border-color: rgba(96, 165, 250, 0.3); }
.alert--success { background: var(--success-soft); color: #6ee7b7; border-color: rgba(52, 211, 153, 0.3); }
.alert strong { color: inherit; }

.empty { text-align: center; padding: var(--space-6) var(--space-4); color: var(--text-secondary); }
.empty svg { width: 42px; height: 42px; color: var(--text-muted); margin-bottom: var(--space-3); }
.empty h3 { margin-bottom: 6px; color: var(--text); }
.empty p { color: var(--text-muted); margin-bottom: var(--space-4); }

.skeleton { background: linear-gradient(90deg, var(--overlay) 25%, var(--surface-raised) 37%, var(--overlay) 63%); background-size: 400% 100%; animation: shimmer 1.4s ease infinite; border-radius: 6px; min-height: 14px; }
.skeleton + .skeleton { margin-top: 8px; }

.spinner { width: 28px; height: 28px; border-radius: 50%; border: 3px solid var(--border-strong); border-top-color: var(--accent); animation: spin 0.7s linear infinite; margin: var(--space-5) auto; }

.tooltip { position: relative; }
.tooltip::after {
  content: attr(data-tip); position: absolute; bottom: calc(100% + 6px); left: 50%; transform: translateX(-50%);
  background: var(--overlay); color: var(--text); border: 1px solid var(--border-strong);
  padding: 5px 9px; border-radius: 6px; font-size: 12px; white-space: nowrap;
  opacity: 0; pointer-events: none; transition: opacity 120ms ease; z-index: 50;
}
.tooltip:hover::after { opacity: 1; }

.kbd, kbd {
  font-family: var(--mono); font-size: 10.5px; padding: 1px 5px; border-radius: 5px;
  background: var(--overlay); border: 1px solid var(--border-strong); color: var(--text-muted);
}

.divider { height: 1px; background: var(--border); margin: var(--space-4) 0; }
.spread { display: flex; align-items: center; justify-content: space-between; gap: var(--space-3); }
.spread > * { min-width: 0; }
.break { overflow-wrap: anywhere; word-break: break-word; }
.stack { display: flex; flex-direction: column; gap: var(--space-3); }
.hstack { display: flex; align-items: center; gap: var(--space-2); flex-wrap: wrap; }
.grow { flex: 1; min-width: 0; }
.text-secondary { color: var(--text-secondary); }
.text-muted { color: var(--text-muted); }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.time-expired { color: var(--danger); }
.time-soon { color: var(--warning); }
.time-ok { color: var(--text-secondary); }

.health { display: inline-flex; align-items: center; gap: 6px; font-size: 12.5px; font-weight: 600; }
.health .dot { width: 8px; height: 8px; border-radius: 50%; flex: none; }
.health--ok { color: var(--success); }
.health--ok .dot { background: var(--success); box-shadow: 0 0 0 3px var(--success-soft); }
.health--warn { color: var(--warning); }
.health--warn .dot { background: var(--warning); box-shadow: 0 0 0 3px var(--warning-soft); }
.health--error { color: var(--danger); }
.health--error .dot { background: var(--danger); box-shadow: 0 0 0 3px var(--danger-soft); }
.health--disabled { color: var(--text-muted); }
.health--disabled .dot { background: var(--text-muted); }

.danger-zone { border: 1px solid rgba(248, 113, 113, 0.35); border-radius: var(--radius); background: linear-gradient(180deg, rgba(248, 113, 113, 0.06), transparent); }
.danger-zone .card-head { border-bottom-color: rgba(248, 113, 113, 0.2); }
.danger-zone h3 { color: #fca5a5; }

.warn-box { border: 1px solid rgba(251, 191, 36, 0.35); background: var(--warning-soft); border-radius: var(--radius); padding: var(--space-4); }

/* ============================= auth ============================= */
.auth-body { display: flex; align-items: center; justify-content: center; min-height: 100vh; padding: var(--space-4); }
.auth-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); padding: var(--space-6); width: 100%; max-width: 380px; box-shadow: var(--shadow-2); }
.auth-logo { display: flex; align-items: center; gap: 12px; margin-bottom: var(--space-5); }
.auth-logo .sidebar__logo { width: 42px; height: 42px; }
.auth-card h1 { font-size: 20px; }
.auth-card .sub { color: var(--text-muted); font-size: 13px; margin-top: 2px; }

/* ============================= error pages ============================= */
.error-page { min-height: 100vh; display: grid; place-items: center; padding: var(--space-5); }
.error-card { text-align: center; max-width: 460px; }
.error-code { font-family: var(--mono); font-size: 64px; font-weight: 700; background: var(--accent-gradient); -webkit-background-clip: text; background-clip: text; color: transparent; line-height: 1; }

/* ============================= docs / api reference ============================= */
.docs { display: grid; grid-template-columns: 280px 1fr; gap: var(--space-5); align-items: start; }
.docs-toc { position: sticky; top: calc(var(--topbar-h) + var(--space-5)); max-height: calc(100vh - var(--topbar-h) - 48px); overflow-y: auto; }
.docs-toc a { display: block; padding: 5px 10px; border-radius: 7px; color: var(--text-secondary); font-size: 13px; border-left: 2px solid transparent; }
.docs-toc a:hover { background: var(--surface-raised); text-decoration: none; color: var(--text); }
.docs-toc a.on { color: #c7c9ff; border-left-color: var(--accent); background: var(--accent-soft); }
.docs-toc .group-label { font-size: 11px; text-transform: uppercase; letter-spacing: 0.07em; color: var(--text-muted); padding: var(--space-3) 10px 4px; }
.docs-body { min-width: 0; }
.doc-section { margin-bottom: var(--space-6); }
.doc-section:last-child { margin-bottom: 0; }
.doc-anchor { scroll-margin-top: calc(var(--topbar-h) + 16px); }
.api-card { scroll-margin-top: calc(var(--topbar-h) + 16px); }
[id^="settings-"] { scroll-margin-top: calc(var(--topbar-h) + 16px); }
.docs-body h2 { scroll-margin-top: calc(var(--topbar-h) + 16px); margin-bottom: var(--space-3); }
.docs-body h3 { scroll-margin-top: calc(var(--topbar-h) + 16px); }

.api-card { margin-bottom: var(--space-3); overflow: hidden; }
.api-card__summary { display: flex; align-items: center; gap: var(--space-3); padding: var(--space-3) var(--space-4); cursor: pointer; }
.api-card__summary:hover { background: var(--surface-raised); }
.api-card__path { font-family: var(--mono); font-size: 13px; color: var(--text); }
.api-card__path .param { color: #c4b5fd; }
.api-card__title { color: var(--text-secondary); font-size: 13px; }
.api-card__chevron { width: 18px; height: 18px; color: var(--text-muted); transition: transform 160ms ease; margin-left: auto; }
.api-card.open .api-card__chevron { transform: rotate(180deg); }
.api-card__body { display: none; padding: var(--space-4); border-top: 1px solid var(--border); }
.api-card.open .api-card__body { display: block; animation: fade 160ms ease; }

pre.code {
  background: #0a0c11; border: 1px solid var(--border); border-radius: var(--radius-sm);
  padding: 14px 16px; overflow-x: auto; font-family: var(--mono); font-size: 12.5px;
  line-height: 1.6; color: #d7dce8; margin: 0; position: relative;
}
.code-block { position: relative; margin-bottom: var(--space-3); }
.code-block .copy-code { position: absolute; top: 8px; right: 8px; z-index: 3; }
.tok-key { color: #c4b5fd; }
.tok-str { color: #86efac; }
.tok-num { color: #fcd34d; }
.tok-bool { color: #fca5a5; }
.tok-comment { color: #6c7488; font-style: italic; }
.tok-heading { color: #93c5fd; font-weight: 600; }
.tok-prompt { color: var(--text-muted); user-select: none; }
.tok-flag { color: #fcd34d; }

.try-tabs { display: flex; gap: 4px; margin-bottom: var(--space-2); }
.try-tabs button {
  appearance: none; border: 1px solid var(--border); background: var(--surface-raised);
  color: var(--text-secondary); font: inherit; font-size: 12px; font-weight: 600;
  padding: 4px 10px; border-radius: 6px; cursor: pointer;
}
.try-tabs button.on { background: var(--accent-soft); border-color: var(--border-accent); color: #c7c9ff; }

.param-table td, .param-table th { font-size: 12.5px; }

.anchors { display: flex; flex-wrap: wrap; gap: 6px; }
.anchors a { font-family: var(--mono); font-size: 12px; padding: 2px 8px; border: 1px solid var(--border); border-radius: 6px; color: var(--text-secondary); }
.anchors a:hover { border-color: var(--border-accent); text-decoration: none; }

/* ============================= drawer (mobile) ============================= */
.drawer-toggle { display: none; }
.scrim { display: none; }

/* ============================= animations ============================= */
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes shimmer { 0% { background-position: 100% 0; } 100% { background-position: -100% 0; } }
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }
@keyframes pop { from { opacity: 0; transform: translateY(8px) scale(0.98); } to { opacity: 1; transform: none; } }
@keyframes slidein { from { opacity: 0; transform: translateX(20px); } to { opacity: 1; transform: none; } }
@keyframes fadeout { to { opacity: 0; transform: translateX(20px); } }

@media (prefers-reduced-motion: reduce) {
  * { animation-duration: 0.001ms !important; animation-iteration-count: 1 !important; transition-duration: 0.001ms !important; }
}

/* ============================= responsive ============================= */
@media (max-width: 1024px) {
  .layout { grid-template-columns: 1fr; }
  .sidebar {
    position: fixed; top: 0; left: 0; height: 100vh; width: min(300px, 86vw);
    transform: translateX(-102%); transition: transform 200ms ease; z-index: 120;
    box-shadow: var(--shadow-2);
  }
  body.drawer-open .sidebar { transform: none; }
  body.drawer-open .scrim { display: block; position: fixed; inset: 0; z-index: 110; background: rgba(4, 6, 10, 0.6); animation: fade 160ms ease; }
  .drawer-toggle { display: inline-flex; }
  .topbar { padding: 0 var(--space-4); }
  .page { padding: var(--space-4); }
  .search input { width: 150px; }
  .docs { grid-template-columns: 1fr; }
  .docs-toc { position: static; max-height: none; display: flex; flex-wrap: wrap; gap: 4px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: var(--space-3); }
  .docs-toc .group-label { width: 100%; }
  .docs-toc a { border-left: none; border: 1px solid var(--border); }
}

@media (max-width: 640px) {
  h1 { font-size: 20px; }
  .row-2 { grid-template-columns: 1fr; }
  .page-head { flex-direction: column; }
  .page-head__actions { width: 100%; }
  .topbar { height: auto; min-height: var(--topbar-h); flex-wrap: wrap; padding: 8px var(--space-3); gap: 8px; }
  .search { order: 3; width: 100%; }
  .search input { width: 100%; }
  .table th, .table td { padding: 9px 10px; }
  .toasts { left: var(--space-3); right: var(--space-3); bottom: var(--space-3); max-width: none; }
  .btn { min-height: 44px; }
  .btn-sm { min-height: 34px; }
}

/* ========================= branding (оформление ключа) ========================= */
.brand-msg {
  border: 1px solid var(--border); border-radius: var(--radius);
  background: var(--surface); padding: 10px 12px; margin-bottom: 10px;
}
.brand-msg + .brand-msg { margin-top: 0; }
.brand-msg .check { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; font-weight: 600; }
.brand-msg__title { margin-bottom: 6px; }
.brand-msg textarea { margin-top: 0; }
.brand-msg input:disabled, .brand-msg textarea:disabled { opacity: 0.55; }

.brand-hdr {
  border: 1px solid var(--border); border-radius: var(--radius);
  background: var(--surface); padding: 10px 12px; margin-bottom: 10px;
}
.brand-hdr__name { font-family: var(--mono); font-size: 12px; color: var(--accent); margin-bottom: 4px; letter-spacing: 0.2px; }
.brand-hdr__http { word-break: break-all; font-size: 12px; color: var(--text); }
.brand-hdr__raw { word-break: break-all; font-size: 12px; color: var(--text-secondary); margin-top: 2px; }
.brand-hdr .hint { margin-top: 6px; }
[data-brand-result] .empty { padding: 0; }
[data-brand-result] .spread { padding-bottom: 4px; }

.brand-preview { position: sticky; top: calc(var(--topbar-h) + var(--space-5)); }
@media (max-width: 1024px) {
  .brand-preview { position: static; }
}
