/* Тёплое оформление для всех рабочих разделов, кабинетов и окон CRM.
   Низкая специфичность общих правил сохраняет размеры специальных таблиц
   и мобильные раскладки. Семантические цвета статусов не переопределяются. */
.crm-theme {
  --ink: #302e2a;
  --muted: #716d65;
  --line: #eeece7;
  --accent: #b65335;
  --accent-soft: #f7ede6;
  --radius: 14px;
  --control-line: #dedad1;
}
.crm-theme .main { padding: 32px 32px 80px; }
.crm-theme .sidebar { background: #fdfcf9; }
.crm-theme .sb-header { padding-block: 24px 20px; }
.crm-theme .logo, .crm-theme .logo .workspace-title { font-weight: 500; }
.crm-theme .tabs { gap: 4px; }
.crm-theme .tab {
  display: flex; align-items: center; justify-content: flex-start; gap: 10px;
  font-weight: 400; transition: background-color 160ms ease, color 160ms ease;
}
.crm-theme .tab.active { color: var(--accent); background: var(--accent-soft); font-weight: 500; }
.crm-theme .plan-sidebar-tab::after { margin-left: auto; }
.crm-theme .workspace-switcher { border-color: transparent; }
.crm-theme .workspace-option { font-weight: 500; }
.crm-theme .notification-bell { border-color: transparent; background: transparent; }
.crm-nav-icon {
  display: block; width: 17px; height: 17px; flex: 0 0 17px;
  fill: none; stroke: currentColor; stroke-width: 1.5; stroke-linecap: round; stroke-linejoin: round;
}
.crm-page { max-width: 1540px; margin-inline: auto; line-height: 1.5; min-width: 0; }
:where(.crm-theme) .page-head { margin-bottom: 26px; }
:where(.crm-theme) .page-title {
  font-size: clamp(23px, 2.1vw, 30px); font-weight: 500; letter-spacing: -.65px;
  line-height: 1.25; margin-bottom: 10px;
}
:where(.crm-theme) .page-sub { line-height: 1.8; }
:where(.crm-theme) h2.section { font-weight: 500; }
.crm-page:not(.dashboard-page) > h2.section { font-size: 25px; letter-spacing: -.45px; margin-bottom: 22px; }
:where(.crm-theme) .card, :where(.crm-theme) .form-card {
  border-color: transparent; border-radius: 14px; padding: 22px 24px; margin-bottom: 24px;
}
:where(.crm-theme) .card h3 { font-size: 15px; font-weight: 500; }
:where(.crm-theme) .kpi { border-color: transparent; padding: 20px; }
:where(.crm-theme) .kpi .kpi-value { font-size: 30px; font-weight: 500; font-variant-numeric: tabular-nums; }
:where(.crm-theme) .kpi .kpi-label { font-size: 13px; margin-bottom: 10px; }
:where(.crm-theme) .kpi .kpi-sub { line-height: 1.6; }
/* Пунктир — признак предварительного расчёта, а не декоративная рамка. */
.crm-theme .kpi-preliminary { border-color: #c5b8a1; border-style: dashed; }
:where(.crm-theme) .form-card-title { font-weight: 500; text-transform: none; letter-spacing: 0; }
:where(.crm-theme) .form-card-value strong { font-weight: 500; }
:where(.crm-theme) th { font-weight: 500; padding-block: 13px; }
:where(.crm-theme) td { padding-block: 13px; }
:where(.crm-theme) tbody tr:hover { background: #faf9f6; }
.crm-theme :is(.btn-primary, .btn-accent, .btn-ghost, .ref-tab, .workspace-option) {
  transition: background-color 160ms ease, color 160ms ease, border-color 160ms ease, box-shadow 160ms ease;
}
:where(.crm-theme) .btn-primary { background: var(--accent); border-radius: 9px; }
:where(.crm-theme) .btn-primary:hover { background: #99452d; }
:where(.crm-theme) .btn-ghost { border-color: var(--control-line); border-radius: 9px; }
:where(.crm-theme) .btn-ghost:hover { border-color: #c9baa9; background: #f7f4ee; }
.crm-theme button:disabled { cursor: default; opacity: .55; }
.crm-theme :is(.ref-tab.active, .month-active, .fm-active, .sampling-active),
.crm-theme .territory-workspace-nav button[aria-selected="true"] {
  background: var(--accent-soft); border-color: #e7cdbf; color: #97442d;
}
.crm-theme :is(.ref-tab.active, .month-active, .fm-active, .sampling-active):hover { background: #f2e2d7; color: #97442d; }
:where(.crm-theme) .ref-tab { border-radius: 9px; padding: 9px 14px; }
:where(.crm-theme) .saved-filter-bar { background: transparent; border-color: transparent; padding-inline: 0; }
:where(.crm-theme) .saved-filter-label, :where(.crm-theme) .filters label { font-weight: 500; }
.crm-theme .filters > .muted { white-space: normal; line-height: 1.5; max-width: 100%; }
.crm-theme .sb-user > span { min-width: 0; max-width: 100%; overflow-wrap: anywhere; }
.crm-theme :is(input:not([type=checkbox]):not([type=radio]), select, textarea, .multi-combo-trigger) {
  border-color: var(--control-line); border-radius: 9px;
  transition: border-color 160ms ease, box-shadow 160ms ease;
}
.crm-theme :is(input, select, textarea):focus,
.crm-theme .multi-combo-trigger[aria-expanded='true'] {
  outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft);
}
.crm-theme :is(button, summary, a, [tabindex]):focus-visible {
  outline: 2px solid var(--accent); outline-offset: 3px;
}
.crm-theme input:is([type=checkbox], [type=radio]) { accent-color: var(--accent); }
.crm-theme :is(.combo-list, .multi-combo-panel) {
  border-color: var(--control-line); box-shadow: 0 10px 28px #352c2112;
}
:where(.crm-theme) .collapse { border-top: 1px solid var(--line); margin-block: 24px; }
:where(.crm-theme) .collapse > summary { font-size: 15px; font-weight: 500; padding: 16px 0; }
:where(.crm-theme) .collapse > summary::before {
  content: '›'; display: inline-block; margin-right: 10px; font-size: 20px; line-height: 1;
  vertical-align: -1px; transition: transform 200ms ease;
}
:where(.crm-theme) .collapse[open] > summary::before { content: '›'; transform: rotate(90deg); }
:where(.crm-theme) .plan-ranking-dropdown, :where(.crm-theme) .territory-workspace-filters,
:where(.crm-theme) .territory-workspace-card { border-color: transparent; border-radius: 14px; }
.crm-theme .plan-ranking-dropdown { padding: 0; }
.crm-theme .plan-ranking-summary-title { font-weight: 500; }
.crm-theme .plan-filters {
  display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; margin-bottom: 0;
}
.crm-theme .plan-filters > select { max-width: none; }
.crm-theme .plan-filters :is(.multi-combo, .multi-combo-trigger) { min-width: 0; width: 100%; }
.crm-theme .plan-filters .multi-combo-panel { min-width: 0; width: 100%; max-width: 100%; }
:where(.crm-theme) .territory-workspace-card strong { font-weight: 500; font-size: 27px; }
:where(.crm-theme) .plan-ranking-summary,
:where(.crm-theme) .territory-menu-field-summary,
:where(.crm-theme) .territory-workspace-pharmacy > summary { font-weight: 500; }
:where(.crm-theme) .plan-ranking-summary { background: var(--card); }
:where(.crm-theme) .greeting { background: var(--accent-soft); border-color: transparent; }
:where(.crm-theme) .howto-title { font-weight: 500; }
:where(.crm-theme) .ev-grid { gap: 18px; margin-block: 18px; }
:where(.crm-theme) .ev-field { gap: 7px; }
:where(.crm-theme) .ev-contracts-back { margin-bottom: 16px; }
.department-sales-controls .filters { align-items: end; }
.department-sales-controls .filters > label, .department-months { display: grid; gap: 6px; min-width: 150px; flex: 1; }
.department-sales-controls select { width: 100%; }
.department-months > span { font-size: 13px; color: var(--muted); }
.department-months-trigger { width: 100%; min-height: 42px; text-align: left; display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.department-months-trigger::after { content: '⌄'; flex-shrink: 0; }
.department-months-panel { position: fixed; z-index: 120; display: flex; flex-direction: column; gap: 10px; box-sizing: border-box; padding: 12px; border: 1px solid var(--line); border-radius: 12px; background: var(--card); box-shadow: 0 10px 32px #352c2126; }
.department-months-panel[hidden] { display: none; }
.department-months-panel > button, .department-months-buttons { flex-shrink: 0; }
.department-months-panel > button[aria-pressed="true"] { border-color: var(--accent); color: var(--accent); background: var(--accent-soft); }
.department-months-hint { margin: 0; font-size: 13px; flex-shrink: 0; }
.department-months-list { min-height: 0; overflow-y: auto; overscroll-behavior: contain; }
.department-months-panel .department-months-option { display: flex; align-items: center; gap: 10px; min-height: 44px; min-width: 0; padding: 8px; box-sizing: border-box; cursor: pointer; color: var(--ink); font-size: 15px; border-radius: 6px; }
.department-months-option:hover { background: var(--accent-soft); }
.department-months-option input { width: 18px; height: 18px; margin: 0; flex-shrink: 0; accent-color: var(--accent); }
.department-months-option small { display: block; font-size: 12px; }
.department-months-buttons { display: flex; gap: 10px; border-top: 1px solid var(--line); padding-top: 10px; }
.department-months-buttons button { flex: 1; min-width: 0; min-height: 44px; }
@media (max-width: 600px) {
  .department-sales-controls .filters > label, .department-months { flex-basis: 100%; min-width: 0; }
}
.department-sales-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 12px; margin-top: 16px; }
.department-sales-result > .card { margin-top: 20px; }
.department-sales-result details { padding: 12px 0; }
.department-sales-result summary { cursor: pointer; font-weight: 600; }
.department-sales-result details .table-scroll { margin-top: 12px; }
:where(.crm-theme) .ev-field-label { font-weight: 500; }
:where(.crm-theme) .ev-field :is(input, select, textarea) { padding: 10px 12px; }
.crm-theme .ev-field select {
  width: 100%; min-width: 0; max-width: 100%; overflow: hidden; text-overflow: ellipsis;
  /* Нативная отрисовка WebKit выпускает длинный текст за границу поля. */
  -webkit-appearance: none; appearance: none; padding-right: 34px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath d='m3 4.5 3 3 3-3' fill='none' stroke='%23716d65' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 12px center; background-size: 12px;
}
:where(.crm-theme) .ev-next { border-radius: 10px; padding: 14px 16px; }
:where(.crm-theme) .modal-backdrop { background: rgba(48, 46, 42, .28); }
:where(.crm-theme) .modal { border-radius: 18px; box-shadow: 0 18px 60px #302e2a1f; line-height: 1.5; }
:where(.crm-theme) .modal h2, :where(.crm-theme) .modal h3 { font-weight: 500; }
:where(.crm-theme) .modal-actions { gap: 10px; }
:where(.crm-theme) .login-card { border-color: transparent; border-radius: 18px; box-shadow: 0 8px 36px #302e2a06; }
:where(.crm-theme) .plan-chart-month { font-weight: 500; }
@keyframes crm-surface-in {
  from { opacity: .65; transform: translateY(5px); }
  to { opacity: 1; transform: none; }
}
@media (prefers-reduced-motion: no-preference) {
  .crm-theme .modal-backdrop:not(.hidden) > .modal,
  .crm-theme .loyalty-panel:not([hidden]),
  .crm-theme .territory-workspace-content,
  .crm-theme .combo-list:not(.hidden),
  .crm-theme .multi-combo-panel:not(.hidden) { animation: crm-surface-in 180ms ease; }
}
@media (min-width: 801px) and (max-width: 1150px) {
  .crm-theme .plan-filters { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 800px) {
  .crm-theme .main { padding: 24px 12px 60px; }
  .crm-theme .tab { gap: 7px; }
  :where(.crm-theme) .card, :where(.crm-theme) .form-card { padding: 20px 16px; }
  :where(.crm-theme) .kpi { padding: 16px; }
  :where(.crm-theme) .kpi .kpi-value { font-size: 25px; }
  :where(.crm-theme) .page-title, .crm-page:not(.dashboard-page) > h2.section { font-size: 23px; }
  :where(.crm-theme) th, :where(.crm-theme) td { padding-block: 10px; }
  .crm-theme .ev-grid, .crm-theme .ev-grid-wide { grid-template-columns: minmax(0, 1fr); }
  .crm-theme .ev-field :is(input, select, textarea) { min-width: 0; font-size: 16px; }
  .crm-theme .ev-estimate { display: block; overflow-x: auto; }
  .crm-theme .plan-filters { grid-template-columns: minmax(0, 1fr); }
}
@media (prefers-reduced-motion: reduce) {
  .crm-theme *, .crm-theme *::before, .crm-theme *::after {
    animation: none !important; transition: none !important; scroll-behavior: auto !important;
  }
}
