/**
 * AI STUDIO Admin — Premium design system (single source of truth)
 */

/* ─── Reset & base ─── */
*, *::before, *::after { box-sizing: border-box; margin: 0; }

:root {
  /* Surfaces */
  --bg-base: #07080c;
  --bg-raised: #0f1219;
  --bg-surface: #141a24;
  --bg-surface-2: #1a2230;
  --bg-overlay: #1e2736;
  --bg-hover: rgba(255, 255, 255, 0.04);

  /* Brand accent — warm gold premium */
  --accent: #c9a962;
  --accent-hover: #dbbf7a;
  --accent-muted: rgba(201, 169, 98, 0.14);
  --accent-glow: rgba(201, 169, 98, 0.25);

  /* Text */
  --text-primary: #f2f4f8;
  --text-secondary: #b8c2d4;
  --text-muted: #7d8aa3;
  --text-disabled: #556075;

  /* Semantic */
  --success: #34d399;
  --success-bg: rgba(52, 211, 153, 0.12);
  --warning: #fbbf24;
  --warning-bg: rgba(251, 191, 36, 0.12);
  --danger: #f87171;
  --danger-bg: rgba(248, 113, 113, 0.12);
  --info: #60a5fa;
  --info-bg: rgba(96, 165, 250, 0.12);

  /* Legacy aliases (index.html inline vars) */
  --bg: var(--bg-base);
  --surface: var(--bg-raised);
  --surface2: var(--bg-surface-2);
  --border: rgba(255, 255, 255, 0.08);
  --text: var(--text-primary);
  --muted: var(--text-muted);

  /* Typography scale */
  --text-page-title: 1.5rem;
  --text-section: 1.125rem;
  --text-card-title: 0.9375rem;
  --text-body: 0.875rem;
  --text-caption: 0.75rem;

  /* Spacing */
  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-5: 24px;
  --space-6: 32px;
  --space-7: 48px;

  /* Radius & depth */
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --radius-xl: 20px;
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.35);
  --shadow-md: 0 8px 24px rgba(0, 0, 0, 0.45);
  --shadow-lg: 0 16px 48px rgba(0, 0, 0, 0.55);
  --shadow-glow: 0 0 0 1px var(--accent-glow);
}

/* ─── Base ─── */
body {
  font-family: Inter, system-ui, -apple-system, sans-serif;
  background: radial-gradient(ellipse 120% 80% at 0% -20%, rgba(201, 169, 98, 0.06), transparent 50%),
    var(--bg-base);
  color: var(--text-primary);
  font-size: var(--text-body);
  line-height: 1.5;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

.hidden { display: none !important; }

h1 { text-align: center; font-size: 1.5rem; }

.subtitle {
  text-align: center;
  color: var(--text-muted);
  font-size: var(--text-body);
  margin: var(--space-2) 0 var(--space-5);
}

.layout {
  display: flex;
  min-height: 100vh;
}

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

/* ─── Login ─── */
.login-wrap {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--space-5);
  background: radial-gradient(circle at 50% 0%, rgba(201, 169, 98, 0.08), transparent 45%), var(--bg-base);
}

.login-card {
  width: 100%;
  max-width: 400px;
  box-shadow: var(--shadow-lg);
  border: 1px solid var(--border);
  background: linear-gradient(165deg, var(--bg-surface) 0%, var(--bg-raised) 100%);
}

.logo {
  width: 56px;
  height: 56px;
  border-radius: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 24px;
  margin: 0 auto var(--space-4);
  background: linear-gradient(135deg, var(--accent) 0%, #a88b4a 100%);
  box-shadow: 0 8px 24px var(--accent-glow);
}

/* ─── Sidebar ─── */
.sidebar {
  width: 260px;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  background: linear-gradient(180deg, var(--bg-raised) 0%, var(--bg-base) 100%);
  border-right: 1px solid var(--border);
  padding: var(--space-5) var(--space-3);
}

.sidebar-brand {
  padding: 0 var(--space-3) var(--space-5);
  margin-bottom: var(--space-4);
  border-bottom: 1px solid var(--border);
}

.sidebar-brand-title {
  font-size: 1.125rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  background: linear-gradient(90deg, var(--text-primary), var(--accent));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.sidebar-brand-sub {
  color: var(--text-muted);
  font-size: var(--text-caption);
  font-weight: 400;
  margin-top: var(--space-1);
  display: block;
}

.nav-group {
  margin-bottom: var(--space-4);
}

.nav-group-label {
  font-size: 0.6875rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-disabled);
  padding: var(--space-2) var(--space-3);
  margin-bottom: var(--space-1);
}

.nav-item {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: 10px var(--space-3);
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  font-size: var(--text-body);
  margin-bottom: 2px;
  border: 1px solid transparent;
  text-decoration: none;
  cursor: pointer;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
}

.nav-item-icon {
  width: 18px;
  text-align: center;
  opacity: 0.75;
  flex-shrink: 0;
}

.nav-item:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
}

.nav-item.active {
  background: var(--accent-muted);
  color: var(--accent);
  border-color: rgba(201, 169, 98, 0.25);
  box-shadow: inset 3px 0 0 var(--accent);
  padding-left: calc(var(--space-3) - 3px);
}

.nav-item.active .nav-item-icon {
  opacity: 1;
}

#server-version-bar {
  font-size: 0.625rem !important;
  color: var(--text-disabled) !important;
  border-top: 1px solid var(--border) !important;
}

/* ─── Header ─── */
.header {
  background: rgba(15, 18, 25, 0.85);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
  padding: var(--space-4) var(--space-6);
}

.header h2 {
  font-size: var(--text-page-title);
  font-weight: 600;
  letter-spacing: -0.02em;
}

.content {
  padding: var(--space-6);
  flex: 1;
  overflow-y: auto;
  max-width: 1400px;
}

/* ─── Cards ─── */
.card {
  background: linear-gradient(165deg, var(--bg-surface) 0%, var(--bg-raised) 100%);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: var(--space-5);
  box-shadow: var(--shadow-sm);
}

.card strong:first-child,
.card h3 {
  font-size: var(--text-section);
  font-weight: 600;
  color: var(--text-primary);
  display: block;
  margin-bottom: var(--space-3);
}

/* ─── Page headers (tab desc → page header) ─── */
.page-header {
  margin-bottom: var(--space-5);
  padding-bottom: var(--space-4);
  border-bottom: 1px solid var(--border);
}

.page-header-title {
  font-size: var(--text-section);
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: var(--space-2);
}

.page-header-desc {
  font-size: var(--text-body);
  color: var(--text-muted);
  line-height: 1.55;
  max-width: 720px;
}

.tab-desc {
  background: transparent !important;
  border: none !important;
  border-bottom: 1px solid var(--border) !important;
  border-radius: 0 !important;
  padding: 0 0 var(--space-4) 0 !important;
  margin-bottom: var(--space-5) !important;
}

.tab-desc strong {
  font-size: var(--text-section) !important;
  font-weight: 600 !important;
  color: var(--text-primary) !important;
  margin-bottom: var(--space-2) !important;
}

/* ─── Tool page header ─── */
.tool-page-header {
  margin-bottom: var(--space-5);
}

.tool-page-header .toolbar {
  margin-bottom: var(--space-4);
}

.tool-metrics-bar {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-4);
  padding: var(--space-3) var(--space-4);
  background: var(--bg-surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  font-size: var(--text-caption);
  color: var(--text-secondary);
  margin-bottom: var(--space-4);
}

.tool-metrics-bar strong {
  color: var(--accent);
  font-weight: 600;
}

/* ─── Employee page header ─── */
.employee-page-header {
  display: flex;
  gap: var(--space-4);
  align-items: center;
  margin-bottom: var(--space-5);
  padding: var(--space-5);
  background: linear-gradient(135deg, var(--bg-surface) 0%, var(--bg-surface-2) 100%);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-md);
}

.employee-page-header .avatar {
  width: 72px;
  height: 72px;
  font-size: 1.75rem;
  border-radius: var(--radius-lg);
  background: linear-gradient(135deg, var(--accent-muted), var(--bg-overlay));
  border: 1px solid rgba(201, 169, 98, 0.3);
  color: var(--accent);
}

.employee-page-header h2 {
  font-size: 1.375rem;
  font-weight: 600;
  margin-bottom: var(--space-2);
}

.employee-page-header .btn-destructive {
  margin-left: auto;
}

/* ─── Tab groups ─── */
.tab-groups {
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
  margin-bottom: var(--space-5);
}

.tab-group-label {
  font-size: 0.6875rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-disabled);
  margin-bottom: var(--space-2);
  padding-left: var(--space-1);
}

.tab-group-row {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
}

.tabs {
  border-bottom: none !important;
  padding-bottom: 0 !important;
  margin-bottom: var(--space-5) !important;
}

.tab {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 14px;
  border-radius: var(--radius-sm);
  background: var(--bg-surface-2);
  border: 1px solid var(--border);
  color: var(--text-secondary);
  font-size: var(--text-caption);
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s;
}

.tab-icon {
  font-size: 0.875rem;
  opacity: 0.85;
}

.tab:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
  border-color: rgba(255, 255, 255, 0.12);
}

.tab.active {
  background: var(--accent-muted);
  color: var(--accent);
  border-color: rgba(201, 169, 98, 0.35);
  box-shadow: var(--shadow-glow);
}

.tab.soon {
  opacity: 0.45;
}

/* ─── Buttons ─── */
button {
  cursor: pointer;
  font: inherit;
  background: linear-gradient(180deg, var(--accent) 0%, #b8994f 100%);
  color: #0a0c10;
  font-weight: 600;
  border: 1px solid rgba(201, 169, 98, 0.5);
  border-radius: var(--radius-sm);
  padding: 10px 18px;
  box-shadow: 0 2px 8px var(--accent-glow);
  transition: transform 0.1s, box-shadow 0.15s, background 0.15s;
}

button:hover:not(:disabled) {
  background: linear-gradient(180deg, var(--accent-hover) 0%, var(--accent) 100%);
  transform: translateY(-1px);
  box-shadow: 0 4px 16px var(--accent-glow);
}

button.secondary {
  background: var(--bg-surface-2);
  color: var(--text-primary);
  border: 1px solid var(--border);
  box-shadow: none;
}

button.secondary:hover:not(:disabled) {
  background: var(--bg-overlay);
  border-color: rgba(255, 255, 255, 0.15);
  transform: none;
}

button.btn-sm {
  font-size: var(--text-caption);
  padding: 6px 12px;
}

button.btn-destructive,
button.secondary.btn-destructive {
  color: var(--danger) !important;
  border-color: rgba(248, 113, 113, 0.25) !important;
  background: var(--danger-bg) !important;
}

button.btn-destructive:hover:not(:disabled),
button.secondary.btn-destructive:hover:not(:disabled) {
  background: rgba(248, 113, 113, 0.2) !important;
  border-color: rgba(248, 113, 113, 0.4) !important;
}

button:disabled {
  opacity: 0.45;
  cursor: not-allowed;
  transform: none !important;
}

/* ─── Forms ─── */
label {
  display: block;
  font-size: var(--text-caption);
  font-weight: 500;
  color: var(--text-secondary);
  letter-spacing: 0.02em;
  margin-bottom: 6px;
}

input,
select,
textarea {
  width: 100%;
  margin-bottom: 14px;
  font: inherit;
  background: var(--bg-base) !important;
  border: 1px solid var(--border) !important;
  border-radius: var(--radius-sm) !important;
  color: var(--text-primary) !important;
  padding: 10px 14px !important;
  font-size: var(--text-body) !important;
  transition: border-color 0.15s, box-shadow 0.15s;
}

input:focus,
select:focus,
textarea:focus {
  outline: none;
  border-color: rgba(201, 169, 98, 0.5) !important;
  box-shadow: 0 0 0 3px var(--accent-muted);
}

select {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' fill='%237d8aa3' viewBox='0 0 16 16'%3E%3Cpath d='M4 6l4 4 4-4'/%3E%3C/svg%3E") !important;
  background-repeat: no-repeat !important;
  background-position: right 12px center !important;
  padding-right: 36px !important;
}

input[type='checkbox'] {
  appearance: none;
  width: 18px !important;
  height: 18px !important;
  min-width: 18px;
  padding: 0 !important;
  margin: 0 8px 0 0 !important;
  border: 1px solid var(--border) !important;
  border-radius: 4px !important;
  background: var(--bg-base) !important;
  vertical-align: middle;
  cursor: pointer;
  position: relative;
}

input[type='checkbox']:checked {
  background: var(--accent-muted) !important;
  border-color: var(--accent) !important;
}

input[type='checkbox']:checked::after {
  content: '✓';
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  color: var(--accent);
  font-weight: 700;
}

input[type='range'] {
  appearance: none;
  height: 6px !important;
  padding: 0 !important;
  background: var(--bg-surface-2) !important;
  border: none !important;
  border-radius: 999px !important;
}

input[type='range']::-webkit-slider-thumb {
  appearance: none;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--accent);
  border: 2px solid var(--bg-base);
  box-shadow: 0 2px 8px var(--accent-glow);
  cursor: pointer;
}

/* ─── Badges ─── */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 0.6875rem;
  font-weight: 600;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  border: 1px solid transparent;
  margin-left: 8px;
}

.badge::before {
  content: '';
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
}

.badge-green {
  background: var(--success-bg);
  color: var(--success);
  border-color: rgba(52, 211, 153, 0.25);
}

.badge-blue {
  background: var(--info-bg);
  color: var(--info);
  border-color: rgba(96, 165, 250, 0.25);
}

.badge-yellow {
  background: var(--warning-bg);
  color: var(--warning);
  border-color: rgba(251, 191, 36, 0.25);
}

.badge-red {
  background: var(--danger-bg);
  color: var(--danger);
  border-color: rgba(248, 113, 113, 0.25);
}

.badge-gray {
  background: rgba(156, 163, 175, 0.1);
  color: #9ca3af;
  border-color: rgba(156, 163, 175, 0.2);
}

.error {
  background: var(--danger-bg);
  border: 1px solid rgba(248, 113, 113, 0.25);
  color: var(--danger);
  padding: 10px;
  border-radius: var(--radius-sm);
  font-size: var(--text-caption);
  margin-bottom: 14px;
}

/* ─── Stats / dashboard ─── */
.stats {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: var(--space-4);
  margin-bottom: var(--space-5);
}

.stat-card {
  background: linear-gradient(165deg, var(--bg-surface) 0%, var(--bg-raised) 100%);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: var(--space-5);
  box-shadow: var(--shadow-sm);
  transition: border-color 0.15s, box-shadow 0.15s;
}

.stat-card:hover {
  border-color: rgba(201, 169, 98, 0.2);
  box-shadow: var(--shadow-md);
}

.stat-label {
  font-size: var(--text-caption);
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  margin-bottom: var(--space-2);
}

.stat-value {
  font-size: 2rem;
  font-weight: 700;
  letter-spacing: -0.03em;
  color: var(--text-primary);
  background: linear-gradient(90deg, var(--text-primary), var(--accent));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

/* Premium analytics stat tiles */
.stat-tile-premium {
  background: linear-gradient(165deg, var(--bg-surface) 0%, var(--bg-raised) 100%);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: var(--space-4);
  text-align: center;
}

.stat-tile-value {
  font-size: 1.75rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--accent);
  line-height: 1.2;
}

.stat-tile-label {
  font-size: var(--text-caption);
  color: var(--text-muted);
  margin-top: var(--space-2);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.analytics-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: var(--space-3);
}

.analytics-bar-row {
  display: grid;
  grid-template-columns: 88px 1fr 48px;
  align-items: center;
  gap: var(--space-3);
  margin-bottom: var(--space-2);
  font-size: var(--text-caption);
}

.analytics-bar-label {
  color: var(--text-muted);
  font-family: ui-monospace, monospace;
}

.analytics-bar-track {
  height: 8px;
  background: var(--bg-surface-2);
  border-radius: 999px;
  overflow: hidden;
}

.analytics-bar-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--accent), var(--accent-hover));
  border-radius: 999px;
  min-width: 2px;
}

.analytics-bar-value {
  text-align: right;
  color: var(--text-secondary);
  font-variant-numeric: tabular-nums;
}

.funnel-row {
  display: grid;
  grid-template-columns: 120px 1fr 40px;
  align-items: center;
  gap: var(--space-3);
  margin-bottom: var(--space-2);
  font-size: var(--text-body);
}

.funnel-label {
  color: var(--text-secondary);
}

.funnel-track {
  height: 24px;
  background: var(--bg-surface-2);
  border-radius: var(--radius-sm);
  overflow: hidden;
}

.funnel-fill {
  height: 100%;
  background: linear-gradient(90deg, rgba(201, 169, 98, 0.5), var(--accent));
  border-radius: var(--radius-sm);
  min-width: 4px;
}

.funnel-count {
  text-align: right;
  font-weight: 600;
  color: var(--text-primary);
  font-variant-numeric: tabular-nums;
}

/* ─── Tables ─── */
table,
.data-table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  font-size: var(--text-body);
}

table thead th,
.data-table thead th {
  font-size: var(--text-caption);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  padding: var(--space-3) var(--space-4);
  border-bottom: 1px solid var(--border);
  background: var(--bg-surface-2);
  text-align: left;
}

table tbody tr:nth-child(even) td,
.data-table tbody tr:nth-child(even) td {
  background: rgba(255, 255, 255, 0.015);
}

table tbody tr:hover td,
.data-table tbody tr:hover td {
  background: var(--bg-hover);
}

table td,
.data-table td {
  padding: var(--space-3) var(--space-4);
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
  text-align: left;
}

td.num,
th.num {
  text-align: right;
  font-variant-numeric: tabular-nums;
}

/* ─── Employee list ─── */
.employee-row {
  display: flex;
  align-items: center;
  gap: var(--space-4);
  padding: var(--space-5);
  margin-bottom: var(--space-3);
  cursor: pointer;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  transition: border-color 0.15s, box-shadow 0.15s;
}

.employee-row:hover {
  border-color: rgba(201, 169, 98, 0.35);
  box-shadow: var(--shadow-md);
}

.avatar {
  width: 52px;
  height: 52px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  font-weight: 700;
  flex-shrink: 0;
  background: var(--bg-surface-2);
  border: 1px solid var(--border);
}

/* ─── Telegram account cards ─── */
.tg-account-card {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
  transition: border-color 0.15s, box-shadow 0.15s;
}

.tg-account-card:hover {
  border-color: rgba(201, 169, 98, 0.25);
  box-shadow: var(--shadow-md);
}

.tg-account-card-top {
  display: flex;
  gap: var(--space-3);
  align-items: flex-start;
}

.tg-account-card-status {
  margin-left: auto;
  flex-shrink: 0;
}

.tg-account-meta {
  font-size: var(--text-caption);
  color: var(--text-muted);
  line-height: 1.5;
}

.tg-account-actions {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
  margin-top: var(--space-2);
  padding-top: var(--space-3);
  border-top: 1px solid var(--border);
}

.tg-account-actions-destructive {
  display: flex;
  margin-top: var(--space-2);
  padding-top: var(--space-2);
  border-top: 1px dashed var(--border);
}

/* ─── Live logs ─── */
.live-log-panel,
#pipeline-log,
#nc-live-feed {
  font-family: ui-monospace, 'SF Mono', Menlo, monospace;
  font-size: var(--text-caption);
  background: var(--bg-base);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: var(--space-3);
}

.log-line,
.nc-live-row,
.pipeline-log-row {
  display: grid;
  grid-template-columns: 72px 20px 1fr;
  gap: var(--space-2);
  align-items: start;
  padding: var(--space-2) 0;
  border-bottom: 1px solid rgba(255, 255, 255, 0.04);
  font-size: var(--text-caption);
  line-height: 1.45;
}

.log-line:last-child,
.nc-live-row:last-child,
.pipeline-log-row:last-child {
  border-bottom: none;
}

.log-time {
  color: var(--text-disabled);
  font-variant-numeric: tabular-nums;
}

.log-icon {
  text-align: center;
  font-size: 0.75rem;
}

.log-icon--ok { color: var(--success); }
.log-icon--err { color: var(--danger); }
.log-icon--banned { color: var(--danger); }
.log-icon--skip { color: var(--text-muted); }
.log-icon--info { color: var(--info); }

.log-body {
  color: var(--text-secondary);
  font-family: inherit;
}

.log-body strong {
  color: var(--text-primary);
  font-weight: 600;
}

/* ─── Layout helpers ─── */
.studio-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: var(--space-4);
}

.grid-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--space-5);
}

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

.empty-state h3 {
  color: var(--text-primary);
  margin-bottom: var(--space-2);
  font-size: var(--text-section);
}

.timeline-item {
  padding: var(--space-2) 0;
  border-left: 2px solid var(--accent);
  padding-left: var(--space-3);
  margin-left: 4px;
  font-size: var(--text-caption);
}

.filter-bar {
  display: flex;
  gap: var(--space-2);
  flex-wrap: wrap;
  margin-bottom: var(--space-3);
}

.toolbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: var(--space-5);
}

.muted {
  color: var(--text-muted);
  font-size: var(--text-body);
}

.status-msg {
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  font-size: var(--text-caption);
  margin-bottom: var(--space-3);
}

.chat-item {
  padding: 12px;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  margin-bottom: 6px;
  cursor: pointer;
}

.chat-item:hover,
.chat-item.active {
  background: var(--bg-surface-2);
  border-color: rgba(201, 169, 98, 0.35);
}

.toggle {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  cursor: pointer;
}

/* ─── Telegram messenger UI ─── */
.tg-layout {
  display: grid;
  grid-template-columns: 280px 1fr 360px;
  gap: var(--space-4);
  min-height: 520px;
}

.tg-panel {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.tg-panel-head {
  padding: var(--space-3) 14px;
  border-bottom: 1px solid var(--border);
  font-weight: 600;
}

.tg-panel-body {
  padding: var(--space-3);
  overflow-y: auto;
  flex: 1;
}

.msg-list {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  padding: var(--space-3);
  overflow-y: auto;
  flex: 1;
  min-height: 300px;
  max-height: 480px;
}

.msg {
  max-width: 85%;
  padding: 10px 12px;
  border-radius: var(--radius-md);
  font-size: var(--text-body);
  line-height: 1.4;
}

.msg.in {
  align-self: flex-start;
  background: var(--bg-surface-2);
  border: 1px solid var(--border);
}

.msg.out {
  align-self: flex-end;
  background: rgba(201, 169, 98, 0.15);
  border: 1px solid rgba(201, 169, 98, 0.3);
}

.msg-meta {
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 4px;
}

.msg-date {
  text-align: center;
  color: var(--text-muted);
  font-size: var(--text-caption);
  margin: var(--space-2) 0;
}

.msg-input-row {
  display: flex;
  gap: var(--space-2);
  padding: var(--space-3);
  border-top: 1px solid var(--border);
}

.msg-input-row input {
  margin: 0;
  flex: 1;
}

.tg-messenger {
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  overflow: hidden;
  background: var(--bg-surface);
}

.tg-topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: var(--space-3) var(--space-4);
  border-bottom: 1px solid var(--border);
  background: var(--bg-surface-2);
}

.tg-messenger-grid {
  display: grid;
  grid-template-columns: 260px 1fr 280px;
  min-height: 560px;
  max-height: 72vh;
}

.tg-sidebar {
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.tg-sidebar-section {
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
}

.tg-sidebar-label {
  font-size: 11px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  padding: var(--space-2) 12px 4px;
}

.tg-search {
  margin: var(--space-2) 12px;
  width: calc(100% - 24px);
  font-size: var(--text-caption);
}

.tg-chats-scroll {
  overflow-y: auto;
  flex: 1;
  padding: 0 var(--space-2) var(--space-2);
}

.tg-main {
  display: flex;
  flex-direction: column;
  min-height: 0;
  border-right: 1px solid var(--border);
}

.tg-chat-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: var(--space-3) var(--space-4);
  border-bottom: 1px solid var(--border);
}

.tg-chat-title {
  font-weight: 600;
  font-size: 0.9375rem;
}

.tg-chat-actions {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.tg-icon-btn {
  font-size: var(--text-caption);
  padding: 6px 10px;
}

.tg-messages {
  flex: 1;
  min-height: 320px;
}

.tg-context {
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.ctx-block {
  margin-bottom: 14px;
  font-size: var(--text-caption);
}

.ctx-label {
  font-size: 11px;
  color: var(--text-muted);
  margin-bottom: 4px;
  text-transform: uppercase;
}

.tg-voice-bubble {
  font-family: ui-monospace, monospace;
  letter-spacing: -1px;
}

.tg-transcription {
  font-size: 11px;
  margin-top: 6px;
}

.tg-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.55);
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--space-5);
}

.tg-overlay-panel {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  width: min(640px, 100%);
  max-height: 85vh;
  display: flex;
  flex-direction: column;
}

.tg-overlay-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 14px var(--space-4);
  border-bottom: 1px solid var(--border);
}

.tg-overlay-body {
  padding: var(--space-4);
  overflow-y: auto;
}

.debug-flow { font-size: var(--text-caption); }
.debug-step { background: var(--bg-surface-2); border-radius: var(--radius-md); padding: var(--space-3); }
.debug-arrow { text-align: center; color: var(--text-muted); padding: 4px 0; }

/* ─── Debug grid ─── */
.debug-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: var(--space-3);
}

.debug-item {
  background: var(--bg-surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: var(--space-4);
}

.debug-item strong {
  font-size: var(--text-caption) !important;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-muted) !important;
}

/* ─── Status messages ─── */
.status-msg.info { background: var(--info-bg); color: var(--info); border: 1px solid rgba(96, 165, 250, 0.2); }
.status-msg.error { background: var(--danger-bg); color: var(--danger); border: 1px solid rgba(248, 113, 113, 0.2); }
.status-msg.success { background: var(--success-bg); color: var(--success); border: 1px solid rgba(52, 211, 153, 0.2); }
.status-msg.loading { background: var(--warning-bg); color: var(--warning); border: 1px solid rgba(251, 191, 36, 0.2); }

/* ─── Filter bar ─── */
.filter-bar button.active {
  background: var(--accent-muted);
  color: var(--accent);
  border: 1px solid rgba(201, 169, 98, 0.35);
}

.hint {
  font-size: var(--text-caption);
}

/* Responsive */
@media (max-width: 1100px) {
  .tg-layout { grid-template-columns: 1fr; }
  .tg-messenger-grid { grid-template-columns: 1fr; max-height: none; }
}

@media (max-width: 900px) {
  .layout { flex-direction: column; }
  .sidebar { width: 100%; min-height: auto; }
  .employee-page-header { flex-wrap: wrap; }
  .tab-group-row { gap: var(--space-1); }
  .grid-2 { grid-template-columns: 1fr; }
}
