/* АйТелефон — UI v3 */
:root {
  --layout-max: 520px;
  --brand-blue: #0ea5e9;
  --brand-mid: #6366f1;
  --brand-purple: #7c3aed;
  --brand-gradient: linear-gradient(135deg, #38bdf8 0%, #6366f1 55%, #7c3aed 100%);
  --primary: #4f46e5;
  --primary-hover: #4338ca;
  --primary-soft: rgba(79, 70, 229, 0.1);
  --navy: #0f172a;
  --bg: #f8fafc;
  --bg-elevated: #ffffff;
  --surface: #ffffff;
  --surface-hover: #f1f5f9;
  --surface-muted: #e2e8f0;
  --input-bg: #ffffff;
  --border: #e2e8f0;
  --border-strong: #cbd5e1;
  --text: #0f172a;
  --text-secondary: #475569;
  --text-muted: #94a3b8;
  --accent: #4f46e5;
  --accent-2: #6366f1;
  --live: #059669;
  --live-dim: rgba(5, 150, 105, 0.1);
  --danger: #dc2626;
  --warn: #d97706;
  --radius: 12px;
  --radius-lg: 16px;
  --radius-sm: 10px;
  --dock-h: 64px;
  --safe-t: env(safe-area-inset-top, 0px);
  --safe-b: env(safe-area-inset-bottom, 0px);
  --font: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --shadow-sm: 0 1px 2px rgba(15, 23, 42, 0.04);
  --shadow: 0 8px 30px -12px rgba(15, 23, 42, 0.12);
  --ring: 0 0 0 3px var(--primary-soft);
  --ease-out: cubic-bezier(0.22, 1, 0.36, 1);
  --ease-spring: cubic-bezier(0.34, 1.45, 0.64, 1);
  --dur-fast: 0.15s;
  --dur-med: 0.28s;
  --dur-slow: 0.42s;
}

[data-theme="dark"] {
  color-scheme: dark;
  --bg: #0f172a;
  --bg-elevated: #1e293b;
  --surface: #1e293b;
  --surface-hover: #334155;
  --surface-muted: #475569;
  --input-bg: #1e293b;
  --border: #334155;
  --border-strong: #64748b;
  --text: #f1f5f9;
  --text-secondary: #cbd5e1;
  --text-muted: #94a3b8;
  --navy: #f1f5f9;
  --primary-soft: rgba(99, 102, 241, 0.22);
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.35);
  --shadow: 0 8px 30px -12px rgba(0, 0, 0, 0.55);
}

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

@keyframes viewEnter {
  from { opacity: 0; transform: translateY(14px); }
  to { opacity: 1; transform: translateY(0); }
}
@keyframes uiRise {
  from { opacity: 0; transform: translateY(10px) scale(0.98); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}
@keyframes uiFade {
  from { opacity: 0; }
  to { opacity: 1; }
}
@keyframes sheetBackdropIn {
  from { opacity: 0; }
  to { opacity: 1; }
}
@keyframes sheetPanelIn {
  from { opacity: 0; transform: translateY(100%); }
  to { opacity: 1; transform: translateY(0); }
}
@keyframes toastIn {
  from { opacity: 0; transform: translate(-50%, 12px) scale(0.96); }
  to { opacity: 1; transform: translate(-50%, 0) scale(1); }
}
@keyframes headerIn {
  from { opacity: 0; transform: translateY(-8px); }
  to { opacity: 1; transform: translateY(0); }
}

.ui-rise {
  animation: uiRise var(--dur-slow) var(--ease-out) both;
  animation-delay: var(--ui-delay, 0ms);
}
.ui-fade {
  animation: uiFade var(--dur-med) var(--ease-out) both;
  animation-delay: var(--ui-delay, 0ms);
}

/* SVG icons */
.ico {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  vertical-align: middle;
  color: inherit;
}
.ico svg { display: block; }
.ico--btn { color: currentColor; }
.ico--on-accent { color: var(--accent-2); }
.ico--live { color: var(--live); }
.ico--danger { color: var(--danger); }
.ico--muted { color: var(--text-muted); }
.chip .ico, .btn .ico { margin-right: 0; }
.chip { display: inline-flex; align-items: center; gap: 6px; }
.agent-tile__photo {
  width: 100%;
  height: 100%;
  border-radius: var(--radius-sm);
  object-fit: cover;
  flex-shrink: 0;
  background: var(--surface-hover);
  display: block;
}
.agent-tile__ava-wrap {
  position: relative;
  flex-shrink: 0;
  width: 48px;
  height: 48px;
  border-radius: var(--radius-sm);
  overflow: visible;
  cursor: pointer;
}
.agent-tile__ava-wrap .agent-tile__photo {
  border-radius: var(--radius-sm);
}
.agent-tile__ava-wrap .agent-tile__ava {
  width: 100%;
  height: 100%;
}
.agent-tile__ava-upload {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  border: none;
  border-radius: var(--radius-sm);
  background: rgba(15, 23, 42, 0.52);
  color: #fff;
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--dur-med) var(--ease-out), background var(--dur-fast) ease;
  -webkit-tap-highlight-color: transparent;
}
.agent-tile__ava-upload .ico { color: #fff; }
@media (hover: hover) {
  .agent-tile__ava-wrap:hover .agent-tile__ava-upload {
    opacity: 1;
  }
  .agent-tile__ava-upload:hover {
    background: rgba(79, 70, 229, 0.72);
  }
}
@media (hover: none) {
  .agent-tile__ava-upload:focus-visible {
    opacity: 1;
  }
}
.agent-tile__ava-upload:active {
  background: rgba(79, 70, 229, 0.85);
  opacity: 1;
}
.agent-tile__ava .ico,
.editor-hero__ava .ico {
  color: #fff;
  opacity: 0.95;
}
.iconbtn .ico { margin: 0; }
.stat-card .ico { margin-bottom: 6px; color: var(--accent-2); }

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
html, body { margin: 0; padding: 0; overflow-x: hidden; }
body {
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.5;
  color: var(--text);
  background: var(--bg);
  min-height: 100dvh;
  -webkit-font-smoothing: antialiased;
  padding-bottom: calc(var(--dock-h) + var(--safe-b) + 12px);
}
button, input, select, textarea { font: inherit; color: inherit; }

.ambient {
  position: fixed;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  background: var(--bg);
}

.shell {
  width: 100%;
  max-width: 520px;
  margin: 0 auto;
  padding: calc(var(--safe-t) + 20px) 16px 0;
  box-sizing: border-box;
}

/* Header */
.app-header {
  margin: 0 0 26px;
  padding: 0;
  animation: headerIn 0.55s var(--ease-out) 0.04s both;
}
.shell--hide-header .app-header,
.app-header[hidden] {
  display: none !important;
  margin: 0;
  animation: none;
}
.shell--hide-header {
  padding-top: calc(var(--safe-t) + 12px);
}
.app-header__row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
}
.app-header__brand {
  display: flex;
  gap: 12px;
  align-items: center;
  min-width: 0;
  flex: 1;
}
.app-header__mark {
  width: 48px;
  height: 48px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: visible;
}
.brand-logo {
  display: block;
  width: 48px;
  height: 48px;
  object-fit: contain;
  object-position: center;
}
.app-header__text { min-width: 0; }
.app-header__title {
  margin: 0;
  font-size: 1.35rem;
  font-weight: 700;
  letter-spacing: -0.03em;
  line-height: 1.15;
}
.brand-word-ai {
  background: var(--brand-gradient);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
}
.brand-word-tel { color: var(--navy); }
.app-header__tagline {
  margin: 4px 0 0;
  font-size: 0.72rem;
  font-weight: 500;
  letter-spacing: 0.01em;
  color: var(--text-muted);
  line-height: 1.3;
}
.app-header__tagline--company {
  font-size: 0.8125rem;
  font-weight: 600;
  color: var(--text-secondary);
  letter-spacing: 0;
}
.app-header__company-title {
  flex: 1;
  min-width: 0;
  margin: 0;
  font-size: 1.35rem;
  font-weight: 700;
  letter-spacing: -0.03em;
  line-height: 1.15;
  color: var(--navy);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.app-header__company-title[hidden],
#appHeaderBrand[hidden] {
  display: none !important;
}
.app-header--company .app-header__row {
  align-items: center;
  gap: 8px;
}
.app-header--company .app-header__company-title {
  flex: 1 1 0;
  min-width: 0;
  font-size: 1.05rem;
  line-height: 1.25;
  white-space: normal;
  overflow: visible;
  text-overflow: unset;
  overflow-wrap: break-word;
  word-break: break-word;
}
.app-header--company #btnOpenQuickCall {
  display: none !important;
}
.app-header:not(.app-header--company) #btnHeaderAddStaff {
  display: none !important;
}
.app-header__actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}
.btn--call-header {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  flex-shrink: 0;
  padding: 10px 16px;
  border-radius: var(--radius-sm);
  border: none;
  background: var(--primary);
  color: #fff;
  font-size: 0.8125rem;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  box-shadow: var(--shadow-sm);
  transition:
    background var(--dur-med) var(--ease-out),
    transform var(--dur-fast) var(--ease-out),
    box-shadow var(--dur-med) var(--ease-out);
}
.btn--call-header svg { flex-shrink: 0; stroke: currentColor; transition: transform var(--dur-med) var(--ease-out); }
@media (hover: hover) {
  .btn--call-header:hover {
    background: var(--primary-hover);
    box-shadow: 0 6px 18px rgba(79, 70, 229, 0.22);
    transform: translateY(-1px);
  }
}
.btn--call-header:active {
  background: var(--primary-hover);
  transform: scale(0.97) translateY(0);
  box-shadow: var(--shadow-sm);
}
.btn--icon-header {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  width: 40px;
  height: 40px;
  padding: 0;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text-secondary);
  font-family: inherit;
  cursor: pointer;
  box-shadow: var(--shadow-sm);
  transition:
    background var(--dur-med) var(--ease-out),
    border-color var(--dur-med) var(--ease-out),
    color var(--dur-med) var(--ease-out),
    transform var(--dur-fast) var(--ease-out);
}
.btn--icon-header svg { flex-shrink: 0; }
@media (hover: hover) {
  .btn--icon-header:hover {
    background: var(--surface-hover);
    border-color: var(--border-strong);
    color: var(--text);
  }
}
.btn--icon-header:active {
  transform: scale(0.94);
  background: var(--surface-hover);
}
.app-header__link {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--accent-2);
  text-decoration: none;
  padding: 8px 12px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--surface);
}

/* Views */
.views { min-height: 40vh; }
#viewAgents > .toolbar { margin-top: 0; }
.view { display: none; }
.view.view--active { display: block; }
.view.view--active.view--enter {
  animation: viewEnter var(--dur-slow) var(--ease-out) both;
}

/* Toolbar */
.toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}
.toolbar__title { margin: 0; font-size: 1.125rem; font-weight: 600; letter-spacing: -0.02em; }
.toolbar__heading {
  display: flex;
  align-items: baseline;
  gap: 8px;
  flex-wrap: wrap;
  min-width: 0;
}
.toolbar__count {
  font-size: 0.8125rem;
  font-weight: 500;
  color: var(--text-muted);
  line-height: 1.25;
  white-space: nowrap;
}
.toolbar__hint { margin: 4px 0 0; font-size: 0.8125rem; color: var(--text-muted); line-height: 1.4; }

/* Agent grid */
.agent-grid {
  display: flex;
  flex-direction: column;
  gap: 10px;
  width: 100%;
  min-width: 0;
}
.agent-tile {
  position: relative;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 16px;
  border-radius: var(--radius);
  background: var(--surface);
  border: 1px solid var(--border);
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
  transition:
    background var(--dur-med) var(--ease-out),
    border-color var(--dur-med) ease,
    transform var(--dur-fast) var(--ease-out),
    box-shadow var(--dur-med) var(--ease-out);
  text-align: left;
  width: 100%;
  max-width: 100%;
  min-width: 0;
  box-sizing: border-box;
  color: inherit;
}
@media (hover: hover) {
  .agent-tile:hover {
    background: var(--surface-hover);
    box-shadow: var(--shadow-sm);
    transform: translateY(-2px);
  }
}
.agent-tile:active { transform: scale(0.98) translateY(0); }
.agent-tile--blocked {
  opacity: 0.72;
  cursor: not-allowed;
  background: var(--surface-muted);
  border-color: var(--border);
  border-style: dashed;
}
.agent-tile--blocked .agent-tile__photo,
.agent-tile--blocked .agent-tile__ava,
.agent-tile--blocked .agent-tile__ava-wrap {
  filter: grayscale(0.85);
  opacity: 0.75;
}
.agent-tile--blocked .agent-tile__ava-wrap {
  cursor: not-allowed;
  pointer-events: none;
}
@media (hover: hover) {
  .agent-tile--blocked:hover {
    background: var(--surface-muted);
    box-shadow: none;
    transform: none;
  }
}
.badge-blocked {
  display: inline-block;
  margin-left: 6px;
  padding: 2px 7px;
  border-radius: 999px;
  font-size: 0.625rem;
  font-weight: 600;
  color: var(--text-muted);
  background: var(--surface-hover);
  vertical-align: middle;
}
.agent-tile__ava {
  width: 48px; height: 48px;
  border-radius: var(--radius-sm);
  display: flex; align-items: center; justify-content: center;
  font-size: 1.35rem;
  flex-shrink: 0;
  background: #7c3aed;
  color: #fff;
}
.agent-tile__body { flex: 1; min-width: 0; }
.agent-tile__name {
  font-weight: 600;
  font-size: 0.95rem;
  display: flex;
  align-items: center;
  gap: 8px;
}
.agent-tile__meta {
  display: none !important;
}
.agent-tile__actions {
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 4px;
  flex-shrink: 0;
}
.agent-tile__duplicate,
.agent-tile__delete {
  flex-shrink: 0;
  width: 34px;
  height: 34px;
  margin-left: 2px;
  padding: 0;
  border: none;
  border-radius: 10px;
  background: transparent;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 1;
  cursor: pointer;
  transition: background var(--dur-fast) ease;
  -webkit-tap-highlight-color: transparent;
}
@media (hover: hover) {
  .agent-tile__duplicate:hover {
    background: rgba(79, 70, 229, 0.12);
  }
  .agent-tile__delete:hover {
    background: rgba(239, 68, 68, 0.12);
  }
}
.agent-tile__duplicate:active {
  background: rgba(79, 70, 229, 0.18);
}
.agent-tile__delete:active {
  background: rgba(239, 68, 68, 0.18);
}
.agent-tile--blocked .agent-tile__duplicate,
.agent-tile--blocked .agent-tile__delete {
  display: none;
}
.badge-incoming {
  font-size: 0.6875rem;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 6px;
  background: var(--live-dim);
  color: var(--live);
  border: 1px solid rgba(5, 150, 105, 0.2);
}
.agent-tile__incoming-badge {
  position: absolute;
  right: -3px;
  bottom: -3px;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--live);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 2px solid var(--surface);
  pointer-events: none;
  z-index: 2;
}
.agent-tile__incoming-badge .ico {
  width: 10px;
  height: 10px;
}

/* Dock */
.dock {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  width: 100%;
  max-width: var(--layout-max);
  margin: 0 auto;
  display: flex;
  gap: 0;
  padding: 6px 8px calc(6px + var(--safe-b));
  border-radius: 0;
  background: rgba(255, 255, 255, 0.92);
  border: none;
  border-top: 1px solid var(--border);
  backdrop-filter: blur(16px) saturate(1.2);
  -webkit-backdrop-filter: blur(16px) saturate(1.2);
  box-shadow: 0 -1px 0 rgba(15, 23, 42, 0.04);
  z-index: 100;
}
[data-theme="dark"] .dock {
  background: rgba(30, 41, 59, 0.94);
  border-top-color: var(--border);
  box-shadow: 0 -1px 0 rgba(0, 0, 0, 0.25);
}
.dock__item {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  padding: 6px 4px;
  border: none;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--text-muted);
  font-size: 0.625rem;
  font-weight: 500;
  cursor: pointer;
  transition:
    color var(--dur-med) var(--ease-out),
    transform var(--dur-fast) var(--ease-spring);
}
.dock__item svg {
  opacity: 0.55;
  transition: opacity var(--dur-med) ease, transform var(--dur-med) var(--ease-out), stroke var(--dur-med) ease;
}
.dock__item:active { transform: scale(0.9); }
.dock__item--on {
  color: var(--primary);
  background: transparent;
}
.dock__item--on svg { opacity: 1; stroke: var(--primary); transform: scale(1.06); }
.dock__item[hidden],
[hidden].dock__item { display: none !important; }
.shell--superadmin .dock {
  justify-content: center;
  gap: 0;
}
.shell--superadmin .dock__item:not(#dockAdmin) {
  display: none !important;
  width: 0 !important;
  min-width: 0 !important;
  padding: 0 !important;
  margin: 0 !important;
  overflow: hidden !important;
  pointer-events: none !important;
  opacity: 0 !important;
}

/* Panels */
.panel {
  padding: 18px;
  border-radius: var(--radius-lg);
  background: var(--surface);
  border: 1px solid var(--border);
  margin-bottom: 16px;
}
.panel--flat { margin-bottom: 12px; }

/* Аналитика — дашборд / звонки (только когда вкладка активна) */
#viewHistory.view--active {
  display: flex;
  flex-direction: column;
  gap: 14px;
}
#viewHistory .hist-subseg {
  margin-bottom: 0;
}
.hist-panel[hidden] {
  display: none !important;
}
#viewHistory .dash.panel,
.sa-company-body .dash.panel,
.hist-filters.panel {
  margin-bottom: 12px;
}
#viewHistory .dash.panel,
#viewHistory .hist-filters.panel {
  margin-top: 0;
}
.hist-filters.panel {
  padding: 8px 10px;
  border-radius: 10px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.hist-filters__search.search {
  width: 100%;
  margin: 0;
  padding: 0 8px;
  min-height: 32px;
  gap: 6px;
  border-radius: 8px;
}
.hist-filters__search input {
  padding: 6px 0;
  font-size: 0.8rem;
}
.hist-filters__row {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 6px;
  align-items: stretch;
}
.hist-filters__row .select-wrap--xs {
  min-width: 0;
}
.hist-filters__row .select-wrap--xs select {
  min-height: 32px;
  padding: 6px 8px;
  font-size: 0.72rem;
}
.hist-filters__toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 3px;
  flex-shrink: 0;
  padding: 6px 8px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--input-bg);
  color: var(--text-secondary);
  font-size: 0.65rem;
  font-weight: 600;
  cursor: pointer;
  transition: border-color 0.15s, color 0.15s;
  white-space: nowrap;
}
.hist-filters__dates {
  display: flex;
  align-items: center;
  gap: 4px;
}
.hist-filters__dates .input--xs {
  flex: 1;
  min-width: 0;
  padding: 4px 6px;
  min-height: 28px;
  font-size: 0.68rem;
  color: var(--text-muted);
}
.hist-filters__sep {
  flex-shrink: 0;
  font-size: 0.7rem;
  color: var(--text-muted);
}
.hist-filters__toggle[aria-expanded="true"] {
  border-color: var(--primary);
  color: var(--primary);
  background: var(--primary-soft);
}
.hist-filters__toggle[aria-expanded="true"] .hist-filters__chev {
  transform: rotate(180deg);
}
.hist-filters__chev {
  transition: transform 0.2s;
  opacity: 0.7;
}
.hist-filters__badge {
  font-size: 0.6875rem;
  font-weight: 600;
  padding: 2px 6px;
  border-radius: 6px;
  background: var(--primary-soft);
  color: var(--primary);
}
.hist-filters__extra {
  display: flex;
  flex-direction: column;
  gap: 5px;
  padding-top: 2px;
}
.hist-filters__extra:not([hidden]) {
  animation: uiFade var(--dur-med) var(--ease-out) both;
}
.hist-filters__extra[hidden] { display: none; }
.hist-filters__rec.check--sm {
  margin: 0;
  padding: 2px 0 0;
  font-size: 0.68rem;
}
input.input--xs,
textarea.input--xs {
  padding: 6px 8px;
  font-size: 0.78rem;
  border-radius: 8px;
  line-height: 1.2;
  min-height: 32px;
  height: auto;
  box-sizing: border-box;
  width: 100%;
}
#viewHistory .hist-filters input[type="date"].input--xs,
.dash-dates .input--xs {
  padding: 5px 6px;
  font-size: 0.75rem;
}
.check--sm {
  flex-shrink: 0;
  margin: 0;
  font-size: 0.62rem;
  gap: 3px;
  white-space: nowrap;
}
.check--sm input { width: 12px; height: 12px; accent-color: var(--accent); }
#viewHistory .stat-row { margin-bottom: 10px; }

.dash { padding: 8px 10px; display: flex; flex-direction: column; gap: 8px; }
.dash-filters-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}
.select-wrap--period {
  flex: 1;
  min-width: 140px;
}
.period-custom[hidden] {
  display: none !important;
}
.period-custom.dash-dates {
  flex: 1 1 100%;
}
.dash-dates {
  display: flex;
  align-items: center;
  gap: 4px;
}
.dash-dates .input--xs {
  flex: 1;
  min-width: 0;
  color: var(--text-muted);
}
.dash-dates__sep {
  flex-shrink: 0;
  font-size: 0.72rem;
  color: var(--text-muted);
}
.dash-selects {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 4px;
}
.dash-selects .select-wrap--xs { min-width: 0; }
.dash-body { display: flex; flex-direction: column; gap: 10px; }
.dash-kpi {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}
.dash-kpi__card {
  padding: 12px 12px 10px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: var(--surface);
}
.dash-kpi__card--wide { grid-column: 1 / -1; }
.dash-kpi__val {
  font-size: 1.35rem;
  font-weight: 700;
  line-height: 1.1;
  color: var(--text);
}
.dash-kpi__val--ok { color: var(--live); }
.dash-kpi__val--warn { color: #c47a00; }
.dash-kpi__val--err { color: var(--danger); }
.dash-kpi__lbl {
  margin-top: 4px;
  font-size: 0.72rem;
  font-weight: 500;
  color: var(--text-muted);
}
.dash-kpi__sub {
  margin-top: 2px;
  font-size: 0.65rem;
  color: var(--text-muted);
}
.dash-section {
  padding: 12px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: var(--surface);
}
.dash-section__title {
  margin: 0 0 10px;
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--text-secondary);
}
.dash-bars { display: flex; flex-direction: column; gap: 8px; }
.dash-bar { display: flex; flex-direction: column; gap: 4px; }
.dash-bar__head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 8px;
  font-size: 0.75rem;
}
.dash-bar__name { font-weight: 600; color: var(--text); }
.dash-bar__cnt { color: var(--text-muted); font-variant-numeric: tabular-nums; }
.dash-bar__track {
  height: 6px;
  border-radius: 999px;
  background: var(--surface-hover);
  overflow: hidden;
}
.dash-bar__fill {
  height: 100%;
  border-radius: 999px;
  background: var(--primary);
  transition: width 0.35s var(--ease-out);
}
.dash-bar__fill--ok { background: var(--live); }
.dash-bar__fill--warn { background: #e8a317; }
.dash-bar__fill--err { background: var(--danger); }
.dash-bar__fill--muted { background: var(--text-muted); }
.dash-bar__fill--retry { background: #e8a317; }
.dash-chart__seg--retry { background: #e8a317; }
.dash-chart {
  display: flex;
  align-items: flex-end;
  gap: 4px;
  height: 88px;
  padding-top: 4px;
}
.dash-chart__col {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  height: 100%;
  justify-content: flex-end;
}
.dash-chart__stack {
  width: 100%;
  max-width: 22px;
  display: flex;
  flex-direction: column-reverse;
  border-radius: 4px 4px 2px 2px;
  overflow: hidden;
  min-height: 2px;
}
.dash-chart__seg { width: 100%; }
.dash-chart__seg--ok { background: var(--live); }
.dash-chart__seg--warn { background: #e8a317; }
.dash-chart__seg--err { background: var(--danger); }
.dash-chart__lbl {
  font-size: 0.6rem;
  color: var(--text-muted);
  white-space: nowrap;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  text-align: center;
}
.dash-chart--week {
  gap: 6px;
}
.dash-chart--week .dash-chart__lbl {
  font-size: 0.68rem;
  font-weight: 600;
  text-transform: lowercase;
}
.dash-chart--dense .dash-chart__lbl { font-size: 0.5rem; }
.dash-chart--dense .dash-chart__col { min-width: 0; }
.dash-chart--dense .dash-chart__lbl {
  max-width: 52px;
  overflow: hidden;
  text-overflow: ellipsis;
}
.dash-chart__empty {
  font-size: 0.78rem;
  color: var(--text-muted);
  text-align: center;
  padding: 16px 0;
  width: 100%;
}
.panel__title { margin: 0 0 6px; font-size: 1.05rem; font-weight: 700; }
.panel__lead { margin: 0 0 16px; font-size: 0.85rem; color: var(--text-secondary); line-height: 1.45; }
.panel__lead strong { color: var(--live); font-weight: 600; }

/* Segmented control */
.seg {
  display: flex;
  gap: 4px;
  padding: 4px;
  margin-bottom: 16px;
  border-radius: var(--radius);
  background: var(--surface);
  border: 1px solid var(--border);
}
.seg__btn {
  flex: 1;
  padding: 10px;
  border: none;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--text-muted);
  font-weight: 600;
  font-size: 0.85rem;
  cursor: pointer;
  transition:
    background var(--dur-med) var(--ease-out),
    color var(--dur-med) ease,
    box-shadow var(--dur-med) ease,
    transform var(--dur-fast) var(--ease-out);
}
.seg__btn:active { transform: scale(0.97); }
.seg__btn--on {
  background: var(--surface);
  color: var(--text);
  box-shadow: var(--shadow-sm);
}
.lang-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
}
.flag {
  font-size: 1.05rem;
  line-height: 1;
}
.seg--field { margin-bottom: 0; }
.seg--single .seg__btn[data-mode="incoming"] { display: none; }
.seg--single .seg__btn { flex: 1; }
.profile-apply-btn { margin-top: 8px; }
.profile-apply-btn[hidden] { display: none !important; }
.hist-scroll-sentinel { height: 1px; pointer-events: none; }
.co-phone-bar { margin-bottom: 16px; }
.co-phone-row { display: flex; gap: 8px; align-items: center; }
.co-phone-row .input { flex: 1; min-width: 0; }
.agent-tile__mode {
  font-size: 0.68rem;
  color: var(--text-muted);
  margin-top: 2px;
  font-variant-numeric: tabular-nums;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 4px;
}
.agent-tile__meta-sep {
  opacity: 0.45;
  user-select: none;
}
.agent-tile__meta-phone {
  font-variant-numeric: tabular-nums;
}
.agent-tile__dir {
  display: inline-flex;
  align-items: center;
  gap: 4px;
}
.agent-tile__dir-btn {
  min-width: 28px;
  height: 22px;
  padding: 0 6px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--surface-muted);
  color: var(--text-muted);
  font-size: 0.625rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  line-height: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition:
    background var(--dur-fast) ease,
    border-color var(--dur-fast) ease,
    color var(--dur-fast) ease,
    transform var(--dur-fast) var(--ease-out);
  -webkit-tap-highlight-color: transparent;
}
.agent-tile__dir-btn--on {
  background: rgba(91, 141, 239, 0.14);
  border-color: rgba(91, 141, 239, 0.35);
  color: var(--brand-mid);
}
.agent-tile__dir-btn--on[data-dir="in"] {
  background: var(--live-dim);
  border-color: rgba(5, 150, 105, 0.35);
  color: var(--live);
}
.agent-tile__dir-btn:active { transform: scale(0.92); }
.campaign-panel { margin-bottom: 20px; }
.campaign-panel__inner {
  padding: 18px;
  border-radius: var(--radius-lg);
  background: var(--surface);
  border: 1px solid var(--border);
  transition: border-color var(--dur-med) ease, box-shadow var(--dur-med) ease;
}
.campaign-panel--run {
  border-color: rgba(52, 211, 153, 0.35);
  box-shadow: 0 0 0 1px rgba(52, 211, 153, 0.12);
}
.campaign-panel__head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
  margin-bottom: 14px;
}
.campaign-panel__title { font-size: 1.05rem; font-weight: 700; margin-bottom: 4px; }
.campaign-panel__meta { font-size: 0.8rem; color: var(--text-muted); line-height: 1.4; }
.campaign-panel__badge {
  flex-shrink: 0;
  font-size: 0.7rem;
  font-weight: 700;
  padding: 5px 10px;
  border-radius: 999px;
  background: var(--live-dim);
  color: var(--live);
}
.campaign-panel__badge--idle {
  background: rgba(91, 141, 239, 0.14);
  color: var(--brand-mid);
}
.campaign-progress { margin-bottom: 12px; }
.campaign-panel__actions {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.campaign-panel__actions--compact {
  flex-direction: row;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 10px;
}
.campaign-panel__actions--compact .btn {
  width: auto;
  min-height: 34px;
  padding: 6px 12px;
  font-size: 0.78rem;
  font-weight: 600;
  border-radius: 8px;
  white-space: nowrap;
}
.campaign-panel__actions--compact .btn--block {
  width: auto;
}
.campaign-panel__actions--compact .btn--start-call {
  flex: 1 1 100%;
  min-width: 0;
}
.campaign-panel__actions--compact .btn--ghost:not(.btn--cancel-queue) {
  flex: 1 1 calc(50% - 3px);
  min-width: 0;
}
.campaign-panel__actions--compact .btn--cancel-queue {
  flex: 1 1 100%;
  min-height: 32px;
  font-size: 0.74rem;
  font-weight: 500;
  color: var(--text-muted);
  border-color: var(--border);
}
.campaign-panel__actions .btn--cancel-queue {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
}
.btn--start-call {
  background: var(--primary);
  color: #fff;
  border: none;
  font-weight: 600;
  box-shadow: var(--shadow-sm);
}
@media (hover: hover) {
  .btn--start-call:hover:not(:disabled) {
    background: var(--primary-hover);
    box-shadow: 0 10px 26px rgba(79, 70, 229, 0.28);
    transform: translateY(-2px);
  }
}
.sheet--manual { align-items: stretch; }
.sheet__body--manual {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
  overflow: hidden;
}
.panel__lead--compact { margin-bottom: 10px; font-size: 0.8rem; }
.manual-rows-scroller {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-bottom: 12px;
}
.toolbar__actions { display: flex; gap: 8px; flex-shrink: 0; }
.outreach-toolbar {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  margin-bottom: 8px;
}
.outreach-toolbar__back {
  flex-shrink: 0;
  margin-top: 2px;
  width: 36px;
  height: 36px;
  border-radius: 10px;
}
.outreach-toolbar__back[hidden] { display: none !important; }
.outreach-toolbar__body {
  flex: 1;
  min-width: 0;
}
.outreach-toolbar__body .toolbar__title {
  margin: 0;
  line-height: 1.25;
}
.outreach-toolbar__body .toolbar__hint {
  margin: 4px 0 0;
}
.outreach-import-bar {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  align-items: stretch;
  margin-bottom: 12px;
}
.outreach-import-bar[hidden],
#outreachListView[hidden],
#outreachDetailView[hidden] {
  display: none !important;
}
.outreach-import-bar .btn--upload,
.outreach-import-bar .btn--manual {
  flex: none;
  width: 100%;
  min-height: 44px;
  margin: 0;
  padding: 8px 10px;
  border-radius: var(--radius-sm);
  justify-content: center;
  text-align: center;
}
.btn--upload {
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
}
.btn--upload--inline { max-width: none; }
.btn--upload__text {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1px;
  min-width: 0;
}
.btn--upload__title { font-size: 0.8125rem; font-weight: 600; line-height: 1.2; }
.btn--upload__sub { font-size: 0.6875rem; font-weight: 500; color: rgba(255, 255, 255, 0.75); }
.btn--manual {
  font-size: 0.8rem;
  white-space: nowrap;
}
.btn--upload-mini {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 0.75rem;
  padding: 6px 10px;
}
.campaign-panel__tools {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin: 0 0 10px;
  padding-bottom: 2px;
}
.btn--cancel-queue {
  color: var(--danger);
  border-color: rgba(220, 38, 38, 0.25);
}
@media (hover: hover) {
  .btn--cancel-queue:hover:not(:disabled) {
    background: rgba(220, 38, 38, 0.06);
    border-color: rgba(220, 38, 38, 0.4);
  }
}
.queue-call-list {
  margin: 14px 0 16px;
  max-height: min(42vh, 320px);
  overflow-y: auto;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--input-bg);
}
.queue-call-list__hint {
  padding: 8px 12px;
  font-size: 0.72rem;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border);
}
.queue-call-item {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
}
.queue-call-item__body--tap { cursor: pointer; }
.queue-call-item__meta {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-top: 5px;
}
.queue-call-item__tag {
  font-size: 0.65rem;
  font-weight: 600;
  padding: 2px 7px;
  border-radius: 6px;
  background: var(--surface-hover);
  color: var(--text-muted);
  border: 1px solid var(--border);
}
.queue-call-item__tag--ok { color: var(--live); border-color: rgba(5, 150, 105, 0.25); background: var(--live-dim); }
.queue-call-item__tag--err { color: var(--danger); border-color: rgba(248, 113, 113, 0.25); background: rgba(248, 113, 113, 0.08); }
.queue-call-item__tag--mute { color: var(--text-secondary); }
.queue-call-item__retry {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  margin-top: 0.35rem;
  font-size: 0.75rem;
  color: var(--warn, #b45309);
  font-weight: 500;
}
.queue-call-item__retry--eta {
  color: var(--text-muted);
  font-weight: 400;
}
.queue-call-item--pending .queue-call-item__st--retry,
.queue-call-item--retry-wait .queue-call-item__st--retry {
  background: rgba(245, 158, 11, 0.22);
  color: #b45309;
  border: 1px solid rgba(245, 158, 11, 0.35);
}
.queue-call-item__ai {
  margin-top: 4px;
  font-size: 0.68rem;
  line-height: 1.35;
  color: var(--text-muted);
}
.queue-call-item:last-child { border-bottom: none; }
.queue-call-item--done { opacity: 0.55; }
.queue-call-item--failed { opacity: 0.7; }
.queue-call-item.is-dragging { opacity: 0.45; }
.queue-call-item.is-drag-over { background: rgba(124, 108, 240, 0.12); }
.queue-call-item__drag {
  flex-shrink: 0;
  width: 20px;
  color: var(--text-muted);
  font-size: 0.85rem;
  cursor: grab;
  user-select: none;
  touch-action: none;
  text-align: center;
}
.queue-call-item--done .queue-call-item__drag,
.queue-call-item--failed .queue-call-item__drag { visibility: hidden; }
.queue-call-item__body { flex: 1; min-width: 0; }
.queue-call-item__name { font-weight: 600; font-size: 0.88rem; }
.queue-call-item__phone { font-size: 0.78rem; color: var(--text-muted); font-variant-numeric: tabular-nums; }
.queue-call-item__st {
  flex-shrink: 0;
  font-size: 0.68rem;
  font-weight: 600;
  padding: 3px 8px;
  border-radius: 999px;
  background: var(--surface-hover);
  color: var(--text-muted);
}
.queue-call-item--pending .queue-call-item__st { background: rgba(124, 108, 240, 0.2); color: var(--accent-2); }
.queue-call-item--done .queue-call-item__st { background: var(--live-dim); color: var(--live); }
.queue-call-item--failed .queue-call-item__st { background: rgba(248, 113, 113, 0.15); color: var(--danger); }
.outreach-pick {
  display: none !important;
}
.manual-rows { display: flex; flex-direction: column; gap: 10px; margin-bottom: 12px; }
.manual-row {
  display: grid;
  grid-template-columns: 1fr 1fr 36px;
  gap: 8px;
  align-items: center;
}

/* Forms */
.field { margin-bottom: 14px; }
.form-sep {
  border: 0;
  border-top: 1px solid var(--border);
  margin: 18px 0;
}
.sip-auth {
  min-height: 44px;
  line-height: 1.35;
  white-space: pre-wrap;
  word-break: break-all;
  cursor: text;
  -webkit-user-select: text;
  user-select: text;
}
.field--sip > .hint:first-of-type { margin-bottom: 12px; }
.sip-lines {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 10px;
}
.sip-lines-empty { margin: 0; }
.sip-line-opt {
  display: block;
  width: 100%;
  padding: 10px 12px;
  border: 2px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text);
  text-align: left;
  cursor: pointer;
  transition:
    border-color var(--dur-fast) ease,
    background var(--dur-fast) ease,
    box-shadow var(--dur-fast) ease;
}
.sip-line-opt__row {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  width: 100%;
}
.sip-line-opt__check {
  flex: 0 0 1.25rem;
  width: 1.25rem;
  height: 1.25rem;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  font-size: 0.75rem;
  font-weight: 700;
  line-height: 1;
  color: transparent;
  background: transparent;
  margin-top: 2px;
}
.sip-line-opt--on {
  border-color: var(--primary);
  background: var(--primary-soft);
  box-shadow: 0 0 0 1px rgba(91, 141, 239, 0.2);
}
.sip-line-opt--on .sip-line-opt__check {
  color: #fff;
  background: var(--primary);
}
.sip-line-opt__body {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 2px;
  min-width: 0;
  flex: 1;
}
.sip-line-opt__phone {
  font-size: 0.875rem;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}
.sip-line-opt__meta {
  font-size: 0.75rem;
  color: var(--text-muted);
}
.seg__btn--disabled,
.seg__btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
  pointer-events: none;
}
.sip-lines[hidden],
.sip-fields[hidden],
#mSipLinesPick[hidden],
#mSipFieldsNew[hidden] {
  display: none !important;
}
.sip-fields {
  display: flex;
  flex-direction: column;
  gap: 14px;
  margin-top: 4px;
}
.sip-field .label { margin-bottom: 6px; }
.sip-hint { margin-top: 12px !important; }
.field--tight { margin-bottom: 10px; }
.label {
  display: block;
  font-size: 0.8125rem;
  font-weight: 500;
  color: var(--text-secondary);
  margin-bottom: 6px;
}
.label-row {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 10px;
  margin-bottom: 8px;
}
.label-row .label { margin: 0; }
.input {
  width: 100%;
  padding: 12px 14px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--input-bg);
  color: var(--text);
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s, background-color 0.15s;
}
.input:focus {
  border-color: var(--primary);
  box-shadow: var(--ring);
}
.input--lg { font-size: 1.1rem; padding: 14px 16px; }
.input--mono { font-family: ui-monospace, "SF Mono", Menlo, monospace; font-size: 0.82rem; line-height: 1.45; }
textarea.input { resize: vertical; min-height: 80px; }

/* Выпадающие списки */
.select-wrap {
  position: relative;
  display: block;
  width: 100%;
}
.select-wrap::after {
  content: "";
  position: absolute;
  right: 14px;
  top: 50%;
  width: 8px;
  height: 8px;
  border-right: 2px solid var(--text-muted);
  border-bottom: 2px solid var(--text-muted);
  transform: translateY(-62%) rotate(45deg);
  pointer-events: none;
  opacity: 0.78;
  transition: opacity var(--dur-fast) ease, border-color var(--dur-fast) ease;
}
.select-wrap:hover::after,
.select-wrap:focus-within::after {
  opacity: 1;
  border-color: var(--text-secondary);
}
.select-wrap select {
  appearance: none;
  -webkit-appearance: none;
  width: 100%;
  margin: 0;
  padding: 11px 42px 11px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background-color: var(--input-bg);
  background-image: linear-gradient(180deg, rgba(255, 255, 255, 0.6) 0%, transparent 100%);
  color: var(--text);
  font-size: 0.875rem;
  font-weight: 500;
  line-height: 1.25;
  cursor: pointer;
  outline: none;
  box-shadow: var(--shadow-sm);
  transition:
    border-color var(--dur-fast) ease,
    box-shadow var(--dur-fast) ease,
    background-color var(--dur-fast) ease;
}
.select-wrap select:hover:not(:disabled) {
  border-color: var(--border-strong);
  background-color: #fafbff;
}
.select-wrap select:focus {
  border-color: var(--primary);
  box-shadow: var(--ring), var(--shadow-sm);
}
.select-wrap select:active:not(:disabled) {
  transform: scale(0.995);
}
.select-wrap select:disabled {
  opacity: 0.55;
  cursor: not-allowed;
  background-color: var(--surface-hover);
}
.select-wrap select:has(option[value=""]:checked) {
  color: var(--text-muted);
}
.select-wrap select option {
  color: var(--text);
  font-weight: 500;
  background: var(--surface);
}
.select-wrap .select-arrow {
  display: none;
}
.select-wrap--xs::after {
  right: 10px;
  width: 6px;
  height: 6px;
  border-width: 1.5px;
}
.select-wrap--xs select {
  min-height: 32px;
  padding: 6px 30px 6px 10px;
  font-size: 0.75rem;
  border-radius: 9px;
}
.sheet__head--picker .sheet__title {
  flex: 1;
  min-width: 0;
  text-align: center;
  white-space: normal;
  overflow: visible;
  text-overflow: unset;
}
.select-wrap--picker select {
  pointer-events: none;
}
.select-wrap--picker {
  cursor: pointer;
}

/* Выбор из списка (sheet вместо нативного picker) */
.sheet--picker {
  z-index: 300;
}
.sheet--picker .sheet__panel--picker {
  max-height: 70dvh;
}
.sheet--picker .sheet__handle {
  margin: 12px auto 10px;
}
.sheet__head--picker {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 6px 16px 18px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 0;
}
.select-picker__list {
  overflow-y: auto;
  padding: 16px 14px max(20px, env(safe-area-inset-bottom));
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.select-picker__opt {
  width: 100%;
  text-align: left;
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text);
  font-size: 0.9rem;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
}
.select-picker__opt--on {
  border-color: var(--primary);
  background: var(--primary-soft);
  color: var(--primary);
}
.select-picker__opt--rich {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 3px;
  padding: 14px 16px;
}
.select-picker__opt--rich.select-picker__opt--on .select-picker__opt-desc {
  color: var(--primary);
  opacity: 0.85;
}
.select-picker__opt-title {
  font-size: 0.95rem;
  font-weight: 600;
  line-height: 1.2;
}
.select-picker__opt-desc {
  font-size: 0.78rem;
  font-weight: 500;
  color: var(--text-secondary);
  line-height: 1.3;
}
.select-picker__opt:active {
  transform: scale(0.99);
}
.search {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 14px;
  margin-bottom: 12px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--input-bg);
}
.search input {
  flex: 1;
  border: none;
  background: transparent;
  padding: 12px 0;
  outline: none;
}
.search svg { opacity: 0.45; flex-shrink: 0; }
.grid { display: grid; gap: 10px; }
.grid--2 { grid-template-columns: 1fr 1fr; }
.row-inline { display: flex; gap: 8px; }
.row-inline .input { flex: 1; }
.field--voice-meta { margin-top: 4px; }
.field--voice-meta .hint { margin-top: 6px; }
.field--prompt-vars { margin-top: 4px; }
.prompt-vars .chip { font-size: 0.78rem; }
.voice-pick-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  background: var(--surface-hover);
  border: 1px solid var(--border);
}
.voice-pick-row__name {
  margin: 0;
  flex: 1;
  min-width: 0;
  font-size: 0.875rem;
  color: var(--text-secondary);
}
.voice-params-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin: 4px 0 2px;
}
.voice-params-row__label {
  margin: 0;
}
.row-actions { display: flex; gap: 8px; margin-top: 12px; flex-wrap: wrap; }
.check {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.85rem;
  color: var(--text-secondary);
  margin: 10px 0;
  cursor: pointer;
}
.hint { font-size: 0.78rem; color: var(--text-muted); margin: 4px 0 0; }
.status-line { font-size: 0.82rem; color: var(--text-secondary); min-height: 1.2em; margin-top: 8px; }

/* Buttons */
.btn {
  position: relative;
  isolation: isolate;
  overflow: hidden;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 11px 16px;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  font-weight: 600;
  font-size: 0.875rem;
  cursor: pointer;
  transition:
    background var(--dur-med) var(--ease-out),
    border-color var(--dur-med) var(--ease-out),
    color var(--dur-med) ease,
    transform var(--dur-fast) var(--ease-out),
    box-shadow var(--dur-med) var(--ease-out);
}
.btn::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  background: currentColor;
  opacity: 0;
  transition: opacity var(--dur-med) ease;
  pointer-events: none;
}
.btn:active:not(:disabled) { transform: scale(0.97); }
.btn:active:not(:disabled)::after { opacity: 0.06; }
.btn:disabled { opacity: 0.45; cursor: not-allowed; }
.btn--primary,
.btn--upload,
.btn--gradient {
  background: var(--primary);
  color: #fff;
  border: none;
  box-shadow: var(--shadow-sm);
}
.btn--primary::after,
.btn--upload::after,
.btn--gradient::after { background: #fff; }
.btn--primary:active:not(:disabled)::after,
.btn--upload:active:not(:disabled)::after,
.btn--gradient:active:not(:disabled)::after { opacity: 0.14; }
@media (hover: hover) {
  .btn--primary:hover:not(:disabled),
  .btn--upload:hover:not(:disabled),
  .btn--gradient:hover:not(:disabled) {
    background: var(--primary-hover);
    box-shadow: 0 8px 22px rgba(79, 70, 229, 0.24);
    transform: translateY(-1px);
  }
  .btn--ghost:hover:not(:disabled),
  .btn--glass:hover:not(:disabled) {
    background: var(--surface-hover);
    border-color: var(--border-strong);
    transform: translateY(-1px);
  }
  .btn--accent:hover:not(:disabled) {
    background: rgba(5, 150, 105, 0.16);
    transform: translateY(-1px);
  }
  .btn--danger:hover:not(:disabled) {
    background: #fee2e2;
    transform: translateY(-1px);
  }
}
.btn--primary:active:not(:disabled),
.btn--upload:active:not(:disabled),
.btn--gradient:active:not(:disabled) {
  background: var(--primary-hover);
}
.btn--upload { color: #fff; }
.btn--accent {
  background: var(--live-dim);
  color: var(--live);
  border: 1px solid rgba(5, 150, 105, 0.25);
}
.btn--ghost,
.btn--glass {
  background: var(--surface);
  border-color: var(--border);
  color: var(--text);
}
.btn--ghost:active:not(:disabled),
.btn--glass:active:not(:disabled) {
  background: var(--surface-hover);
}
.btn--danger {
  background: #fef2f2;
  border-color: #fecaca;
  color: var(--danger);
}
.btn--sm { padding: 8px 12px; font-size: 0.8125rem; }
.btn--block { width: 100%; }
.btn--lg { padding: 13px 18px; font-size: 0.9375rem; }

.iconbtn {
  width: 40px; height: 40px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: var(--surface);
  display: flex; align-items: center; justify-content: center;
  cursor: pointer;
  flex-shrink: 0;
  transition:
    background var(--dur-med) var(--ease-out),
    border-color var(--dur-med) ease,
    transform var(--dur-fast) var(--ease-out);
}
@media (hover: hover) {
  .iconbtn:hover { background: var(--surface-hover); transform: scale(1.04); }
}
.iconbtn:active { transform: scale(0.94); }
.iconbtn--ghost { background: transparent; }
.iconbtn--call {
  background: var(--live);
  border: none;
  color: #fff;
}

.chip-group { display: flex; flex-wrap: wrap; gap: 8px; }
.chip--rec {
  border-color: #f87171;
  color: #fca5a5;
}
.chip {
  font-size: 0.72rem;
  font-weight: 600;
  padding: 8px 12px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--surface);
  cursor: pointer;
  color: var(--text-secondary);
  white-space: nowrap;
  transition:
    background var(--dur-med) ease,
    border-color var(--dur-med) ease,
    color var(--dur-med) ease,
    transform var(--dur-fast) var(--ease-out);
}
@media (hover: hover) {
  .chip:hover { background: var(--surface-hover); transform: translateY(-1px); }
}
.chip:active { transform: scale(0.96); }
.chip--ai {
  border-color: rgba(79, 70, 229, 0.25);
  color: var(--primary);
  background: var(--primary-soft);
}

/* Cards stack (contacts, batches, calls) */
.card-stack { display: flex; flex-direction: column; gap: 8px; margin-bottom: 16px; }
.contact-card, .call-card, .queue-card, .voice-item {
  padding: 14px;
  border-radius: var(--radius);
  background: var(--surface);
  border: 1px solid var(--border);
  cursor: pointer;
  transition:
    background var(--dur-med) var(--ease-out),
    border-color var(--dur-med) ease,
    transform var(--dur-fast) var(--ease-out),
    box-shadow var(--dur-med) ease;
}
@media (hover: hover) {
  .contact-card:hover, .call-card:hover, .queue-card:hover {
    background: var(--surface-hover);
    transform: translateY(-1px);
    box-shadow: var(--shadow-sm);
  }
}
.contact-card:active, .call-card:active { transform: scale(0.99); }
.contact-card__name, .call-card__name, .queue-card__name { font-weight: 600; }
.contact-card__phone, .call-card__meta, .queue-card__meta {
  font-size: 0.78rem; color: var(--text-muted); margin-top: 2px;
}
.contact-card { display: flex; align-items: center; gap: 12px; }
.contact-card__ava {
  width: 40px; height: 40px;
  border-radius: 50%;
  background: var(--surface-hover);
  display: flex; align-items: center; justify-content: center;
  font-weight: 700;
}
.contact-card__body { flex: 1; min-width: 0; }
.contact-card__status {
  font-size: 0.7rem;
  font-weight: 600;
  padding: 4px 8px;
  border-radius: 6px;
  background: var(--surface-hover);
  text-transform: lowercase;
}
.call-card__badge {
  display: inline-flex;
  align-items: center;
  font-size: 0.6875rem;
  font-weight: 600;
  padding: 3px 8px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--surface-hover);
  white-space: nowrap;
}
.call-card__badge--ok {
  color: var(--live);
  border-color: rgba(5, 150, 105, 0.28);
  background: var(--live-dim);
}
.call-card__badge--fail {
  color: var(--danger);
  border-color: rgba(248, 113, 113, 0.3);
  background: rgba(248, 113, 113, 0.08);
}
.call-card__badge--retry {
  color: #b45309;
  border-color: rgba(245, 158, 11, 0.35);
  background: rgba(254, 243, 199, 0.9);
}
.call-card__badge--live {
  color: var(--primary);
  border-color: rgba(99, 102, 241, 0.3);
  background: var(--primary-soft);
}
.call-card__badge--neutral {
  color: var(--text-secondary);
}
.call-card { display: flex; gap: 12px; align-items: center; }
.call-card--ok { border-color: rgba(5, 150, 105, 0.18); }
.call-card--err { border-color: rgba(248, 113, 113, 0.2); }
.call-card--retry { border-color: rgba(245, 158, 11, 0.28); background: rgba(255, 251, 235, 0.5); }
.call-card__ico {
  width: 40px; height: 40px;
  border-radius: 50%;
  background: var(--surface-hover);
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.call-card__ico--ok { color: var(--live); background: var(--live-dim); }
.call-card__ico--err { color: var(--danger); background: rgba(248, 113, 113, 0.08); }
.call-card__ico--retry { color: #b45309; background: rgba(254, 243, 199, 0.9); }
.call-card__ico--live { color: var(--primary); background: var(--primary-soft); }
.call-card__body { flex: 1; min-width: 0; }
.call-card__top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 2px;
}
.call-card__top .call-card__name {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.call-card__badges {
  display: inline-flex;
  flex-wrap: wrap;
  gap: 4px;
  justify-content: flex-end;
  flex-shrink: 0;
  max-width: 58%;
}
.call-card__badge--sub {
  font-size: 0.625rem;
  padding: 2px 6px;
}
.call-card__retry {
  margin-top: 4px;
  font-size: 0.72rem;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  gap: 4px;
}
.call-card__right { text-align: right; font-size: 0.8rem; color: var(--text-muted); flex-shrink: 0; }
.call-card__dur { font-weight: 700; color: var(--text); }
.queue-list { display: flex; flex-direction: column; gap: 10px; }
.queue-card {
  display: flex;
  align-items: stretch;
  padding: 0;
  overflow: hidden;
}
.queue-card__main {
  flex: 1;
  min-width: 0;
  text-align: left;
  padding: 14px 16px;
  background: transparent;
  border: none;
  color: inherit;
  cursor: pointer;
  font: inherit;
}
.queue-card__head { display: flex; justify-content: space-between; align-items: flex-start; gap: 8px; margin-bottom: 4px; }
.queue-card__title { margin: 0; font-size: 0.95rem; font-weight: 600; }
.queue-card__badge {
  font-size: 0.7rem;
  padding: 3px 8px;
  border-radius: 6px;
  background: var(--surface-hover);
  color: var(--text-muted);
  white-space: nowrap;
}
.queue-card--running { border-color: rgba(52, 211, 153, 0.3); }
.queue-card--running .queue-card__badge { background: var(--live-dim); color: var(--live); }
.queue-card--paused { border-color: rgba(251, 191, 36, 0.28); }
.queue-card--paused .queue-card__badge { background: rgba(251, 191, 36, 0.15); color: #fbbf24; }
.queue-card--stopped { border-color: rgba(148, 163, 184, 0.28); }
.queue-card--finished { opacity: 0.85; }
.queue-card__progress { margin: 8px 0 0; }
.queue-card__actions {
  display: flex;
  flex-direction: column;
  border-left: 1px solid var(--border);
  flex-shrink: 0;
}
.queue-card__act {
  border-radius: 0;
  min-width: 48px;
  flex: 1;
}
.queue-card__act--danger { color: var(--danger); }
.queue-card__act--danger:hover { background: rgba(248, 113, 113, 0.12); }
.queue-card__top { display: flex; justify-content: space-between; gap: 8px; }
.queue-detail-settings {
  display: flex;
  flex-wrap: nowrap;
  gap: 6px;
  align-items: flex-end;
  margin-bottom: 8px;
}
.queue-detail-settings .field {
  margin-bottom: 0;
  min-width: 0;
}
.queue-detail-settings__agent {
  flex: 1 1 0;
  min-width: 0;
}
.queue-detail-settings__num {
  flex: 0 0 56px;
  max-width: 60px;
}
.queue-detail-settings .label {
  font-size: 0.65rem;
  margin-bottom: 2px;
  line-height: 1.2;
}
.queue-detail-settings .input--xs,
.queue-detail-settings .select-wrap--xs {
  width: 100%;
}
.queue-detail-settings input[type="number"] {
  text-align: center;
  padding-right: 2px;
}
.queue-call-item__del {
  flex-shrink: 0;
  width: 32px;
  height: 32px;
  border: none;
  border-radius: 8px;
  background: transparent;
  color: var(--text-muted);
  font-size: 1.25rem;
  line-height: 1;
  cursor: pointer;
}
.queue-call-item__del:hover { background: rgba(248, 113, 113, 0.12); color: var(--danger); }
.queue-progress { height: 4px; border-radius: 2px; background: var(--surface-hover); margin: 10px 0; overflow: hidden; display: flex; }
.queue-progress__done,
.queue-progress__failed {
  transition: width 0.65s var(--ease-out);
}
.queue-progress__done { background: var(--live); }
.queue-progress__failed { background: var(--danger); }
.queue-stats.stat-row {
  gap: 6px;
  margin-bottom: 8px;
}
.queue-stats .stat-pill {
  font-size: 0.7rem;
  padding: 4px 8px;
  line-height: 1.25;
}
.queue-stats .stat-pill b {
  margin-right: 4px;
}
.queue-actions { display: flex; gap: 8px; margin-top: 10px; flex-wrap: wrap; }
.bar { height: 4px; border-radius: 2px; background: var(--surface-hover); margin-top: 6px; overflow: hidden; display: flex; }
.bar__done { background: var(--live); }
.bar__failed { background: var(--danger); }

.stat-row {
  display: flex;
  flex-wrap: nowrap;
  gap: 6px;
  margin-bottom: 12px;
  width: 100%;
}
.stat-pill {
  flex: 1 1 0;
  min-width: 0;
  white-space: nowrap;
  text-align: center;
  font-size: 0.68rem;
  padding: 5px 6px;
  border-radius: 8px;
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text-secondary);
}
.stat-pill b { color: var(--text); margin-right: 3px; font-size: 0.72rem; }
.stat-pill--ok b { color: var(--live); }
.stat-pill--err b { color: var(--danger); }

.empty {
  padding: 28px 20px;
  text-align: center;
  border-radius: var(--radius);
  border: 1px dashed var(--border-strong);
  color: var(--text-muted);
  font-size: 0.88rem;
}
.empty strong { display: block; color: var(--text); margin-bottom: 6px; font-size: 0.95rem; }

/* Sheet modals */
.sheet[hidden] { display: none !important; }
.sheet {
  position: fixed;
  inset: 0;
  z-index: 200;
  display: flex;
  align-items: flex-end;
  justify-content: center;
}
.sheet--above { z-index: 220; }
.sheet__backdrop {
  position: absolute;
  inset: 0;
  z-index: 0;
  background: rgba(15, 23, 42, 0.4);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
}
.sheet:not([hidden]) .sheet__backdrop {
  animation: sheetBackdropIn var(--dur-med) var(--ease-out) both;
}
.sheet__panel {
  position: relative;
  z-index: 1;
  width: 100%;
  max-width: 520px;
  max-height: 92dvh;
  background: var(--bg-elevated);
  border-radius: var(--radius-lg) var(--radius-lg) 0 0;
  border: 1px solid var(--border);
  border-bottom: none;
  display: flex;
  flex-direction: column;
}
.sheet:not([hidden]) .sheet__panel {
  animation: sheetPanelIn var(--dur-slow) var(--ease-out) both;
}
.sheet__panel--md { max-height: 85dvh; }

.dup-lang-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  margin-top: 14px;
}
.dup-lang-btn {
  min-height: 92px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  font-weight: 700;
  cursor: pointer;
  transition:
    background var(--dur-med) var(--ease-out),
    border-color var(--dur-med) ease,
    transform var(--dur-fast) var(--ease-out),
    box-shadow var(--dur-med) var(--ease-out);
}
.dup-lang-btn__flag {
  font-size: 2rem;
  line-height: 1;
}
.dup-lang-btn__title {
  font-size: 0.95rem;
}
@media (hover: hover) {
  .dup-lang-btn:hover {
    background: var(--surface-hover);
    border-color: rgba(79, 70, 229, 0.35);
    box-shadow: var(--shadow-sm);
  }
}
.dup-lang-btn:active {
  transform: scale(0.98);
}
.dup-lang-btn:disabled {
  opacity: 0.55;
  pointer-events: none;
}
.sheet--upload { align-items: stretch; }
.sheet__panel--upload {
  max-width: 100%;
  width: 100%;
  flex: 1;
  min-height: 0;
  height: 100%;
  max-height: none;
  display: flex;
  flex-direction: column;
  border-radius: var(--radius-lg) var(--radius-lg) 0 0;
  padding-bottom: env(safe-area-inset-bottom, 0px);
}
.sheet__panel--upload > .sheet__handle {
  flex-shrink: 0;
  margin: 16px auto 14px;
}
.sheet__panel--upload > .sheet__head {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 14px 14px;
  border-bottom: 1px solid var(--border);
}
.sheet__panel--upload > .sheet__head > .iconbtn--ghost {
  grid-row: auto;
  align-self: center;
  flex-shrink: 0;
}
.sheet__panel--upload .sheet__title {
  flex: 1;
  min-width: 0;
  padding-top: 2px;
  font-size: 1rem;
}
.sheet__panel--upload > .sheet__head .btn {
  flex-shrink: 0;
}
.sheet__body--upload {
  display: flex;
  flex-direction: column;
  flex: 1 1 auto;
  min-height: 0;
  overflow: hidden;
  padding: 8px 14px max(8px, env(safe-area-inset-bottom, 0px));
}
.upload-form-top {
  flex-shrink: 0;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-bottom: 6px;
}
.field--upload-mini {
  margin-bottom: 0;
  min-width: 0;
}
.upload-form-top .label--xs {
  font-size: 0.65rem;
  margin-bottom: 2px;
  color: var(--text-muted);
}
.upload-form-top .input--xs,
.upload-form-top .select-wrap--xs select {
  min-height: 32px;
  padding: 5px 8px;
  font-size: 0.78rem;
}
.upload-meta-fold {
  flex-shrink: 0;
  margin-bottom: 6px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
}
.upload-meta-fold__title {
  padding: 6px 10px;
  font-size: 0.72rem;
  font-weight: 600;
  cursor: pointer;
  list-style: none;
}
.upload-meta-fold__title::-webkit-details-marker { display: none; }
.upload-meta-fold[open] .upload-meta-fold__title {
  border-bottom: 1px solid var(--border);
}
.upload-meta-fold .kv--compact {
  margin: 0;
  padding: 6px 10px;
  max-height: none;
}
.field--compact { flex-shrink: 0; margin-bottom: 8px; }
.kv--compact {
  flex-shrink: 0;
  font-size: 0.72rem;
  margin-bottom: 8px;
}
.kv--compact dt { opacity: 0.7; }
.upload-toolbar {
  flex-shrink: 0;
  padding: 6px 0;
  border-top: 1px solid var(--border);
  margin-bottom: 4px;
}
.upload-toolbar__row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px 8px;
}
.upload-toolbar__count {
  margin-left: auto;
  font-size: 0.72rem;
  color: var(--text-muted);
  font-weight: 600;
  white-space: nowrap;
}
.seg--sm { margin-bottom: 0; flex: 1; min-width: 0; }
.seg--sm .seg__btn { flex: 1; min-width: 2rem; padding: 5px 6px; font-size: 0.75rem; }
.upload-preview-list {
  flex: 1 1 0;
  min-height: 0;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  touch-action: pan-y;
  overscroll-behavior: contain;
}
.upload-page-nav {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 6px 0 max(4px, env(safe-area-inset-bottom, 0px));
  margin: 0;
  border-top: 1px solid var(--border);
  background: var(--bg-elevated);
}
.upload-page-nav__label {
  font-size: 0.75rem;
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
}
.preview-table--pick { width: 100%; table-layout: fixed; }
.preview-table__cb { width: 36px; text-align: center; vertical-align: middle; }
.preview-table__cb input { width: 18px; height: 18px; accent-color: var(--accent); }
.preview-table__phone { white-space: nowrap; font-variant-numeric: tabular-nums; width: 34%; }
.preview-table__name,
.preview-table__extra {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 0;
}
.preview-table__name { width: 28%; }
.preview-table__extra { width: 38%; }
.preview-table__row { cursor: pointer; }
.preview-table__row--on td { background: rgba(91, 141, 239, 0.07); }
.preview-table thead th {
  position: sticky;
  top: 0;
  z-index: 2;
  background: var(--bg-elevated);
  box-shadow: 0 1px 0 var(--border);
}
.btn--xs { padding: 4px 10px; font-size: 0.75rem; min-height: 28px; }

.sheet__handle {
  width: 36px; height: 4px;
  border-radius: 2px;
  background: var(--border-strong);
  margin: 10px auto 4px;
}
.sheet__head {
  display: grid;
  grid-template-columns: 40px 1fr auto;
  grid-template-rows: auto auto;
  align-items: center;
  gap: 6px 10px;
  padding: 14px 14px 14px;
  border-bottom: 1px solid var(--border);
}
.sheet__head--simple {
  display: block;
  padding: 14px 16px;
}
.sheet__head--simple .sheet__title {
  white-space: normal;
  overflow: visible;
  text-overflow: unset;
}
.sheet__head > .iconbtn--ghost { grid-row: 1 / 3; align-self: center; }
.sheet__head-text {
  grid-column: 2;
  grid-row: 1 / 3;
  min-width: 0;
  align-self: center;
}
.sheet__head-text--agent {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  align-self: flex-start;
  padding-top: 2px;
}
.sheet__head-meta {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  justify-content: center;
  min-height: 44px;
}
.sheet__name-row {
  display: block;
  min-width: 0;
  max-width: 100%;
}
.sheet__name-wrap {
  position: relative;
  display: block;
  width: 100%;
  max-width: 100%;
  min-width: 0;
}
.sheet__name-mirror {
  display: block;
  visibility: hidden;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  word-break: break-word;
  font-weight: 700;
  font-size: 1.05rem;
  line-height: 1.25;
  font-family: inherit;
  padding: 0;
  border: 0;
  min-width: 5ch;
  min-height: 1.25em;
}
.sheet__name-wrap .sheet__name-input {
  position: absolute;
  inset: 0;
  width: 100%;
  min-width: 0;
  max-width: 100%;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  word-break: break-word;
  line-height: 1.25;
  border-radius: 8px;
  transition: background 0.15s, color 0.15s, border-color 0.15s, padding 0.15s;
}
.sheet__name-wrap--incoming .sheet__name-mirror {
  padding: 4px 10px;
  border: 1px solid transparent;
  box-sizing: border-box;
  border-radius: 999px;
}
.sheet__name-wrap--incoming .sheet__name-input {
  background: var(--live-dim);
  color: var(--live);
  border: 1px solid rgba(5, 150, 105, 0.28);
  border-radius: 999px;
  padding: 4px 10px;
  box-sizing: border-box;
}
.sheet__head-meta .sheet__sub:empty {
  display: none;
  margin: 0;
  padding: 0;
}
.sheet-avatar {
  position: relative;
  flex-shrink: 0;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  border: 1.5px dashed var(--accent);
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: visible;
  cursor: pointer;
  background: rgba(79, 70, 229, 0.08);
  -webkit-tap-highlight-color: transparent;
  transition: border-color 0.15s, background 0.15s, transform 0.1s;
}
.sheet-avatar:hover {
  border-color: var(--accent);
  background: rgba(79, 70, 229, 0.14);
}
.sheet-avatar:active {
  transform: scale(0.94);
}
.sheet-avatar__empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1px;
  color: var(--accent);
  pointer-events: none;
}
.sheet-avatar__label {
  font-size: 0.5rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  line-height: 1;
  color: var(--accent);
}
.sheet-avatar__badge {
  position: absolute;
  right: -3px;
  bottom: -3px;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--accent);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 2px solid var(--surface, #fff);
  box-shadow: 0 1px 3px rgba(15, 23, 42, 0.12);
  pointer-events: none;
}
.sheet-avatar__badge .ico { color: #fff; }
.sheet-avatar img {
  width: 100%;
  height: 100%;
  border-radius: 50%;
  object-fit: cover;
}
.sheet-avatar--has {
  border-style: solid;
  border-color: var(--border-strong);
  background: var(--surface-hover);
  overflow: hidden;
}
.sheet-avatar--has:hover {
  border-color: var(--accent);
}
.sheet__name-input {
  width: 100%;
  border: none;
  background: transparent;
  padding: 0;
  margin: 0;
  font-weight: 700;
  font-size: 1.05rem;
  line-height: 1.2;
  height: auto;
  color: var(--text);
  font-family: inherit;
  align-self: center;
}
.sheet__name-input:focus {
  outline: none;
}
.sheet__name-input::placeholder {
  color: var(--text-muted);
  font-weight: 600;
}
.sheet__head-actions {
  grid-column: 3;
  grid-row: 1 / 3;
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
  align-self: center;
}
.sheet__head--agent {
  grid-template-rows: auto;
  grid-template-columns: 40px 1fr auto;
}
.sheet__head--agent > .iconbtn--ghost {
  grid-row: 1;
}
.sheet__head--agent .sheet__title {
  grid-column: 2;
  grid-row: 1;
  min-width: 0;
}
.sheet__head--agent .sheet__head-actions {
  grid-row: 1;
}
.agent-edit-profile {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
  margin-bottom: 8px;
  padding-bottom: 4px;
}
.agent-edit-profile__photo {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 88px;
  height: 88px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--surface-muted);
  cursor: pointer;
  overflow: visible;
  -webkit-tap-highlight-color: transparent;
  transition: border-color 0.15s, background 0.15s, transform 0.1s;
}
.agent-edit-profile__photo:hover {
  border-color: var(--primary);
  background: rgba(79, 70, 229, 0.06);
}
.agent-edit-profile__photo:active {
  transform: scale(0.97);
}
.agent-edit-profile__photo img {
  width: 100%;
  height: 100%;
  border-radius: var(--radius-sm);
  object-fit: cover;
}
.agent-edit-profile__photo--has {
  border-color: var(--border);
  background: var(--surface);
}
.agent-edit-profile__photo-empty {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 100%;
  color: #7c3aed;
  pointer-events: none;
}
.agent-edit-profile__photo-badge {
  position: absolute;
  right: -4px;
  bottom: -4px;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--primary);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 2px solid var(--surface, #fff);
  box-shadow: 0 1px 3px rgba(15, 23, 42, 0.12);
  pointer-events: none;
}
.agent-edit-profile__photo-badge .ico { color: #fff; }
.agent-edit-profile__name {
  width: 100%;
  margin: 0;
}
.sheet__title {
  font-weight: 700;
  font-size: 1.05rem;
  line-height: 1.25;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.sheet__sub {
  font-size: 0.72rem;
  color: var(--text-muted);
  margin-top: 6px;
  padding-top: 2px;
  overflow: hidden;
  text-overflow: ellipsis;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  line-clamp: 2;
  -webkit-box-orient: vertical;
  line-height: 1.4;
}
.sheet__body {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  -webkit-overflow-scrolling: touch;
}
.sheet__pad { height: 24px; }

.toggle-row {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 8px 0 12px;
  font-size: 0.86rem;
  color: var(--text);
  cursor: pointer;
}
.toggle-row input {
  width: 18px;
  height: 18px;
  accent-color: var(--live);
}
.field--retry .slider {
  margin-top: 8px;
}

.field--knowledge .chip-group {
  flex-wrap: wrap;
  margin-top: 8px;
}
.chip--muted {
  color: var(--text-muted);
  border-color: var(--border);
}

.btn-agent-delete {
  width: 36px;
  height: 36px;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 10px;
  font-family: inherit;
  border: 1px solid rgba(239, 68, 68, 0.35);
  background: rgba(254, 226, 226, 0.9);
  color: var(--danger);
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s, transform 0.1s;
}
.btn-agent-delete .ico { width: 20px; height: 20px; }
.btn-agent-delete:hover {
  background: rgba(254, 202, 202, 1);
  border-color: rgba(239, 68, 68, 0.5);
}
.btn-agent-delete:active {
  transform: scale(0.94);
  background: rgba(252, 165, 165, 0.5);
}

.btn-agent-secondary {
  width: auto;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 11px 16px;
  border-radius: var(--radius-sm);
  font-size: 0.82rem;
  font-weight: 600;
  font-family: inherit;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text-secondary);
  cursor: pointer;
}
.btn-agent-secondary:active { background: var(--surface-hover); }

.acc {
  margin-bottom: 14px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--surface);
  overflow: hidden;
}
.acc__sum {
  padding: 18px 16px 16px;
  font-weight: 600;
  font-size: 0.9rem;
  line-height: 1.3;
  cursor: pointer;
  list-style: none;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 52px;
  box-sizing: border-box;
}
.acc__sum::-webkit-details-marker { display: none; }
.acc__sum::after {
  content: "";
  flex-shrink: 0;
  width: 18px;
  height: 18px;
  opacity: 0.45;
  background: center / contain no-repeat url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='18' height='18' viewBox='0 0 24 24' fill='none' stroke='%2394a3b8' stroke-width='2'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
  transition: transform 0.2s;
}
.acc[open] .acc__sum::after { transform: rotate(180deg); }
.acc__body {
  padding: 18px 16px 20px;
  border-top: 1px solid var(--border);
}
.acc__body > .field:first-child { margin-top: 0; }

.slider { margin-bottom: 14px; }
.slider__top, .slider__row {
  display: flex;
  justify-content: space-between;
  font-size: 0.8rem;
  color: var(--text-secondary);
  margin-bottom: 6px;
}
.slider__val, .val { font-weight: 600; color: var(--text); font-variant-numeric: tabular-nums; }
.range {
  width: 100%;
  height: 6px;
  accent-color: var(--accent);
  cursor: pointer;
}

.kv {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 6px 12px;
  font-size: 0.85rem;
}
.kv dt { color: var(--text-muted); }
.kv dd { margin: 0; }

.voice-list { display: flex; flex-direction: column; gap: 14px; }
.voice-section__title {
  margin: 0 0 8px;
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--text-muted);
}
.voice-section__list { display: flex; flex-direction: column; gap: 6px; }
.voice-item {
  display: flex;
  gap: 10px;
  align-items: center;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  background: var(--surface);
  border: 1px solid var(--border);
  cursor: pointer;
}
.sheet__head--voice {
  display: grid;
  grid-template-columns: 44px 1fr 44px;
  align-items: center;
  padding: 14px 12px;
}
.sheet__head--voice .sheet__title {
  grid-column: 1 / -1;
  grid-row: 1;
  text-align: center;
  justify-self: center;
  width: 100%;
  max-width: calc(100% - 88px);
  margin: 0;
  pointer-events: none;
}
.sheet__head--voice > .iconbtn--ghost {
  grid-column: 1;
  grid-row: 1;
  z-index: 1;
  align-self: center;
}
.sheet__head--voice .sheet__head-spacer {
  grid-column: 3;
  grid-row: 1;
  width: 44px;
  height: 44px;
}
.voice-item__play {
  width: 32px; height: 32px;
  border-radius: 50%;
  border: none;
  background: var(--accent);
  color: #fff;
  cursor: pointer;
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.voice-item__play--on {
  background: var(--text);
}
.voice-item__name { font-weight: 600; font-size: 0.9rem; }
.voice-item__meta { font-size: 0.75rem; color: var(--text-muted); }
.voice-item__body { flex: 1; min-width: 0; }
.voice-item__del { flex-shrink: 0; }
.voice-search-row {
  display: flex;
  gap: 8px;
  align-items: stretch;
  margin-bottom: 12px;
}
.voice-search-row__search {
  flex: 1;
  min-width: 0;
  margin-bottom: 0;
}
.voice-search-row__add {
  flex-shrink: 0;
  align-self: center;
  white-space: nowrap;
}
.sheet__head--toolbar {
  grid-template-rows: auto;
  align-items: center;
}
.sheet__head--toolbar > .iconbtn--ghost {
  grid-row: 1;
  grid-column: 1;
}
.sheet__head--toolbar .sheet__title {
  grid-column: 2;
  grid-row: 1;
  text-align: left;
  align-self: center;
}
.sheet__head--toolbar > .btn {
  grid-column: 3;
  grid-row: 1;
  align-self: center;
}
.sheet__head--toolbar .sheet__head-spacer {
  grid-column: 3;
  grid-row: 1;
  width: 44px;
  flex-shrink: 0;
}
#modalQuickCall .sheet__head {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px 14px;
}
#modalQuickCall .sheet__head > .iconbtn--ghost {
  grid-row: auto;
  align-self: center;
}
#modalQuickCall .sheet__title {
  flex: 1;
  min-width: 0;
  margin: 0;
  padding: 0;
  line-height: 40px;
  align-self: center;
}
#modalQuickCall .sheet__head > .btn {
  flex-shrink: 0;
  align-self: center;
}
.voice-add-actions--hidden,
.voice-add-actions[hidden] {
  display: none !important;
}
.voice-add-actions {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 4px;
}
.voice-add-btn { justify-content: flex-start; }
.voice-add-preview {
  margin-top: 12px;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  background: var(--surface);
  border: 1px solid var(--border);
}
.voice-add-preview__row {
  display: flex;
  align-items: center;
  gap: 10px;
}
.voice-add-preview__play {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  border: none;
  background: var(--accent);
  color: #fff;
  cursor: pointer;
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.voice-add-preview__play--on { background: var(--danger, #e5484d); }
.voice-add-preview__label {
  flex: 1;
  font-size: 0.85rem;
  color: var(--text-muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  min-width: 0;
}
.voice-add-preview__change {
  flex-shrink: 0;
  border: none;
  background: none;
  padding: 0;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--accent);
  cursor: pointer;
}
.voice-add-hint { margin-top: 12px; }
.prompt-const-grid {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 8px;
}
.prompt-const-row {
  display: grid;
  grid-template-columns: 7.5rem 1fr;
  gap: 8px;
  align-items: center;
}
.prompt-const-tag {
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--text-muted);
  letter-spacing: 0.02em;
}
.prompt-const-input { min-width: 0; }

.transcript-box {
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-height: 280px;
  overflow-y: auto;
}
.transcript-turn {
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--surface-hover);
}
.transcript-turn--client {
  background: rgba(59, 130, 246, 0.08);
  border-color: rgba(59, 130, 246, 0.22);
}
.transcript-turn--agent {
  background: rgba(124, 108, 240, 0.08);
  border-color: rgba(124, 108, 240, 0.22);
}
.transcript-turn__role {
  font-size: 0.68rem;
  font-weight: 700;
  color: var(--text-muted);
  margin-bottom: 4px;
  letter-spacing: 0.02em;
}
.transcript-turn--client .transcript-turn__role { color: #2563eb; }
.transcript-turn--agent .transcript-turn__role { color: var(--accent-2, #6d5ce8); }
.transcript-turn__text {
  font-size: 0.82rem;
  line-height: 1.45;
  white-space: pre-wrap;
  color: var(--text);
}
.analysis-box {
  padding: 12px 14px;
  border-radius: var(--radius-sm);
  background: rgba(124, 108, 240, 0.08);
  border: 1px solid rgba(124, 108, 240, 0.22);
  font-size: 0.8rem;
  line-height: 1.45;
  white-space: pre-wrap;
  max-height: 220px;
  overflow-y: auto;
  color: var(--text);
}
.analysis-box--pending {
  background: var(--surface-hover);
  border-color: var(--border);
  color: var(--text-muted);
  max-height: none;
}
.player {
  margin: 12px 0;
  padding: 12px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: var(--surface);
}
.player__audio {
  position: absolute;
  width: 0;
  height: 0;
  opacity: 0;
  pointer-events: none;
}
.player__bar {
  display: flex;
  align-items: center;
  gap: 10px;
}
.player__play {
  flex-shrink: 0;
  width: 40px;
  height: 40px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: none;
  border-radius: 50%;
  background: var(--primary);
  color: #fff;
  cursor: pointer;
}
.player__track {
  flex: 1;
  min-width: 0;
}
.player__seek {
  width: 100%;
  height: 4px;
  margin: 0;
  accent-color: var(--primary);
  cursor: pointer;
}
.player__times {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  margin-top: 6px;
  font-size: 0.72rem;
  font-variant-numeric: tabular-nums;
  color: var(--text-muted);
}
.player__tools {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: 10px;
  flex-wrap: nowrap;
}
.player__skips {
  display: flex;
  gap: 4px;
  flex-shrink: 0;
}
.player__skip {
  min-width: 38px;
  height: 30px;
  padding: 0 8px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--surface-hover);
  cursor: pointer;
  font-size: 0.7rem;
  font-weight: 600;
  color: var(--text);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.player__speeds {
  display: flex;
  flex: 1;
  min-width: 0;
  flex-wrap: nowrap;
  gap: 3px;
  justify-content: flex-end;
}
.speed-btn {
  min-width: 0;
  flex: 1 1 0;
  max-width: 44px;
  height: 30px;
  padding: 0 4px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: transparent;
  font-size: 0.65rem;
  font-weight: 600;
  cursor: pointer;
  color: var(--text-muted);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 1;
  white-space: nowrap;
}
.speed-btn--active { background: var(--primary); color: #fff; border-color: transparent; }

/* Skeleton */
.skel {
  background: linear-gradient(90deg, var(--surface) 25%, var(--surface-hover) 50%, var(--surface) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.2s infinite;
  border-radius: 8px;
}
.skel--circle { width: 52px; height: 52px; border-radius: 16px; }
.skel--line { height: 14px; }
.skeleton { background: var(--surface); border-radius: 8px; }
@keyframes shimmer {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

/* Toast — явный светлый текст (Telegram WebView иначе наследует серый) */
.toast {
  position: fixed;
  left: 50%;
  bottom: calc(var(--dock-h) + var(--safe-b) + 16px);
  transform: translateX(-50%);
  max-width: calc(100% - 32px);
  padding: 12px 18px;
  border-radius: 12px;
  background: #1e293b;
  color: #f8fafc;
  border: 1px solid rgba(148, 163, 184, 0.35);
  font-size: 0.88rem;
  font-weight: 600;
  z-index: 300;
  box-shadow: 0 12px 32px rgba(15, 23, 42, 0.28);
  text-align: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--dur-fast) ease;
  -webkit-text-fill-color: #f8fafc;
}
.toast:not([hidden]) {
  pointer-events: auto;
  opacity: 1;
  animation: toastIn var(--dur-slow) var(--ease-out) both;
}
.toast--ok {
  background: #064e3b;
  color: #ecfdf5;
  border-color: rgba(52, 211, 153, 0.55);
  -webkit-text-fill-color: #ecfdf5;
}
.toast--err {
  background: #7f1d1d;
  color: #fef2f2;
  border-color: rgba(248, 113, 113, 0.55);
  -webkit-text-fill-color: #fef2f2;
}

/* Busy overlay (save agent, etc.) */
.busy-overlay { z-index: 450; }
.busy-dots {
  display: inline-flex;
  width: 1.35em;
  justify-content: flex-start;
}
.busy-dots span {
  animation: busyDotBlink 1.2s ease-in-out infinite;
}
.busy-dots span:nth-child(1) { animation-delay: 0s; }
.busy-dots span:nth-child(2) { animation-delay: 0.2s; }
.busy-dots span:nth-child(3) { animation-delay: 0.4s; }
@keyframes busyDotBlink {
  0%, 70%, 100% { opacity: 0.2; }
  35% { opacity: 1; }
}

/* Mic overlay */
.mic-overlay {
  position: fixed;
  inset: 0;
  z-index: 400;
  background: rgba(0, 0, 0, 0.7);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}
.mic-overlay[hidden] { display: none !important; }
.mic-overlay:not([hidden]) {
  animation: uiFade var(--dur-fast) var(--ease-out) both;
}
.mic-box {
  width: 100%;
  max-width: 280px;
  padding: 28px;
  border-radius: var(--radius-lg);
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  text-align: center;
  box-shadow: var(--shadow);
}
.mic-overlay:not([hidden]) .mic-box {
  animation: uiRise var(--dur-med) var(--ease-spring) both;
}
.mic-box__waves {
  display: flex;
  justify-content: center;
  gap: 4px;
  height: 32px;
  align-items: flex-end;
  margin-bottom: 16px;
}
.mic-box__waves span {
  width: 4px;
  height: 100%;
  background: var(--accent);
  border-radius: 2px;
  transform-origin: bottom center;
  transform: scaleY(0.25);
  animation: micWave 0.8s ease-in-out infinite;
  will-change: transform;
}
.mic-box__waves span:nth-child(2) { animation-delay: 0.1s; }
.mic-box__waves span:nth-child(3) { animation-delay: 0.2s; }
.mic-box__waves span:nth-child(4) { animation-delay: 0.15s; }
.mic-box__waves--live span {
  animation-name: micWave;
}
.mic-box__spinner {
  width: 36px;
  height: 36px;
  margin: 0 auto 16px;
  border: 3px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: micSpin 0.7s linear infinite;
}
.mic-box--busy .mic-box__waves { display: none; }
.mic-box--busy .mic-box__spinner { display: block !important; }
@keyframes micSpin { to { transform: rotate(360deg); } }
@keyframes micWave {
  0%, 100% { transform: scaleY(0.25); }
  50% { transform: scaleY(1); }
}
.mic-box__title { font-weight: 700; margin: 0 0 4px; }
.mic-box__time { color: var(--text-muted); font-size: 0.85rem; margin-bottom: 16px; }

/* Legacy compat */
.glass-card, .glass-card--tight {
  padding: 14px;
  border-radius: var(--radius);
  background: var(--surface);
  border: 1px solid var(--border);
  margin-bottom: 12px;
}
.section { margin-bottom: 16px; }
.section-title { font-weight: 700; font-size: 0.88rem; margin-bottom: 10px; }
.comment { padding: 10px; border-radius: 8px; background: var(--surface); margin-bottom: 8px; }
.comment-form textarea { margin-bottom: 8px; }
.preview-wrap { overflow-x: auto; width: 100%; }
.preview-table { width: 100%; font-size: 0.75rem; border-collapse: collapse; }
.preview-table th, .preview-table td { padding: 6px 8px; border-bottom: 1px solid var(--border); text-align: left; }

/* Широкое окно (Telegram Desktop и т.п.) — сетка внутри ограниченной колонки */
@media (min-width: 560px) {
  :root { --layout-max: 560px; }
  .shell { max-width: var(--layout-max); padding: 0 20px; }
  .agent-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
    gap: 12px;
  }
}

@media (min-width: 720px) {
  :root { --layout-max: 680px; }
  .shell { max-width: var(--layout-max); }
}

@media (min-width: 960px) {
  :root { --layout-max: 800px; }
  .shell { max-width: var(--layout-max); }
  .agent-grid {
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  }
}

.seg { background: var(--surface-muted); }
.hist-filters__toggle[aria-expanded="true"] {
  border-color: var(--primary);
  color: var(--primary);
  background: var(--primary-soft);
}
.hist-filters__badge {
  background: var(--primary-soft);
  color: var(--primary);
}
.queue-call-item--pending .queue-call-item__st {
  background: var(--primary-soft);
  color: var(--primary);
}
.outreach-import-bar .btn--manual {
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text);
  font-weight: 600;
}
.sheet__backdrop { background: rgba(15, 23, 42, 0.4); }

/* ═══ Компания / компании (суперадмин) ═══ */
.view-admin--staff .admin-subseg { display: none !important; }
.view-admin--sa .admin-subseg,
.view-admin--sa #adminUsersPanel { display: none !important; }
.view-admin--sa #adminCompaniesPanel { display: block !important; }
.admin-panel--companies { padding: 0 0 28px; }
.co-page-title { font-size: 1.35rem; font-weight: 700; letter-spacing: -0.02em; margin: 4px 0 16px; color: var(--text); }
.co-loading, .co-empty { font-size: 0.88rem; color: var(--text-secondary); padding: 20px 4px; text-align: center; }
.co-cards { display: flex; flex-direction: column; gap: 12px; }
.co-card {
  display: flex; align-items: center; gap: 14px; width: 100%;
  padding: 18px 16px; text-align: left;
  background: linear-gradient(135deg, var(--surface) 0%, #f8fafc 100%);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: 0 1px 3px rgba(15, 23, 42, 0.06);
  cursor: pointer; transition: transform 0.15s ease, box-shadow 0.15s ease, border-color 0.15s ease;
}
.co-card:active { transform: scale(0.985); }
.co-card__icon {
  flex-shrink: 0; width: 52px; height: 52px; border-radius: 14px;
  display: flex; align-items: center; justify-content: center;
  font-size: 1.1rem; font-weight: 700; color: #fff;
  background: linear-gradient(145deg, var(--primary) 0%, #6366f1 100%);
  box-shadow: 0 4px 12px rgba(79, 70, 229, 0.25);
}
.co-card__body { flex: 1; min-width: 0; }
.co-card__name { font-size: 1.08rem; font-weight: 700; color: var(--text); line-height: 1.25; }
.co-card__stats { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.co-card__chev { font-size: 1.5rem; color: var(--text-secondary); opacity: 0.5; line-height: 1; }
.co-add-btn {
  width: 100%; margin-top: 16px; padding: 14px;
  border: 1.5px dashed var(--border-strong); border-radius: var(--radius-lg);
  background: transparent; color: var(--primary); font-size: 0.92rem; font-weight: 600;
  cursor: pointer;
}
.co-back {
  display: inline-flex; align-items: center; margin-bottom: 10px; padding: 4px 0;
  border: none; background: none; color: var(--primary); font-size: 0.88rem; font-weight: 600; cursor: pointer;
}
.co-hero {
  display: flex; align-items: center; gap: 14px;
  padding: 16px; margin-bottom: 14px;
  background: linear-gradient(135deg, var(--primary-soft) 0%, var(--surface) 55%);
  border: 1px solid var(--border); border-radius: var(--radius-lg);
}
.co-hero__icon {
  width: 56px; height: 56px; border-radius: 16px; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  font-size: 1.2rem; font-weight: 700; color: #fff;
  background: linear-gradient(145deg, var(--primary), #6366f1);
}
.co-hero__text { min-width: 0; }
.co-hero__name { font-size: 1.25rem; font-weight: 700; margin: 0; letter-spacing: -0.02em; color: var(--text); }
.co-hero__stats { font-size: 0.8rem; color: var(--text-secondary); margin-top: 4px; display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.co-hero__dot { opacity: 0.5; }
.co-tabs {
  display: flex; gap: 6px; padding: 4px; margin-bottom: 12px;
  background: var(--surface-muted); border-radius: var(--radius);
}
.co-tabs__btn {
  flex: 1; padding: 9px 12px; border: none; border-radius: 8px;
  background: transparent; color: var(--text-secondary);
  font-size: 0.85rem; font-weight: 600; cursor: pointer; transition: background 0.15s, color 0.15s;
}
.co-tabs__btn--on { background: var(--surface); color: var(--text); box-shadow: 0 1px 4px rgba(15, 23, 42, 0.08); }
.co-add-inline {
  width: 100%; margin-bottom: 10px; padding: 10px 12px;
  border: none; border-radius: var(--radius-sm);
  background: var(--primary-soft); color: var(--primary);
  font-size: 0.85rem; font-weight: 600; cursor: pointer;
}
.co-list { display: flex; flex-direction: column; gap: 8px; }
.co-item {
  display: flex; align-items: center; gap: 6px;
  padding: 4px 4px 4px 0; background: var(--surface);
  border: 1px solid var(--border); border-radius: var(--radius);
  overflow: hidden;
}
.co-item__tap {
  flex: 1; min-width: 0; display: flex; align-items: center; gap: 10px;
  padding: 8px 10px; margin: 0; border: none; background: transparent;
  text-align: left; cursor: pointer; font: inherit; color: inherit;
}
.co-item__tap--static { cursor: default; }
.co-item__tap:active { background: var(--surface-hover); }
.co-item__chev { font-size: 1.25rem; color: var(--text-secondary); opacity: 0.45; flex-shrink: 0; }
.co-hero--compact { padding: 12px 14px; margin-bottom: 10px; }
.co-item--off { opacity: 0.5; }
.co-item__avatar {
  width: 40px; height: 40px; border-radius: 11px; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  font-size: 0.8rem; font-weight: 700; color: var(--primary);
  background: var(--primary-soft);
}
.co-item__avatar--agent { color: #0d9488; background: rgba(13, 148, 136, 0.12); }
.co-item__body { flex: 1; min-width: 0; }
.co-item__name { font-size: 0.9rem; font-weight: 600; color: var(--text); line-height: 1.3; }
.co-item__meta { font-size: 0.75rem; color: var(--text-secondary); margin-top: 2px; }
.co-item__acts { display: flex; align-items: center; gap: 4px; flex-shrink: 0; }
.co-pill {
  display: inline-block; padding: 3px 8px; font-size: 0.72rem; font-weight: 600;
  border-radius: 999px; background: var(--surface-muted); color: var(--text-secondary);
}
.co-pill--role { background: var(--primary-soft); color: var(--primary); }
.co-pill--live { background: rgba(34, 197, 94, 0.12); color: #16a34a; font-size: 0.68rem; vertical-align: middle; margin-left: 4px; }
.co-select { font-size: 0.75rem; padding: 4px 6px; border-radius: 8px; border: 1px solid var(--border); background: var(--surface); max-width: 88px; }
.co-iconbtn {
  width: 28px; height: 28px; border: 1px solid var(--border); border-radius: 8px;
  background: var(--surface); font-size: 0.85rem; line-height: 1; cursor: pointer; color: var(--text-secondary);
}
.co-iconbtn--danger { color: var(--danger); }
.co-toolbar { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; }
.co-toolbar__title { font-size: 1.1rem; font-weight: 700; color: var(--text); }
.input--sm { padding: 8px 10px; font-size: 0.85rem; min-height: 36px; }

.adm-stage {
  display: flex;
  flex-direction: column;
  gap: 0;
  min-height: 0;
}
@keyframes admStageIn {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}
.adm-stage--enter {
  animation: admStageIn var(--dur-slow) var(--ease-out) both;
}
.adm-head { margin-bottom: 14px; }
.adm-head--row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}
.adm-head--row .toolbar__title { margin: 0; }
.adm-head--row .toolbar__hint { margin: 4px 0 0; }
.adm-head--actions-only {
  justify-content: flex-end;
  margin-bottom: 12px;
}
.adm-toolbar {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  margin-bottom: 12px;
}
.adm-toolbar__back {
  flex-shrink: 0;
  margin-top: 2px;
  width: 36px;
  height: 36px;
  border-radius: 10px;
}
.adm-toolbar__body { flex: 1; min-width: 0; }
.adm-toolbar__body .toolbar__title { margin: 0; line-height: 1.25; }
.adm-toolbar__body .toolbar__hint { margin: 4px 0 0; }
.adm-toolbar .btn--sm {
  flex-shrink: 0;
  margin-top: 2px;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}
.view-admin--sa .admin-panel--companies .agent-grid,
.view-admin--sa #adminUsersPanel .agent-grid {
  margin-top: 4px;
}
.co-strip-wrap {
  margin: 0 -2px 12px;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}
.co-strip-wrap::-webkit-scrollbar { display: none; }
.co-strip {
  display: flex;
  gap: 8px;
  padding: 2px 2px 6px;
  min-width: min-content;
}
.co-strip__btn {
  flex-shrink: 0;
  padding: 10px 16px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--surface);
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-secondary);
  cursor: pointer;
  transition: background 0.15s ease, border-color 0.15s ease, color 0.15s ease, transform 0.12s ease;
}
.co-strip__btn:active { transform: scale(0.97); }
.co-strip__btn--on {
  background: var(--primary);
  border-color: var(--primary);
  color: #fff;
  box-shadow: 0 2px 10px rgba(79, 70, 229, 0.28);
}
.co-strip__btn--add {
  border-style: dashed;
  color: var(--primary);
  background: var(--primary-soft);
  min-width: 44px;
  padding-left: 14px;
  padding-right: 14px;
}
.co-strip__pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
  padding: 6px 6px 6px 16px;
  border-radius: 999px;
  border: 1px solid var(--primary);
  background: var(--primary);
  color: #fff;
  box-shadow: 0 2px 10px rgba(79, 70, 229, 0.28);
  cursor: pointer;
  transition: transform 0.12s ease;
}
.co-strip__pill:active { transform: scale(0.97); }
.co-strip__pill-name {
  font-size: 0.85rem;
  font-weight: 600;
  white-space: nowrap;
}
.co-strip__pill-del {
  width: 28px;
  height: 28px;
  padding: 0;
  border: none;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.18);
  color: #fff;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: background 0.15s ease;
}
.co-strip__pill-del:active { background: rgba(255, 255, 255, 0.32); }
.co-seg-wrap {
  margin-bottom: 12px;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}
.co-seg-wrap::-webkit-scrollbar { display: none; }
.co-seg {
  display: flex;
  gap: 4px;
  padding: 3px;
  width: max-content;
  min-width: 100%;
  background: var(--surface-muted);
  border-radius: var(--radius);
}
.co-seg__btn {
  flex: 1 1 auto;
  min-width: max-content;
  padding: 8px 10px;
  border: none;
  border-radius: 8px;
  background: transparent;
  font-size: 0.74rem;
  font-weight: 600;
  line-height: 1.2;
  white-space: nowrap;
  color: var(--text-secondary);
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease, box-shadow 0.15s ease;
}
.co-seg__btn--on {
  background: var(--surface);
  color: var(--text);
  box-shadow: 0 1px 4px rgba(15, 23, 42, 0.08);
}
.sa-company-body { min-height: 120px; }
.co-add-bottom {
  width: 100%;
  margin-top: 12px;
  padding: 13px 14px;
  border: none;
  border-radius: var(--radius);
  background: var(--primary-soft);
  color: var(--primary);
  font-size: 0.88rem;
  font-weight: 600;
  cursor: pointer;
}
.co-add-bottom:active { opacity: 0.85; }
.view-admin--sa .admin-panel--companies { padding-top: 4px; }

/* ─── Карточка пользователя ─── */
.usr-list { display: flex; flex-direction: column; gap: 8px; }
.usr-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}
.usr-card--off { opacity: 0.55; }
.usr-card__head {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  padding: 10px;
}
.usr-card__toggle,
.usr-card__ava,
.usr-card__tools {
  align-self: center;
  flex-shrink: 0;
}
.usr-card__toggle {
  width: 24px;
  height: 24px;
  padding: 0;
  border: none;
  border-radius: 6px;
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.usr-card__toggle:active { background: var(--surface-muted); color: var(--text-secondary); }
.usr-card__toggle svg { transition: transform 0.18s ease; }
.usr-card--collapsed .usr-card__toggle svg { transform: rotate(-90deg); }
.usr-card__ava {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--primary);
  background: var(--primary-soft);
}
.usr-card__info {
  flex: 1;
  min-width: 0;
}
.usr-card__name {
  font-size: 0.9rem;
  font-weight: 700;
  line-height: 1.25;
  color: var(--text);
  letter-spacing: -0.01em;
  word-wrap: break-word;
  overflow-wrap: anywhere;
}
.usr-card__meta {
  margin-top: 2px;
  font-size: 0.72rem;
  font-weight: 500;
  line-height: 1.3;
  color: var(--text-secondary);
}
.usr-card__tools {
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 4px;
  margin-left: auto;
}
.usr-card__tools .select-wrap--xs {
  width: auto;
  min-width: 0;
  max-width: 92px;
}
.usr-card__tools .select-wrap--xs select {
  min-height: 30px;
  padding: 5px 8px;
  font-size: 0.72rem;
}
.co-pill--sm {
  font-size: 0.72rem;
  padding: 5px 9px;
}
.usr-toolbtn {
  width: 28px;
  height: 28px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  font-size: 0.72rem;
  cursor: pointer;
  color: var(--text-secondary);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.usr-toolbtn--danger { color: var(--danger); border-color: rgba(248, 113, 113, 0.35); background: rgba(254, 242, 242, 0.6); }
.usr-card__agents {
  border-top: 1px solid var(--border);
  background: var(--surface-muted);
  padding: 4px 10px 8px;
}
.usr-card__empty {
  margin: 0; padding: 8px 4px; font-size: 0.8rem; color: var(--text-secondary); text-align: center;
}
.usr-agent {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  padding: 6px 4px; border-radius: var(--radius-sm);
}
.usr-agent + .usr-agent { border-top: 1px solid rgba(15, 23, 42, 0.06); }
.usr-agent--muted { opacity: 0.72; }
.usr-agent--muted .usr-agent__name { color: var(--text-secondary); }
.usr-agent__info {
  flex: 1; min-width: 0; display: flex; align-items: center; gap: 8px;
  padding: 0; border: none; background: none; text-align: left; cursor: pointer; font: inherit; color: inherit;
}
.usr-agent__info:active { opacity: 0.7; }
.usr-agent__dot {
  width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0;
  background: var(--border-strong);
}
.usr-agent__dot--live { background: var(--live); box-shadow: 0 0 0 3px rgba(34, 197, 94, 0.18); }
.usr-agent__name {
  font-size: 0.88rem; font-weight: 600; color: var(--text);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.usr-agent__badge {
  flex-shrink: 0; font-size: 0.68rem; font-weight: 700; padding: 2px 7px;
  border-radius: 999px; background: rgba(34, 197, 94, 0.12); color: #16a34a;
}
.usr-agent__badge--own {
  background: rgba(79, 70, 229, 0.12); color: var(--primary);
}
.usr-agent__hint {
  flex-shrink: 0; font-size: 0.68rem; color: var(--text-secondary);
  max-width: 88px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.usr-switch {
  position: relative; display: inline-flex; align-items: center; flex-shrink: 0; cursor: pointer;
}
.usr-switch__input {
  position: absolute; opacity: 0; width: 0; height: 0;
}
.usr-switch__track {
  width: 44px; height: 26px; border-radius: 999px;
  background: var(--border-strong);
  transition: background 0.2s ease;
  position: relative;
}
.usr-switch__track::after {
  content: '';
  position: absolute; top: 3px; left: 3px;
  width: 20px; height: 20px; border-radius: 50%;
  background: #fff;
  box-shadow: 0 1px 3px rgba(15, 23, 42, 0.2);
  transition: transform 0.2s ease;
}
.usr-switch__input:checked + .usr-switch__track {
  background: var(--live);
}
.usr-switch__input:checked + .usr-switch__track::after {
  transform: translateX(18px);
}
.usr-switch__input:disabled + .usr-switch__track { opacity: 0.5; }
.co-card {
  animation: none;
}
.co-item {
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}
.co-item:active { transform: scale(0.99); }
.co-card:hover {
  border-color: rgba(79, 70, 229, 0.35);
  box-shadow: 0 4px 14px rgba(79, 70, 229, 0.1);
}

.settings-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 14px 0;
  border-bottom: 1px solid var(--border);
}
.settings-row:last-child { border-bottom: none; padding-bottom: 4px; }
.settings-row__text { min-width: 0; flex: 1; }
.settings-row__label {
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--text);
}
.settings-row__hint {
  margin-top: 3px;
  font-size: 0.75rem;
  color: var(--text-muted);
  line-height: 1.35;
}
.settings-row--lang {
  flex-direction: column;
  align-items: stretch;
  gap: 10px;
}
.sheet__body--settings {
  padding-top: 4px;
  padding-bottom: calc(16px + env(safe-area-inset-bottom, 0px));
}
.settings-lang {
  width: 100%;
}
.settings-lang .seg__btn {
  flex: 1;
  min-width: 0;
  padding: 10px 8px;
}
.settings-sip {
  border-top: 1px solid var(--border);
  padding-top: 14px;
  margin-top: 4px;
}
.settings-sip-head {
  margin-bottom: 10px;
}
.settings-sip-head .settings-row__label {
  font-size: 0.9375rem;
  font-weight: 600;
  margin-bottom: 4px;
}
.settings-sip-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.settings-sip-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 12px 12px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
}
.settings-sip-item__body { min-width: 0; flex: 1; }
.settings-sip-item__phone {
  font-size: 0.875rem;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  line-height: 1.3;
}
.settings-sip-item__meta {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-top: 2px;
  line-height: 1.3;
}
.settings-sip-item__del {
  flex-shrink: 0;
  width: 32px;
  height: 32px;
  border: none;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--text-muted);
  font-size: 1.25rem;
  line-height: 1;
  cursor: pointer;
  transition: color var(--dur-fast) ease, background var(--dur-fast) ease;
}
.settings-sip-item__del:hover { color: var(--danger); background: rgba(248, 113, 113, 0.08); }
.settings-sip-item__del:active { transform: scale(0.94); }
.settings-sip-empty {
  margin: 0 0 4px;
  padding: 12px 14px;
  border: 1px dashed var(--border);
  border-radius: var(--radius-sm);
  text-align: center;
  font-size: 0.8125rem;
}
.settings-sip-add {
  margin-top: 10px;
}
.settings-sip-add[hidden] { display: none !important; }
.settings-sip-form-wrap {
  display: grid;
  grid-template-rows: 0fr;
  opacity: 0;
  margin-top: 0;
  overflow: hidden;
  pointer-events: none;
  transition:
    grid-template-rows 0.38s cubic-bezier(0.22, 1, 0.36, 1),
    opacity 0.28s ease,
    margin-top 0.38s cubic-bezier(0.22, 1, 0.36, 1);
}
.settings-sip-form-wrap--open {
  grid-template-rows: 1fr;
  opacity: 1;
  margin-top: 12px;
  pointer-events: auto;
}
.settings-sip-form {
  min-height: 0;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 14px;
  border: 1px solid rgba(91, 141, 239, 0.28);
  border-radius: var(--radius-md);
  background: rgba(91, 141, 239, 0.05);
  box-shadow: 0 8px 24px rgba(15, 23, 42, 0.06);
}
.settings-sip-form__title {
  font-size: 0.875rem;
  font-weight: 600;
  margin-bottom: 2px;
}
.settings-sip-form__actions {
  display: flex;
  gap: 8px;
  margin-top: 4px;
}
.settings-sip-form__actions .btn { flex: 1; }
[data-theme="dark"] .settings-sip-form {
  background: rgba(91, 141, 239, 0.08);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.18);
}
[data-theme="dark"] .search,
[data-theme="dark"] .panel,
[data-theme="dark"] .sheet__panel,
[data-theme="dark"] .agent-tile,
[data-theme="dark"] .card-stack .call-card,
[data-theme="dark"] .queue-card,
[data-theme="dark"] .co-card,
[data-theme="dark"] .usr-card {
  border-color: var(--border);
}
[data-theme="dark"] .usr-switch__track::after {
  background: #f1f5f9;
}
