/* ═══════════════════════════════════════════════════════════════════════════
   TERRACTOV • LIFE SUITE | MONOCHROME NOIR DESIGN SYSTEM
   Pure Black, White, and Slate-Gray Developer Aesthetic
   ═══════════════════════════════════════════════════════════════════════════ */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700;800&family=JetBrains+Mono:wght@400;500;600;700&display=swap');

:root {
  /* ── Черно-бело-серая палитра ── */
  --bg-canvas:       #0a0a0c;
  --bg-sidebar:      #111115;
  --bg-header:       rgba(17, 17, 21, 0.92);
  --bg-card:         #16161b;
  --bg-card-hover:   #1b1b22;
  --bg-input:        #0c0c0f;
  --bg-input-focus:  #14141a;

  /* ── Границы (оттенки белого и серого) ── */
  --border-subtle:   rgba(255, 255, 255, 0.06);
  --border-card:     rgba(255, 255, 255, 0.09);
  --border-hover:    rgba(255, 255, 255, 0.22);
  --border-focus:    #ffffff;

  /* ── Текст ── */
  --text-white:      #ffffff;
  --text-primary:    #f4f4f6;
  --text-secondary:  #a1a1aa;
  --text-muted:      #71717a;
  --text-dim:        #3f3f46;

  /* ── Монохромные акценты ── */
  --accent-white:    #ffffff;
  --accent-gray-100: #f4f4f5;
  --accent-gray-300: #d4d4d8;
  --accent-gray-600: #52525b;
  --accent-gray-800: #27272a;
  --accent-black:    #0a0a0c;

  /* ── Индикаторы ── */
  --status-emerald:  #10b981;
  --status-crimson:  #ef4444;
  --status-amber:    #f59e0b;

  /* ── Шрифты ── */
  --font-sans:       'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --font-mono:       'JetBrains Mono', 'SF Mono', Consolas, monospace;

  /* ── Переходы ── */
  --ease-spring:     cubic-bezier(0.16, 1, 0.3, 1);
  --trans-fast:      140ms var(--ease-spring);
  --trans-normal:    220ms var(--ease-spring);

  /* ── Скругления ── */
  --radius-xs:       4px;
  --radius-sm:       6px;
  --radius-md:       10px;
  --radius-lg:       14px;
}

/* ═══════════════════════════════════════════════════════════════════════════
   BASE & RESET
   ═══════════════════════════════════════════════════════════════════════════ */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html, body {
  width: 100vw;
  height: 100vh;
  overflow: hidden;
  background-color: var(--bg-canvas);
  color: var(--text-primary);
  font-family: var(--font-sans);
  font-size: 12.5px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  user-select: none;
}

.hidden {
  display: none !important;
}

/* Scrollbar */
::-webkit-scrollbar {
  width: 4px;
  height: 4px;
}
::-webkit-scrollbar-track {
  background: transparent;
}
::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.1);
  border-radius: 4px;
}
::-webkit-scrollbar-thumb:hover {
  background: rgba(255, 255, 255, 0.22);
}

/* ═══════════════════════════════════════════════════════════════════════════
   SESSION PRELOADER (ZERO RELOAD FLICKER)
   ═══════════════════════════════════════════════════════════════════════════ */
html.has-session #view-login {
  display: none !important;
}

html.has-session #view-dashboard {
  display: flex !important;
}

/* ═══════════════════════════════════════════════════════════════════════════
   LOGIN & PENDING MODALS
   ═══════════════════════════════════════════════════════════════════════════ */
.login-fullscreen-overlay {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  z-index: 1000;
  background: radial-gradient(ellipse at center, rgba(17, 17, 21, 0.96) 0%, rgba(10, 10, 12, 0.99) 100%);
  backdrop-filter: blur(16px);
  animation: overlayFadeIn 0.3s var(--ease-spring);
}

@keyframes overlayFadeIn {
  from { opacity: 0; }
  to   { opacity: 1; }
}

.login-modal-card {
  position: relative;
  width: 100%;
  max-width: 390px;
  background: var(--bg-card);
  border: 1px solid var(--border-card);
  border-radius: var(--radius-lg);
  padding: 28px 24px;
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.8), inset 0 1px 0 rgba(255, 255, 255, 0.08);
  display: flex;
  flex-direction: column;
  gap: 16px;
  animation: modalSlideUp 0.35s var(--ease-spring);
}

@keyframes modalSlideUp {
  from { opacity: 0; transform: translateY(14px) scale(0.98); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}

.login-top-brand {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 6px;
}

.login-brand-icon {
  width: 52px;
  height: 52px;
  border-radius: 12px;
  background: #111115;
  border: 1px solid rgba(255, 255, 255, 0.15);
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 2px;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.5), inset 0 1px 0 rgba(255, 255, 255, 0.1);
}

.login-top-brand h2 {
  font-size: 16px;
  font-weight: 800;
  letter-spacing: 0.6px;
  color: var(--text-white);
}

.login-sub {
  font-size: 9.5px;
  font-weight: 700;
  letter-spacing: 1.4px;
  color: var(--text-muted);
  text-transform: uppercase;
}

.login-form-body {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.input-pw-row {
  position: relative;
  display: flex;
  align-items: center;
}

.input-pw-row input {
  width: 100%;
  padding-right: 36px;
}

.btn-eye {
  position: absolute;
  right: 6px;
  top: 50%;
  transform: translateY(-50%);
  background: transparent;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 5px;
  border-radius: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: color var(--trans-fast);
}

.btn-eye:hover {
  color: var(--text-white);
}

.login-hint-box {
  background: rgba(255, 255, 255, 0.02);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.login-hint-box h4 {
  font-size: 10.5px;
  font-weight: 700;
  color: var(--text-secondary);
}

.login-hint-box p {
  font-size: 10px;
  color: var(--text-muted);
  line-height: 1.5;
}

.login-hint-box code {
  font-family: var(--font-mono);
  background: rgba(255, 255, 255, 0.08);
  padding: 1px 5px;
  border-radius: 3px;
  color: var(--text-white);
  font-size: 9.5px;
}

/* Экран ожидания (Pending) */
.pending-pulse-icon {
  width: 52px;
  height: 52px;
  margin: 0 auto;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.2);
  display: flex;
  align-items: center;
  justify-content: center;
  animation: pendingPulse 2.2s infinite var(--ease-spring);
}

@keyframes pendingPulse {
  0%, 100% { transform: scale(1); box-shadow: 0 0 10px rgba(255, 255, 255, 0.1); }
  50%       { transform: scale(1.08); box-shadow: 0 0 20px rgba(255, 255, 255, 0.2); }
}

.pending-user-strip {
  display: flex;
  align-items: center;
  gap: 12px;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  text-align: left;
}

.pending-user-info {
  display: flex;
  flex-direction: column;
  gap: 3px;
  flex: 1;
}

.user-display {
  font-weight: 700;
  font-size: 13px;
  color: var(--text-white);
}

.id-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.id-row code {
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--text-muted);
}

/* ═══════════════════════════════════════════════════════════════════════════
   APP WINDOW & SIDEBAR
   ═══════════════════════════════════════════════════════════════════════════ */
.app-window {
  display: flex;
  width: 100vw;
  height: 100vh;
  overflow: hidden;
  background: var(--bg-canvas);
}

/* Сайдбар */
.sidebar {
  width: 216px;
  min-width: 216px;
  background: var(--bg-sidebar);
  border-right: 1px solid var(--border-subtle);
  display: flex;
  flex-direction: column;
  height: 100%;
  flex-shrink: 0;
  z-index: 10;
}

.sidebar-brand {
  height: 52px;
  padding: 0 16px;
  display: flex;
  align-items: center;
  gap: 10px;
  border-bottom: 1px solid var(--border-subtle);
}

.brand-logo-hex {
  width: 26px;
  height: 26px;
  display: flex;
  align-items: center;
  justify-content: center;
  filter: drop-shadow(0 0 6px rgba(255, 255, 255, 0.2));
}

.brand-name-group {
  display: flex;
  flex-direction: column;
}

.brand-main {
  font-size: 12.5px;
  font-weight: 800;
  letter-spacing: 0.8px;
  color: var(--text-white);
  line-height: 1.1;
}

.brand-mini {
  font-size: 8px;
  font-weight: 700;
  letter-spacing: 1.4px;
  color: var(--text-muted);
  text-transform: uppercase;
}

/* Навигация в сайдбаре */
.sidebar-nav-container {
  flex: 1;
  padding: 12px 8px;
  display: flex;
  flex-direction: column;
  gap: 3px;
  overflow-y: auto;
}

.sidebar-section-header {
  font-size: 8.5px;
  font-weight: 800;
  letter-spacing: 1.2px;
  color: var(--text-dim);
  text-transform: uppercase;
  padding: 8px 8px 4px;
}

.sidebar-section-header.mt-sec {
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px solid var(--border-subtle);
}

.nav-item {
  position: relative;
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 8px 10px;
  background: transparent;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  text-align: left;
  transition: all var(--trans-fast);
}

.nav-item svg {
  stroke: var(--text-muted);
  transition: stroke var(--trans-fast);
  flex-shrink: 0;
}

.nav-item:hover {
  color: var(--text-white);
  background: rgba(255, 255, 255, 0.05);
}

.nav-item:hover svg {
  stroke: var(--text-white);
}

.nav-item.active {
  color: var(--text-white);
  background: rgba(255, 255, 255, 0.08);
  border-color: rgba(255, 255, 255, 0.14);
}

.nav-item.active svg {
  stroke: #ffffff;
}

.nav-item.active::before {
  content: '';
  position: absolute;
  left: 0;
  top: 6px;
  bottom: 6px;
  width: 3px;
  border-radius: 0 3px 3px 0;
  background: #ffffff;
  box-shadow: 0 0 8px rgba(255, 255, 255, 0.6);
}

/* Профиль внизу сайдбара */
.sidebar-user-footer {
  height: 52px;
  padding: 0 10px;
  background: rgba(255, 255, 255, 0.02);
  border-top: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  gap: 8px;
}

.user-avatar-wrap {
  position: relative;
  width: 30px;
  height: 30px;
  flex-shrink: 0;
}

.avatar-round {
  width: 100%;
  height: 100%;
  border-radius: 50%;
  object-fit: cover;
  background: #18181f;
  border: 1px solid var(--border-card);
}

.user-online-dot {
  position: absolute;
  bottom: -1px;
  right: -1px;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #ffffff;
  border: 1.5px solid var(--bg-sidebar);
  box-shadow: 0 0 5px rgba(255, 255, 255, 0.6);
}

.user-footer-meta {
  display: flex;
  flex-direction: column;
  gap: 1px;
  overflow: hidden;
  flex: 1;
}

.user-footer-name {
  font-size: 11.5px;
  font-weight: 700;
  color: var(--text-white);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.badge-role {
  font-size: 9px;
  font-weight: 700;
  color: #ffffff;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 3px;
  padding: 0 5px;
  width: fit-content;
}

.badge-admin   { color: #ffffff; border-color: rgba(255, 255, 255, 0.3); background: rgba(255, 255, 255, 0.12); }
.badge-gl_main { color: #e4e4e7; border-color: rgba(255, 255, 255, 0.2); background: rgba(255, 255, 255, 0.08); }
.badge-main    { color: #d4d4d8; border-color: rgba(255, 255, 255, 0.16); background: rgba(255, 255, 255, 0.06); }
.badge-trainee { color: #a1a1aa; border-color: rgba(255, 255, 255, 0.12); background: rgba(255, 255, 255, 0.04); }

.btn-icon-footer {
  background: transparent;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 5px;
  border-radius: 5px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all var(--trans-fast);
}

.btn-icon-footer:hover {
  color: var(--text-white);
  background: rgba(255, 255, 255, 0.08);
}

/* ═══════════════════════════════════════════════════════════════════════════
   MAIN STAGE
   ═══════════════════════════════════════════════════════════════════════════ */
.main-stage {
  flex: 1;
  min-width: 0;
  min-height: 0;
  display: flex;
  flex-direction: column;
  height: 100%;
  overflow: hidden;
  background: var(--bg-canvas);
  position: relative;
  contain: layout;
}

/* Верхняя полоса статуса */
.stage-topbar {
  height: 48px;
  min-height: 48px;
  padding: 0 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--border-subtle);
  background: var(--bg-header);
  backdrop-filter: blur(12px);
  z-index: 5;
  flex-shrink: 0;
}

.topbar-left h2 {
  font-size: 14px;
  font-weight: 700;
  color: var(--text-white);
  letter-spacing: 0.2px;
}

.topbar-right {
  display: flex;
  align-items: center;
  gap: 8px;
}

.status-pill, .ws-pill {
  display: flex;
  align-items: center;
  gap: 6px;
  background: var(--bg-card);
  border: 1px solid var(--border-card);
  padding: 3px 9px;
  border-radius: 20px;
  font-size: 9.5px;
  font-weight: 700;
  letter-spacing: 0.5px;
  color: var(--text-secondary);
}

.status-indicator-dot, .ws-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #ffffff;
}

.status-indicator-dot.idle {
  background: #ffffff;
  box-shadow: 0 0 5px rgba(255, 255, 255, 0.5);
}

.status-indicator-dot.running {
  background: #ffffff;
  box-shadow: 0 0 8px #ffffff;
  animation: pulseDot 1.2s infinite var(--ease-spring);
}

.status-indicator-dot.error {
  background: var(--status-crimson);
  box-shadow: 0 0 6px var(--status-crimson);
}

@keyframes pulseDot {
  0%, 100% { transform: scale(0.8); opacity: 0.7; }
  50%       { transform: scale(1.2); opacity: 1; }
}

.ws-pill .ws-dot {
  background: var(--text-dim);
}

.ws-pill.ws-connected .ws-dot {
  background: #ffffff;
  box-shadow: 0 0 5px rgba(255, 255, 255, 0.6);
}

.ws-pill.ws-connected .ws-pill-text {
  color: #ffffff;
}

/* ── ТЕЛО СТРАНИЦЫ ── */
.stage-body {
  flex: 1;
  min-width: 0;
  min-height: 0;
  padding: 14px 16px;
  overflow-y: auto;
  overflow-x: hidden;
  display: flex;
  flex-direction: column;
  scrollbar-gutter: stable;
}

.tab-pane {
  display: flex;
  flex-direction: column;
  gap: 12px;
  min-height: 100%;
  height: auto;
  min-width: 0;
}

.cards-layout-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  min-height: 0;
  min-width: 0;
  flex-shrink: 0;
}

@media (max-width: 900px) {
  .cards-layout-row {
    grid-template-columns: 1fr;
  }
}

/* ═══════════════════════════════════════════════════════════════════════════
   КАРТОЧКИ
   ═══════════════════════════════════════════════════════════════════════════ */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border-card);
  border-radius: var(--radius-md);
  padding: 12px 14px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.04);
  transition: border-color var(--trans-fast);
}

.card:hover {
  border-color: var(--border-hover);
}

.card-headline {
  display: flex;
  align-items: center;
  gap: 7px;
  font-size: 10px;
  font-weight: 800;
  color: var(--text-muted);
  letter-spacing: 0.6px;
  text-transform: uppercase;
}

.card-headline svg {
  stroke: #ffffff;
  flex-shrink: 0;
}

.card-headline.mt-card {
  margin-top: 4px;
  padding-top: 6px;
  border-top: 1px solid var(--border-subtle);
}

.tokens-counter-badge {
  margin-left: auto;
  font-family: var(--font-mono);
  font-size: 9.5px;
  font-weight: 600;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.16);
  padding: 1px 7px;
  border-radius: 12px;
  color: var(--text-white);
}

/* Сетки полей */
.form-group {
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.form-group.flex-1 {
  flex: 1;
}

.form-row-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.form-row-3 {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 8px;
}

.form-row-3 .span-2 {
  grid-column: span 2;
}

.form-group label {
  font-size: 9px;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

/* Инпуты */
input[type="text"],
input[type="password"],
input[type="number"],
textarea,
select {
  background-color: var(--bg-input);
  border: 1px solid var(--border-card);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-family: inherit;
  font-size: 12px;
  padding: 5px 8px;
  height: 32px;
  outline: none;
  transition: all var(--trans-fast);
}

input:focus,
textarea:focus,
select:focus {
  background-color: var(--bg-input-focus);
  border-color: #ffffff;
  box-shadow: 0 0 0 2px rgba(255, 255, 255, 0.15);
}

input::placeholder,
textarea::placeholder {
  color: var(--text-dim);
}

textarea {
  height: 100px;
  min-height: 70px;
  max-height: 180px;
  resize: vertical;
  line-height: 1.45;
  font-family: var(--font-mono);
  font-size: 11px;
}

/* Чекбоксы */
.checkbox-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 4px 10px;
}

.checkbox-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.checkbox-list.row-checks {
  flex-direction: row;
  flex-wrap: wrap;
  gap: 12px;
}

.check-wrap-single {
  padding-top: 2px;
}

.check-row {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 11.5px;
  font-weight: 500;
  color: var(--text-secondary);
  cursor: pointer;
  user-select: none;
}

.check-row:hover {
  color: var(--text-white);
}

.check-row input[type="checkbox"] {
  appearance: none;
  -webkit-appearance: none;
  width: 14px;
  height: 14px;
  border-radius: 3px;
  background: var(--bg-input);
  border: 1px solid var(--border-card);
  cursor: pointer;
  display: grid;
  place-content: center;
  transition: all var(--trans-fast);
}

.check-row input[type="checkbox"]::before {
  content: "";
  width: 7px;
  height: 7px;
  transform: scale(0);
  background-color: #0a0a0c;
  clip-path: polygon(14% 44%, 0 65%, 50% 100%, 100% 16%, 80% 0%, 43% 62%);
  transition: transform 100ms var(--ease-spring);
}

.check-row input[type="checkbox"]:checked {
  background-color: #ffffff;
  border-color: #ffffff;
  box-shadow: 0 0 6px rgba(255, 255, 255, 0.4);
}

.check-row input[type="checkbox"]:checked::before {
  transform: scale(1);
}

/* Чипсы быстрых вставок */
.chips-bar {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.btn-chip {
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--border-card);
  border-radius: var(--radius-xs);
  color: var(--text-secondary);
  font-size: 10.5px;
  font-weight: 600;
  padding: 3px 8px;
  cursor: pointer;
  transition: all var(--trans-fast);
  display: inline-flex;
  align-items: center;
  gap: 5px;
}

.btn-chip:hover {
  background: rgba(255, 255, 255, 0.12);
  border-color: rgba(255, 255, 255, 0.28);
  color: var(--text-white);
}

/* Метрики в карточках */
.metrics-row-compact {
  display: flex;
  gap: 6px;
}

.metric-chip {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  background: var(--bg-input);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  padding: 7px 4px;
}

.m-val {
  font-family: var(--font-mono);
  font-size: 15px;
  font-weight: 700;
  color: var(--text-white);
  line-height: 1;
}

.m-lbl {
  font-size: 9px;
  color: var(--text-muted);
  font-weight: 600;
  text-transform: uppercase;
}

.text-green  { color: #ffffff !important; }
.text-red    { color: #a1a1aa !important; }
.text-yellow { color: #d4d4d8 !important; }
.text-purple { color: #e4e4e7 !important; }

/* ═══════════════════════════════════════════════════════════════════════════
   КНОПКИ ДЕЙСТВИЙ (МОНОХРОМ)
   ═══════════════════════════════════════════════════════════════════════════ */
.action-footer-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding-top: 2px;
  flex-shrink: 0;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  font-family: var(--font-sans);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.4px;
  cursor: pointer;
  padding: 7px 16px;
  height: 34px;
  transition: background-color 140ms ease, border-color 140ms ease, box-shadow 140ms ease, opacity 140ms ease;
  user-select: none;
}

.btn:disabled {
  opacity: 0.35;
  cursor: not-allowed;
  pointer-events: none;
}

/* Основная кнопка — Белая с черным текстом */
.btn-primary {
  background: #ffffff;
  color: #0a0a0c;
  box-shadow: 0 2px 10px rgba(255, 255, 255, 0.15);
}

.btn-primary:hover {
  background: #e4e4e7;
  box-shadow: 0 4px 16px rgba(255, 255, 255, 0.28);
}

/* Кнопка сноса — Черно-серый акцент с белой рамкой */
.btn-danger {
  background: #27272a;
  color: #ffffff;
  border: 1px solid rgba(255, 255, 255, 0.2);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.4);
}

.btn-danger:hover {
  background: #3f3f46;
  border-color: rgba(255, 255, 255, 0.4);
}

.btn-secondary {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--border-card);
  color: var(--text-secondary);
}

.btn-secondary:hover {
  background: rgba(255, 255, 255, 0.1);
  color: var(--text-white);
}

.btn-block {
  width: 100%;
}

/* ═══════════════════════════════════════════════════════════════════════════
   АЛЕРТЫ
   ═══════════════════════════════════════════════════════════════════════════ */
.alert {
  border-radius: var(--radius-sm);
  padding: 9px 12px;
  font-size: 11.5px;
  line-height: 1.45;
  border: 1px solid transparent;
}

.alert-error {
  background: rgba(255, 255, 255, 0.05);
  border-color: rgba(255, 255, 255, 0.2);
  color: #ffffff;
}

.alert-warning {
  background: rgba(255, 255, 255, 0.04);
  border-color: rgba(255, 255, 255, 0.15);
  color: #e4e4e7;
}

/* ═══════════════════════════════════════════════════════════════════════════
   ADMIN PANEL
   ═══════════════════════════════════════════════════════════════════════════ */
.admin-metrics-ribbon {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 8px;
}

.admin-metric-card {
  background: var(--bg-card);
  border: 1px solid var(--border-card);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.admin-metric-card .val {
  font-family: var(--font-mono);
  font-size: 20px;
  font-weight: 800;
  color: var(--text-white);
  line-height: 1;
}

.admin-metric-card .lbl {
  font-size: 9.5px;
  color: var(--text-muted);
  font-weight: 600;
  text-transform: uppercase;
}

.admin-table-card {
  overflow: visible;
  flex-shrink: 0;
}

.headline-tools {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 8px;
}

.search-mini {
  height: 26px !important;
  padding: 2px 8px !important;
  font-size: 11px !important;
  width: 170px !important;
}

.table-wrap {
  overflow-x: auto;
  overflow-y: auto;
  max-height: 360px;
  border-radius: var(--radius-sm);
  background: rgba(0, 0, 0, 0.25);
  border: 1px solid var(--border-card);
  position: relative;
  margin-top: 6px;
}

.discord-table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  font-size: 11.5px;
}

.discord-table thead {
  position: sticky;
  top: 0;
  z-index: 10;
}

.discord-table th {
  position: sticky;
  top: 0;
  z-index: 10;
  padding: 9px 12px;
  text-align: left;
  font-size: 9.5px;
  font-weight: 700;
  letter-spacing: 0.6px;
  color: var(--text-muted);
  text-transform: uppercase;
  background: #141419;
  border-bottom: 1px solid var(--border-subtle);
}

.discord-table td {
  padding: 8px 12px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.04);
  color: var(--text-secondary);
  vertical-align: middle;
  background: transparent;
}

/* Стили блока статистики парсинга ролей */
.roleparser-stats-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin-top: 4px;
}

.rp-stat-card {
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  padding: 9px 10px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 3px;
  min-height: 56px;
}

.rp-stat-val {
  font-family: var(--font-mono);
  font-size: 18px;
  font-weight: 800;
  color: var(--text-white);
  line-height: 1.1;
}

.rp-stat-server {
  font-size: 12px !important;
  font-weight: 700;
  line-height: 1.2;
  word-break: break-word;
  color: #60a5fa !important;
  white-space: normal;
  overflow: hidden;
  text-overflow: ellipsis;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}

.rp-stat-lbl {
  font-size: 9px;
  color: var(--text-muted);
  font-weight: 700;
  letter-spacing: 0.5px;
  text-transform: uppercase;
}

.discord-table tbody tr:hover {
  background: rgba(255, 255, 255, 0.02);
}

.empty-state {
  text-align: center;
  color: var(--text-dim);
  font-size: 11.5px;
  padding: 24px !important;
  font-style: italic;
}

.actions-cell {
  display: flex;
  gap: 5px;
  align-items: center;
}

.role-select-mini {
  height: 26px !important;
  padding: 2px 6px !important;
  font-size: 11px !important;
}

/* ═══════════════════════════════════════════════════════════════════════════
   СВОРАЧИВАЕМЫЙ ТЕРМИНАЛ ЛОГОВ (COLLAPSIBLE CLI DRAWER)
   ═══════════════════════════════════════════════════════════════════════════ */
.console-drawer {
  height: 32px;
  min-height: 32px;
  background: #0d0d10;
  border-top: 1px solid var(--border-subtle);
  display: flex;
  flex-direction: column;
  transition: height 200ms cubic-bezier(0.2, 0.8, 0.2, 1);
  overflow: hidden;
  flex-shrink: 0;
  z-index: 10;
  contain: layout;
}

.console-drawer.expanded {
  height: 155px;
}

.console-topbar {
  height: 32px;
  min-height: 32px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 12px;
  cursor: pointer;
  border-bottom: 1px solid transparent;
  transition: background var(--trans-fast);
  user-select: none;
}

.console-drawer.expanded .console-topbar {
  border-bottom-color: var(--border-subtle);
}

.console-topbar:hover {
  background: rgba(255, 255, 255, 0.03);
}

.console-topbar-left {
  display: flex;
  align-items: center;
  gap: 6px;
}

.console-topbar-left svg {
  stroke: #ffffff;
}

.console-heading {
  font-size: 9px;
  font-weight: 800;
  letter-spacing: 1px;
  color: var(--text-muted);
  text-transform: uppercase;
}

.console-counter-badge {
  font-family: var(--font-mono);
  font-size: 9px;
  font-weight: 700;
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid rgba(255, 255, 255, 0.2);
  color: #ffffff;
  padding: 0 5px;
  border-radius: 10px;
  min-width: 18px;
  text-align: center;
}

.console-topbar-right {
  display: flex;
  align-items: center;
  gap: 6px;
}

.check-console {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: 10px;
  color: var(--text-muted);
  cursor: pointer;
  user-select: none;
}

.check-console input[type="checkbox"] {
  height: 12px;
  width: 12px;
}

.btn-chip-icon {
  padding: 2px 7px !important;
  height: 22px !important;
  font-size: 10px !important;
}

.btn-toggle-drawer {
  min-width: 86px;
}

.console-stream-box {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 5px 12px 6px;
  font-family: var(--font-mono);
  font-size: 10.5px;
  line-height: 1.55;
  contain: content;
}

/* Строки лога (монохром с легкой читаемой подсветкой) */
.log-line {
  padding: 0.5px 0;
}
.log-line.success span:last-child { color: #ffffff; font-weight: 600; }
.log-line.error   span:last-child { color: #f87171; }
.log-line.warning span:last-child { color: #fbbf24; }
.log-line.info    span:last-child { color: var(--text-secondary); }
.log-line.accent  span:last-child { color: #ffffff; }
.log-line.header  span:last-child { color: #e4e4e7; font-weight: 600; }

/* ═══════════════════════════════════════════════════════════════════════════
   TOAST УВЕДОМЛЕНИЯ (МОНОХРОМ)
   ═══════════════════════════════════════════════════════════════════════════ */
#toast-container {
  position: fixed;
  top: 14px;
  right: 14px;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 8px;
  pointer-events: none;
}

.toast {
  display: flex;
  align-items: center;
  gap: 10px;
  background: #18181f;
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: var(--radius-sm);
  padding: 9px 14px;
  min-width: 230px;
  max-width: 360px;
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.75);
  pointer-events: all;
  animation: toastSlideIn 0.3s var(--ease-spring);
  font-size: 12px;
  font-weight: 500;
  color: var(--text-primary);
  position: relative;
  overflow: hidden;
}

.toast::before {
  content: '';
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 3px;
  background: #ffffff;
}

.toast.success::before { background: #ffffff; }
.toast.error::before   { background: #ef4444; }
.toast.info::before    { background: #a1a1aa; }

.toast.success { border-color: rgba(255, 255, 255, 0.25); }
.toast.error   { border-color: rgba(239, 68, 68, 0.35); }

.toast-icon {
  display: flex;
  align-items: center;
  flex-shrink: 0;
}

.toast.success .toast-icon { color: #ffffff; }
.toast.error   .toast-icon { color: #ef4444; }
.toast.info    .toast-icon { color: #a1a1aa; }

@keyframes toastSlideIn {
  from { opacity: 0; transform: translateX(20px) scale(0.96); }
  to   { opacity: 1; transform: translateX(0) scale(1); }
}

.toast-hiding {
  animation: toastSlideOut 0.2s var(--ease-spring) forwards;
}

@keyframes toastSlideOut {
  from { opacity: 1; transform: translateX(0); }
  to   { opacity: 0; transform: translateX(20px); }
}
