:root {
  --bg0: #050807;
  --bg1: #0c1411;
  --ink: #e8f2ec;
  --muted: #8aa396;
  --accent: #3dd68c;
  --accent-dim: #1f7a52;
  --warn: #e8b84a;
  --danger: #e86a5a;
  --line: rgba(232, 242, 236, 0.12);
  --font: "DM Sans", system-ui, sans-serif;
  --display: "Syne", "DM Sans", sans-serif;
  --surface: rgba(8, 14, 12, 0.78);
  --radius-card: 42px;
}

* { box-sizing: border-box; }

/* Author `display:` rules beat the UA [hidden] stylesheet without !important.
   Keep login / app shell / modal actually hidden when the attribute is set. */
[hidden] {
  display: none !important;
}

/*
  Ambient background lives on html/body — NOT a fixed .bg sibling with z-index:-1.
  Mobile Safari (esp. with overflow on body) paints z-index:-1 fixed layers ON TOP of
  later siblings → pure black screen (login in DOM, invisible). Earlier "green edges"
  were the same covering layer; mobile CSS then muted the green → solid black.
*/
html, body {
  margin: 0;
  min-height: 100%;
  font-family: var(--font);
  color: var(--ink);
  background-color: var(--bg0);
  background-image:
    radial-gradient(
      ellipse 150% 58% at 50% 50%,
      transparent 30%,
      rgba(6, 18, 12, 0.28) 54%,
      rgba(3, 12, 7, 0.45) 74%,
      rgba(1, 6, 3, 0.55) 90%,
      rgba(0, 3, 1, 0.62) 100%
    ),
    radial-gradient(ellipse 38% 58% at 0% 50%, rgba(92, 255, 176, 0.16) 0%, transparent 68%),
    radial-gradient(ellipse 38% 58% at 100% 50%, rgba(61, 214, 140, 0.14) 0%, transparent 68%),
    radial-gradient(120% 80% at 50% 120%, rgba(16, 48, 34, 0.38), transparent 55%),
    linear-gradient(165deg, #050807 0%, #080e0b 50%, #040605 100%);
  background-attachment: fixed;
  /* Do NOT set overflow-x:hidden on body — Safari stacking bug with fixed layers */
}

@media (max-width: 768px) {
  html, body {
    background-image:
      radial-gradient(ellipse 55% 52% at 0% 50%, rgba(92, 255, 176, 0.14) 0%, transparent 72%),
      radial-gradient(ellipse 55% 52% at 100% 50%, rgba(92, 255, 176, 0.14) 0%, transparent 72%),
      radial-gradient(120% 80% at 50% 120%, rgba(16, 48, 34, 0.38), transparent 55%),
      linear-gradient(165deg, #050807 0%, #080e0b 50%, #040605 100%);
    background-attachment: scroll; /* fixed attachment is flaky on iOS */
  }
}

/* Desktop-only soft orbs — never on mobile Safari (filter + fixed = paint bugs) */
@media (min-width: 769px) {
  body::before,
  body::after {
    content: "";
    position: fixed;
    z-index: 0;
    pointer-events: none;
    border-radius: 50%;
    filter: blur(90px);
    opacity: 0.35;
    top: 50%;
    transform: translateY(-50%);
    -webkit-mask-image: linear-gradient(to bottom, transparent 0%, #000 14%, #000 86%, transparent 100%);
    mask-image: linear-gradient(to bottom, transparent 0%, #000 14%, #000 86%, transparent 100%);
  }
  body::before {
    width: min(60vw, 420px);
    height: min(60vw, 420px);
    left: -6%;
    background: radial-gradient(circle, rgba(92, 255, 176, 0.32) 0%, rgba(61, 214, 140, 0.14) 40%, transparent 72%);
  }
  body::after {
    width: min(70vw, 480px);
    height: min(70vw, 480px);
    right: -12%;
    background: radial-gradient(circle, rgba(61, 214, 140, 0.28) 0%, rgba(45, 180, 120, 0.12) 45%, transparent 72%);
  }
}

@media (min-width: 769px) and (prefers-reduced-motion: reduce) {
  body::before,
  body::after {
    filter: blur(60px);
  }
}

/* Legacy .bg node (if cached HTML still has it) — never cover UI */
.bg {
  display: none !important;
}

.boot-loading {
  position: fixed;
  inset: 0;
  z-index: 5;
  display: flex;
  align-items: center;
  justify-content: center;
  background-color: var(--bg0);
  background-image:
    radial-gradient(ellipse 38% 58% at 0% 50%, rgba(92, 255, 176, 0.12) 0%, transparent 68%),
    radial-gradient(ellipse 38% 58% at 100% 50%, rgba(61, 214, 140, 0.1) 0%, transparent 68%),
    linear-gradient(165deg, #050807 0%, #080e0b 50%, #040605 100%);
}

.boot-loading-spinner {
  width: 1.25rem;
  height: 1.25rem;
  border: 2px solid rgba(92, 255, 176, 0.18);
  border-top-color: rgba(92, 255, 176, 0.75);
  border-radius: 50%;
  animation: boot-spin 0.75s linear infinite;
}

@keyframes boot-spin {
  to { transform: rotate(360deg); }
}

@media (prefers-reduced-motion: reduce) {
  .boot-loading-spinner {
    animation: none;
    opacity: 0.65;
  }
}

.brand {
  margin: 0;
  font-family: var(--display);
  font-weight: 800;
  letter-spacing: 0.08em;
  font-size: 0.85rem;
  color: var(--accent);
  text-transform: uppercase;
}

h1, h2, h3 { font-family: var(--display); margin: 0.2rem 0 0.75rem; }
h1 { font-size: 1.75rem; font-weight: 700; }
h2 { font-size: 1.25rem; }
.muted { color: var(--muted); line-height: 1.45; }
.error { color: var(--danger); margin-top: 0.75rem; }

.login-view {
  position: relative;
  z-index: 2;
  /* no isolation / no ::before|::after — Safari stacking bug */
  min-height: 100vh;
  min-height: 100dvh;
  height: 100vh;
  height: 100dvh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  justify-content: safe center;
  opacity: 1;
  visibility: visible;
  padding: max(1rem, env(safe-area-inset-top)) max(1rem, env(safe-area-inset-right)) max(1rem, env(safe-area-inset-bottom)) max(1rem, env(safe-area-inset-left));
  overflow-x: hidden;
  overflow-y: auto;
  scrollbar-width: none;
  -ms-overflow-style: none;
  -webkit-overflow-scrolling: touch;
  /* ensure author display wins if UA quirks */
  background: transparent;
}
.login-view::-webkit-scrollbar {
  display: none;
}

/* Kill any leftover full-bleed overlays on login / shell (Safari-safe) */
.login-view::before,
.login-view::after,
.app-shell::before,
.app-shell::after {
  content: none !important;
  display: none !important;
}

/* Faint brand watermark in the empty space above the login card */
.login-watermark {
  position: absolute;
  left: 50%;
  top: 14.5%;
  z-index: 1;
  margin: 0;
  transform: translate(-50%, -50%);
  font-family: var(--display);
  font-weight: 800;
  font-size: clamp(4.5rem, 16vw, 9.5rem);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: #fff;
  opacity: 0.06;
  pointer-events: none;
  user-select: none;
  white-space: nowrap;
}

.login-wrap {
  position: relative;
  z-index: 10;
  display: flex;
  flex-direction: column;
  align-items: center;
  width: min(420px, 100%);
  flex-shrink: 0;
  opacity: 1;
  visibility: visible;
  transform: none;
  filter: none;
}

/* Faint credits pinned near the bottom of the login viewport */
.login-credits {
  position: absolute;
  left: 50%;
  bottom: max(1.25rem, env(safe-area-inset-bottom));
  transform: translateX(-50%);
  z-index: 10;
  margin: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.15em;
  font-family: inherit;
  font-weight: 400;
  letter-spacing: -0.01em;
  color: rgba(232, 242, 236, 0.38);
  pointer-events: none;
  user-select: none;
  white-space: nowrap;
  text-align: center;
}

.login-credits-by {
  font-size: 0.8rem;
}

.login-credits-name {
  font-size: 0.68rem;
}

.login-box {
  position: relative;
  z-index: 10;
  width: 100%;
  max-width: 100%;
  padding: 2rem;
  border: 2.5px solid #5cffb0;
  border-radius: var(--radius-card);
  background: rgba(8, 14, 12, 0.92); /* solid fallback — Safari backdrop-filter can hide kids */
  opacity: 1;
  visibility: visible;
  transform: none;
  filter: none;
  box-shadow:
    inset 0 0 0 1px rgba(160, 255, 210, 0.22),
    0 0 56px rgba(92, 255, 176, 0.11),
    0 0 96px rgba(92, 255, 176, 0.055);
  overflow: hidden;
}

@supports ((-webkit-backdrop-filter: blur(1px)) or (backdrop-filter: blur(1px))) {
  .login-box {
    background: var(--surface);
    -webkit-backdrop-filter: blur(14px);
    backdrop-filter: blur(14px);
  }
}

@media (max-width: 768px) {
  /* Mobile: no backdrop-filter (Safari compositing), solid card always */
  .login-box {
    -webkit-backdrop-filter: none;
    backdrop-filter: none;
    background: rgba(8, 14, 12, 0.96);
  }
}

.login-box > * {
  position: relative;
  z-index: 2;
  opacity: 1;
  visibility: visible;
}

@media (max-width: 480px) {
  .login-watermark {
    top: 8%;
    font-size: clamp(3.2rem, 18vw, 5.5rem);
  }
  .login-box {
    padding: 1.35rem 1.1rem;
  }
  .login-view h1 {
    font-size: 1.4rem;
  }
  .login-credits {
    white-space: normal;
  }
}

/* Registration: slightly tighter spacing so more fields fit without a card scrollbar */
#register-form label {
  margin-top: 0.7rem;
}
#register-form input {
  padding: 0.55rem 0.8rem;
}
#register-form button {
  margin-top: 0.85rem;
}
#register-form button.secondary {
  margin-top: 0.5rem;
}

/* Soft green blobs inside the login panel (no outer halo) */
.login-box::before,
.login-box::after {
  content: "";
  position: absolute;
  border-radius: 50%;
  pointer-events: none;
  z-index: 0;
  filter: blur(36px);
}

.login-box::before {
  width: 180px;
  height: 180px;
  top: -60px;
  left: -50px;
  background: rgba(61, 214, 140, 0.55);
}

.login-box::after {
  width: 140px;
  height: 140px;
  right: -50px;
  bottom: -60px;
  background: rgba(31, 122, 82, 0.5);
}

@media (max-width: 768px) {
  /* Avoid filter blur creating Safari stacking issues inside the card */
  .login-box::before,
  .login-box::after {
    content: none;
    display: none;
  }
}

.login-box label,
.action-form label {
  display: block;
  margin: 1rem 0 0.35rem;
  font-size: 0.85rem;
  color: var(--muted);
}

input, textarea, select, button {
  font: inherit;
  width: 100%;
}

input, textarea, select {
  padding: 0.7rem 0.8rem;
  border: 1px solid var(--line);
  background: rgba(0, 0, 0, 0.35);
  color: var(--ink);
  border-radius: 15px;
  max-width: 100%;
  font-size: 1rem; /* avoid iOS focus zoom */
}

button {
  margin-top: 1rem;
  padding: 0.75rem 1rem;
  min-height: 44px;
  border: none;
  border-radius: 15px;
  background: var(--accent);
  color: #062015;
  font-weight: 700;
  cursor: pointer;
}

button:hover { filter: brightness(1.05); }

/* Plain text link under password — right-aligned, no button chrome */
button.login-recover-link {
  display: block;
  width: fit-content;
  max-width: 100%;
  margin: 0.45rem 0 0 auto;
  padding: 0.35rem 0;
  min-height: 0;
  border: none;
  background: transparent;
  color: var(--muted);
  font-weight: 400;
  font-size: 0.85rem;
  text-align: right;
  cursor: pointer;
  box-shadow: none;
}
button.login-recover-link:hover {
  filter: none;
  color: #b5cfc4;
  text-decoration: underline;
}
button.login-recover-link:focus-visible {
  outline: 1px solid var(--accent-dim);
  outline-offset: 2px;
}

button.secondary {
  margin-top: 0.65rem;
  background: transparent;
  color: var(--ink);
  border: 1px solid var(--line);
  font-weight: 600;
}
button.secondary:hover {
  border-color: var(--accent-dim);
  color: var(--accent);
  filter: none;
}
button.ghost {
  width: auto;
  background: transparent;
  color: var(--ink);
  border: 1px solid var(--line);
  margin-top: 0;
}

#logout-btn {
  border: 1px solid #ff5c5c;
  border-radius: 999px;
  background: rgba(232, 106, 90, 0.14);
  box-shadow:
    0 0 6px rgba(255, 92, 92, 0.55),
    0 0 14px rgba(255, 92, 92, 0.35),
    inset 0 0 8px rgba(255, 92, 92, 0.12);
  color: #fff;
  font-weight: 700;
}

#logout-btn:hover {
  background: rgba(232, 106, 90, 0.22);
  box-shadow:
    0 0 8px rgba(255, 92, 92, 0.7),
    0 0 18px rgba(255, 92, 92, 0.45),
    inset 0 0 10px rgba(255, 92, 92, 0.16);
}

/* Registration success — centered overlay matching login theme */
.auth-modal {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: max(1rem, env(safe-area-inset-top)) max(1rem, env(safe-area-inset-right)) max(1rem, env(safe-area-inset-bottom)) max(1rem, env(safe-area-inset-left));
  overflow-x: hidden;
  overflow-y: auto;
}
.auth-modal[hidden] {
  display: none !important;
}
.auth-modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(4, 8, 6, 0.72);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
}
.auth-modal-dialog {
  position: relative;
  z-index: 1;
  width: min(360px, 100%);
  max-width: 100%;
  padding: 1.75rem 1.5rem;
  border: 1px solid rgba(61, 214, 140, 0.22);
  background: var(--surface);
  box-shadow:
    0 0 40px 6px rgba(31, 122, 82, 0.22),
    0 20px 48px rgba(0, 0, 0, 0.5);
  text-align: center;
}
.auth-modal-title {
  margin: 0 0 0.25rem;
  font-family: var(--display);
  font-weight: 700;
  font-size: 1.15rem;
  line-height: 1.35;
  color: var(--ink);
  overflow-wrap: anywhere;
}
.auth-modal-dialog button {
  margin-top: 1.35rem;
  min-height: 44px;
}

@media (max-width: 480px) {
  .auth-modal-dialog {
    padding: 1.35rem 1.1rem;
  }
  .auth-modal-title {
    font-size: 1.05rem;
  }
}

/* Authenticated shell: fixed sidebar + scrollable main */
.app-shell {
  position: relative;
  z-index: 2;
  /* no isolation — glow is on body only */
  display: flex;
  min-height: 100vh;
  min-height: 100dvh;
  height: 100vh;
  height: 100dvh;
  overflow: hidden;
  opacity: 1;
  visibility: visible;
  background: transparent;
}

.app-shell[hidden] {
  display: none !important;
}

.sidebar-backdrop {
  display: none;
}

/*
  Do NOT force position:relative on .sidebar here — that selector (.app-shell > .sidebar)
  beats mobile `.sidebar { position:fixed }` and leaves the drawer in-flow (100dvh empty
  strip + overflow:hidden) → blank post-login screen on iPhone Safari.
*/
.app-shell > .app-main {
  position: relative;
  z-index: 2;
}
.app-shell > .sidebar {
  z-index: 2;
}

.sidebar {
  flex: 0 0 240px;
  width: 240px;
  height: 100%;
  display: flex;
  flex-direction: column;
  border-right: 1px solid rgba(61, 214, 140, 0.14);
  background:
    linear-gradient(180deg, rgba(8, 16, 12, 0.98) 0%, rgba(5, 10, 8, 0.98) 100%);
  padding: 1.35rem 0.9rem 1rem;
  overflow: hidden;
}

.sidebar-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.5rem;
  flex-shrink: 0;
}

.sidebar-brand {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.55rem;
  margin: 0 0.35rem 1.5rem;
  user-select: none;
}

.sidebar-brand-mark {
  flex: 0 0 auto;
  width: 32px;
  height: 32px;
  display: block;
}

.sidebar-brand-text {
  font-family: var(--display);
  font-weight: 900;
  font-stretch: condensed;
  letter-spacing: 0.02em;
  text-transform: uppercase;
  text-align: left;
  color: #000;
  -webkit-text-stroke: 1.15px var(--accent);
  line-height: 1.05;
}

.sidebar-brand-line {
  display: block;
  font-size: 1.22rem;
}

.sidebar-close {
  display: none;
  flex: 0 0 auto;
  width: 44px;
  height: 44px;
  margin: -0.35rem -0.15rem 0 0;
  padding: 0;
  border: 1px solid transparent;
  background: transparent;
  color: var(--muted);
  font-size: 1.6rem;
  font-weight: 400;
  line-height: 1;
  cursor: pointer;
}
.sidebar-close:hover {
  filter: none;
  color: var(--ink);
  border-color: var(--line);
}

.sidebar-nav {
  flex: 1 1 auto;
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  padding: 0 0.2rem;
  min-height: 0;
  overflow-x: hidden;
  overflow-y: auto;
  scrollbar-width: none;
  -ms-overflow-style: none;
}
.sidebar-nav::-webkit-scrollbar {
  display: none;
}

.nav-tab {
  width: 100%;
  margin: 0;
  padding: 0.55rem 0.85rem;
  min-height: 44px;
  text-align: left;
  background: transparent;
  color: var(--muted);
  border: 1px solid transparent;
  font-weight: 600;
  font-size: 0.9rem;
  border-radius: 23px;
  cursor: pointer;
}
.nav-tab:hover {
  filter: none;
  color: var(--ink);
  background: rgba(61, 214, 140, 0.08);
  border-color: rgba(61, 214, 140, 0.12);
}
.nav-tab.active {
  color: var(--accent);
  background: rgba(61, 214, 140, 0.14);
  border-color: rgba(61, 214, 140, 0.28);
  box-shadow: inset 3px 0 0 var(--accent);
}

.sidebar-profile {
  flex-shrink: 0;
  position: relative;
  z-index: 0;
  margin-top: 0.85rem;
  padding: 0.85rem 0.8rem 0.75rem;
  overflow: hidden;
  isolation: isolate;
  border: 1px solid var(--line);
  border-radius: 17px;
  background: rgba(8, 14, 12, 0.9);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  box-shadow: 0 0 0 1px rgba(8, 20, 14, 0.25);
  pointer-events: none;
  user-select: none;
}

.sidebar-profile::before,
.sidebar-profile::after {
  content: "";
  position: absolute;
  border-radius: 50%;
  pointer-events: none;
  z-index: 0;
  filter: blur(36px);
}

.sidebar-profile::before {
  width: 120px;
  height: 120px;
  top: -48px;
  left: -36px;
  background: rgba(61, 214, 140, 0.55);
}

.sidebar-profile::after {
  width: 100px;
  height: 100px;
  right: -40px;
  bottom: -44px;
  background: rgba(31, 122, 82, 0.5);
}

.sidebar-profile-top,
.sidebar-profile-online {
  position: relative;
  z-index: 1;
}

.sidebar-profile-top {
  display: flex;
  align-items: center;
  gap: 0.7rem;
  min-width: 0;
}

.sidebar-avatar {
  flex: 0 0 40px;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: rgba(138, 163, 150, 0.18);
  border: 1px solid rgba(138, 163, 150, 0.28);
  overflow: hidden;
  position: relative;
}

.sidebar-avatar-img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: 50%;
}

.sidebar-avatar-img[hidden] {
  display: none;
}

.sidebar-profile-meta {
  min-width: 0;
  flex: 1 1 auto;
}

.sidebar-nickname {
  margin: 0;
  font-weight: 700;
  font-size: 0.9rem;
  color: var(--ink);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.sidebar-position {
  margin: 0.15rem 0 0;
  font-size: 0.75rem;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.sidebar-profile-online {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  margin-top: 0.65rem;
  min-width: 0;
}

.online-dot {
  flex: 0 0 8px;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--accent);
  transform-origin: center;
  animation: online-pulse 1.4s ease-in-out infinite;
}

.online-dot--off {
  background: var(--danger);
}

@keyframes online-pulse {
  0%,
  100% {
    transform: scale(1);
    opacity: 1;
  }
  50% {
    transform: scale(1.45);
    opacity: 0.55;
  }
}

@media (prefers-reduced-motion: reduce) {
  .online-dot,
  .online-dot--off {
    animation: none;
  }
}

.sidebar-email {
  font-size: 0.72rem;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.app-main {
  flex: 1 1 auto;
  min-width: 0;
  display: flex;
  flex-direction: column;
  height: 100%;
  overflow: hidden;
}

.app-header {
  flex-shrink: 0;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.75rem;
  padding: 1.15rem 1.5rem;
  border-bottom: 1px solid var(--line);
  background: rgba(5, 8, 7, 0.55);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
}

.app-header-left {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  min-width: 0;
  flex: 1 1 auto;
}

.menu-toggle {
  display: none;
  flex: 0 0 auto;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  gap: 5px;
  width: 44px;
  height: 44px;
  margin: 0;
  padding: 0;
  border: 1px solid var(--line);
  background: transparent;
  color: var(--ink);
  cursor: pointer;
}
.menu-toggle:hover {
  filter: none;
  border-color: var(--accent-dim);
  color: var(--accent);
}
.menu-toggle-bar {
  display: block;
  width: 18px;
  height: 2px;
  background: currentColor;
}

.app-title {
  margin: 0;
  font-size: 1.35rem;
  font-weight: 700;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.app-content {
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  flex-direction: column;
  overflow-x: hidden;
  overflow-y: auto;
  padding: 1.35rem 1.5rem 2.5rem;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: thin;
  scrollbar-color: rgba(61, 214, 140, 0.25) transparent;
}
.app-content::-webkit-scrollbar {
  width: 6px;
}
.app-content::-webkit-scrollbar-thumb {
  background: rgba(61, 214, 140, 0.25);
}

.panel { display: none; }
.panel.active { display: block; }

/* —— Управление ботами —— */
#tab-bots.panel.active {
  display: flex;
  flex-direction: column;
  flex: 1 1 auto;
  align-self: stretch;
  min-height: 0;
  height: 100%;
}

#tab-bots.panel.active > h2 {
  flex: 0 0 auto;
}

.bots-layout {
  display: flex;
  align-items: stretch;
  flex: 1 1 auto;
  min-height: 0;
  gap: 0.85rem;
  margin-top: 0.75rem;
  width: 100%;
  max-width: none;
}

.bots-column {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  flex: 0 1 560px;
  width: 560px;
  max-width: 100%;
  gap: 0.85rem;
  min-width: 0;
  min-height: 0;
}

.bots-logs {
  display: flex;
  flex-direction: column;
  flex: 1 1 auto;
  min-width: 0;
  min-height: 0;
  padding: 1.1rem 1.15rem;
  border: 1px solid var(--line);
  border-radius: var(--radius-card);
  background: rgba(8, 14, 12, 0.55);
  box-shadow: 0 0 0 1px rgba(8, 20, 14, 0.25);
}

.bots-logs-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  flex: 0 0 auto;
  margin-bottom: 0.75rem;
}

.bots-logs-title {
  margin: 0;
  font-size: 1.05rem;
  font-weight: 800;
  line-height: 1.25;
  letter-spacing: 0.01em;
  color: var(--ink);
}

.bots-logs-body {
  flex: 1 1 auto;
  min-height: 120px;
  overflow: auto;
  border-radius: 12px;
  padding: 0.55rem 0.45rem;
  background: rgba(0, 0, 0, 0.22);
  border: 1px solid rgba(138, 163, 150, 0.12);
  display: flex;
  flex-direction: column;
  gap: 0.55rem;
}

.bots-logs-placeholder {
  margin: 0;
  padding: 0.35rem 0.3rem;
  font-size: 0.85rem;
  font-weight: 500;
  line-height: 1.4;
  color: var(--muted);
}

.bots-events-list {
  display: flex;
  flex-direction: column;
  gap: 0.55rem;
}

.bots-event-card {
  position: relative;
  display: flex;
  align-items: stretch;
  gap: 0.5rem;
  padding: 0.65rem 0.75rem;
  padding-right: 2.1rem;
  border-radius: 18px;
  border: 1px solid rgba(138, 163, 150, 0.22);
  background: rgba(6, 12, 10, 0.72);
  box-shadow: 0 0 0 1px rgba(8, 20, 14, 0.2);
  min-width: 0;
}

.bots-event-card-main {
  display: flex;
  align-items: flex-start;
  gap: 0.65rem;
  flex: 1 1 auto;
  min-width: 0;
}

.bots-event-avatar {
  flex: 0 0 36px;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  overflow: hidden;
  background: rgba(0, 0, 0, 0.35);
  border: 1px solid rgba(138, 163, 150, 0.25);
  display: flex;
  align-items: center;
  justify-content: center;
}

.bots-event-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.bots-event-avatar-fallback {
  font-size: 0.72rem;
  font-weight: 800;
  color: var(--muted);
  letter-spacing: 0.02em;
  user-select: none;
}

.bots-event-content {
  flex: 1 1 auto;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
}

.bots-event-name {
  font-size: 0.88rem;
  font-weight: 800;
  line-height: 1.25;
  color: var(--ink);
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.35rem;
  min-width: 0;
}

.bots-event-name-text {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  min-width: 0;
  flex: 0 1 auto;
}

.bots-event-restart-label {
  flex: 0 0 auto;
  font-size: 0.72rem;
  font-weight: 800;
  line-height: 1.2;
  color: #ff4d5e;
  letter-spacing: 0.01em;
}

.bots-event-reason {
  font-size: 0.8rem;
  font-weight: 500;
  line-height: 1.35;
  color: rgba(220, 236, 226, 0.88);
  word-break: break-word;
}

.bots-event-time {
  font-size: 0.72rem;
  font-weight: 500;
  line-height: 1.3;
  color: var(--muted);
  margin-top: 0.1rem;
}

.bots-event-badge {
  position: absolute;
  top: 50%;
  right: 0.65rem;
  transform: translateY(-50%);
  flex: 0 0 auto;
  width: 1.35rem;
  height: 1.35rem;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.95rem;
  font-weight: 900;
  line-height: 1;
  border-radius: 50%;
  user-select: none;
  pointer-events: none;
}

/* Error / warning — neon red */
.bots-event-card--error,
.bots-event-card--warning {
  border-color: rgba(255, 72, 88, 0.72);
  box-shadow:
    0 0 0 1px rgba(255, 72, 88, 0.28),
    0 0 14px rgba(255, 60, 80, 0.22),
    inset 0 0 18px rgba(255, 40, 60, 0.06);
}

.bots-event-card--error .bots-event-badge,
.bots-event-card--warning .bots-event-badge {
  color: #ff4d5e;
  text-shadow:
    0 0 6px rgba(255, 77, 94, 0.95),
    0 0 14px rgba(255, 40, 60, 0.65);
}

/* User actions — muted accent blue-green */
.bots-event-card--user_action {
  border-color: rgba(92, 200, 255, 0.42);
  box-shadow:
    0 0 0 1px rgba(92, 200, 255, 0.16),
    0 0 10px rgba(92, 200, 255, 0.1);
}

.bots-event-card--user_action .bots-event-reason {
  color: rgba(180, 228, 255, 0.92);
}

/* Info — subtle green */
.bots-event-card--info {
  border-color: rgba(61, 214, 140, 0.38);
  box-shadow:
    0 0 0 1px rgba(61, 214, 140, 0.14),
    0 0 10px rgba(61, 214, 140, 0.08);
}

.bots-event-card--info .bots-event-reason {
  color: rgba(180, 240, 210, 0.9);
}

/* Self restart / reconnect — muted, no neon */
.bots-event-card--neutral {
  border-color: rgba(138, 163, 150, 0.22);
  box-shadow: 0 0 0 1px rgba(8, 20, 14, 0.2);
  background: rgba(6, 12, 10, 0.68);
}

.bots-event-card--neutral .bots-event-reason {
  color: rgba(200, 214, 206, 0.82);
}

/* Crash / join fail — bright red + pulsing badge */
.bots-event-card--critical {
  border-color: rgba(255, 48, 64, 0.95);
  box-shadow:
    0 0 0 1px rgba(255, 48, 64, 0.55),
    0 0 20px rgba(255, 32, 48, 0.38),
    inset 0 0 16px rgba(255, 24, 40, 0.08);
}

.bots-event-card--critical .bots-event-reason {
  color: rgba(255, 196, 202, 0.95);
}

.bots-event-card--critical .bots-event-badge {
  color: #ff3040;
  text-shadow:
    0 0 8px rgba(255, 48, 64, 1),
    0 0 18px rgba(255, 24, 40, 0.85);
  animation: bots-event-critical-pulse 1.35s ease-in-out infinite;
}

@keyframes bots-event-critical-pulse {
  0%,
  100% {
    opacity: 1;
    transform: translateY(-50%) scale(1);
  }
  50% {
    opacity: 0.55;
    transform: translateY(-50%) scale(1.12);
  }
}

.bots-card {
  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: 0.9rem;
  width: 100%;
  min-height: 72px;
  padding: 0.95rem 1.1rem;
  border: 1px solid var(--line);
  border-radius: var(--radius-card);
  background: rgba(8, 14, 12, 0.55);
  box-shadow: 0 0 0 1px rgba(8, 20, 14, 0.25);
}

.bots-card--main {
  position: relative;
  z-index: 0;
  isolation: isolate;
  overflow: hidden;
  flex: 0 0 auto;
  min-height: 120px;
  padding: 1.25rem 1.35rem;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  border-radius: 17px;
}

/* Soft green blobs inside main bots card only (like login / sidebar profile) */
.bots-card--main::before,
.bots-card--main::after {
  content: "";
  position: absolute;
  border-radius: 50%;
  pointer-events: none;
  z-index: 0;
  filter: blur(36px);
}

.bots-card--main::before {
  width: 160px;
  height: 160px;
  top: -56px;
  left: -44px;
  background: rgba(61, 214, 140, 0.55);
}

.bots-card--main::after {
  width: 130px;
  height: 130px;
  right: -48px;
  bottom: -52px;
  background: rgba(31, 122, 82, 0.5);
}

.bots-card--main > * {
  position: relative;
  z-index: 1;
}

.bots-card-main-aside {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  justify-content: center;
  gap: 0.55rem;
  flex: 0 1 auto;
  min-width: 0;
}

.bots-card-updated {
  font-size: 0.78rem;
  font-weight: 400;
  line-height: 1.3;
  color: var(--muted);
  white-space: nowrap;
  text-align: right;
}

.bots-card-main-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 0.45rem;
}

.bots-card-btn {
  width: auto;
  margin-top: 0;
  padding: 0.5rem 0.9rem;
  min-height: 40px;
  border-radius: 15px;
  font-size: 0.82rem;
  font-weight: 700;
  white-space: nowrap;
}

.bots-card-btn--primary {
  border: none;
  background: var(--accent);
  color: #062015;
}

.bots-card-btn--primary:hover {
  filter: brightness(1.05);
}

.bots-card-btn--secondary {
  background: transparent;
  color: var(--ink);
  border: 1px solid var(--line);
  font-weight: 600;
}

.bots-card-btn--secondary:hover {
  border-color: var(--accent-dim);
  color: var(--accent);
  filter: none;
}

@media (max-width: 768px) {
  .bots-card--main::before,
  .bots-card--main::after {
    content: none;
    display: none;
  }
}

.bots-card-avatar {
  flex: 0 0 auto;
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: rgba(138, 163, 150, 0.16);
  border: 1px solid rgba(138, 163, 150, 0.28);
  overflow: hidden;
  position: relative;
}

.bots-card-avatar-img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: 50%;
}

.bots-card-avatar-img[hidden] {
  display: none;
}

.bots-card-meta {
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 0.18rem;
  min-width: 0;
  flex: 1 1 auto;
}

.bots-card-name-row {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  min-width: 0;
}

.bots-card-name {
  font-size: 0.95rem;
  font-weight: 700;
  line-height: 1.25;
  color: var(--ink);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  min-width: 0;
  flex: 0 1 auto;
}

.bots-card-presence {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  flex: 0 0 auto;
  min-width: 0;
}

/* Same pulse as profile online — higher specificity so reduced-motion
   base `.online-dot { animation: none }` does not kill it. */
.bots-card-presence .online-dot {
  flex: 0 0 8px;
  width: 8px;
  height: 8px;
  transform-origin: center;
  animation: online-pulse 1.4s ease-in-out infinite;
}

.bots-card-presence-label {
  font-size: 0.72rem;
  font-weight: 600;
  line-height: 1.2;
  color: var(--accent);
  white-space: nowrap;
}

.bots-card-presence[data-in-room="false"] .bots-card-presence-label {
  color: var(--danger);
}

.bots-card-presence.bots-slot-status--restarting .bots-card-presence-label,
.bots-card-presence[data-restarting="true"] .bots-card-presence-label {
  color: #6eb0f0;
}

.bots-card-presence .online-dot--restarting {
  background: #6eb0f0;
  transform-origin: center;
  animation: online-pulse 1.4s ease-in-out infinite;
}

@media (prefers-reduced-motion: reduce) {
  .bots-card-presence .online-dot--restarting {
    animation: none;
  }
}

.bots-card-active {
  flex: 0 1 auto;
  min-width: 0;
  font-size: 1.55rem;
  font-weight: 800;
  line-height: 1.2;
  letter-spacing: 0.01em;
  color: var(--ink);
  white-space: nowrap;
  text-align: left;
}

.bots-card-id,
.bots-card-token {
  font-size: 0.78rem;
  font-weight: 400;
  line-height: 1.3;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.bots-card-actions {
  display: flex;
  flex-direction: row;
  align-items: center;
  justify-content: flex-end;
  gap: 0.35rem;
  flex: 0 0 auto;
  margin-left: auto;
}

.bots-slot-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  min-height: 0;
  margin: 0;
  padding: 0;
  border: 1px solid transparent;
  border-radius: 12px;
  cursor: pointer;
  flex: 0 0 auto;
  transition: filter 0.15s ease, border-color 0.15s ease, background 0.15s ease;
}

.bots-slot-btn-icon {
  width: 15px;
  height: 15px;
  display: block;
}

.bots-slot-btn--start {
  background: rgba(61, 214, 140, 0.2);
  color: var(--accent);
  border-color: rgba(61, 214, 140, 0.42);
}

.bots-slot-btn--start:hover {
  background: rgba(61, 214, 140, 0.32);
  filter: none;
}

.bots-slot-btn--stop {
  background: rgba(232, 106, 90, 0.18);
  color: var(--danger);
  border-color: rgba(232, 106, 90, 0.4);
}

.bots-slot-btn--stop:hover {
  background: rgba(232, 106, 90, 0.3);
  filter: none;
}

.bots-slot-btn--restart {
  background: rgba(90, 157, 232, 0.18);
  color: #6eb0f0;
  border-color: rgba(90, 157, 232, 0.42);
}

.bots-slot-btn--restart:hover {
  background: rgba(90, 157, 232, 0.3);
  filter: none;
}

.bots-slot-btn:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.bots-grid {
  display: flex;
  flex-direction: column;
  flex: 1 1 auto;
  min-height: 0;
  gap: 0.75rem;
  width: 100%;
  max-width: none;
  align-self: stretch;
}

.bots-grid .bots-card {
  flex: 1 1 0;
  min-height: 64px;
  border: 1.5px solid #5cffb0;
  box-shadow:
    0 0 12px rgba(92, 255, 176, 0.14),
    0 0 28px rgba(92, 255, 176, 0.06);
}

@media (max-width: 900px) {
  .bots-layout {
    flex-direction: column;
    max-width: none;
  }

  .bots-column {
    flex: 0 0 auto;
    width: 100%;
  }

  .bots-logs {
    flex: 1 1 auto;
    min-height: 220px;
  }
}

@media (max-width: 560px) {
  .bots-layout {
    max-width: 100%;
  }

  .bots-grid {
    max-width: 100%;
  }

  .bots-logs {
    padding: 0.95rem 1rem;
    min-height: 200px;
  }

  .bots-logs-title {
    font-size: 0.98rem;
  }

  .bots-event-card {
    padding: 0.6rem 0.65rem;
    padding-right: 1.95rem;
    border-radius: 16px;
  }

  .bots-event-avatar {
    flex: 0 0 32px;
    width: 32px;
    height: 32px;
  }

  .bots-event-name {
    font-size: 0.84rem;
  }

  .bots-event-reason {
    font-size: 0.76rem;
  }

  .bots-card {
    gap: 0.75rem;
    padding: 0.85rem 0.95rem;
  }

  .bots-card-avatar {
    width: 40px;
    height: 40px;
  }

  .bots-card--main {
    min-height: 100px;
    flex-direction: column;
    align-items: stretch;
    justify-content: flex-start;
    gap: 0.85rem;
    border-radius: 16px;
  }

  .bots-card-main-aside {
    align-items: stretch;
  }

  .bots-card-updated {
    text-align: left;
  }

  .bots-card-main-actions {
    justify-content: stretch;
  }

  .bots-card-btn {
    flex: 1 1 auto;
    min-width: 0;
    padding: 0.55rem 0.7rem;
    font-size: 0.78rem;
  }

  .bots-grid .bots-card {
    border-radius: max(24px, calc(var(--radius-card) - 10px));
  }

  .bots-card-name {
    font-size: 0.9rem;
  }

  .bots-card-active {
    font-size: 1.28rem;
  }

  .bots-card-id,
  .bots-card-token {
    font-size: 0.72rem;
  }

  .bots-card-actions {
    gap: 0.28rem;
  }

  .bots-slot-btn {
    width: 30px;
    height: 30px;
    border-radius: 10px;
  }

  .bots-slot-btn-icon {
    width: 13px;
    height: 13px;
  }
}

.profile-layout {
  display: grid;
  grid-template-columns: minmax(0, 1180px) minmax(0, 1fr);
  grid-template-rows: auto auto auto;
  gap: 1rem;
  width: 100%;
  max-width: 100%;
  min-width: 0;
  align-items: stretch;
}

.profile-top-main {
  grid-column: 1;
  grid-row: 1;
  display: flex;
  flex-direction: column;
  gap: 1rem;
  min-width: 0;
  max-width: none;
}

.profile-shifts {
  grid-column: 2;
  grid-row: 1;
  border: 1px solid var(--line);
  border-radius: var(--radius-card);
  background: rgba(8, 14, 12, 0.55);
  box-shadow: 0 0 0 1px rgba(8, 20, 14, 0.25);
  padding: 1.1rem 1.2rem 1.2rem;
  display: flex;
  flex-direction: column;
  width: auto;
  min-width: 0;
  max-width: none;
  min-height: 0;
  /* row 1: height matches left stack through Highrise */
  align-self: stretch;
}

.profile-shifts-empty {
  margin: auto 0;
  padding: 1.5rem 0.5rem;
  text-align: center;
  font-size: 0.95rem;
}

.profile-issued-warns {
  grid-column: 2;
  grid-row: 2 / 4;
  border: 1px solid var(--line);
  border-radius: var(--radius-card);
  background: rgba(8, 14, 12, 0.55);
  box-shadow: 0 0 0 1px rgba(8, 20, 14, 0.25);
  padding: 1.1rem 1.2rem 1.2rem;
  display: flex;
  flex-direction: column;
  width: auto;
  min-width: 0;
  max-width: none;
  min-height: 0;
  /* spans Telegram + account forms; bottom aligns with Смена пароля */
  align-self: stretch;
}

.profile-issued-warns-empty {
  margin: auto 0;
  padding: 1.5rem 0.5rem;
  text-align: center;
  font-size: 0.95rem;
}

.profile-card {
  display: flex;
  align-items: center;
  gap: 1.15rem;
  width: 100%;
  padding: 1.25rem 1.35rem;
  border: 1px solid var(--line);
  border-radius: var(--radius-card);
  background: rgba(8, 14, 12, 0.55);
  box-shadow: 0 0 0 1px rgba(8, 20, 14, 0.25);
}

.profile-card-dates {
  margin-left: auto;
  flex: 0 1 auto;
  max-width: 280px;
  text-align: right;
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  min-width: 0;
}

.profile-card-date-line {
  margin: 0;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 0.15rem;
  font-size: 0.78rem;
  line-height: 1.4;
  color: var(--muted);
  overflow-wrap: normal;
  word-break: normal;
}

.profile-card-date-label {
  display: block;
  color: #fff;
  font-weight: 700;
}

.profile-card-date-value {
  display: block;
  color: var(--muted);
  font-weight: 400;
  white-space: nowrap;
}

.profile-below {
  display: grid;
  grid-template-columns: minmax(0, 1.4fr) minmax(0, 0.85fr);
  gap: 1rem;
  /* equal-height sessions + stats only; Смены stays outside this row */
  align-items: stretch;
  min-width: 0;
}

/* Mid desktop: keep Смены/варны right column, stack sessions/stats when content is tight */
@media (min-width: 769px) and (max-width: 1100px) {
  .profile-layout {
    grid-template-columns: minmax(0, 1.25fr) minmax(200px, 0.85fr);
  }
  .profile-below {
    grid-template-columns: minmax(0, 1fr);
  }
}

.profile-sessions,
.profile-stats {
  border: 1px solid var(--line);
  border-radius: var(--radius-card);
  background: rgba(8, 14, 12, 0.55);
  box-shadow: 0 0 0 1px rgba(8, 20, 14, 0.25);
  padding: 1.1rem 1.2rem 1.2rem;
  min-height: 0;
  display: flex;
  flex-direction: column;
}

.profile-sessions {
  min-height: 220px;
}

.profile-sessions-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  margin-bottom: 0.85rem;
}

.profile-sessions-header .profile-block-title {
  margin: 0;
}

.profile-block-title {
  margin: 0 0 0.85rem;
  font-family: var(--display);
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--ink);
  letter-spacing: 0.01em;
}

.profile-period-dropdown {
  position: relative;
  flex: 0 0 auto;
}

.profile-period-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  width: auto;
  margin: 0;
  padding: 0.35rem 0.75rem;
  min-height: 0;
  border: 1px solid #3dff9a;
  border-radius: 15px;
  background: rgba(61, 214, 140, 0.18);
  box-shadow:
    0 0 6px rgba(61, 255, 154, 0.55),
    0 0 14px rgba(61, 255, 154, 0.35),
    inset 0 0 8px rgba(61, 255, 154, 0.12);
  color: #fff;
  font-size: 0.82rem;
  font-weight: 700;
  line-height: 1.2;
  cursor: pointer;
  white-space: nowrap;
}

.profile-period-btn:hover {
  background: rgba(61, 214, 140, 0.26);
  box-shadow:
    0 0 8px rgba(61, 255, 154, 0.7),
    0 0 18px rgba(61, 255, 154, 0.45),
    inset 0 0 10px rgba(61, 255, 154, 0.16);
}

.profile-period-btn[aria-expanded="true"] {
  background: rgba(61, 214, 140, 0.28);
  box-shadow:
    0 0 8px rgba(61, 255, 154, 0.75),
    0 0 20px rgba(61, 255, 154, 0.5),
    inset 0 0 10px rgba(61, 255, 154, 0.18);
}

.profile-period-arrow {
  display: inline-block;
  width: 0;
  height: 0;
  border-left: 4px solid transparent;
  border-right: 4px solid transparent;
  border-top: 5px solid #fff;
  margin-top: 1px;
  transition: transform 0.15s ease;
}

.profile-period-btn[aria-expanded="true"] .profile-period-arrow {
  transform: rotate(180deg);
}

.profile-period-menu {
  position: absolute;
  top: calc(100% + 0.35rem);
  right: 0;
  z-index: 20;
  list-style: none;
  margin: 0;
  padding: 0.3rem;
  min-width: 100%;
  border: 1px solid #3dff9a;
  border-radius: 15px;
  background: rgba(61, 214, 140, 0.14);
  box-shadow:
    0 0 6px rgba(61, 255, 154, 0.55),
    0 0 16px rgba(61, 255, 154, 0.35),
    0 8px 24px rgba(0, 0, 0, 0.45);
  backdrop-filter: blur(8px);
}

.profile-period-menu[hidden] {
  display: none !important;
}

.profile-period-menu li {
  padding: 0.45rem 0.7rem;
  border-radius: 10px;
  color: var(--ink);
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
}

.profile-period-menu li:hover {
  background: rgba(61, 214, 140, 0.18);
}

.profile-period-menu li[aria-selected="true"] {
  background: rgba(61, 214, 140, 0.45);
  color: #fff;
}

.profile-sessions-list {
  list-style: none;
  margin: 0;
  padding: 0;
  flex: 1 1 auto;
  display: flex;
  flex-direction: column;
  gap: 0.55rem;
}

.profile-sessions-empty {
  margin: auto 0;
  padding: 1.5rem 0.5rem;
  text-align: center;
  font-size: 0.95rem;
}

.profile-session-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.7rem 0.85rem;
  border: 1px solid rgba(138, 163, 150, 0.18);
  border-radius: 10px;
  background: rgba(6, 12, 10, 0.45);
  font-size: 0.88rem;
  line-height: 1.3;
}

.profile-session-row.is-active {
  border-color: rgba(61, 255, 154, 0.35);
  background: rgba(61, 214, 140, 0.08);
  box-shadow: 0 0 10px rgba(61, 255, 154, 0.08);
}

.profile-session-row.is-daily-fallback .profile-session-range {
  color: var(--muted);
  font-weight: 500;
  font-size: 0.84rem;
}

.profile-session-range {
  flex: 1 1 auto;
  min-width: 0;
  color: var(--ink);
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.01em;
}

.profile-session-duration {
  flex: 0 0 auto;
  color: var(--muted);
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.profile-session-item {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 0.35rem 0.75rem;
  padding: 0.65rem 0.75rem;
  border: 1px solid rgba(138, 163, 150, 0.18);
  border-radius: 8px;
  background: rgba(6, 12, 10, 0.4);
  font-size: 0.88rem;
}

.profile-session-item strong {
  color: var(--ink);
  font-weight: 600;
}

.profile-db-status {
  margin: 0 0 0.65rem;
  font-size: 0.78rem;
  line-height: 1.35;
  color: var(--muted);
}

.profile-db-status.is-warning,
.profile-db-status.is-error {
  color: #b45309;
}

.profile-stats-list {
  margin: 0;
  flex: 1 1 auto;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.profile-stat-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 0.5rem 0.85rem;
  align-items: baseline;
  padding-bottom: 0.7rem;
  border-bottom: 1px solid rgba(138, 163, 150, 0.14);
}

.profile-stat-row:last-child {
  padding-bottom: 0;
  border-bottom: none;
}

.profile-stat-row dt {
  margin: 0;
  font-size: 0.88rem;
  color: var(--muted);
  line-height: 1.35;
}

.profile-stat-row dd {
  margin: 0;
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--ink);
  text-align: right;
  line-height: 1.35;
  word-break: break-word;
}

.profile-highrise {
  width: 100%;
  max-width: none;
  border: 1px solid var(--line);
  border-radius: var(--radius-card);
  background: rgba(8, 14, 12, 0.55);
  box-shadow: 0 0 0 1px rgba(8, 20, 14, 0.25);
  padding: 1.1rem 1.2rem 1.25rem;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 0.85rem;
}

.profile-telegram {
  grid-column: 1;
  grid-row: 2;
  max-width: none;
}

.profile-highrise .profile-block-title {
  margin-bottom: 0;
}

.profile-highrise-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.85rem 1rem;
}

.profile-highrise-identity {
  display: flex;
  align-items: center;
  gap: 0.85rem;
  min-width: 0;
  flex: 1 1 auto;
}

.profile-highrise-avatar {
  flex: 0 0 52px;
  width: 52px;
  height: 52px;
  border-radius: 50%;
  background: rgba(138, 163, 150, 0.12);
  border: 1px solid rgba(138, 163, 150, 0.22);
  overflow: hidden;
  position: relative;
}

.profile-highrise-avatar-img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: 50%;
}

.profile-highrise-avatar-img[hidden] {
  display: none;
}

.profile-highrise-meta {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
}

.profile-highrise-nick {
  margin: 0;
  font-size: 1rem;
  font-weight: 600;
  color: var(--ink);
  line-height: 1.3;
  word-break: break-word;
}

.profile-highrise-nick.muted {
  font-weight: 500;
  color: var(--muted);
}

.profile-highrise-id {
  margin: 0;
  font-size: 0.82rem;
  line-height: 1.35;
  color: var(--muted);
  word-break: break-all;
}

.profile-highrise #profile-highrise-btn {
  margin-top: 0;
  min-height: 40px;
  width: auto;
  flex: 0 0 auto;
  padding: 0.55rem 1.1rem;
  font-size: 0.9rem;
  border-radius: 999px;
}

.profile-highrise #profile-highrise-btn.is-unlink {
  background: transparent;
  color: #e8a09a;
  border: 1px solid rgba(232, 106, 90, 0.38);
  box-shadow: none;
}

.profile-highrise #profile-highrise-btn.is-unlink:hover {
  filter: none;
  background: rgba(232, 106, 90, 0.1);
  border-color: rgba(232, 106, 90, 0.55);
  color: #f0b8b2;
}

.profile-telegram #profile-telegram-btn {
  margin-top: 0;
  min-height: 40px;
  width: auto;
  flex: 0 0 auto;
  padding: 0.55rem 1.1rem;
  font-size: 0.9rem;
  border-radius: 999px;
}

.profile-telegram #profile-telegram-btn.is-unlink {
  background: transparent;
  color: #e8a09a;
  border: 1px solid rgba(232, 106, 90, 0.38);
  box-shadow: none;
}

.profile-telegram #profile-telegram-btn.is-unlink:hover {
  filter: none;
  background: rgba(232, 106, 90, 0.1);
  border-color: rgba(232, 106, 90, 0.55);
  color: #f0b8b2;
}

.profile-telegram-avatar {
  display: flex;
  align-items: center;
  justify-content: center;
  color: rgba(138, 163, 150, 0.85);
}

.profile-telegram-icon {
  display: block;
  opacity: 0.9;
}

.profile-account-forms {
  grid-column: 1;
  grid-row: 3;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1rem;
  width: 100%;
  max-width: none;
  align-items: stretch;
}

.profile-account-card {
  border: 1px solid var(--line);
  border-radius: var(--radius-card);
  background: rgba(8, 14, 12, 0.55);
  box-shadow: 0 0 0 1px rgba(8, 20, 14, 0.25);
  padding: 1.1rem 1.2rem 1.25rem;
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
  min-height: 0;
  height: 100%;
}

.profile-account-card .profile-block-title {
  margin-bottom: 0;
}

.profile-account-form {
  display: flex;
  flex-direction: column;
  gap: 0.55rem;
  margin: 0;
  flex: 1 1 auto;
  min-height: 0;
}

.profile-current-email {
  margin: 0 0 0.15rem;
  font-size: 0.88rem;
  line-height: 1.45;
  word-break: break-word;
}

.profile-current-email-label {
  margin-right: 0.35rem;
  color: #fff;
  font-weight: 700;
}

.profile-account-form label {
  font-size: 0.88rem;
  color: var(--muted);
}

.profile-account-form input {
  width: 100%;
}

.profile-account-form button[type="submit"] {
  margin-top: auto;
  width: auto;
  align-self: flex-start;
  min-height: 40px;
  padding: 0.55rem 1.1rem;
  font-size: 0.9rem;
}

.highrise-link-form {
  margin-top: 1rem;
  text-align: left;
  display: flex;
  flex-direction: column;
  gap: 0.55rem;
}

.highrise-link-form label {
  font-size: 0.88rem;
  color: var(--muted);
}

.highrise-link-form input {
  width: 100%;
}

.highrise-link-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.55rem;
  margin-top: 0.5rem;
}

.highrise-link-actions button {
  margin-top: 0;
  flex: 1 1 auto;
  min-width: 120px;
}

.profile-card-avatar {
  flex: 0 0 88px;
  width: 88px;
  height: 88px;
  border-radius: 50%;
  background: rgba(138, 163, 150, 0.14);
  border: 1px solid rgba(138, 163, 150, 0.26);
  overflow: hidden;
  position: relative;
}

.profile-card-avatar-img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: 50%;
}

.profile-card-avatar-img[hidden] {
  display: none;
}

.profile-card-meta {
  min-width: 0;
  flex: 1 1 auto;
}

.profile-card-nickname {
  margin: 0;
  font-family: var(--display);
  font-weight: 700;
  font-size: 1.2rem;
  color: var(--ink);
  line-height: 1.25;
  overflow-wrap: normal;
  word-break: normal;
}

.profile-card-position {
  margin: 0.4rem 0 0;
  font-size: 0.9rem;
  color: var(--muted);
  line-height: 1.35;
  overflow-wrap: normal;
  word-break: normal;
}

.profile-card-online {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-top: 0.45rem;
}

.profile-card-online .online-dot {
  flex: 0 0 12px;
  width: 12px;
  height: 12px;
  animation: online-pulse 1.4s ease-in-out infinite;
}

.profile-card-online-label {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--accent);
  line-height: 1.2;
}

.profile-card-offline-label {
  font-size: 0.85rem;
  font-weight: 600;
  line-height: 1.2;
}

.profile-view-other {
  width: 100%;
  margin-bottom: 0.75rem;
}

.profile-back-staff-btn {
  width: auto;
  margin-top: 0;
  margin-bottom: 0.15rem;
  border-radius: 999px;
  border: 1.5px solid rgba(92, 255, 176, 0.35);
}

.profile-layout.profile-view-other .profile-account-forms {
  display: none;
}

/* Profile: single column + mobile stack order (≤768px). Desktop 2-col intact ≥769px */
@media (max-width: 768px) {
  .profile-layout {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows: none;
    gap: 0.9rem;
    width: 100%;
    max-width: 100%;
    min-width: 0;
    overflow-x: hidden;
  }

  /* Flatten wrappers so blocks can reorder as siblings of the layout grid */
  .profile-top-main,
  .profile-below {
    display: contents;
  }

  .profile-card,
  .profile-sessions,
  .profile-stats,
  .profile-shifts,
  .profile-highrise:not(.profile-telegram),
  .profile-telegram,
  .profile-account-forms,
  .profile-issued-warns {
    grid-column: 1;
    grid-row: auto;
    width: 100%;
    max-width: 100%;
    min-width: 0;
  }

  .profile-card { order: 1; }
  .profile-sessions { order: 2; }
  .profile-stats { order: 3; }
  .profile-shifts { order: 4; }
  .profile-highrise:not(.profile-telegram) { order: 5; }
  .profile-telegram { order: 6; }
  .profile-account-forms { order: 7; }
  .profile-issued-warns { order: 8; }

  .profile-card {
    flex-direction: column;
    flex-wrap: nowrap;
    align-items: stretch;
    gap: 0.95rem;
    padding: 1.1rem 1.15rem;
    box-sizing: border-box;
  }

  .profile-card-avatar {
    align-self: center;
  }

  .profile-card-meta {
    flex: 1 1 auto;
    width: 100%;
    max-width: 100%;
    min-width: 0;
    text-align: center;
  }

  .profile-card-online {
    justify-content: center;
  }

  .profile-card-dates {
    margin-left: 0;
    flex: 1 1 auto;
    width: 100%;
    max-width: none;
    text-align: left;
    padding-top: 0.85rem;
    border-top: 1px solid rgba(138, 163, 150, 0.14);
  }

  .profile-card-date-line {
    align-items: flex-start;
    font-size: 0.8rem;
    overflow-wrap: normal;
    word-break: normal;
  }

  .profile-card-date-label,
  .profile-card-date-value {
    overflow-wrap: normal;
    word-break: normal;
  }

  .profile-card-date-value {
    white-space: normal;
  }

  .profile-card-nickname,
  .profile-card-position {
    overflow-wrap: normal;
    word-break: normal;
  }

  .profile-sessions,
  .profile-stats,
  .profile-shifts,
  .profile-issued-warns,
  .profile-highrise,
  .profile-account-card {
    padding: 1rem 1.05rem 1.1rem;
  }

  .profile-sessions,
  .profile-shifts,
  .profile-issued-warns {
    min-height: 0;
  }

  .profile-sessions-header {
    flex-wrap: wrap;
    align-items: center;
    gap: 0.55rem 0.75rem;
  }

  .profile-period-btn {
    min-height: 40px;
    padding: 0.5rem 0.9rem;
    font-size: 0.85rem;
  }

  .profile-period-menu li {
    min-height: 40px;
    display: flex;
    align-items: center;
    padding: 0.55rem 0.8rem;
    font-size: 0.88rem;
  }

  .profile-highrise-row {
    flex-direction: column;
    align-items: stretch;
  }

  .profile-highrise #profile-highrise-btn,
  .profile-telegram #profile-telegram-btn {
    width: 100%;
    min-height: 44px;
  }

  .profile-account-forms {
    grid-template-columns: minmax(0, 1fr);
    gap: 0.9rem;
  }

  .profile-account-card {
    height: auto;
  }

  .profile-account-form input {
    min-height: 44px;
    font-size: 1rem;
  }

  .profile-account-form button[type="submit"] {
    width: 100%;
    align-self: stretch;
    min-height: 44px;
  }

  .highrise-link-actions button {
    min-width: 0;
    width: 100%;
    min-height: 44px;
  }
}

@media (max-width: 480px) {
  .profile-layout {
    gap: 0.8rem;
  }

  .profile-card {
    gap: 0.85rem;
    padding: 0.95rem 1rem;
  }

  .profile-card-avatar {
    flex-basis: 72px;
    width: 72px;
    height: 72px;
  }

  .profile-card-nickname {
    font-size: 1.05rem;
  }

  .profile-card-position {
    font-size: 0.85rem;
  }

  .profile-card-dates {
    gap: 0.45rem;
  }

  .profile-sessions,
  .profile-stats,
  .profile-shifts,
  .profile-issued-warns,
  .profile-highrise,
  .profile-account-card {
    padding: 0.9rem 0.95rem 1rem;
    border-radius: max(24px, calc(var(--radius-card) - 10px));
  }

  .profile-card {
    border-radius: max(24px, calc(var(--radius-card) - 10px));
  }

  .profile-block-title {
    font-size: 1rem;
  }

  .profile-highrise-avatar {
    flex-basis: 48px;
    width: 48px;
    height: 48px;
  }

  .profile-session-item {
    padding: 0.7rem 0.8rem;
    font-size: 0.86rem;
  }

  .profile-stat-row {
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 0.35rem 0.65rem;
  }

  .profile-stat-row dt {
    font-size: 0.84rem;
  }

  .profile-stat-row dd {
    font-size: 0.9rem;
  }
}

.bots-subtabs {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  margin: 1rem 0 1.1rem;
  padding-bottom: 0.65rem;
  border-bottom: 1px solid var(--line);
}

.bots-subtab {
  width: auto;
  margin: 0;
  padding: 0.55rem 0.85rem;
  min-height: 40px;
  background: transparent;
  color: var(--muted);
  border: 1px solid transparent;
  font-weight: 600;
  font-size: 0.85rem;
}
.bots-subtab:hover {
  filter: none;
  color: var(--ink);
}
.bots-subtab.active {
  color: var(--accent);
  border-color: rgba(61, 214, 140, 0.35);
  background: rgba(61, 214, 140, 0.08);
}

.bots-pane { display: none; }
.bots-pane.active { display: block; }

/* Mobile: off-canvas sidebar drawer + hamburger header */
@media (max-width: 768px) {
  /*
   * Block layout (not flex): fixed sidebar must not reserve horizontal space.
   * With display:flex + flex:none + width:~86vw, some WebKit builds still leave
   * a huge empty left gap and squeeze .app-main into a thin right strip.
   */
  .app-shell,
  #app-view.app-shell {
    position: relative;
    z-index: 2;
    display: block;
    width: 100%;
    max-width: 100%;
    overflow: hidden;
    opacity: 1;
    visibility: visible;
  }

  .app-shell > .sidebar-backdrop,
  .sidebar-backdrop {
    display: block;
    position: fixed;
    inset: 0;
    z-index: 40;
    background: rgba(4, 8, 6, 0.62);
    backdrop-filter: blur(3px);
    -webkit-backdrop-filter: blur(3px);
    border: none;
    padding: 0;
    margin: 0;
    cursor: pointer;
  }
  .sidebar-backdrop[hidden],
  .app-shell > .sidebar-backdrop[hidden] {
    display: none !important;
  }

  /* Higher specificity than any leftover position:relative on .sidebar */
  .app-shell > .sidebar,
  #app-view > .sidebar {
    position: fixed;
    top: 0;
    left: 0;
    z-index: 50;
    width: min(280px, 86vw);
    max-width: min(280px, 86vw);
    flex: unset;
    height: 100%;
    height: 100dvh;
    padding-top: max(1.1rem, env(safe-area-inset-top));
    padding-bottom: max(1rem, env(safe-area-inset-bottom));
    border-right: 1px solid rgba(61, 214, 140, 0.18);
    box-shadow: 12px 0 40px rgba(0, 0, 0, 0.45);
    transform: translateX(-105%);
    transition: transform 0.22s ease;
    will-change: transform;
    /* out of flow — must not push .app-main below the fold */
    margin: 0;
  }
  .app-shell.nav-open > .sidebar,
  #app-view.nav-open > .sidebar {
    transform: translateX(0);
  }

  .app-shell > .app-main,
  #app-view > .app-main {
    position: relative;
    z-index: 2;
    display: flex;
    flex-direction: column;
    width: 100%;
    max-width: 100%;
    min-width: 0;
    height: 100%;
    min-height: 100%;
    margin: 0;
    opacity: 1;
    visibility: visible;
  }

  .sidebar-close {
    display: inline-flex;
    align-items: center;
    justify-content: center;
  }

  .sidebar-brand {
    margin-bottom: 1.15rem;
  }

  .menu-toggle {
    display: inline-flex;
  }

  .app-header {
    padding: 0.75rem 0.9rem;
    padding-left: max(0.9rem, env(safe-area-inset-left));
    padding-right: max(0.9rem, env(safe-area-inset-right));
  }

  .app-title {
    font-size: 1.1rem;
  }

  .app-content {
    padding: 1rem 0.9rem 2rem;
    padding-left: max(0.9rem, env(safe-area-inset-left));
    padding-right: max(0.9rem, env(safe-area-inset-right));
    width: 100%;
    max-width: 100%;
    min-width: 0;
    box-sizing: border-box;
  }

  .app-content::-webkit-scrollbar {
    display: none;
  }
  .app-content {
    scrollbar-width: none;
  }

  button.ghost {
    min-height: 40px;
    padding: 0.45rem 0.75rem;
    flex-shrink: 0;
  }

  .row-between {
    flex-wrap: wrap;
  }

  .toast {
    left: 1rem;
    right: 1rem;
    bottom: max(1rem, env(safe-area-inset-bottom));
    max-width: none;
  }
}

@media (max-width: 768px) and (prefers-reduced-motion: reduce) {
  .app-shell > .sidebar,
  #app-view > .sidebar {
    transition: none;
  }
}

.grid-2 {
  display: grid;
  gap: 1rem;
  grid-template-columns: 1fr;
}

@media (min-width: 769px) {
  .grid-2 { grid-template-columns: 1.2fr 0.8fr; }
}

.action-form, .hint-block {
  border: 1px solid var(--line);
  padding: 1rem;
  background: var(--surface);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
}

.bots-list, .queue-list {
  display: grid;
  gap: 0.6rem;
}

.bot-row, .queue-row {
  display: grid;
  gap: 0.25rem;
  padding: 0.85rem 1rem;
  border: 1px solid var(--line);
  background: rgba(0, 0, 0, 0.25);
}

.bot-row strong { font-family: var(--display); }
.badge {
  display: inline-block;
  font-size: 0.75rem;
  padding: 0.15rem 0.45rem;
  border: 1px solid var(--line);
  color: var(--muted);
}

.badge.pending { color: var(--warn); border-color: rgba(232, 184, 74, 0.4); }
.badge.done { color: var(--accent); border-color: rgba(61, 214, 140, 0.4); }
.badge.error, .badge.cancelled { color: var(--danger); }

.row-between {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
}

.code-block {
  padding: 1rem;
  overflow: auto;
  border: 1px solid var(--line);
  background: rgba(0, 0, 0, 0.35);
  font-size: 0.85rem;
  white-space: pre-wrap;
}

.toast {
  position: fixed;
  bottom: 1.25rem;
  right: 1.25rem;
  padding: 0.75rem 1rem;
  background: var(--accent-dim);
  color: var(--ink);
  border: 1px solid var(--accent);
  max-width: min(360px, calc(100vw - 2rem));
}

code {
  font-size: 0.85em;
  color: var(--accent);
}

/* Staff tab */
.staff-layout {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  width: 100%;
}

.staff-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  flex-wrap: wrap;
}

.staff-count {
  margin: 0;
  font-size: 0.88rem;
}

.staff-refresh-btn {
  flex: 0 0 auto;
  font-size: 0.82rem;
  padding: 0.45rem 0.85rem;
}

.staff-loading {
  margin: 0;
}

.staff-empty {
  padding: 2rem 1.25rem;
  text-align: center;
  border: 1px dashed rgba(138, 163, 150, 0.28);
  border-radius: var(--radius-card);
  background: rgba(8, 14, 12, 0.35);
}

.staff-empty p {
  margin: 0;
}

.staff-grid {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 0.75rem;
  width: 100%;
}

.staff-card {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 0.75rem;
  width: 100%;
  max-width: 520px;
  padding: 1rem 1.1rem;
  border: 1.5px solid rgba(92, 255, 176, 0.35);
  border-radius: var(--radius-card);
  background: rgba(8, 14, 12, 0.55);
  box-shadow:
    0 0 12px rgba(92, 255, 176, 0.1),
    0 0 28px rgba(92, 255, 176, 0.04);
  box-sizing: border-box;
}

.staff-card-body {
  display: flex;
  align-items: flex-start;
  flex-wrap: wrap;
  gap: 0.75rem 0.85rem;
  width: 100%;
  min-width: 0;
}

.staff-card-open-btn {
  width: 100%;
  margin-top: 0;
  border-radius: 999px;
  border: 1.5px solid rgba(92, 255, 176, 0.45);
  background: rgba(8, 14, 12, 0.35);
  color: var(--accent);
  font-weight: 700;
  padding: 0.65rem 1rem;
  box-shadow:
    0 0 10px rgba(92, 255, 176, 0.12),
    inset 0 0 12px rgba(92, 255, 176, 0.04);
}

.staff-card-open-btn:hover {
  border-color: rgba(92, 255, 176, 0.75);
  color: #fff;
  box-shadow:
    0 0 14px rgba(92, 255, 176, 0.22),
    inset 0 0 14px rgba(92, 255, 176, 0.06);
}

.staff-card-open-btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.staff-card-avatar {
  flex: 0 0 56px;
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: rgba(138, 163, 150, 0.16);
  border: 1px solid rgba(138, 163, 150, 0.28);
  overflow: hidden;
  position: relative;
}

.staff-card-avatar-img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: 50%;
}

.staff-card-avatar-img[hidden] {
  display: none;
}

.staff-card-meta {
  min-width: 0;
  flex: 1 1 auto;
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
}

.staff-card-name-row {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  flex-wrap: wrap;
  min-width: 0;
}

.staff-card-nickname {
  margin: 0;
  font-family: var(--display);
  font-weight: 700;
  font-size: 1.05rem;
  color: var(--ink);
  line-height: 1.25;
}

.staff-card-presence {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
}

.staff-card-presence .online-dot {
  flex: 0 0 10px;
  width: 10px;
  height: 10px;
  animation: online-pulse 1.4s ease-in-out infinite;
}

.staff-card-presence-label {
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--accent);
  line-height: 1.2;
}

.staff-card-subtitle {
  margin: 0;
  font-size: 0.84rem;
  line-height: 1.35;
}

.staff-card-email {
  margin: 0;
  font-size: 0.8rem;
  line-height: 1.35;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.staff-card-dates {
  flex: 1 1 100%;
  margin-left: 0;
  max-width: none;
  text-align: left;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.35rem 0.75rem;
  min-width: 0;
  padding-top: 0.55rem;
  border-top: 1px solid rgba(138, 163, 150, 0.14);
}

.staff-card-date-line {
  margin: 0;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 0.12rem;
  font-size: 0.74rem;
  line-height: 1.35;
  color: var(--muted);
}

.staff-card-date-label {
  display: block;
  color: #fff;
  font-weight: 700;
}

.staff-card-date-value {
  display: block;
  color: var(--muted);
  font-weight: 400;
  white-space: nowrap;
}

@media (max-width: 768px) {
  .staff-card {
    max-width: none;
    gap: 0.85rem;
    padding: 1rem 1.05rem;
    border-radius: max(24px, calc(var(--radius-card) - 10px));
  }

  .staff-card-body {
    flex-direction: column;
    align-items: stretch;
    gap: 0.85rem;
  }

  .staff-card-avatar {
    align-self: center;
    flex-basis: 64px;
    width: 64px;
    height: 64px;
  }

  .staff-card-meta {
    text-align: center;
  }

  .staff-card-name-row {
    justify-content: center;
  }

  .staff-card-email {
    white-space: normal;
    overflow-wrap: anywhere;
  }

  .staff-card-dates {
    display: flex;
    flex-direction: column;
    gap: 0.3rem;
    margin-left: 0;
    max-width: none;
    text-align: left;
    padding-top: 0.75rem;
    border-top: 1px solid rgba(138, 163, 150, 0.14);
  }

  .staff-card-date-line {
    align-items: flex-start;
  }

  .staff-card-date-value {
    white-space: normal;
  }
}

@media (max-width: 480px) {
  .staff-toolbar {
    flex-direction: column;
    align-items: stretch;
  }

  .staff-refresh-btn {
    width: 100%;
  }
}

/* Chat tab */
#tab-chat.panel.active {
  display: flex;
  flex-direction: column;
  flex: 1 1 auto;
  align-self: stretch;
  min-height: 0;
  height: 100%;
}

#tab-chat.panel.active > h2,
#tab-chat.panel.active > .chat-status {
  flex: 0 0 auto;
}

.chat-status {
  margin: 0.35rem 0 0;
  font-size: 0.88rem;
}

.chat-status--error {
  color: var(--danger, #ff6b6b);
}

.chat-layout {
  display: flex;
  align-items: stretch;
  flex: 1 1 auto;
  min-height: 0;
  gap: 0.85rem;
  margin-top: 0.75rem;
  width: 100%;
  max-width: none;
}

.chat-main {
  display: flex;
  flex-direction: column;
  flex: 0 0 62%;
  max-width: 62%;
  min-width: 0;
  min-height: 0;
  gap: 0.75rem;
}

.chat-side {
  display: flex;
  flex-direction: column;
  flex: 1 1 auto;
  min-width: 0;
  min-height: 0;
}

.chat-management {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  justify-content: flex-start;
  flex: 1 1 auto;
  min-height: 0;
  padding: 1.1rem 1.15rem;
  border: 1px solid rgba(92, 255, 176, 0.32);
  border-radius: var(--radius-card);
  background: rgba(8, 14, 12, 0.55);
  box-shadow:
    0 0 0 1px rgba(8, 20, 14, 0.25),
    0 0 12px rgba(92, 255, 176, 0.1),
    0 0 28px rgba(92, 255, 176, 0.04);
  overflow-y: auto;
}

.chat-management-title {
  margin: 0 0 0.85rem;
  font-size: 1.05rem;
  font-weight: 800;
  line-height: 1.25;
  letter-spacing: 0.01em;
  color: var(--ink);
  text-align: center;
}

.chat-filters {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  width: 100%;
}

.chat-filter-block {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.chat-filter-label {
  font-size: 0.78rem;
  font-weight: 700;
  color: rgba(232, 242, 236, 0.88);
  letter-spacing: 0.01em;
}

.chat-filter-input {
  width: 100%;
  margin: 0;
  padding: 0.45rem 0.7rem;
  border: 1px solid #3dff9a;
  border-radius: 15px;
  background: rgba(61, 214, 140, 0.12);
  box-shadow:
    0 0 4px rgba(61, 255, 154, 0.35),
    inset 0 0 6px rgba(61, 255, 154, 0.08);
  color: #fff;
  font-size: 0.82rem;
  font-weight: 600;
  line-height: 1.3;
  box-sizing: border-box;
}

.chat-filter-input:focus {
  outline: none;
  background: rgba(61, 214, 140, 0.2);
  box-shadow:
    0 0 6px rgba(61, 255, 154, 0.55),
    0 0 14px rgba(61, 255, 154, 0.3),
    inset 0 0 8px rgba(61, 255, 154, 0.12);
}

.chat-filter-input::placeholder {
  color: rgba(255, 255, 255, 0.38);
}

.chat-filter-input--time,
.chat-filter-input--date {
  color-scheme: dark;
}

.chat-filter-time-row {
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

.chat-filter-time-row .chat-filter-input--time {
  flex: 1 1 0;
  min-width: 0;
}

.chat-filter-time-sep {
  flex: 0 0 auto;
  font-size: 0.78rem;
  font-weight: 600;
  color: rgba(255, 255, 255, 0.55);
}

.chat-filter-actions {
  display: flex;
  gap: 0.5rem;
  margin-top: 0.15rem;
}

.chat-filter-apply,
.chat-filter-reset {
  flex: 1 1 0;
  margin: 0;
  padding: 0.45rem 0.65rem;
  font-size: 0.82rem;
  font-weight: 700;
  border-radius: 15px;
}

.chat-filter-apply {
  border: 1px solid #3dff9a;
  background: rgba(61, 214, 140, 0.22);
  box-shadow:
    0 0 6px rgba(61, 255, 154, 0.45),
    inset 0 0 8px rgba(61, 255, 154, 0.1);
}

.chat-filter-apply:hover {
  background: rgba(61, 214, 140, 0.32);
}

.chat-filter-reset {
  border: 1px solid rgba(92, 255, 176, 0.35);
  background: rgba(8, 14, 12, 0.45);
}

.chat-filter-count {
  margin: 0.15rem 0 0;
  font-size: 0.8rem;
  font-weight: 600;
  text-align: center;
}

.chat-highlight-toggles {
  display: flex;
  flex-direction: column;
  gap: 0.55rem;
  width: 100%;
  margin-top: 0.85rem;
  padding-top: 0.85rem;
  border-top: 1px solid rgba(92, 255, 176, 0.18);
}

.chat-highlight-toggle {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  margin: 0;
  cursor: pointer;
  user-select: none;
}

.chat-highlight-checkbox {
  flex: 0 0 auto;
  width: 1rem;
  height: 1rem;
  margin: 0;
  accent-color: #3dff9a;
  cursor: pointer;
}

.chat-highlight-toggle-label {
  font-size: 0.8rem;
  font-weight: 600;
  line-height: 1.3;
  color: rgba(232, 242, 236, 0.9);
}

.chat-messages {
  flex: 1 1 auto;
  min-height: 280px;
  padding: 0.85rem;
  border: 1px solid var(--line);
  border-radius: 17px;
  background: rgba(0, 0, 0, 0.28);
  overflow-y: auto;
  display: flex;
  flex-direction: column;
}

.chat-msg-list {
  display: flex;
  flex-direction: column;
  gap: 0.55rem;
}

.chat-msg {
  display: flex;
  align-items: flex-start;
  gap: 0.65rem;
  padding: 0.55rem 0.65rem;
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid rgba(255, 255, 255, 0.05);
}

.chat-msg--owner {
  border: 1px solid rgba(255, 255, 255, 0.72);
  box-shadow:
    0 0 10px rgba(255, 255, 255, 0.28),
    0 0 18px rgba(255, 255, 255, 0.1),
    inset 0 0 12px rgba(255, 255, 255, 0.06);
}

.chat-msg--moderator {
  border: 1px solid rgba(110, 176, 240, 0.72);
  box-shadow:
    0 0 10px rgba(110, 176, 240, 0.32),
    0 0 18px rgba(110, 176, 240, 0.12),
    inset 0 0 12px rgba(110, 176, 240, 0.06);
}

.chat-msg-nick-wrap {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  min-width: 0;
}

.chat-owner-pill,
.chat-mod-pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 auto;
  font-size: 0.7rem;
  font-weight: 900;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  padding: 0.16rem 0.48rem;
  border-radius: 5px;
  background: rgba(255, 255, 255, 0.9);
  border: 1px solid rgba(255, 255, 255, 0.78);
  line-height: 1;
  isolation: isolate;
}

.chat-pill-knockout {
  display: block;
  line-height: 1;
  color: #000;
  -webkit-text-stroke: 0.4px #000;
  mix-blend-mode: destination-out;
}

.chat-msg-avatar {
  flex: 0 0 2.25rem;
  width: 2.25rem;
  height: 2.25rem;
  border-radius: 50%;
  overflow: hidden;
  background: rgba(255, 255, 255, 0.08);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  color: rgba(255, 255, 255, 0.82);
}

.chat-msg-avatar--initials {
  border: 1px solid rgba(255, 255, 255, 0.1);
}

.chat-msg-avatar-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.chat-msg-body {
  flex: 1 1 auto;
  min-width: 0;
}

.chat-msg-head {
  display: flex;
  align-items: baseline;
  gap: 0.5rem;
  margin-bottom: 0.15rem;
}

.chat-msg-nick {
  font-weight: 700;
  font-size: 0.92rem;
  color: rgba(255, 255, 255, 0.95);
}

.chat-msg-time {
  font-size: 0.75rem;
  color: rgba(255, 255, 255, 0.42);
  white-space: nowrap;
}

.chat-msg-text {
  margin: 0;
  font-size: 0.92rem;
  line-height: 1.45;
  color: rgba(255, 255, 255, 0.86);
  word-break: break-word;
}

.chat-empty {
  margin: auto;
  text-align: center;
  padding: 2rem 1rem;
}

.chat-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  flex-wrap: wrap;
}

.chat-refresh-btn {
  flex: 0 0 auto;
  font-size: 0.82rem;
  padding: 0.45rem 0.85rem;
  margin-top: 0;
}

.chat-readonly-note {
  margin: 0;
  font-size: 0.82rem;
  flex: 1 1 auto;
  text-align: right;
}

@media (max-width: 900px) {
  .chat-layout {
    flex-direction: column;
  }

  .chat-main {
    flex: 0 0 auto;
    max-width: 100%;
    width: 100%;
  }

  .chat-side {
    flex: 1 1 auto;
    min-height: 220px;
  }
}

@media (max-width: 520px) {
  .chat-footer {
    flex-direction: column;
    align-items: stretch;
  }

  .chat-refresh-btn {
    width: 100%;
  }

  .chat-readonly-note {
    text-align: center;
  }

  .chat-management {
    padding: 0.95rem 1rem;
    min-height: 200px;
  }
}
