html, body { font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif; }

.scroll-x { overflow-x: auto; }

.heatmap-cell { display: inline-block; }

table.dash-table th, table.dash-table td {
  padding: 6px 10px;
  border-bottom: 1px solid #e5e7eb;
  text-align: left;
  font-size: 13px;
  vertical-align: top;
}
table.dash-table th { font-weight: 600; color: #475569; background: #f8fafc; position: sticky; top: 0; }
table.dash-table tr:hover td { background: #f1f5f9; cursor: default; }
table.dash-table tr.clickable:hover td { background: #eef6ff; cursor: pointer; }

.kpi-card { transition: transform .12s ease; }
.kpi-card:hover { transform: translateY(-1px); }

.badge-up { color: #166534; background: #dcfce7; }
.badge-down { color: #991b1b; background: #fee2e2; }
.badge-neutral { color: #475569; background: #e2e8f0; }

.banner-error {
  background: #fef2f2; color: #991b1b; border: 1px solid #fecaca;
}

.drawer-backdrop {
  position: fixed; inset: 0; background: rgba(15, 23, 42, .42);
  display: flex; justify-content: flex-end; z-index: 50;
}
.drawer {
  width: min(720px, 100%); height: 100%; background: white;
  box-shadow: -8px 0 32px rgba(0,0,0,.12); overflow-y: auto;
}

.code-mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12px; }

/* Фильтр по функциям в реестре клиентов: нативный <details>, чтобы не тащить
   поповер с отслеживанием кликов мимо. Панель абсолютная — иначе раскрытие
   раздвигает строку фильтров и таблицу под ней. */
.client-filter { position: relative; }
.client-filter > summary { list-style: none; }
.client-filter > summary::-webkit-details-marker { display: none; }
.client-filter > summary::after { content: " ▾"; color: #94a3b8; }
.client-filter[open] > summary::after { content: " ▴"; }
.client-filter-panel {
  position: absolute; z-index: 30; top: calc(100% + 4px); left: 0;
  min-width: 280px; max-width: 380px;
  background: #fff; border: 1px solid #e2e8f0; border-radius: 12px;
  box-shadow: 0 8px 24px rgba(15, 23, 42, .12); padding: 8px;
}

/* Подсказка при наведении (лимиты и заметки в реестре клиентов).
   Панель — position: fixed, координаты ставит JS: у обёртки таблицы свой
   overflow-auto, и абсолютную панель он обрезал бы по краям. */
.hint { position: relative; display: inline-block; }
.hint-panel {
  position: fixed; z-index: 60;
  background: #fff; border: 1px solid #e2e8f0; border-radius: 12px;
  box-shadow: 0 8px 24px rgba(15, 23, 42, .14); padding: 8px 10px; cursor: default;
  display: block; max-height: 60vh; overflow: auto;
}
.hint-table { width: 100%; border-collapse: collapse; }
.hint-table th, .hint-table td { font-size: 12px; padding: 3px 6px; white-space: nowrap; }
.hint-table th { color: #64748b; font-weight: 600; text-align: left; border-bottom: 1px solid #e2e8f0; }
.hint-table td { color: #1e293b; }
.hint-unit { color: #94a3b8; font-size: 11px; margin-left: 4px; }
.hint-note { color: #94a3b8; font-size: 11px; margin-top: 4px; }

/* Сортировка кликом по заголовку. Стрелка держит своё место всегда (в том
   числе у неактивных колонок), иначе при переключении сортировки заголовки
   дёргаются по ширине. */
table.dash-table th.th-sort { cursor: pointer; user-select: none; }
table.dash-table th.th-sort:hover { background: #eef2f7; color: #1e293b; }
table.dash-table th.th-sort-active { color: #2563eb; }
.th-sort-label { display: inline-flex; align-items: baseline; gap: 4px; }
.th-sort-arrow { font-size: 9px; width: 8px; display: inline-block; }
/* В правых колонках заголовок прижимается к правому краю вместе со стрелкой */
table.dash-table th.th-sort.text-right .th-sort-label { flex-direction: row; }

/* Заметки в реестре: значок с подсказкой. Панель раскрывается вправо —
   колонка «Клиент» первая, влево ей некуда. */
.notes-badge {
  display: inline-flex; align-items: center; gap: 2px; cursor: default;
  font-size: 11px; line-height: 1; padding: 2px 5px; border-radius: 999px;
  background: #fef3c7; color: #92400e; white-space: nowrap;
}
/* Счета в реестре: по точке на статус перед почтой владельца. */
.inv-dots { display: inline-flex; align-items: center; gap: 3px; margin-right: 5px; vertical-align: middle; }
.inv-dot { width: 8px; height: 8px; border-radius: 999px; display: inline-block; }
.inv-dot-awaiting { background: #f59e0b; }
.inv-dot-paid { background: #10b981; }
.inv-dot-canceled { background: #f43f5e; }
.inv-tag { display: inline-block; font-size: 11px; line-height: 1; padding: 3px 7px; border-radius: 999px; white-space: nowrap; cursor: default; }
.note-hint-item + .note-hint-item { margin-top: 6px; padding-top: 6px; border-top: 1px solid #e2e8f0; }
.note-hint-meta { font-size: 11px; color: #94a3b8; }
.note-hint-text { font-size: 12px; color: #1e293b; white-space: pre-wrap; }

/* Теги клиента. Значок рисуется цветом из справочника, поэтому фон и цвет
   текста приходят инлайном из JS, а классу остаётся форма и размер. */
.tag-chip {
  display: inline-flex; align-items: center; gap: 4px;
  font-size: 11px; line-height: 1; padding: 3px 7px; border-radius: 999px;
  white-space: nowrap; max-width: 160px; cursor: default;
}
.tag-chip-name { overflow: hidden; text-overflow: ellipsis; }
.tag-chip-click { cursor: pointer; }
.tag-chip-click:hover { filter: brightness(1.08); }
/* Крестик снятия тега: заметен только при наведении на сам значок, иначе
   ряд меток в карточке читается как ряд кнопок «удалить». */
.tag-chip-x { opacity: .55; cursor: pointer; font-size: 10px; }
.tag-chip:hover .tag-chip-x { opacity: 1; }
.tag-list { display: inline-flex; align-items: center; gap: 4px; flex-wrap: wrap; }
.tag-more {
  font-size: 11px; line-height: 1; padding: 3px 6px; border-radius: 999px;
  background: #e2e8f0; color: #475569; cursor: default; white-space: nowrap;
}

/* Выбор цвета тега: палитра кружками + нативный input для своего цвета. */
.color-dot {
  width: 18px; height: 18px; border-radius: 999px; border: 2px solid transparent;
  padding: 0; cursor: pointer;
}
.color-dot-active { border-color: #0f172a; }
.color-input {
  width: 26px; height: 22px; padding: 0; border: 1px solid #e2e8f0;
  border-radius: 6px; background: none; cursor: pointer;
}
