/* =====================================================================
   Дизайн-система в стилистике shadcn/ui: нейтральная палитра Zinc + синий акцент.
   Тёмная тема — по умолчанию; светлая — [data-theme="light"] на <html>.
   Иконки — Lucide (Iconify), инлайн-SVG класса .i (см. app/icons.py, api.js icon()).
   ===================================================================== */
:root, [data-theme="dark"] {
  color-scheme: dark; /* нативные select-попапы, скроллбары и date-пикеры — в тёмной палитре */
  --bg: #09090b;          /* фон страницы (zinc-950) */
  --bg-2: #111113;        /* вложенные плашки, липкие колонки таблиц */
  --card: #18181b;        /* карточки, модалки, выпадающие меню (zinc-900) */
  --card-2: #1f1f23;      /* приглушённая поверхность внутри карточки */
  --border: #27272a;      /* рамки и разделители (zinc-800) */
  --input: #3f3f46;       /* рамка полей ввода (zinc-700) */
  --input-bg: rgba(255,255,255,.035);
  --hover: #27272a;       /* фон наведения (accent в терминах shadcn) */
  --text: #fafafa;
  --muted: #a1a1aa;       /* приглушённый текст (zinc-400) */
  --primary: #2563eb;     /* основные кнопки (blue-600) */
  --primary-hover: #3b82f6;
  --on-primary: #ffffff;
  --accent: #60a5fa;      /* ссылки, выделения, активные рамки (blue-400) */
  --accent-2: #38bdf8;    /* второй акцент — голубой (фирменная гамма Узтелеком) */
  --on-accent: #09090b;
  --ok: #22c55e;
  --warn: #f59e0b;
  --bad: #ef4444;
  --radius: 12px;
  --shadow-xs: 0 1px 2px rgba(0,0,0,.30);
  --shadow-sm: 0 1px 3px rgba(0,0,0,.35), 0 1px 2px -1px rgba(0,0,0,.35);
  --shadow-md: 0 8px 24px -6px rgba(0,0,0,.55), 0 2px 6px -2px rgba(0,0,0,.4);
  --shadow-lg: 0 18px 44px -10px rgba(0,0,0,.65), 0 6px 14px -6px rgba(0,0,0,.45);
  --bubble-other: #27272a;
  --overlay: rgba(0,0,0,.6);
  --sidebar-bg: #0e0e10;
  --topbar-bg: rgba(9,9,11,.78);
  --skeleton: rgba(255,255,255,.06);
  --skeleton-shine: rgba(255,255,255,.10);

  /* Шрифты */
  --font-sans: "Inter", "Segoe UI", Roboto, system-ui, -apple-system, sans-serif;
  --font-mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;

  /* Каркас */
  --sidebar-w: 252px;
  --sidebar-w-collapsed: 60px;
  --topbar-h: 56px;

  /* ===== Шкалы (значения = прежним литералам → вёрстка страниц не поплывёт) ===== */
  /* Отступы (шаг 4/8) */
  --sp-1: 4px;  --sp-2: 6px;  --sp-3: 8px;  --sp-4: 10px; --sp-5: 12px; --sp-6: 14px;
  --sp-7: 16px; --sp-8: 18px; --sp-9: 20px; --sp-10: 24px; --sp-11: 28px; --sp-12: 32px;
  /* Размеры шрифта */
  --fs-2xs: 10px; --fs-xs: 11px; --fs-sm: 12px; --fs-13: 13px; --fs-base: 14px;
  --fs-15: 15px;  --fs-md: 16px; --fs-lg: 18px; --fs-19: 19px; --fs-xl: 22px;
  --fs-2xl: 26px; --fs-3xl: 32px;
  /* Межстрочный и насыщенность */
  --lh-tight: 1.1; --lh-snug: 1.25; --lh-normal: 1.4;
  --fw-normal: 400; --fw-medium: 500; --fw-semibold: 600; --fw-bold: 700;
  /* Радиусы (--radius: 12px — карточки; поля и кнопки — --radius-md) */
  --radius-xs: 4px; --radius-sm: 6px; --radius-md: 8px; --radius-lg: 10px;
  --radius-xl: 16px; --radius-pill: 999px;
  /* Слои z-index */
  --z-sticky-cell: 4; --z-sticky-col: 5; --z-sticky-corner: 6;
  --z-topbar: 50; --z-sidebar: 60; --z-dropdown: 100; --z-toast: 300; --z-lightbox: 400;
  /* Анимации */
  --dur-fast: 0.12s; --dur-base: 0.15s; --dur-slow: 0.3s; --ease: ease;
  --ease-out: cubic-bezier(.22,1,.36,1);
  /* Фокус-кольцо (клавиатура) */
  --ring: color-mix(in srgb, var(--accent) 45%, transparent);
  --focus-ring: 0 0 0 3px var(--ring);

  /* AA-контрастные ТЕКСТОВЫЕ варианты статусных цветов (заливки используют --ok/--warn/--bad) */
  --ok-text: #4ade80; --warn-text: #fbbf24; --bad-text: #f87171;
  /* Цвета тегов ролей (тёмная тема) */
  --tag-coord-bg: rgba(239,68,68,.15);   --tag-coord-fg: #fca5a5;
  --tag-aktiv-bg: rgba(34,197,94,.15);   --tag-aktiv-fg: #86efac;
  --tag-vecher-bg: rgba(96,165,250,.15); --tag-vecher-fg: #93c5fd;
  --tag-smen-bg: rgba(245,158,11,.16);   --tag-smen-fg: #fcd34d;
  --tag-day-bg: rgba(161,161,170,.14);   --tag-day-fg: var(--muted);
  /* Палитра графиков (Chart.js читает её из CSS — см. charts.js) */
  --chart-1: #3b82f6; --chart-2: #8b5cf6; --chart-3: #10b981; --chart-4: #f59e0b;
  --chart-5: #ef4444; --chart-6: #06b6d4; --chart-7: #ec4899; --chart-8: #84cc16;

  /* Совместимость: имена, на которые ссылались страницы, но которых не было в токенах */
  --fg: var(--text);
  --bg-hover: var(--hover);
}

[data-theme="light"] {
  color-scheme: light;
  --bg: #fafafa;
  --bg-2: #f4f4f5;
  --card: #ffffff;
  --card-2: #f4f4f5;
  --border: #e4e4e7;
  --input: #d4d4d8;
  --input-bg: #ffffff;
  --hover: #f4f4f5;
  --text: #09090b;
  --muted: #71717a;
  --primary: #2563eb;
  --primary-hover: #1d4ed8;
  --on-primary: #ffffff;
  --accent: #2563eb;
  --accent-2: #0284c7;
  --on-accent: #ffffff;
  --ok: #16a34a;
  --warn: #d97706;
  --bad: #dc2626;
  --shadow-xs: 0 1px 2px rgba(0,0,0,.05);
  --shadow-sm: 0 1px 3px rgba(0,0,0,.07), 0 1px 2px -1px rgba(0,0,0,.07);
  --shadow-md: 0 8px 20px -6px rgba(0,0,0,.14), 0 2px 6px -2px rgba(0,0,0,.08);
  --shadow-lg: 0 18px 40px -12px rgba(0,0,0,.22), 0 6px 14px -6px rgba(0,0,0,.10);
  --bubble-other: #f4f4f5;
  --overlay: rgba(9,9,11,.42);
  --sidebar-bg: #ffffff;
  --topbar-bg: rgba(250,250,250,.8);
  --skeleton: rgba(0,0,0,.06);
  --skeleton-shine: rgba(0,0,0,.03);

  /* Светлая тема: затемнённые текстовые/теговые цвета для читаемости на белом */
  --ok-text: #15803d; --warn-text: #b45309; --bad-text: #b91c1c;
  --tag-coord-bg: rgba(220,38,38,.09);   --tag-coord-fg: #b91c1c;
  --tag-aktiv-bg: rgba(22,163,74,.10);   --tag-aktiv-fg: #15803d;
  --tag-vecher-bg: rgba(37,99,235,.09);  --tag-vecher-fg: #1d4ed8;
  --tag-smen-bg: rgba(217,119,6,.11);    --tag-smen-fg: #b45309;
  --tag-day-bg: rgba(113,113,122,.10);   --tag-day-fg: var(--muted);
  --chart-1: #2563eb; --chart-2: #7c3aed; --chart-3: #059669; --chart-4: #d97706;
  --chart-5: #dc2626; --chart-6: #0891b2; --chart-7: #db2777; --chart-8: #65a30d;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: var(--font-sans);
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}
::selection { background: color-mix(in srgb, var(--primary) 35%, transparent); }

/* --- Иконки Lucide (инлайн-SVG 1em, цвет = currentColor) --- */
.i {
  width: 1em; height: 1em; flex-shrink: 0; display: inline-block;
  vertical-align: -0.14em; overflow: visible; pointer-events: none;
}

/* --- Полоса прокрутки (под тему, тонкая) --- */
* { scrollbar-width: thin; scrollbar-color: var(--border) transparent; }
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb {
  background: var(--border); border-radius: 99px;
  border: 2px solid transparent; background-clip: content-box;
}
::-webkit-scrollbar-thumb:hover { background: var(--muted); background-clip: content-box; }
::-webkit-scrollbar-corner { background: transparent; }
a { color: var(--accent); text-decoration: none; }
h1, h2, h3, h4 { letter-spacing: -0.01em; }

/* =====================================================================
   Каркас: боковое меню (sidebar) + основная колонка (topbar + main)
   ===================================================================== */
.app-sidebar {
  position: fixed; top: 0; bottom: 0; left: 0; z-index: var(--z-sidebar);
  width: var(--sidebar-w); display: flex; flex-direction: column;
  background: var(--sidebar-bg); border-right: 1px solid var(--border);
  transition: width .22s var(--ease-out), transform .26s var(--ease-out);
}
.app-main {
  margin-left: var(--sidebar-w); min-width: 0; min-height: 100vh;
  display: flex; flex-direction: column;
  transition: margin-left .22s var(--ease-out);
}

.sb-header {
  height: var(--topbar-h); flex-shrink: 0; display: flex; align-items: center;
  padding: 0 12px; border-bottom: 1px solid var(--border);
}
.sb-brand { display: flex; align-items: center; gap: 10px; min-width: 0; color: var(--text); }
.sb-logo {
  width: 32px; height: 32px; flex-shrink: 0; display: grid; place-items: center;
  border-radius: 9px; font-size: 18px; color: #fff;
  background: linear-gradient(135deg, #2563eb, #0ea5e9);
  box-shadow: 0 4px 14px -4px rgba(37,99,235,.6), inset 0 1px 0 rgba(255,255,255,.25);
}
.sb-brand-text { display: flex; flex-direction: column; line-height: 1.2; min-width: 0; }
.sb-brand-text b { font-size: 14.5px; font-weight: 650; letter-spacing: -0.01em; }
.sb-brand-text small {
  font-size: 11.5px; color: var(--muted); white-space: nowrap;
  overflow: hidden; text-overflow: ellipsis;
}

.sb-nav {
  flex: 1; overflow-y: auto; overflow-x: hidden; padding: 10px 10px 12px;
  display: flex; flex-direction: column; gap: 14px;
}
.sb-group { display: flex; flex-direction: column; gap: 2px; }
.sb-label {
  font-size: 11.5px; font-weight: 500; color: var(--muted); letter-spacing: .01em;
  padding: 4px 10px 6px; white-space: nowrap; overflow: hidden;
}
/* Пункт меню. Это и <a>, и <button> (свернуть) — сбрасываем базовый стиль кнопки. */
.sb-item {
  position: relative; display: flex; align-items: center; justify-content: flex-start; gap: 10px; width: 100%;
  height: 36px; min-height: 0; padding: 0 10px; border: 0; border-radius: var(--radius-md);
  background: transparent; color: var(--text); box-shadow: none;
  font: inherit; font-size: 14px; font-weight: 450; text-align: left; cursor: pointer;
  transition: background-color var(--dur-base), color var(--dur-base);
}
.sb-item > span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sb-item .i { font-size: 18px; color: var(--muted); transition: color var(--dur-base); }
.sb-item:hover { background: var(--hover); color: var(--text); }
.sb-item:hover .i { color: var(--text); }
.sb-item.active {
  background: color-mix(in srgb, var(--primary) 14%, transparent);
  color: var(--text); font-weight: 600;
}
.sb-item.active .i { color: var(--accent); }
.sb-item.active::before {
  content: ""; position: absolute; left: -10px; top: 8px; bottom: 8px; width: 3px;
  border-radius: 0 3px 3px 0; background: var(--accent);
}
.sb-footer {
  flex-shrink: 0; padding: 8px 10px 10px; border-top: 1px solid var(--border);
  display: flex; flex-direction: column; gap: 2px;
}
.sb-collapse { color: var(--muted); }
.sb-collapse .sb-ico-open { display: none; }

/* Свёрнутое меню (только десктоп): узкая полоса иконок + подсказки справа */
@media (min-width: 1025px) {
  [data-sidebar="collapsed"] .app-sidebar { width: var(--sidebar-w-collapsed); }
  [data-sidebar="collapsed"] .app-main { margin-left: var(--sidebar-w-collapsed); }
  [data-sidebar="collapsed"] .sb-header { padding: 0 14px; }
  [data-sidebar="collapsed"] .sb-brand-text,
  [data-sidebar="collapsed"] .sb-item > span { display: none; }
  [data-sidebar="collapsed"] .sb-label {
    height: 1px; padding: 0; margin: 4px 8px 8px; background: var(--border); font-size: 0;
  }
  [data-sidebar="collapsed"] .sb-group:first-child .sb-label { display: none; }
  [data-sidebar="collapsed"] .sb-nav { overflow: visible; padding: 10px 8px; gap: 6px; }
  [data-sidebar="collapsed"] .sb-footer { padding: 8px; }
  [data-sidebar="collapsed"] .sb-item { justify-content: center; padding: 0; }
  [data-sidebar="collapsed"] .sb-item.active::before { left: -8px; }
  [data-sidebar="collapsed"] .sb-collapse .sb-ico-close { display: none; }
  [data-sidebar="collapsed"] .sb-collapse .sb-ico-open { display: inline-block; }
  [data-sidebar="collapsed"] .sb-item::after {
    content: attr(data-tip); position: absolute; left: calc(100% + 12px); top: 50%;
    transform: translate(-4px, -50%); opacity: 0; pointer-events: none; white-space: nowrap;
    background: var(--text); color: var(--bg); font-size: 12px; font-weight: 500;
    padding: 5px 9px; border-radius: var(--radius-sm); box-shadow: var(--shadow-md);
    transition: opacity var(--dur-base), transform var(--dur-base); z-index: 5;
  }
  [data-sidebar="collapsed"] .sb-item:hover::after,
  [data-sidebar="collapsed"] .sb-item:focus-visible::after { opacity: 1; transform: translate(0, -50%); }
  .sb-backdrop { display: none; }
}

/* Планшет/телефон: меню — выезжающая шторка поверх контента */
@media (max-width: 1024px) {
  .app-sidebar {
    width: min(288px, 86vw); transform: translateX(-100%);
    box-shadow: none; visibility: hidden;
    transition: transform .26s var(--ease-out), visibility 0s linear .26s, box-shadow .26s;
  }
  [data-sidebar-open] .app-sidebar {
    transform: none; visibility: visible; box-shadow: var(--shadow-lg);
    transition: transform .26s var(--ease-out), visibility 0s, box-shadow .26s;
  }
  .app-main { margin-left: 0; }
  .sb-collapse { display: none; }
  .sb-backdrop {
    position: fixed; inset: 0; z-index: calc(var(--z-sidebar) - 1);
    background: var(--overlay); backdrop-filter: blur(2px);
    animation: overlay-in var(--dur-base) var(--ease-out);
  }
}

/* --- Верхняя панель --- */
.topbar {
  position: sticky; top: 0; z-index: var(--z-topbar);
  height: var(--topbar-h); flex-shrink: 0;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 0 24px; background: var(--topbar-bg);
  -webkit-backdrop-filter: saturate(1.5) blur(12px); backdrop-filter: saturate(1.5) blur(12px);
  border-bottom: 1px solid var(--border);
}
.topbar-left { display: flex; align-items: center; gap: 8px; min-width: 0; }
.topbar-sep { width: 1px; height: 18px; background: var(--border); margin: 0 4px; flex-shrink: 0; }
.crumbs { display: flex; align-items: center; gap: 6px; min-width: 0; font-size: 14px; color: var(--muted); }
.crumbs .crumb-root { color: var(--muted); transition: color var(--dur-base); }
.crumbs .crumb-root:hover { color: var(--text); }
.crumbs .crumb-sep { font-size: 14px; opacity: .7; }
.crumbs .crumb-current {
  color: var(--text); font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.topbar-right { display: flex; align-items: center; gap: 4px; }

.main-full { padding: 28px 32px 40px; width: 100%; max-width: 1440px; margin: 0 auto; flex: 1; }
/* Чат/операторы — почти на всю ширину рабочей области. */
.main-full.main-wide { max-width: none; padding: 20px 24px 28px; }
.main-full.main-ops { max-width: none; padding: 20px 24px 28px; }

/* Раздел «Статистика»: заголовки блоков «Регионы» / «Обращения» */
.stat-section { margin-bottom: 18px; }
.stat-section-title { font-size: 18px; font-weight: 600; letter-spacing: -0.015em; margin: 8px 0 14px; }
.page-title {
  font-size: 24px; font-weight: 650; letter-spacing: -0.025em; line-height: 1.2;
  margin: 0 0 22px; display: flex; align-items: center; gap: 10px;
}
.page-title:empty { display: none; }

/* Кнопка профиля: аватар + имя/роль (NavUser в shadcn) */
.userbox { display: flex; align-items: center; gap: 10px; color: var(--text); min-width: 0; }
.userbox .ub-text { display: flex; flex-direction: column; line-height: 1.2; min-width: 0; text-align: left; }
.userbox .ub-name {
  font-size: 13px; font-weight: 600; max-width: 180px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.userbox .ub-role { font-size: 11.5px; color: var(--muted); font-weight: 500; }
.userbox .avatar { width: 30px; height: 30px; font-size: 12px; border-radius: 8px; }
.avatar-skel { background: var(--skeleton) !important; }

/* --- Меню профиля --- */
.profile-menu { position: relative; }
.profile-btn {
  display: flex; align-items: center; gap: 8px; cursor: pointer; height: 40px;
  background: transparent; border: 1px solid transparent; border-radius: var(--radius-md);
  padding: 4px 8px 4px 5px; color: var(--text); font-weight: 600; box-shadow: none;
  transition: background-color var(--dur-base), border-color var(--dur-base);
}
.profile-btn:hover, .profile-menu.open .profile-btn { background: var(--hover); }
.profile-btn .chev { color: var(--muted); display: flex; font-size: 14px; }

.profile-dropdown {
  position: absolute; right: 0; top: calc(100% + 8px);
  background: var(--card); border: 1px solid var(--border); border-radius: var(--radius-lg);
  min-width: 240px; padding: 4px; box-shadow: var(--shadow-lg);
  display: none; z-index: var(--z-dropdown); transform-origin: top right;
}
.profile-menu.open .profile-dropdown { display: block; animation: pop-in var(--dur-base) var(--ease-out); }
.pd-head { display: flex; align-items: center; gap: 10px; padding: 8px 8px 10px; }
.pd-head:empty { display: none; }
.pd-head .avatar { width: 34px; height: 34px; font-size: 13px; border-radius: 9px; }
.pd-head .pd-name { font-weight: 600; font-size: 13.5px; line-height: 1.25; }
.pd-head .pd-sub { font-size: 12px; color: var(--muted); }
.profile-dropdown a {
  display: flex; align-items: center; gap: 9px; padding: 7px 9px; border-radius: var(--radius-sm);
  color: var(--text); font-size: 14px; transition: background-color var(--dur-fast);
}
.profile-dropdown a .i { font-size: 16px; color: var(--muted); }
.profile-dropdown a:hover { background: var(--hover); }
.profile-dropdown a.active { background: var(--hover); font-weight: 600; }
.profile-dropdown a.active .i { color: var(--accent); }
.profile-dropdown .pd-logout:hover { color: var(--bad-text); }
.profile-dropdown .pd-logout:hover .i { color: var(--bad-text); }
.dd-sep { border-top: 1px solid var(--border); margin: 4px -4px; }
@keyframes pop-in { from { opacity: 0; transform: translateY(-4px) scale(.98); } to { opacity: 1; transform: none; } }

/* =====================================================================
   Формы и кнопки (shadcn: Input / Select / Button / Checkbox / Switch)
   Базовые правила обёрнуты в :where() — нулевая специфичность, поэтому ЛЮБОЙ класс
   компонента (.toast-close, .msg-actions button и т.п.) перекрывает их без !important.
   ===================================================================== */
.controls { display: flex; gap: 12px; flex-wrap: wrap; margin-bottom: 20px; align-items: end; }
.field { display: flex; flex-direction: column; gap: 6px; }
.field label { font-size: 12.5px; font-weight: 500; color: var(--muted); }

:where(input:not([type=checkbox], [type=radio], [type=range], [type=file], [type=color], [type=submit], [type=button], [type=reset], [type=image]), select, textarea) {
  font-family: inherit; font-size: 14px; line-height: 20px; padding: 7px 12px; min-height: 36px;
  background: var(--input-bg); color: var(--text);
  border: 1px solid var(--input); border-radius: var(--radius-md);
  box-shadow: var(--shadow-xs);
  transition: border-color var(--dur-base) var(--ease), box-shadow var(--dur-base) var(--ease);
}
:where(textarea) { min-height: 64px; resize: vertical; }
:where(input, select, textarea):focus {
  outline: none; border-color: var(--accent); box-shadow: var(--focus-ring);
}
:where(input, select, textarea)[aria-invalid="true"] { border-color: var(--bad); }
input::placeholder, textarea::placeholder { color: var(--muted); opacity: .8; }

/* Единый вид нативных выпадающих списков: свой шеврон вместо системной стрелки */
:where(select) {
  appearance: none; -webkit-appearance: none;
  padding-right: 34px; cursor: pointer;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 24 24' fill='none' stroke='%2371717a' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 10px center;
}
:where(select[multiple]) { background-image: none; padding-right: 12px; }

/* Файл: кнопка выбора — как outline-кнопка */
input[type="file"] { font: inherit; font-size: 13px; color: var(--muted); max-width: 100%; }
input[type="file"]::file-selector-button {
  font: inherit; font-size: 13px; font-weight: 500; margin-right: 10px; padding: 6px 12px;
  border: 1px solid var(--input); border-radius: var(--radius-md); cursor: pointer;
  background: var(--card); color: var(--text); transition: background-color var(--dur-base);
}
input[type="file"]::file-selector-button:hover { background: var(--hover); }

/* Чекбокс и радио — собственные (shadcn Checkbox); галочка — фоном, без псевдоэлементов */
input[type="checkbox"], input[type="radio"] {
  appearance: none; -webkit-appearance: none; margin: 0; padding: 0;
  width: 16px; height: 16px; flex-shrink: 0; display: inline-block; vertical-align: -3px;
  border: 1px solid var(--input); border-radius: 4px; background-color: var(--input-bg);
  background-repeat: no-repeat; background-position: center; background-size: 12px;
  box-shadow: var(--shadow-xs); cursor: pointer;
  transition: background-color var(--dur-fast), border-color var(--dur-fast), box-shadow var(--dur-fast);
}
input[type="radio"] { border-radius: 50%; }
input[type="checkbox"]:hover:not(:disabled), input[type="radio"]:hover:not(:disabled) { border-color: var(--accent); }
input[type="checkbox"]:checked {
  background-color: var(--primary); border-color: var(--primary);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='white' stroke-width='3.2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M20 6 9 17l-5-5'/%3E%3C/svg%3E");
}
input[type="checkbox"]:indeterminate {
  background-color: var(--primary); border-color: var(--primary);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='white' stroke-width='3.2' stroke-linecap='round'%3E%3Cpath d='M6 12h12'/%3E%3C/svg%3E");
}
input[type="radio"]:checked {
  border-color: var(--primary);
  background-image: radial-gradient(circle, var(--primary) 0 4px, transparent 4.5px);
  background-size: 100% 100%;
}
input[type="checkbox"]:focus-visible, input[type="radio"]:focus-visible { outline: none; box-shadow: var(--focus-ring); }

/* Переключатель (uiverse-style switch): <input type="checkbox" class="switch"> */
input[type="checkbox"].switch {
  width: 38px; height: 22px; border-radius: 999px; border: 0; vertical-align: middle;
  background-color: var(--input); box-shadow: inset 0 1px 2px rgba(0,0,0,.2);
  background-image: radial-gradient(circle, #fff 0 8px, transparent 8.5px);
  background-size: 22px 22px; background-position: 0 50%;
  transition: background-color .2s var(--ease-out), background-position .2s var(--ease-out);
}
input[type="checkbox"].switch:checked {
  background-color: var(--primary);
  background-image: radial-gradient(circle, #fff 0 8px, transparent 8.5px);
  background-size: 22px 22px; background-position: 16px 50%;
}

/* Кнопки. Без класса — основная (primary); .ghost — «outline»; .btn-secondary — приглушённая;
   .btn-danger — destructive; .btn-sm — компактная; .btn-icon — квадратная под иконку. */
:where(button) {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  font-family: inherit; font-size: 14px; font-weight: 500; line-height: 20px;
  min-height: 36px; padding: 7px 14px; cursor: pointer;
  background: var(--primary); color: var(--on-primary);
  border: 1px solid transparent; border-radius: var(--radius-md);
  box-shadow: var(--shadow-xs);
  transition: background-color var(--dur-base) var(--ease), border-color var(--dur-base) var(--ease),
              color var(--dur-base) var(--ease), box-shadow var(--dur-base) var(--ease),
              transform var(--dur-fast) var(--ease), opacity var(--dur-base);
}
:where(button:not(:disabled)):hover { background: var(--primary-hover); }
:where(button:not(:disabled)):active { transform: translateY(1px) scale(.985); }
:where(button) .i { font-size: 16px; }

:where(button).ghost, :where(button).btn-outline {
  background: var(--input-bg); color: var(--text); border-color: var(--input);
}
:where(button.ghost, button.btn-outline):where(:not(:disabled)):hover { background: var(--hover); border-color: var(--input); }
:where(button).btn-secondary { background: var(--hover); color: var(--text); box-shadow: none; }
:where(button.btn-secondary:not(:disabled)):hover { background: color-mix(in srgb, var(--hover) 75%, var(--muted)); }
:where(button).btn-plain { background: transparent; color: var(--text); box-shadow: none; }
:where(button.btn-plain:not(:disabled)):hover { background: var(--hover); }
.btn-danger { background: var(--bad); color: #fff; border-color: transparent; }
:where(button.btn-danger:not(:disabled)):hover { background: color-mix(in srgb, var(--bad) 85%, #000); }
.btn-sm { min-height: 30px; padding: 4px 10px; font-size: 13px; gap: 5px; border-radius: var(--radius-sm); }
.btn-sm .i { font-size: 14px; }
.btn-icon { padding: 0; width: 36px; min-width: 36px; }
.btn-sm.btn-icon { width: 30px; min-width: 30px; }
.btn-block { width: 100%; }

/* --- Интерактивные состояния (клавиатурная доступность + обратная связь) --- */
/* Кольцо фокуса показываем ТОЛЬКО при навигации с клавиатуры; мышиный :focus не трогаем */
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
/* У полей ввода фокус уже подсвечен рамкой и кольцом — без двойной обводки */
input:focus-visible, select:focus-visible, textarea:focus-visible { outline: none; }
/* Заблокированные элементы — явное приглушённое состояние */
button:disabled, input:disabled, select:disabled, textarea:disabled { opacity: .5; cursor: not-allowed; }
button:disabled { box-shadow: none; }

/* Спиннер загрузки (uiverse-style): <span class="spinner"></span>, в кнопке — .is-loading */
.spinner {
  display: inline-block; width: 16px; height: 16px; flex-shrink: 0; border-radius: 50%;
  border: 2px solid color-mix(in srgb, currentColor 25%, transparent);
  border-top-color: currentColor; animation: spin .7s linear infinite; vertical-align: -3px;
}
.spinner.lg { width: 28px; height: 28px; border-width: 3px; }
@keyframes spin { to { transform: rotate(360deg); } }
button.is-loading { pointer-events: none; opacity: .85; }
button.is-loading > .i { display: none; }
button.is-loading::before {
  content: ""; width: 14px; height: 14px; border-radius: 50%;
  border: 2px solid color-mix(in srgb, currentColor 30%, transparent); border-top-color: currentColor;
  animation: spin .7s linear infinite;
}

/* Скелетон (мерцающая заглушка, пока грузятся данные) */
.skeleton {
  display: block; border-radius: var(--radius-sm); min-height: 12px; color: transparent !important;
  background: linear-gradient(90deg, var(--skeleton) 0%, var(--skeleton-shine) 40%, var(--skeleton) 80%);
  background-size: 300% 100%; animation: shimmer 1.4s ease-in-out infinite;
}
@keyframes shimmer { from { background-position: 100% 0; } to { background-position: -50% 0; } }

/* Уважать системную настройку «уменьшить движение» */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    transition-duration: .001ms !important;
    animation-duration: .001ms !important;
    scroll-behavior: auto !important;
  }
}

/* Подсказка роли до ответа /api/auth/me (data-role ставится до отрисовки из localStorage,
   окончательно — loadCurrentUser). Только косметика меню: доступ проверяет сервер. */
html:not([data-role="admin"]) [data-admin-only],
html:not([data-role="admin"]):not([data-role="aktiv"]) [data-staff-only],
html:not([data-role="operator"]):not([data-role="aktiv"]) [data-self-schedule],
html:not([data-role="aktiv"]) [data-aktiv-only],
html[data-role="operator"] [data-hide-operator] { display: none !important; }

/* --- Cards / KPI --- */
.kpi-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: 16px; margin-bottom: 24px; }
/* KPI-плитка (shadcn SectionCards): подпись + иконка в цветной плашке, крупное значение.
   Цвет плитки задаёт --kpi-c (классы c-blue / c-indigo / c-green / c-red / c-amber). */
.kpi {
  --kpi-c: var(--chart-1);
  position: relative; overflow: hidden; height: 100%;
  background: linear-gradient(to top, color-mix(in srgb, var(--kpi-c) 7%, var(--card)) 0%, var(--card) 72%);
  border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow-xs);
  padding: 18px 20px 20px;
  transition: transform .2s var(--ease-out), box-shadow .2s var(--ease-out), border-color .2s;
}
.kpi .kpi-top { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.kpi .kpi-icon {
  width: 36px; height: 36px; flex-shrink: 0; display: grid; place-items: center;
  border-radius: 10px; font-size: 18px; color: var(--kpi-c);
  background: color-mix(in srgb, var(--kpi-c) 14%, transparent);
  box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--kpi-c) 22%, transparent);
}
.kpi .label { color: var(--muted); font-size: 13px; font-weight: 500; line-height: 1.3; }
.kpi .value {
  font-size: 30px; font-weight: 650; letter-spacing: -0.025em; line-height: 1.1;
  margin-top: 14px; font-variant-numeric: tabular-nums;
}
.kpi.bad .value { color: var(--bad-text); }
.kpi.ok .value { color: var(--ok-text); }

/* Цветовые акценты KPI */
.kpi.c-blue { --kpi-c: var(--chart-1); }
.kpi.c-indigo { --kpi-c: var(--accent-2); }   /* синяя гамма бренда */
.kpi.c-green { --kpi-c: var(--ok); }   .kpi.c-green .value { color: var(--ok-text); }
.kpi.c-red { --kpi-c: var(--bad); }    .kpi.c-red .value { color: var(--bad-text); }
.kpi.c-amber { --kpi-c: var(--warn); } .kpi.c-amber .value { color: var(--warn-text); }

.period-caption {
  display: inline-flex; align-items: center; gap: 8px; min-height: 36px;
  background: var(--card); border: 1px solid var(--border); border-radius: var(--radius-md);
  padding: 7px 12px; color: var(--text); font-weight: 500; white-space: nowrap; box-shadow: var(--shadow-xs);
}
.period-caption .i { color: var(--muted); }

.grid-2 {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
}

.grid-2 .card:first-child {
  grid-column: 1 / 3;
}

@media (max-width: 768px) {
  .grid-2 {
    grid-template-columns: 1fr;
  }

  .grid-2 .card:first-child {
    grid-column: 1 / 2;
  }
}

.card {
  background: var(--card); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 20px 22px; margin-bottom: 16px; box-shadow: var(--shadow-xs);
}
.card h3 {
  margin: 0 0 16px; font-size: 15px; font-weight: 600; letter-spacing: -0.01em; line-height: 1.35;
  display: flex; align-items: center; gap: 8px;
}
.card h3 .i { color: var(--muted); }
.chart-wrap { position: relative; height: 320px; }
.card:has(#topChart) .chart-wrap { height: 450px; }
.card:has(#requestsChart) .chart-wrap { height: 350px; }

/* --- Table (shadcn Table: шапка приглушённым текстом, строки разделены линией) --- */
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--border); }
th {
  color: var(--muted); font-size: 12.5px; font-weight: 500;
  cursor: pointer; user-select: none; height: 40px;
}
tbody tr { transition: background-color var(--dur-fast) var(--ease); }
tbody tr:hover { background: color-mix(in srgb, var(--hover) 55%, transparent); }

/* Таблицы внутри карточек: шапка на приглушённом фоне, цифры — моноширинные */
.card table { border-radius: var(--radius-md); overflow: hidden; }
.card th, .card td { padding: 11px 14px; }
.card thead th { background: color-mix(in srgb, var(--card-2) 70%, var(--card)); border-bottom: 1px solid var(--border); }
.card tbody tr:last-child td { border-bottom: none; }
.card td { font-variant-numeric: tabular-nums; }

/* Широкие таблицы прокручиваются по горизонтали внутри карточки —
   края таблицы совпадают с краями карточки и не вылезают за неё. */
.table-scroll { overflow-x: auto; border-radius: var(--radius-md); }
.table-scroll table { border-radius: 0; }
/* Компактные кнопки действий, чтобы колонка не распирала таблицу. */
.row-actions .btn-sm { padding: 4px 9px; white-space: nowrap; }

/* Бейджи (shadcn Badge): мягкая заливка + тонкая рамка того же оттенка */
.badge {
  display: inline-flex; align-items: center; gap: 0; vertical-align: middle;
  padding: 2px 8px; border-radius: var(--radius-sm); font-size: 12px; font-weight: 500;
  line-height: 18px; white-space: nowrap; border: 1px solid transparent;
}
.badge .i { font-size: 13px; }
/* Отступ задаём иконке, а не gap: JS местами переключает бейджу display на block */
.badge > .i, .badge > .status-dot { margin-right: 5px; }
.badge > .status-dot { margin-right: 7px; }
.badge.ok { background: color-mix(in srgb, var(--ok) 13%, transparent); color: var(--ok-text); border-color: color-mix(in srgb, var(--ok) 26%, transparent); }
.badge.bad { background: color-mix(in srgb, var(--bad) 13%, transparent); color: var(--bad-text); border-color: color-mix(in srgb, var(--bad) 28%, transparent); }
.badge.neutral { background: color-mix(in srgb, var(--muted) 12%, transparent); color: var(--muted); border-color: color-mix(in srgb, var(--muted) 20%, transparent); }
.badge.warn { background: color-mix(in srgb, var(--warn) 14%, transparent); color: var(--warn-text); border-color: color-mix(in srgb, var(--warn) 28%, transparent); }
.badge.info { background: color-mix(in srgb, var(--accent) 13%, transparent); color: var(--accent); border-color: color-mix(in srgb, var(--accent) 26%, transparent); }
/* Точка-индикатор статуса (вкл/выкл, работает/выходной) */
.status-dot {
  display: inline-block; width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0;
  background: var(--muted); vertical-align: 1px;
}
.status-dot.ok { background: var(--ok); box-shadow: 0 0 0 3px color-mix(in srgb, var(--ok) 22%, transparent); }
.status-dot.bad { background: var(--bad); box-shadow: 0 0 0 3px color-mix(in srgb, var(--bad) 22%, transparent); }
.status-dot.warn { background: var(--warn); box-shadow: 0 0 0 3px color-mix(in srgb, var(--warn) 22%, transparent); }
.status-dot.pulse { animation: dot-pulse 1.8s ease-in-out infinite; }
@keyframes dot-pulse { 50% { box-shadow: 0 0 0 6px transparent; } }

/* Профиль оператора: обращения региона (порядок обработки) */
.rr-warning {
  display: flex; align-items: flex-start; gap: 10px;
  background: color-mix(in srgb, var(--bad) 10%, transparent); color: var(--bad-text);
  border: 1px solid color-mix(in srgb, var(--bad) 30%, transparent);
  border-radius: var(--radius-md); padding: 10px 14px; margin-bottom: 12px; font-size: 14px;
}
tr.rr-bad { background: color-mix(in srgb, var(--warn) 8%, transparent); }
.underperf-row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }

.pagination { display: flex; gap: 6px; align-items: center; margin-top: 16px; justify-content: flex-end; color: var(--muted); }

.muted { color: var(--muted); }
.empty { text-align: center; color: var(--muted); padding: 40px; }

/* Пустое состояние (shadcn Empty): иконка в плашке + заголовок + пояснение */
.empty-state {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 8px;
  text-align: center; color: var(--muted); padding: 44px 20px;
}
.empty-state-icon {
  width: 48px; height: 48px; display: grid; place-items: center; border-radius: 12px;
  font-size: 22px; color: var(--muted); background: var(--hover); margin: 0 auto 6px;
  border: 1px solid var(--border);
}
.empty-state h3, .empty-state .empty-state-title { color: var(--text); font-size: 15px; font-weight: 600; margin: 0; }
.empty-state p { margin: 4px auto 0; font-size: 13.5px; max-width: 420px; }

/* Загрузка: спиннер + подпись по центру блока */
.loading {
  display: flex; align-items: center; justify-content: center; gap: 10px;
  padding: 40px 20px; color: var(--muted); font-size: 14px;
}

.ops-summary {
  margin-bottom: 14px; padding: 10px 14px; background: var(--card); border: 1px solid var(--border);
  border-radius: var(--radius-md); font-size: 14px; box-shadow: var(--shadow-xs);
}
.ops-summary b { color: var(--accent); }
.warn-text { color: var(--warn-text); font-weight: 600; }
.row-warn { background: color-mix(in srgb, var(--warn) 6%, transparent); }

.kpi-link { cursor: pointer; }
a:has(> .kpi-link) { display: block; height: 100%; }
.kpi-link::after {
  content: ""; position: absolute; right: 18px; bottom: 18px; width: 16px; height: 16px;
  background: var(--muted); opacity: 0; transform: translate(-4px, 4px);
  -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M7 7h10v10M7 17 17 7'/%3E%3C/svg%3E") center / contain no-repeat;
          mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M7 7h10v10M7 17 17 7'/%3E%3C/svg%3E") center / contain no-repeat;
  transition: opacity .2s var(--ease-out), transform .2s var(--ease-out);
}
.kpi-link:hover {
  transform: translateY(-2px); box-shadow: var(--shadow-md);
  border-color: color-mix(in srgb, var(--kpi-c) 45%, var(--border));
}
.kpi-link:hover::after { opacity: 1; transform: none; }

.row-actions { display: flex; gap: 6px; align-items: center; }

.tag {
  display: inline-flex; align-items: center; gap: 4px; padding: 2px 8px; border-radius: var(--radius-sm);
  font-size: 12px; font-weight: 500; line-height: 18px; white-space: nowrap;
}
.tag.coord { background: var(--tag-coord-bg); color: var(--tag-coord-fg); }
.tag.aktiv { background: var(--tag-aktiv-bg); color: var(--tag-aktiv-fg); }
.tag.vecher { background: var(--tag-vecher-bg); color: var(--tag-vecher-fg); }
.tag.smen { background: var(--tag-smen-bg); color: var(--tag-smen-fg); }
.tag.day { background: var(--tag-day-bg); color: var(--tag-day-fg); }

/* Текстовые/теговые цвета для светлой темы централизованы в токенах --*-text / --tag-*-fg */

/* Переключатель темы в меню профиля */
.theme-toggle { display: flex; align-items: center; gap: 8px; }

/* --- Modal --- */
.modal-overlay {
  position: fixed; inset: 0; background: var(--overlay);
  -webkit-backdrop-filter: blur(3px); backdrop-filter: blur(3px);
  display: none; align-items: center; justify-content: center; z-index: var(--z-dropdown); padding: 12px;
}
.modal-overlay.open { display: flex; }
.modal {
  position: relative;
  background: var(--card); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 24px; width: 460px; max-width: 92vw; box-shadow: var(--shadow-lg);
  /* Высокая модалка (напр. со списком регионов) не должна вылезать за экран —
     иначе кнопки внизу недостижимы. Делаем модалку прокручиваемой. */
  max-height: 92vh; overflow-y: auto;
}
.modal h3 {
  margin: 0 0 18px; font-size: 18px; font-weight: 600; letter-spacing: -0.015em; line-height: 1.3;
  padding-right: 34px; display: flex; align-items: center; gap: 8px;
}
/* Крестик закрытия (добавляет api.js в каждую .modal без своего .modal-x) */
.modal-x {
  position: absolute; top: 14px; right: 14px; z-index: 2;
  width: 32px; height: 32px; min-height: 0; padding: 0; border-radius: var(--radius-sm);
  background: transparent; color: var(--muted); border: 0; box-shadow: none; font-size: 18px;
}
.modal-x:hover { background: var(--hover); color: var(--text); }
.modal .field { margin-bottom: 16px; }
.modal .field input:where(:not([type=checkbox], [type=radio])), .modal .field select { width: 100%; }
.modal .derived { font-size: 12px; color: var(--muted); margin: -8px 0 16px; }
.regions-box {
  max-height: 300px; overflow-y: auto; overflow-x: hidden; border: 1px solid var(--border);
  border-radius: var(--radius-md); padding: 8px; background: var(--bg-2);
  /* Одна колонка на всю ширину: имя региона + селект типа (Оба/Ишонч/Сайт) помещаются
     без обрезки. Двухколоночная сетка была слишком узкой — длинные названия резались. */
  display: grid; grid-template-columns: 1fr; gap: 6px;
}
.reg-check {
  display: flex; align-items: center; gap: 8px; font-size: 13px; cursor: pointer;
  text-align: left; line-height: 1.25; padding: 8px 10px; border-radius: 8px;
  border: 1px solid var(--border); background: var(--card);
  transition: background .12s, border-color .12s;
}
.reg-check:hover { border-color: color-mix(in srgb, var(--accent) 50%, var(--border)); }
.reg-check:has(input:checked) { background: color-mix(in srgb, var(--accent) 15%, transparent); border-color: var(--accent); }
/* Чекбокс + имя — кликабельный <label>, занимает всё место (селект типа — снаружи него). */
.reg-check-main { display: flex; align-items: center; gap: 8px; flex: 1; min-width: 0; cursor: pointer; }
/* Имя региона занимает место и переносится (не режется), селект типа прижат вправо. */
.reg-check .reg-name { flex: 1; min-width: 0; white-space: normal; word-break: break-word; }
.reg-check .reg-type {
  flex-shrink: 0; width: auto; min-width: 88px; font-size: 12px; padding: 2px 6px; margin: 0;
  border-radius: 6px; border: 1px solid var(--border); background: var(--card); color: var(--text);
}
.reg-check .reg-type:disabled { opacity: .45; }

/* Таблица операторов — компактная, «Действия» sticky справа у края прокрутки. */
.table-scroll--ops { overflow-x: auto; width: 100%; }
.ops-table { table-layout: fixed; width: 100%; min-width: 960px; }
.ops-table th,
.ops-table td { vertical-align: middle; }
.ops-table .col-login { width: 7%; white-space: nowrap; }
.ops-table .col-fio {
  width: 18%;
  min-width: 160px;
  padding-top: 8px;
  padding-bottom: 8px;
}
.ops-table .col-fio a {
  display: block;
  white-space: normal;
  word-break: break-word;
  line-height: 1.35;
  font-size: 12px;
  font-weight: 500;
}
.ops-table .col-regions { width: 20%; min-width: 140px; padding-top: 8px; padding-bottom: 8px; }
.ops-table .col-role { width: 8%; }
.ops-table .col-shift { width: 7%; white-space: nowrap; }
.ops-table .col-stat { width: 9%; white-space: nowrap; text-align: center; }
.ops-table .col-calls { width: 7%; white-space: nowrap; text-align: center; }
.ops-table .col-break { width: 9%; white-space: nowrap; text-align: center; }
.ops-table .col-norm { width: 7%; white-space: nowrap; text-align: center; }
.ops-table th { padding-left: 10px; padding-right: 10px; }
.ops-table th.col-stat, .ops-table th.col-normpct { white-space: normal; line-height: 1.25; }
.ops-table .col-normpct { width: 8%; white-space: nowrap; text-align: center; }
.ops-table .col-group {
  width: 12%;
  max-width: 200px;
  font-size: 11px;
  line-height: 1.3;
  white-space: normal;
  word-break: break-word;
}
.ops-table .col-actions {
  width: 48px;
  min-width: 48px;
  max-width: 48px;
  white-space: nowrap;
  text-align: center;
  position: sticky;
  right: 0;
  z-index: 3;
  background: var(--card);
  box-shadow: -6px 0 10px -4px rgba(0, 0, 0, 0.35);
}
.ops-table thead .col-actions {
  background: color-mix(in srgb, var(--card-2) 70%, var(--card));
  z-index: 4;
}
.ops-table tbody tr:hover .col-actions {
  background: var(--hover);
}
.region-chips {
  display: flex; flex-direction: column; align-items: stretch;
  gap: 4px; width: 100%;
}
.region-chip {
  display: flex; align-items: flex-start; gap: 6px;
  padding: 3px 7px; min-width: 0; width: 100%;
  border-radius: 6px;
  background: color-mix(in srgb, var(--muted) 8%, transparent);
  border: 1px solid var(--border);
  box-shadow: none;
}
.region-chip:hover { border-color: color-mix(in srgb, var(--accent) 35%, var(--border)); }
.region-chip-name {
  flex: 1; min-width: 0;
  font-size: 11px; font-weight: 500; color: var(--text);
  line-height: 1.3;
  white-space: normal; word-break: break-word;
}
.ops-menu-wrap { position: relative; display: inline-block; }
.ops-menu-btn { min-width: 32px; width: 32px; min-height: 30px; font-size: 16px; line-height: 1; padding: 0; }
.ops-menu {
  /* position: fixed + JS выносит меню в document.body при открытии — чтобы его НЕ резал
     ни overflow-скролл таблицы, ни transform/contain у предков. display включает JS инлайн
     (menu.style.display='flex'), поэтому flex-direction/gap держим в базовом правиле. */
  display: none; position: fixed; z-index: 1000;
  flex-direction: column; gap: 2px;
  min-width: 160px; padding: 4px;
  border-radius: var(--radius-lg); border: 1px solid var(--border);
  background: var(--card); box-shadow: var(--shadow-lg);
}
.ops-menu-wrap.open .ops-menu { display: flex; }
.ops-menu button {
  display: flex; align-items: center; justify-content: flex-start; gap: 8px; width: 100%; text-align: left;
  min-height: 0; padding: 7px 9px; border: none; border-radius: var(--radius-sm); box-shadow: none;
  background: transparent; color: var(--text); font-size: 13px; font-weight: 400; cursor: pointer;
}
.ops-menu button .i { font-size: 15px; color: var(--muted); }
.ops-menu button:hover { background: color-mix(in srgb, var(--muted) 12%, transparent); }
.ops-menu button.danger, .ops-menu button.danger .i { color: var(--bad-text); }
.rtype {
  display: inline-flex; align-items: center; gap: 3px;
  padding: 1px 5px;
  border-radius: var(--radius-pill);
  font-size: 9px; font-weight: 700;
  letter-spacing: .03em; text-transform: uppercase;
  line-height: 14px; flex-shrink: 0;
  border: 1px solid transparent;
}
.rtype-dot {
  width: 5px; height: 5px; border-radius: 50%; flex-shrink: 0;
}
.rtype-scraper {
  background: color-mix(in srgb, var(--accent) 14%, transparent); border-color: color-mix(in srgb, var(--accent) 45%, transparent); color: #7dd3fc;
}
.rtype-scraper .rtype-dot { background: #38bdf8; }
.rtype-scraper2 {
  background: rgba(34,197,94,.14); border-color: rgba(34,197,94,.45); color: #86efac;
}
.rtype-scraper2 .rtype-dot { background: #22c55e; }
.rtype-both {
  background: rgba(245,158,11,.12); border-color: rgba(245,158,11,.5); color: #fcd34d;
}
.rtype-both .rtype-dot { background: #f59e0b; }
.rtype-help {
  background: rgba(167,139,250,.14); border-color: rgba(167,139,250,.45); color: #c4b5fd;
}
.rtype-help .rtype-dot { background: #a78bfa; }
[data-theme="light"] .rtype-scraper  { color: #0369a1; background: rgba(2,132,199,.1); }
[data-theme="light"] .rtype-scraper2 { color: #15803d; background: rgba(22,163,74,.1); }
[data-theme="light"] .rtype-both     { color: #b45309; background: rgba(245,158,11,.12); }
[data-theme="light"] .rtype-help     { color: #6d28d9; background: rgba(139,92,246,.1); }

.modal-actions { display: flex; gap: 8px; justify-content: flex-end; flex-wrap: wrap; margin-top: 8px; }
/* Кнопки модалки — «липкий» футер: всегда видны при прокрутке высокой модалки. */
.modal .modal-actions {
  position: sticky; bottom: -24px;
  margin: 12px -24px -24px; padding: 14px 24px;
  background: var(--card); border-top: 1px solid var(--border);
  border-radius: 0 0 var(--radius) var(--radius);
}

/* --- Модалка: норма обработок по операторам --- */
.modal-norms { width: 600px; }
.norm-stats-summary {
  margin-bottom: 12px; padding: 10px 14px; background: var(--bg-2);
  border: 1px solid var(--border); border-radius: 8px; font-size: 14px; color: var(--muted);
}
.norm-stats-summary b { color: var(--accent); }
.norm-stats-search { width: 100%; margin-bottom: 12px; }
.norm-stats-scroll {
  max-height: 56vh; overflow-y: auto; display: flex; flex-direction: column;
  gap: 6px; padding-right: 4px;
}
.norm-stat-row {
  display: flex; align-items: center; gap: 12px; padding: 10px 12px;
  background: var(--bg-2); border: 1px solid var(--border); border-radius: 10px;
}
.nsr-rank { width: 22px; flex-shrink: 0; text-align: center; font-size: 12px; font-weight: 700; color: var(--muted); }
.nsr-main { flex: 1; min-width: 0; }
.nsr-name {
  display: block; font-size: 13px; font-weight: 600; color: var(--text);
  line-height: 1.3; margin-bottom: 6px;
}
.nsr-name:hover { color: var(--accent); }
.nsr-bar { height: 8px; background: var(--border); border-radius: 99px; overflow: hidden; }
.nsr-bar-fill { height: 100%; border-radius: 99px; transition: width .3s; }
.nsr-meta { flex-shrink: 0; width: 88px; text-align: right; }
.nsr-pct { font-size: 16px; font-weight: 700; line-height: 1.1; }
.nsr-nums { font-size: 11px; color: var(--muted); margin-top: 2px; white-space: nowrap; }

/* --- Вход: стеклянная панель на синем градиенте; внутри панели — фото Узтелеком (волны) --- */
.login-page {
  --lg-base: #071330;
  --lg-bg: linear-gradient(135deg, #061129 0%, #0a1f45 50%, #062238 100%);
  --lg-photo-tint: rgba(4,20,60,.36);       /* синяя тонировка фото в панели — белый текст читается, цвета не сереют */
  --lg-glass: linear-gradient(150deg, rgba(10,28,66,.62), rgba(6,18,46,.5));
  --lg-btn1: #1d4ed8; --lg-btn2: #0ea5e9;
  --lg-glass-border: rgba(255,255,255,.14);
  --lg-glass-hi: rgba(255,255,255,.22);
  --lg-edge: linear-gradient(140deg, rgba(255,255,255,.55), rgba(255,255,255,.06) 38%, rgba(255,255,255,.04) 62%, rgba(255,255,255,.3));
  --lg-sheen: linear-gradient(165deg, rgba(255,255,255,.1), transparent 34%);
  --lg-field: rgba(9,24,60,.92);
  --lg-field-border: rgba(255,255,255,.16);
  --lg-autofill: #13254a;
  --lg-chip: rgba(6,18,46,.5);
  --lg-text: #f8fafc; --lg-muted: rgba(226,232,240,.75);
  position: relative; display: flex; align-items: center; justify-content: center;
  min-height: 100vh; min-height: 100dvh; padding: 24px 16px; overflow: hidden; isolation: isolate;
  background: var(--lg-base) var(--lg-bg) fixed;
  color: var(--lg-text);
}
[data-theme="light"] .login-page {
  --lg-base: #e9f1fd;
  --lg-bg: linear-gradient(135deg, #e6efff 0%, #eef5ff 50%, #e3f4fc 100%);
  --lg-photo-tint: rgba(8,40,110,.22);
  --lg-glass: linear-gradient(150deg, rgba(255,255,255,.58), rgba(255,255,255,.36));
  --lg-glass-border: rgba(255,255,255,.6);
  --lg-glass-hi: rgba(255,255,255,.95);
  --lg-edge: linear-gradient(140deg, #fff, rgba(255,255,255,.35) 38%, rgba(255,255,255,.2) 62%, rgba(255,255,255,.85));
  --lg-sheen: linear-gradient(165deg, rgba(255,255,255,.55), transparent 36%);
  --lg-field: rgba(255,255,255,.97);
  --lg-field-border: rgba(15,23,42,.12);
  --lg-autofill: #f3f8ff;
  --lg-chip: rgba(255,255,255,.75);
  --lg-text: #0b1736; --lg-muted: rgba(22,33,62,.8);
}

/* Стеклянная панель: бренд + форма + подпись */
.login-glass {
  position: relative; width: 100%; max-width: 410px; padding: 34px 30px 24px;
  border-radius: 24px; background: var(--lg-glass);
  border: 1px solid var(--lg-glass-border);
  box-shadow: inset 0 1px 0 var(--lg-glass-hi);   /* без внешней тени */
  -webkit-backdrop-filter: blur(16px) saturate(160%);
          backdrop-filter: blur(16px) saturate(160%);
  animation: lg-in .5s var(--ease-out) both;
}
/* Стеклянная кромка (светлая сверху-слева, гаснет к середине) и блик по верху панели */
.login-glass::before, .login-glass::after {
  content: ""; position: absolute; inset: -1px; border-radius: inherit; pointer-events: none;
}
.login-glass::before {
  padding: 1px; background: var(--lg-edge);
  -webkit-mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0);
  -webkit-mask-composite: xor;
          mask: linear-gradient(#000 0 0) content-box exclude, linear-gradient(#000 0 0);
}
.login-glass::after { background: var(--lg-sheen); }
.login-glass > * { position: relative; z-index: 1; }
/* Фото Узтелеком на всю стеклянную панель (вместе с логотипом), чётко, с лёгкой синей
   тонировкой. Текст на фото — белый (см. .login-brand h1/p, label, .login-foot). */
.login-glass > .login-photo {
  position: absolute; z-index: 0; inset: 0;
  overflow: hidden; border-radius: 23px; pointer-events: none;
}
.login-photo::before {
  content: ""; position: absolute; inset: 0;
  /* чётко, без размытия; прижато влево — кончики волн не попадают на подписи «Логин»/«Пароль» */
  background: url("../img/uztelecom-bg.jpg") left center / cover no-repeat;
}
.login-photo::after { content: ""; position: absolute; inset: 0; background: var(--lg-photo-tint); }
@keyframes lg-in { from { opacity: 0; transform: translateY(12px) scale(.98); } to { opacity: 1; transform: none; } }
.login-glass.shake { animation: lg-shake .4s ease; }
@keyframes lg-shake { 20%, 60% { transform: translateX(-7px); } 40%, 80% { transform: translateX(7px); } }
@media (prefers-reduced-motion: reduce) { .login-glass, .login-glass.shake { animation: none; } }
@supports not ((backdrop-filter: blur(1px)) or (-webkit-backdrop-filter: blur(1px))) {
  .login-glass { background: var(--card); }
}

.login-brand { display: flex; flex-direction: column; align-items: center; text-align: center; gap: 10px; margin-bottom: 26px; }
.login-logo {
  display: inline-flex; align-items: center; justify-content: center;
  width: 54px; height: 54px; font-size: 27px; border-radius: 16px; color: #fff;
  background: linear-gradient(135deg, var(--lg-btn1), var(--lg-btn2));
  box-shadow: inset 0 1px 0 rgba(255,255,255,.35);
}
/* Логотип-«кардиограмма»: по тусклой линии пульса бежит яркий импульс (копию пути с классом
   pulse-trace добавляет скрипт login.html; pathLength=100), плитка мягко «бьётся» в такт. */
.login-logo { animation: lg-beat 2.4s ease-in-out infinite; }
.login-logo .i { overflow: visible; filter: drop-shadow(0 0 3px rgba(255,255,255,.55)); }
.login-logo .pulse-base { opacity: .3; }
.login-logo .pulse-trace {
  stroke-dasharray: 34px 126px; stroke-dashoffset: 0px;
  animation: lg-pulse-run 2.4s linear infinite;
}
@keyframes lg-pulse-run { from { stroke-dashoffset: 0px; } to { stroke-dashoffset: 160px; } }
@keyframes lg-beat {
  0%, 30%, 100% { transform: scale(1); }
  45% { transform: scale(1.07); }
  60% { transform: scale(.98); }
}
/* «Уменьшить движение» (часто включено в Windows на рабочих ПК): убираем только «биение»
   плитки; импульс по линии — мелкое движение внутри иконки, его оставляем (просьба заказчика). */
@media (prefers-reduced-motion: reduce) {
  .login-logo { animation: none; }
  /* глобальное правило выше режет все анимации до .001ms — импульсу возвращаем его длительность */
  .login-logo .pulse-trace { animation-duration: 2.4s !important; }
}
.login-brand h1 { margin: 4px 0 0; font-size: 25px; font-weight: 700; letter-spacing: -0.03em; color: #fff; }
.login-brand p { margin: 0; font-size: 13.5px; color: rgba(255,255,255,.9); }

.login-form .field { margin-bottom: 16px; gap: 7px; }
.login-form .field label { color: rgba(255,255,255,.9); font-size: 12.5px; font-weight: 600; }
.login-form input {
  width: 100%; min-height: 46px; font-size: 14.5px; border-radius: 12px;
  background: var(--lg-field); border: 1px solid var(--lg-field-border); color: var(--lg-text);
  box-shadow: none;
}
.login-form input::placeholder { color: var(--lg-muted); opacity: .7; }
.login-form input:hover { border-color: color-mix(in srgb, var(--lg-field-border) 50%, var(--accent)); }
.login-form input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 4px color-mix(in srgb, var(--accent) 22%, transparent);
}
.login-form input[aria-invalid="true"] { border-color: var(--bad); box-shadow: 0 0 0 4px color-mix(in srgb, var(--bad) 18%, transparent); }
/* Автозаполнение браузера не должно красить поле поверх стекла */
.login-form input:-webkit-autofill {
  -webkit-text-fill-color: var(--lg-text);
  -webkit-box-shadow: 0 0 0 1000px var(--lg-autofill) inset;
  caret-color: var(--lg-text); transition: background-color 9999s;
}
.login-form .input-wrap > .i { left: 14px; z-index: 1; font-size: 17px; color: var(--lg-muted); }   /* иконка всегда поверх поля */
.login-form .input-wrap > input { padding-left: 42px; }
.login-form .input-wrap > input.has-action { padding-right: 46px; }
.login-form .input-wrap .input-action { right: 7px; width: 34px; height: 34px; color: var(--lg-muted); border-radius: 9px; }
.login-form .input-wrap .input-action:hover { background: color-mix(in srgb, var(--lg-text) 10%, transparent); color: var(--lg-text); }
.login-form .input-wrap:focus-within > .i { color: var(--accent); }

.caps-hint { display: flex; align-items: center; gap: 6px; margin-top: 2px; font-size: 12px; color: var(--warn-text); }
.caps-hint[hidden] { display: none; }

.login-form button[type="submit"] {
  width: 100%; min-height: 48px; margin-top: 8px; border: 0; border-radius: 12px;
  font-size: 15px; font-weight: 600; color: #fff; letter-spacing: .01em;
  background: linear-gradient(135deg, var(--lg-btn1), var(--lg-btn2));
  box-shadow: inset 0 1px 0 rgba(255,255,255,.25);
  transition: transform var(--dur-base) var(--ease), box-shadow var(--dur-base) var(--ease), filter var(--dur-base) var(--ease);
}
.login-form button[type="submit"]:hover:not(:disabled) { transform: translateY(-1px); filter: brightness(1.08); }
.login-form button[type="submit"]:active:not(:disabled) { transform: translateY(0); filter: brightness(.97); }
.login-form button[type="submit"]:focus-visible { outline: none; box-shadow: 0 0 0 4px color-mix(in srgb, var(--accent) 35%, transparent); }

.login-foot {
  display: flex; align-items: center; justify-content: center; gap: 6px;
  margin-top: 22px; padding-top: 16px; border-top: 1px solid rgba(255,255,255,.3);
  font-size: 12px; color: rgba(255,255,255,.9); text-align: center;
}
/* Ошибка и Caps Lock — «плашкой», чтобы читались на фото */
.login-form .error-msg { color: #fff; background: color-mix(in srgb, var(--bad) 88%, transparent); padding: 8px 12px; border-radius: 10px; }
.login-form .caps-hint { align-self: flex-start; color: #fff; background: color-mix(in srgb, var(--warn) 85%, transparent); padding: 3px 8px; border-radius: 8px; }
.login-theme {
  position: absolute; top: 16px; right: 16px; z-index: 1;
  width: 40px; height: 40px; min-height: 0; padding: 0; border-radius: 12px;
  display: inline-flex; align-items: center; justify-content: center; font-size: 18px;
  color: var(--lg-text); background: var(--lg-chip); border: 1px solid var(--lg-glass-border);
  box-shadow: none; -webkit-backdrop-filter: blur(12px); backdrop-filter: blur(12px);
}
.login-theme:hover { background: color-mix(in srgb, var(--lg-text) 12%, transparent); }
@media (max-width: 480px) {
  .login-glass { padding: 28px 20px 20px; border-radius: 20px; }
  .login-brand h1 { font-size: 22px; }
}
.input-wrap { position: relative; display: flex; align-items: center; }
.input-wrap > .i { position: absolute; left: 11px; font-size: 16px; color: var(--muted); pointer-events: none; }
.input-wrap > input { padding-left: 36px; }
.input-wrap > input.has-action { padding-right: 40px; }
.input-wrap .input-action {
  position: absolute; right: 4px; width: 30px; height: 30px; min-height: 0; padding: 0;
  background: transparent; color: var(--muted); border: 0; box-shadow: none; border-radius: var(--radius-sm);
}
.input-wrap .input-action:hover { background: var(--hover); color: var(--text); }
.error-msg { display: flex; align-items: center; gap: 6px; color: var(--bad-text); font-size: 13px; margin-top: 12px; min-height: 18px; }
.error-msg:empty { display: none; }

/* --- Schedule Table --- */
#schedule-table-container {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-top: 1rem;
  background: var(--card);
}

.schedule-table {
  border-collapse: collapse;
  width: 100%;
}

.schedule-table th,
.schedule-table td {
  border: 1px solid var(--border);
  padding: 0.5rem;
  text-align: center;
  min-width: 3rem;
  height: 2.5rem;
  font-size: 0.85rem;
}

.schedule-table td:first-child,
.schedule-table th:first-child {
  position: sticky;
  left: 0;
  background: var(--bg-2);
  font-weight: 500;
  min-width: 150px;
  text-align: left;
  z-index: var(--z-sticky-col);
}

.schedule-table th:first-child {
  z-index: var(--z-sticky-corner);
  background: var(--card-2);
}

.schedule-table th {
  background: var(--card-2);
  color: var(--muted);
  font-weight: 600;
  position: sticky;
  top: 0;
  z-index: var(--z-sticky-cell);
}

.shift-empty { background: transparent; color: var(--muted); }
.shift-off { background: color-mix(in srgb, var(--ok) 13%, transparent); color: var(--ok-text); font-weight: 600; }
.shift-evening { background: color-mix(in srgb, var(--warn) 15%, transparent); color: var(--warn-text); font-weight: 600; }
.shift-day { background: color-mix(in srgb, var(--accent-2) 15%, transparent); color: var(--accent-2); font-weight: 600; }
.shift-other { background: color-mix(in srgb, var(--accent) 13%, transparent); color: var(--accent); font-weight: 600; }

@media (max-width: 768px) {
  .schedule-table th,
  .schedule-table td {
    padding: 0.25rem;
    min-width: 2.5rem;
    height: 2rem;
    font-size: 0.75rem;
  }

  .schedule-table td:first-child,
  .schedule-table th:first-child {
    min-width: 100px;
  }
}

/* --- Кнопки-иконки (ghost/icon): верхняя панель, строки таблиц --- */
.icon-btn {
  position: relative; display: inline-flex; align-items: center; justify-content: center;
  width: 32px; height: 32px; min-height: 0; padding: 0; flex-shrink: 0;
  cursor: pointer; background: transparent; border: 1px solid transparent; box-shadow: none;
  border-radius: var(--radius-md); color: var(--muted); font-size: 17px;
  line-height: 1; text-decoration: none;
  transition: background-color var(--dur-base), color var(--dur-base), border-color var(--dur-base);
}
.icon-btn:hover { background: var(--hover); color: var(--text); }
.topbar .icon-btn { width: 36px; height: 36px; font-size: 18px; }
.notif-menu.open > .icon-btn { background: var(--hover); color: var(--text); }
.nav-badge {
  position: absolute; top: 2px; right: 1px;
  background: var(--bad); color: #fff; font-size: 10px; font-weight: 700;
  min-width: 17px; height: 17px; line-height: 17px; padding: 0 5px;
  border-radius: 999px; text-align: center; font-variant-numeric: tabular-nums;
  box-shadow: 0 0 0 2px var(--bg);
}
.nav-badge[hidden] { display: none; }

/* Колокольчик: свой класс (НЕ .profile-menu — её ищет querySelector в api.js) */
.notif-menu { position: relative; }
.notif-dropdown {
  position: absolute; right: 0; top: calc(100% + 8px);
  background: var(--card); border: 1px solid var(--border); border-radius: var(--radius-lg);
  width: 360px; max-width: calc(100vw - 24px); padding: 4px; box-shadow: var(--shadow-lg);
  display: none; z-index: var(--z-dropdown); max-height: 70vh; overflow-y: auto; transform-origin: top right;
}
.notif-menu.open .notif-dropdown { display: block; animation: pop-in var(--dur-base) var(--ease-out); }
.notif-item {
  display: flex; gap: 10px; padding: 10px; border-radius: var(--radius-sm); color: var(--text);
  transition: background-color var(--dur-fast);
}
.notif-item + .notif-item { margin-top: 2px; }
.notif-item:hover { background: var(--hover); }
.notif-item .notif-ico {
  width: 30px; height: 30px; flex-shrink: 0; display: grid; place-items: center; border-radius: 8px;
  font-size: 15px; color: var(--accent); background: color-mix(in srgb, var(--accent) 13%, transparent);
}
.notif-item .notif-body { min-width: 0; flex: 1; }
.notif-item .notif-title { font-weight: 600; font-size: 13px; line-height: 1.35; }
.notif-item .notif-preview {
  font-size: 12.5px; color: var(--muted); margin-top: 2px;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.notif-item .notif-time { font-size: 11.5px; color: var(--muted); margin-top: 4px; }
.notif-empty {
  display: flex; flex-direction: column; align-items: center; gap: 8px;
  padding: 26px 12px; text-align: center; color: var(--muted); font-size: 13px;
}
.notif-empty .i { font-size: 22px; opacity: .7; }

/* --- Тосты (всплывающие уведомления) --- */
#toast-container {
  position: fixed; right: 20px; bottom: 20px; z-index: var(--z-toast);
  display: flex; flex-direction: column; gap: 10px;
  width: min(380px, calc(100vw - 32px)); pointer-events: none;
}
.toast {
  pointer-events: auto; position: relative; display: flex; align-items: flex-start; gap: 11px;
  background: var(--card); border: 1px solid var(--border); border-radius: var(--radius-lg);
  padding: 13px 40px 13px 14px; box-shadow: var(--shadow-lg);
  cursor: pointer; animation: toast-in .32s var(--ease-out);
}
.toast.leaving { animation: toast-out .2s ease-in forwards; }
.toast .toast-ico { font-size: 18px; flex-shrink: 0; margin-top: 1px; color: var(--accent); }
.toast.success .toast-ico { color: var(--ok-text); }
.toast.error .toast-ico { color: var(--bad-text); }
.toast.warning .toast-ico { color: var(--warn-text); }
.toast .toast-body { min-width: 0; flex: 1; }
.toast .toast-title { font-weight: 600; font-size: 13.5px; line-height: 1.35; }
.toast .toast-msg { font-size: 13.5px; line-height: 1.45; white-space: pre-line; word-break: break-word; padding-top: 1px; }
.toast .toast-preview {
  font-size: 13px; color: var(--muted); margin-top: 2px; line-height: 1.4;
  white-space: pre-line; word-break: break-word;
}
.toast.no-link { cursor: default; }
.toast-close {
  position: absolute; top: 8px; right: 8px; width: 26px; height: 26px; min-height: 0; padding: 0;
  display: inline-flex; align-items: center; justify-content: center;
  background: none; border: none; box-shadow: none; border-radius: var(--radius-sm);
  color: var(--muted); font-size: 15px; cursor: pointer;
}
.toast-close:hover { color: var(--text); background: var(--hover); }
@keyframes toast-in { from { opacity: 0; transform: translateY(14px) scale(.97); } to { opacity: 1; transform: none; } }
@keyframes toast-out { to { opacity: 0; transform: translateX(24px); } }

/* --- Диалог подтверждения (uiConfirm) --- */
.confirm-modal { width: 420px; }
.confirm-modal .confirm-body { display: flex; gap: 14px; align-items: flex-start; }
.confirm-modal .confirm-ico {
  width: 40px; height: 40px; flex-shrink: 0; display: grid; place-items: center; border-radius: 10px;
  font-size: 20px; color: var(--accent); background: color-mix(in srgb, var(--accent) 13%, transparent);
}
.confirm-modal.danger .confirm-ico { color: var(--bad-text); background: color-mix(in srgb, var(--bad) 13%, transparent); }
.confirm-modal h3 { margin: 2px 0 6px; padding-right: 0; font-size: 16.5px; }
.confirm-modal .confirm-text { color: var(--muted); font-size: 14px; line-height: 1.5; white-space: pre-line; word-break: break-word; }
.confirm-modal .confirm-input { width: 100%; margin-top: 12px; }
.confirm-modal .modal-actions { margin-top: 20px; }

/* --- Общее: многострочный пользовательский текст --- */
.pre-wrap { white-space: pre-wrap; word-break: break-word; }

/* --- Новости --- */
.news-card { box-shadow: var(--shadow-sm); transition: box-shadow .15s, border-color .15s; }
.news-card:hover { box-shadow: var(--shadow-md); }
.news-meta { font-size: 12px; color: var(--muted); margin: 4px 0 14px; }
.news-actions { display: flex; gap: 8px; }
.news-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; }
.comments-toggle {
  background: none; border: none; color: var(--accent); font-size: 13px;
  cursor: pointer; padding: 0; font-weight: 600;
}
.comments-box { display: none; margin-top: 12px; border-top: 1px solid var(--border); padding-top: 12px; }
.comments-box.open { display: block; }
.comment-row { display: flex; gap: 10px; padding: 8px 0; }
.comment-main { flex: 1; min-width: 0; }
.comment-meta { font-size: 12px; color: var(--muted); display: flex; gap: 8px; align-items: center; }
.comment-body {
  font-size: 14px; margin-top: 4px; padding: 8px 12px;
  background: var(--bg-2); border: 1px solid var(--border); border-radius: 4px 12px 12px 12px;
}
.comment-body a { color: var(--accent); text-decoration: underline; }
.comment-form { display: flex; gap: 8px; margin-top: 10px; }
.comment-form input { flex: 1; border-radius: 20px; }
.btn-link-danger { background: none; border: none; color: var(--bad-text); font-size: 12px; cursor: pointer; padding: 0; }

/* --- Чат --- */
#chat-layout { display: flex; gap: 16px; height: calc(100vh - 160px); min-height: 420px; }
.chat-sidebar {
  width: 280px; flex-shrink: 0; background: var(--card); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 12px; display: flex; flex-direction: column;
  gap: 6px; overflow-y: auto;
}
.chat-sidebar .side-label {
  font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: .03em;
  margin: 10px 4px 4px; display: flex; justify-content: space-between; align-items: center;
}
.conv-row {
  display: flex; flex-direction: column; gap: 2px; padding: 10px 12px;
  border-radius: 10px; cursor: pointer; position: relative;
  border: 1px solid transparent; transition: background .12s, border-color .12s;
}
.conv-row:hover { background: var(--hover); }
.conv-row.active { background: color-mix(in srgb, var(--primary) 13%, transparent); border-color: color-mix(in srgb, var(--accent) 40%, transparent); }
.conv-row .conv-name { font-weight: 600; font-size: 14px; display: flex; align-items: center; gap: 8px; }
.conv-row .conv-preview { font-size: 12px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.conv-row .nav-badge { position: static; margin-left: auto; }
.chat-main {
  flex: 1; min-width: 0; background: var(--card); border: 1px solid var(--border);
  border-radius: var(--radius); display: flex; flex-direction: column;
}
#chat-header { padding: 14px 18px; border-bottom: 1px solid var(--border); font-weight: 600; }
#messages { flex: 1; overflow-y: auto; padding: 16px 18px; display: flex; flex-direction: column; gap: 6px; }

/* Сообщение — строка [аватар][контент]; цветной пузырь — внутренний .bubble */
.msg { display: flex; align-items: flex-end; gap: 8px; max-width: 78%; align-self: flex-start; }
.msg.mine { align-self: flex-end; }
.msg-avatar { flex-shrink: 0; }
.msg.mine .msg-avatar { display: none; }
.msg.compact .msg-avatar { visibility: hidden; }   /* место под аватар сохраняем для выравнивания серии */
.msg-content { display: flex; flex-direction: column; min-width: 0; }
.bubble {
  position: relative; padding: 8px 12px; border-radius: 16px;
  background: var(--bubble-other); box-shadow: var(--shadow-sm);
  border-bottom-left-radius: 5px;                    /* «хвост» у чужих сообщений */
}
.msg.compact .bubble { border-bottom-left-radius: 16px; }
.msg.mine .bubble {
  background: linear-gradient(135deg, var(--primary), color-mix(in srgb, var(--primary) 72%, #0ea5e9));
  color: var(--on-primary);
  border-bottom-left-radius: 16px; border-bottom-right-radius: 5px;
}
.msg.mine.compact .bubble { border-bottom-right-radius: 16px; }
.bubble.deleted { background: var(--bg-2); box-shadow: none; border: 1px dashed var(--border); }
.msg.mine .bubble.deleted { background: var(--bg-2); color: var(--muted); }
.msg .msg-author { font-size: 11px; font-weight: 700; color: var(--accent); margin-bottom: 3px; }
.msg .msg-body { font-size: 14px; line-height: 1.4; }
.msg .msg-body a { color: inherit; text-decoration: underline; text-underline-offset: 2px; }
.msg .msg-time { font-size: 10px; opacity: .65; margin-top: 3px; text-align: right; }
.chat-form { display: flex; gap: 8px; padding: 12px 18px; border-top: 1px solid var(--border); align-items: flex-end; }
.chat-form textarea {
  flex: 1; resize: none; font-family: inherit; font-size: 14px; padding: 10px 16px;
  background: var(--bg); color: var(--text); border: 1px solid var(--border); border-radius: 20px;
  max-height: 120px; transition: border-color .15s, box-shadow .15s;
}
.chat-form textarea:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 12%, transparent); }
.chat-form button[type="submit"] { border-radius: 20px; padding: 9px 20px; }
.chat-form #attach-btn { border-radius: 50%; width: 40px; height: 40px; padding: 0; font-size: 17px; }
.user-pick-list { max-height: 50vh; overflow-y: auto; display: flex; flex-direction: column; gap: 4px; margin-top: 10px; }
.user-pick-row { padding: 10px 12px; border-radius: 8px; cursor: pointer; display: flex; justify-content: space-between; gap: 8px; }
.user-pick-row:hover { background: var(--hover); }

@media (max-width: 768px) {
  #chat-layout { flex-direction: column; height: auto; }
  .chat-sidebar { width: auto; max-height: 200px; }
  .chat-main { height: 60vh; }
}

/* --- Новости: этап 2 (вложения, закрепление, «Ознакомлен») --- */
.news-card.pinned { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent), var(--shadow-sm); }
.pin-badge {
  display: inline-flex; align-items: center; gap: 4px;
  font-size: 11.5px; font-weight: 600; color: var(--on-primary); background: var(--primary);
  border-radius: 999px; padding: 2px 9px; margin-right: 8px;
  vertical-align: middle; white-space: nowrap;
}
/* Галерея картинок новости: сетка с обрезкой и «+N» на последней */
.news-images { display: grid; gap: 6px; margin-top: 14px; max-width: 520px; grid-template-columns: repeat(2, 1fr); }
.news-images.count-1 { grid-template-columns: 1fr; max-width: 420px; }
.news-img-wrap {
  position: relative; padding: 0; border: none; background: var(--bg-2); cursor: zoom-in;
  border-radius: 10px; overflow: hidden; aspect-ratio: 4 / 3;
}
.news-images.count-1 .news-img-wrap { aspect-ratio: 16 / 10; }
.news-img {
  width: 100%; height: 100%; object-fit: cover; display: block;
  max-width: none; max-height: none; border: none; border-radius: 0;
}
.more-overlay {
  position: absolute; inset: 0; background: rgba(0,0,0,.55); color: #fff;
  display: flex; align-items: center; justify-content: center; font-size: 26px; font-weight: 700;
}
.news-files { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }
.file-chip {
  display: inline-flex; align-items: center; gap: 6px; font-size: 13px;
  background: var(--bg); border: 1px solid var(--border); border-radius: 8px;
  padding: 6px 10px; color: var(--text);
}
.file-chip:hover { border-color: var(--accent); }
.news-footer {
  display: flex; align-items: center; gap: 16px; margin-top: 12px; flex-wrap: wrap;
}
.ack-btn {
  font-size: 13px; min-height: 32px; padding: 5px 12px; border-radius: var(--radius-md);
  background: var(--primary); color: var(--on-primary); border: none; cursor: pointer;
}
.ack-btn.acked {
  background: transparent; color: var(--ok-text); border: 1px solid var(--ok);
  cursor: default; font-weight: 600;
}
.acks-scroll { max-height: 55vh; overflow-y: auto; }
.ack-section { margin-bottom: 14px; }
.ack-section b { display: block; margin-bottom: 6px; }
.ack-row {
  display: flex; justify-content: space-between; gap: 10px;
  padding: 6px 8px; border-bottom: 1px solid var(--border); font-size: 13px;
}
.ack-row:last-child { border-bottom: none; }

/* --- Чат: этап 2 (reply, реакции, вложения, поиск) --- */
#chat-header { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.chat-header-left { display: flex; align-items: center; gap: 10px; min-width: 0; }
.chat-header-left #chat-title { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chat-back-btn { flex-shrink: 0; }
.chat-header-actions { display: flex; align-items: center; gap: 8px; }
#chat-search { font-size: 13px; padding: 6px 12px; width: 180px; border-radius: 20px; }
.msg-reply {
  font-size: 12px; border-left: 3px solid var(--accent); padding: 3px 8px;
  margin-bottom: 5px; opacity: .9; border-radius: 6px;
  background: color-mix(in srgb, var(--accent) 10%, transparent);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 360px;
}
.msg.mine .msg-reply { border-left-color: rgba(255,255,255,.75); background: rgba(255,255,255,.14); }
.msg-img {
  max-width: 260px; max-height: 220px; border-radius: 12px; display: block; margin: 2px 0;
}
.msg.mine .file-chip { background: rgba(255,255,255,.18); color: inherit; border-color: transparent; }
.msg-reactions { display: flex; gap: 4px; margin-top: 5px; flex-wrap: wrap; align-self: flex-start; }
.msg.mine .msg-reactions { align-self: flex-end; }
.react-chip {
  font-size: 12px; padding: 2px 9px; border-radius: 12px; cursor: pointer;
  background: var(--card-2); border: 1px solid var(--border); color: var(--text);
  transition: transform .1s;
}
.react-chip:hover { transform: scale(1.08); }
.react-chip.mine { border-color: var(--accent); background: color-mix(in srgb, var(--accent) 16%, transparent); font-weight: 700; }
.react-picker {
  position: absolute; bottom: calc(100% + 6px); right: 0; z-index: var(--z-sticky-corner);
  display: grid; grid-template-columns: repeat(8, 1fr); gap: 2px; background: var(--card);
  border: 1px solid var(--border); border-radius: 14px; padding: 6px;
  box-shadow: var(--shadow-md);
  width: 312px; max-width: 90vw; max-height: 240px; overflow-y: auto;
}
.react-picker button {
  background: none; border: none; font-size: 20px; padding: 4px; cursor: pointer;
  border-radius: 8px; line-height: 1; transition: transform .1s, background .1s;
}
.react-picker button:hover { transform: scale(1.25); background: var(--card-2); }
.msg-actions {
  position: absolute; top: -14px; right: 8px; display: none; gap: 1px; z-index: var(--z-sticky-col);
  background: var(--card); border: 1px solid var(--border); border-radius: 10px;
  padding: 2px; box-shadow: var(--shadow-md);
}
.msg:hover .msg-actions { display: flex; }
.msg-actions button {
  background: none; border: none; font-size: 13px; padding: 3px 6px; cursor: pointer;
  color: var(--text); border-radius: 7px;
}
.msg-actions button:hover { background: var(--hover); }
#reply-bar, #edit-bar, #file-bar {
  padding: 8px 18px; border-top: 1px solid var(--border); font-size: 13px;
  background: var(--bg-2);
}
.reply-bar-content { display: flex; justify-content: space-between; align-items: center; gap: 10px; }
.reply-bar-content .toast-close { position: static; }
#search-results { flex: 1; overflow-y: auto; padding: 16px 18px; }
.search-head { font-size: 12px; margin-bottom: 10px; }
.search-row { padding: 8px 0; border-bottom: 1px solid var(--border); }
.search-row:last-child { border-bottom: none; }

/* --- UI/UX этап 3 --- */

/* Аватарка-инициалы */
.avatar {
  display: inline-flex; align-items: center; justify-content: center;
  width: 24px; height: 24px; border-radius: 50%; color: #fff;
  font-size: 10px; font-weight: 700; flex-shrink: 0; vertical-align: middle;
  user-select: none;
}
.msg-author { display: flex; align-items: center; gap: 6px; }
.conv-name .avatar { margin-right: 2px; }
.comment-meta .avatar { margin-right: 2px; }
.news-meta { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }

/* Липкая «пилюля» даты при прокрутке */
.date-sep {
  position: sticky; top: 4px; z-index: var(--z-sticky-cell); align-self: center; margin: 6px 0; pointer-events: none;
}
.date-sep span {
  display: inline-block; background: var(--bg-2); color: var(--muted);
  border: 1px solid var(--border); box-shadow: var(--shadow-sm);
  font-size: 11px; font-weight: 600; padding: 3px 12px; border-radius: 999px; white-space: nowrap;
}
/* Черта «Новые сообщения» */
.unread-sep {
  display: flex; align-items: center; gap: 10px; margin: 8px 0;
  font-size: 11px; color: var(--bad-text); font-weight: 700; align-self: stretch;
}
.unread-sep::before, .unread-sep::after {
  content: ""; flex: 1; border-top: 1px solid var(--bad); opacity: .5;
}
.unread-sep span { white-space: nowrap; }

/* Группировка серий сообщений одного автора */
.msg.compact { margin-top: -2px; }

/* Плавное появление новых сообщений */
@keyframes msg-in { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
.msg.msg-new { animation: msg-in .22s ease-out; }

/* Кнопка «↓ Вниз» */
.chat-main { position: relative; }
#scroll-down-btn {
  position: absolute; right: 18px; bottom: 86px; z-index: var(--z-sticky-col);
  border-radius: 18px; padding: 8px 14px; font-size: 14px; font-weight: 700;
  background: var(--primary); color: var(--on-primary); border: none; cursor: pointer;
  box-shadow: var(--shadow-lg); min-height: 0;
}

/* Drag&drop файла в чат */
.chat-main.drag-over { outline: 2px dashed var(--accent); outline-offset: -6px; }

/* Превью картинки перед отправкой */
#file-preview {
  width: 36px; height: 36px; object-fit: cover; border-radius: 6px;
  border: 1px solid var(--border);
}

/* Лайтбокс изображений (галерея со стрелками) */
#lightbox {
  position: fixed; inset: 0; background: rgba(0,0,0,.88); z-index: var(--z-lightbox);
  display: none; align-items: center; justify-content: center; cursor: zoom-out;
}
#lightbox.open { display: flex; }
#lightbox img {
  max-width: 92vw; max-height: 92vh; border-radius: 8px;
  box-shadow: 0 20px 60px rgba(0,0,0,.6);
}
.lb-nav {
  position: absolute; top: 50%; transform: translateY(-50%);
  width: 48px; height: 48px; border-radius: 50%; border: none; cursor: pointer;
  background: rgba(255,255,255,.14); color: #fff; font-size: 26px; line-height: 1; min-height: 0; padding: 0;
  display: flex; align-items: center; justify-content: center; box-shadow: none;
}
.lb-nav:hover { background: rgba(255,255,255,.28); }
.lb-prev { left: 20px; }
.lb-close {
  position: absolute; top: 16px; right: 16px; width: 40px; height: 40px; min-height: 0; padding: 0;
  border-radius: 50%; border: none; cursor: pointer; font-size: 20px;
  background: rgba(255,255,255,.14); color: #fff; box-shadow: none;
}
.lb-close:hover { background: rgba(255,255,255,.28); }
.lb-next { right: 20px; }
.lb-counter {
  position: absolute; top: 18px; left: 50%; transform: translateX(-50%);
  color: #fff; background: rgba(0,0,0,.5); padding: 4px 12px; border-radius: 999px;
  font-size: 13px; font-weight: 600;
}
.msg-img, .news-img { cursor: zoom-in; }

/* Сворачивание длинных новостей */
.news-content.collapsed {
  max-height: 200px; overflow: hidden; position: relative;
  -webkit-mask-image: linear-gradient(to bottom, #000 70%, transparent);
  mask-image: linear-gradient(to bottom, #000 70%, transparent);
}
.expand-btn { display: block; margin-top: 6px; }

/* --- «Новости» как полноэкранный раздел внутри чата (только добавление) --- */
/* Комната «Новости» подсвечивается своим классом .news-active, чтобы поллинг chat.js
   (highlightActiveRoom очищает .active у всех .conv-row) её не сбрасывал. */
#room-news.news-active { background: color-mix(in srgb, var(--primary) 13%, transparent); border-color: color-mix(in srgb, var(--accent) 40%, transparent); }
/* Панель новостей занимает всю область рядом с сайдбаром. По умолчанию скрыта атрибутом
   hidden; показ/скрытие делает JS inline-стилями (display) — работает и без этого CSS. */
#news-panel {
  flex: 1; min-width: 0; flex-direction: column;
  background: var(--card); border: 1px solid var(--border); border-radius: var(--radius);
}
#news-panel .news-chat-head {
  padding: 14px 18px; border-bottom: 1px solid var(--border); font-weight: 600;
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
}
#news-panel .news-chat-body { flex: 1; overflow-y: auto; padding: 16px 18px; }
#news-panel .controls { margin-bottom: 14px; }
#news-panel .pagination { margin-top: 14px; }
/* Пока открыты «Новости» — активную чат-комнату не подсвечиваем (выделена только «Новости»). */
#chat-layout.viewing-news .chat-sidebar .conv-row.active { background: transparent; border-color: transparent; }
@media (max-width: 768px) {
  #news-panel { height: 60vh; }
}

/* Шапка dropdown уведомлений (переключатель звука) */
.notif-head {
  display: flex; justify-content: space-between; align-items: center; gap: 8px;
  padding: 6px 6px 8px 10px; margin-bottom: 4px; border-bottom: 1px solid var(--border);
  font-size: 14px; font-weight: 600;
}
/* Быстрая ссылка «Открыть новости» в колокольчике */
.notif-action {
  display: flex; align-items: center; gap: 8px; padding: 8px 10px; margin-bottom: 4px;
  color: var(--accent); font-weight: 500; border-radius: var(--radius-sm);
  font-size: 13px; text-decoration: none;
}
.notif-action:hover { background: var(--hover); }

/* --- Markdown-lite (formatRich) в сообщениях и новостях --- */
.md-body { white-space: normal; word-break: break-word; }
.md-body strong { font-weight: 700; }
.md-body em { font-style: italic; }
.md-body del { opacity: .7; }
.md-body code {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: .92em; background: rgba(127,127,127,.18); padding: 1px 5px; border-radius: 5px;
}
.md-body pre.md-code {
  background: rgba(127,127,127,.16); border-radius: 8px; padding: 8px 10px;
  overflow-x: auto; margin: 4px 0;
}
.md-body pre.md-code code { background: none; padding: 0; }
.md-body ul, .md-body ol { margin: 4px 0; padding-left: 22px; }
.md-body li { margin: 1px 0; }
.md-body blockquote { margin: 4px 0; padding: 2px 10px; border-left: 3px solid var(--accent); opacity: .9; }
.md-body h3 { font-size: 15px; margin: 6px 0 2px; }
.md-body h4 { font-size: 14px; margin: 6px 0 2px; }
.md-body a { color: var(--accent); text-decoration: underline; }

/* Несколько картинок в одном сообщении (сетка) */
.msg-images { display: grid; gap: 4px; margin: 4px 0; max-width: 380px; }
.msg-images.count-1 { grid-template-columns: 1fr; }
.msg-images.count-2, .msg-images.count-4 { grid-template-columns: 1fr 1fr; }
.msg-images.count-3 { grid-template-columns: 1fr 1fr 1fr; }
.msg-images .msg-img { width: 100%; height: 100%; object-fit: cover; border-radius: 8px; max-height: 220px; }

/* Полоса прикреплённых файлов перед отправкой */
#file-list.file-list { display: flex; flex-wrap: wrap; gap: 8px; flex: 1; }
.file-chip-pending {
  display: flex; align-items: center; gap: 6px; background: var(--bg-2);
  border: 1px solid var(--border); border-radius: 8px; padding: 4px 6px; max-width: 200px;
}
.file-chip-pending img { width: 32px; height: 32px; object-fit: cover; border-radius: 5px; }
.file-chip-pending .fc-ico { font-size: 18px; }
.file-chip-pending .fc-name {
  font-size: 12px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 120px;
}
.file-chip-pending .fc-del { background: none; border: none; cursor: pointer; color: var(--muted); padding: 0 2px; font-size: 13px; }

/* ============================================================
   Адаптив (меняем только размеры/отступы — структуру и поведение JS не трогаем)
   ============================================================ */
@media (max-width: 1024px) {
  .main-full:not(.main-wide):not(.main-ops) { padding: 22px 24px 32px; }
  .kpi-grid { gap: var(--sp-6); }
}

@media (max-width: 768px) {
  .topbar { padding: 0 12px; }
  .crumbs .crumb-root, .crumbs .crumb-sep { display: none; }
  .userbox .ub-text { display: none; }
  .main-full:not(.main-wide):not(.main-ops) { padding: 18px 16px 28px; }
  .main-full.main-wide,
  .main-full.main-ops { padding: 14px 12px 24px; }
  .page-title { font-size: 20px; margin-bottom: var(--sp-7); }
  .controls { gap: var(--sp-3); }
}

@media (max-width: 480px) {
  .topbar { padding: 0 8px; gap: 6px; }
  .topbar-sep { display: none; }
  .topbar-right { gap: 2px; }
  .main-full:not(.main-wide):not(.main-ops) { padding: 16px 12px 24px; }
  .main-full.main-wide,
  .main-full.main-ops { padding: 12px 8px 20px; }

  /* KPI: minmax(200px) на телефоне даёт горизонтальный скролл — один столбец */
  .kpi-grid { grid-template-columns: 1fr; gap: var(--sp-5); }
  .kpi { padding: var(--sp-6) var(--sp-7); }
  .kpi .value { font-size: var(--fs-2xl); }

  /* Поля управления — на всю ширину, чтобы строка не ломалась */
  .controls { flex-direction: column; align-items: stretch; }
  .controls .field { width: 100%; }
  .period-caption { white-space: normal; }

  /* Список регионов в модалке — в один столбец */
  .regions-box { grid-template-columns: 1fr; }

  /* Модалка почти во всю ширину. «Липкий» футер завязан на padding модалки —
     меняем padding и отрицательные margin/bottom футера В ПАРЕ (иначе разъедется). */
  .modal { padding: var(--sp-9); width: 96vw; }
  .modal h3 { margin-bottom: var(--sp-6); }
  .modal .modal-actions {
    bottom: calc(-1 * var(--sp-9));
    margin: var(--sp-5) calc(-1 * var(--sp-9)) calc(-1 * var(--sp-9));
    padding: var(--sp-6) var(--sp-9);
  }
  .modal-norms { width: 96vw; }
}

/* ============================================================
   Точечная полировка компонентов
   ============================================================ */
/* Страница «Пользователи»: ровные строки, действия в одну линию, контролы по ширине ячейки */
.users-table td { vertical-align: middle; }
.users-table select,
.users-table input[type="text"] { width: 100%; }
.users-table td:last-child { white-space: nowrap; text-align: right; }

/* Пагинация: ровные компактные кнопки на всех страницах со списками */
.pagination button { min-width: 34px; padding: 6px 12px; border-radius: var(--radius-md); }

/* Плавное появление модальных окон (уважает prefers-reduced-motion) */
.modal-overlay.open { animation: overlay-in var(--dur-base) var(--ease-out); }
.modal-overlay.open .modal { animation: modal-pop .2s var(--ease-out); }
@keyframes overlay-in { from { opacity: 0; } to { opacity: 1; } }
@keyframes modal-pop {
  from { opacity: 0; transform: translateY(10px) scale(.98); }
  to { opacity: 1; transform: none; }
}

/* ===== Кастомный округлённый дропдаун (улучшение нативного <select>) ===== */
.cs { position: relative; display: inline-block; vertical-align: middle; max-width: 100%; }
/* нативный select скрыт визуально, но остаётся в DOM (значение/события синхронны) */
.cs-native {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); border: 0;
}
.cs-trigger {
  display: flex; align-items: center; justify-content: space-between; gap: var(--sp-3);
  width: 100%; min-width: 120px; min-height: 36px;
  font-family: inherit; font-size: var(--fs-base); font-weight: var(--fw-normal); line-height: 20px;
  padding: 7px 10px 7px 12px; text-align: left;
  background: var(--input-bg); color: var(--text); box-shadow: var(--shadow-xs);
  border: 1px solid var(--input); border-radius: var(--radius-md); cursor: pointer;
  transition: border-color var(--dur-base) var(--ease), box-shadow var(--dur-base) var(--ease),
              background-color var(--dur-base) var(--ease);
}
.cs-trigger:hover { background: color-mix(in srgb, var(--hover) 45%, var(--input-bg)); }
.cs.cs-open .cs-trigger { border-color: var(--accent); box-shadow: var(--focus-ring); }
.cs-label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cs-chev {
  flex-shrink: 0; display: inline-flex; color: var(--muted); font-size: 15px;
  transition: transform var(--dur-base) var(--ease);
}
.cs.cs-open .cs-chev { transform: rotate(180deg); }
.cs.cs-disabled { opacity: .55; }
.cs.cs-disabled .cs-trigger { cursor: not-allowed; }

.cs-menu {
  position: fixed; z-index: var(--z-dropdown);
  max-width: min(420px, 92vw); max-height: 320px; overflow-y: auto; overscroll-behavior: contain;
  padding: 4px; background: var(--card); border: 1px solid var(--border);
  border-radius: var(--radius-lg); box-shadow: var(--shadow-lg); display: none;
}
.cs.cs-open .cs-menu { display: block; animation: cs-pop var(--dur-base) var(--ease-out); }
@keyframes cs-pop { from { opacity: 0; transform: translateY(-4px); } to { opacity: 1; transform: none; } }
.cs-option {
  position: relative; padding: 7px 32px 7px 10px; border-radius: var(--radius-sm); cursor: pointer;
  color: var(--text); font-size: var(--fs-base); line-height: 20px; white-space: nowrap;
}
.cs-option:hover, .cs-option.cs-active { background: var(--hover); }
.cs-option.cs-selected { font-weight: var(--fw-medium); }
/* Галочка у выбранного пункта (как в shadcn Select) */
.cs-option.cs-selected::after {
  content: ""; position: absolute; right: 10px; top: 50%; width: 15px; height: 15px;
  transform: translateY(-50%); background: var(--accent);
  -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2.4' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M20 6 9 17l-5-5'/%3E%3C/svg%3E") center / contain no-repeat;
          mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2.4' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M20 6 9 17l-5-5'/%3E%3C/svg%3E") center / contain no-repeat;
}
.cs-option.cs-disabled { opacity: .5; cursor: not-allowed; }

/* Календарь фильтра «День» (<select data-day-picker>): 1 клик — день, 2 клика — начало периода */
.cs-menu.cs-daypicker { width: 284px; max-width: calc(100vw - 16px); max-height: none; overflow: visible; padding: 10px; }
.dp-head { font-weight: var(--fw-semibold); font-size: var(--fs-base); padding: 2px 4px 8px; }
.dp-grid { display: grid; grid-template-columns: repeat(7, 1fr); row-gap: 2px; }
.dp-dow { font-size: var(--fs-xs); color: var(--muted); text-align: center; padding: 2px 0 6px; }
.dp-dow.dp-we { color: color-mix(in srgb, var(--bad) 70%, var(--muted)); }
.dp-day {
  height: 34px; display: flex; align-items: center; justify-content: center;
  border-radius: var(--radius-sm); cursor: pointer; user-select: none;
  font-size: var(--fs-13); font-variant-numeric: tabular-nums; color: var(--text);
  transition: background-color var(--dur-fast) var(--ease);
}
.dp-day:hover, .dp-day.cs-active { background: var(--hover); }
.dp-day.dp-today { box-shadow: inset 0 0 0 1px var(--input); font-weight: var(--fw-semibold); }
.dp-day.dp-in { background: color-mix(in srgb, var(--accent) 20%, transparent); border-radius: 0; }
.dp-day.dp-sel { background: var(--primary); color: var(--on-primary); font-weight: var(--fw-semibold); }
.dp-day.dp-sel.cs-active { box-shadow: var(--focus-ring); }
.dp-day.dp-off { opacity: .3; cursor: not-allowed; background: none; box-shadow: none; }
.dp-foot {
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  margin-top: 8px; padding-top: 8px; border-top: 1px solid var(--border);
}
.dp-hint { font-size: var(--fs-xs); color: var(--muted); line-height: 1.3; }
.cs-daypicker.dp-picking .dp-hint { color: var(--accent); }
.dp-all {
  flex-shrink: 0; min-height: 0; padding: 5px 10px; font: inherit; font-size: var(--fs-sm);
  color: var(--text); background: transparent; border: 1px solid var(--input);
  border-radius: var(--radius-sm); cursor: pointer; box-shadow: none; white-space: nowrap;
}
.dp-all:hover { background: var(--hover); }
.dp-all.dp-all-on { border-color: var(--accent); color: var(--accent); }

/* Полноширинные контексты: модалки, форма пользователей */
.modal .cs, .users-table .cs { display: block; width: 100%; }
/* Поденный наряд XQ/обращений (Настройки): мультивыбор операторов чекбоксами. */
.duty-list {
  max-height: 260px; overflow-y: auto; overflow-x: hidden; border: 1px solid var(--border);
  border-radius: var(--radius-md); padding: 8px; background: var(--bg-2);
  display: grid; grid-template-columns: 1fr 1fr; gap: 6px;
}
.duty-op {
  display: flex; align-items: center; gap: 8px; font-size: 13px; cursor: pointer;
  padding: 6px 10px; border-radius: 8px; border: 1px solid var(--border);
  background: var(--card); line-height: 1.25;
}
.duty-op:has(input:checked) { background: color-mix(in srgb, var(--accent) 15%, transparent); border-color: var(--accent); }
/* ИСКЛЮЧЕНИЕ: селект типа обращений (Оба/Ишонч/Сайт) рядом с чекбоксом региона.
   Здесь .cs НЕ должен быть полноширинным блоком — иначе перекрывает название региона.
   Делаем компактным инлайн-дропдауном, прижатым вправо в строке региона. */
.regions-box .reg-check .cs { display: inline-flex; width: auto; flex-shrink: 0; vertical-align: middle; }
.regions-box .reg-check .cs-trigger {
  min-width: 84px; min-height: 0; padding: 4px 8px; font-size: 12px; border-radius: 6px;
}

/* =====================================================================
   Редизайн (shadcn/ui + Lucide): дополнительные компоненты страниц
   ===================================================================== */
/* Крупная кнопка и «тихая» кнопка удаления (ghost + красный) */
.btn-lg { min-height: 42px; padding: 9px 20px; font-size: 14.5px; font-weight: 600; border-radius: var(--radius-md); }
.btn-lg .i { font-size: 18px; }
:where(button).btn-ghost-danger { background: transparent; color: var(--bad-text); border-color: transparent; box-shadow: none; }
:where(button.btn-ghost-danger:not(:disabled)):hover { background: color-mix(in srgb, var(--bad) 13%, transparent); }
.murojaat-link { display: inline-block; }

/* Иконка-плашка у заголовка карточки */
.card-ico {
  width: 38px; height: 38px; flex-shrink: 0; display: grid; place-items: center; border-radius: 10px;
  font-size: 18px; color: var(--accent); background: color-mix(in srgb, var(--accent) 13%, transparent);
}

/* Цифры-предупреждения в таблицах */
.num-bad { color: var(--bad-text); font-weight: 650; }
.sort-ico { font-size: 13px; margin-left: 4px; color: var(--accent); vertical-align: -2px; }

/* Поле поиска с иконкой внутри (вне формы входа) */
.controls .input-wrap { width: 100%; }
/* Кнопки в строке фильтров — той же высоты, что поля */
.controls .field > button.btn-sm { min-height: 36px; padding: 7px 12px; font-size: 13.5px; }
/* Широкие таблицы без собственной обёртки прокручиваются внутри карточки */
.card:has(> table.users-table) { overflow-x: auto; }
.controls .input-wrap > input { width: 100%; }

/* Бейджи графика на сегодня (профиль оператора) */
.ts-badge { display: inline-flex; align-items: center; gap: 7px; }
.ts-badge .i { font-size: 15px; }

/* Чат: заголовок, действия сообщения, выбор участников, панели ответа/правки */
#chat-title, .news-title { display: inline-flex; align-items: center; gap: 8px; }
#chat-title .i, .news-title .i { color: var(--muted); font-size: 17px; }
.conv-row .conv-name .i { color: var(--muted); font-size: 16px; }
.conv-row.active .conv-name .i, #room-news.news-active .conv-name .i { color: var(--accent); }
.chat-header-actions .input-wrap > .i { left: 10px; font-size: 14px; }
#chat-search { padding-left: 32px; }
.msg-actions button { display: inline-flex; align-items: center; justify-content: center; min-height: 0; width: 28px; height: 26px; padding: 0; font-size: 15px; box-shadow: none; }
.msg-actions button.danger:hover { color: var(--bad-text); }
.msg-reply { display: flex; align-items: center; gap: 5px; }
.msg-reply .i { flex-shrink: 0; font-size: 13px; opacity: .8; }
.bubble.deleted .msg-body { display: inline-flex; align-items: center; gap: 6px; }
.user-pick-row .pick-name { display: inline-flex; align-items: center; gap: 9px; }
.user-pick-row .pick-name .i { font-size: 16px; color: var(--muted); }
.user-pick-row .pick-name .i.pick-on { color: var(--accent); }
.bar-text { display: inline-flex; align-items: center; gap: 7px; min-width: 0; }
.bar-text .i { color: var(--accent); flex-shrink: 0; }
#scroll-down-btn { display: inline-flex; align-items: center; gap: 6px; }
#scroll-down-btn[hidden] { display: none; }
.chat-form #attach-btn .i { font-size: 18px; }
.file-chip .i { color: var(--muted); }
.file-chip-pending .fc-ico { display: grid; place-items: center; width: 32px; height: 32px; border-radius: 6px; background: var(--hover); color: var(--muted); font-size: 16px; }
.file-chip-pending .fc-del { display: inline-flex; align-items: center; min-height: 0; font-size: 14px; box-shadow: none; }
@media (max-width: 600px) { .send-label { display: none; } }

/* Новости: кнопки «Ознакомлен», «Комментарии» и т.п. с иконками */
.comments-toggle { display: inline-flex; align-items: center; gap: 6px; min-height: 0; box-shadow: none; }
.ack-btn { display: inline-flex; align-items: center; gap: 6px; }
.ack-section b { display: flex; align-items: center; gap: 6px; }

/* Мини-таблица графика (Настройки → «Мой график на месяц») */
.mini-schedule { border-collapse: collapse; width: 100%; font-size: 12.5px; }
.mini-schedule th, .mini-schedule td { border: 1px solid var(--border); padding: 6px 4px; text-align: center; min-width: 34px; height: auto; }
.mini-schedule th { background: var(--card-2); color: var(--muted); font-weight: 500; }
.mini-schedule .ms-label { font-weight: 600; text-align: left; padding: 6px 10px; color: var(--muted); }

/* Пустое состояние / загрузка внутри ячейки таблицы: остаётся table-cell (иначе ломается colspan) */
td.empty-state, td.loading { display: table-cell; text-align: center; vertical-align: middle; padding: 44px 20px; }
td.empty-state .empty-state-icon { margin: 0 auto 10px; }
td.empty-state p { margin: 4px auto 0; color: var(--muted); }
td.empty-state p.empty-state-title { color: var(--text); font-weight: 600; font-size: 15px; }
td.loading .spinner { margin-right: 8px; }

/* =====================================================================
   Рабочая область «как у входа»: фирменный фон Узтелеком (волны) под
   тонировкой + стеклянные карточки/KPI. Модалки и выпадашки — плотные.
   ===================================================================== */
:root {
  --app-bg: linear-gradient(135deg, #060e24 0%, #0a1838 50%, #071a2c 100%);
  --app-logo-color: #60a5fa;
  --app-logo-opacity: .26;
  --glass-bg: rgba(22,30,56,.5);
  --glass-border: rgba(255,255,255,.1);
  --glass-hi: rgba(255,255,255,.07);
}
[data-theme="light"] {
  --app-bg: linear-gradient(135deg, #e8f0fd 0%, #f2f7ff 50%, #e6f3fb 100%);
  --app-logo-color: #2563eb;
  --app-logo-opacity: .24;
  --glass-bg: rgba(255,255,255,.5);
  --glass-border: rgba(255,255,255,.85);
  --glass-hi: rgba(255,255,255,.9);
}
.app-main { position: relative; isolation: isolate; background: var(--app-bg) fixed; }
/* Логотип-волны Узтелеком (вырезаны из фото: app/static/img/uztelecom-waves.png) — чёткий
   водяной знак фирменного синего, компактно по центру рабочей области, не двигается при прокрутке. */
.app-main::before {
  content: ""; position: fixed; z-index: -1; pointer-events: none;
  top: var(--topbar-h); right: 0; bottom: 0; left: var(--sidebar-w);
  background: var(--app-logo-color);
  -webkit-mask: url("../img/uztelecom-waves.png") center / min(280px, 34vh) no-repeat;
          mask: url("../img/uztelecom-waves.png") center / min(280px, 34vh) no-repeat;
  opacity: var(--app-logo-opacity);
}
@media (min-width: 1025px) { [data-sidebar="collapsed"] .app-main::before { left: var(--sidebar-w-collapsed); } }
@media (max-width: 1024px) { .app-main::before { left: 0; } }
.card, .kpi, .chat-sidebar, .chat-main, #news-panel, .ops-summary {
  border-color: var(--glass-border);
  box-shadow: inset 0 1px 0 var(--glass-hi);   /* без размытия — знак за панелями виден чётко */
}
.card, .chat-sidebar, .chat-main, #news-panel, .ops-summary { background: var(--glass-bg); }
.kpi { background: linear-gradient(to top, color-mix(in srgb, var(--kpi-c) 10%, transparent) 0%, transparent 72%), var(--glass-bg); }
.kpi-link:hover { box-shadow: inset 0 1px 0 var(--glass-hi), var(--shadow-md); }
/* Шапка таблиц в стеклянных карточках — тоже полупрозрачная (у графика шапка «липкая» —
   ей оставляем плотный фон, иначе при прокрутке сквозь неё видны строки). */
.card table:not(.schedule-table) thead th { background: color-mix(in srgb, var(--card-2) 50%, transparent); }
/* Логотип в боковом меню — та же «кардиограмма», что на входе: по тусклой линии бежит импульс
   (копию пути с классом pulse-trace добавляет api.js). Работает и при «уменьшить движение». */
.sb-logo .i { overflow: visible; filter: drop-shadow(0 0 2px rgba(255,255,255,.55)); }
.sb-logo .pulse-base { opacity: .35; }
.sb-logo .pulse-trace {
  stroke-dasharray: 34px 126px; stroke-dashoffset: 0px;
  animation: lg-pulse-run 2.4s linear infinite;
}
@media (prefers-reduced-motion: reduce) { .sb-logo .pulse-trace { animation-duration: 2.4s !important; } }

/* --- Профиль: время работы и перерывы (колл-центр) --- */
#worktime-card .wt-stats { margin-top: 4px; }
#worktime-card .wt-note { margin: 10px 0 12px; font-size: 12.5px; line-height: 1.5; }
#worktime-card .wt-table { width: 100%; }
#worktime-card .wt-table td, #worktime-card .wt-table th { white-space: nowrap; }
.pstat-value.bad-text { color: var(--bad-text); }
.pstat-value.ok-text { color: var(--ok-text); }
.break-norms-table { max-width: 760px; }
.break-norms-table input { width: 110px; }
.break-norms-table .bn-shifts .badge { margin: 2px 0; }
/* Переключатель «Перерыв и время работы» для Excel-выгрузки: выкл — как ghost, вкл — синий */
.export-toggle {
  display: inline-flex; align-items: center; gap: 6px; white-space: nowrap;
  background: transparent; color: var(--muted); border: 1px dashed var(--border); box-shadow: none;
}
.export-toggle:hover { color: var(--text); border-color: var(--accent); background: color-mix(in srgb, var(--accent) 8%, transparent); }
.export-toggle .et-on { display: none; }
.export-toggle[aria-pressed="true"] {
  color: #fff; border: 1px solid transparent;
  background: linear-gradient(135deg, #2563eb, #0ea5e9);
}
.export-toggle[aria-pressed="true"] .et-on { display: inline-flex; }
.export-toggle[aria-pressed="true"] .et-off { display: none; }
.export-toggle-hint { display: flex; align-items: center; gap: 5px; margin-top: 6px; font-size: 12px; color: var(--accent); }
.export-toggle-hint[hidden] { display: none; }
.users-table tr.user-off td { opacity: .55; }
.users-table tr.user-off td:last-child { opacity: 1; }
