:root {
  --bg: #0f1115;
  --bg-elev: #171a21;
  --bg-elev-2: #1e222b;
  --bg-hover: #232732;
  --border: #2a2f3a;
  --text: #e7ebf0;
  --text-dim: #97a0ad;
  --text-faint: #6b7480;
  --accent: #3b82f6;
  --accent-hover: #2f6fe0;
  --green: #22c55e;
  --red: #ef4444;
  --orange: #f59e0b;
  --radius: 12px;
  --shadow: 0 8px 30px rgba(0,0,0,.35);
  --header-h: 60px;
  --icon-btn-size: 36px;
  --icon-btn-radius: 9px;
  --icon-btn-font: 15px;
  --login-glow: #1b2330;
  --player-track: #2a3140;
  --player-buffer: #4a5d7a;
  --player-played: #3b82f6;
  --player-thumb: #ffffff;
  --player-thumb-ring: #3b82f6;
  font-synthesis: none;
}

/* ---------- Light theme ---------- */
:root[data-theme="light"] {
  --bg: #f3f5f9;
  --bg-elev: #ffffff;
  --bg-elev-2: #eef1f6;
  --bg-hover: #e6eaf1;
  --border: #dde2ec;
  --text: #1b2230;
  --text-dim: #5a6473;
  --text-faint: #8b95a4;
  --accent: #2f6fe0;
  --accent-hover: #2560c8;
  --shadow: 0 10px 30px rgba(23,38,66,.12);
  --login-glow: #dbe6fb;
  --player-track: #d8dee9;
  --player-buffer: #a8b8d4;
  --player-played: #2f6fe0;
  --player-thumb: #ffffff;
  --player-thumb-ring: #2f6fe0;
}

* { box-sizing: border-box; }

/* Smooth, flicker-free theme switching. Transitions are enabled only for the
   brief moment a theme toggle happens (the .theme-transition class is added to
   <html> by JS and removed right after), so every surface — backgrounds,
   borders, text and icons — fades together instead of snapping element by
   element. Keeping it scoped to the toggle avoids interfering with normal
   hover/UI animations and the initial page load. */
html.theme-transition,
html.theme-transition *,
html.theme-transition *::before,
html.theme-transition *::after {
  transition: background-color .3s ease, border-color .3s ease,
              color .3s ease, fill .3s ease, stroke .3s ease,
              box-shadow .3s ease, opacity .3s ease, transform .3s ease !important;
  transition-delay: 0s !important;
}
@media (prefers-reduced-motion: reduce) {
  html.theme-transition,
  html.theme-transition *,
  html.theme-transition *::before,
  html.theme-transition *::after { transition: none !important; }
}

html, body {
  margin: 0;
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: "Segoe UI", system-ui, -apple-system, Roboto, Arial, sans-serif;
  font-size: 14px;
  -webkit-font-smoothing: antialiased;
  transition: background .2s ease, color .2s ease;
}

.hidden { display: none !important; }
/* The `hidden` attribute must win over class-level display:flex/grid. */
[hidden] { display: none !important; }

/* ---------- Login ---------- */
.login-screen {
  position: fixed; inset: 0;
  display: flex; align-items: center; justify-content: center;
  background: radial-gradient(1200px 600px at 50% -10%, var(--login-glow) 0%, var(--bg) 55%);
  padding: 20px;
}
.login-card {
  width: 100%; max-width: 400px;
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 40px 34px 34px;
  box-shadow: var(--shadow);
  text-align: center;
  animation: pop .25s ease;
}
@keyframes pop { from { transform: translateY(8px) scale(.98); opacity: 0; } }
.login-card h1 { font-size: 22px; font-weight: 700; margin: 2px 0 4px; letter-spacing: -.2px; }
.login-sub { color: var(--text-dim); margin: 0 0 26px; font-size: 13px; }
/* Input with a leading icon inside a strict-cornered field. */
.login-field { position: relative; margin-bottom: 14px; margin-top: 14px; }
.login-field-ico {
  position: absolute; left: 14px; top: 50%; transform: translateY(-50%);
  color: var(--text-faint); font-size: 14px; pointer-events: none;
}
.login-card input {
  width: 100%; padding: 13px 14px 13px 40px;
  background: var(--bg-elev-2); border: 1px solid var(--border);
  border-radius: 4px; color: var(--text); font-size: 15px; outline: none;
  transition: border-color .15s;
}
.login-card input:focus { border-color: var(--accent); }
.login-card input:focus + .login-field-ico,
.login-field:focus-within .login-field-ico { color: var(--accent); }
.login-card button {
  width: 100%; padding: 13px; border: none; border-radius: 4px; margin-top: 4px;
  background: var(--accent); color: #fff; font-size: 15px; font-weight: 600;
  cursor: pointer; transition: background .15s;
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
}
.login-card button:hover { background: var(--accent-hover); }
.login-error { color: var(--red); font-size: 13px; min-height: 18px; margin-top: 12px; }

/* ---------- App shell ---------- */
/* The dashboard markup is injected into #appRoot after login, so the wrapper
   must pass the full viewport height through to .app (which sizes at 100%). */
#appRoot { height: 100%; }
.app { display: flex; height: 100%; overflow: hidden; }
.backdrop { display: none; }

.sidebar {
  width: 320px; flex-shrink: 0;
  background: var(--bg-elev);
  border-right: 1px solid var(--border);
  display: flex; flex-direction: column;
}
.sidebar-header {
  display: flex; align-items: center; justify-content: space-between;
  min-height: var(--header-h); height: auto; padding: 0 16px;
  border-bottom: 1px solid var(--border); flex-shrink: 0;
}
.brand { display: flex; align-items: center; gap: 12px; min-width: 0; }
.brand-dot { width: 10px; height: 10px; border-radius: 50%; background: var(--green); flex-shrink: 0; transition: background .2s, box-shadow .2s; }
.brand-dot.online { background: var(--green); box-shadow: 0 0 0 4px rgba(34,197,94,.15); }
.brand-dot.connecting { background: #eab308; box-shadow: 0 0 0 4px rgba(234,179,8,.15); }
.brand-dot.offline { background: var(--red); box-shadow: 0 0 0 4px rgba(239,68,68,.15); }
.brand-text h1 { font-size: 16px; margin: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.header-tools { display: flex; align-items: center; gap: 8px; flex-shrink: 0; }
.header-tools a.icon-btn { text-decoration: none; color: var(--text-dim); }

.icon-btn {
  background: var(--bg-elev-2); border: 1px solid var(--border); color: var(--text-dim);
  width: var(--icon-btn-size); height: var(--icon-btn-size);
  min-width: var(--icon-btn-size); min-height: var(--icon-btn-size);
  border-radius: var(--icon-btn-radius); cursor: pointer; font-size: var(--icon-btn-font);
  position: relative;
  display: inline-block;
  padding: 0; box-sizing: border-box; flex-shrink: 0;
  transition: .15s;
  -webkit-tap-highlight-color: transparent;
}
.icon-btn > i {
  position: absolute;
  top: 50%; left: 50%;
  transform: translate(-50%, -50%);
  display: block;
  width: auto; height: auto;
  font-size: var(--icon-btn-font); line-height: 1;
  pointer-events: none;
  text-align: center;
}
.icon-btn > i::before {
  display: block;
  line-height: 1;
}
.icon-btn.btn-ico-resp {
  display: inline-flex; align-items: center; justify-content: center;
  width: auto; padding: 0 12px; gap: 6px;
}
.icon-btn.btn-ico-resp > i {
  position: static;
  transform: none;
}
.icon-btn:hover { background: var(--bg-hover); color: var(--text); }
.icon-btn:focus { outline: none; }
.icon-btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.icon-btn:active { transform: scale(0.96); }
.icon-btn:disabled,
.icon-btn[disabled] { opacity: .4; cursor: not-allowed; pointer-events: none; }
.icon-btn-danger { color: #ff8b8b; border-color: rgba(239,68,68,.35); }
.icon-btn-danger:hover { background: rgba(239,68,68,.14); color: #ff9090; }

.wipe-all-btn { color: #ff8b8b; border-color: rgba(239,68,68,.35); }
.wipe-all-btn:hover { background: rgba(239,68,68,.16); color: #ff9090; border-color: rgba(239,68,68,.6); }

/* Theme toggle: show the icon of the theme you can switch to. The two icons are
   stacked and cross-fade with a small rotate so switching looks smooth instead
   of snapping. */
.theme-toggle { position: relative; }
.theme-toggle .icon-sun,
.theme-toggle .icon-moon {
  position: absolute; inset: 0;
  display: inline-flex; align-items: center; justify-content: center;
  transition: opacity .3s ease, transform .3s ease;
}
.theme-toggle .icon-moon { opacity: 0; transform: rotate(-90deg) scale(.5); }
.theme-toggle .icon-sun  { opacity: 1; transform: rotate(0) scale(1); }
:root[data-theme="light"] .theme-toggle .icon-sun  { opacity: 0; transform: rotate(90deg) scale(.5); }
:root[data-theme="light"] .theme-toggle .icon-moon { opacity: 1; transform: rotate(0) scale(1); }

.search-box { padding: 12px 14px; flex-shrink: 0; }
.search-field { position: relative; display: flex; align-items: center; }
.search-box input {
  width: 100%; padding: 10px 36px 10px 12px; background: var(--bg-elev-2);
  border: 1px solid var(--border); border-radius: 9px; color: var(--text); outline: none;
}
.search-box input:focus { border-color: var(--accent); }
.search-clear {
  position: absolute; right: 6px; top: 50%; transform: translateY(-50%);
  width: 24px; height: 24px; border: none; background: transparent; cursor: pointer;
  color: var(--text-faint); border-radius: 6px; font-size: 13px;
  display: inline-flex; align-items: center; justify-content: center; transition: .15s;
}
.search-clear:hover { background: var(--bg-hover); color: var(--text); }
.team-filter {
  width: 100%; margin-top: 8px; padding: 8px 10px;
  background: var(--bg-elev-2); border: 1px solid var(--border); border-radius: 9px;
  color: var(--text); outline: none; font-size: 13px;
}
.team-filter:focus { border-color: var(--accent); }

.branch-list { flex: 1; overflow-y: auto; padding: 4px 8px 12px; }
.branch-item {
  padding: 9px 11px; border-radius: 10px; cursor: pointer; margin-bottom: 4px;
  border: 1px solid transparent;
  transition: background .12s, border-color .12s; position: relative;
  display: flex; align-items: center; gap: 11px;
  box-sizing: border-box;
}
.branch-item:hover { background: var(--bg-hover); }
.branch-item.active {
  background: linear-gradient(90deg, rgba(59,130,246,.18), rgba(59,130,246,.06));
  border-color: rgba(59,130,246,.35);
}
.branch-avatar,
.ac-item .ac-avatar {
  position: relative;
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  box-sizing: border-box;
  border-radius: 50%;
  text-transform: uppercase;
  user-select: none;
  font-weight: 700;
  overflow: visible;
}
.branch-avatar {
  width: 40px; height: 40px;
  font-size: 17px; color: #fff;
  background: linear-gradient(135deg, #4f8cff, #7c5cff);
}
.avatar-letter {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
  text-align: center;
  pointer-events: none;
}
.ac-item .ac-avatar {
  width: 36px; height: 36px;
  font-size: 15px;
  color: var(--text);
  background: var(--bg-elev-2);
}
.presence {
  position: absolute; bottom: -2px; right: -2px;
  width: 11px; height: 11px; border-radius: 50%;
  border: 2px solid var(--bg-elev);
  box-sizing: border-box;
  z-index: 1;
  pointer-events: none;
}
.presence.on { background: var(--green); }
.presence.off { background: #9aa4b2; }
.branch-body { min-width: 0; flex: 1; }
.branch-name { font-weight: 600; font-size: 14px; display: flex; align-items: center; gap: 8px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.branch-preview { color: var(--text-dim); font-size: 12.5px; margin-top: 3px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.branch-time { color: var(--text-faint); font-size: 11px; margin-top: 3px; }
.branch-sip { color: var(--text-faint); font-size: 11px; margin-top: 1px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.branch-meta-sip { color: var(--text-dim); font-size: 12.5px; }
.branch-meta-sip:not(:empty)::before { content: '•'; margin: 0 6px; opacity: .5; }

/* ---------- Content ---------- */
.content { flex: 1; display: flex; flex-direction: column; min-width: 0; background: var(--bg); }
.content-header {
  display: flex; align-items: center; gap: 14px;
  min-height: var(--header-h); height: auto; padding: 0 20px;
  border-bottom: 1px solid var(--border); background: var(--bg-elev); flex-shrink: 0;
}
/* Operator navbar is only shown once a branch is selected. */
.app.no-branch .content-header { display: none; }

/* Active-calls control lives in the sidebar header (replaces the old title). */
.sidebar-header .brand { flex: 1; min-width: 0; display: flex; align-items: center; gap: 8px; }
.sidebar-header .active-calls-btn { flex: 0 0 auto; width: auto; justify-content: center; }
.header-info { flex: 1; min-width: 0; }
.header-info h2 {
  font-size: 17px; margin: 0;
  display: inline-flex; align-items: center; gap: 8px;
  flex-wrap: wrap; line-height: 1.25;
  overflow: hidden; text-overflow: ellipsis;
}
.branch-meta {
  font-size: 12.5px; color: var(--text-dim);
  display: flex; flex-wrap: wrap; align-items: baseline; gap: 0;
  line-height: 1.35;
}
.branch-meta-last:empty { display: none; }
.branch-meta-last:not(:empty)::before {
  content: '·';
  margin-left: 0.35em;
  margin-right: 0.35em;
}
.header-actions { display: flex; gap: 8px; align-items: center; }
.header-actions .icon-btn { padding: 0; }
.menu-toggle { display: none; flex-shrink: 0; }

.btn-ghost, .btn-danger {
  border: 1px solid var(--border); background: var(--bg-elev-2); color: var(--text);
  min-height: var(--icon-btn-size); height: var(--icon-btn-size);
  padding: 0 14px; border-radius: var(--icon-btn-radius); cursor: pointer; font-size: 13px;
  transition: .15s; display: inline-flex; align-items: center; justify-content: center;
  box-sizing: border-box; flex-shrink: 0; gap: 6px;
  -webkit-tap-highlight-color: transparent;
}
.btn-ghost:hover { background: var(--bg-hover); }
.btn-danger { color: #ff8b8b; border-color: rgba(239,68,68,.4); }
.btn-danger:hover { background: rgba(239,68,68,.14); }

.log-list { flex: 1; overflow: hidden; padding: 0; display: flex; flex-direction: column; min-height: 0; }

/* Single scroll container: sticky header keeps columns aligned on all widths. */
.log-table-wrap {
  position: relative;
  flex: 1; min-height: 0; display: flex; flex-direction: column; overflow: hidden;
}
.log-loading {
  position: absolute; inset: 0; z-index: 4;
  display: flex; align-items: center; justify-content: center;
  margin: 0; padding: 0;
  background: color-mix(in srgb, var(--bg) 82%, transparent);
  pointer-events: none;
}
.log-empty-journal {
  position: absolute; inset: 0; z-index: 3;
  display: flex; align-items: center; justify-content: center;
  pointer-events: none;
}
.log-empty-journal.hidden { display: none; }
.log-empty-journal-inner { text-align: center; max-width: 340px; padding: 24px; }
.log-empty-journal .empty-title {
  margin: 0; font-size: 15px; font-weight: 500; color: var(--text-dim);
}
.log-table-wrap.log-journal-empty .log-table thead,
.log-table-wrap.log-journal-loading .log-table thead { display: none; }
.log-scroll {
  flex: 1 1 auto; min-height: 0;
  overflow: auto;
  -webkit-overflow-scrolling: touch;
}

/* ---------- Log table ---------- */
.log-table { width: 100%; border-collapse: collapse; font-size: 13px; table-layout: fixed; }
.log-table col.col-time { width: 11%; }
.log-table col.col-number { width: 26%; }
.log-table col.col-account { width: 18%; }
.log-table col.col-status { width: 19%; }
.log-table col.col-dur { width: 13%; }
.log-table col.col-rec { width: 13%; }
.log-table thead th {
  position: sticky; top: 0; z-index: 2;
  background: var(--bg-elev);
  text-align: center; font-weight: 600; color: var(--text-dim); font-size: 12px;
  padding: 11px 10px; border-bottom: 1px solid var(--border);
  white-space: normal; line-height: 1.25;
}
.log-table tbody td {
  padding: 11px 10px; border-bottom: 1px solid var(--border);
  vertical-align: middle; text-align: center;
}
.log-table tbody tr { animation: slideIn .18s ease; }
.log-table tbody tr:hover { background: var(--bg-hover); }
.log-table thead th,
.log-table tbody td { box-sizing: border-box; }
.log-table .c-play { overflow: hidden; }
.log-table .c-play .rec-actions {
  display: inline-flex; align-items: center; justify-content: center;
  gap: 6px; max-width: 100%;
}
.log-table .c-number { font-weight: 600; word-break: break-word; }
.num-cell { display: inline-flex; align-items: center; gap: 7px; justify-content: center; }
.call-ico { display: inline-flex; align-items: center; justify-content: center; flex: 0 0 auto; font-size: 14px; width: 18px; min-width: 18px; }
.call-ico i { display: inline-block; line-height: 1; font-style: normal; width: 1em; text-align: center; }
.call-ico.incoming { color: var(--green); }
.call-ico.outgoing { color: var(--accent); }
.call-ico.missed { color: var(--red); }
.call-ico.other { color: var(--text-faint); }
.log-table .c-sub { color: var(--text-faint); font-size: 11.5px; font-weight: 400; margin-top: 2px; }
.log-table .c-time, .log-table .c-dur { white-space: nowrap; color: var(--text-dim); }
.log-th-mobile { display: none; }
.log-details-btn {
  display: none;
  width: var(--icon-btn-size); height: var(--icon-btn-size);
  padding: 0; font-size: 14px; line-height: 1;
  border: 1px solid var(--border); border-radius: 8px;
  background: var(--bg-elev-2); color: var(--text-dim);
  cursor: pointer; font-family: inherit;
  align-items: center; justify-content: center;
  transition: background .15s, border-color .15s, color .15s;
  -webkit-tap-highlight-color: transparent;
}
.log-details-btn i { pointer-events: none; }
.log-th-mobile { display: none; font-size: 11px; line-height: 1; color: var(--text-dim); font-weight: 600; }
.log-details-btn:hover { background: var(--bg-hover); color: var(--text); border-color: var(--accent); }

/* Log details modal (mobile) */
.log-details-modal { max-width: 360px; }
.log-details-list { margin: 0; padding: 0; }
.log-detail-row {
  display: flex; flex-direction: column; gap: 4px;
  padding: 12px 0; border-bottom: 1px solid var(--border);
}
.log-detail-row:first-child { padding-top: 0; }
.log-detail-row:last-child { border-bottom: none; padding-bottom: 0; }
.log-detail-row dt { margin: 0; font-size: 12px; color: var(--text-dim); font-weight: 500; }
.log-detail-row dd { margin: 0; font-size: 15px; color: var(--text); font-weight: 600; }
.log-detail-row dd .status-error { font-size: 13px; }
.log-table .c-account, .log-table .c-status { color: var(--text-dim); word-break: break-word; }
.status-error {
  display: inline-block;
  padding: 2px 9px;
  border: 1px solid var(--red);
  border-radius: 999px;
  background: rgba(239, 68, 68, .12);
  color: var(--red);
  font-size: 12px;
  font-weight: 600;
  line-height: 1.5;
  white-space: nowrap;
}
.log-loader { display: flex; align-items: center; justify-content: center; padding: 16px; }

/* ---------- Empty / loading states ---------- */
.empty-state { margin: auto; text-align: center; color: var(--text-dim); max-width: 400px; padding: 32px 24px; }
.empty-icon {
  width: 76px; height: 76px; margin: 0 auto 18px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  background: var(--bg-elev-2); border: 1px solid var(--border); color: var(--text-faint);
}
.empty-icon svg { width: 34px; height: 34px; }
.empty-icon i { font-size: 30px; }
.empty-title { font-size: 15.5px; color: var(--text); font-weight: 600; margin: 0 0 6px; }
.empty-sub { font-size: 13px; color: var(--text-dim); margin: 0; line-height: 1.5; }
.empty-emoji { font-size: 44px; margin-bottom: 10px; }

.log-loading.hidden { display: none !important; }

.spinner {
  width: 30px; height: 30px; border-radius: 50%;
  border: 3px solid var(--border); border-top-color: var(--accent);
  animation: spin .7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes slideIn { from { opacity: 0; transform: translateY(6px); } }

.log-play {
  position: relative;
  display: inline-block;
  width: var(--icon-btn-size); height: var(--icon-btn-size); padding: 0;
  background: var(--bg-elev-2); border: 1px solid var(--border); color: var(--text);
  border-radius: 8px; cursor: pointer; transition: .15s;
}
.log-play:hover:not(:disabled) { background: var(--bg-hover); border-color: var(--accent); }
.log-play i, .log-download i {
  position: absolute;
  top: 50%; left: 50%;
  transform: translate(-50%, -50%);
  display: block;
  font-size: 14px; line-height: 1; color: var(--accent);
}
.log-play i::before, .log-download i::before { display: block; line-height: 1; }
.log-play.active { border-color: var(--accent); background: rgba(59,130,246,.12); }
.log-play:disabled { opacity: .45; cursor: default; color: var(--text-faint); }
.log-play:disabled i { color: var(--text-faint); }

/* Play + download buttons side by side in the "Запись" column. */
.rec-actions { display: inline-flex; align-items: center; gap: 6px; }
.log-download {
  position: relative;
  display: inline-block;
  width: var(--icon-btn-size); height: var(--icon-btn-size); padding: 0;
  background: var(--bg-elev-2); border: 1px solid var(--border); color: var(--accent);
  border-radius: 8px; cursor: pointer; transition: .15s;
}
.log-download:hover:not(:disabled) { background: var(--bg-hover); border-color: var(--accent); }
.log-download:disabled { opacity: .45; cursor: default; color: var(--text-faint); }
.log-download:disabled i { color: var(--text-faint); }

/* ---------- Live "in call" indicator ---------- */
.call-live {
  display: inline-flex; align-items: center; justify-content: center;
  flex: 0 0 auto; color: var(--green);
  vertical-align: middle; line-height: 1;
}
.call-live-wave {
  display: inline-flex; align-items: center; gap: 2px;
  height: 10px; line-height: 1;
}
/* --ad is a negative delay set per element from wall-clock time, so a freshly
   re-rendered icon picks up the animation mid-cycle (in phase) instead of
   restarting from zero — the wave looks continuous across re-renders. */
.call-live-wave i {
  width: 2px; height: 10px; border-radius: 2px; background: currentColor;
  transform-origin: center center; transform: scaleY(0.35);
  animation: callWave 1s ease-in-out infinite;
  animation-delay: var(--ad, 0ms);
}
.call-live-wave i:nth-child(2) { animation-delay: calc(var(--ad, 0ms) + .15s); }
.call-live-wave i:nth-child(3) { animation-delay: calc(var(--ad, 0ms) + .3s); }
h2 .call-live { color: var(--green); }

@keyframes callShake {
  0%, 100% { transform: rotate(0deg); }
  20% { transform: rotate(-12deg) scale(1.08); }
  40% { transform: rotate(10deg); }
  60% { transform: rotate(-7deg); }
  80% { transform: rotate(5deg); }
}
@keyframes callWave {
  0%, 100% { transform: scaleY(0.35); opacity: .55; }
  50% { transform: scaleY(1); opacity: 1; }
}

/* ---------- Active calls indicator (header) ---------- */
.active-calls-btn {
  position: relative;
  display: inline-flex; align-items: center; gap: 6px;
  width: auto; padding: 0 10px;
}
.active-calls-btn .ac-wave {
  display: inline-flex; align-items: center; justify-content: center;
  gap: 2px; height: 18px; line-height: 1;
  color: var(--text-dim); flex-shrink: 0;
}
.active-calls-btn .ac-wave i {
  width: 2px; height: 10px; border-radius: 2px; background: currentColor;
  opacity: .5; transform-origin: center center; transform: scaleY(0.35);
}
.active-calls-btn .ac-count {
  min-width: 18px; height: 18px; padding: 0 5px;
  display: inline-flex; align-items: center; justify-content: center;
  border-radius: 9px; background: var(--bg-elev-2); border: 1px solid var(--border);
  color: var(--text-dim); font-size: 11.5px; font-weight: 700; line-height: 1;
}
.active-calls-btn.has-calls .ac-wave { color: var(--green); }
.active-calls-btn.has-calls .ac-wave i { animation: callWave 1s ease-in-out infinite; }
.active-calls-btn.has-calls .ac-wave i:nth-child(2) { animation-delay: .15s; }
.active-calls-btn.has-calls .ac-wave i:nth-child(3) { animation-delay: .3s; }
.active-calls-btn.has-calls .ac-count {
  background: rgba(34, 197, 94, .15); border-color: var(--green); color: var(--green);
}

/* ---------- Active calls modal list ---------- */
.active-calls-list {
  position: relative;
  display: flex; flex-direction: column;
  --ac-row-h: 58px;
  --ac-row-gap: 10px;
  --ac-rows: 4;
  --ac-list-pad: 8px;
  --ac-list-h: calc(
    var(--ac-rows) * var(--ac-row-h) +
    (var(--ac-rows) - 1) * var(--ac-row-gap) +
    var(--ac-list-pad) * 2
  );
  gap: var(--ac-row-gap);
  overflow-y: auto;
  overflow-x: hidden;
  padding: var(--ac-list-pad) 6px var(--ac-list-pad) 2px;
  scrollbar-gutter: stable;
}
.active-calls-list:has(.ac-item) {
  height: min(var(--ac-list-h), calc(100vh - 11rem));
  max-height: min(var(--ac-list-h), calc(100vh - 11rem));
  min-height: calc(var(--ac-row-h) + var(--ac-list-pad) * 2);
}
.active-calls-list:has(.ac-empty) {
  height: min(220px, calc(100vh - 11rem));
  min-height: 180px;
  max-height: min(220px, calc(100vh - 11rem));
  overflow: hidden;
}
.active-calls-list:has(.ac-empty)::after { display: none; }
.active-calls-list::after {
  content: ''; display: block; flex: 0 0 2px; min-height: 2px;
}
.ac-item {
  display: flex; align-items: center; gap: 12px;
  min-height: var(--ac-row-h);
  padding: 11px 14px; border: 1px solid var(--border); border-radius: 10px;
  background: var(--bg-elev);
  flex-shrink: 0;
}
.ac-item .ac-body { flex: 1 1 auto; min-width: 0; }
.ac-item .ac-name {
  font-weight: 600; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  display: flex; align-items: center; gap: 7px;
}
.ac-item .ac-sub { font-size: 12px; color: var(--text-faint); margin-top: 2px; }
.ac-item .ac-timer {
  flex: 0 0 auto; font-variant-numeric: tabular-nums; font-weight: 700; font-size: 14px;
  color: var(--green); padding: 4px 10px; border-radius: 999px;
  border: 1px solid var(--green); background: rgba(34, 197, 94, .12); white-space: nowrap;
}
.ac-empty {
  position: absolute; inset: 0;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  text-align: center; padding: 24px; margin: 0;
}
.ac-empty-icon {
  width: 72px; height: 72px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  background: var(--bg-elev-2); border: 1px solid var(--border);
  color: var(--text-faint); font-size: 28px; margin-bottom: 14px;
}
.ac-empty-text { margin: 0; color: var(--text-dim); font-size: 14px; line-height: 1.45; max-width: 260px; }

.active-calls-modal {
  max-width: 420px;
  display: flex; flex-direction: column;
  max-height: calc(100vh - 40px);
  overflow: hidden;
}
.active-calls-modal .stats-head { flex: 0 0 auto; margin-bottom: 14px; }
.active-calls-modal .active-calls-list { flex: 0 0 auto; min-height: 0; }

/* ---------- Modal ---------- */
.modal-overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,.55); backdrop-filter: blur(2px);
  display: flex; align-items: center; justify-content: center; z-index: 100; padding: 20px;
  animation: fade .15s ease;
}
@keyframes fade { from { opacity: 0; } }
.modal {
  width: 100%; max-width: 390px; background: var(--bg-elev); border: 1px solid var(--border);
  border-radius: 16px; padding: 24px; box-shadow: var(--shadow); animation: pop .2s ease;
  max-height: calc(100vh - 40px);
  overflow-y: auto;
  display: flex; flex-direction: column;
}
.active-calls-modal,
.stats-modal,
.screen-modal { overflow: hidden; }
.modal h3 { margin: 0 0 8px; font-size: 17px; }
.modal p { margin: 0 0 16px; color: var(--text-dim); font-size: 14px; line-height: 1.5; }

/* ---------- Statistics modal ---------- */
.stats-modal { max-width: 540px; }
.stats-modal .stats-head { flex: 0 0 auto; margin-bottom: 18px; }
.stats-modal .stats-grid {
  flex: 1 1 auto; min-height: 0;
  overflow-y: auto;
  max-height: min(420px, 52vh);
}
.stats-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 16px; }
.stats-head h3 { margin: 0; font-size: 16px; }

/* ---------- Player ---------- */
.player {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 18px; border-top: 1px solid var(--border); background: var(--bg-elev);
}
.player-info {
  display: flex; align-items: center; gap: 8px; color: var(--text-dim); font-size: 13px;
  white-space: nowrap; flex: 0 0 auto; max-width: 28%;
  overflow: hidden; text-overflow: ellipsis;
}
.player-info svg { color: var(--accent); flex-shrink: 0; }
.player-info i { color: var(--accent); flex-shrink: 0; }
.player-controls {
  display: flex; align-items: center; gap: 10px; flex: 1; min-width: 0;
}
.player-play-btn {
  display: inline-flex; align-items: center; justify-content: center;
  width: var(--icon-btn-size); height: var(--icon-btn-size); padding: 0; flex-shrink: 0;
  background: var(--bg-elev-2); border: 1px solid var(--border); border-radius: 50%;
  color: var(--accent); cursor: pointer; transition: .15s;
}
.player-play-btn:hover { background: var(--bg-hover); border-color: var(--accent); }
.player-play-btn i { font-size: 14px; }
.player-play-btn.is-playing .icon-play { display: none; }
.player-play-btn.is-playing .icon-pause { display: block !important; }
.player-scrubber {
  position: relative; flex: 1; height: 28px; min-width: 80px;
  display: flex; align-items: center;
}
.player-scrubber-track {
  position: absolute; left: 0; right: 0; height: 6px; border-radius: 999px;
  background: var(--player-track); overflow: hidden; pointer-events: none;
}
.player-scrubber-buffer,
.player-scrubber-played {
  position: absolute; left: 0; top: 0; bottom: 0; width: 0;
  border-radius: 999px; transition: width .08s linear;
}
.player-scrubber-buffer { background: var(--player-buffer); z-index: 1; }
.player-scrubber-played { background: var(--player-played); z-index: 2; }
.player-seek {
  -webkit-appearance: none; appearance: none;
  position: relative; z-index: 3;
  width: 100%; height: 28px; margin: 0; padding: 0;
  background: transparent; cursor: pointer;
}
.player-seek:focus { outline: none; }
.player-seek:focus-visible::-webkit-slider-thumb {
  box-shadow: 0 0 0 3px rgba(59,130,246,.35);
}
.player-seek::-webkit-slider-runnable-track {
  height: 6px; background: transparent; border: none;
}
.player-seek::-moz-range-track {
  height: 6px; background: transparent; border: none;
}
.player-seek::-webkit-slider-thumb {
  -webkit-appearance: none; appearance: none;
  width: 14px; height: 14px; margin-top: -4px;
  border-radius: 50%; border: 2px solid var(--player-thumb-ring);
  background: var(--player-thumb);
  box-shadow: 0 1px 4px rgba(0,0,0,.28);
  opacity: 1;
}
.player-seek::-moz-range-thumb {
  width: 14px; height: 14px; border: none; border-radius: 50%;
  border: 2px solid var(--player-thumb-ring);
  background: var(--player-thumb);
  box-shadow: 0 1px 4px rgba(0,0,0,.28);
}
.player-time {
  flex: 0 0 auto; font-size: 12px; color: var(--text-dim);
  font-variant-numeric: tabular-nums; white-space: nowrap;
}

/* ---------- Player volume ---------- */
.player-volume { position: relative; display: flex; align-items: center; gap: 8px; flex: 0 0 auto; }
.player-vol-panel { display: flex; align-items: center; }
.player-volume .player-vol-btn.icon-btn {
  background: transparent; border: none;
  color: var(--text-dim); font-size: 15px;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
  -webkit-touch-callout: none; user-select: none;
}
.player-volume .player-vol-btn.icon-btn:hover { background: var(--bg-hover); color: var(--text); }
.player-volume .player-vol-btn.icon-btn.is-muted { color: var(--text-faint); }
.player-vol-slider {
  -webkit-appearance: none; appearance: none;
  width: 84px; height: 22px; margin: 0; padding: 0;
  border: none; background: transparent;
  cursor: pointer; outline: none;
}
.player-vol-slider::-webkit-slider-runnable-track {
  height: 6px; border-radius: 999px; border: none;
  background: linear-gradient(to right,
    var(--player-played) 0%, var(--player-played) var(--vol-pct, 100%),
    var(--player-track) var(--vol-pct, 100%), var(--player-track) 100%);
}
.player-vol-slider::-moz-range-track {
  height: 6px; border-radius: 999px; border: none;
  background: var(--player-track);
}
.player-vol-slider::-moz-range-progress {
  height: 6px; border-radius: 999px;
  background: var(--player-played);
}
.player-vol-slider::-webkit-slider-thumb {
  -webkit-appearance: none; appearance: none;
  width: 13px; height: 13px; margin-top: -3.5px;
  border-radius: 50%;
  border: 2px solid var(--player-thumb-ring); background: var(--player-thumb);
  box-shadow: 0 1px 4px rgba(0,0,0,.28);
}
.player-vol-slider::-moz-range-thumb {
  width: 13px; height: 13px; border-radius: 50%;
  border: 2px solid var(--player-thumb-ring); background: var(--player-thumb);
  box-shadow: 0 1px 4px rgba(0,0,0,.28);
}
.player-vol-slider:focus-visible::-webkit-slider-thumb { box-shadow: 0 0 0 3px rgba(59,130,246,.35); }
@media (max-width: 960px) {
  .player-vol-panel { display: none; }
  .player-volume.vol-open .player-vol-panel {
    display: flex;
    position: absolute;
    bottom: calc(100% + 8px); left: 50%;
    transform: translateX(-50%);
    width: auto; height: auto;
    flex-direction: column; align-items: center;
    padding: 12px 14px;
    background: var(--bg-elev);
    border: 1px solid var(--border);
    border-radius: 12px;
    box-shadow: var(--shadow);
    z-index: 60;
  }
  .player-volume.vol-open .player-vol-slider {
    -webkit-appearance: none; appearance: none;
    writing-mode: vertical-lr; direction: rtl;
    width: 28px; height: 96px; margin: 0; padding: 0;
    border: none; background: transparent; outline: none;
  }
  .player-volume.vol-open .player-vol-slider::-webkit-slider-runnable-track {
    width: 6px; height: 100%;
    border-radius: 999px; border: none;
    background: linear-gradient(to top,
      var(--player-played) 0%, var(--player-played) var(--vol-pct, 100%),
      var(--player-track) var(--vol-pct, 100%), var(--player-track) 100%);
  }
  .player-volume.vol-open .player-vol-slider::-moz-range-track {
    width: 6px; height: 96px;
    border-radius: 999px; border: none;
    background: var(--player-track);
  }
  .player-volume.vol-open .player-vol-slider::-moz-range-progress {
    width: 6px; border-radius: 999px;
    background: var(--player-played);
  }
  .player-volume.vol-open .player-vol-slider::-webkit-slider-thumb {
    -webkit-appearance: none; appearance: none;
    width: 13px; height: 13px;
    margin-top: 0; margin-left: -3.5px;
    border-radius: 50%;
    border: 2px solid var(--player-thumb-ring); background: var(--player-thumb);
    box-shadow: 0 1px 4px rgba(0,0,0,.28);
  }
  .player-volume.vol-open .player-vol-slider::-moz-range-thumb {
    width: 13px; height: 13px; border-radius: 50%;
    border: 2px solid var(--player-thumb-ring); background: var(--player-thumb);
    box-shadow: 0 1px 4px rgba(0,0,0,.28);
  }
  .player-volume .player-vol-btn.icon-btn {
    background: var(--bg-elev-2);
    border: 1px solid var(--border);
  }
}

/* ---------- Composer (screen message) ---------- */
.screen-composer {
  flex-shrink: 0;
  margin-top: 12px; padding: 10px 12px;
  border: 1px solid var(--border); border-radius: 12px;
  background: var(--bg-elev-2);
}
.composer-field {
  position: relative;
  display: flex;
  align-items: stretch;
  min-width: 0;
  width: 100%;
}
.composer-field textarea {
  flex: 1; width: 100%; min-width: 0;
  resize: none; min-height: 44px; max-height: 120px;
  padding: 12px 44px 12px 14px;
  border-radius: 12px;
  background: var(--bg-elev); border: 1px solid var(--border); color: var(--text);
  font-family: inherit; font-size: 14.5px; line-height: 20px; outline: none;
  overflow-y: auto; scrollbar-width: none;
  box-sizing: border-box;
}
.composer-field textarea::-webkit-scrollbar { width: 0; height: 0; }
.composer-field textarea:focus { border-color: var(--accent); }
.composer-send {
  position: absolute; right: 10px; top: 50%;
  transform: translateY(-50%);
  width: 28px; height: 28px; padding: 0; border: none;
  background: transparent; color: var(--text-faint);
  cursor: default; display: inline-flex; align-items: center; justify-content: center;
  font-size: 16px; line-height: 1; border-radius: 50%;
  transition: color .15s ease, opacity .15s ease;
  -webkit-tap-highlight-color: transparent;
}
.composer-send:not(:disabled) {
  color: var(--accent); cursor: pointer;
}
.composer-send:not(:disabled):hover { color: var(--accent-hover); }
.composer-send i { display: block; line-height: 1; }
.composer-send:disabled { opacity: .55; }

/* ---------- Toast (top, auto-dismiss) ---------- */
.toast {
  position: fixed; top: 22px; left: 50%; transform: translateX(-50%) translateY(-24px);
  display: flex; align-items: center; gap: 9px;
  background: var(--bg-elev-2); border: 1px solid var(--border); color: var(--text);
  padding: 12px 18px; border-radius: 12px; box-shadow: var(--shadow);
  opacity: 0; pointer-events: none; transition: transform .28s cubic-bezier(.2,.8,.2,1), opacity .28s; z-index: 200; font-size: 14px;
  max-width: calc(100vw - 32px);
}
.toast::before {
  content: ""; width: 9px; height: 9px; border-radius: 50%; background: var(--accent); flex-shrink: 0;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.toast.error { border-color: rgba(239,68,68,.5); }
.toast.error::before { background: var(--red); }
.toast.success { border-color: rgba(34,197,94,.5); }
.toast.success::before { background: var(--green); }

/* ---------- Remote screen modal ---------- */
.screen-modal {
  max-width: min(1760px, 97vw);
  width: 100%;
  max-height: calc(100vh - 40px);
  display: flex; flex-direction: column;
}
.screen-head-tools {
  display: flex; align-items: center; gap: 8px; flex-wrap: nowrap;
}
.journal-date {
  height: var(--icon-btn-size);
  background: var(--bg-elev-2); border: 1px solid var(--border); color: var(--text);
  border-radius: var(--icon-btn-radius); font-size: 12.5px;
  padding: 0 8px; cursor: pointer; flex-shrink: 0;
}
.journal-date:hover { background: var(--bg-hover); }
.screen-quality-select {
  height: var(--icon-btn-size);
  background: var(--bg-elev-2); border: 1px solid var(--border); color: var(--text-dim);
  border-radius: var(--icon-btn-radius); font-size: 12.5px;
  padding: 0 8px; cursor: pointer; flex-shrink: 0;
}
.screen-quality-select:hover { background: var(--bg-hover); color: var(--text); }
.screen-volume {
  position: relative;
  display: inline-flex; align-items: center; gap: 6px;
  flex-shrink: 0;
}
/* Sound ON: normal icon-btn look; OFF: red with crossed icon */
.screen-sound-btn {
  background: var(--bg-elev-2);
  border: 1px solid var(--border);
  color: var(--text-dim);
}
.screen-sound-btn:hover {
  background: var(--bg-hover);
  color: var(--text);
}
.screen-sound-btn.sound-off {
  background: #ef4444; border-color: #ef4444; color: #fff;
}
.screen-sound-btn.sound-off:hover {
  background: #dc2626; border-color: #dc2626; color: #fff;
}
.screen-vol-popup {
  position: relative;
  display: flex; align-items: center; justify-content: center;
  width: 105px; height: var(--icon-btn-size);
  flex-shrink: 0;
}
.screen-vol-slider {
  -webkit-appearance: none; appearance: none;
  position: absolute; left: 0; right: 0;
  top: 50%; transform: translateY(-50%);
  width: 100%; height: 13px;
  margin: 0; padding: 0;
  border: none; background: transparent;
  cursor: pointer; outline: none;
}
.screen-vol-slider::-webkit-slider-runnable-track {
  height: 6px; border-radius: 999px; border: none;
  background: linear-gradient(to right,
    var(--player-played) 0%, var(--player-played) var(--vol-pct, 100%),
    var(--player-track) var(--vol-pct, 100%), var(--player-track) 100%);
}
.screen-vol-slider::-moz-range-track {
  height: 6px; border-radius: 999px; border: none;
  background: var(--player-track);
}
.screen-vol-slider::-moz-range-progress {
  height: 6px; border-radius: 999px;
  background: var(--player-played);
}
.screen-vol-slider::-webkit-slider-thumb {
  -webkit-appearance: none; appearance: none;
  width: 13px; height: 13px; margin-top: -3.5px;
  border-radius: 50%;
  border: 2px solid var(--player-thumb-ring); background: var(--player-thumb);
  box-shadow: 0 1px 4px rgba(0,0,0,.28);
}
.screen-vol-slider::-moz-range-thumb {
  width: 13px; height: 13px; border-radius: 50%;
  border: 2px solid var(--player-thumb-ring); background: var(--player-thumb);
  box-shadow: 0 1px 4px rgba(0,0,0,.28);
}
.screen-vol-slider:focus-visible::-webkit-slider-thumb {
  box-shadow: 0 0 0 3px rgba(59,130,246,.35);
}
@media (max-width: 960px) {
  .screen-vol-popup { display: none; }
  .screen-volume.vol-open .screen-vol-popup {
    display: flex;
    position: absolute;
    top: calc(100% + 8px); left: 50%;
    transform: translateX(-50%);
    width: auto; height: auto;
    flex-direction: column; align-items: center;
    padding: 12px 14px;
    background: var(--bg-elev);
    border: 1px solid var(--border);
    border-radius: 12px;
    box-shadow: var(--shadow);
    z-index: 60;
  }
  .screen-volume.vol-open .screen-vol-slider {
    position: static; transform: none;
    -webkit-appearance: none; appearance: none;
    writing-mode: vertical-lr; direction: rtl;
    width: 28px; height: 96px; margin: 0; padding: 0;
    border: none; background: transparent; outline: none;
  }
  .screen-volume.vol-open .screen-vol-slider::-webkit-slider-runnable-track {
    width: 6px; height: 100%;
    border-radius: 999px; border: none;
    background: linear-gradient(to top,
      var(--player-played) 0%, var(--player-played) var(--vol-pct, 100%),
      var(--player-track) var(--vol-pct, 100%), var(--player-track) 100%);
  }
  .screen-volume.vol-open .screen-vol-slider::-moz-range-track {
    width: 6px; height: 96px;
    border-radius: 999px; border: none;
    background: var(--player-track);
  }
  .screen-volume.vol-open .screen-vol-slider::-moz-range-progress {
    width: 6px; border-radius: 999px;
    background: var(--player-played);
  }
  .screen-volume.vol-open .screen-vol-slider::-webkit-slider-thumb {
    -webkit-appearance: none; appearance: none;
    width: 13px; height: 13px;
    margin-top: 0; margin-left: -3.5px;
    border-radius: 50%;
    border: 2px solid var(--player-thumb-ring); background: var(--player-thumb);
    box-shadow: 0 1px 4px rgba(0,0,0,.28);
  }
  .screen-volume.vol-open .screen-vol-slider::-moz-range-thumb {
    width: 13px; height: 13px; border-radius: 50%;
    border: 2px solid var(--player-thumb-ring); background: var(--player-thumb);
    box-shadow: 0 1px 4px rgba(0,0,0,.28);
  }
}
/* Mic button: OFF (default) is red with the crossed-out mic; turning it ON
   makes it neutral/grey with the normal mic. (Inverted from the old scheme.) */
.screen-mic-btn { background: #ef4444; border-color: #ef4444; color: #fff; }
.screen-mic-btn:hover { background: #dc2626; border-color: #dc2626; color: #fff; }
.screen-mic-btn.mic-on {
  background: var(--bg-elev-2); border-color: var(--border); color: var(--text-dim);
}
.screen-mic-btn.mic-on:hover { background: var(--bg-hover); color: var(--text); }
.screen-status-icon { font-size: 46px; color: var(--text-faint); }
.screen-stage {
  position: relative;
  /* Letterbox bars follow the theme instead of a hard black so the modal
     looks right in both light and dark mode. */
  background: var(--bg-elev-2);
  border: 1px solid var(--border);
  border-radius: 12px;
  overflow: hidden;
  /* Fill the modal content box exactly so the video is evenly inset on every
     side (no extra overhang on the right). Allowed to shrink so the header +
     message composer always fit within the viewport. */
  width: 100%;
  height: min(80vh, 920px);
  flex: 1 1 auto; min-height: 0;
  display: flex; align-items: center; justify-content: center;
}
.screen-stage canvas {
  width: 100%; height: 100%;
  object-fit: contain;
  display: block;
  image-rendering: auto;
}
.screen-status {
  position: absolute; inset: 0;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 16px;
  color: var(--text-dim); font-size: 14px; letter-spacing: .2px;
  background: color-mix(in srgb, var(--bg-elev-2) 84%, transparent);
  backdrop-filter: blur(3px);
  pointer-events: none;
  text-align: center;
}
.screen-status-text { color: var(--text-dim); font-size: 14px; }
.screen-info-badge {
  position: absolute; top: 10px; left: 10px; z-index: 2;
  background: color-mix(in srgb, var(--bg-elev-2) 70%, transparent);
  backdrop-filter: blur(4px);
  color: var(--text-dim);
  font-size: 12px; font-variant-numeric: tabular-nums;
  padding: 4px 9px; border-radius: 8px;
  pointer-events: none;
  min-height: 1em;
}
/* Theme-aware preloader: a soft track in the current surface color with the
   accent sweeping around it. Works in both light and dark mode. */
.screen-spinner {
  width: 48px; height: 48px; border-radius: 50%;
  border: 3px solid color-mix(in srgb, var(--text-faint) 30%, transparent);
  border-top-color: var(--accent);
  animation: screenSpin .8s linear infinite;
}
@keyframes screenSpin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) {
  .screen-spinner { animation-duration: 1.8s; }
}

/* ---------- Fullscreen screen-share ---------- */
.screen-modal:fullscreen {
  max-width: none; width: 100vw; height: 100vh;
  border-radius: 0; padding: 14px;
  background: var(--bg);
  justify-content: flex-start;
}
.screen-modal:-webkit-full-screen {
  max-width: none; width: 100vw; height: 100vh;
  border-radius: 0; padding: 14px; background: var(--bg);
}
.screen-modal:fullscreen .screen-stage { height: auto; flex: 1 1 auto; min-height: 0; }
.screen-modal:-webkit-full-screen .screen-stage { height: auto; flex: 1 1 auto; min-height: 0; }
.stats-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.stat-card {
  background: var(--bg-elev-2); border: none; border-radius: 14px;
  padding: 20px 10px; text-align: center;
  min-height: 96px;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
}
.stat-value {
  font-size: 28px; font-weight: 700; color: var(--text);
  line-height: 1.15; font-variant-numeric: tabular-nums;
}
.stat-label {
  font-size: 11.5px; color: var(--text-dim); margin-top: 10px;
  line-height: 1.35; max-width: 11em;
}
.modal input {
  width: 100%; padding: 11px 13px; margin-bottom: 18px; background: var(--bg-elev-2);
  border: 1px solid var(--border); border-radius: 10px; color: var(--text); font-size: 15px; outline: none;
}
.modal input:focus { border-color: var(--accent); }
.modal-actions { display: flex; justify-content: flex-end; gap: 10px; }
.btn-primary {
  border: none; background: var(--accent); color: #fff; padding: 9px 18px;
  border-radius: 9px; cursor: pointer; font-size: 13px; font-weight: 400; transition: .15s;
}
.btn-primary:hover { background: var(--accent-hover); }
.btn-primary.danger { background: var(--red); }
.btn-primary.danger:hover { background: #dc2626; }
a.btn-primary { display: inline-flex; align-items: center; text-decoration: none; }

/* ---------- Scrollbars ---------- */
/* Straight (no rounded ends) everywhere there is scrolling. */
::-webkit-scrollbar { width: 9px; height: 9px; }
::-webkit-scrollbar-track { background: transparent; border-radius: 0; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 0; }
::-webkit-scrollbar-thumb:hover { background: var(--text-faint); }
* { scrollbar-color: var(--border) transparent; }

/* ---------- Responsive ---------- */
@media (max-width: 980px) {
  .sidebar { width: 280px; }
}
@media (max-width: 760px) {
  :root { --header-h: 68px; }
  .sidebar {
    position: fixed; inset: 0 auto 0 0; z-index: 40; width: 86%; max-width: 340px;
    transform: translateX(-100%); transition: transform .25s ease; box-shadow: var(--shadow);
    background: var(--bg-elev);
    backface-visibility: hidden;
    -webkit-backface-visibility: hidden;
  }
  .app.sidebar-open .sidebar { transform: translateX(0); }
  .app.sidebar-open .backdrop { display: block; position: fixed; inset: 0; background: rgba(0,0,0,.5); z-index: 35; }
  .content { position: relative; z-index: 1; }
  /* Hide toggle while the drawer is open or animating — no square bleed on the panel. */
  .app.sidebar-open .menu-toggle,
  .menu-toggle.menu-suppressed {
    visibility: hidden; opacity: 0; pointer-events: none;
  }
  .menu-toggle { display: inline-flex; }
  .app.no-branch .sidebar { position: static; transform: none; width: 100%; max-width: none; box-shadow: none; border-right: none; z-index: auto; }
  .app.no-branch .content { display: none; }
  .app.no-branch .backdrop { display: none; }
  .sidebar-header {
    min-height: var(--header-h); height: auto; padding: 10px 16px;
  }
  .content-header {
    padding: 10px 12px; gap: 10px; flex-wrap: nowrap; align-items: center;
    min-height: var(--header-h);
  }
  .header-info { flex: 1 1 0; min-width: 0; }
  .header-info h2 { font-size: 16px; line-height: 1.25; white-space: normal; }
  .branch-meta {
    flex-direction: column; align-items: flex-start; gap: 1px;
    font-size: 11.5px; line-height: 1.35; white-space: normal;
  }
  .branch-meta-last:not(:empty)::before { content: none; }
  .branch-meta-last { font-size: 11px; color: var(--text-faint); }
  .header-actions { flex: 0 0 auto; gap: 8px; }
  /* Mobile log table: Детали | Номер | Аудио — keep hidden cols in layout (no display:none). */
  .log-scroll { overflow-x: hidden; }
  .log-table {
    min-width: 0; width: 100%; table-layout: fixed;
  }
  .log-table col.col-time { width: 22%; }
  .log-table col.col-number { width: 48%; }
  .log-table col.col-rec { width: 30%; }
  .log-table col.col-account,
  .log-table col.col-status,
  .log-table col.col-dur { width: 0 !important; }
  .log-col-mobile-hide {
    width: 0 !important; max-width: 0 !important;
    padding: 0 !important; border: none !important;
    overflow: hidden; opacity: 0; pointer-events: none;
    font-size: 0; line-height: 0; white-space: nowrap;
  }
  .log-th-desktop, .log-time-desktop { display: none; }
  .log-th-mobile { display: inline; }
  .log-details-btn { display: inline-flex; align-items: center; justify-content: center; }
  .log-table thead th, .log-table tbody td { padding: 10px 6px; }
  .log-table thead th:first-child,
  .log-table tbody td.c-time { padding-left: 8px; padding-right: 4px; }
  .log-table thead th:last-child,
  .log-table tbody td.c-play { padding-left: 4px; padding-right: 8px; }
  .log-table { font-size: 12px; }
  .log-table thead th { font-size: 11px; white-space: nowrap; }
  .log-table .c-number { font-size: 13px; text-align: left; }
  .log-table .c-number .num-cell { justify-content: flex-start; }
  .log-table .c-play .rec-actions { gap: 4px; width: 100%; }
  .log-table .c-play .log-play,
  .log-table .c-play .log-download {
    width: 32px; height: 32px; min-width: 32px;
  }
  .admin-topbar { min-height: var(--header-h); height: auto; padding: 10px 16px; }
  .player {
    display: grid;
    grid-template-columns: 1fr auto auto;
    grid-template-rows: auto auto;
    gap: 8px;
    padding: 10px 12px;
    align-items: center;
  }
  .player-info {
    grid-column: 1 / -1;
    max-width: 100%;
    padding-left: 5px;
  }
  .player-controls {
    grid-column: 1;
    flex: none;
    min-width: 0;
    width: 100%;
    align-items: center;
  }
  .player-scrubber {
    flex: 1 1 0%;
    min-width: 0;
  }
  .player-volume { grid-column: 2; flex: none; align-items: center; }
  .player > .icon-btn { grid-column: 3; flex-shrink: 0; }
  .player-time { font-size: 11px; min-width: 0; flex-shrink: 0; }
  .screen-composer { padding: 8px 10px; margin-top: 10px; }
  .composer-field textarea {
    min-height: 42px; font-size: 16px; line-height: 20px;
    padding: 11px 40px 11px 12px;
  }
  .composer-send { right: 8px; top: 50%; transform: translateY(-50%); width: 26px; height: 26px; font-size: 15px; }
  /* Modals: centered card, not full-screen sheet */
  .modal-overlay { padding: 16px; align-items: center; justify-content: center; }
  .modal {
    width: 100%;
    max-width: min(420px, calc(100vw - 32px));
    border-radius: 16px;
    max-height: calc(100vh - 32px);
    padding: 20px;
  }
  .stats-modal { max-width: min(480px, calc(100vw - 32px)); }
  .active-calls-modal { max-width: min(420px, calc(100vw - 32px)); }
  .active-calls-list {
    --ac-row-h: 54px;
    --ac-row-gap: 8px;
    --ac-list-pad: 6px;
  }
  .active-calls-list:has(.ac-item) {
    height: min(var(--ac-list-h), calc(100vh - 9.5rem));
    max-height: min(var(--ac-list-h), calc(100vh - 9.5rem));
  }
  .active-calls-list:has(.ac-empty) {
    height: min(200px, calc(100vh - 9.5rem));
    max-height: min(200px, calc(100vh - 9.5rem));
  }
  .ac-item { padding: 10px 12px; gap: 10px; }
  .screen-modal {
    max-width: calc(100vw - 24px);
    max-height: calc(100vh - 24px);
    border-radius: 14px;
  }
  .screen-stage { height: min(56vh, 520px); }
}
@media (max-width: 560px) {
  .header-info h2 { font-size: 15px; }
  .branch-meta { font-size: 11px; }
  .empty-icon { width: 64px; height: 64px; }
  .empty-icon i { font-size: 26px; }
  .modal { padding: 18px 16px; }
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
  .ac-item { padding: 10px 12px; }
  .ac-item .ac-timer { font-size: 12px; padding: 3px 8px; }
  .ac-empty-icon { width: 64px; height: 64px; font-size: 24px; }
  .player-scrubber { min-width: 60px; }
  .num-cell { gap: 4px; }
  .rec-actions { gap: 4px; }
}
@media (max-width: 380px) {
  .stats-grid { grid-template-columns: 1fr; }
  .player-info span { max-width: 140px; overflow: hidden; text-overflow: ellipsis; }
}

/* ---------- Login logo ---------- */
.login-logo {
  display: block; margin: 0 auto 12px;
  max-width: 264px; max-height: 192px; width: auto; height: auto;
  object-fit: contain;
}

/* ---------- Admin page (/admin, /admin/managers, /admin/sip-pool) ---------- */
/* Full-screen shell: a persistent left sidebar (nav between the admin pages)
   next to a main column whose own content area scrolls -- the sidebar and
   the slim page-title bar stay put. */
.admin-page { height: 100vh; display: flex; background: var(--bg); overflow: hidden; }

.admin-sidebar {
  width: 220px; flex-shrink: 0; height: 100%;
  display: flex; flex-direction: column;
  background: var(--bg-elev); border-right: 1px solid var(--border);
}
.admin-sidebar-brand {
  display: flex; align-items: center; gap: 10px;
  padding: 18px 18px 14px;
  font-size: 15px; font-weight: 700; color: var(--text);
}
.admin-sidebar-brand i { color: var(--accent); font-size: 17px; }
.admin-sidebar-nav { flex: 1; min-height: 0; overflow-y: auto; padding: 6px 10px; display: flex; flex-direction: column; gap: 2px; }
.admin-sidebar-group-label {
  padding: 10px 12px 4px; font-size: 11px; font-weight: 700; text-transform: uppercase;
  letter-spacing: .5px; color: var(--text-faint);
}
.admin-sidebar-link {
  display: flex; align-items: center; gap: 11px;
  padding: 10px 12px; border-radius: 8px;
  color: var(--text-dim); text-decoration: none; font-size: 13.5px;
  transition: background .15s, color .15s;
}
.admin-sidebar-link i { width: 18px; text-align: center; font-size: 14px; flex-shrink: 0; }
.admin-sidebar-link:hover { background: var(--bg-hover); color: var(--text); }
.admin-sidebar-link.active { background: color-mix(in srgb, var(--accent) 16%, transparent); color: var(--accent); font-weight: 600; }
.admin-sidebar-foot {
  padding: 10px; border-top: 1px solid var(--border);
  display: flex; flex-direction: column; gap: 8px;
}
.admin-sidebar-foot-icons { display: flex; align-items: center; gap: 6px; }
.admin-sidebar-foot .icon-btn { flex-shrink: 0; }
.admin-sidebar-foot .admin-sidebar-link { flex: 1; }

.admin-main { flex: 1; min-width: 0; height: 100%; display: flex; flex-direction: column; }
.admin-topbar {
  display: flex; align-items: center; justify-content: space-between; gap: 14px;
  padding: 0 22px; min-height: var(--header-h); height: auto; flex-shrink: 0;
  background: var(--bg-elev); border-bottom: 1px solid var(--border);
  z-index: 10;
}
.admin-topbar-title {
  display: inline-flex; align-items: center; gap: 9px; min-width: 0;
  font-size: 15px; font-weight: 600; color: var(--text); line-height: 1;
}
.admin-topbar-title > span { line-height: 1.2; }
.admin-topbar-title > i {
  color: var(--text-dim);
  font-size: 15px; line-height: 1;
  display: block;
  transform: translateY(1px);
  flex-shrink: 0;
}
.admin-topbar-title > i::before {
  display: block;
  line-height: 1;
}
.admin-topbar-tools { display: flex; align-items: center; gap: 8px; flex-shrink: 0; }
.admin-topbar-tools a.icon-btn { text-decoration: none; }
.icon-btn.btn-ico-resp .btn-label { font-size: 13px; color: var(--text); }
.admin-content {
  flex: 1; min-height: 0; overflow-y: auto;
  padding: 22px 20px 40px;
}
/* Lock background scroll while a modal is open. */
body.modal-open .admin-content { overflow: hidden; }

@media (max-width: 900px) {
  .admin-sidebar { width: 60px; }
  .admin-sidebar-brand span, .admin-sidebar-link span, .admin-sidebar-foot .admin-sidebar-link span { display: none; }
  .admin-sidebar-brand { justify-content: center; padding: 18px 0 14px; }
  .admin-sidebar-group-label { display: none; }
  .admin-sidebar-link { justify-content: center; padding: 12px 0; }
  .admin-sidebar-link i { width: auto; }
  .admin-sidebar-foot-icons { flex-direction: column; }
}

/* Two balanced columns, centered as a group. Update sits under Storage,
   Cleanup under Managers (each column stacks its own cards). */
.admin-grid {
  width: 100%; max-width: 1080px; margin: 0 auto;
  display: grid; grid-template-columns: 1fr 1fr; gap: 18px; align-items: start;
}
.admin-col { display: flex; flex-direction: column; gap: 18px; min-width: 0; }

/* Full-width section below the two-column grid (e.g. the cleanup card, which
   wants more horizontal room for the date-range pickers than a half column
   gives it). Same max-width as .admin-grid so the two line up visually. */
.admin-section-wide { width: 100%; max-width: 1080px; margin: 18px auto 0; }

/* Single-column grid used by standalone full pages (e.g. /admin/managers)
   that don't need the two-column split. */
.admin-grid-single { grid-template-columns: 1fr; max-width: 900px; }

.admin-card {
  background: var(--bg-elev); border: 1px solid var(--border);
  border-radius: 4px; padding: 18px 20px;
  box-shadow: 0 1px 2px rgba(0,0,0,.06);
}
.admin-card h3 { margin: 0 0 14px; font-size: 15px; display: flex; align-items: center; gap: 9px; }
.admin-card h3 i { color: var(--accent); }
.admin-card-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 14px; }
.admin-card-head h3 { margin: 0; line-height: 1.25; }
.admin-card-head h3 > i {
  color: var(--accent);
  width: 1em; height: 1em;
  display: inline-flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.managers-title { display: inline; line-height: 1.25; }
.managers-title-label { vertical-align: middle; }
.managers-count {
  --mgr-count-size: 18px;
  display: inline-grid; place-items: center;
  vertical-align: middle;
  position: relative; top: 1px;
  margin-left: 7px;
  height: var(--mgr-count-size);
  min-width: var(--mgr-count-size);
  padding: 0 5px;
  line-height: 1; border-radius: 999px;
  background: var(--bg-elev-2); border: 1px solid var(--border);
  color: var(--text-dim);
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 11px; font-weight: 600;
  font-variant-numeric: tabular-nums lining-nums;
  font-feature-settings: "tnum" 1, "lnum" 1;
  letter-spacing: 0; text-transform: none;
  box-sizing: border-box; white-space: nowrap;
}
.managers-count.is-single {
  width: var(--mgr-count-size);
  min-width: var(--mgr-count-size);
  padding: 0;
}
.managers-count[data-digits="2"] { min-width: 24px; padding: 0 4px; font-size: 10.5px; }
.managers-count[data-digits="3"] { min-width: 30px; padding: 0 5px; font-size: 10px; }
.managers-count[data-digits="4"] { min-width: 36px; padding: 0 5px; font-size: 9.5px; }
.managers-count[data-digits="5"] { min-width: 42px; padding: 0 6px; font-size: 9px; }
.managers-count[data-digits="6"] { min-width: 48px; padding: 0 6px; font-size: 8.5px; }
.btn-sm { padding: 7px 12px; font-size: 12.5px; }
.btn-primary i, .btn-ghost i, .btn-danger i { margin-right: 4px; }

/* Pretty file input (replaces the default browser control). */
.file-input { position: relative; display: flex; align-items: center; gap: 12px; }
.file-input input[type="file"] {
  position: absolute; inset: 0; width: 100%; height: 100%;
  opacity: 0; cursor: pointer;
}
.file-input-btn {
  display: inline-flex; align-items: center; gap: 7px; flex-shrink: 0;
  padding: 9px 14px; border-radius: 4px; font-size: 13px;
  background: var(--bg-elev-2); border: 1px solid var(--border); color: var(--text);
  transition: .15s;
}
.file-input:hover .file-input-btn { background: var(--bg-hover); border-color: var(--accent); }
.file-input-name { font-size: 12.5px; color: var(--text-dim); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* Pagination */
.pager { display: flex; align-items: center; justify-content: center; gap: 14px; margin-top: 14px; }
.pager-btn {
  width: 32px; height: 32px; border-radius: 4px; cursor: pointer;
  background: var(--bg-elev-2); border: 1px solid var(--border); color: var(--text);
  display: inline-flex; align-items: center; justify-content: center; transition: .15s;
}
.pager-btn:hover:not(:disabled) { background: var(--bg-hover); border-color: var(--accent); }
.pager-btn:disabled { opacity: .4; cursor: default; }
.pager-info { font-size: 13px; color: var(--text-dim); min-width: 46px; text-align: center; }

/* Storage donut (SVG ring with rounded caps + value in the hole). */
.storage-wrap { display: flex; align-items: center; gap: 22px; flex-wrap: wrap; }
.storage-donut {
  --storage-rec: #22c55e;
  --storage-db: #a855f7;
  --storage-used: var(--accent);
  --storage-free: color-mix(in srgb, var(--text-faint) 35%, transparent);
  --track: color-mix(in srgb, var(--text-faint) 22%, var(--bg-elev));
  position: relative; width: 132px; height: 132px; flex-shrink: 0;
}
.storage-donut-svg {
  position: absolute; inset: 0; width: 100%; height: 100%;
  transform: rotate(-90deg);
}
.storage-donut-track,
.storage-donut-segment {
  fill: none;
  stroke-width: 10;
  stroke-linejoin: round;
}
.storage-donut-track { stroke: var(--track); transition: opacity .35s ease; }
.storage-donut-segment {
  fill: none;
  transition: stroke-dashoffset .55s ease, stroke-dasharray .55s ease;
}
.storage-seg-rec { stroke: #22c55e; }
.storage-seg-db { stroke: #a855f7; }
.storage-seg-used { stroke: var(--accent); }
.storage-seg-used-warn { stroke: #f59e0b; }
.storage-seg-used-danger { stroke: var(--red); }
.storage-seg-free { stroke: color-mix(in srgb, var(--text-faint) 55%, var(--bg-elev)); }
.storage-donut-hole {
  position: absolute; inset: 17px; border-radius: 50%;
  background: var(--bg-elev);
  display: flex; flex-direction: column; align-items: center; justify-content: center;
}
.storage-pct { font-size: 26px; font-weight: 700; color: var(--text); }
.storage-pct-sub { font-size: 11px; color: var(--text-dim); margin-top: 2px; }
.storage-legend { list-style: none; margin: 0; padding: 0; flex: 1; min-width: 200px; }
.storage-legend li { display: flex; align-items: center; gap: 9px; padding: 5px 0; font-size: 13px; color: var(--text-dim); }
.storage-legend li b { color: var(--text); font-weight: 600; margin-left: auto; }
.storage-legend .dot { width: 11px; height: 11px; border-radius: 3px; flex-shrink: 0; }
.storage-legend .dot.used { background: var(--accent); }
.storage-legend .dot.rec { background: #22c55e; }
.storage-legend .dot.db { background: #a855f7; }
.storage-legend .dot.total { background: #f59e0b; }
.storage-legend .dot.free { background: color-mix(in srgb, var(--text-faint) 35%, transparent); }
.storage-loading { color: var(--text-dim); }

/* Managers table — fixed height for exactly 5 rows + pagination */
.admin-card-managers {
  display: flex; flex-direction: column; min-width: 0;
  --mgr-row-h: 48px;
  --mgr-head-h: 36px;
  --mgr-btn-size: 32px;
  --mgr-actions-w: 116px;
  --mgr-page-rows: 5;
}
/* The standalone /admin/managers page has a full-width column to itself, so
   it shows twice as many rows per page before paginating. */
.admin-card-managers-full { --mgr-page-rows: 10; }
.managers-search.search-box { padding: 0 0 12px; flex-shrink: 0; }
.managers-table-wrap {
  position: relative;
  flex: 0 0 auto;
  min-width: 0;
  min-height: calc(var(--mgr-head-h) + var(--mgr-page-rows) * var(--mgr-row-h));
}
.managers-table {
  width: 100%; border-collapse: collapse; font-size: 13.5px; table-layout: fixed;
}
.managers-table col.col-check { width: 32px; }
.managers-table col.col-login { width: 22%; }
.managers-table col.col-name { width: calc(54% - var(--mgr-actions-w) - 32px); }
.managers-table col.col-team { width: 20%; }
.managers-table col.col-actions { width: var(--mgr-actions-w); }
.managers-table td.mt-check, .managers-table th.mt-check { text-align: center; padding: 0; }
.managers-table td.mt-check input, .managers-table th.mt-check input {
  width: 15px; height: 15px; cursor: pointer; accent-color: var(--accent); margin: 0;
}
.managers-bulk-bar {
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
  padding: 8px 0; margin: -4px 0 8px;
}
.managers-bulk-count { font-size: 12.5px; color: var(--text-dim); white-space: nowrap; }
.managers-bulk-bar input {
  flex: 1 1 140px; min-width: 100px; padding: 7px 10px;
  background: var(--bg-elev-2); border: 1px solid var(--border); border-radius: 8px;
  color: var(--text); outline: none; font-size: 12.5px;
}
.managers-bulk-bar input:focus { border-color: var(--accent); }
.managers-table thead th {
  text-align: left; padding: 0 10px; color: var(--text-dim); font-weight: 600;
  border-bottom: 1px solid var(--border); font-size: 12px; text-transform: uppercase; letter-spacing: .3px;
  height: var(--mgr-head-h); box-sizing: border-box; vertical-align: middle;
  white-space: nowrap;
}
.managers-table thead th.mt-actions { padding: 0 8px 0 0; }
.managers-table tbody tr { height: var(--mgr-row-h); }
.managers-table tbody td {
  padding: 0 10px; border-bottom: 1px solid var(--border); vertical-align: middle;
  height: var(--mgr-row-h); box-sizing: border-box;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.managers-table tbody tr.mgr-placeholder td { border-bottom: 1px solid var(--border); }
.managers-table tbody tr.mgr-placeholder { pointer-events: none; visibility: hidden; }
.managers-table .mt-login { font-family: ui-monospace, Menlo, Consolas, monospace; color: var(--text); }
.managers-table td.mt-actions,
.managers-table th.mt-actions {
  width: var(--mgr-actions-w); padding: 0 8px 0 0; overflow: visible;
}
.managers-table .mt-actions-inner {
  display: flex; align-items: center; justify-content: flex-end; gap: 4px;
  width: 100%; min-width: 0;
}
.managers-table .mt-actions .icon-btn {
  width: var(--mgr-btn-size); height: var(--mgr-btn-size);
  min-width: var(--mgr-btn-size); min-height: var(--mgr-btn-size);
  margin: 0; font-size: 13px; flex-shrink: 0;
}
.managers-empty {
  position: absolute; inset: var(--mgr-head-h) 0 0 0;
  display: flex; align-items: center; justify-content: center;
  padding: 18px; text-align: center; color: var(--text-dim); font-size: 13px;
}
.admin-card-managers .pager {
  flex: 0 0 auto;
  margin-top: 14px;
  min-height: 36px;
}

/* Generic labelled field rows (manager + update forms) */
.field-row { margin-bottom: 14px; }
.field-row label { display: block; font-size: 12.5px; color: var(--text-dim); margin-bottom: 6px; }
.field-row .req { color: var(--red); }
.field-row > input[type="text"],
.field-row > input[type="password"],
.field-row > input[type="date"],
.field-row > textarea {
  width: 100%; padding: 10px 12px; background: var(--bg-elev-2); border: 1px solid var(--border);
  border-radius: 4px; color: var(--text); font-size: 14px; outline: none;
  font-family: inherit; box-sizing: border-box;
}
.field-row > input[type="date"] { color-scheme: light dark; }
.field-row > select {
  width: 100%; padding: 10px 12px; background: var(--bg-elev-2); border: 1px solid var(--border);
  border-radius: 4px; color: var(--text); font-size: 14px; outline: none;
  font-family: inherit; box-sizing: border-box; color-scheme: light dark;
}
.field-row > select:focus { border-color: var(--accent); }
.field-row textarea { resize: vertical; min-height: 64px; line-height: 1.45; }
.field-row > input:focus,
.field-row > textarea:focus { border-color: var(--accent); }
.field-row > input:disabled {
  color: var(--text-dim);
  background: color-mix(in srgb, var(--bg-elev) 90%, var(--text-faint));
  border-color: color-mix(in srgb, var(--border) 70%, transparent);
  border-style: dashed;
  cursor: not-allowed;
  opacity: 1;
}
.field-row > input:disabled:focus { border-color: color-mix(in srgb, var(--border) 70%, transparent); }
.field-row.field-locked label .field-hint {
  display: inline;
  margin-left: 5px;
  font-weight: 400; color: var(--text-faint); font-size: 11.5px;
}
.field-row .field-hint { display: none; }
.field-hint-visible { display: inline !important; }
.manager-form-error { color: var(--red); font-size: 13px; min-height: 16px; margin-bottom: 6px; }

.input-with-btn {
  display: flex; align-items: stretch;
  width: 100%; box-sizing: border-box;
  background: var(--bg-elev-2); border: 1px solid var(--border);
  border-radius: 4px; overflow: hidden;
  transition: border-color .15s ease;
}
.input-with-btn:focus-within { border-color: var(--accent); }
.input-with-btn input {
  flex: 1 1 auto; min-width: 0; width: 0;
  padding: 10px 12px; margin: 0;
  border: none; border-radius: 0;
  background: transparent; box-shadow: none;
  color: var(--text); font-size: 14px; outline: none;
  font-family: inherit; box-sizing: border-box;
}
.input-with-btn input:focus { outline: none; }
.input-with-btn input.input-mono {
  font-family: ui-monospace, Menlo, Consolas, monospace;
  letter-spacing: .3px;
}
.input-side-btn {
  flex: 0 0 40px; align-self: stretch;
  border: none; border-left: 1px solid var(--border);
  background: transparent; color: var(--text-dim); cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center;
  padding: 0; margin: 0;
  transition: background .15s, color .15s;
}
.input-side-btn:hover { background: var(--bg-hover); color: var(--accent); }
.input-side-btn:focus { outline: none; }
.input-side-btn:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }

.update-current { font-size: 13px; color: var(--text-dim); margin-bottom: 14px; line-height: 1.5; }
.update-current b { color: var(--text); }
.update-actions { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 6px; }
.update-progress { margin-top: 10px; font-size: 12.5px; color: var(--text-dim); }

.update-enable-row {
  display: flex; align-items: center; gap: 10px;
  font-size: 13px; color: var(--text-dim); cursor: pointer;
  margin-bottom: 16px;
}
.switch { position: relative; display: inline-block; width: 36px; height: 20px; flex: none; }
.switch input { position: absolute; opacity: 0; width: 100%; height: 100%; margin: 0; cursor: pointer; }
.switch-track {
  position: absolute; inset: 0; border-radius: 20px;
  background: var(--bg-elev-2); border: 1px solid var(--border);
  transition: background .15s, border-color .15s;
}
.switch-track::before {
  content: ""; position: absolute; top: 2px; left: 2px; width: 14px; height: 14px;
  border-radius: 50%; background: var(--text-faint);
  transition: transform .15s, background .15s;
}
.switch input:checked + .switch-track { background: var(--accent); border-color: var(--accent); }
.switch input:checked + .switch-track::before { transform: translateX(16px); background: #fff; }
.switch input:focus-visible + .switch-track { outline: 2px solid var(--accent); outline-offset: 2px; }

.danger-actions { display: flex; gap: 10px; flex-wrap: wrap; }

/* SIP pool summary tiles */
.sip-counts { display: flex; gap: 12px; flex-wrap: wrap; margin-bottom: 16px; }
.sip-count-tile {
  flex: 1 1 120px; min-width: 100px; text-align: center;
  padding: 16px 10px; border-radius: 10px;
  background: var(--bg-elev-2); border: 1px solid var(--border);
  transition: transform .15s, border-color .15s;
}
.sip-count-tile:hover { transform: translateY(-1px); }
.sip-count-tile i { display: block; font-size: 15px; margin-bottom: 6px; opacity: .8; }
.sip-count-num { display: block; font-size: 26px; font-weight: 700; color: var(--text); font-variant-numeric: tabular-nums; }
.sip-count-label { display: block; margin-top: 4px; font-size: 12px; color: var(--text-dim); }
.sip-count-free { border-color: color-mix(in srgb, var(--green) 35%, var(--border)); }
.sip-count-free i, .sip-count-free .sip-count-num { color: var(--green); }
.sip-count-busy { border-color: color-mix(in srgb, var(--orange) 35%, var(--border)); }
.sip-count-busy i, .sip-count-busy .sip-count-num { color: var(--orange); }
.sip-count-all i { color: var(--accent); }

/* Sidebar-driven sections on /admin/sip-pool (Дашборд/Сотрудники/Номера/
   Настройки) -- only the one matching the URL hash is shown. */
.admin-grid-single > [data-view] { display: none; }
.admin-grid-single > [data-view].active-view { display: flex; flex-direction: column; gap: 18px; }

.sip-add-row { display: flex; gap: 16px; flex-wrap: wrap; }
.sip-add-row .field-row { flex: 1 1 180px; min-width: 160px; }

/* Small pill per assigned line in the "Сотрудники и линии" table -- an
   operator can hold more than one, so this needs to wrap onto its own row. */
.staff-line-tag {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 4px 4px 4px 10px; margin: 2px 4px 2px 0; border-radius: 999px;
  background: var(--bg-elev-2); border: 1px solid var(--border);
  font-size: 12.5px; white-space: nowrap;
  transition: border-color .15s;
}
.staff-line-tag:hover { border-color: color-mix(in srgb, var(--orange) 40%, var(--border)); }
.staff-line-release {
  width: 18px; height: 18px; border: none; border-radius: 50%; padding: 0;
  background: transparent; color: var(--text-faint); cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center; font-size: 10.5px;
  transition: .15s;
}
.staff-line-release:hover { background: rgba(239,68,68,.18); color: #ff9090; }
.staff-line-release:active { transform: scale(.92); }

.sip-status-dot { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; }
.sip-status-dot::before { content: ""; width: 7px; height: 7px; border-radius: 50%; flex-shrink: 0; }
.sip-status-busy { color: var(--orange); }
.sip-status-busy::before { background: var(--orange); }
.sip-status-free { color: var(--green); }
.sip-status-free::before { background: var(--green); }

/* Cleanup card: period presets + a from/to date range above the danger button. */
.cleanup-hint { font-size: 13px; color: var(--text-dim); margin: 0 0 16px; line-height: 1.5; max-width: 640px; }
.cleanup-presets { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 16px; }
.cleanup-preset {
  padding: 7px 14px; border-radius: 999px; font-size: 12.5px; cursor: pointer;
  background: var(--bg-elev-2); border: 1px solid var(--border); color: var(--text-dim);
  transition: .15s;
}
.cleanup-preset:hover { background: var(--bg-hover); color: var(--text); border-color: var(--accent); }
.cleanup-preset.active { background: var(--accent); border-color: var(--accent); color: #fff; }
.cleanup-range { display: flex; gap: 16px; flex-wrap: wrap; margin-bottom: 4px; }
.cleanup-range .field-row { flex: 1 1 200px; min-width: 160px; margin-bottom: 14px; }
.cleanup-range .field-row label { display: flex; align-items: center; gap: 6px; }
.cleanup-range .field-hint { display: inline; font-weight: 400; color: var(--text-faint); font-size: 11.5px; }

/* Strict (square) buttons inside the admin panel. */
.admin-page .btn-primary,
.admin-page .btn-ghost,
.admin-page .btn-danger,
.admin-page .icon-btn { border-radius: 4px; }

/* Admin modals: strict corners to match the panel. */
.admin-page ~ .modal-overlay .modal,
.modal-overlay .modal.admin-strict { border-radius: 6px; }

/* Managers card header action buttons (add / export / reset passwords). */
.managers-head-tools { display: flex; align-items: center; gap: 8px; flex-shrink: 0; }
.btn-icon-square {
  width: var(--icon-btn-size); height: var(--icon-btn-size);
  min-width: var(--icon-btn-size); min-height: var(--icon-btn-size);
  border-radius: 4px; cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center;
  font-size: var(--icon-btn-font); line-height: 1; padding: 0;
  border: 1px solid var(--border); background: var(--bg-elev-2); color: var(--text-dim);
  transition: .15s; box-sizing: border-box; flex-shrink: 0;
  -webkit-tap-highlight-color: transparent;
}
.btn-icon-square i { margin: 0; }
.btn-icon-square:hover { background: var(--bg-hover); color: var(--text); }
.btn-icon-square.btn-primary { border: none; background: var(--accent); color: #fff; }
.btn-icon-square.btn-primary:hover { background: var(--accent-hover); }

@media (max-width: 820px) {
  .admin-grid { grid-template-columns: 1fr; max-width: 560px; }
}
@media (max-width: 560px) {
  .storage-wrap { justify-content: center; }
  .admin-content { padding: 16px 14px 32px; }
  /* Icon-only topbar buttons on mobile — same square size as everywhere else. */
  .icon-btn.btn-ico-resp .btn-label { display: none; }
  .icon-btn.btn-ico-resp { width: var(--icon-btn-size); min-width: var(--icon-btn-size); padding: 0; }
}
