/* Светлая тема по умолчанию */
:root {
  --bg: #f1f5f9;
  --bg-card: #ffffff;
  --bg-sidebar: #e2e8f0;
  --border: #cbd5e1;
  --text: #1e293b;
  --text-muted: #64748b;
  --accent: #3b82f6;
  --accent-hover: #2563eb;
  --success: #22c55e;
  --danger: #ef4444;
  --radius: 10px;
  --font: 'Manrope', -apple-system, sans-serif;
  --hover-overlay: rgba(0, 0, 0, 0.04);
  --shadow-card: 0 20px 50px rgba(0, 0, 0, 0.08);
  --banner-warning-text: #854d0e;
  --nav-subtree-line: rgba(59, 130, 246, 0.22);
  --nav-subtree-dot: rgba(100, 116, 139, 0.45);
}

/* Тёмная тема */
[data-theme="dark"] {
  --bg: #0f1419;
  --bg-card: #1a2332;
  --bg-sidebar: #0a0e14;
  --border: #2d3a4a;
  --text: #e6edf3;
  --text-muted: #8b9cb3;
  --accent: #3b82f6;
  --accent-hover: #2563eb;
  --success: #22c55e;
  --danger: #ef4444;
  --hover-overlay: rgba(255, 255, 255, 0.04);
  --shadow-card: 0 20px 50px rgba(0, 0, 0, 0.3);
  --banner-warning-text: #facc15;
  --nav-subtree-line: rgba(59, 130, 246, 0.35);
  --nav-subtree-dot: rgba(139, 156, 179, 0.55);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.5;
  color: var(--text);
  background: var(--bg);
  min-height: 100vh;
}

.hidden { display: none !important; }

.banner {
  padding: 0.6rem 1rem;
  margin: 0;
  font-size: 0.9rem;
  line-height: 1.4;
}
.banner-warning {
  background: rgba(234, 179, 8, 0.15);
  border-bottom: 1px solid rgba(234, 179, 8, 0.4);
  color: var(--banner-warning-text);
}

.plan-status-banner {
  padding: 0.6rem 1rem;
  margin: 0;
  font-size: 0.9rem;
  line-height: 1.4;
  background: rgba(234, 179, 8, 0.15);
  border-bottom: 1px solid rgba(234, 179, 8, 0.4);
  color: var(--text);
}
.plan-status-banner a { color: var(--accent); font-weight: 600; }

/* Режим «только чтение»: тариф не оплачен, редактирование только в разделе «Тарифы» */
#page-content.read-only-plan section.content-section:not(#content-tariffs) input:not([readonly]):not([type="hidden"]),
#page-content.read-only-plan section.content-section:not(#content-tariffs) select,
#page-content.read-only-plan section.content-section:not(#content-tariffs) textarea,
#page-content.read-only-plan section.content-section:not(#content-tariffs) button:not([disabled]),
#page-content.read-only-plan section.content-section:not(#content-tariffs) a.btn {
  pointer-events: none;
  opacity: 0.75;
  cursor: not-allowed;
}

/* Подсказка «выберите тариф» в режиме только чтение — показывать и оставлять ссылку кликабельной */
.read-only-plan-notice { display: none; }
#page-content.read-only-plan .read-only-plan-notice {
  display: block;
  margin-bottom: 1rem;
  padding: 0.75rem 1rem;
  background: var(--surface-hover, rgba(234, 179, 8, 0.1));
  border-radius: 6px;
  border-left: 3px solid var(--accent, #eab308);
}
#page-content.read-only-plan .read-only-plan-notice,
#page-content.read-only-plan .read-only-plan-notice a.read-only-plan-notice-link {
  pointer-events: auto;
  opacity: 1;
  cursor: pointer;
}

/* Суперадмин может редактировать организацию (название, slug, сеть) даже без тарифа */
#page-content.read-only-plan #content-organization #org-edit-main-card input,
#page-content.read-only-plan #content-organization #org-edit-main-card button,
#page-content.read-only-plan #content-organization #org-edit-main-card select,
#page-content.read-only-plan #content-organization #org-edit-main-card label {
  pointer-events: auto;
  opacity: 1;
  cursor: auto;
}

/* Login */
#init-loading {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background: linear-gradient(145deg, #e2e8f0 0%, #f1f5f9 50%, #f8fafc 100%);
}
[data-theme="dark"] #init-loading {
  background: linear-gradient(145deg, #0a0e14 0%, #151d2b 50%, #0f1419 100%);
}
#init-loading.hidden { display: none !important; }

#login-screen {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background: linear-gradient(145deg, #e2e8f0 0%, #f1f5f9 50%, #f8fafc 100%);
}
[data-theme="dark"] #login-screen {
  background: linear-gradient(145deg, #0a0e14 0%, #151d2b 50%, #0f1419 100%);
}

.login-card {
  width: 100%;
  max-width: 380px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 2rem;
  box-shadow: var(--shadow-card);
}

.login-title {
  margin: 0 0 0.25rem;
  font-size: 1.75rem;
  font-weight: 700;
  color: var(--text);
}

.login-tabs {
  display: flex;
  gap: 0;
  margin: 1rem 0 1.25rem;
  border-bottom: 1px solid var(--border);
}

.login-tab {
  flex: 1;
  padding: 0.5rem 0.75rem;
  font: inherit;
  font-size: 0.9rem;
  color: var(--text-muted);
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  cursor: pointer;
  border-radius: 4px 4px 0 0;
}

.login-tab:hover {
  color: var(--text);
}

.login-tab.active {
  color: var(--accent);
  font-weight: 500;
  border-bottom-color: var(--accent);
}

.login-tab-pane {
  display: block;
}

.login-tab-pane.hidden {
  display: none !important;
}

.login-subtitle {
  margin: 0 0 1.5rem;
  color: var(--text-muted);
  font-size: 0.95rem;
}

.login-register-link {
  margin-top: 1rem;
  text-align: center;
}
.login-register-link .btn-ghost { font-size: 0.9rem; }

.login-form label {
  display: block;
  margin-bottom: 1rem;
}

.login-form label span {
  display: block;
  margin-bottom: 0.35rem;
  font-size: 0.875rem;
  color: var(--text-muted);
}

.login-form input {
  width: 100%;
  padding: 0.65rem 0.85rem;
  font: inherit;
  color: var(--text);
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 6px;
}

.login-form input::placeholder {
  color: var(--text-muted);
  opacity: 0.7;
}

.login-form input:focus {
  outline: none;
  border-color: var(--accent);
}

.login-call-timer {
  font-size: 1.25rem;
  font-variant-numeric: tabular-nums;
  margin: 0.5rem 0;
  color: var(--text);
}

.error-msg {
  color: var(--danger);
  font-size: 0.875rem;
  margin-bottom: 0.75rem;
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.6rem 1.2rem;
  font: inherit;
  font-weight: 500;
  border: none;
  border-radius: 6px;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}

.btn-primary {
  background: var(--accent);
  color: #fff;
  width: 100%;
  padding: 0.75rem;
}

.btn-primary:hover { background: var(--accent-hover); }
.btn-primary:disabled { opacity: 0.6; cursor: not-allowed; }

/* Schedule: calmer primary action (macOS-like) */
#schedule-day-load.btn-primary {
  background: #3b6fe6;
}
#schedule-day-load.btn-primary:hover { background: #2f61d8; }
#schedule-day-load.btn-primary:active { background: #2a57c4; }
[data-theme="dark"] #schedule-day-load.btn-primary {
  background: #2f66e8;
}
[data-theme="dark"] #schedule-day-load.btn-primary:hover { background: #2a5dd6; }
[data-theme="dark"] #schedule-day-load.btn-primary:active { background: #2452bf; }

.btn-secondary { background: var(--bg-card); color: var(--text-muted); border: 1px solid var(--border); }
.btn-secondary:hover { background: var(--bg); color: var(--text); }

.btn-danger { background: #8b2635; color: #fff; border: none; }
.btn-danger:hover { background: #a52d3f; }

.btn-ghost {
  background: transparent;
  color: var(--text-muted);
}

.btn-ghost:hover { color: var(--text); background: var(--hover-overlay); }

/* App layout */
#app-screen {
  display: flex;
  min-height: 100vh;
  min-height: 100dvh;
  height: 100vh;
  height: 100dvh;
  max-height: 100dvh;
  overflow: hidden;
}

.sidebar {
  width: 240px;
  background: var(--bg-sidebar);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  min-height: 0;
  overflow-x: hidden;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  transition: width 0.2s ease, opacity 0.2s ease, border-color 0.2s ease;
}

.sidebar-header {
  padding: 1.25rem;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
  overflow: hidden;
}

.logo {
  font-weight: 700;
  font-size: 1.1rem;
}

.user-role {
  display: block;
  margin-top: 0.25rem;
  font-size: 0.75rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.sidebar-header-context {
  margin-top: 0.5rem;
  font-size: 0.7rem;
  color: var(--text-muted);
  line-height: 1.35;
}

.sidebar-header-context .context-line {
  display: block;
}

.sidebar-header-branch {
  margin-top: 0.5rem;
  font-size: 0.7rem;
  color: var(--text-muted);
}

.sidebar-header-branch-label {
  display: block;
  margin-bottom: 0.2rem;
}

.sidebar-header-branch select {
  width: 100%;
  padding: 0.35rem 0.5rem;
  font-size: 0.75rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg);
  color: var(--text);
}

.sidebar-header-exit-impersonate {
  margin-top: 0.5rem;
}

/* Toast notifications (top-right) */
.toast-container {
  position: fixed;
  top: 1rem;
  right: 1rem;
  z-index: 1200;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  width: min(92vw, 380px);
  pointer-events: none;
}
.toast {
  pointer-events: auto;
  display: flex;
  align-items: flex-start;
  gap: 0.6rem;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-left: 4px solid var(--accent);
  color: var(--text);
  border-radius: 8px;
  box-shadow: var(--shadow-card);
  padding: 0.65rem 0.75rem;
}
.toast.toast-success { border-left-color: #16a34a; }
.toast.toast-error { border-left-color: #dc2626; }
.toast.toast-warning { border-left-color: #d97706; }
.toast.toast-info { border-left-color: #2563eb; }
.toast-message {
  flex: 1;
  min-width: 0;
  word-break: break-word;
  font-size: 0.92rem;
  line-height: 1.35;
}
.toast-close {
  border: 0;
  background: transparent;
  color: var(--text-muted);
  font-size: 1.05rem;
  line-height: 1;
  padding: 0.1rem 0.25rem;
  cursor: pointer;
}
.toast-close:hover { color: var(--text); }

.workhours-editor {
  display: flex;
  flex-direction: column;
  gap: 0.55rem;
  margin-bottom: 0.8rem;
}

.workhours-editor-row {
  display: grid;
  grid-template-columns: minmax(150px, 1fr) minmax(100px, 120px) minmax(100px, 120px) auto auto;
  gap: 0.5rem;
  align-items: center;
}

.workhours-editor-row .btn {
  min-height: 38px;
}

.workhours-editor-empty {
  color: var(--text-muted);
  font-size: 0.9rem;
}

@media (max-width: 900px) {
  .workhours-editor-row {
    grid-template-columns: 1fr;
  }
}

.workhours-slot-block {
  cursor: grab;
}

.workhours-slot-block:active {
  cursor: grabbing;
}

.sidebar-header-exit-impersonate .btn {
  width: 100%;
  justify-content: center;
}

.sidebar-nav {
  flex: 0 0 auto;
  padding: 0.75rem 0;
  position: relative;
  z-index: 1;
  min-height: auto;
}

.nav-link {
  display: block;
  padding: 0.42rem 1.25rem;
  color: var(--text-muted);
  text-decoration: none;
  font-size: 0.95rem;
  line-height: 1.3;
  transition: color 0.15s, background 0.15s;
}

.nav-link:hover { color: var(--text); background: var(--hover-overlay); }
.nav-link.active { color: var(--accent); background: rgba(59,130,246,0.1); }

/* Раскрывающаяся группа меню: строгий macOS-like стиль */
.nav-group {
  margin: 0.12rem 0.7rem;
  border-radius: 10px;
}
.nav-group-toggle {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  text-align: left;
  border: 0;
  background: transparent;
  color: var(--text-muted);
  padding: 0.46rem 0.62rem 0.46rem 0.92rem;
  font: inherit;
  font-size: 0.95rem;
  line-height: 1.3;
  cursor: pointer;
  border-radius: 8px;
  transition: color 0.15s ease, background 0.15s ease, border-color 0.15s ease;
  border: 1px solid transparent;
}
.nav-group-toggle::after {
  content: "";
  margin-left: auto;
  flex-shrink: 0;
  width: 0.42rem;
  height: 0.42rem;
  border-right: 1.7px solid currentColor;
  border-bottom: 1.7px solid currentColor;
  transform: rotate(-45deg);
  opacity: 0.48;
  transition: transform 0.2s ease, opacity 0.15s ease;
}
.nav-group-toggle[aria-expanded="true"]::after {
  transform: rotate(45deg);
  margin-top: -2px;
}
.nav-group-toggle:hover {
  color: var(--text);
  background: rgba(148, 163, 184, 0.1);
  border-color: rgba(148, 163, 184, 0.2);
}
.nav-group-toggle:hover::after { opacity: 0.85; }
.nav-group-toggle.active {
  color: var(--text);
  background: rgba(148, 163, 184, 0.12);
  border-color: rgba(148, 163, 184, 0.24);
}
.nav-group-toggle.active::after {
  opacity: 0.78;
  border-color: var(--text-muted);
}

.nav-group-items {
  margin: 0.16rem 0 0.28rem 0.48rem;
  padding: 0.06rem 0 0.28rem 0.62rem;
  border-left: 1px solid color-mix(in oklab, var(--border) 82%, transparent);
}
.nav-group-items:not(.hidden) {
  margin-bottom: 0.1rem;
}
.nav-group-items .nav-link-sub {
  position: relative;
  padding: 0.38rem 0.58rem 0.38rem 1.18rem;
  margin: 0.03rem 0;
  font-size: 0.9rem;
  line-height: 1.35;
  border-radius: 7px;
  border: 1px solid transparent;
  transition: color 0.15s ease, background 0.15s ease, border-color 0.15s ease;
}
.nav-group-items .nav-link-sub::before {
  content: "";
  position: absolute;
  left: 0.35rem;
  top: 50%;
  transform: translateY(-50%);
  width: 4px;
  height: 4px;
  border-radius: 50%;
  background: color-mix(in oklab, var(--text-muted) 72%, transparent);
  transition: background 0.15s ease, transform 0.15s ease;
}
.nav-group-items .nav-link-sub:hover {
  background: rgba(148, 163, 184, 0.08);
  border-color: rgba(148, 163, 184, 0.18);
}
.nav-group-items .nav-link-sub:hover::before {
  background: color-mix(in oklab, var(--text) 62%, var(--text-muted));
}
.nav-group-items .nav-link-sub.active {
  color: var(--text);
  background: color-mix(in oklab, var(--bg-card) 76%, var(--bg-sidebar));
  font-weight: 600;
  border-color: color-mix(in oklab, var(--border) 88%, transparent);
  box-shadow: 0 1px 0 rgba(255, 255, 255, 0.45) inset;
}
.nav-group-items .nav-link-sub.active::before {
  background: color-mix(in oklab, var(--text) 80%, var(--text-muted));
  transform: translateY(-50%) scale(1.08);
}
[data-theme="dark"] .nav-group-items .nav-link-sub.active {
  background: color-mix(in oklab, var(--bg-card) 84%, #111722);
  box-shadow: 0 1px 0 rgba(255, 255, 255, 0.04) inset;
}

.incoming-requests-row--selected {
  background: rgba(59, 130, 246, 0.12);
}
[data-theme="dark"] .incoming-requests-row--selected {
  background: rgba(59, 130, 246, 0.22);
}

.nav-admin,
.nav-client,
.nav-superadmin-only { display: none; }
.role-admin .nav-admin,
.role-org_main_admin .nav-admin,
.role-superadmin .nav-admin { display: block; }
.role-superadmin .nav-superadmin-only { display: block; }
/* Суперадмин без выбранной организации: скрыть разделы, требующие контекста организации */
.superadmin-no-org .nav-requires-org { display: none !important; }
.superadmin-no-org .nav-requires-org.nav-widget-for-superadmin { display: block !important; }
.superadmin-no-org .nav-requires-org.nav-settings-for-superadmin { display: block !important; }
.superadmin-no-org .nav-requires-org.nav-payment-gateways-for-superadmin { display: block !important; }
.superadmin-no-org .nav-requires-org.nav-api-tokens-for-superadmin { display: block !important; }
/* Филиалы показываем только организациям с флагом «сеть» */
.nav-link[data-page="branches"] { display: none !important; }
.org-is-network .nav-link[data-page="branches"] { display: block !important; }
.role-client .nav-client { display: block; }
.role-trainer .nav-client { display: none; }

.sidebar-footer {
  padding: 1rem 1.25rem;
  border-top: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  flex-shrink: 0;
  background: var(--bg-sidebar);
  z-index: 1;
}

.main {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
  overflow: hidden;
}

.main-header {
  padding: 1rem 1.5rem;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 0.5rem;
  position: sticky;
  top: 0;
  z-index: 50;
  background: var(--bg);
  box-shadow: 0 1px 0 rgba(0, 0, 0, 0.04);
}

.main-header h2 {
  margin: 0;
  font-size: 1.25rem;
  font-weight: 600;
}

.user-info {
  font-size: 0.875rem;
  color: var(--text-muted);
}

.page-content {
  flex: 1;
  min-height: 0;
  padding: 1.5rem;
  overflow: auto;
}

.admin-version-badge {
  position: fixed;
  right: 16px;
  bottom: 12px;
  z-index: 90;
  padding: 0.35rem 0.6rem;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--bg-card);
  color: var(--text-muted);
  font-size: 0.76rem;
  line-height: 1.2;
  font-variant-numeric: tabular-nums;
  backdrop-filter: blur(6px);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
  pointer-events: none;
}

.content-section {
  width: 100%;
  max-width: none;
}

.content-section.hidden { display: none; }

.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem 1.5rem;
  margin-bottom: 1.25rem;
}

.card h3 {
  margin: 0 0 1rem;
  font-size: 1.05rem;
  font-weight: 600;
}

.card .muted { color: var(--text-muted); font-size: 0.9rem; }

.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.4);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
}
.modal-overlay.hidden { display: none; }
.modal-card {
  background: var(--bg-card);
  border-radius: var(--radius);
  padding: 1.25rem 1.5rem;
  max-width: 90vw;
  max-height: 85vh;
  overflow: auto;
  box-shadow: var(--shadow-card);
}
.modal-card h3 { margin: 0 0 0.75rem; font-size: 1.05rem; }
.modal-actions { margin-top: 1rem; display: flex; flex-wrap: wrap; gap: 0.75rem; }
.schedule-validation-modal-hint {
  margin: 0.75rem 0 0;
  font-size: 0.92rem;
  line-height: 1.45;
}
.schedule-delete-list { max-height: 200px; overflow-y: auto; margin: 0.5rem 0; padding-left: 1.25rem; font-size: 0.9rem; }

/* Модалка события расписания */
.modal-card--schedule-event {
  max-width: 580px;
  width: 100%;
  max-height: 90vh;
  overflow-y: auto;
  padding: 1.5rem 1.65rem 1.35rem;
  border: 1px solid var(--border);
}
.schedule-event-modal__headline {
  margin: 0 0 1rem;
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--text);
  padding-bottom: 0.65rem;
  border-bottom: 2px solid var(--accent);
}
.schedule-event-modal__info-root { margin-bottom: 1.25rem; }
.schedule-event-modal__summary {
  background: var(--bg-sidebar);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem 1.15rem;
}
[data-theme="dark"] .schedule-event-modal__summary {
  background: rgba(59, 130, 246, 0.06);
  border-color: var(--border);
}
.schedule-event-modal__service-name {
  font-size: 1.05rem;
  font-weight: 600;
  color: var(--text);
  line-height: 1.35;
  margin-bottom: 0.85rem;
}
.schedule-event-modal__meta-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.65rem 1.25rem;
}
@media (max-width: 520px) {
  .schedule-event-modal__meta-grid { grid-template-columns: 1fr; }
}
.schedule-event-modal__meta {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
}
.schedule-event-modal__meta--wide {
  grid-column: 1 / -1;
}
.schedule-event-modal__meta-label {
  font-size: 0.72rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-muted);
}
.schedule-event-modal__meta-value {
  font-size: 0.95rem;
  color: var(--text);
  line-height: 1.4;
}
.schedule-event-modal__alert {
  margin-top: 0.85rem;
  padding: 0.55rem 0.75rem;
  border-radius: 8px;
  font-size: 0.9rem;
  line-height: 1.4;
}
.schedule-event-modal__alert--danger {
  background: rgba(239, 68, 68, 0.12);
  border: 1px solid rgba(239, 68, 68, 0.35);
  color: var(--danger);
}
.schedule-event-modal__alert--warn {
  background: rgba(234, 179, 8, 0.12);
  border: 1px solid rgba(234, 179, 8, 0.35);
  color: var(--banner-warning-text);
}
.schedule-event-modal__section {
  margin-top: 1.15rem;
  padding-top: 1rem;
  border-top: 1px solid var(--border);
}
.schedule-event-modal__section:first-of-type {
  border-top: none;
  padding-top: 0;
  margin-top: 0;
}
.schedule-event-modal__section-title {
  margin: 0 0 0.65rem;
  font-size: 0.8rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
}
.schedule-event-modal__hint {
  margin: 0 0 0.85rem;
  font-size: 0.88rem;
  color: var(--text-muted);
  line-height: 1.45;
}
.schedule-event-modal__field {
  margin-bottom: 1rem;
}
.schedule-event-modal__field:last-of-type { margin-bottom: 0.35rem; }
.schedule-event-modal__label {
  display: block;
  margin-bottom: 0.35rem;
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--text);
}
.schedule-event-modal__search-wrap {
  position: relative;
  display: flex;
  align-items: center;
}
.schedule-event-modal__search-wrap::before {
  content: "";
  position: absolute;
  left: 0.85rem;
  top: 50%;
  transform: translateY(-50%);
  width: 1.1rem;
  height: 1.1rem;
  background: center / contain no-repeat
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath fill='%2364748b' d='M15.5 14h-.79l-.28-.27A6.471 6.471 0 0016 9.5 6.5 6.5 0 105.5 16c1.61 0 3.09-.59 4.23-1.57l.27.28v.79l5 4.99L20.49 19l-4.99-5zm-6 0C7.01 14 5 11.99 5 9.5S7.01 5 9.5 5 14 7.01 14 9.5 11.99 14 9.5 14z'/%3E%3C/svg%3E");
  opacity: 0.85;
  pointer-events: none;
}
[data-theme="dark"] .schedule-event-modal__search-wrap::before {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath fill='%238b9cb3' d='M15.5 14h-.79l-.28-.27A6.471 6.471 0 0016 9.5 6.5 6.5 0 105.5 16c1.61 0 3.09-.59 4.23-1.57l.27.28v.79l5 4.99L20.49 19l-4.99-5zm-6 0C7.01 14 5 11.99 5 9.5S7.01 5 9.5 5 14 7.01 14 9.5 11.99 14 9.5 14z'/%3E%3C/svg%3E");
}
.schedule-event-modal__input,
.schedule-event-modal__select {
  width: 100%;
  padding: 0.6rem 0.85rem;
  font: inherit;
  font-size: 0.95rem;
  color: var(--text);
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 8px;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.schedule-event-modal__search-wrap .schedule-event-modal__input {
  padding-left: 2.35rem;
}
.schedule-event-modal__input:hover,
.schedule-event-modal__select:hover {
  border-color: color-mix(in srgb, var(--accent) 35%, var(--border));
}
.schedule-event-modal__input:focus,
.schedule-event-modal__select:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 22%, transparent);
}
.schedule-event-modal__select {
  cursor: pointer;
  min-height: 2.65rem;
  padding-right: 2rem;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%2364748b' d='M3 4.5L6 7.5L9 4.5'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 0.75rem center;
  appearance: none;
}
[data-theme="dark"] .schedule-event-modal__select {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%238b9cb3' d='M3 4.5L6 7.5L9 4.5'/%3E%3C/svg%3E");
}
.schedule-event-modal__pick-list {
  margin-top: 0.5rem;
  max-height: 200px;
  overflow-y: auto;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--bg-card);
  box-shadow: 0 2px 8px var(--hover-overlay);
}
.schedule-event-modal__pick-hint {
  padding: 0.55rem 0.75rem;
  margin: 0;
  font-size: 0.88rem;
}
.schedule-event-modal__pick-btn {
  display: block;
  width: 100%;
  text-align: left;
  padding: 0.55rem 0.85rem;
  border: none;
  border-bottom: 1px solid var(--border);
  background: transparent;
  cursor: pointer;
  font: inherit;
  font-size: 0.92rem;
  color: var(--text);
  transition: background 0.12s;
}
.schedule-event-modal__pick-btn:last-child { border-bottom: none; }
.schedule-event-modal__pick-btn:hover {
  background: color-mix(in srgb, var(--accent) 12%, transparent);
}
.schedule-event-modal__pick-btn:focus {
  outline: none;
  background: color-mix(in srgb, var(--accent) 15%, transparent);
}
.schedule-event-modal__client-badge {
  margin-top: 0.5rem;
  display: inline-flex;
  align-items: center;
  padding: 0.4rem 0.75rem;
  font-size: 0.88rem;
  font-weight: 600;
  color: var(--accent);
  background: color-mix(in srgb, var(--accent) 10%, transparent);
  border: 1px solid color-mix(in srgb, var(--accent) 28%, var(--border));
  border-radius: 8px;
}
.schedule-event-modal__bookings {
  min-height: 0.5rem;
}
.schedule-event-modal__booking-list {
  list-style: none;
  padding: 0;
  margin: 0;
}
.schedule-event-modal__booking-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem 0.75rem;
  padding: 0.55rem 0.65rem;
  margin-bottom: 0.4rem;
  background: var(--bg-sidebar);
  border: 1px solid var(--border);
  border-radius: 8px;
}
[data-theme="dark"] .schedule-event-modal__booking-row {
  background: rgba(255, 255, 255, 0.03);
}
.schedule-event-modal__booking-name {
  font-weight: 600;
  font-size: 0.92rem;
  flex: 0 1 10rem;
  min-width: 7rem;
}
.schedule-event-modal__pay-line {
  display: inline-flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 0.35rem 0.5rem;
  flex: 1 1 12rem;
  min-width: 10rem;
  font-size: 0.88rem;
}
.schedule-event-modal__pay-unpaid {
  color: #b45309;
  font-weight: 600;
}
[data-theme="dark"] .schedule-event-modal__pay-unpaid {
  color: #fbbf24;
}
.schedule-event-modal__pay-paid {
  color: #15803d;
  font-weight: 600;
}
[data-theme="dark"] .schedule-event-modal__pay-paid {
  color: #4ade80;
}
.schedule-event-modal__pay-na {
  color: var(--text-muted);
  font-weight: 500;
}
.schedule-event-modal__pay-hint,
.schedule-event-modal__pay-channel,
.schedule-event-modal__record-status {
  font-size: 0.78rem;
}
.schedule-event-modal__booking-status {
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  color: var(--text-muted);
  padding: 0.15rem 0.45rem;
  background: var(--bg-card);
  border-radius: 4px;
  border: 1px solid var(--border);
}
.schedule-event-modal__booking-cancel.btn-sm {
  margin-left: auto;
}
.schedule-event-modal__booking-row .btn-sm {
  flex-shrink: 0;
}
.schedule-event-modal__pay-note {
  font-size: 0.75rem;
  padding: 0.1rem 0.4rem;
  border-radius: 4px;
  background: var(--bg-card);
  border: 1px solid var(--border);
}
.schedule-event-modal__history-title {
  margin: 0.85rem 0 0.35rem;
  font-size: 0.72rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}
.schedule-event-modal__history-list {
  list-style: none;
  padding: 0;
  margin: 0;
  font-size: 0.88rem;
  line-height: 1.5;
}
.schedule-event-modal__history-list li {
  padding: 0.25rem 0;
  border-bottom: 1px dashed color-mix(in srgb, var(--border) 70%, transparent);
}
.schedule-event-modal__history-list li:last-child {
  border-bottom: none;
}
.schedule-event-modal__empty {
  margin: 0;
  padding: 0.5rem 0;
  font-size: 0.92rem;
}
.schedule-event-modal__form-error {
  margin-top: 0.65rem;
  margin-bottom: 0;
  padding: 0.45rem 0.65rem;
  border-radius: 8px;
  background: rgba(239, 68, 68, 0.08);
  border: 1px solid rgba(239, 68, 68, 0.25);
}
.schedule-event-modal__actions {
  margin-top: 1.35rem;
  padding-top: 1rem;
  border-top: 1px solid var(--border);
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.65rem;
}
.schedule-event-modal__actions #schedule-event-book-submit {
  margin-left: auto;
  min-width: 7.5rem;
}
@media (max-width: 480px) {
  .schedule-event-modal__actions #schedule-event-book-submit {
    margin-left: 0;
    width: 100%;
  }
}

.nav-inline { color: var(--accent); text-decoration: none; }
.nav-inline:hover { text-decoration: underline; }

.form-row {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
  align-items: flex-end;
  margin-bottom: 1rem;
}

.form-row label { display: flex; align-items: center; gap: 0.5rem; }
.form-row label:has(textarea) { align-items: flex-start; flex-direction: column; }
/* Строка формы: подпись сверху, палитра сеткой ниже (порядок в DOM = порядок на экране) */
.form-row--color-palette {
  flex-direction: column;
  align-items: flex-start;
  align-content: flex-start;
  width: 100%;
}
.form-row--color-palette .form-row--color-palette__label {
  display: block;
  width: 100%;
  margin-bottom: 0;
}
/* Палитра выбора цвета (4 ряда по 20) для типа услуги и услуги */
.service-color-palette {
  display: grid;
  grid-template-columns: repeat(20, 28px);
  gap: 6px;
  margin-top: 0;
  width: 100%;
}
.service-color-swatch {
  width: 28px;
  height: 28px;
  padding: 0;
  border: 2px solid var(--border);
  border-radius: 6px;
  cursor: pointer;
  transition: transform 0.12s ease, box-shadow 0.12s ease;
}
.service-color-swatch:hover {
  transform: scale(1.08);
  box-shadow: 0 2px 8px rgba(0,0,0,0.15);
}
.service-color-swatch.selected {
  border-color: var(--text);
  box-shadow: 0 0 0 2px var(--bg), 0 0 0 4px var(--text);
}
.service-type-swatch { display: inline-block; width: 14px; height: 14px; border-radius: 3px; border: 1px solid var(--border); vertical-align: middle; margin-right: 0.25rem; }
.service-swatch { margin-right: 0; }
#services-list td:first-child .service-type-swatch { margin-right: 0.35rem; }
.service-list-slot-preview {
  display: inline-block;
  min-width: 44px;
  width: 100%;
  min-height: 48px;
  border-radius: 6px;
  border-width: 3px;
  border-style: solid;
  box-sizing: border-box;
  vertical-align: middle;
}
.service-slot-preview-label { font-size: 0.9rem; color: var(--text-muted); margin-right: 0.5rem; }
.service-slot-preview {
  display: inline-block;
  min-width: 120px;
  height: 36px;
  border-radius: 6px;
  border-width: 3px;
  border-style: solid;
  border-color: rgba(156, 163, 175, 0.10);
  background: rgba(156, 163, 175, 0.10);
  vertical-align: middle;
}
.form-row input, .form-row select, .form-row textarea,
.form-inline input, .form-inline select, .form-inline textarea {
  padding: 0.5rem 0.75rem;
  font: inherit;
  color: var(--text);
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 6px;
}
.form-row textarea { width: 100%; min-height: 80px; resize: vertical; }

/* Секреты: поле + кнопка «показать/скрыть» */
.password-input-wrap {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
}
.password-input-wrap input { flex: 1; min-width: 12rem; }
.btn-password-toggle {
  flex-shrink: 0;
  padding: 0.4rem 0.5rem;
  font-size: 1.1rem;
  line-height: 1;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 6px;
  cursor: pointer;
  color: var(--text);
}
.btn-password-toggle:hover { background: var(--border); color: var(--text); }
.btn-password-toggle:focus { outline: 2px solid var(--accent); outline-offset: 1px; }
.btn-password-toggle .icon-eye-off { display: none; }
.btn-password-toggle.is-visible .icon-eye { display: none; }
.btn-password-toggle.is-visible .icon-eye-off { display: block; }

.media-display {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  margin-right: 0.5rem;
  color: var(--text-muted);
  font-size: 0.9rem;
}
/* Блок с фото: сверху превью, под ним подпись и метаданные */
.media-display-image {
  flex-direction: column;
  align-items: flex-start;
  flex-wrap: wrap;
  gap: 0.35rem;
}
.media-display-preview {
  width: 160px;
  height: 120px;
  object-fit: cover;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  display: block;
  background: var(--bg);
}
.media-display-preview[hidden],
.media-display-preview:not([src]) { display: none !important; }
.media-display-meta {
  width: 100%;
  margin-top: 0;
  font-size: 0.8rem;
  color: var(--text-muted);
}

.form-inline {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.75rem;
}
.form-inline label { display: flex; align-items: center; gap: 0.5rem; }
.form-inline input[type="search"],
.form-inline input[type="text"],
.form-inline input[type="email"],
.form-inline input[type="tel"],
.form-inline input[type="url"],
.form-inline input[type="password"] {
  min-width: 180px;
}

.widget-booking-block { margin-bottom: 1.5rem; padding-bottom: 1.5rem; border-bottom: 1px solid var(--border); }
.widget-booking-block h4 { margin: 0 0 0.35rem; font-size: 1rem; }
.widget-booking-block .widget-cors-hint-pre { margin: 0.5rem 0; }
.widget-promo-fieldset { margin: 1.25rem 0; padding: 1rem; border: 1px solid var(--border); border-radius: var(--radius); }
.widget-promo-fieldset legend { padding: 0 0.5rem; color: var(--text-muted); font-size: 0.9rem; }
.label-inline { margin-right: 0.75rem; color: var(--text-muted); font-size: 0.9rem; }
.checkbox-inline { display: inline-flex; align-items: center; gap: 0.35rem; margin-right: 1rem; font-size: 0.9rem; cursor: pointer; }
.checkbox-inline input { width: auto; }

.table-wrap {
  overflow-x: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
}

th, td {
  padding: 0.6rem 0.75rem;
  text-align: left;
  border-bottom: 1px solid var(--border);
}

th {
  color: var(--text-muted);
  font-weight: 500;
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

tr:last-child td { border-bottom: none; }
tr:hover td { background: var(--hover-overlay); }

.btn-sm {
  padding: 0.35rem 0.7rem;
  font-size: 0.85rem;
}

.token-created {
  margin-top: 1rem;
  padding: 1rem;
  background: rgba(34,197,94,0.1);
  border: 1px solid rgba(34,197,94,0.3);
  border-radius: 6px;
}

.token-created code {
  display: block;
  margin-top: 0.5rem;
  padding: 0.5rem;
  background: var(--bg);
  border-radius: 4px;
  font-size: 0.85rem;
  word-break: break-all;
}

.empty-msg { color: var(--text-muted); font-style: italic; }

/* Schedule: toolbar & view toggle */
.schedule-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 1rem;
  margin-bottom: 1rem;
}
.schedule-view-toggle .schedule-view-btn { margin-right: 0.25rem; }
.schedule-view-toggle .schedule-view-btn.active { background: var(--accent); color: #fff; border-color: var(--accent); }
.schedule-controls { display: flex; flex-wrap: wrap; align-items: center; gap: 0.75rem; }
.schedule-controls label { display: flex; align-items: center; gap: 0.35rem; font-size: 0.9rem; }
.schedule-week-label { min-width: 140px; text-align: center; font-weight: 500; }

/* Schedule: display filters (week + day views) */
.schedule-display-filters {
  margin-bottom: 1rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg);
  padding: 0.5rem 0.75rem;
}
.schedule-display-filters-details summary {
  cursor: pointer;
  font-weight: 600;
  padding: 0.25rem 0;
  list-style: none;
}
.schedule-display-filters-details summary::-webkit-details-marker { display: none; }
.schedule-display-filters-summary { user-select: none; }
.schedule-display-filters-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 1rem;
  margin-top: 0.75rem;
}
.schedule-display-toggles {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem 1rem;
  margin-top: 0.75rem;
}
.schedule-display-toggles .schedule-filter-cb {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.35rem 0.5rem;
  background: var(--hover-overlay);
}
.schedule-filter-group-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  margin-bottom: 0.35rem;
}
.schedule-filter-group-label { font-size: 0.9rem; font-weight: 600; display: inline-flex; align-items: center; gap: 0.45rem; }
.schedule-filter-group-label::before {
  content: "";
  width: 1.02rem;
  height: 1.02rem;
  flex-shrink: 0;
  display: inline-block;
  background-color: var(--text-muted);
  mask-size: contain;
  mask-position: center;
  mask-repeat: no-repeat;
  -webkit-mask-size: contain;
  -webkit-mask-position: center;
  -webkit-mask-repeat: no-repeat;
}
.schedule-filter-group-label--type::before {
  background-color: #3f78ea;
  mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='black'%3E%3Cpath d='M10 4V2h4v2h5a2 2 0 0 1 2 2v4H3V6a2 2 0 0 1 2-2h5zm11 8v8a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-8h18z'/%3E%3C/svg%3E");
  -webkit-mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='black'%3E%3Cpath d='M10 4V2h4v2h5a2 2 0 0 1 2 2v4H3V6a2 2 0 0 1 2-2h5zm11 8v8a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-8h18z'/%3E%3C/svg%3E");
}
.schedule-filter-group-label--trainer::before {
  background-color: #e0586a;
  mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='black'%3E%3Cpath d='M12 12a5 5 0 1 0 0-10 5 5 0 0 0 0 10zm0 2c-4.42 0-8 2.24-8 5v3h16v-3c0-2.76-3.58-5-8-5z'/%3E%3C/svg%3E");
  -webkit-mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='black'%3E%3Cpath d='M12 12a5 5 0 1 0 0-10 5 5 0 0 0 0 10zm0 2c-4.42 0-8 2.24-8 5v3h16v-3c0-2.76-3.58-5-8-5z'/%3E%3C/svg%3E");
}
.schedule-filter-group-label--service::before {
  background-color: #22a987;
  mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='black'%3E%3Cpath d='M10 4V2h4v2h5a2 2 0 0 1 2 2v4H3V6a2 2 0 0 1 2-2h5zm11 8v8a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-8h18z'/%3E%3C/svg%3E");
  -webkit-mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='black'%3E%3Cpath d='M10 4V2h4v2h5a2 2 0 0 1 2 2v4H3V6a2 2 0 0 1 2-2h5zm11 8v8a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-8h18z'/%3E%3C/svg%3E");
}
.schedule-filter-group-actions { display: flex; flex-wrap: wrap; gap: 0.35rem; }
.schedule-filter-checkboxes {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  max-height: 11rem;
  overflow-y: auto;
  padding: 0.35rem 0.25rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg);
  font-size: 0.88rem;
}
.schedule-filter-cb { display: flex; align-items: flex-start; gap: 0.35rem; cursor: pointer; }
.schedule-filter-cb input { margin-top: 0.2rem; flex-shrink: 0; }
.schedule-filter-cb-text {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  line-height: 1.25;
}
.schedule-filter-cb-text::before {
  content: "";
  width: 0.86rem;
  height: 0.86rem;
  flex-shrink: 0;
  display: inline-block;
  background-color: #64748b;
  mask-size: contain;
  mask-position: center;
  mask-repeat: no-repeat;
  -webkit-mask-size: contain;
  -webkit-mask-position: center;
  -webkit-mask-repeat: no-repeat;
  mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='black'%3E%3Cpath d='M19 6h-2V5a2 2 0 1 0-4 0v1H9V5a2 2 0 1 0-4 0v1H3v15h18V6zM7 5a1 1 0 1 1 2 0v1H7V5zm8 0a1 1 0 1 1 2 0v1h-2V5zm4 14H5V8h14v11z'/%3E%3C/svg%3E");
  -webkit-mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='black'%3E%3Cpath d='M19 6h-2V5a2 2 0 1 0-4 0v1H9V5a2 2 0 1 0-4 0v1H3v15h18V6zM7 5a1 1 0 1 1 2 0v1H7V5zm8 0a1 1 0 1 1 2 0v1h-2V5zm4 14H5V8h14v11z'/%3E%3C/svg%3E");
}
.schedule-filter-cb--booked .schedule-filter-cb-text::before {
  background-color: #4d73e6;
  mask-image: url(\"data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='black'%3E%3Cpath d='M9 16.2 5.8 13l1.4-1.4L9 13.4l7.6-7.6L18 7.2 9 16.2z'/%3E%3C/svg%3E\");
  -webkit-mask-image: url(\"data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='black'%3E%3Cpath d='M9 16.2 5.8 13l1.4-1.4L9 13.4l7.6-7.6L18 7.2 9 16.2z'/%3E%3C/svg%3E\");
}
.schedule-filter-cb-text--type::before {
  background-color: #4d73e6;
  mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='black'%3E%3Cpath d='M10 4V2h4v2h5a2 2 0 0 1 2 2v4H3V6a2 2 0 0 1 2-2h5zm11 8v8a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-8h18z'/%3E%3C/svg%3E");
  -webkit-mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='black'%3E%3Cpath d='M10 4V2h4v2h5a2 2 0 0 1 2 2v4H3V6a2 2 0 0 1 2-2h5zm11 8v8a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-8h18z'/%3E%3C/svg%3E");
}
.schedule-filter-cb--trainer-hours .schedule-filter-cb-text::before,
.schedule-filter-cb-text--trainer::before {
  background-color: #e86c62;
  mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='black'%3E%3Cpath d='M12 12a5 5 0 1 0 0-10 5 5 0 0 0 0 10zm0 2c-4.42 0-8 2.24-8 5v3h16v-3c0-2.76-3.58-5-8-5z'/%3E%3C/svg%3E");
  -webkit-mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='black'%3E%3Cpath d='M12 12a5 5 0 1 0 0-10 5 5 0 0 0 0 10zm0 2c-4.42 0-8 2.24-8 5v3h16v-3c0-2.76-3.58-5-8-5z'/%3E%3C/svg%3E");
}
.schedule-filter-cb--service-hours .schedule-filter-cb-text::before,
.schedule-filter-cb-text--service::before {
  background-color: #24aa88;
  mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='black'%3E%3Cpath d='M10 4V2h4v2h5a2 2 0 0 1 2 2v4H3V6a2 2 0 0 1 2-2h5zm11 8v8a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-8h18z'/%3E%3C/svg%3E");
  -webkit-mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='black'%3E%3Cpath d='M10 4V2h4v2h5a2 2 0 0 1 2 2v4H3V6a2 2 0 0 1 2-2h5zm11 8v8a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-8h18z'/%3E%3C/svg%3E");
}
.schedule-filter-hint { margin: 0.75rem 0 0; font-size: 0.82rem; }

/* Schedule: week grid */
.schedule-week-wrap {
  overflow-x: auto;
  margin-top: 0.5rem;
}
.schedule-week-grid {
  display: grid;
  grid-template-columns: minmax(52px, max-content) repeat(7, minmax(100px, 1fr));
  grid-auto-rows: 28px;
  min-width: 700px;
  min-height: 400px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  position: relative;
}
.schedule-week-grid .grid-corner { grid-column: 1; grid-row: 1; border-right: 1px solid var(--border); border-bottom: 1px solid var(--border); }
.schedule-week-grid .grid-time {
  grid-column: 1;
  padding: 2px 6px;
  font-size: 0.75rem;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border);
  align-self: stretch;
  white-space: nowrap;
}
.schedule-week-grid .grid-day {
  padding: 6px 4px;
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-muted);
  text-align: center;
  border-bottom: 1px solid var(--border);
  border-right: 1px solid var(--border);
}
.schedule-week-grid .grid-day:last-of-type { border-right: none; }
.schedule-week-grid .grid-cell {
  border-bottom: 1px solid var(--border);
  border-right: 1px solid var(--border);
  min-height: 28px;
  cursor: pointer;
  transition: background 0.15s;
}
.schedule-week-grid .grid-cell:hover { background: rgba(59, 130, 246, 0.12); }
.schedule-week-grid .grid-cell:last-of-type { border-right: none; }
.schedule-week-grid .grid-cell.schedule-non-working-day,
.schedule-week-grid .grid-day.schedule-non-working-day { background: var(--hover-overlay); opacity: 0.85; cursor: default; }
.schedule-week-grid .grid-cell.schedule-outside-hours,
.schedule-week-grid .grid-time.schedule-outside-hours { background: var(--hover-overlay); opacity: 0.65; }
.schedule-week-grid .grid-cell.schedule-non-working-day:hover,
.schedule-week-grid .grid-cell.schedule-outside-hours:hover { background: var(--hover-overlay); }
.schedule-week-grid .schedule-now-line {
  position: absolute;
  left: 0;
  right: 0;
  height: 3px;
  background: rgba(220, 38, 38, 0.82);
  box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.38), 0 0 10px rgba(220, 38, 38, 0.24);
  z-index: 12;
  pointer-events: none;
}
.schedule-week-grid .schedule-now-label {
  position: absolute;
  left: 4px;
  transform: translateY(-50%);
  min-width: 54px;
  padding: 2px 8px;
  border-radius: 8px;
  background: #1f2937;
  color: #fff;
  font-size: 0.85rem;
  font-weight: 700;
  line-height: 1.1;
  letter-spacing: 0.01em;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.22);
  z-index: 13;
  pointer-events: none;
}
[data-theme="dark"] .schedule-week-grid .schedule-now-line {
  background: rgba(248, 113, 113, 0.88);
}
[data-theme="dark"] .schedule-week-grid .schedule-now-label {
  background: #0f172a;
  color: #e5e7eb;
}
.schedule-week-grid .schedule-slot-block {
  grid-column: span 1;
  margin: 2px 3px;
  padding: 0;
  border-radius: 6px;
  font-size: 0.8rem;
  line-height: 1.25;
  cursor: pointer;
  overflow: visible;
  background: color-mix(in srgb, var(--slot-bg, var(--accent)) 50%, transparent);
  color: #fff;
  border-width: 3px;
  border-style: solid;
  border-color: var(--slot-border, rgba(255,255,255,0.10));
  transition: opacity 0.15s;
  box-sizing: border-box;
  min-width: 0;
  position: relative;
  touch-action: none;
}
.schedule-week-grid .schedule-slot-block.schedule-slot-block--multi-lane {
  /* Multi-lane width/offset formula assumes no horizontal margins */
  margin-left: 0;
  margin-right: 0;
}
/* Слой графика YC (смена) под слотами записей: не перехватывает клики */
.schedule-week-grid .schedule-slot-block.schedule-yc-shift-layer {
  opacity: 0.42;
  z-index: 1;
  pointer-events: none;
  cursor: default;
}
.schedule-week-grid .schedule-slot-block.schedule-workhours-layer {
  opacity: 0.24;
  z-index: 1;
  pointer-events: none;
  cursor: default;
  border-style: dashed;
}
.schedule-week-grid .schedule-slot-block.schedule-workhours-layer--trainer {
  opacity: 1;
  background: rgba(34, 197, 94, 0.14);
  border-color: rgba(34, 197, 94, 0.9);
  color: rgba(17, 24, 39, 0.85);
}
.schedule-week-grid .schedule-slot-block.schedule-workhours-layer--service {
  background: rgba(59, 130, 246, 0.16);
  border-color: rgba(59, 130, 246, 0.35);
  color: rgba(17, 24, 39, 0.85);
}
.schedule-week-grid .schedule-slot-block:not(.schedule-yc-shift-layer) {
  z-index: 2;
}
.schedule-week-grid .schedule-slot-block--custom-colors {
  color: var(--text);
}
.schedule-week-grid .schedule-slot-block--custom-colors .slot-service,
.schedule-week-grid .schedule-slot-block--custom-colors .slot-trainer,
.schedule-week-grid .schedule-slot-block--custom-colors .slot-capacity { color: inherit; }
.schedule-week-grid .schedule-slot-block--dragging {
  opacity: 0.32;
  z-index: 5;
}
/* Предпросмотр места слота при перетаскивании / растягивании */
.schedule-slot-drag-preview {
  position: fixed;
  z-index: 10050;
  pointer-events: none;
  box-sizing: border-box;
  border-radius: 6px;
  border-width: 3px;
  border-style: dashed;
  border-color: var(--slot-border, var(--accent));
  background: var(--slot-bg, rgba(59, 130, 246, 0.10));
  box-shadow:
    0 0 0 1px rgba(255, 255, 255, 0.35) inset,
    0 4px 20px rgba(59, 130, 246, 0.25);
  transition:
    left 0.13s cubic-bezier(0.25, 0.8, 0.25, 1),
    top 0.13s cubic-bezier(0.25, 0.8, 0.25, 1),
    width 0.13s cubic-bezier(0.25, 0.8, 0.25, 1),
    height 0.13s cubic-bezier(0.25, 0.8, 0.25, 1),
    border-color 0.15s ease,
    background 0.15s ease;
}
.schedule-slot-drag-preview--invalid {
  border-color: var(--danger);
  background: rgba(239, 68, 68, 0.14);
  box-shadow:
    0 0 0 1px rgba(255, 255, 255, 0.25) inset,
    0 4px 16px rgba(239, 68, 68, 0.2);
}
.schedule-slot-drag-preview__time {
  position: absolute;
  left: 5px;
  top: 3px;
  right: 4px;
  font-size: 0.68rem;
  font-weight: 700;
  line-height: 1.2;
  color: var(--accent);
  text-shadow: 0 0 6px #fff, 0 0 4px #fff, 0 1px 0 #fff;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.schedule-slot-drag-preview--invalid .schedule-slot-drag-preview__time {
  color: var(--danger);
}
[data-theme="dark"] .schedule-slot-drag-preview__time {
  text-shadow: 0 0 8px #0f1419, 0 1px 2px #0f1419;
}
[data-theme="dark"] .schedule-slot-drag-preview--invalid .schedule-slot-drag-preview__time {
  text-shadow: 0 0 8px #0f1419;
}
.schedule-week-grid .schedule-slot-body {
  height: 100%;
  min-height: 100%;
  cursor: grab;
  overflow: hidden;
  padding: 4px 6px;
  border-radius: 5px;
  box-sizing: border-box;
}
.schedule-week-grid .schedule-slot-block--dragging .schedule-slot-body {
  cursor: grabbing;
}
.schedule-slot-resize {
  position: absolute;
  z-index: 4;
  box-sizing: border-box;
}
.schedule-slot-resize-n {
  top: 0;
  left: 12%;
  right: 12%;
  height: 8px;
  cursor: ns-resize;
  margin-top: -2px;
}
.schedule-slot-resize-s {
  bottom: 0;
  left: 12%;
  right: 12%;
  height: 8px;
  cursor: ns-resize;
  margin-bottom: -2px;
}
.schedule-slot-resize-w {
  left: 0;
  top: 6px;
  bottom: 6px;
  width: 10px;
  cursor: ew-resize;
  margin-left: -2px;
}
.schedule-slot-resize-e {
  right: 0;
  top: 6px;
  bottom: 6px;
  width: 10px;
  cursor: ew-resize;
  margin-right: -2px;
}
.modal-actions--wrap {
  flex-wrap: wrap;
  gap: 0.5rem;
  justify-content: flex-end;
}
.schedule-recurring-geometry-list {
  margin: 0.75rem 0;
  padding-left: 1.25rem;
  font-size: 0.9rem;
  line-height: 1.45;
}
/* Пересекающиеся по времени слоты в один день — в одну колонку слева/справа, без перекрытия */
.schedule-week-grid .schedule-slot-block--multi-lane {
  /* По умолчанию grid-item тянется на всю ширину ячейки; тогда width/max-width ниже не действуют и слоты снова накладываются. */
  justify-self: start;
  width: calc((100% - (var(--schedule-max-lanes) + 1) * 2px) / var(--schedule-max-lanes));
  margin-right: 0;
  margin-left: calc(2px + var(--schedule-lane, 0) * ((100% - (var(--schedule-max-lanes) + 1) * 2px) / var(--schedule-max-lanes) + 2px));
  max-width: calc((100% - (var(--schedule-max-lanes) + 1) * 2px) / var(--schedule-max-lanes));
}
.schedule-week-grid .schedule-slot-block:hover { opacity: 0.9; }

/* Подробный тултип при наведении на слот в сетке недели */
.schedule-slot-tooltip-popup {
  position: fixed;
  z-index: 10040;
  max-width: 320px;
  padding: 10px 12px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-card);
  font-size: 0.8rem;
  line-height: 1.4;
  pointer-events: none;
}
.schedule-slot-tooltip-popup.hidden {
  display: none !important;
}
.schedule-slot-tooltip__row {
  margin-bottom: 0.25rem;
}
.schedule-slot-tooltip__hint {
  margin-bottom: 0.5rem;
  padding-bottom: 0.5rem;
  border-bottom: 1px solid var(--border);
  font-size: 0.75rem;
  color: var(--text-muted);
  line-height: 1.35;
}
.schedule-slot-tooltip__row:last-child { margin-bottom: 0; }
.schedule-slot-tooltip__label {
  color: var(--text-muted);
  margin-right: 0.35rem;
}
.schedule-slot-tooltip__value {
  color: var(--text);
}
.schedule-week-grid .schedule-slot-block.slot-unavailable { background: var(--text-muted); }
.schedule-week-grid .schedule-slot-block .slot-service { font-weight: 600; }
.schedule-week-grid .schedule-slot-block .slot-trainer { font-size: 0.7rem; opacity: 0.9; }
.schedule-week-grid .schedule-slot-block .slot-field-label {
  font-size: 0.66rem;
  font-weight: 700;
  letter-spacing: 0.01em;
  color: rgba(255, 255, 255, 0.88);
}
.schedule-week-grid .schedule-slot-block .slot-service--with-icon {
  display: inline;
  white-space: normal;
  overflow-wrap: anywhere;
  word-break: break-word;
}
.schedule-week-grid .schedule-slot-block .slot-type--with-icon {
  display: inline-flex;
  align-items: center;
  margin-right: 0.28rem;
  vertical-align: middle;
}
.schedule-week-grid .schedule-slot-block .slot-type--with-icon::before {
  content: "";
  width: 0.62rem;
  height: 0.62rem;
  flex-shrink: 0;
  display: inline-block;
  background-color: #3f78ea;
  mask-size: contain;
  mask-position: center;
  mask-repeat: no-repeat;
  -webkit-mask-size: contain;
  -webkit-mask-position: center;
  -webkit-mask-repeat: no-repeat;
  mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='black'%3E%3Cpath d='M10 4V2h4v2h5a2 2 0 0 1 2 2v4H3V6a2 2 0 0 1 2-2h5zm11 8v8a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-8h18z'/%3E%3C/svg%3E");
  -webkit-mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='black'%3E%3Cpath d='M10 4V2h4v2h5a2 2 0 0 1 2 2v4H3V6a2 2 0 0 1 2-2h5zm11 8v8a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-8h18z'/%3E%3C/svg%3E");
}
.schedule-week-grid .schedule-slot-block .slot-service--with-icon::before {
  content: "";
  width: 0.62rem;
  height: 0.62rem;
  border-radius: 0.16rem;
  flex-shrink: 0;
  display: inline-block;
  background: linear-gradient(135deg, #2acb87, #11a7bc);
  box-shadow: 0 0 0 1px rgba(20, 28, 45, 0.14) inset;
  margin-right: 0.28rem;
  vertical-align: baseline;
}
.schedule-week-grid .schedule-slot-block .slot-service--with-icon.slot-service--personal::before {
  background-color: #facc15;
  background-image: none;
  box-shadow: 0 0 0 1px rgba(15, 23, 42, 0.28) inset, 0 0 0 1px rgba(255, 255, 255, 0.28);
  mask-size: 82%;
  mask-position: center;
  mask-repeat: no-repeat;
  -webkit-mask-size: 82%;
  -webkit-mask-position: center;
  -webkit-mask-repeat: no-repeat;
  mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='black'%3E%3Cpath d='m12 2 2.7 5.47 6.03.88-4.36 4.25 1.03 6.01L12 15.77l-5.4 2.84 1.03-6.01L3.27 8.35l6.03-.88L12 2z'/%3E%3C/svg%3E");
  -webkit-mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='black'%3E%3Cpath d='m12 2 2.7 5.47 6.03.88-4.36 4.25 1.03 6.01L12 15.77l-5.4 2.84 1.03-6.01L3.27 8.35l6.03-.88L12 2z'/%3E%3C/svg%3E");
}
.schedule-week-grid .schedule-slot-block .slot-trainer--with-icon {
  display: inline-flex;
  align-items: center;
  gap: 0.28rem;
}
.schedule-week-grid .schedule-slot-block .slot-trainer--with-icon::before {
  content: "";
  width: 0.62rem;
  height: 0.62rem;
  border-radius: 50%;
  flex-shrink: 0;
  display: inline-block;
  background: linear-gradient(135deg, #ff8f5e, #ff5d87);
}
.schedule-week-grid .schedule-slot-block .slot-duration {
  font-size: 0.68rem;
  opacity: 0.92;
}
.schedule-week-grid .schedule-slot-block .slot-duration--with-icon {
  display: inline-flex;
  align-items: center;
  gap: 0.26rem;
}
.schedule-week-grid .schedule-slot-block .slot-duration--with-icon::before {
  content: "";
  width: 0.58rem;
  height: 0.58rem;
  flex-shrink: 0;
  display: inline-block;
  background-color: rgba(255, 255, 255, 0.92);
  mask-size: contain;
  mask-position: center;
  mask-repeat: no-repeat;
  -webkit-mask-size: contain;
  -webkit-mask-position: center;
  -webkit-mask-repeat: no-repeat;
  mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='black'%3E%3Cpath d='M12 1a11 11 0 1 0 11 11A11 11 0 0 0 12 1zm1 11.59V6h-2v7h6v-2z'/%3E%3C/svg%3E");
  -webkit-mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='black'%3E%3Cpath d='M12 1a11 11 0 1 0 11 11A11 11 0 0 0 12 1zm1 11.59V6h-2v7h6v-2z'/%3E%3C/svg%3E");
}
.schedule-week-grid .schedule-slot-block .slot-capacity {
  font-size: 0.68rem;
  font-weight: 500;
  opacity: 0.92;
  display: inline-block;
  margin-top: 1px;
}
.schedule-week-grid .schedule-slot-block .slot-capacity--full {
  font-weight: 800;
  opacity: 1;
  letter-spacing: 0.02em;
}
.schedule-week-grid .schedule-slot-block.slot-unavailable .slot-capacity { opacity: 0.85; }
.slot-form .form-row { margin-bottom: 0.75rem; }
.slot-form .form-row:last-of-type { margin-bottom: 0; }
.form-weekdays-label { margin-right: 0.5rem; color: var(--text-muted); }

/* Расписание — карточка «Настройки расписания» */
#schedule-settings-card {
  min-width: 0;
  max-width: 100%;
  box-sizing: border-box;
}
#schedule-settings-card .schedule-settings-weekdays-row {
  align-items: flex-start;
}
#schedule-settings-card .schedule-settings-workhours-label {
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
  width: 100%;
}
#schedule-settings-card .schedule-settings-workhours-inputs {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.65rem 1.25rem;
}
#schedule-settings-card .schedule-settings-workhours-inputs label {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  flex: 0 1 auto;
}
#schedule-settings-card .schedule-settings-workhours-inputs input[type="time"] {
  min-width: 7.25rem;
}
#schedule-settings-card .schedule-settings-actions-row {
  align-items: flex-end;
}

/* Widget secrets list */
.widget-secrets-list { margin-bottom: 1rem; }
.widget-secret-row { margin-bottom: 0.75rem; }
.widget-secret-row .widget-secret-desc { min-width: 180px; }
.widget-secret-row .widget-secret-key { min-width: 200px; font-family: ui-monospace, monospace; }

/* Widget embed code */
.widget-embed-code {
  margin: 0;
  padding: 0.85rem 1rem;
  font-family: ui-monospace, 'Cascadia Code', 'Source Code Pro', Menlo, monospace;
  font-size: 0.875rem;
  line-height: 1.4;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  overflow-x: auto;
  user-select: all;
}

.widget-embed-block {
  margin-bottom: 1rem;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem;
}
.widget-embed-block .widget-embed-code { flex: 1; min-width: 200px; }
.widget-embed-block .btn { flex-shrink: 0; }

/* Inline hint under embed code */
.hint-inline {
  margin-top: 0.75rem;
  margin-bottom: 0;
  font-size: 0.875rem;
}

/* CORS hint for widget */
.widget-cors-hint {
  border-left: 3px solid var(--accent);
}
.widget-cors-hint h3::before {
  content: "ℹ ";
  opacity: 0.9;
}
.widget-cors-hint .hint-list {
  margin: 0.75rem 0 0;
  padding-left: 1.25rem;
  color: var(--text-muted);
  font-size: 0.9rem;
  line-height: 1.6;
}
.widget-cors-hint .hint-list li { margin-bottom: 0.5rem; }
.widget-cors-hint .hint-list li:last-child { margin-bottom: 0; }
.widget-cors-hint code {
  font-family: ui-monospace, 'Cascadia Code', Menlo, monospace;
  font-size: 0.85em;
  padding: 0.15em 0.4em;
  background: var(--bg);
  border-radius: 4px;
  color: var(--accent);
}

/* Superadmin impersonation */
.widget-cors-hint-pre {
  margin: 0.5rem 0 0;
  padding: 0.85rem 1rem;
  font-family: ui-monospace, 'Cascadia Code', Menlo, monospace;
  font-size: 0.8rem;
  line-height: 1.4;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text-muted);
  overflow-x: auto;
  white-space: pre;
}

/* Ссылки на домене виджетов: Запись и Тренеры — отдельными блоками друг под другом */
.widget-mobile-domain-section {
  display: block;
  margin-bottom: 1rem;
}
.widget-mobile-domain-section:last-child {
  margin-bottom: 0;
}
.widget-mobile-domain-label {
  display: block;
  font-weight: 600;
  margin-bottom: 0.25rem;
}

/* Блоки суперадмина: скрыты по умолчанию, видны только при .role-superadmin на app-screen */
.superadmin-only { display: none !important; }
.role-superadmin .superadmin-only { display: block !important; }
.superadmin-impersonate { margin-top: 1rem; border-left: 3px solid var(--accent); }
.superadmin-impersonate .org-list { list-style: none; margin: 0.75rem 0 0; padding: 0; }
.superadmin-impersonate .org-list li { margin-bottom: 0.5rem; }
.superadmin-impersonate .org-list li:last-child { margin-bottom: 0; }

.widget-superadmin-org-list .org-list { list-style: none; margin: 0.75rem 0 0; padding: 0; }
.widget-superadmin-org-list .org-list li { margin-bottom: 0.75rem; display: flex; align-items: center; flex-wrap: wrap; gap: 0.5rem; }
.widget-superadmin-org-list .org-list li:last-child { margin-bottom: 0; }
.widget-superadmin-org-list .org-list-name { font-weight: 500; }

/* Модальное окно «Посмотреть виджет» — виджет в рамке телефона */
.widget-phone-modal {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}
.widget-phone-modal.hidden { display: none !important; }
.widget-phone-modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.65);
  cursor: pointer;
}
.widget-phone-frame {
  position: relative;
  width: 320px;
  height: 640px;
  max-width: calc(100vw - 2rem);
  max-height: calc(100vh - 2rem);
  background: #1a1a1a;
  border-radius: 36px;
  padding: 12px;
  box-shadow: 0 25px 80px rgba(0, 0, 0, 0.5), 0 0 0 3px #2d2d2d, inset 0 0 0 2px rgba(255,255,255,0.05);
}
.widget-phone-notch {
  position: absolute;
  top: 12px;
  left: 50%;
  transform: translateX(-50%);
  width: 100px;
  height: 24px;
  background: #0a0a0a;
  border-radius: 0 0 16px 16px;
  z-index: 1;
}
.widget-phone-screen {
  width: 100%;
  height: 100%;
  background: #fff;
  border-radius: 24px;
  overflow: hidden;
  position: relative;
}
.widget-phone-screen iframe {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  border: none;
}
.widget-phone-close {
  position: absolute;
  top: -12px;
  right: -12px;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: 2px solid var(--border);
  background: var(--bg-card);
  color: var(--text);
  font-size: 1.5rem;
  line-height: 1;
  cursor: pointer;
  z-index: 2;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  transition: background 0.15s, color 0.15s;
}
.widget-phone-close:hover {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}

.superadmin-create-org { margin-top: 1rem; }
.superadmin-create-org .form-row { margin-bottom: 0.75rem; }

/* ——— Кнопка меню: всегда в шапке (липкая); на мобильном — выезд сайдбара ——— */
.sidebar-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  padding: 0;
  margin: 0 0.5rem 0 0;
  background: transparent;
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text);
  cursor: pointer;
  flex-shrink: 0;
}

@media (min-width: 769px) {
  #app-screen.sidebar-collapsed .sidebar {
    width: 0 !important;
    min-width: 0;
    flex-basis: 0;
    flex-shrink: 1;
    padding: 0;
    overflow: hidden;
    opacity: 0;
    border-right-width: 0;
    pointer-events: none;
  }
}
.sidebar-toggle:hover { background: var(--hover-overlay); }
.sidebar-toggle-icon {
  display: block;
  width: 20px;
  height: 2px;
  background: currentColor;
  box-shadow: 0 -6px 0 currentColor, 0 6px 0 currentColor;
}

.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  z-index: 100;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease;
}

/* ——— Mobile breakpoint ——— */
@media (max-width: 768px) {
  body.sidebar-open { overflow: hidden; }

  .sidebar-overlay {
    display: block;
  }
  #app-screen.sidebar-open .sidebar-overlay {
    opacity: 1;
    pointer-events: auto;
  }

  .sidebar {
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    width: 280px;
    max-width: 85vw;
    z-index: 101;
    transform: translateX(-100%);
    transition: transform 0.25s ease;
    box-shadow: none;
  }
  #app-screen.sidebar-open .sidebar {
    transform: translateX(0);
    box-shadow: 4px 0 20px rgba(0, 0, 0, 0.4);
  }

  .main { min-width: 0; }
  .main-header {
    padding: 0.75rem 1rem;
    gap: 0.5rem;
  }
  .main-header h2 { font-size: 1.1rem; }
  .user-info { font-size: 0.8rem; max-width: 50%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

  .page-content { padding: 1rem; }
  .admin-version-badge {
    right: 10px;
    bottom: 8px;
    font-size: 0.7rem;
  }

  .card { padding: 1rem; margin-bottom: 1rem; }
  .card h3 { font-size: 1rem; margin-bottom: 0.75rem; }

  /* Forms: stack vertically, full-width inputs */
  .form-row {
    flex-direction: column;
    align-items: stretch;
    gap: 0.75rem;
    margin-bottom: 0.75rem;
  }
  .form-row label {
    flex-direction: column;
    align-items: stretch;
    gap: 0.35rem;
  }
  .form-row label input,
  .form-row label select,
  .form-row label textarea { width: 100%; min-width: 0; }
  .form-row label.checkbox-inline {
    flex-direction: row;
    align-items: center;
    gap: 0.5rem;
  }
  .form-row label.checkbox-inline input {
    width: auto;
    min-width: auto;
    flex: 0 0 auto;
  }
  .form-row .btn { width: 100%; min-height: 44px; }
  .form-weekdays-label { margin-bottom: 0.25rem; }
  /* Расписание: настройки — дни недели в сетке, время на всю ширину */
  #schedule-settings-card .schedule-settings-weekdays-row {
    flex-direction: row;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.35rem 0.55rem;
  }
  #schedule-settings-card .schedule-settings-weekdays-row > .form-weekdays-label {
    flex: 1 1 100%;
    width: 100%;
    margin-right: 0;
    margin-bottom: 0.2rem;
  }
  #schedule-settings-card .schedule-settings-weekdays-row > label {
    flex-direction: row;
    align-items: center;
    flex: 0 0 auto;
  }
  #schedule-settings-card .schedule-settings-workhours-inputs {
    flex-direction: column;
    align-items: stretch;
    gap: 0.5rem;
    width: 100%;
  }
  #schedule-settings-card .schedule-settings-workhours-inputs label {
    flex-direction: row;
    justify-content: space-between;
    width: 100%;
    gap: 0.5rem;
  }
  #schedule-settings-card .schedule-settings-workhours-inputs input[type="time"] {
    min-width: 0;
    flex: 1 1 auto;
    width: auto;
    max-width: 100%;
    min-height: 44px;
  }
  #schedule-settings-card .schedule-settings-actions-row label {
    width: 100%;
  }
  .form-row#slot-form-weekdays-row { flex-direction: row; flex-wrap: wrap; }
  .widget-promo-fieldset .form-row .checkbox-inline { display: flex; margin-bottom: 0.25rem; }

  /* Schedule toolbar: stack */
  .schedule-toolbar {
    flex-direction: column;
    align-items: stretch;
    gap: 0.75rem;
  }
  .schedule-view-toggle { display: flex; gap: 0.25rem; }
  .schedule-view-toggle .schedule-view-btn { flex: 1; min-height: 40px; }
  .schedule-controls {
    flex-wrap: wrap;
    gap: 0.5rem;
  }
  .schedule-controls label { flex: 1 1 auto; min-width: 120px; }
  .schedule-week-label { min-width: 0; }
  .schedule-week-wrap { margin-top: 0.5rem; -webkit-overflow-scrolling: touch; }
  .schedule-week-grid {
    min-width: 600px;
    font-size: 0.7rem;
  }
  .schedule-week-grid .schedule-slot-block { font-size: 0.7rem; }
  .schedule-week-grid .schedule-slot-body { padding: 3px 4px; }
  .schedule-week-grid .grid-time { padding: 2px 4px; }

  /* Tables: keep horizontal scroll, larger touch targets */
  .table-wrap { -webkit-overflow-scrolling: touch; margin: 0 -0.5rem; padding: 0 0.5rem; }
  .table-wrap table { font-size: 0.85rem; }
  .table-wrap th,
  .table-wrap td { padding: 0.5rem 0.5rem; }
  .table-wrap .btn-sm { min-height: 36px; padding: 0.4rem 0.6rem; }

  .btn, .btn-primary, .btn-secondary { min-height: 44px; }
  .login-card { padding: 1.5rem; margin: 0 0.5rem; }
  .form-inline { flex-direction: column; align-items: stretch; }
  .form-inline label { width: 100%; min-width: 0; flex-direction: column; align-items: stretch; }
  .form-inline input { min-width: 0; width: 100%; }
  .form-inline .btn { width: 100%; }
}

/* Modal overlay */
.modal {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.5);
  padding: 1rem;
}
.modal.hidden { display: none !important; }
.modal .modal-content { max-width: 520px; width: 100%; max-height: 90vh; overflow-y: auto; }
.modal .modal-content.audit-payment-detail-content {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.25);
}
.audit-payments-summary {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(230px, 1fr));
  gap: 0.75rem;
  margin-bottom: 0.85rem;
}
.audit-payments-summary-card {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg-card);
  padding: 0.65rem 0.75rem;
}
.audit-payments-summary-value {
  margin-top: 0.25rem;
  font-size: 1.15rem;
  font-weight: 700;
}
.tariffs-contact-manager-form textarea {
  width: 100%;
  min-width: 0;
  box-sizing: border-box;
  resize: vertical;
}

/* Crop modal — редактор фото при загрузке (z-index выше остальных модалок) */
.crop-modal {
  position: fixed;
  inset: 0;
  z-index: 99999;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  box-sizing: border-box;
}
.crop-modal.hidden { display: none !important; visibility: hidden !important; pointer-events: none !important; }
.crop-modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.65);
}
.crop-modal-content {
  position: relative;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem;
  max-width: 90vw;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.4);
}
.crop-modal-title {
  margin: 0 0 0.5rem;
  font-size: 1.15rem;
}
.crop-modal-hint {
  margin: 0 0 1rem;
  color: var(--text-muted);
  font-size: 0.9rem;
}
.crop-modal-meta {
  margin: 0 0 0.5rem;
  color: var(--text-muted);
  font-size: 0.9rem;
}
.crop-modal-ratio-hint,
.crop-modal-size-hint { display: block; }
.crop-modal-src-size {
  margin: 0 0 1rem;
  color: var(--text-muted);
  font-size: 0.85rem;
}
.crop-modal-body {
  flex: 1;
  min-height: 0;
  margin-bottom: 1rem;
}
.crop-container {
  width: 100%;
  max-width: 560px;
  height: 360px;
  margin: 0 auto;
  background: #111;
  overflow: hidden;
  position: relative;
}
.crop-container img {
  display: block;
  max-width: 100%;
  max-height: 100%;
}
/* Рамка кадрирования как в виджете (скругление 10px у блока «Об организации») */
.crop-container .cropper-crop-box {
  border-radius: 10px;
}
.crop-container .crop-loading {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
  font-size: 0.95rem;
}
.crop-container.crop-ready .crop-loading { display: none; }
.crop-modal-footer {
  display: flex;
  gap: 0.75rem;
  justify-content: flex-end;
  flex-shrink: 0;
}
@media (max-width: 600px) {
  .crop-container { height: 280px; }
}

/* Small phones */
@media (max-width: 480px) {
  .main-header h2 { font-size: 1rem; }
  .user-info { max-width: 40%; }
  .sidebar { width: 260px; max-width: 90vw; }
}

/* YC sync: конфликты — суть + раскрываемый JSON */
#content-yc-sync-conflicts .yc-sync-conflicts-table { width: 100%; table-layout: fixed; }
#content-yc-sync-conflicts .yc-sync-conflict-summary { max-width: 36rem; vertical-align: top; word-break: break-word; }
#content-yc-sync-conflicts .yc-sync-conflict-json { margin-top: 0.35rem; }
#content-yc-sync-conflicts .yc-sync-conflict-json pre {
  max-height: 14rem;
  overflow: auto;
  font-size: 0.75rem;
  margin: 0.35rem 0 0;
  padding: 0.5rem;
  background: var(--bg-muted, #f5f5f5);
  border-radius: 4px;
}

/* YC sync: строки лога кликабельны для открытия деталей */
#content-yc-sync-log .yc-sync-log-row { cursor: pointer; }
#content-yc-sync-log .yc-sync-log-row:hover td { background: var(--hover-overlay); }

/* Воронка продаж: канбан */
#content-sales-funnel .sales-funnel-board {
  width: 100%;
  max-width: 100%;
  overflow-x: auto;
  overflow-y: visible;
  -webkit-overflow-scrolling: touch;
  padding-bottom: 0.35rem;
  margin-top: 0.5rem;
}
.sales-funnel-board-inner {
  display: flex;
  flex-wrap: nowrap;
  gap: 0.75rem;
  min-width: min-content;
  padding-bottom: 0.25rem;
  margin-top: 0.25rem;
}
.sales-funnel-col {
  flex: 0 0 220px;
  min-width: 200px;
  min-height: 120px;
  background: var(--bg-muted, #f0f0f0);
  border-radius: 8px;
  padding: 0.5rem;
}
[data-theme="dark"] .sales-funnel-col {
  background: var(--bg-muted, #2a2a2a);
}
.sales-funnel-stages-editor {
  margin-bottom: 0.75rem;
}
.sales-funnel-stages-editor .sales-funnel-stages-card {
  padding: 0.75rem 1rem;
  border: 1px solid var(--border-color, #ddd);
  border-radius: 8px;
  background: var(--bg-muted, #fafafa);
}
.sales-funnel-stages-editor h4 {
  margin: 0 0 0.35rem;
  font-size: 1rem;
}
.sales-funnel-stages-table {
  width: 100%;
  max-width: 52rem;
}
.sales-funnel-stages-table input[type="text"] {
  min-width: 10rem;
  width: 100%;
  max-width: 20rem;
  box-sizing: border-box;
}
.sales-funnel-stages-table input[type="number"] {
  width: 5rem;
  box-sizing: border-box;
}
.sales-funnel-card-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.35rem;
  margin: -0.25rem -0.25rem 0.35rem -0.25rem;
  padding: 0.2rem 0.25rem;
  border-bottom: 1px solid rgba(0, 0, 0, 0.08);
  font-size: 0.75rem;
}
[data-theme="dark"] .sales-funnel-card-toolbar {
  border-bottom-color: rgba(255, 255, 255, 0.12);
}
.sales-funnel-card-drag-hint {
  cursor: grab;
  color: var(--muted, #666);
  user-select: none;
  letter-spacing: -0.1em;
}
.sales-funnel-card--dragging .sales-funnel-card-drag-hint {
  cursor: grabbing;
}
.sales-funnel-card-move-modal-btn {
  flex-shrink: 0;
  white-space: nowrap;
}
.sales-funnel-card[draggable="true"] {
  cursor: grab;
}
.sales-funnel-card--dragging {
  opacity: 0.55;
  cursor: grabbing;
}
.sales-funnel-col--drop-over {
  outline: 2px dashed var(--accent, #0a6);
  outline-offset: 2px;
  background: rgba(10, 102, 160, 0.06);
}
[data-theme="dark"] .sales-funnel-col--drop-over {
  background: rgba(100, 180, 255, 0.08);
}

.sales-funnel-col-title {
  font-weight: 600;
  margin-bottom: 0.5rem;
  font-size: 0.9rem;
}
.sales-funnel-card {
  background: var(--card-bg, #fff);
  border: 1px solid var(--border-color, #ddd);
  border-radius: 6px;
  padding: 0.5rem;
  margin-bottom: 0.5rem;
  font-size: 0.85rem;
}
[data-theme="dark"] .sales-funnel-card {
  background: var(--card-bg, #1e1e1e);
  border-color: var(--border-color, #444);
}
.sales-funnel-card-name { font-weight: 600; }
.sales-funnel-follow-up { font-size: 0.8rem; color: var(--accent, #0a6); margin: 0.25rem 0; }
.sales-funnel-card-stage, .sales-funnel-fu { display: block; margin-top: 0.35rem; font-size: 0.8rem; }
.sales-funnel-card select, .sales-funnel-card textarea, .sales-funnel-fu input { width: 100%; max-width: 100%; box-sizing: border-box; }

.sales-funnel-add-client-row {
  align-items: flex-end;
  flex-wrap: wrap;
  gap: 0.75rem;
}
.sales-funnel-add-client-wrap {
  position: relative;
  flex: 1 1 16rem;
  min-width: 12rem;
  max-width: 28rem;
}
.sales-funnel-add-client-wrap > label {
  display: block;
  margin-bottom: 0.35rem;
}
.sales-funnel-add-client-wrap input[type="text"] {
  width: 100%;
  box-sizing: border-box;
}
.sales-funnel-client-suggestions {
  position: absolute;
  left: 0;
  right: 0;
  top: 100%;
  z-index: 30;
  margin: 0.2rem 0 0;
  padding: 0;
  list-style: none;
  background: var(--card-bg, #fff);
  border: 1px solid var(--border-color, #ccc);
  border-radius: 6px;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.12);
  max-height: 14rem;
  overflow-y: auto;
}
.sales-funnel-client-suggestions:not(.hidden) { display: block; }
.sales-funnel-client-suggestions li {
  padding: 0.5rem 0.75rem;
  cursor: pointer;
  font-size: 0.9rem;
  line-height: 1.35;
}
.sales-funnel-client-suggestions li small {
  display: block;
  color: var(--text-muted, #666);
  font-size: 0.8rem;
  margin-top: 0.15rem;
}
.sales-funnel-client-suggestions li:hover,
.sales-funnel-client-suggestions li.sales-funnel-suggest-active {
  background: var(--hover-overlay, rgba(0, 0, 0, 0.06));
}
.sales-funnel-client-suggestions .sales-funnel-suggest-empty {
  cursor: default;
  color: var(--text-muted);
}
.sales-funnel-client-suggestions .sales-funnel-suggest-empty:hover {
  background: transparent;
}

/* Доступность: скрытый текст для aria-describedby */
.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* YC sync: визуальное сопоставление «зона как staff» → услуга CRM */
.yc-resource-staff-block {
  padding: 0.85rem 1rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg-card);
  box-shadow: var(--shadow-card);
}
.yc-resource-staff-block__title strong {
  font-size: 1.02rem;
}
.yc-resource-staff-flow {
  display: flex;
  flex-wrap: wrap;
  align-items: stretch;
  gap: 0.65rem 1rem;
  margin: 0.85rem 0 1rem;
  padding: 0.75rem 1rem;
  border-radius: 8px;
  background: var(--hover-overlay);
  border: 1px dashed var(--border);
}
.yc-resource-staff-flow__col {
  flex: 1 1 140px;
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
  min-width: 0;
}
.yc-resource-staff-flow__badge {
  display: inline-block;
  align-self: flex-start;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  padding: 0.2rem 0.5rem;
  border-radius: 4px;
  background: var(--accent);
  color: #fff;
}
.yc-resource-staff-flow__badge--crm {
  background: var(--success);
}
.yc-resource-staff-flow__label {
  font-weight: 600;
  font-size: 0.95rem;
}
.yc-resource-staff-flow__hint {
  font-size: 0.8rem;
  line-height: 1.3;
}
.yc-resource-staff-flow__arrow {
  flex: 0 0 auto;
  align-self: center;
  font-size: 1.5rem;
  font-weight: 300;
  color: var(--text-muted);
  line-height: 1;
}
.yc-resource-staff-table-wrap {
  margin-top: 0.25rem;
}
.yc-resource-staff-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
  margin-bottom: 0.65rem;
}
.yc-resource-staff-table th,
.yc-resource-staff-table td {
  padding: 0.45rem 0.5rem;
  text-align: left;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}
.yc-resource-staff-table th {
  font-weight: 600;
  color: var(--text-muted);
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}
.yc-resource-staff-table__actions {
  width: 6.5rem;
  text-align: right;
}
.yc-resource-staff-table input[type="number"] {
  width: 100%;
  max-width: 12rem;
  padding: 0.4rem 0.5rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--bg-card);
  color: var(--text);
}
.yc-resource-staff-table select.yc-resource-staff-select {
  width: 100%;
  max-width: 100%;
  min-width: 0;
  padding: 0.45rem 0.5rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--bg-card);
  color: var(--text);
  font-size: 0.88rem;
}
.yc-resource-staff-table tr.yc-resource-staff-empty td {
  border-bottom: none;
  font-size: 0.88rem;
}
#settings-yc-resource-staff-add-row {
  margin-top: 0.15rem;
}
