* {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
  margin: 0;
  padding: 0;
}

:root {
  --bg: #F8FAFC;
  --card: #FFFFFF;
  --text: #0F172A;
  --text-sub: #64748B;
  --accent: #2563EB;
  --accent-light: #DBEAFE;
  --border: #E2E8F0;
  --hover: #F1F5F9;
  --success: #10B981;
  --warning: #F59E0B;
  --danger: #EF4444;
  --radius: 16px;
  --shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
  --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1);
}

[data-theme="dark"] {
  --bg: #0F1115;
  --card: #1A1D23;
  --text: #F2F4F7;
  --text-sub: #9CA3AF;
  --accent: #C7E648;
  --accent-light: #2D3A1E;
  --border: #2D323B;
  --hover: #242931;
  --shadow: 0 2px 12px rgba(0, 0, 0, 0.2);
  --shadow-lg: 0 10px 40px rgba(0, 0, 0, 0.4);
}

body {
  font-family: 'Inter', sans-serif;
  background: var(--bg);
  color: var(--text);
  height: 100vh;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  transition: background 0.3s, color 0.3s;
}

/* ========== ЛОАДЕР ========== */
#loader {
  position: fixed;
  inset: 0;
  background: var(--bg);
  z-index: 9999;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  transition: opacity 0.3s;
}

#loader.hidden {
  opacity: 0;
  pointer-events: none;
}

.spinner {
  font-size: 42px;
  color: var(--accent);
  margin-bottom: 20px;
}

.loader-text {
  font-weight: 600;
  color: var(--text-sub);
  font-size: 14px;
}

/* ========== ЛОГИН ========== */
#login-page {
  position: fixed;
  inset: 0;
  background: var(--bg);
  z-index: 8000;
  display: flex;
  justify-content: center;
  align-items: center;
}

.login-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 40px;
  width: 380px;
  box-shadow: var(--shadow-lg);
}

.login-card h2 {
  font-size: 22px;
  font-weight: 800;
  margin-bottom: 8px;
  text-align: center;
}

.login-card .login-subtitle {
  color: var(--text-sub);
  font-size: 13px;
  text-align: center;
  margin-bottom: 28px;
}

.login-card input {
  width: 100%;
  padding: 12px 16px;
  border: 1px solid var(--border);
  border-radius: 10px;
  font-size: 14px;
  margin-bottom: 14px;
  background: var(--bg);
  color: var(--text);
  outline: none;
  transition: border 0.2s;
}

.login-card input:focus {
  border-color: var(--accent);
}

.login-card .login-btn {
  width: 100%;
  padding: 12px;
  border: none;
  border-radius: 10px;
  background: var(--accent);
  color: white;
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
  transition: opacity 0.2s, transform 0.1s;
}

[data-theme="dark"] .login-card .login-btn {
  color: #0F1115;
}

.login-card .login-btn:hover {
  opacity: 0.9;
}

.login-card .login-btn:active {
  transform: scale(0.98);
}

.login-error {
  color: var(--danger);
  font-size: 12px;
  text-align: center;
  margin-top: 12px;
  min-height: 16px;
}

/* ========== НАВИГАЦИЯ ========== */
.top-nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 20px;
  background: var(--card);
  border-bottom: 1px solid var(--border);
  gap: 12px;
  flex-shrink: 0;
  z-index: 1000;
}

.nav-left {
  display: flex;
  align-items: center;
  gap: 10px;
}

.brand-logo {
  height: 26px;
  width: auto;
}

.nav-tabs {
  display: flex;
  gap: 4px;
  margin-left: 16px;
}

.nav-tab {
  padding: 8px 16px;
  border-radius: 8px;
  border: 1px solid transparent;
  background: transparent;
  cursor: pointer;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-sub);
  transition: all 0.2s;
  white-space: nowrap;
  position: relative;
}

.nav-tab:hover:not(.disabled) {
  background: var(--hover);
  color: var(--text);
}

.nav-tab.active {
  background: var(--accent-light);
  color: var(--accent);
  border-color: transparent;
}

[data-theme="dark"] .nav-tab.active {
  color: #0F1115;
}

.nav-tab.disabled {
  opacity: 0.4;
  cursor: not-allowed;
  pointer-events: none;
}

.nav-right {
  display: flex;
  align-items: center;
  gap: 8px;
}

.nav-btn {
  padding: 8px 12px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--card);
  cursor: pointer;
  font-size: 12px;
  font-weight: 600;
  color: var(--text);
  display: flex;
  align-items: center;
  gap: 6px;
  transition: all 0.2s;
}

.nav-btn:hover {
  background: var(--hover);
  border-color: var(--accent);
}

.nav-btn i {
  font-size: 13px;
}

.user-badge {
  padding: 6px 12px;
  border-radius: 8px;
  background: var(--accent-light);
  color: var(--accent);
  font-size: 11px;
  font-weight: 700;
}

/* ========== ОСНОВНОЙ КОНТЕНТ ========== */
#app {
  flex-direction: column;
  width: 100%;
  height: 100%;
}

.main-content {
  flex: 1;
  min-width: 0;
  min-height: 0;
  overflow-y: auto;
  padding: 16px 20px 0px 20px; /* Убрал нижний padding, используем ::after */
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.main-content::after {
  content: "";
  display: block;
  flex: 0 0 15px; /* Жестко 15px блок внизу */
}

/* ========== СТРАНИЦА ДАШБОРДА ========== */
.dashboard-page {
  display: none;
  flex-direction: column;
  gap: 16px;
  min-width: 0;
  /* min-height: 0; убрано, чтобы контейнер не сжимался и не отдавал скролл детям */
}

.dashboard-page.active {
  display: flex;
}

/* ========== ХЕДЕР ДАШБОРДА ========== */
.dashboard-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 15px;
}

.dashboard-title {
  font-weight: 800;
  font-size: 18px;
}

.filter-bar {
  display: flex;
  gap: 8px;
  align-items: center;
  position: relative;
}

.filter-btn {
  padding: 8px 16px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--card);
  cursor: pointer;
  font-size: 12px;
  font-weight: 600;
  color: var(--text);
  display: flex;
  align-items: center;
  gap: 8px;
  transition: all 0.2s;
  white-space: nowrap;
}

.filter-btn:hover {
  border-color: var(--accent);
}

/* ========== МУЛЬТИСЕЛЕКТ ========== */
.multiselect-container {
  position: relative;
}

.multiselect-content {
  display: none;
  position: absolute;
  top: calc(100% + 5px);
  right: 0;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: var(--shadow-lg);
  z-index: 2500;
  min-width: 240px;
  max-height: 350px;
  overflow-y: auto;
  padding: 8px;
}

.multiselect-content.show {
  display: block;
}

.multiselect-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  font-size: 12px;
  cursor: pointer;
  border-radius: 8px;
  color: var(--text);
  transition: background 0.15s;
}

.multiselect-item:hover {
  background: var(--hover);
}

.multiselect-item input[type="checkbox"] {
  accent-color: var(--accent);
}

/* ========== КАЛЕНДАРЬ ========== */
#calendarModal, #pulseCalendarModal, #mCalendarModal, #crCalendarModal {
  position: absolute;
  top: 50px;
  right: 0;
  background: var(--card);
  border-radius: 16px;
  box-shadow: var(--shadow-lg);
  display: none;
  flex-direction: column;
  border: 1px solid var(--border);
  z-index: 3000;
  width: 800px;
  overflow: hidden;
}

#calendarModal.show, #pulseCalendarModal.show, #mCalendarModal.show, #crCalendarModal.show {
  display: flex;
}

.cal-container {
  display: flex;
  height: 380px;
}

.cal-sidebar {
  width: 180px;
  border-right: 1px solid var(--border);
  padding: 15px 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
  background: var(--card);
}

.cal-preset-btn {
  padding: 8px 20px;
  font-size: 13px;
  color: var(--text);
  cursor: pointer;
  font-weight: 500;
  transition: 0.2s;
  border: none;
  background: none;
  text-align: left;
}

.cal-preset-btn:hover {
  background: var(--hover);
  color: var(--accent);
}

.cal-view {
  flex: 1;
  padding: 20px;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
  background: var(--card);
}

.cal-month-title {
  font-weight: 700;
  font-size: 14px;
  text-align: center;
  margin-bottom: 15px;
  position: relative;
  color: var(--text);
}

.cal-nav {
  position: absolute;
  top: 0;
  cursor: pointer;
  padding: 0 10px;
  color: var(--text-sub);
  background: none;
  border: none;
  font-size: 14px;
}

.cal-nav:hover {
  color: var(--accent);
}

.cal-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 2px;
}

.cal-day-name {
  font-size: 10px;
  font-weight: 700;
  color: var(--text-sub);
  text-align: center;
  padding-bottom: 10px;
  text-transform: lowercase;
}

.cal-cell {
  aspect-ratio: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  cursor: pointer;
  border-radius: 50%;
  color: var(--text);
  transition: 0.2s;
  border: none;
  background: none;
}

.cal-cell:hover:not(.empty) {
  background: var(--hover);
}

.cal-cell.selected {
  background: var(--accent) !important;
  color: white !important;
  font-weight: 700;
  z-index: 2;
}

[data-theme="dark"] .cal-cell.selected {
  color: #0F1115 !important;
}

.cal-cell.range {
  background: rgba(49, 57, 200, 0.08);
  border-radius: 0;
}

[data-theme="dark"] .cal-cell.range {
  background: rgba(199, 230, 72, 0.1);
}

.cal-cell.empty {
  cursor: default;
  opacity: 0.3;
}

.cal-footer {
  padding: 15px 20px;
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.cal-input-box {
  border: 1px solid var(--border);
  padding: 8px 12px;
  border-radius: 10px;
  font-size: 13px;
  width: 130px;
  text-align: center;
  background: var(--bg);
  color: var(--text);
  font-weight: 600;
}

/* ========== KPI КАРТОЧКИ ========== */
.top-container {
  display: grid;
  grid-template-columns: 460px 1fr;
  gap: 16px;
  min-height: 200px;
  flex-shrink: 0;
}

.kpi-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 6px;
  align-items: stretch;
  min-width: 0;
}

.card {
  background: var(--card);
  border-radius: var(--radius);
  padding: 12px 14px;
  border: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  justify-content: center;
  box-shadow: var(--shadow);
  transition: transform 0.2s, box-shadow 0.2s;
  position: relative;
  overflow: visible;
  min-width: 0;
}

.card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-lg);
}

.card-highlight {
  background: var(--accent);
  border: none;
}

.card-highlight .kpi-label {
  color: rgba(255, 255, 255, 0.8) !important;
}

.card-highlight .kpi-val {
  color: #FFFFFF !important;
}

/* Компактные KPI для Академии */
.academic-kpis {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
}

.kpi-card-small {
  padding: 8px 12px;
  min-height: 0;
}

.kpi-card-small .kpi-label {
  font-size: 9px;
  margin-bottom: 4px;
}

.kpi-card-small .kpi-val {
  font-size: 14px;
}

.charts-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 15px;
}

.kpi-label {
  font-size: 10px;
  font-weight: 500;
  color: var(--text-sub);
  margin-bottom: auto;
  /* отталкивает значение вниз */
  letter-spacing: 0.1px;
  line-height: 1.3;
}

.kpi-val {
  font-size: 16px;
  font-weight: 700;
  color: var(--text);
  line-height: 1;
  /* чтобы числа стояли ровно на базовой линии */
  word-break: break-all;
  display: flex;
  align-items: baseline;
  margin-top: 6px;
}

.kpi-val.accent {
  color: var(--accent);
}

/* ========== SYNC INFO BAR ========== */
.sync-info-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
}

.sync-info-label {
  font-size: 11px;
  color: var(--text-sub);
  font-weight: 500;
  white-space: nowrap;
}

.sync-info-time {
  font-size: 12px;
  font-weight: 600;
  color: var(--text);
  white-space: nowrap;
}

.btn-sync-quick {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: 6px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: opacity 0.2s, transform 0.1s;
  white-space: nowrap;
}

.btn-sync-quick:hover {
  opacity: 0.85;
  transform: translateY(-1px);
}

.btn-sync-quick:disabled {
  opacity: 0.6;
  cursor: not-allowed;
  transform: none;
}

.btn-sync-previews {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  background: #fff;
  color: var(--accent);
  border: 1.5px solid var(--accent);
  border-radius: 6px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: opacity 0.2s, transform 0.1s;
  white-space: nowrap;
}

.btn-sync-previews:hover {
  opacity: 0.85;
  transform: translateY(-1px);
  background: rgba(59, 130, 246, 0.05);
}

.btn-sync-previews:disabled {
  opacity: 0.6;
  cursor: not-allowed;
  transform: none;
}

/* ========== KPI ТУЛТИПЫ ========== */
[data-tooltip-full] {
  position: relative;
  cursor: default;
}

[data-tooltip-full]::after {
  content: attr(data-tooltip-full);
  position: absolute;
  bottom: calc(100% + 6px);
  left: 50%;
  transform: translateX(-50%);
  background: #1E293B;
  color: #F8FAFC;
  font-size: 11px;
  font-weight: 600;
  padding: 5px 10px;
  border-radius: 6px;
  white-space: nowrap;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.15s;
  z-index: 100;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}

[data-tooltip-full]::before {
  content: '';
  position: absolute;
  bottom: calc(100% + 1px);
  left: 50%;
  transform: translateX(-50%);
  border: 5px solid transparent;
  border-top-color: #1E293B;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.15s;
  z-index: 100;
}

[data-tooltip-full]:hover::after,
[data-tooltip-full]:hover::before {
  opacity: 1;
}

/* ========== ВКЛАДКИ НАСТРОЕК ========== */
.settings-tabs {
  display: flex;
  gap: 4px;
  margin-bottom: 20px;
  flex-wrap: wrap;
  border-bottom: 2px solid var(--border);
  padding-bottom: 0;
}

.settings-tab {
  padding: 8px 16px;
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-sub);
  cursor: pointer;
  transition: color 0.2s, border-color 0.2s;
  display: flex;
  align-items: center;
  gap: 6px;
  border-radius: 6px 6px 0 0;
}

.settings-tab:hover {
  color: var(--accent);
}

.settings-tab.active {
  color: var(--accent);
  border-bottom-color: var(--accent);
  background: rgba(37, 99, 235, 0.05);
}

.settings-tab-content {
  display: none;
}

.settings-tab-content.active {
  display: block;
}

/* ========== ТАБЛИЦА ========== */
.table-cont {
  background: var(--card);
  border-radius: var(--radius);
  border: 1px solid var(--border);
  flex: 1;
  box-shadow: var(--shadow);
  margin-bottom: 15px; /* footer gap */
}

.table-scroll {
  overflow-x: auto;
  overflow-y: visible;
  height: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
  table-layout: fixed;
  min-width: 1000px;
}

#academic-table {
  min-width: 1800px; /* Только для Академии расширяем */
}

th {
  text-align: center; /* Центрируем заголовки по горизонтали */
  vertical-align: middle; /* Центрируем по вертикали */
  padding: 8px 4px;
  background: var(--hover);
  position: sticky;
  top: 0;
  font-size: 8px; /* Еще немного меньше для вместимости */
  line-height: 1.0;
  color: var(--text-sub);
  border-bottom: 2px solid var(--border);
  z-index: 100;
  text-transform: uppercase;
  letter-spacing: 0.1px;
  font-weight: 800;
  height: 45px; /* Фиксированная высота для предотвращения наслаивания */
  word-wrap: break-word; /* Разрешаем перенос слов */
}

td {
  padding: 12px 8px;
  border-bottom: 1px solid var(--border);
  font-size: 11px;
  word-wrap: break-word;
  color: var(--text);
}

td:first-child,
th:first-child {
  position: sticky;
  left: 0;
  background: var(--card);
  z-index: 105; /* Еще выше основной шапки */
  width: 180px;
  border-right: 1px solid var(--border);
  padding-left: 12px;
}

th:first-child {
  background: var(--hover); /* Чтобы вся шапка была серой */
  top: 0;
  z-index: 110;
}

.row-main {
  cursor: pointer;
  font-weight: 700;
  transition: background 0.15s;
}

.row-main:hover {
  background: var(--hover);
}

.row-sub {
  background: #FBFCFE;
  display: none;
}

[data-theme="dark"] .row-sub {
  background: #1e222a;
}

.toggle-icon {
  margin-right: 8px;
  color: var(--accent);
  transition: transform 0.2s;
  font-size: 8px;
  display: inline-block;
}

.expanded .toggle-icon {
  transform: rotate(90deg);
}

tfoot td {
  font-weight: 800;
  background: rgba(49, 57, 200, 0.03);
  border-top: 2px solid var(--border);
}

[data-theme="dark"] tfoot td {
  background: rgba(199, 230, 72, 0.05);
}

/* ========== СТРАНИЦА НАСТРОЕК ========== */
.settings-page {
  display: none;
  flex-direction: column;
  gap: 20px;
  min-width: 0;
  min-height: 0;
}

.settings-page.active {
  display: flex;
}

.settings-section {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
  box-shadow: var(--shadow);
  margin-bottom: 20px;
}

.settings-section h3 {
  font-size: 15px;
  font-weight: 800;
  margin-bottom: 18px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.settings-section h3 i {
  color: var(--accent);
}

.settings-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}

.setting-field {
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.setting-field label {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-sub);
  text-transform: uppercase;
  letter-spacing: 0.3px;
}

.setting-field input,
.setting-field select {
  padding: 10px 14px;
  border: 1px solid var(--border);
  border-radius: 10px;
  font-size: 13px;
  background: var(--bg);
  color: var(--text);
  outline: none;
  transition: border 0.2s;
}

.setting-field input:focus,
.setting-field select:focus {
  border-color: var(--accent);
}

.settings-actions {
  display: flex;
  gap: 10px;
  margin-top: 8px;
}

.btn {
  padding: 10px 20px;
  border-radius: 10px;
  border: none;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 8px;
  transition: all 0.2s;
}

.btn-primary {
  background: var(--accent);
  color: white;
}

[data-theme="dark"] .btn-primary {
  color: #0F1115;
}

.btn-primary:hover {
  opacity: 0.9;
}

.btn-outline {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text);
}

.btn-outline:hover {
  border-color: var(--accent);
}

.btn-danger {
  background: var(--danger);
  color: white;
}

.btn-danger:hover {
  opacity: 0.9;
}

.btn-sm {
  padding: 6px 12px;
  font-size: 11px;
}

/* Пользователи */
.users-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 16px;
}

.user-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 14px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--bg);
}

.user-info {
  display: flex;
  align-items: center;
  gap: 10px;
}

.user-info span {
  font-size: 13px;
  font-weight: 600;
}

.user-role {
  font-size: 10px;
  font-weight: 700;
  padding: 3px 8px;
  border-radius: 6px;
  background: var(--accent-light);
  color: var(--accent);
  text-transform: uppercase;
}

/* Sync статус */
.sync-status-bar {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  border-radius: 10px;
  background: var(--bg);
  border: 1px solid var(--border);
  font-size: 12px;
}

.sync-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--success);
  flex-shrink: 0;
}

.sync-dot.error {
  background: var(--danger);
}

.sync-dot.running {
  background: var(--warning);
  animation: pulse 1s infinite;
}

@keyframes pulse {

  0%,
  100% {
    opacity: 1;
  }

  50% {
    opacity: 0.4;
  }
}

/* Уведомления */
.toast {
  position: fixed;
  bottom: 20px;
  right: 20px;
  padding: 14px 20px;
  border-radius: 12px;
  color: white;
  font-size: 13px;
  font-weight: 600;
  z-index: 9000;
  box-shadow: var(--shadow-lg);
  transform: translateY(100px);
  opacity: 0;
  transition: all 0.3s;
}

.toast.show {
  transform: translateY(0);
  opacity: 1;
}

.toast.success {
  background: var(--success);
}

.toast.error {
  background: var(--danger);
}

.toast.info {
  background: var(--accent);
}

/* ========== АДАПТИВНОСТЬ ========== */
@media (max-width: 1200px) {
  .top-container {
    grid-template-columns: 1fr;
  }

  .kpi-grid {
    grid-template-columns: repeat(4, 1fr);
  }
}

@media (max-width: 900px) {
  .top-nav {
    padding: 10px 12px;
    flex-wrap: wrap;
  }

  .nav-tabs {
    overflow-x: auto;
    gap: 3px;
  }

  .nav-tab {
    padding: 6px 10px;
    font-size: 11px;
  }

  .main-content {
    padding: 12px;
  }

  .dashboard-header {
    flex-direction: column;
    align-items: flex-start;
  }

  .kpi-grid {
    grid-template-columns: repeat(3, 1fr);
  }

  .charts-row {
    grid-template-columns: 1fr;
  }

  .settings-grid {
    grid-template-columns: 1fr;
  }

  #calendarModal, #pulseCalendarModal, #mCalendarModal {
    width: 95vw;
    right: -10px;
  }

  .cal-container {
    flex-direction: column;
    height: auto;
  }

  .cal-sidebar {
    width: 100%;
    flex-direction: row;
    overflow-x: auto;
    border-right: none;
    border-bottom: 1px solid var(--border);
  }

  .cal-view {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 600px) {
  .nav-tabs {
    display: none;
  }

  .mobile-menu-btn {
    display: flex !important;
  }

  .kpi-grid {
    grid-template-columns: repeat(2, 1fr);
  }

  table {
    min-width: 700px;
  }

  .login-card {
    width: 90vw;
    padding: 28px;
  }

  .top-container {
    min-height: auto;
  }
}

.mobile-menu-btn {
  display: none !important;
}

/* Мобильное меню */
.mobile-nav-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  z-index: 5000;
}

.mobile-nav-overlay.show {
  display: block;
}

.mobile-nav-panel {
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  width: 280px;
  background: var(--card);
  padding: 24px;
  z-index: 5001;
  display: flex;
  flex-direction: column;
  gap: 6px;
  transform: translateX(-100%);
  transition: transform 0.3s;
}

.mobile-nav-panel.show {
  transform: translateX(0);
}

.mobile-nav-item {
  padding: 12px 16px;
  border-radius: 10px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  color: var(--text);
  transition: background 0.15s;
  border: none;
  background: none;
  text-align: left;
  width: 100%;
}

.mobile-nav-item:hover {
  background: var(--hover);
}

.mobile-nav-item.active {
  background: var(--accent);
  color: white;
}

.mobile-nav-item.disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

/* ========== ПУЛЬС ОП ========== */
.pulse-top-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
  flex-wrap: wrap;
  gap: 12px;
}

.pulse-top-bar h2 {
  font-size: 20px;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 8px;
}

.pulse-controls {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
}

.pulse-scroll-wrap {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow-x: auto;
  padding: 0;
  min-width: 0;
  margin-bottom: 15px; /* footer */
}

.pulse-grid {
  display: grid;
  grid-template-columns: minmax(180px, 1.2fr) repeat(10, minmax(75px, 1fr)) minmax(105px, 0.9fr) minmax(130px, 1.5fr);
  grid-auto-rows: min-content; 
  width: 100%;
  min-width: 900px;
  font-size: 11px;
  color: var(--text);
  /* Обеспечим, чтобы контент не "нырял" под шапку при загрузке */
  position: relative;
}

.pulse-header-row {
  display: contents;
}

.pulse-header-cell {
  background: #F1F5F9; 
  font-weight: 700;
  color: var(--text-sub);
  text-transform: uppercase;
  font-size: 11px; /* Вернули размер */
  letter-spacing: 0.3px;
  border-bottom: 2px solid var(--border);
  border-right: 1px solid var(--border);
  padding: 0 4px;
  height: 32px; /* Вернули высоту чуть больше для читаемости */
  display: flex;
  align-items: center;
  justify-content: center;
  position: sticky;
  top: 0;
  z-index: 100 !important;
}

.pulse-header-cell:last-child {
  border-right: none;
}

.pulse-header-cell.pulse-cell-manager {
  position: sticky;
  left: 0;
  z-index: 101;
  background: #F1F5F9 !important;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 0;
}

.pulse-manager-row {
  display: contents;
}

.pulse-manager-row:hover .pulse-cell {
  background: var(--hover);
}

.pulse-cell {
  padding: 4px 0px;
  border-bottom: 1px solid var(--border);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: flex-start; /* Выравнивание по левому краю для вертикального списка */
  gap: 4px;
  min-height: 100px;
  transition: background 0.15s;
}

.pulse-cell:last-child {
  border-right: none;
}

.pulse-cell-manager {
  position: sticky;
  left: 0;
  background: var(--card);
  z-index: 1;
  padding-left: 10px;
  justify-content: center;
}

.pulse-cell-hour {
  text-align: center;
  align-items: center;
  border-left: 1px solid #F1F5F9;
}


.pulse-cell-day {
  background: #FFFBEB;
  border-left: 1px solid #FDE68A;
  text-align: center;
  align-items: center;
  font-weight: 500;
  padding: 6px;
}

.pulse-cell-month {
  background: #F0FDF4;
  border-left: 1px solid #BBF7D0;
  padding: 8px 12px;
  justify-content: flex-start;
  gap: 0px;
}

.pulse-manager-info {
  display: flex;
  align-items: center;
  gap: 6px;
}

.charts-grid-academic {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 15px;
}

@media (min-width: 1200px) {
    .charts-grid-academic {
        grid-template-columns: repeat(3, 1fr);
    }
}
@media (min-width: 1600px) {
    .charts-grid-academic {
        grid-template-columns: repeat(4, 1fr);
    }
}

.pulse-medal {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 8px;
  font-weight: bold;
  font-family: monospace;
  position: relative;
}

.pulse-medal i {
  position: absolute;
  top: -8px;
  left: -2px;
  font-size: 12px;
}

.pulse-medal span {
  z-index: 1;
  color: white;
  text-shadow: 0px 1px 1px rgba(0, 0, 0, 0.5);
}

.pulse-medal-1 {
  background: #FBBF24;
}

.pulse-medal-1 i {
  color: #F59E0B;
}

.pulse-medal-2 {
  background: #9CA3AF;
}

.pulse-medal-2 i {
  color: #6B7280;
}

.pulse-medal-3 {
  background: #D97706;
}

.pulse-medal-3 i {
  color: #B45309;
}

/* Стили для кружков ранга с обводкой */
.pulse-rank-circle {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  font-weight: 800;
  flex-shrink: 0;
  border: 2px solid transparent;
}
.rank-1 { border-color: #FFD700 !important; background: #FFF9E6 !important; color: #856404 !important; }
.rank-2 { border-color: #C0C0C0 !important; background: #F2F2F2 !important; color: #383d41 !important; }
.rank-3 { border-color: #CD7F32 !important; background: #F9EBE0 !important; color: #721c24 !important; }

.pulse-rank {
  font-size: 10px;
  color: var(--text-sub);
  width: 20px;
  text-align: center;
  font-weight: 600;
}

.pulse-avatar-wrap {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  overflow: hidden;
  flex-shrink: 0;
  box-shadow: var(--shadow-sm);
}

.pulse-avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  object-fit: cover;
}

.pulse-avatar-initials {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: var(--text);
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  font-weight: 700;
}

.pulse-manager-name {
  font-weight: 700;
  font-size: 12px;
  line-height: 1.2;
  color: var(--text);
  max-width: 80px;
  word-wrap: break-word;
}

/* Hour cells */
.pulse-hour-row {
  display: flex;
  justify-content: center;
  gap: 8px;
  font-size: 11px;
  color: var(--text-sub);
  font-family: monospace;
}

.pulse-calls-in {
  color: #3B82F6;
  font-weight: 600;
}

.pulse-calls-out {
  color: var(--text-sub);
}

.pulse-time-val {
  color: var(--text-sub);
}

.pulse-invoice-val {
  color: #9CA3AF;
}

.pulse-hour-sale {
  margin-top: 2px;
  text-align: center;
}

.pulse-sale-badge {
  display: inline-block;
  background: #DCFCE7;
  color: #15803D;
  padding: 2px 6px;
  border-radius: 4px;
  font-size: 10px;
  font-weight: 700;
  white-space: nowrap;
}

.pulse-zero {
  color: #D1D5DB;
  font-size: 10px;
}

/* Day totals */
.pulse-day-stat {
  font-size: 11px;
  color: var(--text);
  font-weight: 700;
  margin-bottom: 2px;
  font-family: monospace;
}

.pulse-day-calls {
  color: var(--text);
}

.pulse-day-sale-wrap {
  margin-top: 4px;
}

/* Новые стили для ячеек часов (вертикальный список с иконками) */
.pulse-stat-row {
  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: 8px;
  width: 100%;
  padding: 1px 0px 1px 16px; /* отступ слева для иконок */
  font-size: 11px; /* уменьшенный размер текста */
  font-family: 'Inter', sans-serif;
  line-height: 1.3;
  color: #CBD5E1; /* серый по умолчанию */
}

.pulse-stat-row i {
  width: 14px;
  text-align: center;
  font-size: 11px; /* уменьшенная иконка */
  color: #94A3B8; /* серая иконка по умолчанию */
}

/* Активные статусы */
.pulse-stat-row.active-calls i { color: #8BA1B8; }
.pulse-stat-row.active-calls span { color: #3B82F6; font-weight: 700; }

.pulse-stat-row.active-time i { color: #8BA1B8; }
.pulse-stat-row.active-time span { color: #1E293B; font-weight: 500; }

.pulse-stat-row.active-inv i { color: #8BA1B8; }
.pulse-stat-row.active-inv span { color: #1E293B; font-weight: 500; }

.pulse-stat-row.active-sale { 
  background: #DCFCE7; 
  padding: 2px 4px 2px 12px;
  border-radius: 4px;
  margin-top: 2px;
  width: 90%;
  box-sizing: border-box;
}
.pulse-stat-row.active-sale i { color: #15803D; font-size: 9px; }
.pulse-stat-row.active-sale span { color: #15803D; font-weight: 700; font-size: 9px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%; }

.pulse-stat-row.inactive i { color: #CBD5E1; }
.pulse-stat-row.inactive span { color: #CBD5E1; font-weight: 400; }

.pulse-sale-badge-day {
  font-size: 10px;
  font-weight: 700;
  color: #15803D;
  background: #DCFCE7;
  padding: 2px 6px;
  border-radius: 4px;
  display: inline-block;
}

.pulse-day-sale-zero {
  font-size: 10px;
  color: #15803D;
  font-weight: 700;
}

/* Month totals */
.pulse-month-stats {
  display: flex;
  flex-direction: column;
  gap: 2px;
  margin-bottom: 6px;
}

.pulse-month-line {
  font-size: 10px;
  color: var(--text-sub);
  white-space: nowrap;
}

.pulse-month-line b {
  color: var(--text);
  font-size: 11px;
}

.pulse-month-revenue-wrap {
  display: flex;
  justify-content: space-between;
  align-items: center;
  width: 100%;
  margin: 4px 0;
}

.pulse-month-revenue {
  font-size: 13px;
  font-weight: 800;
  color: var(--text);
}

.pulse-plan-pct {
  font-size: 11px;
  font-weight: 800;
}

.pulse-plan-bar-wrap {
  width: 100%;
  height: 4px;
  background: #E5E7EB;
  border-radius: 2px;
  position: relative;
  margin-bottom: 4px;
}

.pulse-plan-bar {
  height: 100%;
  border-radius: 2px;
  transition: width 0.5s ease;
}

.pulse-plan-label {
  font-size: 9px;
  color: var(--text-sub);
  white-space: nowrap;
}

/* ========== МАРКЕТИНГ — СВЕТЛАЯ ТЕМА ========== */
.marketing-light-page {
  border-radius: 16px;
}

.marketing-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0;
  flex-wrap: wrap;
  gap: 10px;
}

.marketing-header-left {
  display: flex;
  align-items: center;
  gap: 16px;
}

.m-sub-tab {
  font-size: 13px;
  font-weight: 500;
  color: var(--text-sub);
  padding: 6px 14px;
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.2s;
}

.m-sub-tab.active, .m-sub-tab:hover {
  background: var(--bg-card);
  color: var(--text);
  border: 1px solid var(--border);
}

.marketing-header-right {
  display: flex;
  align-items: center;
  gap: 8px;
  position: relative;
}

.m-filter-btn {
  padding: 7px 14px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--bg-card);
  color: var(--text);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 6px;
  transition: border-color 0.2s;
  white-space: nowrap;
}

.m-filter-btn:hover {
  border-color: var(--accent);
}

/* KPI Container */
.m-kpi-container {
  padding: 0;
  display: grid;
  grid-template-columns: repeat(10, 1fr);
  gap: 16px;
}

.m-kpi-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 12px;
  display: flex;
  flex-direction: column;
  justify-content: center;
}

.m-kpi-card.m-kpi-chart-card {
  grid-column: span 3;
  grid-row: span 2;
  padding: 12px;
}

.m-kpi-card.m-kpi-highlight {
  background: var(--accent);
  border-color: var(--accent);
}

.m-kpi-card.m-kpi-highlight .m-kpi-label {
  color: rgba(255,255,255,0.7);
}

.m-kpi-card.m-kpi-highlight .m-kpi-value {
  color: #FFFFFF !important;
}

.m-kpi-label {
  font-size: 10px;
  font-weight: 600;
  color: var(--text-sub);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 4px;
}

.m-kpi-value {
  font-size: 18px;
  font-weight: 800;
  color: var(--text);
  line-height: 1.1;
}

.m-kpi-value.m-accent {
  color: var(--accent);
}

.m-chart-title {
  font-size: 11px;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 4px;
}

/* Marketing Table */
.m-table-cont {
  padding: 0;
  overflow: visible;
  margin-bottom: 15px; /* footer gap */
}

.m-table-cont table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12px;
  color: var(--text);
}

.m-table-cont thead th {
  background: var(--hover);
  padding: 8px 4px;
  font-size: 8px;
  font-weight: 800;
  color: var(--text-sub);
  text-transform: uppercase;
  letter-spacing: 0.1px;
  border-bottom: 2px solid var(--border);
  cursor: pointer;
  white-space: nowrap;
  text-align: center;
  vertical-align: middle;
  height: 45px;
  position: static;
  z-index: auto;
}

.m-table-cont thead th:first-child,
.m-table-cont tbody td:first-child {
  position: static;
  left: 0;
  z-index: 25;
  background: var(--card);
  text-align: left;
  box-shadow: 2px 0 5px -2px rgba(0,0,0,0.1);
  min-width: 280px;
  width: 280px;
}

.m-table-cont thead th:first-child {
  z-index: 30;
}

.m-table-cont tbody td {
  padding: 10px 10px;
  border-bottom: 1px solid var(--border);
  text-align: right;
  color: var(--text);
  font-weight: 500;
  white-space: nowrap;
}

.m-table-cont tbody td:first-child {
  text-align: left;
  font-weight: 700;
}

.m-table-cont tbody tr:hover {
  background: var(--bg-card);
}

.m-table-cont tfoot td {
  padding: 10px 10px;
  font-weight: 800;
  color: var(--text);
  border-top: 2px solid var(--border);
  text-align: right;
  white-space: nowrap;
}

.m-table-cont tfoot td:first-child {
  text-align: left;
}

/* Expandable rows */
.m-row-toggle {
  cursor: pointer;
  user-select: none;
}

.m-row-toggle:hover {
  background: var(--hover);
}

.m-toggle-icon {
  font-size: 10px;
  width: 14px;
  transition: transform 0.2s;
  margin-right: 6px;
  color: var(--text-sub);
  display: inline-block;
}

.expanded .m-toggle-icon {
  transform: rotate(90deg);
}

.m-level-2 { background: #fbfcfe; }
.m-level-3 {
    background: #fdfdfe;
    font-style: italic;
    font-size: 0.95em;
    color: #475569;
}

.m-row-child td {
  padding-left: 28px !important;
  font-weight: 400 !important;
  color: var(--text-sub) !important;
  font-size: 11px;
}

.m-row-child td:first-child {
  font-weight: 500 !important;
}

.m-romi-positive { color: var(--accent); font-weight: 700; }
.m-romi-negative { color: #EF4444; font-weight: 700; }
/* Tooltips */
.kzt-tooltip {
    position: relative;
    cursor: help;
    border-bottom: 1px dashed rgba(0,0,0,0.1);
}

.kzt-tooltip:hover::after {
    content: attr(data-tooltip);
    position: absolute;
    bottom: 125%;
    left: 50%;
    transform: translateX(-50%);
    background: #1e293b;
    color: #fff;
    padding: 4px 8px;
    border-radius: 6px;
    font-size: 11px;
    white-space: nowrap;
    z-index: 9999;
    box-shadow: 0 4px 6px -1px rgb(0 0 0 / 0.1);
    pointer-events: none;
}

.kzt-tooltip:hover::before {
    content: "";
    position: absolute;
    bottom: 105%;
    left: 50%;
    transform: translateX(-50%);
    border: 6px solid transparent;
    border-top-color: #1e293b;
    z-index: 9999;
    pointer-events: none;
}

.btn-loading {
    position: relative;
    color: transparent !important;
    pointer-events: none;
}

.btn-loading::after {
    content: "";
    position: absolute;
    width: 16px;
    height: 16px;
    top: 50%;
    left: 50%;
    margin: -8px 0 0 -8px;
    border: 2px solid rgba(255,255,255,0.3);
    border-radius: 50%;
    border-top-color: #fff;
    animation: btn-spin 0.6s linear infinite;
}

@keyframes btn-spin {
    to { transform: rotate(360deg); }
}

/* Marketing Table Nesting & Icons */
.m-toggle-icon {
    font-size: 10px;
    width: 12px;
    transition: transform 0.2s;
    margin-right: 4px;
    color: var(--text-sub);
}

.expanded .m-toggle-icon {
    transform: rotate(90deg);
}

.m-level-2 {
    background: #fbfcfe;
}
/* Custom Chart Tooltip styling */
.m-chart-tooltip {
    background: #1e293b;
    color: #fff;
    padding: 8px 12px;
    border-radius: 8px;
    font-size: 13px;
    box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1);
    border: none;
}
.m-chart-tooltip-title {
    font-weight: 700;
    margin-bottom: 4px;
    border-bottom: 1px solid rgba(255,255,255,0.1);
    padding-bottom: 4px;
    font-size: 12px;
    color: #94a3b8;
}
.m-chart-tooltip-row {
    display: flex;
    justify-content: space-between;
    gap: 15px;
    margin-top: 2px;
}
.m-chart-tooltip-val {
    font-weight: 600;
    color: #f8fafc;
}

/* ========== ОТЧЕТ ПО КРЕАТИВАМ ========== */
.cr-kpi-grid {
    display: grid;
    grid-template-columns: 1.2fr 1.5fr 0.8fr;
    gap: 16px;
}

.cr-card-title {
    font-size: 11px;
    font-weight: 700;
    color: var(--text-sub);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 12px;
}

.cr-funnel-kpi {
    display: flex;
    gap: 24px;
    margin-bottom: 4px;
}

.cr-kpi-sublabel {
    display: block;
    font-size: 9px;
    font-weight: 700;
    color: var(--text-sub);
    text-transform: uppercase;
    letter-spacing: 0.3px;
}

.cr-kpi-big {
    display: block;
    font-size: 18px;
    font-weight: 800;
    color: var(--text);
    line-height: 1.2;
}

.cr-money-row {
    display: flex;
    justify-content: space-between;
    align-items: flex-end;
    margin-bottom: 10px;
}

.cr-money-val {
    font-size: 20px;
    font-weight: 800;
}

.cr-progress-bar {
    height: 8px;
    background: var(--border);
    border-radius: 4px;
    overflow: hidden;
    display: flex;
    margin-bottom: 16px;
}

.cr-metrics-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 8px;
}

.cr-metric-pill {
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 8px;
    text-align: center;
}

.cr-pill-label {
    display: block;
    font-size: 9px;
    font-weight: 700;
    color: var(--text-sub);
    text-transform: uppercase;
}

.cr-pill-val {
    display: block;
    font-size: 13px;
    font-weight: 800;
    color: var(--text);
    margin-top: 2px;
}

/* Creatives Table */
.cr-table-cont {
    overflow: visible;
    width: 100%;
}

.cr-table-cont thead th {
    position: static;
    z-index: auto;
}

.cr-table-cont thead th:first-child,
.cr-table-cont tbody td:first-child {
    position: static;
    box-shadow: none;
    min-width: 60px;
    width: 60px;
    padding-left: 10px;
    padding-right: 10px;
    text-align: center;
}

.cr-img-box {
    width: 40px;
    height: 40px;
    border-radius: 6px;
    overflow: visible;
    border: 1px solid var(--border);
    background: var(--bg);
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    margin: 0 auto;
}

.cr-creo-img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 6px;
}

.cr-active-on {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 10px;
    font-weight: 700;
    background: rgba(16, 185, 129, 0.1);
    color: #10B981;
}

.cr-active-off {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 10px;
    font-weight: 700;
    background: rgba(239, 68, 68, 0.1);
    color: #EF4444;
}

/* Preview Zoom on Hover */

.cr-img-box:has(.cr-creo-img):hover::after {
    content: '';
    position: absolute;
    left: calc(100% + 12px);
    top: 50%;
    transform: translateY(-50%);
    width: 200px;
    height: 200px;
    background-image: var(--preview-url);
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
    border-radius: 12px;
    border: 2px solid var(--border);
    box-shadow: 0 20px 40px rgba(0,0,0,0.2);
    z-index: 9999;
    pointer-events: none;
}
