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

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

:root {
  /* Surfaces — deep graphite / navy */
  --bg-base: #050B18;
  --bg-raised: #071428;
  --bg-surface: #091A35;
  --bg-surface-2: #0c2142;
  --bg-overlay: #10284d;
  --bg-hover: rgba(24, 169, 255, 0.08);

  /* Brand */
  --accent: #D4B06A;
  --accent-hover: #e6c98b;
  --accent-muted: rgba(212, 176, 106, 0.16);
  --accent-glow: rgba(212, 176, 106, 0.28);
  --blue: #18A9FF;
  --blue-glow: rgba(24, 169, 255, 0.28);

  /* Text */
  --text-primary: #f8fafc;
  --text-secondary: #9aa9c3;
  --text-muted: #9aa9c3;
  --text-disabled: #667085;

  /* 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: #16315A;
  --text: var(--text-primary);
  --muted: var(--text-muted);

  /* Typography scale */
  --text-page-title: 28px;
  --text-section: 22px;
  --text-card-title: 15px;
  --text-body: 15px;
  --text-caption: 13px;

  /* 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: 10px;
  --radius-md: 16px;
  --radius-lg: 24px;
  --radius-xl: 28px;
  --shadow-sm: 0 1px 0 rgba(255, 255, 255, 0.04) inset, 0 1px 2px rgba(0, 0, 0, 0.24);
  --shadow-md: 0 8px 18px rgba(0, 0, 0, 0.22);
  --shadow-lg: 0 16px 32px rgba(0, 0, 0, 0.28);
  --shadow-glow: none;
}

:root[data-theme="light"] {
  --bg-base: #f8fafc;
  --bg-raised: #ffffff;
  --bg-surface: #ffffff;
  --bg-surface-2: #eef4ff;
  --bg-overlay: #eef4ff;
  --bg-hover: #eef4ff;

  --accent: #2563eb;
  --accent-hover: #3b82f6;
  --accent-muted: rgba(37, 99, 235, 0.1);
  --accent-glow: rgba(37, 99, 235, 0.16);
  --blue: #2563eb;
  --blue-glow: rgba(37, 99, 235, 0.16);

  --text-primary: #0f172a;
  --text-secondary: #475569;
  --text-muted: #475569;
  --text-disabled: #64748b;

  --border: #d8e1ec;
  --success: #157347;
  --success-bg: #eef8f3;
  --warning: #92610a;
  --warning-bg: #fbf6ea;
  --danger: #b42318;
  --danger-bg: #fef3f2;
  --info: #2563eb;
  --info-bg: #eef4ff;
  --shadow-sm: 0 1px 2px rgba(17, 24, 39, 0.04);
  --shadow-md: 0 8px 20px rgba(17, 24, 39, 0.06);
  --shadow-lg: 0 16px 32px rgba(17, 24, 39, 0.08);
  --shadow-glow: none;
}

/* ─── Base ─── */
body {
  font-family: Rubik, system-ui, -apple-system, sans-serif;
  font-weight: 400;
  background:
    radial-gradient(1100px 640px at -8% -18%, rgba(77, 140, 255, 0.16), transparent 58%),
    radial-gradient(900px 520px at 108% -8%, rgba(212, 176, 106, 0.08), transparent 52%),
    radial-gradient(800px 480px at 50% 120%, rgba(18, 27, 45, 0.85), transparent 60%),
    var(--bg-base);
  color: var(--text-primary);
  font-size: var(--text-body);
  line-height: 1.5;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

html[data-theme="light"] body {
  background:
    radial-gradient(980px 560px at 0% -12%, rgba(55, 125, 255, 0.12), transparent 60%),
    radial-gradient(820px 480px at 100% 0%, rgba(55, 125, 255, 0.08), transparent 55%),
    var(--bg-base);
}

.hidden { display: none !important; }

h1, h2, h3 { font-weight: 700; }
h1 { text-align: center; font-size: 36px; letter-spacing: -0.03em; }

.subtitle {
  text-align: center;
  color: var(--text-muted);
  font-weight: 500;
  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: grid;
  grid-template-columns: minmax(0, 1.15fr) minmax(320px, 0.85fr);
  align-items: stretch;
  padding: 0;
  position: relative;
  background: var(--bg-base);
}

.login-card {
  width: 100%;
  max-width: 460px;
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.28);
  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: 240px;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  background: linear-gradient(180deg, rgba(18, 27, 45, 0.96) 0%, #070b14 100%);
  border-right: 1px solid var(--border);
  box-shadow: inset -1px 0 0 rgba(122, 180, 255, 0.08);
  padding: 28px 14px 16px;
}

.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-group-label-toggle { cursor: pointer; display: flex; align-items: center; gap: 6px; user-select: none; }
.nav-group-label-toggle:hover { color: var(--accent); }
.sidebar-caret { display: inline-block; width: 10px; font-size: 10px; }

.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;
  height: 18px;
  text-align: center;
  opacity: 0.8;
  flex-shrink: 0;
  display: inline-flex;
}
.nav-item-icon svg {
  width: 18px;
  height: 18px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.6;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.nav-item {
  transition: background 180ms ease, color 180ms ease, transform 180ms ease, box-shadow 180ms ease;
}

.nav-item:hover {
  background: rgba(77, 140, 255, 0.08);
  color: var(--text-primary);
  transform: translateX(3px);
}

.nav-item.active {
  background: linear-gradient(90deg, rgba(212, 176, 106, 0.16), rgba(77, 140, 255, 0.1));
  color: var(--text-primary);
  border-color: transparent;
  box-shadow: inset 2px 0 0 var(--accent), 0 8px 24px rgba(77, 140, 255, 0.12);
  padding-left: calc(var(--space-3) - 2px);
}

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

.nav-help {
  margin-left: auto;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  border: 1px solid var(--border);
  color: var(--text-muted);
  font-size: 10px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  cursor: help;
}
.nav-help:hover { border-color: var(--accent); color: var(--accent); }

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

/* ─── Header ─── */
.header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  background: linear-gradient(180deg, rgba(9, 26, 53, 0.92), rgba(5, 11, 24, 0.78));
  backdrop-filter: blur(18px);
  border-bottom: 1px solid var(--border);
  box-shadow: 0 1px 0 rgba(24, 169, 255, 0.16);
  padding: 16px var(--space-6);
  min-height: 72px;
}

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

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

/* ─── Cards ─── */
.card {
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.045), transparent 42%),
    linear-gradient(165deg, var(--bg-surface) 0%, var(--bg-raised) 100%);
  border: 1px solid var(--border);
  border-radius: 24px;
  padding: 20px;
  box-shadow: var(--shadow-sm);
  transition: transform 180ms ease, box-shadow 180ms ease, border-color 180ms ease;
}

.card:hover:not(:focus-within) {
  transform: translateY(-1px);
  border-color: rgba(77, 140, 255, 0.35);
  box-shadow: var(--shadow-md);
}

.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: 12px;
  padding: 0;
  background: transparent;
  border: none;
  font-size: 13px;
  color: var(--text-secondary);
  margin-bottom: var(--space-4);
}

.tool-metrics-bar strong {
  color: var(--text-primary);
  font-weight: 600;
  font-size: 28px;
  letter-spacing: -0.04em;
  font-variant-numeric: tabular-nums;
  margin-left: 8px;
  line-height: 1;
}

/* ─── Employee page header ─── */
.employee-page-header {
  display: flex;
  gap: var(--space-4);
  align-items: center;
  margin-bottom: var(--space-5);
  padding: 28px;
  background:
    radial-gradient(420px 180px at 12% 0%, rgba(212, 176, 106, 0.16), transparent 70%),
    linear-gradient(180deg, var(--bg-surface), var(--bg-raised));
  border: 1px solid var(--border);
  border-radius: 24px;
  box-shadow: var(--shadow-md);
}

.employee-page-header .avatar {
  width: 84px;
  height: 84px;
  font-size: 2rem;
  border-radius: 50%;
  background: linear-gradient(160deg, var(--bg-overlay), var(--bg-raised));
  border: 2px solid rgba(212, 176, 106, 0.55);
  box-shadow: 0 8px 18px rgba(0, 0, 0, 0.18);
  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;
}

.btn-back {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  color: var(--text-secondary);
  border-radius: 50%;
  padding: 0;
  font-size: 16px;
  cursor: pointer;
  transition: all 0.15s ease;
  flex-shrink: 0;
}
.btn-back:hover {
  background: var(--accent-muted);
  border-color: var(--accent);
  color: var(--accent);
  transform: translateX(-2px);
}

/* ─── Tab groups ─── */
.tab-groups {
  display: flex;
  flex-direction: column;
  gap: 28px;
  margin-bottom: 32px;
}

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

.tab-group-row {
  display: grid;
  grid-template-columns: repeat(2, max-content);
  gap: 16px;
  padding: 0;
  background: transparent;
  border: none;
  border-radius: 0;
  width: fit-content;
  max-width: 100%;
}

.tab {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 14px;
  border-radius: 12px;
  background: transparent;
  border: 1px solid transparent;
  color: var(--text-secondary);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: background 180ms ease, color 180ms ease, box-shadow 180ms ease, transform 180ms ease;
}

.tab:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
  border-color: transparent;
}

.tab.active {
  background: linear-gradient(180deg, var(--bg-overlay), var(--bg-surface));
  color: var(--text-primary);
  border-color: rgba(212, 176, 106, 0.35);
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.22), inset 0 1px 0 rgba(255, 255, 255, 0.08);
}

.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-subnav { display: flex; gap: 8px; border-bottom: 1px solid var(--border); padding-bottom: 8px; }
.tab-sub {
  background: transparent;
  border: none;
  color: var(--text-secondary);
  padding: 6px 12px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: 13px;
}
.tab-sub.active { background: var(--accent-muted); color: var(--accent); font-weight: 600; }
.tab-sub:hover:not(.active) { background: var(--bg-hover); }

.tab.soon {
  opacity: 0.45;
}

/* ─── Buttons ─── */
button {
  cursor: pointer;
  font: inherit;
  background: linear-gradient(180deg, #e6c98b 0%, #d4b06a 48%, #c89a3e 100%);
  color: #162032;
  font-weight: 600;
  border: 1px solid rgba(230, 201, 139, 0.7);
  border-radius: 16px;
  padding: 10px 18px;
  box-shadow: 0 3px 10px rgba(0, 0, 0, 0.18), 0 1px 0 rgba(255, 255, 255, 0.28) inset;
  transition: background 120ms ease, transform 120ms ease, box-shadow 120ms ease, border-color 120ms ease;
}

button:hover:not(:disabled) {
  filter: brightness(1.05);
  transform: translateY(-1px);
  box-shadow: 0 3px 10px rgba(0, 0, 0, 0.18), 0 1px 0 rgba(255, 255, 255, 0.3) inset;
}

button:active:not(:disabled) {
  transform: translateY(0);
  filter: none;
}

button.secondary {
  background: linear-gradient(180deg, #12264a, #0d1d3a);
  color: #f8fafc;
  border: 1px solid #173b73;
  box-shadow: 0 3px 10px rgba(0, 0, 0, 0.18);
}

button.secondary:hover:not(:disabled) {
  background: linear-gradient(180deg, #163056, #12264a);
  border-color: #173b73;
  box-shadow: 0 3px 10px rgba(0, 0, 0, 0.18);
  transform: translateY(-1px);
  filter: brightness(1.05);
}

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

button.btn-destructive,
button.secondary.btn-destructive {
  color: #fecaca !important;
  border-color: rgba(180, 35, 24, 0.45) !important;
  background: linear-gradient(180deg, #6b2430, #4a1520) !important;
}

button.btn-destructive:hover:not(:disabled),
button.secondary.btn-destructive:hover:not(:disabled) {
  background: linear-gradient(180deg, #7a2c3a, #5a1c28) !important;
  border-color: rgba(248, 113, 113, 0.45) !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: 14px !important;
  color: var(--text-primary) !important;
  padding: 12px 14px !important;
  font-size: 15px !important;
  box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.28);
  transition: border-color 180ms ease, box-shadow 180ms ease;
}

input:focus,
select:focus,
textarea:focus {
  outline: none;
  border-color: var(--blue) !important;
  box-shadow: inset 0 2px 0 var(--accent), 0 0 0 4px var(--blue-glow);
}

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(--accent-muted);
  color: var(--accent);
  border-color: rgba(212, 176, 106, 0.4);
}

.badge-red {
  background: rgba(180, 35, 24, 0.14);
  color: #f0a8a4;
  border-color: rgba(180, 35, 24, 0.35);
}

.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 {
  position: sticky;
  top: 0;
  z-index: 1;
  font-size: 13px;
  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 transparent;
  background: var(--bg-raised);
  text-align: left;
  box-shadow: inset 0 -1px 0 rgba(34, 50, 74, 0.7);
}

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);
}

.employee-folder-group { margin-bottom: 16px; }
.employee-folder-header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 16px;
  cursor: pointer;
  border-radius: var(--radius-md);
  user-select: none;
  background: linear-gradient(165deg, var(--bg-surface) 0%, var(--bg-raised) 100%);
  border: 1px solid var(--border);
  margin-bottom: 8px;
  transition: border-color 0.15s;
}
.employee-folder-header:hover { border-color: rgba(201, 169, 98, 0.25); }
.employee-folder-caret { color: var(--accent); width: 12px; display: inline-block; }
.employee-folder-icon { opacity: 0.85; }
.employee-folder-count {
  font-size: var(--text-caption);
  color: var(--text-muted);
  background: var(--bg-hover);
  border-radius: 999px;
  padding: 2px 9px;
  margin-left: auto;
}

.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: radial-gradient(circle at 30% 20%, var(--bg-overlay), var(--bg-raised));
  border: 2px solid rgba(212, 176, 106, 0.45);
  box-shadow: none;
}

/* ─── 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; }
}

/* ─── Split activity feed cards ─── */
.activity-feed-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
  gap: var(--space-4);
  margin-top: var(--space-4);
}

.activity-feed-card {
  background: linear-gradient(165deg, var(--bg-surface) 0%, var(--bg-raised) 100%);
  border: 1px solid var(--border);
  border-left: 3px solid var(--info);
  border-radius: var(--radius-lg);
  padding: var(--space-4) var(--space-5);
  box-shadow: var(--shadow-sm);
}

.activity-feed-card--mass {
  border-left-color: var(--accent);
}

.activity-feed-card__head {
  display: flex;
  align-items: center;
  gap: var(--space-2);
}

.activity-feed-card__icon {
  font-size: 1.05em;
  line-height: 1;
}

.activity-feed-card__head strong {
  font-size: var(--text-card-title);
  color: var(--text-primary);
  flex: 1;
}

.activity-status-pill {
  font-size: var(--text-caption);
  padding: 2px 10px;
  border-radius: 999px;
  font-weight: 600;
  white-space: nowrap;
}

.activity-status-pill--is-live {
  background: var(--success-bg);
  color: var(--success);
}

.activity-status-pill--is-idle {
  background: var(--warning-bg);
  color: var(--warning);
}

.activity-status-pill--is-off {
  background: var(--bg-hover);
  color: var(--text-disabled);
}

.activity-status-pill--is-stopped {
  background: var(--danger-bg);
  color: var(--danger);
}

.activity-summary-strip {
  display: flex;
  gap: var(--space-3);
  margin-bottom: var(--space-3);
  flex-wrap: wrap;
}

.activity-summary-strip__item {
  font-size: var(--text-caption);
  padding: 2px 8px;
  border-radius: 6px;
  background: var(--bg-hover);
  color: var(--text-secondary);
  cursor: pointer;
}

.activity-summary-strip__item.is-active {
  font-weight: 600;
  outline: 1px solid currentColor;
}

.activity-summary-strip__item--ok {
  color: var(--success);
}

.activity-summary-strip__item--skip {
  color: var(--text-muted);
}

.activity-summary-strip__item--error {
  color: var(--danger);
}

.activity-summary-strip__item--all {
  color: var(--text-primary);
}

.activity-feed-card__list {
  max-height: 360px;
  overflow-y: auto;
}

/* ─── Page transition ─── */
@keyframes contentFadeIn {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}

.content.is-entering,
#tab-content.is-entering {
  animation: contentFadeIn 0.32s cubic-bezier(0.2, 0.8, 0.2, 1);
}

/* ─── Dashboard hero ─── */
.dashboard-hero {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: var(--space-5);
}

.dashboard-hero-greeting {
  font-size: 1.125rem;
  font-weight: 600;
  color: var(--text-primary);
}

.dashboard-hero-date {
  font-size: var(--text-caption);
  color: var(--text-muted);
  text-transform: capitalize;
}

.stat-card-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border-radius: var(--radius-md);
  background: var(--accent-muted);
  font-size: 18px;
  margin-bottom: var(--space-3);
}

/* ─── Visual corrections ─── */
html { scrollbar-color: #22324a transparent; }
* { scrollbar-width: thin; }
*::-webkit-scrollbar { width: 8px; height: 8px; }
*::-webkit-scrollbar-thumb { background: #22324a; border-radius: 999px; }
*::-webkit-scrollbar-track { background: transparent; }

html[data-theme="light"] body {
  background:
    radial-gradient(900px 420px at 0% -10%, rgba(37, 99, 235, 0.06), transparent 60%),
    #f7f9fc;
}
html[data-theme="light"] .sidebar {
  background: #ffffff;
  border-right: 1px solid #d7e3f5;
  box-shadow: none;
}
html[data-theme="light"] .header {
  background: rgba(255, 255, 255, 0.92);
  box-shadow: inset 0 -1px 0 #d7e3f5;
}
html[data-theme="light"] .card,
html[data-theme="light"] .employee-row,
html[data-theme="light"] .employee-folder-header,
html[data-theme="light"] .stat-card,
html[data-theme="light"] .login-card {
  background: #ffffff;
  border-color: #d7e3f5;
  box-shadow: 0 1px 2px rgba(17, 24, 39, 0.04);
}
html[data-theme="light"] .nav-item:hover {
  background: #e8f0ff;
  transform: translateX(3px);
  box-shadow: inset 2px 0 0 #2563eb;
}
html[data-theme="light"] .nav-item.active {
  background: linear-gradient(90deg, #e8f0ff, #ffffff);
  color: #111827;
  box-shadow: inset 2px 0 0 #2563eb;
}
html[data-theme="light"] button:not(.secondary):not(.help-chat-close):not(.btn-back) {
  background: linear-gradient(180deg, #3b82f6, #2563eb);
  color: #ffffff;
  border-color: #2563eb;
  box-shadow: none;
}
html[data-theme="light"] button:not(.secondary):not(.help-chat-close):not(.btn-back):hover:not(:disabled) {
  background: linear-gradient(180deg, #60a5fa, #3b82f6);
  box-shadow: none;
  filter: none;
}
html[data-theme="light"] button.secondary {
  background: #ffffff;
  color: #111827;
  border: 1px solid #2563eb;
  box-shadow: none;
}
html[data-theme="light"] button.secondary:hover:not(:disabled) {
  background: #e8f0ff;
  border-color: #2563eb;
  box-shadow: none;
  transform: none;
}
html[data-theme="light"] .tab-group-row { background: #eef4ff; }
html[data-theme="light"] .badge-red { color: #b42318; }
html[data-theme="light"] * { scrollbar-color: #d7e3f5 transparent; }
html[data-theme="light"] *::-webkit-scrollbar-thumb { background: #d7e3f5; }

.employee-row {
  align-items: center;
  overflow: visible;
  background: var(--bg-raised);
}
.employee-row:hover {
  transform: translateY(-1px);
  box-shadow: var(--shadow-md);
}
.employee-row .avatar {
  width: 48px;
  height: 48px;
  box-shadow: none;
}
.employee-row strong {
  display: inline;
  font-weight: 600;
  line-height: 1.2;
  vertical-align: middle;
}
.employee-row .badge {
  display: inline-flex;
  align-items: center;
  height: 20px;
  vertical-align: middle;
  margin-left: 8px;
}
.tg-account-card strong {
  font-weight: 650;
  color: var(--text-primary);
  letter-spacing: -0.015em;
}
.tg-account-card-status .badge {
  font-size: 11px;
  padding: 2px 8px;
  line-height: 1.2;
}
.tg-account-card,
.employee-folder-group,
.stats {
  overflow: visible;
}
.tg-account-card:hover {
  transform: translateY(-1px);
  border-color: rgba(77, 140, 255, 0.28);
  box-shadow: var(--shadow-md);
}
.tg-account-card-top { align-items: center; }
.tg-account-card-top .avatar {
  width: 56px !important;
  height: 56px !important;
  font-size: 20px !important;
}
.tg-account-card-status .badge { margin-left: 0; }
.activity-feed-card {
  border-radius: 24px;
}
.activity-status-pill--is-live {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.activity-status-pill--is-live::before {
  content: '';
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--success);
  box-shadow: 0 0 0 0 rgba(52, 211, 153, 0.6);
  animation: livePulse 1.6s ease-out infinite;
}
@keyframes livePulse {
  0% { box-shadow: 0 0 0 0 rgba(52, 211, 153, 0.55); }
  100% { box-shadow: 0 0 0 8px rgba(52, 211, 153, 0); }
}
.activity-summary-strip__item {
  border-radius: 999px;
  padding: 6px 10px;
  border: 1px solid var(--border);
}
.card.muted {
  text-align: center;
  padding: 40px 24px;
  border-style: dashed;
  background: transparent;
}
.card.muted::before {
  content: '';
  display: block;
  width: 42px;
  height: 42px;
  margin: 0 auto 12px;
  border-radius: 14px;
  border: 1px solid var(--border);
  background: radial-gradient(circle at 50% 35%, var(--accent-muted), transparent 72%);
}
#profile-edit-modal .card:hover,
#profile-bulk-modal .card:hover,
#employees-move-menu .card:hover,
#tg-import-modal .card:hover,
.stories-modal:hover,
.login-card:hover {
  transform: none;
}

.nav-item:hover {
  background: rgba(77, 140, 255, 0.08);
  color: var(--text-primary);
  transform: translateX(3px);
  box-shadow: inset 2px 0 0 rgba(77, 140, 255, 0.7);
  transition: background 120ms ease, transform 120ms ease, box-shadow 120ms ease;
}
.nav-item.active {
  background: linear-gradient(90deg, rgba(37, 99, 235, 0.22), rgba(18, 27, 45, 0.2));
  box-shadow: inset 2px 0 0 #4d8cff, inset 0 0 0 1px rgba(77, 140, 255, 0.12);
}

.stat-card {
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.05), transparent 36%),
    var(--bg-surface);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
}
html[data-theme="light"] .stat-card {
  background: linear-gradient(180deg, #ffffff, #f7f9fc 140%);
}

.company-process-banner {
  margin-bottom: 12px;
  padding: 12px 14px;
  border-radius: 16px;
  background: #10261f;
  border: 1px solid rgba(52, 211, 153, 0.28);
}
.company-process-banner__title {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: #b7ebc9;
  font-weight: 600;
}
.company-process-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #34d399;
}
html[data-theme="light"] .company-process-banner {
  background: #f3faf6;
  border-color: #b7e4c7;
}
html[data-theme="light"] .company-process-banner__title { color: #157347; }

div.toggle {
  display: inline-flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 2px 6px;
  min-height: 36px;
  max-width: 100%;
  padding: 3px;
  border: 1px solid #173b73;
  border-radius: 999px;
  background: #071120;
  box-sizing: border-box;
  vertical-align: middle;
}
div.toggle > strong {
  display: inline-flex;
  align-items: center;
  margin: 0 8px 0 6px;
  padding: 0;
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0;
  color: var(--text-primary);
  white-space: normal;
}
div.toggle .threads-kill-status { display: none; }
div.toggle label {
  position: relative;
  margin: 0;
  height: 28px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0 14px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.04em;
  color: #94a3b8;
  white-space: nowrap;
  cursor: pointer;
  transition: background 220ms cubic-bezier(0.34, 1.3, 0.64, 1), color 160ms ease, box-shadow 220ms ease;
}
div.toggle input {
  position: absolute;
  opacity: 0;
  width: 1px;
  height: 1px;
  margin: 0;
  pointer-events: none;
}
div.toggle label:has(input:checked) {
  background: #2563eb;
  color: #ffffff;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.18), 0 0 10px rgba(37, 99, 235, 0.28);
}
html[data-theme="light"] div.toggle {
  background: #f1f5f9;
  border-color: #d8e1ec;
}
html[data-theme="light"] div.toggle label { color: #64748b; }

label.toggle:has(#theme-toggle) {
  width: 56px !important;
  height: 30px !important;
  border: none !important;
  background: transparent !important;
  padding: 0 !important;
  border-radius: 0 !important;
}
#theme-toggle {
  width: 56px !important;
  height: 30px !important;
  min-width: 56px !important;
}
#theme-toggle::before {
  width: 22px;
  height: 22px;
  line-height: 22px;
  background: #d4b06a;
  color: #111827;
  box-shadow: none;
}
#theme-toggle:checked::before {
  content: '☀';
  background: #2563eb;
  color: #ffffff;
  transform: translateX(26px);
}

.help-chat-head {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 14px 14px 12px;
  border-bottom: 1px solid var(--border);
  font-weight: 600;
}
.help-chat-title::before {
  content: '';
  display: inline-block;
  width: 8px;
  height: 8px;
  margin-right: 8px;
  border-radius: 50%;
  background: #34d399;
  vertical-align: middle;
}
.help-chat-close {
  margin-left: auto;
  width: 28px !important;
  height: 28px !important;
  min-width: 28px;
  padding: 0 !important;
  border-radius: 50% !important;
  background: transparent !important;
  color: var(--text-secondary) !important;
  border: 1px solid var(--border) !important;
  box-shadow: none !important;
}
#help-chat-log {
  flex: 1;
  overflow-y: auto;
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.help-bubble {
  max-width: 82%;
  padding: 10px 12px;
  font-size: 13px;
  line-height: 1.45;
  font-weight: 400;
}
.help-bubble.is-user {
  align-self: flex-end;
  background: #2563eb;
  color: #fff;
  border-radius: 16px 16px 4px 16px;
}
.help-bubble.is-ai {
  align-self: flex-start;
  background: var(--bg-surface-2);
  color: var(--text-primary);
  border: 1px solid var(--border);
  border-radius: 16px 16px 16px 4px;
}
.help-chat-compose {
  display: flex;
  gap: 8px;
  align-items: center;
  padding: 12px;
  border-top: 1px solid var(--border);
}
.help-chat-compose input { margin: 0 !important; min-height: 46px; border-radius: 16px !important; }
.help-chat-send {
  width: 42px !important;
  height: 42px !important;
  min-width: 42px;
  border-radius: 50% !important;
  padding: 0 !important;
  background: #2563eb !important;
  color: #fff !important;
  border: none !important;
  box-shadow: none !important;
}
#help-chat-panel {
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.28) !important;
}
html[data-theme="light"] #help-chat-panel {
  background: #ffffff !important;
  border-color: #d7e3f5 !important;
  box-shadow: 0 16px 40px rgba(17, 24, 39, 0.08) !important;
}
#help-chat-fab { box-shadow: 0 8px 18px rgba(0, 0, 0, 0.18) !important; }
html[data-theme="light"] #help-chat-fab {
  background: linear-gradient(180deg, #3b82f6, #2563eb) !important;
  color: #fff !important;
}

strong, h1, h2, h3, .page-header-title, .sidebar-brand-title { font-weight: 650; }
body, .muted, p { font-weight: 400; }
.nav-item, button, label, .badge { font-weight: 500; }
.card, .nav-item, button, .employee-row, .stat-card { transition-duration: 120ms; }
.content.is-entering, #tab-content.is-entering { animation-duration: 200ms; }

label.toggle:has(#theme-toggle) {
  position: relative !important;
  width: 56px !important;
  height: 30px !important;
  font-size: 0 !important;
  display: inline-flex !important;
}
#theme-toggle {
  appearance: none !important;
  position: relative;
  width: 56px !important;
  height: 30px !important;
  min-width: 56px !important;
  margin: 0 !important;
  padding: 0 !important;
  border-radius: 999px !important;
  border: 1px solid #22324a !important;
  background: #0b1220 !important;
  box-shadow: none !important;
  transition: background 220ms ease, border-color 220ms ease !important;
}
#theme-toggle::before {
  content: '☾';
  position: absolute;
  top: 3px;
  left: 3px;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: #d4b06a;
  color: #111827;
  font-size: 11px;
  line-height: 22px;
  text-align: center;
  box-shadow: none;
  transition: transform 220ms ease, background 220ms ease;
}
#theme-toggle:checked {
  background: #f7f9fc !important;
  border-color: #d7e3f5 !important;
}
#theme-toggle:checked::before {
  content: '☀';
  background: #2563eb;
  color: #fff;
  transform: translateX(26px);
}
#theme-toggle:checked::after { content: none !important; }

#help-chat-fab {
  width: 56px !important;
  height: 56px !important;
  right: 28px !important;
  bottom: 28px !important;
}
#help-chat-panel {
  width: 380px !important;
  height: 520px !important;
  max-height: min(520px, calc(100vh - 120px)) !important;
  right: 28px !important;
  bottom: 100px !important;
  border-radius: 24px !important;
  animation: helpChatIn 200ms ease;
}
@keyframes helpChatIn {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: none; }
}

.sidebar-foot {
  margin-top: auto;
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding-top: 16px;
}
.sidebar-foot .nav-group { margin-bottom: 0; }
.sidebar-support {
  display: flex;
  align-items: center;
  min-height: 40px;
  padding: 8px 12px;
  border-radius: 10px;
  color: var(--text-secondary);
  text-decoration: none;
  font-size: 15px;
  font-weight: 500;
}
.sidebar-support:hover { background: var(--bg-hover); color: var(--text-primary); }
.sidebar-logout {
  width: 100%;
  margin-top: 8px;
  background: #0b1c37 !important;
  color: #f8fafc !important;
  border: 1px solid #173b73 !important;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.2) !important;
}
.sidebar-logout:hover:not(:disabled) {
  background: #13305a !important;
  filter: none !important;
  transform: none !important;
}

button.tab,
button.tab:hover,
button.tab:active {
  background: transparent !important;
  color: var(--text-secondary) !important;
  border: 1px solid transparent !important;
  box-shadow: none !important;
  transform: none !important;
  filter: none !important;
  border-radius: 16px !important;
  font-weight: 500 !important;
}
button.tab:hover { background: var(--bg-hover) !important; color: var(--text-primary) !important; }
button.tab.active {
  background: var(--bg-overlay) !important;
  color: var(--text-primary) !important;
  border-color: rgba(77, 140, 255, 0.35) !important;
}

.employee-folder-header { min-height: 48px; }
.employee-folder-name {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.employee-folder-count { margin-left: 0; flex-shrink: 0; }
.employee-folder-actions {
  width: 32px;
  margin-left: auto;
  display: flex;
  justify-content: flex-end;
  opacity: 0;
  flex-shrink: 0;
}
.employee-folder-header:hover .employee-folder-actions,
.employee-folder-header:focus-within .employee-folder-actions { opacity: 1; }
.folder-icon-btn {
  width: 28px !important;
  height: 28px !important;
  min-width: 28px;
  padding: 0 !important;
  border-radius: 8px !important;
  background: transparent !important;
  color: var(--text-secondary) !important;
  border: 1px solid var(--border) !important;
  box-shadow: none !important;
  transform: none !important;
  filter: none !important;
}
.employee-folder-rename {
  flex: 1;
  min-width: 0;
  width: auto !important;
  height: 28px !important;
  margin: 0 !important;
  padding: 0 10px !important;
  border-radius: 8px !important;
  border: 1px solid #2563eb !important;
  box-shadow: none !important;
  font-size: 14px !important;
  font-weight: 600;
}

.tg-account-card { height: 100%; min-width: 0; }
.tg-account-card-top { align-items: center; min-width: 0; }
.tg-account-card-top > div { min-width: 0; }
.tg-account-card-top .avatar,
.tg-account-card-top img { align-self: center; flex-shrink: 0; }
.tg-account-card-status { margin-left: auto; flex-shrink: 0; align-self: flex-start; }
.tg-account-meta,
.tg-account-card-top .muted,
.tg-account-card-top > div > div {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  line-height: 20px;
  min-height: 20px;
}
.card:hover:not(:focus-within),
.employee-row:hover,
.tg-account-card:hover,
.stat-card:hover {
  transform: translateY(-1px);
}

html[data-theme="light"] body { background: #f8fafc; }
html[data-theme="light"] .sidebar,
html[data-theme="light"] .card,
html[data-theme="light"] .employee-row,
html[data-theme="light"] .employee-folder-header,
html[data-theme="light"] .header { border-color: #d8e1ec; }
html[data-theme="light"] .nav-item { color: #334155; }
html[data-theme="light"] .nav-item .nav-item-icon { color: #475569; opacity: 1; }
html[data-theme="light"] .nav-item:hover {
  background: #eef4ff;
  color: #1d4ed8;
  transform: translateX(2px);
  box-shadow: none;
}
html[data-theme="light"] .nav-item:hover .nav-item-icon { color: #2563eb; }
html[data-theme="light"] .nav-item.active {
  background: #e8f0ff;
  color: #0f172a;
  box-shadow: inset 2px 0 0 #2563eb;
}
html[data-theme="light"] .nav-item.active .nav-item-icon { color: #2563eb; }
html[data-theme="light"] .sidebar-support { color: #334155; }
html[data-theme="light"] .sidebar-support:hover { background: #eef4ff; color: #1d4ed8; }
html[data-theme="light"] .sidebar-logout {
  background: #ffffff !important;
  color: #0f172a !important;
  border: 1px solid #2563eb !important;
  box-shadow: none !important;
}
html[data-theme="light"] .sidebar-logout:hover:not(:disabled) { background: #eef4ff !important; }
html[data-theme="light"] button.tab.active {
  background: #e8f0ff !important;
  color: #0f172a !important;
  border-color: #2563eb !important;
}
html[data-theme="light"] .tab-group-row { background: transparent; border: none; }
html[data-theme="light"] button:not(.secondary):not(.help-chat-close):not(.btn-back):not(.tab):not(.folder-icon-btn):not(.sidebar-logout) {
  box-shadow: 0 3px 10px rgba(37, 99, 235, 0.2);
}
html[data-theme="light"] button.secondary:not(.sidebar-logout):not(.btn-destructive) {
  background: #ffffff;
  color: #0f172a;
  border: 1px solid #2563eb;
  box-shadow: 0 2px 6px rgba(15, 23, 42, 0.06);
}
html[data-theme="light"] button.secondary:not(.sidebar-logout):not(.btn-destructive):hover:not(:disabled) {
  background: #eef4ff;
  transform: translateY(-1px);
  filter: none;
}
[data-locked-btn], .is-locked {
  opacity: 0.85;
  position: relative;
}

/* ─── Auth split, top bar, account, pricing ─── */
.auth-home {
  position: absolute;
  z-index: 2;
  top: 22px;
  left: 22px;
  color: #f7faff;
  text-decoration: none;
  font-weight: 600;
  font-size: 14px;
}
.auth-brand {
  position: relative;
  overflow: hidden;
  min-height: 100vh;
  background: #050b18;
  display: flex;
  align-items: flex-end;
  padding: 64px;
}
.auth-brand-grid {
  position: absolute;
  inset: 0;
  background-image:
    linear-gradient(rgba(24, 169, 255, 0.08) 1px, transparent 1px),
    linear-gradient(90deg, rgba(24, 169, 255, 0.08) 1px, transparent 1px);
  background-size: 56px 56px;
  mask-image: radial-gradient(circle at 30% 40%, black 20%, transparent 75%);
}
.auth-glow {
  position: absolute;
  width: 420px;
  height: 420px;
  left: 8%;
  top: 18%;
  border-radius: 50%;
  background: rgba(24, 169, 255, 0.28);
  filter: blur(36px);
}
.auth-tile {
  position: absolute;
  width: 72px;
  height: 72px;
  border-radius: 18px;
  border: 1px solid rgba(24, 169, 255, 0.45);
  background: rgba(24, 169, 255, 0.08);
  box-shadow: 0 0 24px rgba(24, 169, 255, 0.25);
}
.auth-tile-a { top: 18%; right: 18%; }
.auth-tile-b { top: 38%; right: 32%; width: 48px; height: 48px; }
.auth-tile-c { bottom: 28%; right: 16%; width: 36px; height: 36px; }
.auth-brand-copy { position: relative; max-width: 460px; }
.auth-brand-copy h1 { text-align: left; color: #f7faff; font-size: 56px; margin: 12px 0; }
.auth-brand-copy p { color: #94a3b8; font-size: 18px; font-weight: 500; }
.auth-mark {
  width: 56px;
  height: 56px;
  border-radius: 16px;
  display: grid;
  place-items: center;
  font-weight: 700;
  color: #041018;
  background: linear-gradient(180deg, #3ec4ff, #18a9ff);
  box-shadow: 0 0 28px rgba(24, 169, 255, 0.35);
}
.auth-panel {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 32px 24px;
  background: #071428;
}
.login-card h2 { text-align: left; margin-bottom: 4px; }
.login-card .subtitle { text-align: left; }
.login-card input {
  height: 50px;
  border-radius: 14px;
  transition: border-color 160ms ease, box-shadow 160ms ease;
}
.login-card input:hover { border-color: rgba(24, 169, 255, 0.45); }
.login-card input:focus {
  outline: none;
  border-color: #18a9ff;
  box-shadow: 0 0 0 3px rgba(24, 169, 255, 0.18);
}
.auth-submit {
  width: 100%;
  height: 52px;
  margin-top: 8px;
  border: none !important;
  color: #041018 !important;
  font-weight: 600 !important;
  background: linear-gradient(180deg, #49c4ff, #1276ff) !important;
  box-shadow: 0 8px 24px rgba(24, 169, 255, 0.28) !important;
}
.auth-submit:hover:not(:disabled) {
  filter: brightness(1.08);
  transform: translateY(-1px) scale(1.01);
}
.auth-forgot { text-align: right; margin: -6px 0 12px; }
.auth-forgot a, .auth-switch a { color: #18a9ff; text-decoration: none; font-weight: 600; }
.auth-or { margin: 18px 0 10px; }
.auth-social { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.auth-agree {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  font-size: 12px;
  font-weight: 400;
  margin: 12px 0;
}
.auth-agree input { width: auto; height: auto; margin-top: 2px; }
.cf-turnstile { margin: 12px 0; }
a.sidebar-brand { display: block; text-decoration: none; color: inherit; cursor: pointer; }
.topbar { display: flex; align-items: center; gap: 10px; margin-left: auto; }
.top-stat {
  min-width: 84px;
  padding: 6px 10px;
  border-radius: 14px;
  border: 1px solid var(--border);
  background: rgba(24, 169, 255, 0.06);
}
.top-stat span { display: block; font-size: 11px; color: var(--text-muted); font-weight: 500; }
.top-stat strong { font-size: 14px; font-weight: 700; }
.top-lang {
  height: 36px;
  width: auto;
  margin: 0;
  border-radius: 999px !important;
  border: 1px solid var(--border) !important;
  background: var(--bg-surface) !important;
  color: var(--text-primary) !important;
  padding: 0 10px !important;
  font: inherit;
  font-weight: 600;
}
.top-theme { margin: 0; }
.profile-menu { position: relative; }
.profile-trigger {
  display: flex;
  align-items: center;
  gap: 8px;
  height: 40px;
  padding: 0 12px 0 6px;
  border-radius: 999px;
  background: var(--bg-surface) !important;
  color: var(--text-primary) !important;
  border: 1px solid var(--border) !important;
  box-shadow: none !important;
}
.profile-avatar {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: #18a9ff;
  color: #041018;
  font-weight: 700;
  font-size: 13px;
}
.profile-dropdown {
  position: fixed;
  right: 16px;
  top: 72px;
  width: 260px;
  z-index: 20000;
  padding: 8px;
  border-radius: 18px;
  border: 1px solid var(--border);
  background: #091a35;
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.35);
  transform-origin: top right;
  opacity: 0;
  transform: scale(0.96);
  pointer-events: none;
  transition: opacity 180ms ease, transform 180ms ease;
}
.profile-dropdown.is-open { opacity: 1; transform: scale(1); pointer-events: auto; }
.profile-dropdown-head { display: flex; gap: 10px; align-items: center; padding: 8px; }
.profile-dropdown-head .profile-avatar { width: 36px; height: 36px; }
.profile-dropdown-head p { font-size: 12px; }
.profile-dropdown-rule { height: 1px; margin: 6px 8px; background: var(--border); }
.profile-dropdown button {
  width: 100%;
  text-align: left;
  background: transparent !important;
  color: var(--text-primary) !important;
  border: none !important;
  box-shadow: none !important;
  border-radius: 12px;
  font-weight: 500;
}
.profile-dropdown button:hover { background: rgba(24, 169, 255, 0.1) !important; transform: none; }
.profile-dropdown button.is-danger { color: #f87171 !important; }
.top-plan-note { display: none; }
html[data-theme="light"] .profile-dropdown { background: #fff; }
html[data-theme="light"] .auth-panel { background: #f4f8fc; }
html[data-theme="light"] .auth-brand { background: #e7f1fb; }
html[data-theme="light"] .auth-home, html[data-theme="light"] .auth-brand-copy h1 { color: #0e1726; }
.account-shell { display: grid; grid-template-columns: 220px minmax(0, 720px); gap: 20px; align-items: start; }
.account-nav { display: flex; flex-direction: column; gap: 6px; }
.account-tab {
  text-align: left;
  background: transparent !important;
  color: var(--text-secondary) !important;
  border: 1px solid transparent !important;
  box-shadow: none !important;
  font-weight: 600;
}
.account-tab.is-active, .account-tab:hover {
  background: rgba(24, 169, 255, 0.1) !important;
  color: var(--text-primary) !important;
  border-color: rgba(24, 169, 255, 0.28) !important;
}
.account-panel { display: flex; flex-direction: column; gap: 16px; }
.account-card { width: 100%; }
.account-card-head, .account-links > div { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.account-meta, .account-fields { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; margin-top: 14px; }
.account-meta span { display: block; color: var(--text-muted); font-size: 12px; font-weight: 500; }
.account-empty { display: grid; justify-items: start; gap: 8px; padding: 8px 0; }
.account-empty-icon {
  width: 44px;
  height: 44px;
  border-radius: 14px;
  display: grid;
  place-items: center;
  background: rgba(24, 169, 255, 0.12);
  color: #18a9ff;
  font-weight: 700;
}
.account-links { display: flex; flex-direction: column; gap: 10px; margin-top: 12px; }
.account-table-wrap { overflow-x: auto; }
.account-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.account-table th, .account-table td { text-align: left; padding: 10px 8px; border-bottom: 1px solid var(--border); }
.device-pill { display: inline-flex; padding: 2px 8px; border-radius: 999px; background: rgba(24, 169, 255, 0.12); color: #18a9ff; font-weight: 600; }
.ip-code { font-family: ui-monospace, monospace; color: #18a9ff; }
.account-switch { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 0; font-weight: 500; }
.account-switch input {
  appearance: none !important;
  width: 44px !important;
  height: 26px !important;
  min-height: 0 !important;
  margin: 0 0 0 auto !important;
  padding: 0 !important;
  border-radius: 999px !important;
  background: #16315a !important;
  position: relative;
  cursor: pointer;
  border: none !important;
  box-shadow: none !important;
}
.account-switch input::after { content: ""; position: absolute; top: 3px; left: 3px; width: 20px; height: 20px; border-radius: 50%; background: #fff; transition: transform 160ms ease; }
.account-switch input:checked { background: #18a9ff; }
.account-switch input:checked::after { transform: translateX(18px); }
.pricing-layout { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.pricing-list { display: flex; flex-direction: column; gap: 10px; }
.pricing-plan {
  text-align: left;
  width: 100%;
  background: #091a35 !important;
  color: inherit !important;
  border: 1px solid #16315a !important;
  box-shadow: none !important;
}
.pricing-plan.is-selected { border-color: #18a9ff !important; box-shadow: 0 0 24px rgba(24, 169, 255, 0.22) !important; }
.pricing-detail {
  border-radius: 24px;
  padding: 22px;
  background: linear-gradient(180deg, rgba(24, 169, 255, 0.16), #091a35 42%);
  border: 1px solid rgba(24, 169, 255, 0.35);
}
.pricing-detail ul { list-style: none; padding: 0; margin: 12px 0; display: flex; flex-direction: column; gap: 8px; }
.pricing-modules { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; margin-top: 16px; }
.pricing-module { border: 1px solid #16315a; border-radius: 18px; padding: 14px; background: #071428; }
.pricing-module strong { display: block; margin: 8px 0 4px; }
.sub-modal { max-width: 980px !important; }
@media (max-width: 960px) {
  .login-wrap, .account-shell, .pricing-layout, .pricing-modules, .account-meta, .account-fields { grid-template-columns: 1fr; }
  .auth-brand { min-height: 280px; padding: 72px 24px 32px; }
  .auth-brand-copy h1 { font-size: 40px; }
  .header { flex-wrap: wrap; }
}



