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

:root {
  --stone-950: #0c0a09;
  --stone-400: #a8a29e;
  --stone-500: #78716c;
  --amber-100: #fef3c7;
  --white-80: rgba(255,255,255,0.8);
  --white-70: rgba(255,255,255,0.7);
  --white-60: rgba(255,255,255,0.6);
  --white-50: rgba(255,255,255,0.5);
  --white-30: rgba(255,255,255,0.3);
  --white-20: rgba(255,255,255,0.2);
  --white-18: rgba(255,255,255,0.18);
  --white-15: rgba(255,255,255,0.15);
  --white-10: rgba(255,255,255,0.1);
  --white-08: rgba(255,255,255,0.08);
  --white-05: rgba(255,255,255,0.05);
  --white-03: rgba(255,255,255,0.03);

  --font-heading: 'Raleway', -apple-system, BlinkMacSystemFont, system-ui, sans-serif;
  --font-mono: 'Zed-Mono-Extended', 'JetBrains Mono', 'SF Mono', 'Fira Code', monospace;

  --accent: #f9a8d4;
  --accent-2: #fdba74;
  --accent-bg: rgba(249, 168, 212, 0.1);
  --accent-glow: rgba(249, 168, 212, 0.15);
  --accent-glow-strong: rgba(249, 168, 212, 0.35);
  --accent-grad: linear-gradient(135deg, #f9a8d4 0%, #fdba74 100%);
  --accent-contrast: #1c1917;

  --page-bg: #0c0a09;
  --dot-color: #171717;
  --text-strong: #ffffff;
  --surface-30: rgba(30, 27, 24, 0.55);
  --surface-40: rgba(20, 18, 16, 0.72);
  --surface-45: rgba(30, 27, 24, 0.65);
  --surface-50: rgba(24, 22, 20, 0.82);
  --surface-85: rgba(12, 10, 9, 0.85);
  --surface-92: rgba(12, 10, 9, 0.92);
  --surface-modal: #1c1917;
  --border-soft: rgba(255, 255, 255, 0.14);
  --border-btn: rgba(255, 255, 255, 0.32);

  --purple: #c4b5fd;
  --purple-bg: rgba(196, 181, 253, 0.08);
  --blue: #93c5fd;
  --blue-bg: rgba(147, 197, 253, 0.08);
  --orange: #fdba74;
  --orange-bg: rgba(253, 186, 116, 0.08);

  --success: #86efac;
  --warning: #fde68a;
  --danger: #fca5a5;
  --success-bg: rgba(134, 239, 172, 0.1);
  --warning-bg: rgba(253, 230, 138, 0.1);
  --danger-bg: rgba(252, 165, 165, 0.1);

  --radius-sm: 8px;
  --radius-md: 10px;
  --radius-lg: 12px;
  --space-sm: 12px;
  --color-success: #86efac;
  --color-warning: #fde68a;
  --color-text-dim: rgba(255,255,255,0.3);

  --ease: cubic-bezier(0.215, 0.61, 0.355, 1);
}

[data-theme="light"] {
  --page-bg: #f4f2ef;
  --dot-color: #ddd9d4;
  --stone-950: #f4f2ef;
  --stone-400: #79716b;
  --stone-500: #57534e;
  --amber-100: #b45309;
  --text-strong: #1c1917;
  --white-80: rgba(28, 25, 23, 0.85);
  --white-70: rgba(28, 25, 23, 0.72);
  --white-60: rgba(28, 25, 23, 0.62);
  --white-50: rgba(28, 25, 23, 0.52);
  --white-30: rgba(28, 25, 23, 0.38);
  --white-20: rgba(28, 25, 23, 0.22);
  --white-18: rgba(28, 25, 23, 0.2);
  --white-15: rgba(28, 25, 23, 0.16);
  --white-10: rgba(28, 25, 23, 0.1);
  --white-08: rgba(28, 25, 23, 0.07);
  --white-05: rgba(28, 25, 23, 0.045);
  --white-03: rgba(28, 25, 23, 0.03);
  --surface-30: #ffffff;
  --surface-40: rgba(255, 255, 255, 0.85);
  --surface-45: #ffffff;
  --surface-50: #ffffff;
  --surface-85: rgba(255, 255, 255, 0.97);
  --surface-92: #ffffff;
  --surface-modal: #ffffff;
  --border-soft: rgba(28, 25, 23, 0.16);
  --border-btn: rgba(28, 25, 23, 0.38);
  --accent: #db2777;
  --accent-2: #ea580c;
  --accent-bg: rgba(219, 39, 119, 0.08);
  --accent-glow: rgba(219, 39, 119, 0.12);
  --accent-glow-strong: rgba(219, 39, 119, 0.25);
  --accent-grad: linear-gradient(135deg, #f472b6 0%, #fb923c 100%);
  --accent-contrast: #ffffff;
  --purple: #7c3aed;
  --blue: #2563eb;
  --orange: #ea580c;
  --success: #15803d;
  --warning: #a16207;
  --danger: #dc2626;
  --color-success: #15803d;
  --color-warning: #a16207;
  --color-text-dim: rgba(28, 25, 23, 0.38);
}

[data-theme="ocean"] {
  --page-bg: #0a111e;
  --dot-color: #15223c;
  --surface-30: rgba(24, 36, 60, 0.55);
  --surface-40: rgba(16, 26, 46, 0.72);
  --surface-45: rgba(24, 36, 60, 0.65);
  --surface-50: rgba(20, 31, 52, 0.82);
  --surface-85: rgba(13, 22, 40, 0.9);
  --surface-92: rgba(13, 22, 40, 0.95);
  --surface-modal: #101a2e;
  --border-soft: rgba(147, 197, 253, 0.16);
  --border-btn: rgba(147, 197, 253, 0.35);
  --accent: #7dd3fc;
  --accent-2: #a5b4fc;
  --accent-bg: rgba(125, 211, 252, 0.1);
  --accent-glow: rgba(125, 211, 252, 0.15);
  --accent-glow-strong: rgba(125, 211, 252, 0.35);
  --accent-grad: linear-gradient(135deg, #7dd3fc 0%, #a5b4fc 100%);
  --accent-contrast: #0a111e;
}

[data-theme="forest"] {
  --page-bg: #0a130d;
  --dot-color: #16241b;
  --surface-30: rgba(22, 36, 26, 0.55);
  --surface-40: rgba(14, 26, 19, 0.72);
  --surface-45: rgba(22, 36, 26, 0.65);
  --surface-50: rgba(18, 30, 22, 0.82);
  --surface-85: rgba(12, 22, 15, 0.9);
  --surface-92: rgba(12, 22, 15, 0.95);
  --surface-modal: #0f1c13;
  --border-soft: rgba(134, 239, 172, 0.15);
  --border-btn: rgba(134, 239, 172, 0.32);
  --accent: #86efac;
  --accent-2: #d9f99d;
  --accent-bg: rgba(134, 239, 172, 0.1);
  --accent-glow: rgba(134, 239, 172, 0.15);
  --accent-glow-strong: rgba(134, 239, 172, 0.35);
  --accent-grad: linear-gradient(135deg, #86efac 0%, #d9f99d 100%);
  --accent-contrast: #0a130d;
}

[data-theme="grape"] {
  --page-bg: #120d1c;
  --dot-color: #221736;
  --surface-30: rgba(31, 22, 48, 0.55);
  --surface-40: rgba(22, 15, 36, 0.72);
  --surface-45: rgba(31, 22, 48, 0.65);
  --surface-50: rgba(26, 18, 40, 0.82);
  --surface-85: rgba(19, 13, 30, 0.9);
  --surface-92: rgba(19, 13, 30, 0.95);
  --surface-modal: #171025;
  --border-soft: rgba(216, 180, 254, 0.16);
  --border-btn: rgba(216, 180, 254, 0.35);
  --accent: #d8b4fe;
  --accent-2: #f0abfc;
  --accent-bg: rgba(216, 180, 254, 0.1);
  --accent-glow: rgba(216, 180, 254, 0.15);
  --accent-glow-strong: rgba(216, 180, 254, 0.35);
  --accent-grad: linear-gradient(135deg, #d8b4fe 0%, #f0abfc 100%);
  --accent-contrast: #120d1c;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html { -webkit-text-size-adjust: 100%; }

body {
  font-family: var(--font-mono);
  font-size: 13px;
  line-height: 1.55;
  color: var(--white-80);
  background-color: var(--page-bg);
  background-image: radial-gradient(var(--dot-color) 1.5px, transparent 1.5px);
  background-size: 16px 16px;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

a { color: inherit; text-decoration: none; }
svg { display: block; flex-shrink: 0; }

::selection { background: var(--white-10); color: var(--text-strong); }
::-webkit-scrollbar { display: none; }
* { scrollbar-width: none; }

:focus-visible {
  outline: none;
  box-shadow: 0 0 0 2px var(--stone-950), 0 0 0 4px var(--accent);
  border-radius: 6px;
}

h1, h2, h3, h4 {
  font-family: var(--font-heading);
  font-weight: 600;
  color: var(--text-strong);
  letter-spacing: -0.3px;
  text-wrap: balance;
}
h1 { font-size: 30px; line-height: 1.15; }
h2 { font-size: 20px; }
h3 { font-size: 16px; }
h4 { font-size: 14px; }

.text-primary { color: var(--text-strong); font-weight: 600; }
.text-secondary { color: var(--white-70); }
.text-tertiary { color: var(--stone-400); font-size: 12px; }
.text-muted { color: var(--white-50); font-size: 11px; }
.text-mono { font-family: var(--font-mono); font-variant-numeric: tabular-nums; }
.text-caption {
  font-size: 10px; text-transform: uppercase; letter-spacing: 0.8px;
  font-weight: 600; color: var(--stone-400);
}

.page-center {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: 24px;
}

.auth-card {
  width: 100%;
  max-width: 380px;
  background: var(--surface-30);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  border: 1px dotted var(--border-soft);
  border-radius: 12px;
  padding: 36px 28px;
  animation: appear-fade 0.5s var(--ease);
}

.auth-card__brand { text-align: center; margin-bottom: 26px; }

.auth-card__brand .shield-logo {
  width: 48px; height: 48px;
  margin: 0 auto 16px;
  background: var(--accent-grad);
  border-radius: 14px;
  display: flex; align-items: center; justify-content: center;
  box-shadow: 0 0 24px var(--accent-glow-strong);
}

.auth-card__brand h1 {
  font-size: 20px; font-weight: 600; color: var(--text-strong);
  font-family: var(--font-heading);
}
.auth-card__brand p { font-size: 12px; color: var(--stone-400); margin-top: 4px; }

.auth-card__footer {
  text-align: center; margin-top: 8px; padding-top: 16px;
  border-top: 1px dotted var(--white-10);
}
.auth-card__footer a {
  font-size: 12px; color: var(--stone-400); font-weight: 500;
  transition: color 0.3s var(--ease);
}
.auth-card__footer a:hover { color: var(--amber-100); }

.auth-divider {
  display: flex; align-items: center; gap: 16px;
  color: var(--white-50); font-size: 10px; text-transform: uppercase;
  letter-spacing: 0.6px; font-weight: 600;
}
.auth-divider::before, .auth-divider::after {
  content: ''; flex: 1; height: 1px; background: var(--white-10);
}
.telegram-login { display: flex; justify-content: center; }

.form { width: 100%; display: flex; flex-direction: column; gap: 14px; }
.form__group { display: flex; flex-direction: column; gap: 5px; }

.form__group label {
  display: flex; align-items: center; gap: 6px;
  font-size: 12px; font-weight: 600; color: var(--stone-400);
  letter-spacing: 0.3px;
}

.form__group input, .form__group select, .form__group textarea {
  width: 100%; padding: 11px 14px;
  background: var(--surface-50);
  border: 1px dotted var(--white-15);
  border-radius: 10px;
  color: var(--white-80); font-size: 13px; font-family: var(--font-mono);
  outline: none;
  transition: border-color 0.3s var(--ease), box-shadow 0.3s var(--ease);
}
.form__group input::placeholder { color: var(--white-30); }
.form__group input:focus, .form__group select:focus, .form__group textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-glow);
}
.form__hint { font-size: 11px; color: var(--white-50); line-height: 1.5; margin-top: 2px; }

.select-wrap { position: relative; }
.select-wrap select { appearance: none; padding-right: 36px; cursor: pointer; }
.select-wrap::after {
  content: ''; position: absolute; right: 14px; top: 50%;
  width: 7px; height: 7px;
  border: 1.5px solid var(--white-50); border-top: none; border-left: none;
  transform: translateY(-65%) rotate(45deg); pointer-events: none;
}

.form__role-preview { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; }
.role-option { cursor: pointer; }
.role-option input { display: none; }

.role-option__card {
  display: flex; flex-direction: column; align-items: center; gap: 6px;
  padding: 14px 10px;
  background: var(--white-03);
  border: 1px dotted var(--border-soft);
  border-radius: 10px;
  font-size: 12px; font-weight: 500;
  color: var(--white-50);
  transition: all 0.3s var(--ease);
  text-align: center;
}
.role-option:hover .role-option__card { border-color: var(--white-30); color: var(--white-80); }
.role-option input:checked + .role-option__card, .role-option--selected .role-option__card {
  border-color: var(--accent);
  background: var(--accent-bg);
  color: var(--accent);
  box-shadow: 0 0 16px var(--accent-glow);
}

.alert {
  display: flex; align-items: center; gap: 8px;
  padding: 10px 14px;
  border-radius: 10px;
  font-size: 12px; font-weight: 500;
  border: 1px dotted var(--border-soft);
  animation: slideDown 0.25s var(--ease);
}
@keyframes slideDown { from { opacity: 0; transform: translateY(-10px); } to { opacity: 1; transform: translateY(0); } }
.alert--error { background: var(--danger-bg); color: var(--danger); }
.alert--success { background: var(--success-bg); color: var(--success); }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 8px 20px;
  border: 1px dashed var(--border-btn);
  border-radius: 999px;
  font-size: 12px; font-weight: 600;
  font-family: var(--font-mono);
  cursor: pointer; text-decoration: none; white-space: nowrap;
  min-height: 36px;
  background: transparent;
  color: var(--white-80);
  transition: all 0.3s var(--ease);
}
.btn:hover { border-color: var(--text-strong); background: var(--white-05); color: var(--text-strong); }
.btn:active { transform: scale(0.96); }

.btn--primary {
  background: var(--accent-grad);
  color: var(--accent-contrast);
  border: none;
  font-weight: 700;
  box-shadow: 0 0 16px var(--accent-glow-strong);
}
.btn--primary:hover { box-shadow: 0 0 24px var(--accent-glow-strong); color: var(--accent-contrast); transform: translateY(-1px); }

.btn--ghost { color: var(--white-60); border-color: var(--border-btn); }
.btn--ghost:hover { color: var(--text-strong); background: var(--white-05); }

.btn--success { background: var(--success-bg); color: var(--success); border-color: transparent; }
.btn--success:hover { opacity: 0.85; color: var(--success); background: var(--success-bg); }
.btn--danger { background: var(--danger-bg); color: var(--danger); border-color: transparent; }
.btn--danger:hover { opacity: 0.85; color: var(--danger); background: var(--danger-bg); }

.btn--icon {
  width: 36px; height: 36px; padding: 0; min-height: auto;
  border-radius: 999px;
  background: transparent; color: var(--white-50);
}
.btn--icon:hover { color: var(--danger); background: var(--danger-bg); }

.btn--full { width: 100%; }
.btn--sm { padding: 5px 14px; font-size: 11px; min-height: 30px; }
.btn--xs { padding: 4px 10px; font-size: 10px; min-height: 26px; }
.btn--back { margin-bottom: 20px; align-self: flex-start; }

.badge {
  display: inline-flex; align-items: center;
  padding: 3px 12px;
  border-radius: 999px;
  font-size: 10px; font-weight: 600;
  border: 1px dotted var(--white-15);
}
.badge--active { background: var(--accent-bg); color: var(--accent); border-color: var(--accent); }
.badge--inactive { background: var(--white-03); color: var(--white-50); }

.toggle-form { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.toggle { position: relative; display: inline-block; width: 44px; height: 24px; flex-shrink: 0; }
.toggle input { display: none; }
.toggle__slider {
  position: absolute; inset: 0;
  background: var(--white-05);
  border: 1px dotted var(--white-20);
  border-radius: 24px;
  cursor: pointer;
  transition: background 0.3s var(--ease);
}
.toggle__slider::before {
  content: ''; position: absolute;
  width: 16px; height: 16px; left: 3px; bottom: 3px;
  background: var(--stone-400);
  border-radius: 50%;
  transition: transform 0.3s var(--ease);
}
.toggle input:checked + .toggle__slider { background: var(--accent-grad); border-color: transparent; }
.toggle input:checked + .toggle__slider::before { transform: translateX(20px); background: var(--accent-contrast); }
.toggle__label { font-size: 12px; color: var(--white-60); font-weight: 500; }

.table-wrap { overflow-x: auto; border-radius: 12px; border: 1px dotted var(--border-soft); }
.table { width: 100%; border-collapse: collapse; font-size: 12px; }
.table th, .table td { padding: 11px 14px; text-align: left; }
.table th {
  font-size: 10px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.6px;
  color: var(--stone-400); background: var(--white-03); border-bottom: 1px dotted var(--white-10);
}
.table td { border-bottom: 1px dotted var(--white-10); vertical-align: middle; }
.table tbody tr:last-child td { border-bottom: none; }
.table tbody tr { transition: background 0.3s var(--ease); }
.table tbody tr:hover { background: var(--white-03); }
.table__id { font-family: var(--font-mono); font-size: 11px; color: var(--stone-400); font-variant-numeric: tabular-nums; }
.table__username { font-weight: 600; color: var(--text-strong); }
.table__date { font-size: 11px; color: var(--stone-400); white-space: nowrap; font-variant-numeric: tabular-nums; }
.table__th-actions { width: 40px; }

.role-badge {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 3px 10px; border-radius: 6px;
  font-size: 11px; font-weight: 600;
  border: 1px dotted var(--white-15);
  white-space: nowrap;
}
.role-badge--creator { background: var(--accent-bg); color: var(--accent); }
.role-badge--admin { background: var(--purple-bg); color: var(--purple); }
.role-badge--agent { background: var(--success-bg); color: var(--success); }
.role-badge--developer { background: var(--orange-bg); color: var(--orange); }
.role-badge--none { background: var(--white-03); color: var(--white-50); }

.maintenance {
  text-align: center; max-width: 440px; width: 100%;
  padding: 48px 24px; margin: auto;
  animation: appear-fade 0.5s var(--ease);
}
.maintenance__icon { margin-bottom: 24px; display: inline-block; }
.maintenance__title {
  font-size: 36px; font-weight: 600; color: var(--text-strong);
  margin-bottom: 10px; line-height: 1.2; font-family: var(--font-heading);
}
.maintenance__text { font-size: 13px; color: var(--white-60); margin-bottom: 32px; line-height: 1.6; }
.maintenance__loader { display: flex; justify-content: center; gap: 10px; margin-bottom: 28px; }
.maintenance__loader span {
  width: 10px; height: 10px; background: var(--accent); border-radius: 50%;
  animation: bounce 1.4s ease-in-out infinite both;
}
.maintenance__loader span:nth-child(1) { animation-delay: -0.32s; }
.maintenance__loader span:nth-child(2) { animation-delay: -0.16s; }
.maintenance__loader span:nth-child(3) { animation-delay: 0s; }
@keyframes bounce { 0%,80%,100% { transform: scale(0); opacity: 0.2; } 40% { transform: scale(1); opacity: 1; } }
.maintenance__login {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 12px 28px;
  background: var(--accent-grad);
  color: var(--accent-contrast); border-radius: 999px; font-weight: 700; font-size: 13px; border: none;
  box-shadow: 0 0 16px var(--accent-glow-strong);
  font-family: var(--font-mono);
  transition: box-shadow 0.3s var(--ease), transform 0.3s var(--ease);
}
.maintenance__login:hover { box-shadow: 0 0 24px var(--accent-glow-strong); transform: translateY(-1px); color: var(--accent-contrast); }

.footer { text-align: center; font-size: 11px; color: var(--white-30); padding: 16px 24px 24px; }
.footer a { color: var(--white-50); font-weight: 500; transition: color 0.3s var(--ease); }
.footer a:hover { color: var(--amber-100); }

.client-page { min-height: 100vh; }

.topbar-client {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 10px 20px;
  background: var(--surface-40);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border-bottom: 1px dotted var(--white-10);
  position: sticky; top: 0; z-index: 50;
}
.topbar-client__brand {
  display: flex; align-items: center; gap: 10px;
  font-weight: 600; color: var(--text-strong); font-size: 15px; font-family: var(--font-heading);
  transition: opacity 0.3s var(--ease);
}
a.topbar-client__brand:hover { opacity: 0.75; }
.topbar-client__right { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; justify-content: flex-end; }

.topbar-link {
  display: inline-flex; align-items: center; gap: 6px;
  color: var(--white-60); font-size: 12px; font-weight: 500;
  padding: 6px 12px;
  border-radius: 999px;
  border: 1px dotted var(--white-15);
  background: transparent;
  font-family: var(--font-mono);
  transition: all 0.3s var(--ease);
}
.topbar-link:hover { color: var(--text-strong); border-color: var(--white-50); background: var(--white-05); }
.topbar-link--admin { border-color: var(--purple); color: var(--purple); }
.topbar-link--admin:hover { border-color: var(--purple); color: var(--text-strong); background: var(--purple-bg); }

.profile-link-back {
  display: inline-flex; align-items: center; gap: 6px;
  color: var(--stone-400); font-size: 12px;
  transition: color 0.3s var(--ease);
}
.profile-link-back:hover { color: var(--text-strong); }

.impersonate select {
  background: var(--white-05); color: var(--white-80);
  border: 1px dotted var(--white-20); border-radius: 999px;
  padding: 6px 12px; font-size: 11px; font-family: var(--font-mono);
  cursor: pointer; outline: none;
}

.profile-pill {
  display: flex; align-items: center; gap: 10px;
  background: var(--white-05);
  border: 1px dotted var(--white-15);
  border-radius: 999px; padding: 3px 6px 3px 3px;
  max-width: 220px; flex-shrink: 0;
}
.profile-pill__avatar {
  width: 32px; height: 32px; flex: 0 0 32px; border-radius: 50%;
  background: var(--accent-grad);
  color: var(--accent-contrast);
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 12px;
  background-size: cover; background-position: center;
}
.profile-pill__avatar--img { text-indent: -9999px; }
.profile-pill__info { display: flex; flex-direction: column; line-height: 1.2; min-width: 0; }
.profile-pill__name {
  font-size: 12px; font-weight: 600; color: var(--text-strong);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.profile-pill__role { font-size: 10px; color: var(--stone-400); }
.profile-pill__logout { color: var(--stone-400); display: inline-flex; padding: 6px; border-radius: 50%; transition: all 0.3s var(--ease); }
.profile-pill__logout:hover { color: var(--danger); background: var(--danger-bg); }

.maint-badge {
  display: inline-flex; align-items: center; gap: 5px;
  font-size: 10px; font-weight: 600;
  color: var(--warning); background: var(--warning-bg);
  border: 1px dotted var(--white-15); border-radius: 999px; padding: 4px 10px;
}
.maint-toggle { margin: 0; }

.maint-dd { position: relative; }
.maint-badge--btn {
  cursor: pointer; font-family: var(--font-mono);
  transition: border-color 0.3s var(--ease), box-shadow 0.3s var(--ease);
}
.maint-badge--btn:hover { border-color: var(--warning); box-shadow: 0 0 12px rgba(253, 230, 138, 0.15); }
.maint-dd__menu {
  position: absolute; top: calc(100% + 8px); right: 0; z-index: 200;
  min-width: 220px; padding: 12px;
  background: var(--surface-92); backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px);
  border: 1px dotted var(--white-15); border-radius: 12px;
  box-shadow: 0 8px 40px rgba(0,0,0,0.6);
  animation: popIn 140ms var(--ease);
}
.maint-dd__menu[hidden] { display: none; }
.maint-dd__title {
  font-size: 10px; text-transform: uppercase; letter-spacing: 0.6px;
  color: var(--warning); font-weight: 600; margin-bottom: 4px;
}
.maint-dd__desc { font-size: 11px; color: var(--stone-400); line-height: 1.5; margin-bottom: 10px; }

.theme-dd__menu { min-width: 190px; padding: 10px; }
.theme-option {
  width: 100%; display: flex; align-items: center; gap: 10px;
  padding: 8px 10px; border-radius: 999px;
  background: transparent; border: 1px solid transparent;
  color: var(--white-70); font-size: 12px; font-weight: 500;
  font-family: var(--font-mono); cursor: pointer; text-align: left;
  transition: all 0.25s var(--ease);
}
.theme-option:hover { color: var(--text-strong); background: var(--white-05); }
.theme-option--active { color: var(--accent); background: var(--accent-bg); border-color: var(--accent); }
.theme-option__dot {
  width: 16px; height: 16px; flex: 0 0 16px; border-radius: 50%;
  border: 1px dotted var(--white-30); box-shadow: inset 0 0 0 1px rgba(0,0,0,0.2);
}

.topbar-bell { background: transparent; cursor: pointer; font-family: var(--font-mono); }
.topbar-bell--off { opacity: 0.4; }

.profile-pill { cursor: pointer; transition: border-color 0.3s var(--ease), background 0.3s var(--ease), transform 0.3s var(--ease); }
.profile-pill:hover { border-color: var(--accent); background: var(--white-08); }
.profile-pill:hover .profile-pill__name { color: var(--accent); }
.profile-pill:focus-visible { box-shadow: 0 0 0 2px var(--stone-950), 0 0 0 4px var(--accent); }

.verified-check { color: var(--purple); font-weight: 700; margin-left: 2px; cursor: help; }
.verified-check--sm { font-size: 10px; }
.verified-badge { color: var(--purple); font-weight: 700; }

.verified-tg { display: inline-flex; align-items: center; vertical-align: -2px; margin-left: 3px; cursor: help; }
.verified-tg svg { display: block; filter: drop-shadow(0 1px 2px rgba(51, 144, 236, 0.45)); }

.celebrity-tag {
  display: inline-flex; align-items: center; gap: 3px;
  font-size: 10px; font-weight: 600;
  color: var(--amber-100); background: rgba(254,243,199,0.08);
  border-radius: 999px; padding: 1px 7px; cursor: help;
}

.client-main { max-width: 820px; margin: 0 auto; padding: 24px; }
.client-main--narrow { max-width: 640px; }
.client-main__head {
  display: flex; align-items: center; gap: 12px; margin-bottom: 24px; flex-wrap: wrap;
}
.client-main__head h1 {
  font-size: 26px; font-weight: 600; color: var(--text-strong);
  margin: 0; flex: 1; font-family: var(--font-heading);
}
.ticket-title { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.empty {
  text-align: center; color: var(--white-50);
  padding: 48px 24px; border: 1px dotted var(--border-soft);
  border-radius: 12px; font-size: 13px; line-height: 1.6;
}

.ticket-list { display: flex; flex-direction: column; gap: 8px; }

.ticket-card {
  display: block;
  background: var(--surface-30);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  border: 1px dotted var(--border-soft);
  border-radius: 12px;
  padding: 18px 22px;
  text-decoration: none; color: inherit;
  transition: border-color 0.3s var(--ease), transform 0.3s var(--ease), box-shadow 0.3s var(--ease);
}
.ticket-card:hover {
  border-color: var(--accent);
  transform: translateY(-2px);
  box-shadow: 0 8px 32px rgba(0,0,0,0.5);
}

.ticket-card__top { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 6px; }
.ticket-card__subject { font-weight: 600; color: var(--text-strong); font-size: 13px; }
.ticket-card__meta {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  font-size: 11px; color: var(--stone-400);
}
.ticket-card__user { font-weight: 500; color: var(--white-60); }

.status-badge {
  display: inline-flex; align-items: center; gap: 4px;
  font-size: 10px; font-weight: 600;
  padding: 3px 10px; border-radius: 999px;
  border: 1px dotted var(--white-15);
  white-space: nowrap;
  text-transform: uppercase; letter-spacing: 0.4px;
}
.status--created { background: var(--white-05); color: var(--white-60); }
.status--waiting_user { background: var(--warning-bg); color: var(--warning); border-color: var(--warning); }
.status--waiting_support { background: var(--blue-bg); color: var(--blue); border-color: var(--blue); }
.status--resolved { background: var(--success-bg); color: var(--success); border-color: var(--success); }
.status--closed { background: var(--danger-bg); color: var(--danger); border-color: var(--danger); }

.chat {
  display: flex; flex-direction: column; gap: 10px;
  background: var(--surface-30);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  border: 1px dotted var(--border-soft);
  border-radius: 12px;
  padding: 20px; max-height: 55vh; overflow-y: auto; margin-bottom: 12px;
}

.chat-locked {
  background: var(--surface-30);
  border: 1px dotted var(--border-soft);
  border-radius: 10px;
  padding: 14px 18px; text-align: center;
  font-size: 12px; color: var(--stone-400); line-height: 1.5;
}

.msg-system {
  text-align: center; font-size: 10px; color: var(--stone-400);
  background: var(--white-05);
  border: 1px dotted var(--border-soft);
  border-radius: 999px; padding: 4px 16px; margin: 4px auto; max-width: 80%;
}

.msg {
  max-width: 80%; padding: 10px 14px; border-radius: 12px;
  animation: appear-fade 0.2s var(--ease);
  border: 1px dotted var(--border-soft);
}
.msg--me { align-self: flex-end; background: var(--accent-bg); border-color: var(--accent); }
.msg--me .msg__head { color: var(--accent); }
.msg--them { align-self: flex-start; background: var(--surface-45); }

.msg__head {
  font-size: 11px; font-weight: 600; color: var(--text-strong); margin-bottom: 3px;
  display: flex; align-items: center; gap: 4px; flex-wrap: wrap;
}
.msg__role { color: var(--stone-400); font-weight: 400; font-size: 10px; }
.msg__body { font-size: 13px; color: var(--white-80); white-space: pre-wrap; word-break: break-word; line-height: 1.5; }
.msg__time { font-size: 10px; color: var(--white-30); margin-top: 5px; text-align: right; font-variant-numeric: tabular-nums; }

.chat-form { display: flex; gap: 8px; margin-bottom: 12px; align-items: flex-end; }
.chat-form input, .chat-form textarea {
  flex: 1; min-width: 0;
  background: var(--surface-50);
  border: 1px dotted var(--white-15);
  border-radius: 999px;
  padding: 11px 16px;
  color: var(--white-80); font-size: 13px; font-family: var(--font-mono);
  outline: none;
  transition: border-color 0.3s var(--ease), box-shadow 0.3s var(--ease);
}
.chat-form textarea {
  resize: none;
  border-radius: 18px;
  min-height: 41px;
  max-height: 160px;
  line-height: 1.5;
  overflow-y: auto;
  display: block;
}
.chat-form input:focus, .chat-form textarea:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-glow); }
.chat-form__attach { border: 1px dotted var(--white-15); flex-shrink: 0; }
.chat-form__attach:hover { color: var(--accent); background: var(--accent-bg); }

.msg__body--image { margin-top: 4px; }
.msg__body--image + .msg__body { margin-top: 4px; }
.msg__image {
  max-width: min(280px, 100%); max-height: 320px;
  border-radius: 10px; cursor: zoom-in; display: block;
  border: 1px dotted var(--white-15);
  transition: opacity 0.3s var(--ease);
}
.msg__image:hover { opacity: 0.85; }

.lightbox { border: none; background: transparent; padding: 0; max-width: none; margin: auto; }
.lightbox::backdrop { background: rgba(0,0,0,0.82); backdrop-filter: blur(4px); }
.lightbox img { max-width: 92vw; max-height: 88vh; border-radius: 12px; display: block; }

.upload-status {
  display: flex; align-items: center; gap: 8px;
  font-size: 11px; color: var(--stone-400);
  min-height: 20px; padding: 0 6px; margin: -2px 0 8px;
}
.upload-status--error { color: var(--danger); }
.upload-status--ok { color: var(--success); }
.spinner {
  width: 12px; height: 12px; flex-shrink: 0;
  border: 2px solid var(--white-20); border-top-color: var(--accent);
  border-radius: 50%; animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.chat-empty { text-align: center; color: var(--stone-400); font-size: 12px; padding: 40px 16px; margin: auto; }
.smsg { display: flex; gap: 8px; max-width: 85%; animation: appear-fade 0.2s var(--ease); }
.smsg--mine { align-self: flex-end; flex-direction: row-reverse; }
.smsg--them { align-self: flex-start; }
.smsg__avatar {
  width: 28px; height: 28px; flex: 0 0 28px; margin-top: 2px;
  border-radius: 50%; background: var(--accent-grad);
  background-size: cover; background-position: center;
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 11px; font-weight: 700; color: var(--accent-contrast);
}
.smsg__bubble {
  min-width: 0; padding: 9px 13px; border-radius: 12px;
  border: 1px dotted var(--border-soft);
  background: var(--surface-45);
}
.smsg--mine .smsg__bubble { background: var(--accent-bg); border-color: var(--accent); }
.smsg__head {
  font-size: 11px; font-weight: 600; color: var(--text-strong); margin-bottom: 3px;
  display: flex; align-items: center; gap: 5px; flex-wrap: wrap;
}
.smsg--mine .smsg__head { color: var(--accent); }
.smsg__head .verified-tg { margin-left: 0; }
.smsg__role { color: var(--stone-400); font-weight: 400; font-size: 10px; }
.smsg__body { font-size: 13px; color: var(--white-80); white-space: pre-wrap; word-break: break-word; line-height: 1.5; }
.smsg__time {
  font-size: 10px; color: var(--white-30); margin-top: 4px;
  display: flex; justify-content: flex-end; align-items: center; gap: 4px;
  font-variant-numeric: tabular-nums;
}
.smsg__reads { display: inline-flex; align-items: center; gap: 2px; }
.smsg__reads-count { font-size: 10px; }

.join-support {
  width: 100%; display: flex; align-items: center; gap: 14px; text-align: left;
  background: var(--surface-30); backdrop-filter: blur(4px); -webkit-backdrop-filter: blur(4px);
  border: 1px dotted var(--border-soft); border-radius: 12px;
  padding: 16px 20px; margin-top: 16px; cursor: pointer;
  color: inherit; font-family: var(--font-mono);
  transition: border-color 0.3s var(--ease), transform 0.3s var(--ease), box-shadow 0.3s var(--ease);
  animation: appear-fade 0.35s var(--ease);
}
.join-support:hover { border-color: var(--accent); transform: translateY(-2px); box-shadow: 0 8px 32px rgba(0,0,0,0.5); }
.join-support__icon {
  width: 42px; height: 42px; flex: 0 0 42px; border-radius: 12px;
  background: var(--accent-grad);
  color: var(--accent-contrast); display: flex; align-items: center; justify-content: center;
}
.join-support__text { flex: 1; display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.join-support__text strong { font-family: var(--font-heading); font-size: 14px; font-weight: 600; color: var(--text-strong); }
.join-support__text small { font-size: 11px; color: var(--stone-400); line-height: 1.4; }

.status-form { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.ticket-bottom-nav { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin-top: 16px; }
.status-form select, .status-form input[type="text"] {
  background: var(--surface-50);
  border: 1px dotted var(--white-15);
  border-radius: 999px;
  padding: 8px 14px;
  color: var(--white-80); font-size: 12px; font-family: var(--font-mono);
  outline: none;
  transition: border-color 0.3s var(--ease);
}
.status-form select:focus, .status-form input[type="text"]:focus { border-color: var(--accent); }

.close-actions { display: flex; gap: 12px; flex-wrap: wrap; align-items: stretch; margin-top: 16px; }

.wait-timer {
  display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
  background: var(--warning-bg);
  border: 1px dotted var(--warning); border-radius: 12px;
  padding: 10px 16px; margin-bottom: 12px;
  animation: slideDown 0.25s var(--ease);
}
.wait-timer__title { font-size: 12px; font-weight: 700; color: var(--warning); font-family: var(--font-heading); }
.wait-timer__count {
  font-size: 18px; font-weight: 700; color: var(--warning);
  font-variant-numeric: tabular-nums; font-family: var(--font-mono);
}
.close-actions__item {
  flex: 1; min-width: 250px;
  display: flex; flex-direction: column; gap: 8px;
  padding: 12px 14px;
  background: var(--white-03);
  border: 1px dotted var(--border-soft); border-radius: 12px;
}
.close-actions__item form { display: flex; gap: 8px; margin: 0; }
.close-actions__item form input[type="text"] {
  flex: 1; min-width: 0;
  background: var(--surface-50);
  border: 1px dotted var(--white-15);
  border-radius: 999px; padding: 8px 14px;
  color: var(--white-80); font-size: 12px; font-family: var(--font-mono);
  outline: none;
  transition: border-color 0.3s var(--ease);
}
.close-actions__item form input[type="text"]:focus { border-color: var(--accent); }
.close-actions__item .form__hint { margin: 0; line-height: 1.5; }

.card {
  background: var(--surface-30);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  border: 1px dotted var(--border-soft);
  border-radius: 12px;
  padding: 24px 28px;
  margin-bottom: 16px;
  animation: appear-fade 0.35s var(--ease);
}
.card__header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 16px; gap: 12px; flex-wrap: wrap; }
.card__header-left { display: flex; align-items: center; gap: 10px; color: var(--stone-400); }
.card__header-left h2 { font-size: 18px; font-weight: 600; color: var(--text-strong); margin: 0; font-family: var(--font-heading); }
.card__desc { font-size: 12px; color: var(--white-50); margin-bottom: 12px; line-height: 1.55; }

.info-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 12px; }
.info-stat {
  padding: 16px 18px;
  background: var(--white-03);
  border: 1px dotted var(--border-soft);
  border-radius: 12px;
  display: flex; flex-direction: column; gap: 6px;
}
.info-stat__label {
  font-size: 10px; text-transform: uppercase; letter-spacing: 0.6px;
  color: var(--stone-400); font-weight: 600;
}
.info-stat__value { font-size: 28px; font-weight: 600; color: var(--text-strong); font-family: var(--font-heading); line-height: 1; }
.info-stat__value--accent { color: var(--accent); }
.info-stat__value--success { color: var(--success); }
.info-stat__value--warning { color: var(--warning); }
.info-stat__value--danger { color: var(--danger); }
.info-stat__value--blue { color: var(--blue); }
.info-stat__hint { font-size: 10px; color: var(--white-40, var(--white-50)); }

.dashboard-info { display: flex; flex-direction: column; gap: 8px; }
.dashboard-info__item {
  display: flex; justify-content: space-between; align-items: center;
  padding: 10px 14px; background: var(--white-03);
  border-radius: 10px; border: 1px dotted var(--border-soft);
}
.dashboard-info__label { font-size: 10px; color: var(--stone-400); text-transform: uppercase; letter-spacing: 0.3px; font-weight: 600; }
.dashboard-info__value { font-size: 13px; color: var(--text-strong); font-weight: 600; font-variant-numeric: tabular-nums; }

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

.sidebar {
  width: 260px;
  background: var(--surface-50);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border-right: 1px dotted var(--white-10);
  display: flex; flex-direction: column;
  position: fixed; top: 0; left: 0; bottom: 0; z-index: 100;
  transition: transform 0.3s var(--ease);
}
.sidebar__brand {
  display: flex; align-items: center; gap: 10px;
  padding: 20px; font-size: 15px; font-weight: 600; color: var(--text-strong);
  border-bottom: 1px dotted var(--white-10);
  font-family: var(--font-heading);
}
.sidebar__brand-icon {
  width: 32px; height: 32px;
  background: var(--accent-grad);
  border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
}

.nav { flex: 1; padding: 8px; display: flex; flex-direction: column; gap: 2px; }
.nav__link {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 14px; border-radius: 999px;
  color: var(--white-60); font-size: 12px; font-weight: 500;
  transition: all 0.3s var(--ease); min-height: 40px;
}
.nav__link:hover { color: var(--text-strong); background: var(--white-05); }
.nav__link--active { color: var(--accent); background: var(--accent-bg); }
.nav__link--active:hover { color: var(--accent); }
.nav__link--logout { margin-top: auto; color: var(--white-50); }
.nav__link--logout:hover { color: var(--danger); background: var(--danger-bg); }

.sidebar__footer { padding: 12px; border-top: 1px dotted var(--white-10); }
.sidebar__user { display: flex; align-items: center; gap: 10px; padding: 8px; margin-bottom: 8px; }
.sidebar__user-avatar {
  width: 34px; height: 34px;
  display: flex; align-items: center; justify-content: center;
  background: var(--accent-grad);
  border-radius: 10px; color: var(--accent-contrast); font-size: 13px; font-weight: 700;
}
.sidebar__user-info { display: flex; flex-direction: column; overflow: hidden; }
.sidebar__user-name { font-size: 12px; font-weight: 600; color: var(--text-strong); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sidebar__user-role { font-size: 10px; color: var(--stone-400); }

.main-content { flex: 1; margin-left: 260px; min-height: 100vh; }

.topbar {
  display: none; align-items: center; gap: 12px;
  padding: 12px 20px;
  background: var(--surface-40);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border-bottom: 1px dotted var(--white-10);
  position: sticky; top: 0; z-index: 50;
}
.topbar__menu {
  background: none; border: none; color: var(--white-60); cursor: pointer;
  padding: 6px; min-height: 40px; min-width: 40px;
  display: flex; align-items: center; justify-content: center;
  border-radius: 999px; transition: background 0.3s var(--ease);
}
.topbar__menu:hover { background: var(--white-05); }
.topbar__title { font-size: 15px; font-weight: 600; color: var(--text-strong); font-family: var(--font-heading); }
.topbar__spacer { flex: 1; }
.content { padding: 24px; max-width: 960px; }
.content--narrow { max-width: 560px; }

.modal {
  border: none; border-radius: 12px;
  background: var(--surface-modal);
  color: var(--white-80);
  padding: 28px; max-width: 400px; width: 90vw;
  margin: auto;
  box-shadow: 0 8px 40px rgba(0,0,0,0.6);
  animation: appear-fade 0.3s var(--ease);
}
.modal::backdrop { background: rgba(0,0,0,0.6); backdrop-filter: blur(4px); }
.modal__actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 20px; }
.modal h2 { font-size: 18px; font-weight: 600; color: var(--text-strong); margin-bottom: 16px; font-family: var(--font-heading); }

.profile-main { max-width: 920px; }
.profile-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 16px; margin-top: 16px; }
.profile-grid .card { margin-bottom: 0; padding: 20px 22px; }
.profile-grid h2 {
  font-size: 16px; font-weight: 600; color: var(--text-strong); margin-bottom: 14px; font-family: var(--font-heading);
  display: flex; align-items: center; gap: 8px;
}
.card-ico {
  width: 26px; height: 26px; flex: 0 0 26px; border-radius: 8px;
  background: var(--accent-bg); color: var(--accent);
  display: inline-flex; align-items: center; justify-content: center;
}
.avatar-preview { display: flex; justify-content: center; margin-bottom: 16px; }
.avatar-preview__frame { position: relative; display: inline-block; }
.avatar-preview__img {
  width: 100px; height: 100px; border-radius: 50%;
  background: var(--accent-grad);
  background-size: cover; background-position: center;
  display: flex; align-items: center; justify-content: center;
  color: var(--accent-contrast); font-size: 32px; font-weight: 700;
  border: 2px dotted var(--white-20);
  box-shadow: 0 0 0 3px var(--accent-glow);
}
.avatar-preview__img--empty { background: var(--accent-grad); }
.avatar-preview__badge {
  position: absolute; right: -2px; bottom: 2px;
  display: inline-flex; filter: drop-shadow(0 2px 4px rgba(0,0,0,0.5));
}
.avatar-preview__badge--star {
  right: auto; bottom: auto; top: -2px; left: -2px;
  width: 26px; height: 26px; border-radius: 50%;
  background: linear-gradient(135deg, #fef3c7, #fdba74); color: #78350f;
  align-items: center; justify-content: center;
  font-size: 14px; font-weight: 700; border: 2px solid var(--stone-950);
}

.account-info {
  list-style: none; display: flex; flex-direction: column; gap: 9px;
  margin-top: 16px; padding-top: 14px;
  border-top: 1px dotted var(--white-10);
}
.account-info li { display: flex; justify-content: space-between; align-items: center; gap: 10px; font-size: 12px; }
.account-info li span {
  color: var(--stone-400); font-size: 10px;
  text-transform: uppercase; letter-spacing: 0.5px; font-weight: 600;
}
.account-info li b { color: var(--text-strong); font-weight: 600; display: inline-flex; align-items: center; gap: 5px; text-align: right; }
.account-info .verified-tg { margin-left: 0; }

.tg-linked {
  display: inline-flex; align-items: center; gap: 6px;
  color: var(--blue); font-weight: 600;
}
a.tg-linked:hover { text-decoration: underline; }

.notify-code {
  font-family: var(--font-mono); font-size: 12px;
  background: var(--surface-50); border: 1px dotted var(--white-15);
  border-radius: 8px; padding: 2px 8px;
  color: var(--accent); white-space: nowrap;
}
.notify-actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.notify-actions form { margin: 0; }

.take-bar {
  display: flex; align-items: center; gap: 14px; flex-wrap: wrap;
  margin-bottom: 12px; padding: 12px 16px;
  background: var(--warning-bg);
  border: 1px dotted var(--warning); border-radius: 12px;
  animation: slideDown 0.25s var(--ease);
}
.take-bar .form__hint { flex: 1; min-width: 200px; margin: 0; }
.take-bar form { margin: 0; }

.ticket-main { max-width: 1080px; }
.ticket-layout { display: grid; grid-template-columns: 290px minmax(0, 1fr); gap: 16px; align-items: start; }
.ticket-info { margin-bottom: 0; padding: 18px 20px; position: sticky; top: 70px; }
.ticket-info h2 {
  font-size: 13px; font-weight: 600; color: var(--text-strong); margin-bottom: 12px;
  font-family: var(--font-heading);
  display: flex; align-items: center; gap: 7px;
}
.ticket-info .account-info { margin-top: 0; padding-top: 0; border-top: none; }
.account-info--wrap { flex-direction: column; align-items: flex-start !important; gap: 3px !important; }
.account-info--wrap b { white-space: normal !important; text-align: left !important; line-height: 1.45; }
.ticket-info__author { flex-wrap: wrap; }
.ticket-chat-col { min-width: 0; display: flex; flex-direction: column; }

.template-bar {
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
  margin-bottom: 8px;
}
.template-bar select {
  background: var(--surface-50);
  border: 1px dotted var(--white-15);
  border-radius: 999px; padding: 7px 14px;
  color: var(--white-80); font-size: 12px; font-family: var(--font-mono);
  outline: none; cursor: pointer;
  transition: border-color 0.3s var(--ease);
}
.template-bar select:focus { border-color: var(--accent); }

.table--templates { table-layout: fixed; width: 100%; }
.table--templates th, .table--templates td { overflow: hidden; }
.table--templates th:nth-child(1), .table--templates td:nth-child(1) { width: 44px; }
.table--templates th:nth-child(2), .table--templates td:nth-child(2) { width: 27%; }
.table--templates th:nth-child(4), .table--templates td:nth-child(4) { width: 84px; }
.table--templates th:nth-child(5), .table--templates td:nth-child(5) { width: 52px; }
.tpl-title {
  display: block; max-width: 100%;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.tpl-body {
  white-space: normal;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
  color: var(--white-60); font-size: 11px; line-height: 1.45;
}
.table__cell-actions { white-space: nowrap; }
.table__cell-actions form { display: inline-flex; }

.version-widget {
  position: fixed; right: 16px; bottom: 16px; z-index: 1000;
  display: flex; flex-direction: column; align-items: flex-end; outline: none;
}
.version-widget__badge {
  background: var(--surface-50); backdrop-filter: blur(8px);
  color: var(--white-60); border: 1px dotted var(--white-15);
  border-radius: 999px; padding: 6px 14px; font-size: 10px; font-weight: 600;
  cursor: help; box-shadow: 0 4px 16px rgba(0,0,0,0.4);
  transition: border-color 0.3s var(--ease), color 0.3s var(--ease);
}
.version-widget__badge:hover { border-color: var(--accent); color: var(--text-strong); }
.version-widget__popup {
  margin-bottom: 10px; width: 300px;
  max-width: calc(100vw - 24px);
  max-height: min(70vh, 460px);
  display: flex; flex-direction: column;
  background: var(--surface-85); backdrop-filter: blur(8px);
  border: 1px dotted var(--border-soft);
  border-radius: 12px; padding: 14px;
  box-shadow: 0 8px 40px rgba(0,0,0,0.6);
}
.version-widget__popup[hidden] { display: none; }
.version-widget__title { font-size: 12px; font-weight: 700; color: var(--accent); margin-bottom: 2px; font-family: var(--font-heading); }
.version-widget__version { font-size: 10px; color: var(--stone-400); margin-bottom: 10px; }
.version-widget__changelog {
  flex: 1; min-height: 0;
  overflow-y: auto; overscroll-behavior: contain;
  padding-right: 6px;
  scrollbar-width: thin;
  scrollbar-color: var(--white-18) transparent;
}
.version-widget__changelog::-webkit-scrollbar { display: block; width: 4px; }
.version-widget__changelog::-webkit-scrollbar-track { background: transparent; }
.version-widget__changelog::-webkit-scrollbar-thumb { background: var(--white-18); border-radius: 999px; }
.version-widget__changelog-title { font-size: 9px; text-transform: uppercase; letter-spacing: 0.6px; color: var(--white-50); font-weight: 600; margin-bottom: 6px; position: sticky; top: 0; }
.version-widget__changelog ul { list-style: none; display: flex; flex-direction: column; gap: 5px; }
.version-widget__changelog li { font-size: 10.5px; line-height: 1.45; color: var(--white-60); padding-left: 10px; position: relative; overflow-wrap: anywhere; }
.version-widget__changelog li::before {
  content: ''; position: absolute; left: 0; top: 5px;
  width: 3px; height: 3px; border-radius: 50%; background: var(--accent);
}

.tag-pop { position: relative; cursor: help; outline: none; }
.tag-pop__card { display: none; }
.tag-pop-layer {
  position: fixed; display: none; width: 220px;
  background: var(--surface-85); backdrop-filter: blur(8px);
  border: 1px dotted var(--border-soft);
  border-radius: 12px; padding: 14px 16px;
  font-size: 11px; line-height: 1.5; color: var(--white-60);
  box-shadow: 0 8px 40px rgba(0,0,0,0.6);
  z-index: 2000; pointer-events: none;
  animation: popIn 140ms var(--ease);
}
@keyframes popIn { from { opacity: 0; transform: translateY(6px) scale(0.95); } to { opacity: 1; transform: translateY(0) scale(1); } }
.tag-pop-layer strong {
  display: flex; align-items: center; gap: 6px; margin-bottom: 6px;
  font-size: 12px; font-weight: 700; color: var(--text-strong);
  font-family: var(--font-heading);
}
.tag-pop-layer strong::before {
  content: ''; width: 6px; height: 6px; border-radius: 50%;
  background: var(--accent); box-shadow: 0 0 8px var(--accent);
}

.staff-main { max-width: 1080px; }
.staff-layout { display: grid; grid-template-columns: 320px 1fr; gap: 16px; margin-top: 16px; align-items: start; }
.staff-layout > .card { padding: 20px; }
.staff-layout > .staff-chat { min-width: 0; }
.staff-layout h2 { font-size: 16px; font-weight: 600; color: var(--text-strong); margin-bottom: 12px; font-family: var(--font-heading); }
.staff-members__list { list-style: none; display: flex; flex-direction: column; gap: 6px; margin-bottom: 12px; }
.staff-members__item {
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
  padding: 8px 10px; background: var(--white-03);
  border-radius: 10px; border: 1px dotted var(--border-soft);
}
.staff-members__name { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; font-weight: 600; }
.staff-members__role { font-size: 10px; color: var(--stone-400); margin-left: auto; }
.staff-members__remove { margin-left: 4px; }
.staff-add-form { display: flex; gap: 8px; }
.staff-add-form input {
  flex: 1;
  background: var(--surface-50);
  border: 1px dotted var(--white-15);
  border-radius: 10px; padding: 8px 12px;
  color: var(--white-80); font-family: var(--font-mono); font-size: 12px; outline: none;
}
.mini-avatar {
  width: 22px; height: 22px; border-radius: 50%;
  background: var(--accent-grad);
  background-size: cover; background-position: center;
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 10px; font-weight: 700; color: var(--accent-contrast); flex: 0 0 22px;
}
.staff-chat .chat { height: 60vh; }

.filter-bar { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 14px; align-items: center; }
.filter-bar input, .filter-bar select {
  background: var(--surface-50);
  border: 1px dotted var(--white-15);
  border-radius: 999px; padding: 8px 14px;
  color: var(--white-80); font-family: var(--font-mono); font-size: 12px; outline: none;
}
.filter-bar input:focus, .filter-bar select:focus { border-color: var(--accent); }

.role-select {
  background: var(--surface-50);
  border: 1px dotted var(--white-15);
  border-radius: 8px; padding: 5px 8px;
  color: var(--white-80); font-family: var(--font-mono); font-size: 11px; outline: none;
  cursor: pointer;
}
.role-select:focus { border-color: var(--accent); }

.flex { display: flex; }
.flex-col { flex-direction: column; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.justify-end { justify-content: flex-end; }
.gap-sm { gap: 12px; }
.gap-xs { gap: 8px; }
.mt-sm { margin-top: 12px; }
.mb-sm { margin-bottom: 12px; }
.text-center { text-align: center; }
.btn-group { display: flex; gap: 8px; flex-wrap: wrap; }

.unread-badge {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 18px; height: 18px; padding: 0 5px;
  font-size: 10px; font-weight: 700;
  color: var(--accent-contrast);
  background: var(--accent-grad);
  border-radius: 999px; line-height: 1;
  box-shadow: 0 0 8px var(--accent-glow-strong);
}

.status-timeline { display: flex; align-items: center; gap: 12px; margin-bottom: 20px; flex-wrap: wrap; }
.status-timeline__step {
  display: flex; align-items: center; gap: 4px;
  font-size: 11px; color: var(--white-40, var(--white-50)); font-weight: 500;
  transition: color 0.3s var(--ease);
}
.status-timeline__step:hover { color: var(--white-70); }
.status-timeline__step--done { color: var(--accent); }
.status-timeline__dot { width: 6px; height: 6px; border-radius: 50%; background: var(--white-40, var(--white-50)); }
.status-timeline__step--done .status-timeline__dot { background: var(--accent); }

.docs-widget {
  position: fixed; left: 16px; bottom: 16px; z-index: 1000;
  display: flex; align-items: center; gap: 8px; outline: none;
}
.docs-widget__btn {
  display: inline-flex; align-items: center; gap: 8px;
  background: var(--surface-50); backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px);
  color: var(--white-60); border: 1px dotted var(--white-15);
  border-radius: 999px; padding: 8px 14px; font-size: 10px; font-weight: 600;
  font-family: var(--font-mono); cursor: pointer; white-space: nowrap;
  box-shadow: 0 4px 16px rgba(0,0,0,0.4);
  transition: border-color 0.3s var(--ease), color 0.3s var(--ease);
}
.docs-widget__btn:hover { border-color: var(--accent); color: #fff; }
.docs-widget__icon { display: inline-flex; flex-shrink: 0; }
.docs-widget__label {
  display: inline-block; max-width: 0; opacity: 0; overflow: hidden;
  white-space: nowrap;
  transition: max-width 0.45s var(--ease), opacity 0.35s var(--ease);
}
.docs-widget--expanded .docs-widget__label { max-width: 110px; opacity: 1; }
.docs-widget--icons .docs-widget__label { max-width: 0; opacity: 0; }

.docs-widget__icons {
  display: flex; gap: 8px;
  opacity: 0; transform: translateX(18px); pointer-events: none;
  transition: opacity 0.3s var(--ease), transform 0.45s var(--ease);
}
.docs-widget--icons .docs-widget__icons { opacity: 1; transform: none; pointer-events: auto; }

.docs-widget__icon-btn {
  width: 36px; height: 36px; border-radius: 50%; flex-shrink: 0;
  display: inline-flex; align-items: center; justify-content: center;
  background: var(--surface-50); backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px);
  border: 1px dotted var(--white-15); color: var(--white-60);
  box-shadow: 0 4px 16px rgba(0,0,0,0.4);
  opacity: 0; transform: translateX(16px);
  transition: opacity 0.35s var(--ease), transform 0.45s var(--ease), color 0.25s var(--ease), border-color 0.25s var(--ease);
}
.docs-widget--icons .docs-widget__icon-btn { opacity: 1; transform: none; }
.docs-widget--icons .docs-widget__icon-btn:nth-child(1) { transition-delay: 0s; }
.docs-widget--icons .docs-widget__icon-btn:nth-child(2) { transition-delay: 0.08s; }
.docs-widget--icons .docs-widget__icon-btn:nth-child(3) { transition-delay: 0.16s; }
.docs-widget__icon-btn:hover { color: var(--accent); border-color: var(--accent); }

.docs-widget__tooltip {
  position: fixed; display: none; z-index: 1500;
  background: var(--surface-85); backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px);
  border: 1px dotted var(--white-15); border-radius: 10px;
  padding: 7px 12px; font-size: 11px; font-weight: 500; color: var(--white-80);
  white-space: nowrap; pointer-events: none;
  box-shadow: 0 8px 24px rgba(0,0,0,0.45);
}
.docs-widget__tooltip.show { display: block; animation: popIn 140ms var(--ease); }

.docs-widget__menu {
  position: absolute; left: 0; bottom: calc(100% + 10px);
  min-width: 250px; padding: 10px;
  background: var(--surface-92); backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px);
  border: 1px dotted var(--white-15); border-radius: 12px;
  box-shadow: 0 8px 40px rgba(0,0,0,0.6);
  animation: popIn 140ms var(--ease);
}
.docs-widget__menu[hidden] { display: none; }
.docs-widget__menu-link {
  display: flex; align-items: center; gap: 9px;
  padding: 9px 12px; border-radius: 999px;
  color: var(--white-70); font-size: 12px; font-weight: 500;
  transition: all 0.25s var(--ease);
}
.docs-widget__menu-link:hover { color: var(--accent); background: var(--accent-bg); }

.legal-main { max-width: 760px; }
.legal-title { display: inline-flex; align-items: center; gap: 10px; }
.legal-title svg { color: var(--accent); }
.legal-doc { padding: 26px 30px; }
.legal-updated {
  display: inline-block; font-size: 10px; font-weight: 600;
  text-transform: uppercase; letter-spacing: 0.6px;
  color: var(--stone-400); margin-bottom: 18px;
  padding: 4px 12px; border: 1px dotted var(--white-15); border-radius: 999px;
}
.legal-doc h2 {
  font-size: 15px; font-weight: 600; color: var(--text-strong);
  margin: 22px 0 8px; font-family: var(--font-heading);
}
.legal-doc h2:first-of-type { margin-top: 0; }
.legal-doc p, .legal-doc li { font-size: 13px; color: var(--white-70); line-height: 1.7; }
.legal-doc ul { padding-left: 20px; display: flex; flex-direction: column; gap: 6px; margin: 8px 0; }
.legal-doc strong { color: var(--text-strong); }
.legal-doc a { color: var(--accent); font-weight: 500; }
.legal-doc a:hover { text-decoration: underline; }
.legal-nav { margin-top: 16px; display: flex; flex-direction: column; gap: 10px; }
.legal-nav__links { display: flex; gap: 8px; flex-wrap: wrap; }

@keyframes appear-fade {
  0% { opacity: 0; transform: scale(0.97); }
  100% { opacity: 1; transform: scale(1); }
}

@media (max-width: 768px) {
  h1 { font-size: 24px; }
  .client-main__head h1 { font-size: 22px; }
  .maintenance__title { font-size: 30px; }
  .topbar-link span { display: none; }
  .topbar-link { padding: 6px 8px; }
  .sidebar { transform: translateX(-100%); }
  .sidebar--open { transform: translateX(0); }
  .main-content { margin-left: 0; }
  .topbar { display: flex; }
  .content { padding: 16px; }
  .card { padding: 20px 18px; }
  .form__role-preview { grid-template-columns: repeat(2, 1fr); }
  .staff-layout { grid-template-columns: 1fr; }
  .profile-grid { grid-template-columns: 1fr; }
  .chat { max-height: 45vh; }
  .staff-chat .chat { height: 50vh; }
  .client-main { padding: 16px; }
}

@media (max-width: 480px) {
  .version-widget { right: 12px; bottom: 12px; }
  .version-widget__badge { padding: 5px 12px; }
  .version-widget__popup { width: calc(100vw - 24px); max-height: 60vh; padding: 12px; }
  .version-widget__title { font-size: 11px; }
  .version-widget__changelog li { font-size: 10px; }
}

@media (max-width: 900px) {
  .ticket-layout { grid-template-columns: 1fr; }
  .ticket-info { position: static; order: 2; }
  .ticket-chat-col { order: 1; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; transition-duration: 0.01ms !important; }
}

/* ===== Убрать потом надо емае ===== */

.nav__telegram-wrapper {
  padding: 4px 0;
  border-top: 1px dotted var(--white-05);
  margin-top: 4px;
}

.nav__link--telegram {
  width: 100%;
  background: none;
  border: none;
  cursor: not-allowed;
  opacity: 0.5;
  position: relative;
  justify-content: space-between;
  padding-right: 12px;
}

.nav__link--telegram:hover {
  background: transparent;
  color: var(--white-60);
}

.nav__telegram-badge {
  font-size: 9px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  padding: 2px 8px;
  border-radius: 999px;
  background: var(--warning-bg);
  color: var(--warning);
  border: 1px dotted var(--border-soft);
  white-space: nowrap;
  animation: pulse-badge 2s ease-in-out infinite;
}

@keyframes pulse-badge {
  0%, 100% { opacity: 0.7; }
  50% { opacity: 1; }
}

.nav__link--telegram:disabled {
  pointer-events: none;
}

.nav__link--telegram .nav__telegram-badge {
  margin-left: auto;
}

/* =========================================================
   Targeted polish: dark select menus + current-user "ВЫ" tag
   This layer intentionally avoids changing page layout.
   ========================================================= */

:root {
  color-scheme: dark;
  --select-bg: #171020;
  --select-option-bg: #171020;
  --select-option-text: #f5edff;
  --self-badge-bg: rgba(216, 180, 254, .13);
  --self-badge-border: rgba(216, 180, 254, .48);
  --self-badge-text: #e7c8ff;
}

/* Keep native dropdowns in the same dark visual theme. */
select,
.impersonate select,
.role-select,
.filter-bar select,
.form__group select,
.status-form select,
.template-bar select {
  color-scheme: dark;
  background-color: var(--select-bg);
  color: var(--white-80);
}

select option,
.impersonate select option,
.role-select option,
.filter-bar select option,
.form__group select option,
.status-form select option,
.template-bar select option {
  background-color: var(--select-option-bg);
  color: var(--select-option-text);
}

select option:checked {
  background: #4c2674 linear-gradient(0deg, #4c2674 0%, #4c2674 100%);
  color: #ffffff;
}

select option:disabled {
  color: #897b99;
}

/* A restrained, rounded outline for the top-bar role selector. */
.impersonate select {
  min-height: 34px;
  padding: 7px 34px 7px 13px;
  border: 1px solid rgba(216, 180, 254, .32);
  border-radius: 999px;
  background-color: rgba(28, 18, 41, .96);
  transition: border-color .18s ease, box-shadow .18s ease;
}

.impersonate select:hover {
  border-color: rgba(216, 180, 254, .62);
}

.impersonate select:focus-visible {
  border-color: #d8b4fe;
  outline: none;
  box-shadow: 0 0 0 3px rgba(216, 180, 254, .13);
}

/* More polished table edges and row rhythm, without thick grid lines. */
.table-wrap {
  border: 1px solid rgba(216, 180, 254, .16);
  border-radius: 13px;
  overflow: auto;
}

.table th,
.table td {
  border-color: rgba(216, 180, 254, .11);
}

.table th {
  background: rgba(216, 180, 254, .045);
}

.table tbody tr:hover {
  background: rgba(216, 180, 254, .045);
}

/* Style common markup patterns used for the current-user label.
   If the HTML already has a dedicated class, these rules cover it too. */
.you-badge,
.self-badge,
.current-user-badge,
.table__you,
.user-badge--self,
.badge--self,
.role-badge--self,
.table__username .badge,
.table__username + .badge,
.table__username + small,
.table__username + span {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  vertical-align: middle;
  white-space: nowrap;
  margin-left: 5px;
  padding: 2px 6px;
  min-height: 17px;
  border: 1px solid var(--self-badge-border);
  border-radius: 999px;
  background: var(--self-badge-bg);
  color: var(--self-badge-text);
  font-family: var(--font-mono);
  font-size: 9px;
  font-weight: 700;
  line-height: 1.2;
  letter-spacing: .35px;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .04);
}

/* The username and its "ВЫ" label should sit neatly on one line. */
.table__username {
  vertical-align: middle;
}

@media (max-width: 600px) {
  .impersonate select {
    max-width: 42vw;
    padding-left: 10px;
    padding-right: 25px;
  }

  .table th,
  .table td {
    padding: 10px 11px;
  }
}

/* =========================================================
   User table actions: keep Delete + Lock fully visible
   and inside the table's rounded border.
   ========================================================= */

/* The actions column needs room for both circular icon buttons. */
.table th.table__th-actions,
.table th:last-child,
.table td:last-child {
  width: 92px;
  min-width: 92px;
  box-sizing: border-box;
  padding-left: 8px;
  padding-right: 8px;
}

.table td:last-child {
  white-space: nowrap;
  overflow: visible;
}

/* Support direct buttons and buttons wrapped in forms. */
.table td:last-child > button,
.table td:last-child > a,
.table td:last-child > form,
.table td:last-child form button,
.table td:last-child .btn--icon {
  vertical-align: middle;
}

.table td:last-child > form,
.table td:last-child .table-actions,
.table td:last-child .user-actions,
.table td:last-child .actions {
  display: inline-flex;
  align-items: center;
  justify-content: flex-end;
  gap: 6px;
  max-width: 100%;
  margin: 0;
}

.table td:last-child > button,
.table td:last-child > a,
.table td:last-child > form,
.table td:last-child .btn--icon {
  flex-shrink: 0;
}

/* Slightly smaller, consistent icon buttons so two actions fit comfortably. */
.table td:last-child .btn--icon,
.table td:last-child button.btn--icon,
.table td:last-child a.btn--icon {
  width: 32px;
  min-width: 32px;
  height: 32px;
  min-height: 32px;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid rgba(216, 180, 254, .22);
  border-radius: 50%;
  background: rgba(216, 180, 254, .025);
  color: var(--white-60);
  flex-shrink: 0;
}

.table td:last-child .btn--icon:hover {
  color: var(--danger);
  border-color: rgba(253, 164, 175, .45);
  background: var(--danger-bg);
}

/* Lock/block action is visually distinct from delete, including if it uses
   a generic icon button class or a title/aria-label instead of a modifier. */
.table td:last-child button[title*="блок" i],
.table td:last-child button[aria-label*="блок" i],
.table td:last-child button[title*="разблок" i],
.table td:last-child button[aria-label*="разблок" i],
.table td:last-child button[title*="заблок" i],
.table td:last-child button[aria-label*="заблок" i],
.table td:last-child button.btn--warning,
.table td:last-child button.btn--lock,
.table td:last-child .btn--lock {
  color: #fda4af;
  border-color: rgba(253, 164, 175, .32);
  background: rgba(253, 164, 175, .055);
}

.table td:last-child button[title*="блок" i]:hover,
.table td:last-child button[aria-label*="блок" i]:hover,
.table td:last-child button[title*="разблок" i]:hover,
.table td:last-child button[aria-label*="разблок" i]:hover,
.table td:last-child button[title*="заблок" i]:hover,
.table td:last-child button[aria-label*="заблок" i]:hover,
.table td:last-child button.btn--warning:hover,
.table td:last-child button.btn--lock:hover,
.table td:last-child .btn--lock:hover {
  color: #fff1f2;
  border-color: rgba(253, 164, 175, .7);
  background: rgba(225, 29, 72, .16);
}

/* Prevent the final action from touching or crossing the rounded table edge. */
.table-wrap {
  overflow-x: auto;
  overflow-y: hidden;
  border-radius: 12px;
  padding: 0;
}

.table {
  table-layout: auto;
  min-width: 850px;
}

@media (max-width: 900px) {
  .table {
    min-width: 850px;
  }
  .table th.table__th-actions,
  .table th:last-child,
  .table td:last-child {
    width: 92px;
    min-width: 92px;
  }
}

/* =========================================================
   Final targeted fix: keep "ВЫ" beside the username and
   give the users table enough width for Delete + Block.
   ========================================================= */

/* Widen only content cards that contain a table (e.g. Users). */
.content:has(.table-wrap),
.content:has(table.table),
.card:has(.table-wrap) {
  width: calc(100% - 32px);
  max-width: 1240px;
  min-width: 0;
}

/* Give the table enough horizontal room for the action controls.
   On narrow screens the table scrolls inside its own rounded frame. */
.table-wrap {
  width: 100%;
  max-width: 100%;
  overflow-x: auto;
  overflow-y: hidden;
  border-radius: 12px;
  box-sizing: border-box;
}

.table {
  width: 100%;
  min-width: 920px;
  table-layout: auto;
}

.table th:last-child,
.table td:last-child,
.table .table__th-actions {
  width: 100px;
  min-width: 100px;
  box-sizing: border-box;
  padding-left: 8px;
  padding-right: 10px;
  white-space: nowrap;
}

.table td:last-child {
  text-align: right;
}

/* The login column must keep the username and current-user badge
   on the same line, even if the badge is a separate child element. */
.table td:nth-child(2) {
  white-space: nowrap;
  min-width: 112px;
}

.table td:nth-child(2) br {
  display: none !important;
}

.table td:nth-child(2) > span,
.table td:nth-child(2) > small,
.table td:nth-child(2) > .you-badge,
.table td:nth-child(2) > .self-badge,
.table td:nth-child(2) > .current-user-badge,
.table td:nth-child(2) > .table__you,
.table td:nth-child(2) > .user-badge--self,
.table td:nth-child(2) > .badge--self,
.table td:nth-child(2) > .role-badge--self {
  display: inline-flex !important;
  vertical-align: middle;
  align-items: center;
  margin: 0 0 0 5px;
}

/* If the username itself is wrapped, keep that wrapper inline too. */
.table td:nth-child(2) > div,
.table td:nth-child(2) > p,
.table td:nth-child(2) > strong,
.table td:nth-child(2) > .table__username {
  display: inline !important;
  vertical-align: middle;
  margin: 0;
}

/* Keep both action buttons visible and separated. */
.table td:last-child > form,
.table td:last-child .table-actions,
.table td:last-child .user-actions,
.table td:last-child .actions {
  display: inline-flex;
  flex-wrap: nowrap;
  align-items: center;
  justify-content: flex-end;
  gap: 6px;
  width: auto;
  max-width: 100%;
  vertical-align: middle;
}

.table td:last-child button,
.table td:last-child a,
.table td:last-child form {
  flex-shrink: 0;
}

@media (max-width: 700px) {
  .content:has(.table-wrap),
  .content:has(table.table),
  .card:has(.table-wrap) {
    width: calc(100% - 20px);
  }

  .table {
    min-width: 920px;
  }
}

/* =========================================================
   Maintenance switch alignment fix
   Keep the toggle grouped together and prevent it from being
   squeezed onto the end of the long explanatory sentence.
   ========================================================= */

.toggle-form {
  display: flex;
  align-items: center;
  justify-content: flex-start;
  flex-wrap: nowrap;
  gap: 12px;
  width: 100%;
  max-width: 100%;
  min-width: 0;
  flex: 0 0 100%;
  margin-top: 10px;
  box-sizing: border-box;
}

.toggle {
  position: relative;
  display: inline-block;
  width: 44px;
  min-width: 44px;
  height: 24px;
  flex: 0 0 44px;
  margin: 0;
  vertical-align: middle;
}

.toggle input {
  position: absolute;
  opacity: 0;
  width: 1px;
  height: 1px;
}

.toggle__slider {
  inset: 0;
  display: block;
  width: 100%;
  height: 100%;
  box-sizing: border-box;
}

.toggle__label {
  display: inline-block;
  flex: 0 0 auto;
  white-space: nowrap;
  line-height: 24px;
  margin: 0;
}

.card:has(.toggle-form) .card__desc {
  max-width: 100%;
  margin-bottom: 8px;
}

@media (max-width: 640px) {
  .toggle-form {
    gap: 9px;
    margin-top: 12px;
  }
}

/* =========================================================
   Maintenance card: align explanatory text and switch cleanly.
   The description occupies the left side; switch + status stay
   together at the right and never sit halfway through the text.
   ========================================================= */

.card:has(.toggle-form) .card__desc {
  display: grid !important;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  column-gap: 22px;
  row-gap: 10px;
  width: 100%;
  max-width: 100%;
  margin-bottom: 0;
  line-height: 1.65;
}

.card:has(.toggle-form) .toggle-form {
  display: inline-flex !important;
  align-items: center;
  justify-content: flex-start;
  flex-wrap: nowrap;
  gap: 10px;
  width: auto;
  min-width: max-content;
  max-width: 100%;
  flex: initial;
  margin: 0;
  white-space: nowrap;
}

.card:has(.toggle-form) .toggle {
  display: inline-block;
  position: relative;
  flex: 0 0 44px;
  width: 44px;
  min-width: 44px;
  height: 24px;
  margin: 0;
}

.card:has(.toggle-form) .toggle__label {
  display: inline-block;
  white-space: nowrap;
  line-height: 1.4;
  margin: 0;
}

/* If the viewport is too narrow, place the switch on its own row,
   aligned to the left, rather than squeezing it into the sentence. */
@media (max-width: 760px) {
  .card:has(.toggle-form) .card__desc {
    grid-template-columns: minmax(0, 1fr);
    align-items: start;
    row-gap: 12px;
  }

  .card:has(.toggle-form) .toggle-form {
    justify-self: start;
  }
}

/* FINAL FIX — center the maintenance switch group in the card.
   Description stays left-aligned; the switch and its status are
   centered as one stable group beneath it. */
.card:has(.toggle-form) .card__desc {
  display: grid !important;
  grid-template-columns: minmax(0, 1fr) !important;
  align-items: center !important;
  row-gap: 12px !important;
  width: 100%;
  max-width: 100%;
}

.card:has(.toggle-form) .toggle-form,
.toggle-form {
  display: flex !important;
  align-items: center !important;
  justify-content: center !important;
  flex-wrap: nowrap !important;
  gap: 12px !important;
  width: 100% !important;
  min-width: 0 !important;
  max-width: 100% !important;
  margin: 0 auto !important;
  box-sizing: border-box;
}

.card:has(.toggle-form) .toggle,
.toggle-form .toggle {
  flex: 0 0 44px !important;
  width: 44px !important;
  min-width: 44px !important;
  height: 24px !important;
  margin: 0 !important;
}

.card:has(.toggle-form) .toggle__label,
.toggle-form .toggle__label {
  flex: 0 0 auto !important;
  white-space: nowrap !important;
  margin: 0 !important;
  line-height: 24px !important;
}

@media (max-width: 760px) {
  .card:has(.toggle-form) .toggle-form,
  .toggle-form {
    justify-content: center !important;
  }
}

/* FINAL POSITION — place the maintenance toggle at the marked spot,
   immediately after the description instead of centering it in the card. */
.card:has(.toggle-form) .card__desc {
  display: flex !important;
  flex-direction: row !important;
  align-items: center !important;
  justify-content: flex-start !important;
  flex-wrap: nowrap !important;
  column-gap: clamp(18px, 5.5vw, 88px) !important;
  row-gap: 0 !important;
  width: 100% !important;
  max-width: 100% !important;
}

.card:has(.toggle-form) .toggle-form,
.toggle-form {
  display: inline-flex !important;
  flex: 0 0 auto !important;
  align-items: center !important;
  justify-content: flex-start !important;
  gap: 12px !important;
  width: auto !important;
  min-width: max-content !important;
  max-width: none !important;
  margin: 0 !important;
  padding: 0 !important;
  position: relative !important;
  left: 0 !important;
  transform: none !important;
}

.card:has(.toggle-form) .toggle,
.toggle-form .toggle {
  flex: 0 0 44px !important;
  width: 44px !important;
  min-width: 44px !important;
  height: 24px !important;
  margin: 0 !important;
}

.card:has(.toggle-form) .toggle__label,
.toggle-form .toggle__label {
  white-space: nowrap !important;
  margin: 0 !important;
}

@media (max-width: 900px) {
  .card:has(.toggle-form) .card__desc {
    flex-wrap: wrap !important;
    column-gap: 18px !important;
    row-gap: 12px !important;
  }

  .card:has(.toggle-form) .toggle-form,
  .toggle-form {
    margin-left: 0 !important;
  }
}

/* Fine adjustment: move the maintenance switch slightly upward and right. */
.card:has(.toggle-form) .toggle-form,
.toggle-form {
  transform: translate(8px, -4px) !important;
}

@media (max-width: 900px) {
  .card:has(.toggle-form) .toggle-form,
  .toggle-form {
    transform: translate(6px, -3px) !important;
  }
}
