/* F69.W3/W4/W5 — AnalyticsDashboard (дашборд руководителя). Premium: токены,
 * slate/brand палитра, Lucide иконки, без эмодзи. Канон calendar-v2 / operators. */

.an-dash {
  padding: var(--space-6, 24px);
  max-width: 1280px;
  margin: 0 auto;
  font-family: var(--font-sans, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif);
  color: var(--color-text, #1a1d23);
}

.an-loading,
.an-error {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-3, 12px);
  min-height: 240px;
  color: var(--color-text-muted, #6b7280);
}
.an-error { flex-direction: column; }

/* Header + period selector ------------------------------------------------- */
.an-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: var(--space-4, 16px);
  margin-bottom: var(--space-6, 24px);
}
.an-title {
  font-size: var(--text-2xl, 24px);
  font-weight: var(--font-semibold, 600);
  letter-spacing: -0.01em;
  margin: 0 0 4px;
}
.an-subtitle {
  font-size: var(--text-sm, 13px);
  color: var(--color-text-muted, #6b7280);
  margin: 0;
}
.an-period {
  display: flex;
  align-items: center;
  gap: var(--space-2, 8px);
}
.an-period-label {
  font-size: var(--text-xs, 12px);
  color: var(--color-text-subtle, #9ca3af);
}
.an-period-btn {
  border: 1px solid var(--color-border, #e1e4ea);
  background: var(--color-bg, #fff);
  color: var(--color-text-muted, #6b7280);
  padding: 6px 12px;
  border-radius: var(--radius-md, 8px);
  font-size: var(--text-sm, 13px);
  cursor: pointer;
  transition: all 150ms ease-out;
}
.an-period-btn:hover { background: var(--color-bg-hover, #eef0f4); }
.an-period-btn.is-active {
  background: var(--brand-primary, #2563eb);
  border-color: var(--brand-primary, #2563eb);
  color: #fff;
}

/* KPI cards ---------------------------------------------------------------- */
.an-kpis {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: var(--space-4, 16px);
  margin-bottom: var(--space-6, 24px);
}
.an-kpi {
  display: flex;
  align-items: center;
  gap: var(--space-3, 12px);
  background: var(--color-bg, #fff);
  border: 1px solid var(--color-border, #e1e4ea);
  border-radius: var(--radius-lg, 12px);
  padding: var(--space-4, 16px);
  box-shadow: var(--shadow-sm, 0 1px 2px rgba(0, 0, 0, 0.04));
}
.an-kpi-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  border-radius: var(--radius-md, 8px);
  background: var(--color-bg-subtle, #f0f2f5);
  color: var(--color-text-muted, #6b7280);
  flex-shrink: 0;
}
.an-kpi.is-primary .an-kpi-icon { background: #eff4ff; color: var(--brand-primary, #2563eb); }
.an-kpi.is-success .an-kpi-icon { background: #ecfdf5; color: #10b981; }
.an-kpi.is-info .an-kpi-icon { background: #eef2ff; color: #6366f1; }
.an-kpi.is-warn .an-kpi-icon { background: #fff7ed; color: #f59e0b; }
.an-kpi-value {
  font-size: var(--text-xl, 20px);
  font-weight: var(--font-semibold, 600);
  line-height: 1.1;
}
.an-kpi-label {
  font-size: var(--text-xs, 12px);
  color: var(--color-text-subtle, #9ca3af);
  margin-top: 2px;
}

/* Two-column grid ---------------------------------------------------------- */
.an-grid {
  display: grid;
  grid-template-columns: 2fr 1fr;
  gap: var(--space-4, 16px);
  margin-bottom: var(--space-4, 16px);
}
.an-card {
  background: var(--color-bg, #fff);
  border: 1px solid var(--color-border, #e1e4ea);
  border-radius: var(--radius-lg, 12px);
  padding: var(--space-5, 20px);
  box-shadow: var(--shadow-sm, 0 1px 2px rgba(0, 0, 0, 0.04));
}
.an-card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: var(--space-4, 16px);
}
.an-card-head h2 {
  font-size: var(--text-md, 15px);
  font-weight: var(--font-semibold, 600);
  margin: 0;
}
.an-badge {
  font-size: var(--text-xs, 12px);
  color: var(--color-text-muted, #6b7280);
  background: var(--color-bg-subtle, #f0f2f5);
  padding: 3px 10px;
  border-radius: var(--radius-full, 999px);
}
.an-badge.is-warn { background: #fff7ed; color: #c2620a; }

.an-empty {
  color: var(--color-text-subtle, #9ca3af);
  font-size: var(--text-sm, 13px);
  padding: var(--space-4, 16px) 0;
  text-align: center;
}
.an-empty.an-ok {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  color: #10b981;
}

/* Occupancy CSS bars (fallback / always present) --------------------------- */
.an-chart-host { position: relative; height: 0; }
.an-chart-host:not(:empty) { height: 220px; margin-bottom: var(--space-4, 16px); }
.an-donut-host:not(:empty) { height: 160px; }

.an-bars { display: flex; flex-direction: column; gap: var(--space-2, 8px); }
.an-bar-row {
  display: grid;
  grid-template-columns: 1fr 2fr auto;
  align-items: center;
  gap: var(--space-3, 12px);
  font-size: var(--text-sm, 13px);
}
.an-bar-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--color-text, #1a1d23);
}
.an-bar-track {
  height: 8px;
  background: var(--color-bg-subtle, #f0f2f5);
  border-radius: var(--radius-full, 999px);
  overflow: hidden;
}
.an-bar-fill {
  display: block;
  height: 100%;
  background: var(--brand-primary, #2563eb);
  border-radius: var(--radius-full, 999px);
  transition: width 300ms cubic-bezier(0.16, 1, 0.3, 1);
}
.an-bar-val {
  font-variant-numeric: tabular-nums;
  color: var(--color-text-muted, #6b7280);
  min-width: 44px;
  text-align: right;
}

/* Status breakdown --------------------------------------------------------- */
.an-status-list { display: flex; flex-direction: column; gap: var(--space-2, 8px); }
.an-status-row {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: var(--space-2, 8px);
  font-size: var(--text-sm, 13px);
}
.an-status-dot { width: 10px; height: 10px; border-radius: 50%; }
.dot-done { background: #10b981; }
.dot-active { background: #6366f1; }
.dot-inprogress { background: #f59e0b; }
.dot-upcoming { background: #94a3b8; }
.dot-cancelled { background: #cbd5e1; }
.dot-noshow { background: #f43f5e; }
.an-status-name { color: var(--color-text-muted, #6b7280); }
.an-status-val { font-variant-numeric: tabular-nums; font-weight: var(--font-medium, 500); }

/* Operations panel --------------------------------------------------------- */
.an-operations { margin-top: var(--space-4, 16px); }
.an-op-cats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: var(--space-4, 16px);
}
.an-op-cat {
  border: 1px solid var(--color-border, #e1e4ea);
  border-radius: var(--radius-md, 8px);
  overflow: hidden;
}
.an-op-cat-head {
  display: flex;
  align-items: center;
  gap: var(--space-2, 8px);
  padding: var(--space-3, 12px);
  background: var(--color-bg-muted, #f7f8fa);
  border-bottom: 1px solid var(--color-border, #e1e4ea);
}
.an-op-cat-icon { display: flex; color: var(--color-text-muted, #6b7280); }
.an-op-cat-icon.cat-stale_unclosed { color: #f59e0b; }
.an-op-cat-icon.cat-pending_overdue { color: #6366f1; }
.an-op-cat-icon.cat-arrival_unpaid { color: #2563eb; }
.an-op-cat-icon.cat-checkout_unpaid { color: #f43f5e; }
.an-op-cat-name {
  font-size: var(--text-sm, 13px);
  font-weight: var(--font-medium, 500);
  flex: 1;
}
.an-op-cat-count {
  font-size: var(--text-xs, 12px);
  font-weight: var(--font-semibold, 600);
  background: var(--color-bg-subtle, #f0f2f5);
  color: var(--color-text-muted, #6b7280);
  padding: 1px 8px;
  border-radius: var(--radius-full, 999px);
}
.an-op-items { display: flex; flex-direction: column; }
.an-op-item {
  display: grid;
  grid-template-columns: 1.4fr 1fr auto auto auto;
  align-items: center;
  gap: var(--space-2, 8px);
  width: 100%;
  text-align: left;
  border: none;
  border-bottom: 1px solid var(--color-border, #e1e4ea);
  background: var(--color-bg, #fff);
  padding: var(--space-3, 12px);
  font-size: var(--text-sm, 13px);
  font-family: inherit;
  color: var(--color-text, #1a1d23);
  cursor: pointer;
  transition: background 150ms ease-out;
}
.an-op-item:last-child { border-bottom: none; }
.an-op-item:hover { background: var(--color-bg-hover, #eef0f4); }
.an-op-res { font-weight: var(--font-medium, 500); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.an-op-resp {
  display: flex;
  align-items: center;
  gap: 4px;
  color: var(--color-text-muted, #6b7280);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
/* F73.W4 — actor-подстрока «Отменил/Удалил: Имя» под именем гостя (CancelledView/
   TrashView). Стэк внутри ячейки .an-op-resp — 5-колоночный grid не меняется. */
.an-op-resp-text { display: flex; flex-direction: column; min-width: 0; line-height: 1.25; }
.an-op-resp-text > span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.an-op-actor { font-size: 11px; color: var(--color-text-subtle, #9ca3af); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.an-op-when { color: var(--color-text-subtle, #9ca3af); font-variant-numeric: tabular-nums; }
.an-op-amount { font-variant-numeric: tabular-nums; text-align: right; }
.an-op-go { display: flex; color: var(--color-text-subtle, #9ca3af); }
.an-op-more {
  padding: var(--space-2, 8px) var(--space-3, 12px);
  font-size: var(--text-xs, 12px);
  color: var(--color-text-subtle, #9ca3af);
}

.an-btn {
  border: 1px solid var(--color-border, #e1e4ea);
  background: var(--color-bg, #fff);
  color: var(--color-text, #1a1d23);
  padding: 8px 16px;
  border-radius: var(--radius-md, 8px);
  font-size: var(--text-sm, 13px);
  cursor: pointer;
}
.an-btn:hover { background: var(--color-bg-hover, #eef0f4); }

/* F69.W11 — сегмент «Все / Мои» (фильтр по ответственному). Premium segmented
   control в стиле Linear/Calendly: pill-контейнер + активная вкладка. */
.an-head-right { display: flex; align-items: center; gap: var(--space-3, 12px); }
.an-seg {
  display: inline-flex;
  padding: 2px;
  background: var(--color-bg-subtle, #f1f5f9);
  border: 1px solid var(--color-border, #e1e4ea);
  border-radius: var(--radius-md, 8px);
}
.an-seg-btn {
  border: none;
  background: transparent;
  color: var(--color-text-muted, #6b7280);
  padding: 5px 14px;
  border-radius: var(--radius-sm, 6px);
  font-size: var(--text-sm, 13px);
  font-weight: var(--font-medium, 500);
  cursor: pointer;
  transition: background 150ms ease-out, color 150ms ease-out;
}
.an-seg-btn:hover { color: var(--color-text, #1a1d23); }
.an-seg-btn.is-active {
  background: var(--color-bg, #fff);
  color: var(--color-text, #1a1d23);
  box-shadow: var(--shadow-sm, 0 1px 2px rgba(16, 24, 40, 0.06));
}
.an-seg-btn:focus-visible {
  outline: 2px solid var(--brand-primary, #2563eb);
  outline-offset: 1px;
}
.an-scope-hint {
  display: flex;
  align-items: center;
  gap: 6px;
  margin: calc(-1 * var(--space-2, 8px)) 0 var(--space-3, 12px);
  font-size: var(--text-xs, 12px);
  color: var(--color-text-muted, #6b7280);
}
.an-scope-hint svg { color: var(--brand-primary, #2563eb); flex-shrink: 0; }

/* F69.W9 — подвкладки «Аналитики» (Занятость/Финансы). .settings-subtabs
   стилизуется в calendar.css (reuse), здесь только отступы обёртки. */
.an-wrap { display: flex; flex-direction: column; gap: var(--space-4, 16px); }
.an-subtabs { margin: var(--space-4, 16px) var(--space-6, 24px) 0; }
.an-subview { min-height: 200px; }

/* F69.W9 — заглушка вкладки «Финансы» (premium empty-state, без эмодзи). */
.an-finance-wip { text-align: center; }
.an-wip {
  display: flex; flex-direction: column; align-items: center; gap: var(--space-3, 12px);
  padding: var(--space-8, 48px) var(--space-6, 24px); color: var(--color-text-muted, #64748b);
}
.an-wip svg { color: var(--brand-primary, #2563eb); opacity: 0.75; }
.an-wip h2 { margin: 0; font-size: var(--text-lg, 18px); color: var(--color-text, #1e293b); }
.an-wip p { margin: 0; max-width: 440px; font-size: var(--text-sm, 13px); line-height: 1.5; }

/* F69.W11 — group-filter bar (ChipsBar readonly) над дашбордом ----------- */
.an-group-bar { margin-bottom: var(--space-4, 16px); }
.an-group-bar:empty { display: none; }

/* F69.W11 — per-resource детализация занятости (занято Xч из Yч) */
.an-bar-hrs {
  display: block;
  font-size: 11px;
  line-height: 1.3;
  color: var(--color-text-subtle, #9ca3af);
  font-variant-numeric: tabular-nums;
}

/* F69.W13 — финансовые таблицы (по группам / по сотрудникам) -------------- */
.an-table-card { margin-top: var(--space-4, 16px); }
.an-table {
  width: 100%;
  border-collapse: collapse;
  font-size: var(--text-sm, 13px);
}
.an-table thead th {
  text-align: left;
  font-weight: var(--font-medium, 500);
  color: var(--color-text-subtle, #9ca3af);
  font-size: var(--text-xs, 12px);
  padding: var(--space-2, 8px) var(--space-3, 12px);
  border-bottom: 1px solid var(--color-border, #e1e4ea);
}
.an-table tbody td {
  padding: var(--space-3, 12px);
  border-bottom: 1px solid var(--color-border, #e1e4ea);
  color: var(--color-text, #1a1d23);
}
.an-table tbody tr:last-child td { border-bottom: none; }
.an-td-name { font-weight: var(--font-medium, 500); }
.an-td-num { text-align: right; font-variant-numeric: tabular-nums; }
.an-td-debt { color: var(--color-text-muted, #6b7280); }

/* Responsive --------------------------------------------------------------- */
@media (max-width: 900px) {
  .an-kpis { grid-template-columns: repeat(2, 1fr); }
  .an-grid { grid-template-columns: 1fr; }
  .an-op-item { grid-template-columns: 1fr auto; }
  .an-op-resp, .an-op-when { display: none; }
  .an-subtabs { margin: var(--space-3, 12px) var(--space-4, 16px) 0; }
}

/* ============ F634 — Шахматка загрузки (OccupancyMatrixView) ============ */
.anm-wrap { padding: var(--space-4, 16px); display: flex; flex-direction: column; gap: var(--space-5, 20px); }
.anm-monthnav { display: inline-flex; align-items: center; gap: var(--space-2, 8px); }
.anm-month-label {
  min-width: 150px; text-align: center; font-weight: var(--font-semibold, 600);
  font-size: var(--text-md, 15px); color: var(--color-text, #1a1a1a);
}
.anm-overall { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: var(--space-3, 12px); }
.anm-kpi {
  background: var(--color-bg, #fff); border: 1px solid var(--color-border, #e5e7eb);
  border-radius: var(--radius-lg, 12px); padding: var(--space-4, 16px); text-align: center;
}
.anm-kpi.is-primary { border-color: var(--brand-primary, #2563eb); }
.anm-kpi-value { font-size: var(--text-2xl, 28px); font-weight: var(--font-semibold, 600); color: var(--color-text, #1a1a1a); }
.anm-kpi.is-primary .anm-kpi-value { color: var(--brand-primary, #2563eb); }
.anm-kpi-label { margin-top: 4px; font-size: var(--text-xs, 12px); color: var(--color-text-muted, #6b7280); }

.anm-summary-list { display: flex; flex-direction: column; gap: var(--space-2, 8px); padding: var(--space-3, 12px) var(--space-4, 16px) var(--space-4, 16px); }
.anm-srow { display: grid; grid-template-columns: 150px 1fr auto; align-items: center; gap: var(--space-3, 12px); }
.anm-sname { font-size: var(--text-sm, 13px); color: var(--color-text, #1a1a1a); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.anm-strack { height: 10px; border-radius: var(--radius-full, 999px); background: var(--color-bg-muted, #f1f3f5); overflow: hidden; }
.anm-sfill { display: block; height: 100%; border-radius: var(--radius-full, 999px); background: var(--brand-primary, #2563eb); transition: width 200ms ease-out; }
.anm-sval { font-size: var(--text-sm, 13px); font-weight: var(--font-semibold, 600); color: var(--color-text, #1a1a1a); text-align: right; min-width: 96px; }
.anm-scnt { display: block; font-size: var(--text-xs, 12px); font-weight: 400; color: var(--color-text-muted, #6b7280); }

.anm-matrix-wrap { overflow-x: auto; padding: 0 var(--space-3, 12px) var(--space-3, 12px); }
.anm-matrix { border-collapse: separate; border-spacing: 2px; font-size: var(--text-xs, 12px); }
.anm-matrix th { font-weight: var(--font-medium, 500); color: var(--color-text-muted, #6b7280); }
.anm-matrix thead .anm-day { width: 26px; text-align: center; padding: 4px 0; }
.anm-cat-col {
  position: sticky; left: 0; z-index: 1; text-align: left; padding: 4px 10px 4px 4px;
  background: var(--color-bg, #fff); color: var(--color-text, #1a1a1a); white-space: nowrap;
  max-width: 160px; overflow: hidden; text-overflow: ellipsis;
}
.anm-cell {
  width: 26px; height: 26px; text-align: center; border-radius: var(--radius-sm, 6px);
  font-variant-numeric: tabular-nums; cursor: default;
}
.anm-total-col { text-align: center; font-weight: var(--font-semibold, 600); padding: 4px 6px; border-radius: var(--radius-sm, 6px); }
.anm-foot-row .anm-cat-col, .anm-foot { font-weight: var(--font-semibold, 600); }
.anm-foot-row .anm-cat-col { color: var(--color-text, #1a1a1a); }

.anm-hint {
  display: flex; align-items: flex-start; gap: 6px; margin: 0;
  font-size: var(--text-xs, 12px); color: var(--color-text-muted, #6b7280); line-height: 1.5;
}
.anm-hint svg { flex-shrink: 0; margin-top: 2px; }

/* F634.W3 — гибкий период (presets + произвольный диапазон) */
.an-period-bar { flex-wrap: wrap; }
.an-period-segs { display: inline-flex; flex-wrap: wrap; gap: var(--space-2, 8px); }
.an-period-custom {
  display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-2, 8px);
  width: 100%; margin-top: var(--space-2, 8px); padding-top: var(--space-2, 8px);
  border-top: 1px solid var(--color-border, #e1e4ea);
}
.an-period-lbl { font-size: var(--text-xs, 12px); color: var(--color-text-subtle, #9ca3af); }
.an-date-input {
  border: 1px solid var(--color-border, #e1e4ea); background: var(--color-bg, #fff);
  color: var(--color-text, #1a1a1a); padding: 6px 10px; border-radius: var(--radius-md, 8px);
  font-size: var(--text-sm, 13px); font-family: inherit;
}
.an-date-input:focus-visible { outline: none; border-color: var(--brand-primary, #2563eb); box-shadow: 0 0 0 3px hsla(221, 83%, 53%, 0.25); }
.an-period-apply {
  border: 1px solid var(--brand-primary, #2563eb); background: var(--brand-primary, #2563eb);
  color: #fff; padding: 6px 14px; border-radius: var(--radius-md, 8px);
  font-size: var(--text-sm, 13px); cursor: pointer; transition: opacity 150ms ease-out;
}
.an-period-apply:hover { opacity: 0.9; }
.an-period-err { font-size: var(--text-xs, 12px); color: var(--color-danger, #dc2626); }

/* Тренд-график загрузки */
.anm-trend .anm-chart-host { height: 200px; padding: var(--space-3, 12px) var(--space-4, 16px) var(--space-4, 16px); }

/* Экстремумы периода (пик / спад) */
.anm-extremes { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: var(--space-3, 12px); }
.anm-ext {
  display: flex; align-items: center; gap: var(--space-3, 12px);
  background: var(--color-bg, #fff); border: 1px solid var(--color-border, #e1e4ea);
  border-radius: var(--radius-lg, 12px); padding: var(--space-3, 12px) var(--space-4, 16px);
}
.anm-ext.is-peak svg { color: var(--color-success, #16a34a); }
.anm-ext.is-low svg { color: var(--color-warning, #d97706); }
.anm-ext-val { font-size: var(--text-lg, 18px); font-weight: var(--font-semibold, 600); color: var(--color-text, #1a1a1a); }
.anm-ext-label { font-size: var(--text-xs, 12px); color: var(--color-text-muted, #6b7280); }

/* F634 — маркер «сегодня» (граница факт / брони на руках) + легенда */
.anm-matrix .anm-today { box-shadow: inset 2px 0 0 var(--brand-primary, #2563eb); }
.anm-matrix th.anm-day.anm-today { color: var(--brand-primary, #2563eb); font-weight: var(--font-semibold, 600); }
.anm-legend {
  display: flex; align-items: flex-start; gap: 6px; margin: var(--space-2, 8px) var(--space-3, 12px) 0;
  font-size: var(--text-xs, 12px); color: var(--color-text-muted, #6b7280); line-height: 1.5;
}
.anm-legend svg { flex-shrink: 0; margin-top: 2px; }

@media (max-width: 640px) {
  .anm-overall { grid-template-columns: repeat(2, 1fr); }
  .anm-srow { grid-template-columns: 110px 1fr auto; }
  .anm-sname { font-size: var(--text-xs, 12px); }
}
