/* ═══════════════════════════════════════════════════════════════════════════
   MODERN — альтернативная дизайн-система CRM (в духе Linear / Vercel).

   Включается атрибутом  <html data-ui-style="modern">  (окно «Цветовая тема»).
   ВСЁ в этом файле начинается с html[data-ui-style="modern"] — при classic
   (по умолчанию) файл не действует, старая вёрстка не меняется.

   Оси:  data-ui-style = classic | modern   (геометрия, поверхности, шрифт)
         data-theme    = dark | light       (нейтральная палитра --m-*)
         --accent-h/s/l                     (акцент, общий для обоих стилей)

   Принципы modern:
     • Каркас: сайдбар «вклеен» в край окна (без парящей карточки),
       контент — одна вдавленная панель с волосяной рамкой (Linear).
     • Слои тоном, а не тенями: page → panel → card (#0b0b0e → #0f0f12 → #16161b).
     • Радиусы 4–8px, рамки 1px, никаких свечений / градиентов / blur.
     • Типографика: Inter + JetBrains Mono для меток, цифр, kbd.
     • Акцент — точечно и ярко: активные пункты, основные кнопки, фокус, «сегодня».

   Специфичность: html[data-ui-style] (0,1,1) + компонент. sidebar.css подключается
   ПОСЛЕ этого файла — выигрываем специфичностью. Светлые: …[data-theme="light"].
   ═══════════════════════════════════════════════════════════════════════════ */

/* ═════════════════════════ 1. Токены ═════════════════════════ */

html[data-ui-style="modern"] {
  /* Нейтрали — тёмный режим */
  --m-page: #0b0b0e;          /* фон окна и сайдбара */
  --m-panel: #0e0e12;         /* рабочая панель */
  --m-card: #121216;          /* карточки, поповеры */
  --m-card-2: #1a1a21;        /* наведение, активные зоны */
  --m-hover: rgba(255, 255, 255, 0.045);
  --m-press: rgba(255, 255, 255, 0.08);
  --m-line: rgba(255, 255, 255, 0.07);
  --m-line-strong: rgba(255, 255, 255, 0.12);
  --m-text: #ededef;
  --m-text-2: #a0a0ab;
  --m-text-3: #6b6b76;
  --m-scrim: rgba(0, 0, 0, 0.6);

  /* Акцент: производные от выбранного цвета */
  --m-accent: var(--accent);
  --m-accent-hover: var(--accent-hover);
  --m-accent-fill: hsl(var(--accent-h) var(--accent-s) var(--accent-l) / 0.14);
  --m-accent-fill-2: hsl(var(--accent-h) var(--accent-s) var(--accent-l) / 0.22);
  --m-accent-line: hsl(var(--accent-h) var(--accent-s) var(--accent-l) / 0.55);
  --m-accent-text: hsl(var(--accent-h) var(--accent-s) calc(var(--accent-l) + 12%));
  --m-ring: 0 0 0 3px hsl(var(--accent-h) var(--accent-s) var(--accent-l) / 0.25);

  /* Геометрия */
  --m-r-xs: 4px;
  --m-r-sm: 6px;
  --m-r: 8px;
  --m-r-lg: 10px;
  --m-h-ctl: 32px;            /* высота кнопок / инпутов */

  /* Глубина — только для всплывающих слоёв */
  --m-pop: 0 0 0 1px var(--m-line-strong), 0 12px 32px rgba(0, 0, 0, 0.5);
  --m-pop-soft: 0 12px 32px rgba(0, 0, 0, 0.4);

  /* Шрифты */
  --m-font: "Inter", "Segoe UI", system-ui, -apple-system, sans-serif;
  --m-mono: "JetBrains Mono", ui-monospace, "SFMono-Regular", Menlo, Consolas, monospace;
  --m-ease: cubic-bezier(0.2, 0, 0, 1);
  --m-fast: 120ms;

  /* Мост в легаси-переменные crm.css */
  --bg0: var(--m-page);
  --bg1: var(--m-panel);
  --bg2: var(--m-card);
  --line: var(--m-line);
  --text: var(--m-text);
  --muted: var(--m-text-2);
  --radius: var(--m-r);
  --shadow: none;
  --font: var(--m-font);

  /* Публичные алиасы (для новых компонентов) */
  --bg-app: var(--m-page);
  --bg-surface: var(--m-card);
  --bg-hover: var(--m-card-2);
  --border-color: var(--m-line);
  --accent-color: var(--accent);
  --accent-glow: var(--m-accent-fill);

  accent-color: var(--accent);
}

html[data-ui-style="modern"][data-theme="light"] {
  --m-page: #f8f9fa;
  --m-panel: #ffffff;
  --m-card: #ffffff;
  --m-card-2: #f1f3f5;
  --m-hover: rgba(0, 0, 0, 0.035);
  --m-press: rgba(0, 0, 0, 0.06);
  --m-line: rgba(0, 0, 0, 0.07);
  --m-line-strong: rgba(0, 0, 0, 0.12);
  --m-text: #111113;
  --m-text-2: #5c5c66;
  --m-text-3: #9a9aa3;
  --m-scrim: rgba(0, 0, 0, 0.3);
  --m-accent-fill: hsl(var(--accent-h) var(--accent-s) var(--accent-l) / 0.1);
  --m-accent-fill-2: hsl(var(--accent-h) var(--accent-s) var(--accent-l) / 0.16);
  --m-accent-text: hsl(var(--accent-h) var(--accent-s) calc(var(--accent-l) - 8%));
  --m-pop: 0 0 0 1px var(--m-line-strong), 0 12px 32px rgba(0, 0, 0, 0.1);
  --m-pop-soft: 0 12px 32px rgba(0, 0, 0, 0.08);
}

/* Острова на Tailwind: тёмные нейтрали палитры (slate/gray/zinc/neutral 700–950)
   → нейтрали modern. Только тёмный режим: в светлом их перекрывают light.css островов. */
html[data-ui-style="modern"]:not([data-theme="light"]) {
  --color-slate-950: #0b0b0e; --color-gray-950: #0b0b0e; --color-zinc-950: #0b0b0e; --color-neutral-950: #0b0b0e;
  --color-slate-900: #121216; --color-gray-900: #121216; --color-zinc-900: #121216; --color-neutral-900: #121216;
  --color-slate-800: #1a1a21; --color-gray-800: #1a1a21; --color-zinc-800: #1a1a21; --color-neutral-800: #1a1a21;
  --color-slate-700: #2a2a33; --color-gray-700: #2a2a33; --color-zinc-700: #2a2a33; --color-neutral-700: #2a2a33;
}

/* Модальные окна (общие): затемнение с размытием, тонкая рамка вместо тяжёлой тени */
html[data-ui-style="modern"] dialog::backdrop {
  background: var(--m-scrim);
  backdrop-filter: blur(8px) !important;   /* css/ac-perf.css глушит blur глобально — подложке модалки разрешаем */
  -webkit-backdrop-filter: blur(8px) !important;
}

html[data-ui-style="modern"] :is(input[type="checkbox"], input[type="radio"], input[type="range"], progress) {
  accent-color: var(--accent);
}

html[data-ui-style="modern"] .crm-app :is(input, textarea) {
  caret-color: var(--accent);
}

/* ═════════════════════════ 2. База ═════════════════════════ */

html[data-ui-style="modern"],
html[data-ui-style="modern"] body {
  background: var(--m-page);
  background-image: none;
  font-family: var(--m-font);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

html[data-ui-style="modern"] ::selection {
  background: var(--m-accent-fill-2);
  color: inherit;
}

/* Шрифт для всего контента, включая React-острова (иконки и моно — не трогаем) */
html[data-ui-style="modern"] .crm-app :where(*):not(i, svg, svg *, code, pre, kbd, samp, .font-mono, [class*="fa-"]) {
  font-family: var(--m-font);
}

html[data-ui-style="modern"] .crm-app :is(code, pre, kbd, samp) {
  font-family: var(--m-mono);
}

html[data-ui-style="modern"] .crm-app :is(td, th, time) {
  font-variant-numeric: tabular-nums;
}

/* Скроллбары — тонкие, без дорожки */
html[data-ui-style="modern"] .crm-app,
html[data-ui-style="modern"][data-theme="light"] .crm-app {
  background-color: var(--m-page);
  background-image: none;
  scrollbar-width: thin;
  scrollbar-color: var(--m-line-strong) transparent;
}

html[data-ui-style="modern"] .crm-app *::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}

html[data-ui-style="modern"] .crm-app *::-webkit-scrollbar-track,
html[data-ui-style="modern"] .crm-app *::-webkit-scrollbar-corner {
  background: transparent;
}

html[data-ui-style="modern"] .crm-app *::-webkit-scrollbar-thumb {
  background: var(--m-line-strong);
  border: 2px solid transparent;
  background-clip: padding-box;
  border-radius: 99px;
}

/* Острова (Tailwind): «пухлые» скругления → строгие */
html[data-ui-style="modern"] .crm-main__surface :is(.rounded-2xl, .rounded-3xl) {
  border-radius: var(--m-r-lg);
}

html[data-ui-style="modern"] .crm-main__surface .rounded-xl {
  border-radius: var(--m-r);
}

/* ═════════════════════════ 3. Каркас ═════════════════════════ */

/* Десктоп: сайдбар «парит» — отступы 12px сверху, снизу и слева, зазор 12px до контента */
@media (min-width: 961px) {
  html[data-ui-style="modern"] .crm-app {
    --sidebar-pad-left: 12px;
    --crm-workspace-inset-top: 12px;
    --crm-workspace-inset-bottom: 12px;
    --crm-workspace-pad-x: 12px;
  }
}
/* Отступы самой панели сайдбара (десктоп и шторка) — crm/sidebar.modern.css */

html[data-ui-style="modern"] .crm-main__surface,
html[data-ui-style="modern"][data-theme="light"] .crm-main__surface {
  border-radius: var(--m-r-lg);
  border: 1px solid var(--m-line);
  background: var(--m-panel);
  box-shadow: none;
  backdrop-filter: none;
  -webkit-backdrop-filter: none;
}

html[data-ui-style="modern"][data-theme="light"] .crm-main__surface {
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.04);
}

/* Шапка (там, где есть) — плоская строка 44px с линией снизу */
html[data-ui-style="modern"] .crm-topbar,
html[data-ui-style="modern"][data-theme="light"] .crm-topbar {
  background: var(--m-panel);
  border-bottom: 1px solid var(--m-line);
  backdrop-filter: none;
  -webkit-backdrop-filter: none;
}

html[data-ui-style="modern"] .crm-topbar h1 {
  font-size: 14px;
  font-weight: 600;
  letter-spacing: -0.01em;
}

/* ═════════════════════════ 4. Сайдбар ═════════════════════════
   Боковое меню «Современного» стиля целиком — в crm/sidebar.modern.css
   (подключается автоматически сразу после crm/sidebar.css, см. ac_theme_output_filter).
   Здесь остаётся только подсветка фона окна, под которой «плавает» панель. */

/* Мягкая акцентная подсветка фона окна — чтобы стекло было «живым» */
html[data-ui-style="modern"] .crm-app,
html[data-ui-style="modern"][data-theme="light"] .crm-app {
  background-image:
    radial-gradient(640px 520px at 0% 0%, hsl(var(--accent-h) var(--accent-s) var(--accent-l) / 0.13), transparent 62%),
    radial-gradient(520px 480px at 0% 100%, hsl(var(--accent-h) var(--accent-s) var(--accent-l) / 0.07), transparent 60%);
}


/* ═════════════════════ 4a. Центр уведомлений (#crmNotifyPop) ═════════════════════
   Поповер колокольчика. В modern notifications_bell.js выносит его в <body> и ставит
   сбоку от панели (класс --side); на ширине ≤960px — под колокольчиком, как раньше.
   Разметка classic не меняется: шапка и тулбар раскладываются одной строкой через
   grid + display:contents. Префикс «html … body» перебивает генерированный crm.modern.css. */
html[data-ui-style="modern"] body #crmNotifyPop.crm-notify-pop {
  --np-bg: rgba(24, 24, 30, 0.94);
  --np-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.05),
    0 18px 48px -10px rgba(0, 0, 0, 0.7),
    0 2px 6px rgba(0, 0, 0, 0.35);
  width: min(360px, calc(100vw - 16px));
  max-height: min(560px, calc(100vh - 16px));
  border: 1px solid var(--m-line-strong);
  border-radius: 14px;
  background: var(--np-bg);
  backdrop-filter: blur(24px) saturate(1.5) !important;
  -webkit-backdrop-filter: blur(24px) saturate(1.5) !important;
  box-shadow: var(--np-shadow);
  color: var(--m-text);
  font-family: var(--m-font);
  font-size: 13px;
  line-height: 1.4;
  text-align: left;
  transform: translateY(-6px) scale(0.98);
  transform-origin: top center;
  transition:
    opacity 150ms var(--m-ease),
    transform 150ms var(--m-ease),
    visibility 150ms;
}

html[data-ui-style="modern"][data-theme="light"] body #crmNotifyPop.crm-notify-pop {
  --np-bg: rgba(255, 255, 255, 0.95);
  --np-shadow:
    0 18px 48px -12px rgba(15, 15, 30, 0.22),
    0 2px 6px rgba(15, 15, 30, 0.06);
  border-color: var(--m-line-strong);
}

html[data-ui-style="modern"] body #crmNotifyPop.crm-notify-pop--side {
  transform: translateX(-6px) scale(0.98);
  transform-origin: left top;
}

html[data-ui-style="modern"] body #crmNotifyPop.crm-notify-pop.is-open {
  transform: none;
}

/* Шапка: [Уведомления] [3] ········ [Прочитать всё] [×] */
html[data-ui-style="modern"] body #crmNotifyPop .crm-notify-pop__inner {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto auto;
  grid-template-rows: auto minmax(0, 1fr) auto;
  grid-template-areas:
    "title badge mark close"
    "list  list  list list"
    "foot  foot  foot foot";
  align-items: center;
  min-height: 0;
  flex: 1 1 auto;
}

html[data-ui-style="modern"] body #crmNotifyPop :is(.crm-notify-pop__topbar, .crm-notify-pop__toolbar, .crm-notify-pop__tabs, .crm-notify-pop__tab) {
  display: contents;
}

html[data-ui-style="modern"] body #crmNotifyPop .crm-notify-pop__tab::after,
html[data-ui-style="modern"] body #crmNotifyPop .crm-notify-pop__tab-label {
  display: none;
}

html[data-ui-style="modern"] body #crmNotifyPop .crm-notify-pop__title {
  grid-area: title;
  margin: 0;
  padding: 14px 0 12px 16px;
  font-family: inherit;
  font-size: 14px;
  font-weight: 600;
  letter-spacing: -0.01em;
  line-height: 20px;
  color: var(--m-text);
}

html[data-ui-style="modern"] body #crmNotifyPop .crm-notify-pop__tab-badge {
  grid-area: badge;
  justify-self: start;
  min-width: 18px;
  height: 18px;
  margin-left: 8px;
  padding: 0 6px;
  border: 0;
  border-radius: 999px;
  background: var(--m-accent);
  color: var(--accent-on, #fff);
  font-size: 10.5px;
  font-weight: 700;
  line-height: 1;
}

html[data-ui-style="modern"] body #crmNotifyPop .crm-notify-pop__mark-read {
  grid-area: mark;
  height: 28px;
  margin: 0 2px 0 8px;
  padding: 0 10px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  box-shadow: none;
  color: var(--m-accent-text);
  font-family: inherit;
  font-size: 12px;
  font-weight: 500;
  transition: background-color 150ms var(--m-ease), color 150ms var(--m-ease);
}

html[data-ui-style="modern"] body #crmNotifyPop .crm-notify-pop__mark-read:hover:not(:disabled) {
  background: var(--m-accent-fill);
  border-color: transparent;
  color: var(--m-accent-text);
}

html[data-ui-style="modern"] body #crmNotifyPop .crm-notify-pop__mark-read:disabled {
  opacity: 1;
  background: transparent;
  border-color: transparent;
  color: var(--m-text-3);
}

html[data-ui-style="modern"] body #crmNotifyPop .crm-notify-pop__mark-read:focus-visible,
html[data-ui-style="modern"] body #crmNotifyPop .crm-notify-pop__close:focus-visible,
html[data-ui-style="modern"] body #crmNotifyPop .crm-notify-pop__clear:focus-visible,
html[data-ui-style="modern"] body #crmNotifyPop .crm-notify-pop__item:focus-visible {
  outline: none;
  box-shadow: var(--m-ring);
}

html[data-ui-style="modern"] body #crmNotifyPop .crm-notify-pop__close {
  grid-area: close;
  width: 28px;
  height: 28px;
  margin-right: 10px;
  border-radius: 8px;
  color: var(--m-text-3);
  font-size: 13px;
}

html[data-ui-style="modern"] body #crmNotifyPop .crm-notify-pop__close:hover {
  background: var(--m-hover);
  color: var(--m-text);
}

/* Список */
html[data-ui-style="modern"] body #crmNotifyPop .crm-notify-pop__list {
  grid-area: list;
  align-self: stretch;
  min-height: 0;
  max-height: 440px;
  padding: 6px;
  border-top: 1px solid var(--m-line);
  scrollbar-color: var(--m-line-strong) transparent;
}

html[data-ui-style="modern"] body #crmNotifyPop .crm-notify-pop__item {
  display: grid;
  grid-template-columns: 32px minmax(0, 1fr) 8px;
  align-items: start;
  gap: 10px;
  padding: 9px 10px;
  border: 0;
  border-radius: 10px;
  color: var(--m-text);
  opacity: 1;
  transition: background-color 150ms var(--m-ease);
}

html[data-ui-style="modern"] body #crmNotifyPop .crm-notify-pop__item + .crm-notify-pop__item {
  margin-top: 2px;
}

html[data-ui-style="modern"] body #crmNotifyPop .crm-notify-pop__item:hover {
  background: var(--m-hover);
  opacity: 1;
}

html[data-ui-style="modern"] body #crmNotifyPop .crm-notify-pop__item--unread::after {
  content: "";
  align-self: center;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--m-accent);
}

html[data-ui-style="modern"] body #crmNotifyPop .crm-notify-pop__item-avatar {
  width: 32px;
  height: 32px;
  border: 0;
  border-radius: 9px;
  background: var(--m-accent-fill);
  color: var(--m-accent-text);
  font-size: 13px;
}

html[data-ui-style="modern"] body #crmNotifyPop .crm-notify-pop__item-avatar::after {
  content: none;
}

html[data-ui-style="modern"] body #crmNotifyPop .crm-notify-pop__item--read .crm-notify-pop__item-avatar {
  background: var(--m-card-2);
  border: 0;
  color: var(--m-text-3);
}

html[data-ui-style="modern"] body #crmNotifyPop .crm-notify-pop__item-body {
  gap: 2px;
  padding-top: 0;
}

html[data-ui-style="modern"] body #crmNotifyPop .crm-notify-pop__item-msg {
  font-size: 13px;
  font-weight: 500;
  line-height: 1.4;
  color: var(--m-text);
  overflow-wrap: anywhere;
}

html[data-ui-style="modern"] body #crmNotifyPop .crm-notify-pop__item--read .crm-notify-pop__item-msg {
  font-weight: 400;
  color: var(--m-text-2);
}

html[data-ui-style="modern"] body #crmNotifyPop .crm-notify-pop__item-meta,
html[data-ui-style="modern"] body #crmNotifyPop .crm-notify-pop__item--read .crm-notify-pop__item-meta {
  font-size: 11.5px;
  font-weight: 400;
  color: var(--m-text-3);
}

/* Пустое состояние */
html[data-ui-style="modern"] body #crmNotifyPop .crm-notify-pop__empty {
  padding: 32px 20px 34px;
}

html[data-ui-style="modern"] body #crmNotifyPop .crm-notify-pop__empty-icon {
  width: 40px;
  height: 40px;
  margin-bottom: 10px;
  border-radius: 12px;
  background: var(--m-card-2);
  color: var(--m-text-3);
  font-size: 16px;
}

html[data-ui-style="modern"] body #crmNotifyPop .crm-notify-pop__empty-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--m-text);
}

html[data-ui-style="modern"] body #crmNotifyPop .crm-notify-pop__empty-hint {
  margin-top: 4px;
  font-size: 12px;
  color: var(--m-text-3);
}

/* Подвал */
html[data-ui-style="modern"] body #crmNotifyPop .crm-notify-pop__foot {
  grid-area: foot;
  padding: 6px;
  border-top: 1px solid var(--m-line);
  background: transparent;
}

html[data-ui-style="modern"] body #crmNotifyPop .crm-notify-pop__clear {
  height: 32px;
  padding: 0 12px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--m-text-2);
  font-family: inherit;
  font-size: 12.5px;
  font-weight: 500;
  letter-spacing: 0;
  transition: background-color 150ms var(--m-ease), color 150ms var(--m-ease);
}

html[data-ui-style="modern"] body #crmNotifyPop .crm-notify-pop__clear i {
  font-size: 12px;
}

html[data-ui-style="modern"] body #crmNotifyPop .crm-notify-pop__clear:hover {
  background: rgba(248, 113, 113, 0.1);
  border-color: transparent;
  color: #f87171;
}

html[data-ui-style="modern"][data-theme="light"] body #crmNotifyPop .crm-notify-pop__clear:hover {
  background: rgba(220, 38, 38, 0.07);
  color: #dc2626;
}

/* ═════════════════════ 5. Кнопки и контролы ═════════════════════ */

html[data-ui-style="modern"] :is(.crm-btn, .cc-btn) {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  height: var(--m-h-ctl);
  padding: 0 12px;
  border-radius: var(--m-r-sm);
  border: 1px solid var(--m-line-strong);
  background: var(--m-card);
  color: var(--m-text);
  font-size: 13px;
  font-weight: 500;
  box-shadow: none;
  filter: none;
  transform: none;
  transition: background var(--m-fast) var(--m-ease), border-color var(--m-fast) var(--m-ease);
}

html[data-ui-style="modern"] :is(.crm-btn, .cc-btn):hover {
  filter: none;
  transform: none;
  box-shadow: none;
  background: var(--m-card-2);
  border-color: var(--m-text-3);
}

html[data-ui-style="modern"] :is(.crm-btn, .cc-btn):active {
  transform: translateY(1px);
  background: var(--m-press);
}

html[data-ui-style="modern"] :is(.crm-btn, .cc-btn):focus-visible {
  outline: none;
  border-color: var(--m-accent);
  box-shadow: var(--m-ring);
}

/* Основная — сплошной акцент */
html[data-ui-style="modern"] :is(.crm-btn.primary, .cc-btn--primary) {
  border-color: transparent;
  background: var(--m-accent);
  color: var(--accent-on);
}

html[data-ui-style="modern"] :is(.crm-btn.primary, .cc-btn--primary):hover {
  border-color: transparent;
  background: var(--m-accent-hover);
}

html[data-ui-style="modern"] :is(.crm-btn.primary, .cc-btn--primary):active {
  background: var(--accent-pressed);
}

html[data-ui-style="modern"] :is(.crm-btn--ghost, .cc-btn--ghost) {
  border-color: transparent;
  background: transparent;
}

html[data-ui-style="modern"] :is(.crm-btn--ghost, .cc-btn--ghost):hover {
  border-color: transparent;
  background: var(--m-hover);
}

html[data-ui-style="modern"] .cc-btn--sm {
  height: 28px;
  padding: 0 10px;
  font-size: 12.5px;
}

html[data-ui-style="modern"] .crm-chip {
  border-radius: var(--m-r-xs);
  border-color: var(--m-line);
  background: transparent;
  font-family: var(--m-mono);
  font-size: 11px;
}

/* ═════════════════════ 6. Главная (дашборд) ═════════════════════
   Плоско и тихо: без теней и подложек у заголовка, сводка — одна полоса с разделителями,
   виджеты — рамки 1px, строки разделены линиями. Разметка общая с classic (crm/home.css). */

html[data-ui-style="modern"] .achome,
html[data-ui-style="modern"][data-theme="light"] .achome {
  --ah-card: var(--m-card);
  --ah-card-hover: var(--m-card-2);
  --ah-sunken: var(--m-card-2);
  --ah-hover: var(--m-hover);
  --ah-border: var(--m-line);
  --ah-border-strong: var(--m-line-strong);
  --ah-text: var(--m-text);
  --ah-muted: var(--m-text-2);
  --ah-dim: var(--m-text-3);
  --ah-primary: var(--m-accent);
  --ah-primary-2: var(--m-accent-text);
  --ah-soft: var(--m-accent-fill);
  --ah-radius: 12px;
  --ah-radius-sm: 8px;
  --ah-shadow: none;
  font-family: var(--m-font);
}

html[data-ui-style="modern"] .achome__inner {
  max-width: 1180px;
  padding: 32px clamp(16px, 3vw, 40px) 64px;
  gap: 24px;
}

/* Заголовок */
html[data-ui-style="modern"] .ah-head {
  align-items: center;
  padding-bottom: 0;
}

html[data-ui-style="modern"] .ah-head__meta {
  margin-bottom: 8px;
  font-family: var(--m-mono);
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--m-text-3);
}

html[data-ui-style="modern"] .ah-head__title {
  font-size: 24px;
  font-weight: 600;
  letter-spacing: -0.025em;
}

html[data-ui-style="modern"] .ah-head__name {
  color: var(--m-text);
  background: none;
  -webkit-text-fill-color: currentColor;
  animation: none;
}

/* Анимации — общие из crm/home.css; в modern короче и без «подпрыгивания» плиток сводки */
html[data-ui-style="modern"] .ah-in {
  animation-duration: 520ms;
}

html[data-ui-style="modern"] .ah-stat:active {
  transform: none;
}

/* Поиск */
html[data-ui-style="modern"] .ah-search {
  flex-basis: 340px;
}

html[data-ui-style="modern"] .ah-search__input {
  height: var(--m-h-ctl);
  padding-left: 34px;
  border-radius: var(--m-r);
  background: var(--m-card);
  font-size: 13px;
}

html[data-ui-style="modern"] .ah-search__icon {
  left: 11px;
  width: 15px;
  height: 15px;
}

html[data-ui-style="modern"] .ah-search__input:focus {
  border-color: var(--m-accent);
  box-shadow: var(--m-ring);
}

html[data-ui-style="modern"] .ah-search__kbd {
  height: 18px;
  min-width: 18px;
  border-color: var(--m-line-strong);
  border-radius: var(--m-r-xs);
  background: transparent;
  font-family: var(--m-mono);
  font-size: 10.5px;
}

html[data-ui-style="modern"] .ah-search__results {
  padding: 4px;
  border-color: var(--m-line-strong);
  border-radius: var(--m-r-lg);
  background: var(--m-card);
  box-shadow: var(--m-pop);
}

html[data-ui-style="modern"] .ah-res {
  padding: 7px 8px;
  border-radius: var(--m-r-sm);
}

html[data-ui-style="modern"] .ah-res__ico {
  flex-basis: 24px;
  width: 24px;
  height: 24px;
  border-radius: var(--m-r-sm);
  background: var(--m-card-2);
  color: var(--m-text-2);
}

html[data-ui-style="modern"] .ah-res.is-active .ah-res__ico {
  background: var(--m-accent-fill);
  color: var(--m-accent-text);
}

html[data-ui-style="modern"] .ah-res__title {
  font-size: 13px;
}

/* Сводка — одна полоса */
html[data-ui-style="modern"] .ah-stats {
  gap: 1px;
  overflow: hidden;
  border: 1px solid var(--m-line);
  border-radius: var(--ah-radius);
  background: var(--m-line);
}

html[data-ui-style="modern"] .ah-stat {
  gap: 4px;
  padding: 16px 20px;
  border: 0;
  border-radius: 0;
  background: var(--m-card);
  box-shadow: none;
  transform: none;
}

html[data-ui-style="modern"] .ah-stat:hover {
  background: var(--m-card-2);
  transform: none;
}

html[data-ui-style="modern"] .ah-stat__label {
  font-size: 12.5px;
  color: var(--m-text-2);
}

html[data-ui-style="modern"] .ah-stat__value {
  font-size: 28px;
  font-weight: 600;
  letter-spacing: -0.03em;
}

html[data-ui-style="modern"] .ah-stat__note {
  font-size: 12px;
}

/* Виджеты */
html[data-ui-style="modern"] .ah-grid,
html[data-ui-style="modern"] .ah-grid__main {
  gap: 16px;
}

html[data-ui-style="modern"] .ah-panel {
  padding: 0;
  overflow: hidden;
  background: var(--m-card);
}

html[data-ui-style="modern"] .ah-panel__head {
  min-height: 44px;
  box-sizing: border-box;
  padding: 0 16px;
  border-bottom: 1px solid var(--m-line);
}

html[data-ui-style="modern"] .ah-panel__title {
  font-size: 13.5px;
  font-weight: 600;
}

html[data-ui-style="modern"] .achome .ah-panel__link {
  font-size: 12px;
  color: var(--m-text-2);
}

html[data-ui-style="modern"] .achome .ah-panel__link:hover {
  color: var(--m-accent-text);
  text-decoration: none;
}

html[data-ui-style="modern"] .ah-list > li + li,
html[data-ui-style="modern"] .ah-feed > li + li {
  border-top: 1px solid var(--m-line);
}

html[data-ui-style="modern"] .ah-row {
  min-height: 46px;
  padding: 8px 16px;
  border-radius: 0;
}

html[data-ui-style="modern"] .ah-row__title {
  font-size: 13.5px;
}

html[data-ui-style="modern"] .ah-row__check {
  border-width: 1.5px;
  border-color: var(--m-line-strong);
}

html[data-ui-style="modern"] .ah-due,
html[data-ui-style="modern"] .ah-badge {
  padding: 2px 7px;
  border-radius: var(--m-r-xs);
  font-size: 11.5px;
  font-weight: 500;
}

html[data-ui-style="modern"] .ah-due--none {
  font-family: var(--m-mono);
  font-size: 11px;
}

html[data-ui-style="modern"] .ah-empty {
  padding: 16px;
  font-size: 13px;
}

html[data-ui-style="modern"] .ah-feed__link {
  padding: 10px 16px 10px 32px;
  border-radius: 0;
}

html[data-ui-style="modern"] .ah-feed__link::before {
  left: 16px;
  top: 17px;
  width: 6px;
  height: 6px;
}

html[data-ui-style="modern"] .ah-feed__time {
  font-family: var(--m-mono);
  font-size: 11px;
}

/* Разделы — список без плашек */
html[data-ui-style="modern"] .ah-apps__title {
  margin: 8px 0 10px;
  font-family: var(--m-mono);
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.06em;
  color: var(--m-text-3);
}

html[data-ui-style="modern"] .ah-apps__grid {
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 4px;
}

html[data-ui-style="modern"] .ah-app {
  padding: 8px 10px;
  border-color: transparent;
  border-radius: var(--m-r);
  background: transparent;
}

html[data-ui-style="modern"] .ah-app:hover {
  border-color: var(--m-line);
  background: var(--m-card);
}

html[data-ui-style="modern"] .ah-app__icon {
  flex-basis: 28px;
  width: 28px;
  height: 28px;
  border: 1px solid var(--m-line);
  border-radius: var(--m-r);
  background: var(--m-card);
  color: var(--m-text-2);
}

html[data-ui-style="modern"] .ah-app:hover .ah-app__icon {
  border-color: var(--m-accent-line);
  color: var(--m-accent-text);
}

html[data-ui-style="modern"] .ah-app__icon svg {
  width: 15px;
  height: 15px;
}

html[data-ui-style="modern"] .ah-app__title {
  font-size: 13px;
  color: var(--m-text-2);
}

html[data-ui-style="modern"] .ah-app:hover .ah-app__title {
  color: var(--m-text);
}

@media (max-width: 640px) {
  html[data-ui-style="modern"] .ah-stats {
    grid-template-columns: repeat(auto-fit, minmax(96px, 1fr));
    gap: 1px;
  }

  html[data-ui-style="modern"] .ah-stat {
    padding: 12px 14px;
  }
}

/* ═════════════════════ 7. Контент-календарь ═════════════════════ */

html[data-ui-style="modern"] .ccal,
html[data-ui-style="modern"][data-theme="light"] .ccal {
  --c-surface: var(--m-card);
  --c-card: var(--m-card);
  --c-card-solid: var(--m-panel);
  --c-border: var(--m-line);
  --c-border-strong: var(--m-line-strong);
  --c-text: var(--m-text);
  --c-muted: var(--m-text-2);
  --c-dim: var(--m-text-3);
  --c-primary: var(--m-accent);
  --c-primary-2: var(--m-accent-text);
  --c-radius: var(--m-r);
  --c-radius-md: var(--m-r);
  --c-radius-sm: var(--m-r-sm);
  --c-shadow: none;
  --c-shadow-hover: none;
}

/* Шапка и панель фильтров — плоские строки */
html[data-ui-style="modern"] .cc-hero {
  border: 0;
  border-bottom: 1px solid var(--m-line);
  border-radius: 0;
  background: transparent;
  backdrop-filter: none;
  -webkit-backdrop-filter: none;
  box-shadow: none;
}

html[data-ui-style="modern"] .cc-hero__title {
  font-size: clamp(22px, 2.4vw, 28px);
  font-weight: 600;
}

html[data-ui-style="modern"] :is(.cc-toolbar, .cc-panel) {
  background: var(--m-panel);
  backdrop-filter: none;
  -webkit-backdrop-filter: none;
  box-shadow: none;
}

/* KPI календаря — как на главной */
html[data-ui-style="modern"] .cc-kpis {
  gap: 1px;
  border: 1px solid var(--m-line);
  border-radius: var(--m-r);
  background: var(--m-card);
  overflow: hidden;
}

html[data-ui-style="modern"] .cc-kpi {
  border: 0;
  border-radius: 0;
  outline: 1px solid var(--m-line);
  background: var(--m-card);
  backdrop-filter: none;
  -webkit-backdrop-filter: none;
  box-shadow: none;
  transform: none;
}

html[data-ui-style="modern"] .cc-kpi:hover {
  background: var(--m-card-2);
  transform: none;
  box-shadow: none;
}

/* Поля ввода, поиск, селекты: чёткие рамки, фокус акцентом */
html[data-ui-style="modern"] :is(.cc-search, .cc-select, .cc-input) {
  height: var(--m-h-ctl);
  border-radius: var(--m-r-sm);
  border: 1px solid var(--m-line-strong);
  background: transparent;
  font-size: 13px;
}

html[data-ui-style="modern"] textarea.cc-input {
  height: auto;
}

html[data-ui-style="modern"] :is(.cc-search, .cc-select):focus-within,
html[data-ui-style="modern"] .cc-input:focus {
  border-color: var(--m-accent);
  box-shadow: var(--m-ring);
}

/* Сегменты (месяц / неделя / список) */
html[data-ui-style="modern"] .cc-seg {
  border-radius: var(--m-r-sm);
  background: var(--m-card);
}

html[data-ui-style="modern"] .cc-seg__btn {
  height: 26px;
  padding: 0 12px;
  border-radius: var(--m-r-xs);
  font-size: 12.5px;
  font-weight: 500;
}

html[data-ui-style="modern"] .cc-seg__thumb {
  border-radius: var(--m-r-xs);
  background: var(--m-card-2);
  box-shadow: 0 0 0 1px var(--m-line-strong);
}

/* Сетка: ячейки делят пиксельные линии */
html[data-ui-style="modern"] .cc-cal {
  border-radius: var(--m-r);
  background: var(--m-panel);
  box-shadow: none;
}

html[data-ui-style="modern"] .cc-weekdays,
html[data-ui-style="modern"][data-theme="light"] .cc-weekdays {
  background: transparent;
}

html[data-ui-style="modern"] .cc-weekdays span {
  padding: 8px 10px;
  text-align: left;
  font-family: var(--m-mono);
  font-size: 10.5px;
  font-weight: 500;
  letter-spacing: 0.06em;
}

html[data-ui-style="modern"] .cc-grid {
  padding: 0;
}

html[data-ui-style="modern"] .cc-day,
html[data-ui-style="modern"][data-theme="light"] .cc-day {
  background: var(--m-panel);
  padding: 6px;
  gap: 4px;
}

html[data-ui-style="modern"] .cc-day:hover {
  background: var(--m-card);
}

html[data-ui-style="modern"] .cc-day--out {
  background: var(--m-page);
}

html[data-ui-style="modern"] .cc-day--today {
  background: var(--m-panel);
  box-shadow: inset 0 2px 0 var(--m-accent);
}

html[data-ui-style="modern"] .cc-day__num {
  min-width: 22px;
  height: 22px;
  padding: 0 5px;
  border-radius: var(--m-r-xs);
  font-family: var(--m-mono);
  font-size: 12px;
  font-weight: 500;
}

html[data-ui-style="modern"] .cc-day--today .cc-day__num {
  background: var(--m-accent);
  color: var(--accent-on);
  box-shadow: none;
}

html[data-ui-style="modern"] .cc-day--weekend .cc-day__num {
  color: var(--m-text-3);
}

/* События: компактные плашки с цветной полосой */
html[data-ui-style="modern"] .cc-event {
  padding: 4px 6px 4px 9px;
  border-radius: var(--m-r-xs);
  border-color: var(--m-line);
  background: var(--m-card);
  box-shadow: none;
}

html[data-ui-style="modern"] .cc-event::before {
  width: 2px;
}

html[data-ui-style="modern"] .cc-event:hover {
  transform: none;
  border-color: var(--m-line-strong);
  background: var(--m-card-2);
  box-shadow: none;
}

html[data-ui-style="modern"] :is(.cc-badge, .cc-legend__item, .cc-tone) {
  border-radius: var(--m-r-xs);
}

html[data-ui-style="modern"] .cc-modal {
  border-radius: var(--m-r-lg);
}

/* ═════════════════════ 8. Окно «Цветовая тема» ═════════════════════ */

html[data-ui-style="modern"] .ac-accent-modal,
html[data-ui-style="modern"] .ac-accent-modal::backdrop {
  background: var(--m-scrim);
  backdrop-filter: blur(8px) !important;
  -webkit-backdrop-filter: blur(8px) !important;
}

html[data-ui-style="modern"] .ac-accent-modal__dialog,
html[data-ui-style="modern"][data-theme="light"] .ac-accent-modal__dialog {
  padding: 20px;
  border-radius: var(--m-r-lg);
  border: 0;
  background: var(--m-card);
  box-shadow: var(--m-pop);
  color: var(--m-text);
  font-family: var(--m-font);
  animation-duration: 140ms;
}

html[data-ui-style="modern"] .ac-accent-modal__title {
  color: var(--m-text);
  font-size: 15px;
  font-weight: 600;
  letter-spacing: -0.01em;
}

html[data-ui-style="modern"] .ac-accent-modal__sub {
  color: var(--m-text-2);
  font-size: 12.5px;
}

html[data-ui-style="modern"] .ac-accent-modal__label {
  color: var(--m-text-3);
  font-family: var(--m-mono);
  font-size: 10.5px;
  font-weight: 500;
  letter-spacing: 0.06em;
}

html[data-ui-style="modern"] .ac-accent-modal__close {
  width: 28px;
  height: 28px;
  border-radius: var(--m-r-sm);
  border-color: transparent;
  background: transparent;
  color: var(--m-text-2);
}

html[data-ui-style="modern"] .ac-accent-modal__close:hover {
  background: var(--m-hover);
}

html[data-ui-style="modern"] .ac-theme-seg,
html[data-ui-style="modern"][data-theme="light"] .ac-theme-seg {
  padding: 2px;
  gap: 2px;
  border-radius: var(--m-r-sm);
  border-color: var(--m-line);
  background: var(--m-page);
}

html[data-ui-style="modern"] .ac-theme-seg__btn {
  min-height: 30px;
  border-radius: var(--m-r-xs);
  color: var(--m-text-2);
  font-size: 12.5px;
  font-weight: 500;
}

html[data-ui-style="modern"] .ac-theme-seg__btn.is-active,
html[data-ui-style="modern"][data-theme="light"] .ac-theme-seg__btn.is-active {
  color: var(--m-text);
  border-color: var(--m-line-strong);
  background: var(--m-card-2);
  box-shadow: none;
}

html[data-ui-style="modern"] .ac-style-pick__btn {
  border-radius: var(--m-r);
}

html[data-ui-style="modern"] .ac-style-pick__btn.is-active {
  border-color: var(--m-accent);
  background: transparent;
  box-shadow: none;
}

html[data-ui-style="modern"] .ac-style-pick__check {
  border-radius: var(--m-r-xs);
}

html[data-ui-style="modern"] .ac-accent-swatch {
  border-radius: var(--m-r-sm);
}
