/* ============================================================
   WINGS TTS Gateway — Admin layout (Jinja2 base.html consumer)
   ============================================================
   Палитра привязана к фирменному стилю WINGS (см. lk-ui).
   Шрифт Inter (Google Fonts) с фоллбэком на system-ui для air-gap.
   Без внешних UI-фреймворков — свой CSS на ~500 строк.
*/

:root {
  --brand: #339999;
  --brand-dark: #005e68;
  --brand-darker: #003a42;
  --accent: #f97316;             /* оранжевый из лого, для CTA */
  --accent-hover: #ea580c;
  --bg: #f1f5f9;
  --surface: #ffffff;
  --text: #0f172a;
  --text-muted: #64748b;
  --border: #e2e8f0;
  --success: #10b981;
  --warning: #f59e0b;
  --error: #ef4444;
  --shadow-sm: 0 1px 2px rgba(15,23,42,0.04), 0 1px 1px rgba(15,23,42,0.06);
  --shadow: 0 4px 6px -1px rgba(15,23,42,0.07), 0 2px 4px -2px rgba(15,23,42,0.05);
  --shadow-lg: 0 10px 25px -5px rgba(15,23,42,0.10), 0 8px 10px -6px rgba(15,23,42,0.05);
  --radius: 10px;
  --radius-sm: 6px;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; height: 100%; }
body {
  font-family: 'Inter', -apple-system, system-ui, "Segoe UI", sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}
code, pre, .mono { font-family: 'JetBrains Mono', ui-monospace, monospace; }
a { color: var(--brand); text-decoration: none; }
a:hover { text-decoration: underline; }

/* === APP GRID === */
.app {
  display: grid;
  grid-template-columns: 248px 1fr;
  grid-template-rows: 60px 1fr;
  grid-template-areas: "sidebar topbar" "sidebar content";
  height: 100vh;
}

/* === TOPBAR === */
.topbar {
  grid-area: topbar;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  padding: 0 24px;
  gap: 16px;
}
.topbar h1 {
  font-size: 15px;
  font-weight: 600;
  margin: 0;
  color: var(--text);
}
.topbar h1 .v {
  font-weight: 400;
  color: var(--text-muted);
  margin-left: 8px;
  font-size: 13px;
}
.topbar .status {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  background: rgba(16,185,129,0.10);
  color: var(--success);
  border-radius: 999px;
  font-size: 12px;
  font-weight: 500;
}
.topbar .status::before {
  content: "";
  width: 6px; height: 6px;
  background: var(--success);
  border-radius: 50%;
  box-shadow: 0 0 0 3px rgba(16,185,129,0.20);
}
.topbar .status.warn { background: rgba(245,158,11,0.10); color: var(--warning); }
.topbar .status.warn::before { background: var(--warning); box-shadow: 0 0 0 3px rgba(245,158,11,0.20); }
.topbar .status.error { background: rgba(239,68,68,0.10); color: var(--error); }
.topbar .status.error::before { background: var(--error); box-shadow: 0 0 0 3px rgba(239,68,68,0.20); }
.topbar .spacer { flex: 1; }
.topbar .user {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px 12px;
  color: var(--text-muted);
  font-size: 13px;
  cursor: pointer;
  border-radius: var(--radius-sm);
}
.topbar .user:hover { background: var(--bg); }
.topbar .user .avatar {
  width: 28px; height: 28px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--brand) 0%, var(--brand-dark) 100%);
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
  font-size: 12px;
}

/* === SIDEBAR === */
.sidebar {
  grid-area: sidebar;
  background: linear-gradient(180deg, var(--brand-dark) 0%, var(--brand-darker) 100%);
  color: rgba(255,255,255,0.85);
  display: flex;
  flex-direction: column;
  overflow-y: auto;
}
.sidebar .brand {
  padding: 16px 20px 14px;
  display: flex;
  align-items: center;
  gap: 10px;
  border-bottom: 1px solid rgba(255,255,255,0.08);
  text-decoration: none;
}
.sidebar .brand:hover { text-decoration: none; }
.sidebar .brand img {
  width: 36px; height: 36px;
  object-fit: contain;
}
.sidebar .brand .name {
  color: white;
  font-weight: 700;
  font-size: 16px;
  letter-spacing: 0.3px;
}
.sidebar .brand .sub {
  color: rgba(255,255,255,0.6);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 1px;
}
.sidebar nav { padding: 12px 8px; flex: 1; }
.sidebar .nav-group-label {
  padding: 12px 14px 6px;
  color: rgba(255,255,255,0.45);
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.8px;
}
.sidebar a.nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 9px 14px;
  margin: 1px 0;
  color: rgba(255,255,255,0.78);
  text-decoration: none;
  font-size: 13.5px;
  font-weight: 500;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: background 0.12s, color 0.12s;
}
.sidebar a.nav-item:hover {
  background: rgba(255,255,255,0.06);
  color: white;
  text-decoration: none;
}
.sidebar a.nav-item.active {
  background: var(--brand);
  color: white;
  box-shadow: 0 4px 12px -2px rgba(51,153,153,0.50);
}
.sidebar a.nav-item .icon {
  width: 18px; height: 18px;
  flex-shrink: 0;
}
.sidebar a.nav-item .ext {
  margin-left: auto;
  width: 12px; height: 12px;
  opacity: 0.5;
}
.sidebar .footer {
  padding: 14px 18px;
  border-top: 1px solid rgba(255,255,255,0.08);
  color: rgba(255,255,255,0.55);
  font-size: 11px;
}
.sidebar .footer a {
  color: rgba(255,255,255,0.75);
  text-decoration: none;
}
.sidebar .footer a:hover { color: white; }

/* === CONTENT WRAPPER === */
.content {
  grid-area: content;
  overflow-y: auto;
  padding: 24px 32px 40px;
}

/* === COMMON COMPONENTS === */
.page-header {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  margin-bottom: 24px;
  gap: 24px;
  flex-wrap: wrap;
}
.page-header h2 {
  font-size: 22px;
  font-weight: 700;
  margin: 0 0 4px;
  color: var(--text);
  letter-spacing: -0.3px;
}
.page-header .subtitle {
  color: var(--text-muted);
  font-size: 14px;
  margin: 0;
  max-width: 720px;
}
.page-header .actions { display: flex; gap: 10px; flex-wrap: wrap; }

.card {
  background: var(--surface);
  border-radius: var(--radius);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
}
.card-pad { padding: 20px 22px; }
.card h3 {
  margin: 0 0 16px;
  font-size: 15px;
  font-weight: 600;
}

button.btn, .btn {
  font-family: inherit;
  font-size: 14px;
  font-weight: 600;
  padding: 10px 18px;
  border-radius: var(--radius-sm);
  border: none;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  transition: background 0.12s, transform 0.06s, box-shadow 0.12s;
  text-decoration: none;
}
button.btn:active, .btn:active { transform: translateY(1px); }
button.btn:disabled, .btn:disabled { cursor: not-allowed; opacity: 0.55; }
button.btn:hover:not(:disabled), .btn:hover:not(:disabled) { text-decoration: none; }
.btn.primary { background: var(--brand); color: white; box-shadow: 0 1px 2px rgba(0,0,0,0.08); }
.btn.primary:hover:not(:disabled) { background: #2c8585; }
.btn.accent { background: var(--accent); color: white; box-shadow: 0 1px 2px rgba(0,0,0,0.08); }
.btn.accent:hover:not(:disabled) { background: var(--accent-hover); }
.btn.ghost { background: transparent; color: var(--text); border: 1px solid var(--border); }
.btn.ghost:hover:not(:disabled) { background: var(--bg); }
.btn.danger { background: var(--error); color: white; }
.btn.danger:hover:not(:disabled) { background: #dc2626; }
.btn.sm { padding: 6px 12px; font-size: 12.5px; }
.btn.xs { padding: 4px 10px; font-size: 12px; }

.badge {
  display: inline-block;
  padding: 2px 8px;
  background: rgba(245,158,11,0.15);
  color: #b45309;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 600;
  margin-left: 8px;
}
.badge.brand { background: rgba(51,153,153,0.15); color: var(--brand-dark); }
.badge.success { background: rgba(16,185,129,0.15); color: #047857; }
.badge.muted { background: var(--bg); color: var(--text-muted); }

/* === HERO (sub for dashboard) === */
.hero {
  background: linear-gradient(135deg, var(--brand-dark) 0%, var(--brand) 100%);
  color: white;
  border-radius: var(--radius);
  padding: 28px 32px;
  margin-bottom: 24px;
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: start;
  gap: 32px;
  position: relative;
  overflow: hidden;
}
.hero > .hero-text { max-width: 640px; }
.hero::after {
  content: "";
  position: absolute;
  right: -100px; top: -100px;
  width: 360px; height: 360px;
  background: radial-gradient(circle, rgba(255,255,255,0.08) 0%, transparent 70%);
  pointer-events: none;
}
.hero h1 {
  margin: 0 0 8px;
  font-size: 26px;
  font-weight: 700;
  letter-spacing: -0.5px;
}
.hero p {
  margin: 0 0 18px;
  font-size: 15px;
  color: rgba(255,255,255,0.85);
  max-width: 540px;
}
.hero .actions { display: flex; gap: 10px; flex-wrap: wrap; }
.hero .btn.primary {
  background: white;
  color: var(--brand-dark);
}
.hero .btn.primary:hover:not(:disabled) { background: rgba(255,255,255,0.92); }
.hero .btn.ghost {
  background: transparent;
  border: 1px solid rgba(255,255,255,0.4);
  color: white;
}
.hero .btn.ghost:hover:not(:disabled) { background: rgba(255,255,255,0.08); }

/* === DASHBOARD SECTIONS === */
.section-label {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  color: var(--text-muted);
  margin: 0 0 10px;
}
.overview-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}
@media (max-width: 900px) { .overview-grid { grid-template-columns: 1fr; } }

.kv {
  margin: 0;
  display: grid;
  grid-template-columns: max-content 1fr;
  gap: 6px 16px;
  font-size: 13px;
}
.kv dt { color: var(--text-muted); }
.kv dd { margin: 0; text-align: right; }
.kv dd.mono { font-family: 'JetBrains Mono', ui-monospace, monospace; font-size: 12.5px; }

/* === KPI CARDS === */
.kpis {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 14px;
  margin-bottom: 0;
}
.kpis + .kpis { margin-top: 14px; }
.kpi {
  background: var(--surface);
  border-radius: var(--radius);
  border: 1px solid var(--border);
  padding: 18px 20px;
  box-shadow: var(--shadow-sm);
  position: relative;
  overflow: hidden;
}
.kpi::before {
  content: "";
  position: absolute; left: 0; top: 0; bottom: 0; width: 3px;
  background: var(--brand); opacity: 0.85;
}
.kpi.muted::before { background: var(--text-muted); opacity: 0.30; }
.kpi.accent::before { background: var(--accent); }
.kpi .sub {
  margin-top: 6px;
  font-size: 12.5px;
  color: var(--text-muted);
}
.kpi .sub b { color: var(--text); font-weight: 600; }
.kpi .sub .ok { color: #15803d; font-weight: 600; }
.kpi .sub .ok::before { content: "● "; }
.kpi .unit {
  font-size: 16px;
  color: var(--text-muted);
  font-weight: 600;
  margin-left: 2px;
}
.kpi .label {
  color: var(--text-muted);
  font-size: 12px;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  margin-bottom: 6px;
}
.kpi .value {
  font-size: 28px;
  font-weight: 700;
  color: var(--text);
  letter-spacing: -0.5px;
  line-height: 1.2;
}
.kpi .delta {
  margin-top: 4px;
  font-size: 12px;
  color: var(--success);
  font-weight: 500;
}
.kpi .delta.muted { color: var(--text-muted); }

/* === QUICK ACTIONS GRID === */
.quick-actions-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 14px;
}
.quick-action {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px;
  cursor: pointer;
  transition: all 0.12s;
  text-decoration: none;
  color: inherit;
  display: block;
}
.quick-action:hover {
  border-color: var(--brand);
  box-shadow: var(--shadow);
  transform: translateY(-2px);
  text-decoration: none;
}
.quick-action .qa-icon {
  width: 38px; height: 38px;
  border-radius: 8px;
  background: rgba(51,153,153,0.10);
  color: var(--brand);
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 10px;
}
.quick-action .qa-icon.orange { background: rgba(249,115,22,0.10); color: var(--accent); }
.quick-action h4 {
  margin: 0 0 4px;
  font-size: 14px;
  font-weight: 600;
}
.quick-action p {
  margin: 0;
  font-size: 12.5px;
  color: var(--text-muted);
  line-height: 1.4;
}

/* === DASHBOARD ROW === */
.dashboard-row {
  display: grid;
  grid-template-columns: 1.4fr 1fr;
  gap: 18px;
  margin-top: 24px;
}
.code-block {
  background: #0f172a;
  color: #e2e8f0;
  padding: 16px 18px;
  border-radius: var(--radius-sm);
  font-family: 'JetBrains Mono', ui-monospace, monospace;
  font-size: 12.5px;
  line-height: 1.6;
  overflow-x: auto;
  white-space: pre-wrap;
}
.code-block .c-com { color: #64748b; }
.code-block .c-kw { color: #67e8f9; }
.code-block .c-str { color: #fde68a; }

.recent { list-style: none; padding: 0; margin: 0; }
.recent li {
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 13px;
}
.recent li:last-child { border-bottom: none; }
.recent .dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  background: var(--success);
  flex-shrink: 0;
}
.recent .dot.warn { background: var(--warning); }
.recent .dot.error { background: var(--error); }
.recent .time { margin-left: auto; color: var(--text-muted); font-size: 12px; }

/* === FORM FIELDS (common) === */
.field { margin-bottom: 16px; }
.field label {
  display: block;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 6px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}
.field input[type="text"],
.field input[type="number"],
.field input[type="search"],
.field select,
.field textarea {
  width: 100%;
  padding: 9px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-family: inherit;
  font-size: 13px;
  background: white;
}
.field textarea {
  min-height: 140px;
  resize: vertical;
  line-height: 1.5;
}
.field input:focus,
.field select:focus,
.field textarea:focus {
  outline: 2px solid rgba(51,153,153,0.25);
  border-color: var(--brand);
}
.toggle-row { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
.toggle {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  background: var(--bg);
  border-radius: 999px;
  font-size: 12px;
  cursor: pointer;
  user-select: none;
}
.toggle input { margin: 0; }

/* === TABS === */
.tabs {
  display: flex;
  gap: 4px;
  background: var(--bg);
  padding: 4px;
  border-radius: var(--radius-sm);
  width: fit-content;
  margin-bottom: 16px;
}
.tabs .tab {
  padding: 6px 16px;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  border-radius: 5px;
  color: var(--text-muted);
  user-select: none;
}
.tabs .tab.active {
  background: white;
  color: var(--text);
  box-shadow: var(--shadow-sm);
}

/* === SYNTH PAGE === */
.synth-grid {
  display: grid;
  grid-template-columns: 1fr 320px;
  gap: 20px;
}
@media (max-width: 1100px) {
  .synth-grid { grid-template-columns: 1fr; }
}
.player {
  background: linear-gradient(135deg, #f1f5f9 0%, #e2e8f0 100%);
  border-radius: var(--radius-sm);
  padding: 16px;
  margin-top: 14px;
  display: flex;
  align-items: center;
  gap: 14px;
}
.player audio { flex: 1; }
.player .meta {
  font-size: 12px;
  color: var(--text-muted);
  text-align: right;
  min-width: 90px;
}
.voice-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 8px;
  margin-top: 8px;
}
.voice-chip {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 12px;
  background: var(--bg);
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: 12.5px;
  font-weight: 500;
  transition: all 0.1s;
  user-select: none;
}
.voice-chip:hover { background: white; border-color: var(--border); }
.voice-chip.active {
  background: var(--brand);
  color: white;
  border-color: var(--brand);
  box-shadow: 0 2px 6px rgba(51,153,153,0.30);
}
.voice-chip .m { color: #3b82f6; font-size: 11px; }
.voice-chip .f { color: #ec4899; font-size: 11px; }
.voice-chip.active .m, .voice-chip.active .f { color: rgba(255,255,255,0.85); }

/* === РЕДАКТОР СЛОВАРЕЙ (поиск, чекбоксы, sticky-header,
       подсветка изменений, счётчики, empty state). Перенесены из
       inline demo.html в общий admin.css — чтобы новые страницы
       /dictionaries/replacements и /dictionaries/pronunciation
       имели правильную стилистику. === */
.dict-toolbar {
  display: flex;
  gap: 0.6em;
  flex-wrap: wrap;
  align-items: center;
  margin: 0.4em 0;
  padding: 0.4em 0.5em;
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: 4px;
}
.dict-toolbar input[type="search"] {
  font: inherit;
  padding: 0.3em 0.5em;
  border: 1px solid #cbd5e1;
  border-radius: 4px;
  min-width: 14em;
  flex: 1;
}
.dict-counter { color: #475569; font-size: 0.85em; }
.dict-bulk-del {
  background: var(--error);
  color: white;
  border: none;
  font: inherit;
  padding: 0.3em 0.7em;
  font-size: 0.85em;
  border-radius: var(--radius-sm);
  cursor: pointer;
}
.dict-bulk-del:disabled { background: #cbd5e1; color: #64748b; cursor: not-allowed; }
.dict-tool-spacer { flex: 1; min-width: 0.5em; }
.dict-tool-btn {
  background: #0ea5e9;
  color: white;
  border: none;
  font: inherit;
  padding: 0.3em 0.7em;
  font-size: 0.85em;
  border-radius: var(--radius-sm);
  cursor: pointer;
}
.dict-tool-btn.ghost { background: #f1f5f9; color: #334155; border: 1px solid #cbd5e1; }
.dict-tool-btn.ghost:hover:not(:disabled) { background: #e2e8f0; }
.dict-changes-badge {
  display: inline-block;
  margin-left: 0.4em;
  padding: 0.1em 0.5em;
  background: #fef3c7;
  color: #92400e;
  border-radius: 999px;
  font-size: 0.8em;
  font-weight: 600;
}
.dict-changes-badge[hidden] { display: none; }
.dict-table { width: 100%; border-collapse: collapse; font-size: 0.9em; }
.dict-table thead th {
  position: sticky;
  top: 0;
  background: #f3f4f6;
  z-index: 1;
  text-align: left;
  padding: 0.35em 0.5em;
  cursor: pointer;
  user-select: none;
  border-bottom: 1px solid #e2e8f0;
  font-weight: 600;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-muted);
}
.dict-table thead th.no-sort { cursor: default; }
.dict-table thead th.sorted-asc::after { content: "  ▲"; font-size: 0.75em; color: #64748b; }
.dict-table thead th.sorted-desc::after { content: "  ▼"; font-size: 0.75em; color: #64748b; }
.dict-table tbody td input[type="text"] {
  font: inherit;
  width: 100%;
  padding: 0.35em 0.5em;
  border: 1px solid #cbd5e1;
  border-radius: 3px;
  background: white;
  box-sizing: border-box;
}
.dict-table tbody td input[type="text"]:focus {
  border-color: var(--brand);
  outline: 2px solid rgba(51,153,153,0.25);
  outline-offset: -1px;
}
.dict-table tbody td { padding: 0.2em 0.3em; }
.dict-table tbody tr.dirty td input[type="text"] { background: #fef3c7; }
.dict-table tbody tr.row-hidden { display: none; }
.dict-table tbody tr.row-error td input[type="text"] { background: #fee2e2; border-color: #fca5a5; }
.dict-empty {
  color: #64748b;
  font-style: italic;
  text-align: center;
  padding: 1em 0.5em;
  background: #f8fafc;
  border: 1px dashed #cbd5e1;
  border-radius: 4px;
  margin-top: 0.3em;
}
.dict-empty[hidden] { display: none; }
.dict-row-test {
  padding: 0.4em 0.6em;
  background: #f8fafc;
  border-left: 3px solid var(--brand);
  font-size: 0.85em;
  margin: 0.2em 0 0.4em 0;
}
.dict-row-test input[type="text"] {
  font: inherit;
  padding: 0.25em 0.4em;
  border: 1px solid #cbd5e1;
  border-radius: 3px;
  width: 60%;
}
.dict-row-test .result { font-family: 'JetBrains Mono', ui-monospace, monospace; color: var(--success); }
.dict-row-test .result.err { color: var(--error); }
.dict-rx-status { font-size: 0.78em; padding: 0.1em 0.4em; border-radius: 3px; display: inline-block; }
.dict-rx-status.ok { background: #dcfce7; color: #15803d; }
.dict-rx-status.err { background: #fee2e2; color: #b91c1c; }

/* === LEGACY DEMO FORMS (импортированы из старого demo.html для /synth и
       страниц словарей; стили применимы только в .content области, чтобы
       не пересекаться с admin-layout). === */
.content fieldset {
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 1em 1.2em;
  margin-bottom: 1em;
  background: var(--surface);
}
.content fieldset legend { padding: 0 0.5em; font-weight: 600; color: var(--text); }
.content fieldset label { display: block; margin: 0.5em 0; color: var(--text); font-size: 13.5px; }
.content textarea, .content select, .content input[type="number"] {
  font: inherit;
  padding: 0.5em 0.7em;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  box-sizing: border-box;
  background: white;
}
.content textarea {
  width: 100%;
  min-height: 100px;
  resize: vertical;
  font-family: 'JetBrains Mono', ui-monospace, monospace;
  font-size: 13px;
}
.content select { min-width: 220px; max-width: 100%; }
.content textarea:focus, .content select:focus, .content input:focus {
  outline: 2px solid rgba(51,153,153,0.25);
  border-color: var(--brand);
}
.content .row {
  display: flex; gap: 1em; flex-wrap: wrap; align-items: center;
}
.content .row label { flex: 1; min-width: 200px; }
.content audio { width: 100%; margin-top: 0.5em; }
.content .meta {
  margin-top: 0.5em;
  font-size: 0.9em;
  color: var(--text-muted);
  font-family: 'JetBrains Mono', ui-monospace, monospace;
}
.content .meta dt { float: left; clear: left; width: 12em; }
.content .error {
  color: var(--error);
  padding: 0.6em 0.8em;
  background: rgba(239,68,68,0.10);
  border-radius: var(--radius-sm);
  margin: 0.5em 0;
}
.content small { color: var(--text-muted); }

/* form-кнопка legacy (внутри demo-form) — в admin-стиле */
.content form button[type="submit"],
.content form #go,
.content form #preview,
.content #be-save,
.content #cd-save, .content #pl-save,
.content #cd-reload, .content #pl-reload,
.content #cd-add-lit, .content #cd-add-rx, .content #pl-add {
  font: inherit;
  padding: 0.55em 1.2em;
  background: var(--brand);
  color: white;
  border: none;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-weight: 600;
  font-size: 14px;
}
.content form button[type="submit"]:hover:not(:disabled) {
  background: #2c8585;
}
.content form button:disabled { background: #cbd5e1; color: #64748b; cursor: not-allowed; }
.content #preview { background: #0ea5e9; }
.content #preview:hover { background: #0284c7; }
.content #cd-reload, .content #pl-reload { background: #0ea5e9; }
.content #cd-add-lit, .content #cd-add-rx, .content #pl-add { background: var(--accent); }

/* === SYSTEM CARD (glass-стиль в правой колонке Hero) === */
.system-card {
  background: rgba(255,255,255,0.10);
  border: 1px solid rgba(255,255,255,0.18);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border-radius: 10px;
  padding: 14px 18px;
  min-width: 260px;
  color: white;
  position: relative; z-index: 2;
}
.system-card .sys-row {
  display: flex; justify-content: space-between; gap: 18px;
  font-size: 12px; padding: 5px 0;
  border-bottom: 1px solid rgba(255,255,255,0.08);
}
.system-card .sys-row:last-child { border-bottom: none; }
.system-card .sys-row .lbl { color: rgba(255,255,255,0.65); }
.system-card .sys-row .val {
  color: white; font-weight: 600;
  font-family: 'JetBrains Mono', ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 11.5px;
}
.system-card .health-row {
  display: flex; align-items: center; gap: 8px;
  margin-bottom: 8px;
  padding-bottom: 10px;
  border-bottom: 1px solid rgba(255,255,255,0.15);
}
.health-pill {
  display: inline-flex; align-items: center; gap: 6px;
  background: rgba(34,197,94,0.20); color: #d6f5e0;
  padding: 4px 10px; border-radius: 999px;
  font-size: 11.5px; font-weight: 600; letter-spacing: 0.3px;
  text-transform: uppercase;
}
.health-pill::before {
  content: ""; width: 7px; height: 7px; border-radius: 50%;
  background: #22c55e;
  box-shadow: 0 0 0 3px rgba(34,197,94,0.25);
}
.health-pill.warn {
  background: rgba(234,179,8,0.20); color: #fef3c7;
}
.health-pill.warn::before { background: #eab308; box-shadow: 0 0 0 3px rgba(234,179,8,0.25); }
.health-pill.error {
  background: rgba(239,68,68,0.20); color: #fecaca;
}
.health-pill.error::before { background: #ef4444; box-shadow: 0 0 0 3px rgba(239,68,68,0.25); }

/* === CACHE CARD (объёмная карточка о ёмкости кэша) === */
.cache-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px 22px;
  margin-top: 14px;
  box-shadow: var(--shadow-sm);
}
.cache-card .cache-head {
  display: flex; align-items: baseline; justify-content: space-between;
  margin-bottom: 12px;
  flex-wrap: wrap; gap: 12px;
}
.cache-card .cache-title {
  font-size: 14px; font-weight: 600; color: var(--text);
}
.cache-card .cache-title .of {
  color: var(--text-muted); font-weight: 400;
}
.cache-card .cache-stats {
  font-size: 12.5px; color: var(--text-muted);
  display: flex; gap: 16px; flex-wrap: wrap;
}
.cache-card .cache-stats b { color: var(--text); font-weight: 600; }
.cache-card .cache-bar {
  background: var(--bg);
  border-radius: 999px;
  height: 10px;
  overflow: hidden;
  position: relative;
}
.cache-card .cache-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--brand), #2c8585);
  border-radius: 999px;
  transition: width 0.4s ease;
}
.cache-card .cache-foot {
  margin-top: 10px;
  font-size: 12px;
  color: var(--text-muted);
}

/* === /synth — новая разметка проверки синтеза (две оси: формат + диалект) === */
.synth-grid {
  display: grid; grid-template-columns: 1.4fr 1fr; gap: 16px;
}

/* Tabs над textarea — главная ось формата */
.synth-tabs {
  display: flex; gap: 4px; margin-bottom: 12px;
  border-bottom: 1px solid var(--border);
}
.synth-tabs .tab {
  padding: 8px 18px; font-size: 13px; font-weight: 600;
  color: var(--text-muted); cursor: pointer;
  border-bottom: 2px solid transparent; margin-bottom: -1px;
  transition: all 0.12s;
  background: transparent; border-left: none; border-right: none; border-top: none;
  font-family: inherit;
}
.synth-tabs .tab.active { color: var(--brand); border-bottom-color: var(--brand); }
.synth-tabs .tab:not(.active):hover { color: var(--text); }

/* Textarea — универсальный mono */
.synth-text textarea {
  width: 100%; box-sizing: border-box; min-height: 180px;
  padding: 14px 16px; border: 1px solid var(--border); border-radius: 8px;
  font-family: 'JetBrains Mono', ui-monospace, monospace;
  font-size: 13px; line-height: 1.55;
  resize: vertical; background: var(--surface); color: var(--text);
}
.synth-text textarea.plain {
  font-family: inherit; font-size: 14px;
}
.synth-text textarea:focus { outline: none; border-color: var(--brand); }
.synth-actions {
  display: flex; gap: 10px; align-items: center; margin-top: 14px;
  flex-wrap: wrap;
}
.synth-actions .opt-toggle {
  margin-left: auto; display: flex; gap: 14px;
  font-size: 12.5px; color: var(--text-muted);
}
.synth-actions .opt-toggle label {
  display: inline-flex; align-items: center; gap: 5px; cursor: pointer;
}

/* Подсказка по маркеру ударения — компактно, ненавязчиво */
.stress-hint {
  margin-top: 10px;
  padding: 8px 12px;
  background: var(--bg);
  border-left: 3px solid var(--brand);
  border-radius: 4px;
  font-size: 12px; color: var(--text-muted);
}
.stress-hint b { color: var(--text); }
.stress-hint code {
  background: var(--surface); padding: 1px 6px; border-radius: 3px;
  font-family: 'JetBrains Mono', ui-monospace, monospace;
  font-size: 11.5px; color: var(--text);
}

/* Примеры разметки — карточки-чипы */
.examples { margin-top: 16px; }
.examples .label {
  font-size: 11px; text-transform: uppercase; letter-spacing: 0.6px;
  color: var(--text-muted); font-weight: 600; margin-bottom: 8px;
}
.examples-grid {
  display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px;
}
.example-chip {
  background: var(--bg); border: 1px solid var(--border);
  border-radius: 8px; padding: 10px 12px; cursor: pointer;
  transition: all 0.12s; user-select: none;
}
.example-chip:hover { border-color: var(--brand); background: var(--surface); }
.example-chip .ex-title {
  font-size: 11.5px; color: var(--text-muted); font-weight: 600;
  margin-bottom: 4px;
}
.example-chip .ex-code {
  font-family: 'JetBrains Mono', ui-monospace, monospace;
  font-size: 11.5px; color: var(--text); line-height: 1.4;
  overflow: hidden; text-overflow: ellipsis;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical;
}
.example-chip .ex-code .tag { color: #c084fc; }
.example-chip .ex-code .attr { color: #14b8a6; }
.example-chip .ex-code .plus { color: var(--brand); font-weight: 700; }

/* Голос — чипы вместо select */
.voice-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.voice-chip {
  padding: 5px 10px; font-size: 12px;
  background: var(--bg); border: 1px solid var(--border);
  border-radius: 999px; cursor: pointer; user-select: none;
  color: var(--text);
  font-family: 'JetBrains Mono', ui-monospace, monospace;
}
.voice-chip:hover { border-color: var(--brand); color: var(--brand); }
.voice-chip.selected {
  background: var(--brand); color: white; border-color: var(--brand);
}
.voice-chip.female.selected { background: #c084fc; border-color: #c084fc; }
.voice-section + .voice-section { margin-top: 14px; }
.voice-section h4 {
  font-size: 11px; text-transform: uppercase; letter-spacing: 0.6px;
  color: var(--text-muted); margin: 0 0 8px; font-weight: 600;
}

/* Параметры — grid 2 колонки */
.param-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-bottom: 12px; }
.param-grid:last-child { margin-bottom: 0; }
.param-grid.full { grid-template-columns: 1fr; }
.param-grid > div > label {
  display: block; font-size: 12px; color: var(--text-muted); margin-bottom: 4px;
}
.param-grid select {
  width: 100%; padding: 6px 10px; border: 1px solid var(--border);
  border-radius: 6px; background: var(--surface); font-size: 13px; color: var(--text);
}
.param-grid input[type="range"] { width: 100%; }
.param-grid .val {
  float: right; font-family: 'JetBrains Mono', ui-monospace, monospace;
}
.params-sep {
  margin: 14px 0 12px; border: 0; border-top: 1px dashed var(--border);
}
.param-grid .dialect-help {
  font-size: 11px; color: var(--text-muted); margin-top: 4px; line-height: 1.4;
}

/* Справочник по тегам — раскрывающиеся карточки (accordion) */
.ref-card { margin-top: 14px; }
.ref-card h3 { margin: 0 0 6px; font-size: 14px; }
.ref-card .ref-sub {
  font-size: 12px; color: var(--text-muted); margin-bottom: 12px;
}
.ref-card .ref-sub a {
  color: var(--brand); text-decoration: none; font-weight: 600;
}
.ref-item {
  border: 1px solid var(--border); border-radius: 8px;
  margin-bottom: 6px; background: var(--surface); overflow: hidden;
}
.ref-item summary {
  padding: 9px 12px; cursor: pointer; user-select: none;
  list-style: none; display: flex; align-items: center; gap: 10px;
  font-size: 12.5px;
}
.ref-item summary::-webkit-details-marker { display: none; }
.ref-item summary::before {
  content: "›"; color: var(--text-muted); font-size: 16px;
  transition: transform 0.15s;
}
.ref-item[open] summary::before { transform: rotate(90deg); }
.ref-item summary .ref-name {
  font-family: 'JetBrains Mono', ui-monospace, monospace;
  color: #7c3aed; font-weight: 700;
}
.ref-item summary .ref-brief {
  color: var(--text-muted); font-size: 12px; flex: 1;
}
.ref-item summary .ref-tag {
  background: var(--bg); padding: 1px 7px; border-radius: 999px;
  font-size: 10px; color: var(--text-muted); font-weight: 600;
  text-transform: uppercase; letter-spacing: 0.4px;
}
.ref-item summary .ref-tag.ok { background: rgba(34,197,94,0.15); color: #15803d; }
.ref-item summary .ref-tag.warn { background: rgba(234,179,8,0.15); color: #a16207; }
.ref-item summary .ref-tag.ignore { background: rgba(239,68,68,0.10); color: #b91c1c; }
.ref-item .ref-body {
  padding: 0 14px 14px;
  border-top: 1px solid var(--border);
  font-size: 12.5px; color: var(--text); line-height: 1.5;
}
.ref-item .ref-body p { margin: 12px 0 8px; }
.ref-item .ref-body pre {
  background: #0f172a; color: #e2e8f0;
  padding: 10px 12px; border-radius: 6px; margin: 8px 0;
  font-family: 'JetBrains Mono', ui-monospace, monospace;
  font-size: 11.5px; line-height: 1.5; white-space: pre-wrap;
}
.ref-item .ref-body pre .tag { color: #a78bfa; }
.ref-item .ref-body pre .attr { color: #5eead4; }
.ref-item .ref-body pre .str { color: #fbbf24; }
.ref-item .ref-body .attrs-table {
  width: 100%; border-collapse: collapse; margin: 8px 0; font-size: 11.5px;
}
.ref-item .ref-body .attrs-table th,
.ref-item .ref-body .attrs-table td {
  text-align: left; padding: 5px 8px;
  border-bottom: 1px solid var(--border); vertical-align: top;
}
.ref-item .ref-body .attrs-table th {
  background: var(--bg); color: var(--text-muted); font-weight: 600;
  font-size: 10.5px; text-transform: uppercase; letter-spacing: 0.4px;
}
.ref-item .ref-body .attrs-table code {
  font-family: 'JetBrains Mono', ui-monospace, monospace;
  background: var(--bg); padding: 1px 5px; border-radius: 3px; font-size: 11px;
}
.ref-item .ref-body .doc-link {
  display: inline-block; margin-top: 8px;
  color: var(--brand); text-decoration: none; font-weight: 600; font-size: 12px;
}
.ref-item .ref-body .doc-link::after { content: " →"; }
.ref-item .ref-body .note {
  background: rgba(234,179,8,0.10); border-left: 3px solid #eab308;
  padding: 8px 10px; border-radius: 4px; margin: 8px 0;
  font-size: 12px;
}

/* Карточка «В нейронку отправляется» (предпросмотр) */
.voiced-card { margin-top: 14px; }
.voiced-card .label {
  font-size: 11px; text-transform: uppercase; letter-spacing: 0.6px;
  color: var(--text-muted); margin-bottom: 8px; font-weight: 600;
}
.voiced-card pre {
  background: var(--bg); padding: 12px 14px; border-radius: 6px;
  border: 1px solid var(--border); margin: 0;
  font-family: 'JetBrains Mono', ui-monospace, monospace;
  font-size: 12.5px; line-height: 1.5; color: var(--text);
  white-space: pre-wrap; word-break: break-word;
}
.voiced-card pre .plus { color: var(--brand); font-weight: 700; }

/* Аудио-плеер: тёмная карточка + нативный <audio controls> */
.audio-card { margin-top: 14px; }
.audio-card h3 { margin: 0 0 12px; font-size: 14px; }
.audio-card audio {
  width: 100%; outline: none;
}
.audio-card .audio-meta {
  margin-top: 10px; font-size: 12px; color: var(--text-muted);
  display: flex; gap: 14px; flex-wrap: wrap;
}
.audio-card .audio-meta b { color: var(--text); font-weight: 600; }
.audio-card .audio-meta a {
  color: var(--brand); text-decoration: none; font-weight: 600;
}

.synth-error {
  background: rgba(239,68,68,0.10); border: 1px solid rgba(239,68,68,0.30);
  color: #b91c1c; padding: 10px 14px; border-radius: 6px;
  margin-top: 12px; font-size: 13px;
}

/* === Тонкая настройка: ссылки на словарь замен/произношения === */
.tuning-card { margin-top: 14px; }
.tuning-card h3 { margin: 0 0 12px; font-size: 14px; }
.tuning-card .tun-sub {
  font-size: 12px; color: var(--text-muted); margin-bottom: 12px;
}
.tun-link {
  display: flex; align-items: flex-start; gap: 12px;
  padding: 12px; margin-bottom: 6px;
  background: var(--bg); border: 1px solid var(--border);
  border-radius: 8px; text-decoration: none; color: inherit;
  transition: all 0.12s;
}
.tun-link:hover {
  border-color: var(--brand);
  background: var(--surface);
  transform: translateX(2px);
}
.tun-link .tun-icon {
  width: 32px; height: 32px; border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
  background: rgba(51,153,153,0.10); color: var(--brand);
}
.tun-link.pron .tun-icon { background: rgba(192,132,252,0.15); color: #7c3aed; }
.tun-link .tun-text { flex: 1; min-width: 0; }
.tun-link .tun-title {
  font-size: 13px; font-weight: 600; color: var(--text);
  display: flex; align-items: center; gap: 6px;
}
.tun-link .tun-title::after {
  content: "→"; color: var(--text-muted); font-weight: 400;
  margin-left: auto; opacity: 0.5; transition: all 0.12s;
}
.tun-link:hover .tun-title::after { opacity: 1; transform: translateX(2px); }
.tun-link .tun-desc {
  font-size: 11.5px; color: var(--text-muted);
  line-height: 1.4; margin-top: 3px;
}

/* Inline-ссылка в подсказке (Stress-hint) */
.stress-hint a {
  color: var(--brand); text-decoration: none; font-weight: 600;
}
.stress-hint a:hover { text-decoration: underline; }

/* === Режим инженера: чекбокс мелким серым внизу карточки Параметры === */
.engineer-toggle {
  margin-top: 14px; padding-top: 12px;
  border-top: 1px dashed var(--border);
  font-size: 12px; color: var(--text-muted);
}
.engineer-toggle label {
  display: flex; align-items: center; gap: 8px; cursor: pointer;
  user-select: none;
}
.engineer-toggle input[type="checkbox"] {
  width: 14px; height: 14px; margin: 0; cursor: pointer;
  accent-color: var(--brand);
}
.engineer-toggle .eng-desc {
  margin-left: 22px; margin-top: 4px;
  font-size: 11px; line-height: 1.4;
}
.engineer-toggle.on label > span { color: #7c3aed; font-weight: 600; }

/* === Карточка «Диагностика» (видна только в Режиме инженера) === */
.diag-card { margin-top: 14px; }
.diag-card h3 {
  margin: 0 0 6px; font-size: 14px;
  display: flex; align-items: center; gap: 8px;
}
.diag-card h3 .eng-badge {
  background: rgba(124,58,237,0.10); color: #7c3aed;
  padding: 2px 8px; border-radius: 999px;
  font-size: 10px; text-transform: uppercase; letter-spacing: 0.5px;
  font-weight: 700;
}
.diag-card .diag-sub {
  font-size: 12px; color: var(--text-muted); margin-bottom: 12px;
}
.diag-block {
  border: 1px solid var(--border); border-radius: 8px;
  margin-bottom: 6px; background: var(--surface); overflow: hidden;
}
.diag-block summary {
  padding: 10px 14px; cursor: pointer; user-select: none;
  list-style: none; display: flex; align-items: center; gap: 10px;
  font-size: 13px;
}
.diag-block summary::-webkit-details-marker { display: none; }
.diag-block summary::before {
  content: "›"; color: var(--text-muted); font-size: 16px;
  transition: transform 0.15s;
}
.diag-block[open] summary::before { transform: rotate(90deg); }
.diag-block summary .diag-name { font-weight: 600; color: var(--text); }
.diag-block summary .diag-brief {
  color: var(--text-muted); font-size: 12px; flex: 1;
}
.diag-block .diag-body {
  padding: 0 14px 14px;
  border-top: 1px solid var(--border);
}
.diag-block .diag-body .diag-summary {
  background: var(--bg); padding: 10px 12px; border-radius: 6px;
  margin: 8px 0; font-size: 12.5px;
}
.diag-block .diag-body .diag-summary dl { margin: 0; display: grid;
  grid-template-columns: max-content 1fr; gap: 4px 14px; }
.diag-block .diag-body .diag-summary dt {
  color: var(--text-muted); font-size: 11px;
}
.diag-block .diag-body .diag-summary dd {
  margin: 0; font-weight: 600;
  font-family: 'JetBrains Mono', ui-monospace, monospace;
  font-size: 12px;
}
.diag-block .diag-body table {
  width: 100%; border-collapse: collapse; font-size: 11.5px;
  margin-top: 8px;
}
.diag-block .diag-body table th,
.diag-block .diag-body table td {
  padding: 5px 8px; border-bottom: 1px solid var(--border);
  text-align: left; vertical-align: top;
}
.diag-block .diag-body table th {
  background: var(--bg); color: var(--text-muted);
  font-size: 10.5px; text-transform: uppercase; letter-spacing: 0.4px;
}
.diag-block .diag-body .bar {
  display: inline-block; height: 10px; background: #6366f1;
  border-radius: 2px; vertical-align: middle; min-width: 2px;
}
.diag-block .diag-body .bar.hit { background: #22c55e; }
.diag-block .diag-body .pill {
  display: inline-block; padding: 1px 7px; border-radius: 999px;
  font-size: 10px; font-weight: 600;
}
.diag-block .diag-body .pill.hit { background: rgba(34,197,94,0.15); color: #15803d; }
.diag-block .diag-body .pill.miss { background: rgba(99,102,241,0.15); color: #4338ca; }

/* Responsive */
@media (max-width: 1200px) {
  .kpis { grid-template-columns: repeat(2, 1fr); }
  .quick-actions-grid { grid-template-columns: repeat(2, 1fr); }
  .dashboard-row { grid-template-columns: 1fr; }
  .hero { grid-template-columns: 1fr; }
  .system-card { min-width: 0; }
}
@media (max-width: 1100px) {
  .synth-grid { grid-template-columns: 1fr; }
}
@media (max-width: 768px) {
  .app { grid-template-columns: 64px 1fr; }
  .sidebar .brand .name, .sidebar .brand .sub,
  .sidebar .nav-group-label, .sidebar a.nav-item span:not(.icon-only),
  .sidebar .footer { display: none; }
  .sidebar a.nav-item { justify-content: center; }
}

/* ============================================================
   Auth-v2 admin pages — users / keys / audit / profile / dropdowns
   ============================================================ */

/* User-pill dropdown (Профиль / Выйти) */
.user-menu { position: relative; cursor: pointer; }
.user-menu .user-dropdown {
  display: none;
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  box-shadow: var(--shadow);
  min-width: 160px;
  z-index: 100;
  overflow: hidden;
}
.user-menu:focus-within .user-dropdown,
.user-menu:hover .user-dropdown { display: block; }
.user-menu .user-dropdown a,
.user-menu .user-dropdown .user-dropdown-btn {
  display: block;
  width: 100%;
  text-align: left;
  padding: 8px 14px;
  font-size: 13px;
  background: none;
  border: 0;
  cursor: pointer;
  color: var(--text);
  font-family: inherit;
}
.user-menu .user-dropdown a:hover,
.user-menu .user-dropdown .user-dropdown-btn:hover { background: var(--bg); }

/* Page-header */
.page-header { display:flex; justify-content:space-between; align-items:flex-start; gap:16px; margin-bottom:20px; flex-wrap:wrap; }
.page-header h2 { margin:0 0 6px 0; font-size:20px; font-weight:700; color:var(--text); }
.page-header .subtitle { margin:0; color:var(--text-muted); font-size:13px; max-width:680px; }
.page-header .actions { display:flex; gap:10px; flex-wrap:wrap; }

/* Inline-mono для префикса ключа, путей */
.mono-inline { font-family:'JetBrains Mono', ui-monospace, monospace; font-size:12.5px; background:rgba(15,23,42,0.05); padding:1px 6px; border-radius:4px; }

/* Универсальная табличка для users/keys/audit */
.tbl { width:100%; border-collapse:separate; border-spacing:0; }
.tbl th, .tbl td { padding:11px 14px; text-align:left; border-bottom:1px solid var(--border); font-size:13px; vertical-align:middle; }
.tbl th { background:var(--bg); color:var(--text-muted); font-weight:600; font-size:11.5px; text-transform:uppercase; letter-spacing:0.4px; }
.tbl tbody tr:hover { background:rgba(51,153,153,0.04); }
.tbl td.num { text-align:right; font-variant-numeric:tabular-nums; }
.tbl td.actions { text-align:right; white-space:nowrap; }
.tbl .row-secondary { color:var(--text-muted); font-size:12px; margin-top:2px; }

/* Цветные бейджи (role/status) */
.badge { display:inline-block; padding:2px 8px; border-radius:999px; font-size:11.5px; font-weight:500; }
.badge.admin { background:rgba(51,153,153,0.12); color:var(--brand-dark); }
.badge.customer { background:rgba(249,115,22,0.12); color:#c2410c; }
.badge.disabled { background:rgba(100,116,139,0.12); color:var(--text-muted); }
.badge.active { background:rgba(16,185,129,0.12); color:#047857; }
.badge.revoked { background:rgba(239,68,68,0.10); color:var(--error); }
.badge.expired { background:rgba(245,158,11,0.12); color:#b45309; }

/* Quota bar */
.quota { min-width:160px; }
.quota .bar { background:var(--bg); border-radius:999px; height:6px; overflow:hidden; margin:4px 0 2px; }
.quota .fill { background:var(--brand); height:100%; border-radius:999px; }
.quota .fill.warn { background:var(--warning); }
.quota .fill.over { background:var(--error); }
.quota .meta { font-size:11.5px; color:var(--text-muted); font-variant-numeric:tabular-nums; }

/* Form-card (создание user / key / профиль) */
.form-card { max-width: 640px; }
.form-card .row2 { display:grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.form-card .form-actions { display:flex; gap:10px; justify-content:flex-end; border-top:1px solid var(--border); margin-top:18px; padding-top:18px; }
.form-card .field .hint { display:block; margin-top:5px; color:var(--text-muted); font-size:12px; }

/* Scope-чекбоксы (карточки на странице выпуска ключа) */
.scope-list { display:flex; flex-direction:column; gap:8px; margin-top:6px; }
.scope-item {
  display:grid;
  grid-template-columns: 18px 130px 1fr;
  gap:10px;
  align-items:center;
  padding:10px 12px;
  border:1px solid var(--border);
  border-radius:8px;
  cursor:pointer;
  background:var(--surface);
  font-weight:400;
  transition: border-color .15s;
  text-transform: none;
  letter-spacing: normal;
  margin-bottom: 0;
}
.scope-item, .scope-item * { text-transform: none; letter-spacing: normal; }
.scope-item:hover { border-color: var(--brand); }
.scope-item input[type=checkbox] { margin:0; width:16px; height:16px; cursor:pointer; }
.scope-item .nm { font-family:'JetBrains Mono', monospace; font-size:13px; font-weight:500; color:var(--text); }
.scope-item .hint { color:var(--text-muted); font-size:12.5px; }

/* Secret-card (показ ключа один раз) */
.secret-card { max-width: 720px; }
.secret-card .warn-row { background:rgba(245,158,11,0.10); border-left:3px solid var(--warning); padding:12px 14px; border-radius:6px; margin-bottom:18px; font-size:13px; }
.secret-card .secret-row { background:#0f172a; color:#f1f5f9; font-family:'JetBrains Mono', monospace; padding:14px 16px; border-radius:8px; display:flex; align-items:center; gap:10px; font-size:14px; }
.secret-card .secret-row code { flex:1; word-break:break-all; color:#f1f5f9; }
.secret-card .secret-row .copy { background:rgba(255,255,255,0.10); color:#fff; border:0; padding:6px 12px; border-radius:6px; font-size:12.5px; cursor:pointer; }
.secret-card .props { margin-top:18px; display:grid; grid-template-columns:auto 1fr; gap:8px 18px; font-size:13px; }
.secret-card .props .lbl { color:var(--text-muted); }

/* Mini-stats (сводка на admin-dashboard) */
.mini-stats { display:grid; grid-template-columns:repeat(4,1fr); gap:14px; margin-bottom:24px; }
.mini-stat { background:var(--surface); border:1px solid var(--border); border-radius:var(--radius); padding:16px 18px; }
.mini-stat .lbl { font-size:11.5px; text-transform:uppercase; letter-spacing:0.4px; color:var(--text-muted); font-weight:600; }
.mini-stat .val { font-size:26px; font-weight:700; margin-top:4px; }
.mini-stat .delta { font-size:12px; color:var(--text-muted); margin-top:3px; }
.mini-stat.accent .val { color:var(--brand-dark); }

/* Activity feed (audit log preview на dashboard) */
.activity { display:flex; flex-direction:column; gap:0; }
.activity .row { display:grid; grid-template-columns:90px 130px 1fr 110px; gap:14px; padding:10px 0; border-bottom:1px solid var(--border); font-size:13px; align-items:center; }
.activity .row:last-child { border-bottom:0; }
.activity .row .ts { font-family:'JetBrains Mono', monospace; color:var(--text-muted); font-size:12px; }
.activity .row .act { font-weight:500; }
.activity .row .who { color:var(--text-muted); font-size:12px; }
.activity .row .ip { font-family:'JetBrains Mono', monospace; font-size:11.5px; color:var(--text-muted); text-align:right; }

/* Profile-grid (свои данные / сессии / пароль / ключи) */
.profile-grid { display:grid; grid-template-columns: 1fr 1fr; gap:20px; align-items:start; }
.profile-grid .card { padding:20px 22px; }
.profile-grid .card h3 { margin:0 0 14px; font-size:15px; font-weight:600; }
.profile-grid .info-row { display:flex; justify-content:space-between; padding:8px 0; border-bottom:1px solid var(--border); font-size:13px; }
.profile-grid .info-row:last-child { border-bottom:0; }
.profile-grid .info-row .l { color:var(--text-muted); }

/* User detail (2/1 grid) */
.detail-grid { display:grid; grid-template-columns: 2fr 1fr; gap:20px; align-items:start; }
.detail-grid .card { padding:18px 20px; }
.detail-grid .card h3 { margin:0 0 12px; font-size:14px; font-weight:600; text-transform:uppercase; letter-spacing:0.3px; color:var(--text-muted); }
.detail-grid .info-row { display:flex; justify-content:space-between; padding:7px 0; border-bottom:1px solid var(--border); font-size:13px; }
.detail-grid .info-row:last-child { border-bottom:0; }
.detail-grid .info-row .l { color:var(--text-muted); }

/* Toolbar над таблицей (поиск + фильтры) */
.toolbar { display:flex; gap:10px; align-items:center; margin-bottom:14px; flex-wrap:wrap; }
.toolbar .search { flex:1; max-width:340px; }
.toolbar .search input { width:100%; padding:8px 12px; border:1px solid var(--border); border-radius:8px; font-size:13px; font-family:inherit; }
.toolbar .filter { padding:7px 10px; border:1px solid var(--border); border-radius:8px; background:var(--surface); font-size:13px; }

.empty { padding: 24px; text-align: center; color: var(--text-muted); }
.muted { color: var(--text-muted); }

/* === Форма «Сменить пароль» в /profile — не uppercase и нормальные input === */
.profile-grid .card .field { margin-bottom: 14px; }
.profile-grid .card .field label {
  display: block;
  text-transform: none;
  letter-spacing: normal;
  font-size: 12.5px;
  font-weight: 500;
  color: var(--text-muted);
  margin-bottom: 6px;
}
.profile-grid .card .field input[type="password"],
.profile-grid .card .field input[type="text"] {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 14px;
  font-family: inherit;
  background: var(--surface);
  color: var(--text);
}
.profile-grid .card .field input:focus {
  outline: none;
  border-color: var(--brand);
  box-shadow: 0 0 0 3px rgba(51,153,153,0.15);
}
.profile-grid .card .field .hint {
  display: block;
  margin-top: 5px;
  color: var(--text-muted);
  font-size: 12px;
}
