/*
 * Система бронирования - ЗАО "Медиэйс"
 * Основные стили
 */

/* Подключение шрифта Gilroy (локальные файлы) */
@font-face {
  font-family: 'Gilroy';
  src: url('fonts/Gilroy-Regular.woff') format('woff');
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: 'Gilroy';
  src: url('fonts/Gilroy-Medium.woff') format('woff');
  font-weight: 500;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: 'Gilroy';
  src: url('fonts/Gilroy-SemiBold.woff') format('woff');
  font-weight: 600;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: 'Gilroy';
  src: url('fonts/Gilroy-Bold.woff') format('woff');
  font-weight: 700;
  font-style: normal;
  font-display: swap;
}

/* CSS переменные для цветовой схемы */
:root {
  /* Основные цвета */
  --primary: #005ab4;
  --primary-light: #3d8fd4;
  --primary-lighter: #e6f0fa;
  --primary-dark: #003d7a;

  /* Нейтральные цвета */
  --white: #ffffff;
  --gray-50: #f9fafb;
  --gray-100: #f3f4f6;
  --gray-200: #e5e7eb;
  --gray-300: #d1d5db;
  --gray-400: #9ca3af;
  --gray-500: #6b7280;
  --gray-600: #4b5563;
  --gray-700: #374151;
  --gray-800: #1f2937;
  --gray-900: #111827;
  --black: #000000;

  /* Статусы */
  --success: #10b981;
  --success-light: #d1fae5;
  --warning: #f59e0b;
  --warning-light: #fef3c7;
  --danger: #ef4444;
  --danger-light: #fee2e2;
  --info: #3b82f6;
  --info-light: #dbeafe;

  /* Тени */
  --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
  --shadow: 0 1px 3px 0 rgb(0 0 0 / 0.1), 0 1px 2px -1px rgb(0 0 0 / 0.1);
  --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
  --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.1);

  /* Скругления */
  --radius-sm: 4px;
  --radius: 8px;
  --radius-lg: 12px;
  --radius-xl: 16px;
}

/* Сброс стилей */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

/* Базовые стили */
html {
  height: 100%;
  width: 100%;
  /* Резервируем место под скроллбар, чтобы контент не прыгал */
  scrollbar-gutter: stable;
}

body {
  height: 100%;
  width: 100%;
  font-family: 'Gilroy', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background-color: var(--gray-50);
  color: var(--gray-900);
  line-height: 1.5;
  min-height: 100vh;
  margin: 0;
  padding: 0;
  /* Fallback для браузеров без поддержки scrollbar-gutter */
  overflow-y: scroll;
}

#app {
  min-height: 100vh;
  width: 100%;
  display: flex;
  flex-direction: column;
}

/* ==================== СТРАНИЦА ВХОДА ==================== */
.login-page {
  flex: 1;
  min-height: 100vh;
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background-color: var(--gray-50);
}

.login-container {
  background: var(--white);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-lg);
  padding: 40px;
  max-width: 420px;
  width: 100%;
}

.login-header {
  text-align: center;
  margin-bottom: 32px;
}

.login-header h1 {
  color: var(--gray-900);
  font-size: 24px;
  font-weight: 700;
  margin-bottom: 8px;
}

.login-header p {
  color: var(--gray-500);
  font-size: 14px;
}

/* ==================== ФОРМЫ ==================== */
.form-group {
  margin-bottom: 20px;
}

.form-group label {
  display: block;
  color: var(--gray-700);
  font-size: 14px;
  font-weight: 500;
  margin-bottom: 6px;
}

.form-group input,
.form-group select,
.form-group textarea {
  width: 100%;
  padding: 12px 14px;
  border: 1px solid var(--gray-200);
  border-radius: var(--radius);
  font-size: 14px;
  font-family: inherit;
  color: var(--gray-900);
  background: var(--white);
  transition: border-color 0.2s, box-shadow 0.2s;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-lighter);
}

.form-group input::placeholder {
  color: var(--gray-400);
}

.form-grid {
  display: grid;
  gap: 20px;
  max-width: 600px;
}

/* ==================== КНОПКИ ==================== */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 12px 20px;
  font-size: 14px;
  font-weight: 600;
  font-family: inherit;
  border-radius: var(--radius);
  cursor: pointer;
  transition: all 0.2s;
  border: none;
}

.btn:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

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

.btn-primary:hover:not(:disabled) {
  background: var(--primary-dark);
}

.btn-full {
  width: 100%;
}

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

.btn-success:hover:not(:disabled) {
  background: #059669;
}

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

.btn-danger:hover:not(:disabled) {
  background: #dc2626;
}

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

.btn-info:hover:not(:disabled) {
  background: var(--primary);
}

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

.btn-warning:hover:not(:disabled) {
  background: #d97706;
}

.btn-secondary {
  background: var(--gray-500);
  color: var(--white);
}

.btn-secondary:hover:not(:disabled) {
  background: var(--gray-600);
}

.btn-outline {
  background: var(--white);
  color: var(--gray-700);
  border: 1px solid var(--gray-200);
}

.btn-outline:hover:not(:disabled) {
  background: var(--gray-50);
  border-color: var(--gray-300);
}

.btn-small {
  padding: 6px 12px;
  font-size: 13px;
  border-radius: var(--radius-sm);
}

/* ==================== СООБЩЕНИЯ ==================== */
.error-message {
  background: var(--danger-light);
  border: 1px solid #fca5a5;
  color: #b91c1c;
  padding: 12px 16px;
  border-radius: var(--radius);
  margin-bottom: 20px;
  font-size: 14px;
  animation: slideDown 0.3s ease-out;
}

@keyframes slideDown {
  from {
    opacity: 0;
    transform: translateY(-8px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.form-group input.input-error {
  border-color: #ef4444;
  box-shadow: 0 0 0 2px rgba(239, 68, 68, 0.15);
}

.info-message {
  background: var(--info-light);
  border: 1px solid #93c5fd;
  color: #1e40af;
  padding: 16px;
  border-radius: var(--radius);
  margin-top: 24px;
  font-size: 13px;
  line-height: 1.6;
}

.info-message p {
  margin: 0 0 8px 0;
}

.info-message p:last-child {
  margin-bottom: 0;
}

.info-message strong {
  color: #1e3a8a;
  font-weight: 600;
}

.info-message a {
  color: var(--primary);
  text-decoration: none;
  font-weight: 500;
  transition: color 0.2s;
}

.info-message a:hover {
  color: var(--primary-dark);
  text-decoration: underline;
}

.result-box {
  margin-top: 20px;
  padding: 16px;
  border-radius: var(--radius);
  font-size: 14px;
}

.result-box.success {
  background: var(--success-light);
  border: 1px solid #6ee7b7;
  color: #065f46;
}

.result-box.error {
  background: var(--danger-light);
  border: 1px solid #fca5a5;
  color: #b91c1c;
}

.result-box.warning {
  background: var(--warning-light);
  border: 1px solid #fcd34d;
  color: #92400e;
}

.result-box.info {
  background: #eff6ff;
  border: 1px solid #93c5fd;
  color: #1e40af;
}

/* ==================== ТЕСТОВЫЕ АККАУНТЫ ==================== */
.test-accounts {
  margin-top: 32px;
  padding-top: 24px;
  border-top: 1px solid var(--gray-200);
}

.test-accounts h3 {
  font-size: 13px;
  color: var(--gray-500);
  font-weight: 500;
  margin-bottom: 12px;
}

.test-accounts table {
  width: 100%;
  font-size: 12px;
  border-collapse: collapse;
}

.test-accounts th {
  text-align: left;
  color: var(--gray-400);
  font-weight: 500;
  padding: 6px 8px;
}

.test-accounts td {
  padding: 6px 8px;
  color: var(--gray-600);
}

/* ==================== DASHBOARD ==================== */
.dashboard {
  background: var(--white);
  border-radius: var(--radius-lg);
  padding: 24px;
  max-width: 1600px;
  width: 95%;
  margin: 24px auto;
  box-shadow: var(--shadow-md);
}

.dashboard-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 24px;
  padding-bottom: 20px;
  border-bottom: 1px solid var(--gray-200);
}

.dashboard-header h2 {
  color: var(--gray-900);
  font-size: 22px;
  font-weight: 700;
}

.dashboard-header p {
  color: var(--gray-500);
  font-size: 14px;
  margin-top: 4px;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 12px;
}

.logout-btn {
  padding: 8px 16px;
  background: var(--white);
  color: var(--gray-700);
  border: 1px solid var(--gray-200);
  border-radius: var(--radius);
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s;
}

.logout-btn:hover {
  background: var(--gray-50);
  border-color: var(--gray-300);
}

/* ==================== ВКЛАДКИ ==================== */
.tabs {
  display: flex;
  gap: 8px;
  margin-bottom: 24px;
  border-bottom: 1px solid var(--gray-200);
}

.tab-button {
  padding: 12px 20px;
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  color: var(--gray-500);
  font-size: 14px;
  font-weight: 500;
  font-family: inherit;
  cursor: pointer;
  transition: all 0.2s;
  margin-bottom: -1px;
}

.tab-button:hover {
  color: var(--gray-700);
}

.tab-button.active {
  color: var(--primary);
  border-bottom-color: var(--primary);
}

/* ==================== КОНТЕНТ ВКЛАДОК ==================== */
.tab-content {
  min-height: 400px;
}

.tab-content-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 20px;
  min-height: 44px;
}

.tab-content-header h3 {
  font-size: 16px;
  font-weight: 600;
  color: var(--gray-700);
  margin: 0;
}

.tab-content-header .btn {
  flex-shrink: 0;
}

.tab-content-body {
  width: 100%;
}

/* Обертка для горизонтальной прокрутки таблиц */
.table-wrapper,
.table-responsive {
  width: 100%;
  overflow-x: auto !important;
  -webkit-overflow-scrolling: touch; /* Плавная прокрутка на iOS */
  border-radius: var(--radius);
  display: block;
  border: 1px solid var(--gray-200);
}

/* Стилизация скроллбара для webkit браузеров */
.table-wrapper::-webkit-scrollbar,
.table-responsive::-webkit-scrollbar {
  height: 8px;
}

.table-wrapper::-webkit-scrollbar-track,
.table-responsive::-webkit-scrollbar-track {
  background: var(--gray-100);
  border-radius: var(--radius);
}

.table-wrapper::-webkit-scrollbar-thumb,
.table-responsive::-webkit-scrollbar-thumb {
  background: var(--gray-300);
  border-radius: var(--radius);
}

.table-wrapper::-webkit-scrollbar-thumb:hover,
.table-responsive::-webkit-scrollbar-thumb:hover {
  background: var(--gray-400);
}

/* ==================== ТАБЛИЦЫ ==================== */
.table,
.bookings-table {
  width: 100%;
  min-width: 1000px !important; /* Минимальная ширина таблицы для предотвращения сжатия */
  border-collapse: collapse;
  margin-top: 16px;
  white-space: nowrap; /* Предотвращает перенос текста в ячейках */
  table-layout: auto !important; /* Автоматический расчет ширины колонок */
}

.table th,
.bookings-table th {
  background: var(--gray-50);
  padding: 12px 16px;
  text-align: left;
  font-weight: 600;
  font-size: 13px;
  color: var(--gray-600);
  border-bottom: 1px solid var(--gray-200);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.table td,
.bookings-table td {
  padding: 14px 16px;
  border-bottom: 1px solid var(--gray-100);
  font-size: 14px;
  color: var(--gray-700);
  word-wrap: break-word;
  overflow-wrap: break-word;
}

.table tr:hover,
.bookings-table tr:hover {
  background: var(--gray-50);
}

/* Заголовки всегда в одну строку */
.table th,
.bookings-table th {
  white-space: nowrap !important;
}

/* Колонки которые ДОЛЖНЫ оставаться в одну строку */
.table td.col-inn,
.table td.col-date,
.table td.col-status,
.table td.col-expiry,
.bookings-table td.col-inn,
.bookings-table td.col-date,
.bookings-table td.col-status,
.bookings-table td.col-expiry {
  white-space: nowrap !important;
}

/* Колонки с текстом могут переноситься */
.table td.col-clinic,
.table td.col-address,
.table td.col-region,
.table td.col-manager,
.table td.col-dealer,
.bookings-table td.col-clinic,
.bookings-table td.col-address,
.bookings-table td.col-region,
.bookings-table td.col-manager,
.bookings-table td.col-dealer {
  white-space: normal !important;
  word-break: break-word;
}

/* Колонка с действиями может иметь перенос, но кнопки в одну строку */
.table td.col-actions,
.bookings-table td.col-actions {
  white-space: normal !important;
}

.table td.col-actions .btn,
.bookings-table td.col-actions .btn {
  white-space: nowrap;
  margin: 2px;
}

/* Сортируемые заголовки */
.table th.sortable,
.bookings-table th.sortable {
  cursor: pointer;
  user-select: none;
  transition: background-color 0.15s;
}

.table th.sortable:hover,
.bookings-table th.sortable:hover {
  background-color: #e2e6ea;
}

/* ==================== ШИРИНЫ КОЛОНОК ==================== */
/* Минимальные ширины для читабельности - автоматически подстраиваются под содержимое */

/* Название клиники */
.table th.col-clinic,
.table td.col-clinic,
.bookings-table th.col-clinic,
.bookings-table td.col-clinic {
  min-width: 150px;
}

/* ИНН */
.table th.col-inn,
.table td.col-inn,
.bookings-table th.col-inn,
.bookings-table td.col-inn {
  min-width: 100px;
}

/* Регион */
.table th.col-region,
.table td.col-region,
.bookings-table th.col-region,
.bookings-table td.col-region {
  min-width: 120px;
}

/* Адрес */
.table th.col-address,
.table td.col-address,
.bookings-table th.col-address,
.bookings-table td.col-address {
  min-width: 180px;
  line-height: 1.4;
}

/* Менеджер/Дилер - ФИО */
.table th.col-manager,
.table td.col-manager,
.table th.col-dealer,
.table td.col-dealer,
.bookings-table th.col-manager,
.bookings-table td.col-manager,
.bookings-table th.col-dealer,
.bookings-table td.col-dealer {
  min-width: 140px;
}

/* Статус - компактный badge */
.table th.col-status,
.table td.col-status,
.bookings-table th.col-status,
.bookings-table td.col-status {
  min-width: 120px;
}

/* Даты */
.table th.col-date,
.table td.col-date,
.bookings-table th.col-date,
.bookings-table td.col-date {
  min-width: 100px;
}

/* Срок/Истекает */
.table th.col-expiry,
.table td.col-expiry,
.bookings-table th.col-expiry,
.bookings-table td.col-expiry {
  min-width: 110px;
}

/* Действия */
.table th.col-actions,
.table td.col-actions,
.bookings-table th.col-actions,
.bookings-table td.col-actions {
  min-width: 200px;
}

/* Добавим немного больше места для колонок с кнопками */
.table .btn-small,
.bookings-table .btn-small {
  margin: 2px;
}

/* ==================== ИЗМЕНЯЕМЫЕ КОЛОНКИ (RESIZABLE) ==================== */

/* Handle для изменения размера колонки */
.column-resizer {
  position: absolute;
  top: 0;
  right: 0;
  width: 8px;
  height: 100%;
  cursor: col-resize;
  z-index: 10;
  user-select: none;
}

/* Визуальная линия - всегда немного видна */
.column-resizer::after {
  content: '';
  position: absolute;
  top: 20%;
  right: 3px;
  width: 2px;
  height: 60%;
  background: var(--gray-300);
  transition: all 0.2s;
  opacity: 0.4;
}

/* При наведении становится ярче и шире */
.column-resizer:hover::after,
th.resizing .column-resizer::after {
  background: var(--primary);
  opacity: 1;
  width: 3px;
  right: 2.5px;
}

/* Иконка resize при наведении на заголовок */
.column-resizer::before {
  content: '⟷';
  position: absolute;
  top: 50%;
  right: 0;
  transform: translateY(-50%);
  font-size: 12px;
  color: var(--primary);
  opacity: 0;
  transition: opacity 0.2s;
  pointer-events: none;
}

.column-resizer:hover::before {
  opacity: 0.8;
}

/* Активное изменение размера */
th.resizing {
  background: var(--gray-100) !important;
  user-select: none;
}

/* Курсор для всего документа при изменении размера */
body.resizing-column {
  cursor: col-resize !important;
  user-select: none;
}

body.resizing-column * {
  cursor: col-resize !important;
}

/* Заголовки таблиц должны иметь относительное позиционирование */
.table th,
.bookings-table th {
  position: relative;
}

/* ==================== БЕЙДЖИ СТАТУСОВ ==================== */
.status-badge {
  display: inline-block;
  padding: 4px 10px;
  border-radius: 100px;
  font-size: 12px;
  font-weight: 600;
  color: var(--white);
  white-space: nowrap;
  flex-shrink: 0;
}

/* Status Dropdown — select стилизованный как badge */
.status-dropdown {
  display: inline-block;
  padding: 4px 24px 4px 10px;
  border-radius: 100px;
  font-size: 12px;
  font-weight: 600;
  color: var(--white);
  white-space: nowrap;
  border: none;
  cursor: pointer;
  appearance: none;
  -webkit-appearance: none;
  -moz-appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 10 6'%3E%3Cpath fill='%23ffffff' d='M0 0l5 6 5-6z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 8px center;
  background-size: 8px 5px;
  outline: none;
  transition: opacity 0.2s, box-shadow 0.2s;
}

.status-dropdown:hover {
  opacity: 0.85;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.15);
}

.status-dropdown:focus {
  box-shadow: 0 0 0 2px rgba(0, 90, 180, 0.3);
}

.status-dropdown option {
  background: var(--white);
  color: var(--gray-900);
  font-weight: 500;
  padding: 4px 8px;
}

/* Extension Status Badge (НОВОЕ) */
.extension-badge {
  display: inline-block;
  padding: 4px 10px;
  margin-left: 8px;
  border-radius: 100px;
  font-size: 11px;
  font-weight: 600;
  white-space: nowrap;
  flex-shrink: 0;
}

.extension-requested {
  background: #fef3c7;
  color: #92400e;
  border: 1px solid #fbbf24;
}

.extension-approved {
  background: #d1fae5;
  color: #065f46;
  border: 1px solid #10b981;
}

.extension-denied {
  background: #fee2e2;
  color: #991b1b;
  border: 1px solid #ef4444;
}

.role-badge {
  display: inline-block;
  padding: 4px 10px;
  border-radius: 100px;
  font-size: 12px;
  font-weight: 600;
  white-space: nowrap;
  flex-shrink: 0;
}

.role-admin {
  background: var(--primary);
  color: var(--white);
}

.role-manager {
  background: var(--warning-light);
  color: #92400e;
}

.role-dealer {
  background: var(--info-light);
  color: #1e40af;
}

/* ==================== ТЕГИ МЕНЕДЖЕРОВ И РЕГИОНОВ ==================== */
.tags-cell {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  white-space: normal !important;
  max-width: 300px;
}

.manager-tag,
.region-tag {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 100px;
  font-size: 12px;
  font-weight: 500;
  background: var(--gray-100);
  color: var(--gray-700);
  border: 1px solid var(--gray-200);
}

/* ==================== МОДАЛЬНЫЕ ОКНА ==================== */
body:has(.modal.active) {
  overflow: hidden;
}

.modal {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.4);
  z-index: 1000;
  align-items: center;
  justify-content: center;
  backdrop-filter: blur(2px);
}

.modal.active {
  display: flex;
}

.modal-content {
  background: var(--white);
  padding: 28px;
  border-radius: var(--radius-lg);
  max-width: 560px;
  width: 90%;
  max-height: 85vh;
  overflow-y: auto;
  box-shadow: var(--shadow-lg);
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 24px;
}

.modal-header h3 {
  font-size: 18px;
  font-weight: 600;
  color: var(--gray-900);
}

.modal-close {
  background: none;
  border: none;
  font-size: 24px;
  cursor: pointer;
  color: var(--gray-400);
  padding: 4px;
  line-height: 1;
  transition: color 0.2s;
}

.modal-close:hover {
  color: var(--gray-600);
}

.modal-actions {
  display: flex;
  gap: 10px;
  margin-top: 20px;
  justify-content: flex-end;
}

/* ==================== ИСТОРИЯ И КОММЕНТАРИИ ==================== */
.history-item {
  padding: 12px 16px;
  border-left: 3px solid var(--primary);
  margin-bottom: 12px;
  background: var(--gray-50);
  border-radius: 0 var(--radius) var(--radius) 0;
}

.history-item .date {
  font-size: 12px;
  color: var(--gray-500);
}

.history-item .action {
  font-weight: 500;
  color: var(--gray-800);
  margin-top: 4px;
}

.history-item .user {
  font-size: 12px;
  color: var(--gray-500);
  margin-top: 4px;
}

.comment-item {
  padding: 14px;
  background: var(--gray-50);
  border-radius: var(--radius);
  margin-bottom: 12px;
}

.comment-item .meta {
  font-size: 12px;
  color: var(--gray-500);
}

.comment-item .text {
  margin-top: 8px;
  color: var(--gray-700);
}

/* ==================== УВЕДОМЛЕНИЯ ==================== */
@keyframes slideIn {
  from {
    transform: translateX(100%);
    opacity: 0;
  }
  to {
    transform: translateX(0);
    opacity: 1;
  }
}

@keyframes slideOut {
  from {
    transform: translateX(0);
    opacity: 1;
  }
  to {
    transform: translateX(100%);
    opacity: 0;
  }
}

.notification {
  position: fixed;
  top: 20px;
  right: 20px;
  padding: 14px 20px;
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  z-index: 10000;
  animation: slideIn 0.3s ease-out;
  font-size: 14px;
  font-weight: 500;
}

.notification-success {
  background: var(--success);
  color: var(--white);
}

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

.notification-info {
  background: var(--primary);
  color: var(--white);
}

/* ==================== ЗАГРУЗКА ==================== */
.loading {
  display: none;
  text-align: center;
  padding: 20px;
  color: var(--gray-500);
}

.loading.active {
  display: block;
}

/* ==================== ПУСТЫЕ СОСТОЯНИЯ ==================== */
.empty-state {
  text-align: center;
  padding: 48px 20px;
  color: var(--gray-500);
}

.empty-state h3 {
  color: var(--gray-700);
  margin-bottom: 8px;
}

.empty-state p {
  font-size: 14px;
}

/* Loading overlay */
.loading-overlay {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(255, 255, 255, 0.7);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 10;
  min-height: 100px;
}

.loading-spinner {
  width: 40px;
  height: 40px;
  border: 3px solid #e0e0e0;
  border-top-color: #2563eb;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

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

/* ==================== КАРТОЧКИ СТАТИСТИКИ ==================== */
.stats-cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}

.stats-card {
  background: var(--white);
  border: 1px solid var(--gray-200);
  border-radius: var(--radius);
  padding: 20px;
  text-align: center;
  border-top: 3px solid var(--primary);
}

.stats-card--success { border-top-color: var(--success); }
.stats-card--danger { border-top-color: var(--danger); }
.stats-card--warning { border-top-color: var(--warning); }
.stats-card--info { border-top-color: var(--info); }

.stats-card-value {
  font-size: 28px;
  font-weight: 700;
  color: var(--gray-900);
  line-height: 1.2;
}

.stats-card-label {
  font-size: 13px;
  color: var(--gray-500);
  margin-top: 4px;
}

/* ==================== АДАПТИВНОСТЬ ==================== */

/* Планшеты (≤768px) */
@media (max-width: 768px) {
  .dashboard {
    padding: 16px;
    margin: 12px;
    width: auto;
  }

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

  .header-actions {
    flex-wrap: wrap;
    gap: 8px;
  }

  .tabs {
    flex-wrap: wrap;
  }

  .tab-button {
    padding: 10px 14px;
    font-size: 13px;
  }

  .tab-content-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 12px;
    min-height: auto;
  }

  .table,
  .bookings-table {
    font-size: 13px;
    min-width: 700px;
  }

  .table th,
  .bookings-table th,
  .table td,
  .bookings-table td {
    padding: 10px 12px;
  }

  /* На мобильных таблица обязательно должна прокручиваться */
  .table-wrapper {
    overflow-x: auto !important;
  }

  .modal-content {
    padding: 20px;
    margin: 16px;
    width: calc(100% - 32px);
  }

  .stats-cards {
    grid-template-columns: repeat(2, 1fr);
    gap: 10px;
  }

  .stats-card-value {
    font-size: 22px;
  }

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

/* Телефоны (≤480px) */
@media (max-width: 480px) {
  .login-container {
    padding: 24px 20px;
  }

  .login-header {
    margin-bottom: 24px;
  }

  .login-header h1 {
    font-size: 20px;
  }

  .dashboard {
    padding: 12px;
    margin: 8px;
    border-radius: var(--radius);
  }

  .dashboard-header {
    margin-bottom: 16px;
    padding-bottom: 14px;
  }

  .dashboard-header h2 {
    font-size: 18px;
  }

  .tabs {
    gap: 4px;
    margin-bottom: 16px;
  }

  .tab-button {
    padding: 8px 10px;
    font-size: 12px;
  }

  .table,
  .bookings-table {
    min-width: 600px;
  }

  .modal-content {
    padding: 16px;
    margin: 8px;
    width: calc(100% - 16px);
    max-height: calc(100vh - 16px);
  }

  /* Touch-friendly кнопки (минимум 44px по высоте — стандарт Apple HIG) */
  .btn {
    min-height: 44px;
  }

  .btn-small {
    min-height: 36px;
  }

  .logout-btn {
    min-height: 36px;
  }

  .form-grid {
    gap: 12px;
  }
}

/* Закрепление проекта */
.pin-toggle {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  cursor: pointer;
  font-size: 13px;
  margin-top: 4px;
}

.pin-toggle input[type="checkbox"] {
  cursor: pointer;
  accent-color: #22c55e;
}

.pin-label {
  user-select: none;
  color: #666;
}

.pin-toggle input[type="checkbox"]:checked + .pin-label {
  color: #22c55e;
  font-weight: 600;
}

.pinned-badge {
  background: #22c55e;
  color: white;
  padding: 2px 8px;
  border-radius: 12px;
  font-size: 11px;
  font-weight: 600;
  margin-left: 6px;
  vertical-align: middle;
}

/* Фильтры */
.filters-row {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 20px;
  flex-wrap: wrap;
}

.filter-input {
  width: 200px;
  padding: 8px 12px;
  border: 1px solid var(--gray-200);
  border-radius: var(--radius-sm);
  font-size: 14px;
  transition: border-color 0.2s;
}

.filter-input:focus {
  outline: none;
  border-color: var(--primary);
}

.filter-select {
  padding: 8px 12px;
  border: 1px solid var(--gray-200);
  border-radius: var(--radius-sm);
  font-size: 14px;
  background: white;
  cursor: pointer;
  transition: border-color 0.2s;
}

.filter-select:focus {
  outline: none;
  border-color: var(--primary);
}

/* Пагинация */
.pagination-controls {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 0;
  margin-top: 12px;
  gap: 16px;
  flex-wrap: wrap;
}

.pagination-info {
  color: #6b7280;
  font-size: 14px;
  white-space: nowrap;
}

.pagination-nav {
  display: flex;
  align-items: center;
  gap: 4px;
}

.pagination-btn {
  min-width: 36px;
  height: 36px;
  padding: 0 8px;
  border: 1px solid #d1d5db;
  background: #fff;
  color: #374151;
  border-radius: 6px;
  cursor: pointer;
  font-size: 14px;
  transition: all 0.15s;
}

.pagination-btn:hover:not(:disabled):not(.active) {
  background: #f3f4f6;
  border-color: #9ca3af;
}

.pagination-btn.active {
  background: #005ab4;
  color: #fff;
  border-color: #005ab4;
  font-weight: 600;
}

.pagination-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.pagination-ellipsis {
  padding: 0 4px;
  color: #9ca3af;
}

.pagination-size {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 14px;
  color: #6b7280;
}

.pagination-size select {
  padding: 6px 8px;
  border: 1px solid #d1d5db;
  border-radius: 6px;
  font-size: 14px;
  background: #fff;
  cursor: pointer;
}

/* ==================== УВЕДОМЛЕНИЯ ==================== */

/* Кнопка-колокольчик */
.notification-bell {
  position: relative;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  border: none;
  background: var(--white);
  color: var(--gray-700);
  cursor: pointer;
  transition: all 0.2s;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.notification-bell:hover {
  background: var(--gray-50);
  transform: scale(1.05);
}

.notification-bell svg {
  width: 24px;
  height: 24px;
}

/* Badge со счётчиком */
.notification-badge {
  position: absolute;
  top: 4px;
  right: 4px;
  min-width: 20px;
  height: 20px;
  border-radius: 10px;
  background: var(--danger);
  color: var(--white);
  font-size: 11px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 5px;
  box-shadow: 0 2px 4px rgba(220, 38, 38, 0.3);
}

/* Модальное окно */
.notification-modal-content {
  background: var(--white);
  border-radius: 12px;
  width: 90%;
  max-width: 600px;
  max-height: 80vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
}

/* Header модального окна */
.notification-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 20px 24px;
  border-bottom: 1px solid var(--gray-200);
  flex-shrink: 0;
}

.notification-header h2 {
  margin: 0;
  font-size: 20px;
  font-weight: 700;
  color: var(--gray-900);
}

.notification-actions {
  display: flex;
  align-items: center;
  gap: 16px;
}

.notification-actions .btn-text {
  padding: 8px 12px;
  font-size: 13px;
  color: var(--primary);
  background: none;
  border: none;
  cursor: pointer;
  border-radius: 6px;
  transition: all 0.2s;
  font-weight: 500;
}

.notification-actions .btn-text:hover {
  background: var(--gray-100);
  color: var(--primary-dark);
}

.notification-actions .btn-close {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  border: none;
  background: var(--gray-100);
  color: var(--gray-600);
  font-size: 24px;
  line-height: 1;
  cursor: pointer;
  transition: all 0.2s;
  display: flex;
  align-items: center;
  justify-content: center;
}

.notification-actions .btn-close:hover {
  background: var(--gray-200);
  color: var(--gray-900);
}

/* Список уведомлений */
.notification-list {
  flex: 1;
  overflow-y: auto;
  padding: 8px;
}

.notification-list::-webkit-scrollbar {
  width: 8px;
}

.notification-list::-webkit-scrollbar-thumb {
  background: var(--gray-300);
  border-radius: 4px;
}

.notification-list::-webkit-scrollbar-thumb:hover {
  background: var(--gray-400);
}

/* Элемент уведомления */
.notification-item {
  position: relative;
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 16px;
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.2s;
  margin-bottom: 4px;
  background: var(--white);
  border: 1px solid transparent;
}

.notification-item:hover {
  background: var(--gray-50);
  border-color: var(--gray-200);
}

.notification-item.notification-read {
  opacity: 0.6;
}

.notification-item.notification-read:hover {
  opacity: 0.8;
}

/* Иконка уведомления */
.notification-icon {
  flex-shrink: 0;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: var(--gray-100);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
}

/* Содержимое уведомления */
.notification-content {
  flex: 1;
  min-width: 0;
}

.notification-title {
  font-size: 14px;
  font-weight: 600;
  color: var(--gray-900);
  margin-bottom: 4px;
}

.notification-message {
  font-size: 13px;
  color: var(--gray-600);
  margin-bottom: 4px;
  word-wrap: break-word;
}

.notification-time {
  font-size: 12px;
  color: var(--gray-500);
}

/* Точка непрочитанного уведомления */
.notification-dot {
  position: absolute;
  top: 20px;
  right: 16px;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--primary);
  box-shadow: 0 0 0 3px rgba(0, 90, 180, 0.1);
}

/* Состояния загрузки */
.notification-loading,
.notification-empty,
.notification-list .notification-error {
  text-align: center;
  padding: 40px 24px;
  color: var(--gray-500);
  font-size: 14px;
}

.notification-list .notification-error {
  color: var(--danger);
}

/* ========================================
   Карточка Контур.Фокус
   ======================================== */

.kontur-card {
  background: #fff;
  border: 1px solid #e5e7eb;
  border-radius: 12px;
  padding: 20px;
  margin-top: 16px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.06);
}

.kontur-header {
  margin-bottom: 16px;
}

.kontur-header h4 {
  margin: 0 0 6px 0;
  font-size: 18px;
  color: var(--gray-900);
}

.kontur-meta {
  font-size: 13px;
  color: var(--gray-500);
}

/* Лицензия */
.kontur-license {
  padding: 12px 16px;
  border-radius: 8px;
  margin-bottom: 16px;
  font-size: 14px;
  line-height: 1.6;
}

.kontur-license.license-active {
  background: #f0fdf4;
  border-left: 3px solid #10b981;
  color: var(--gray-800);
}

.kontur-license.license-warning {
  background: #fffbeb;
  border-left: 3px solid #f59e0b;
  color: var(--gray-800);
}

/* Филиалы */
.kontur-branches {
  margin-top: 16px;
}

.kontur-branches h4 {
  margin: 0;
  font-size: 15px;
  color: var(--gray-800);
}

.kontur-branch {
  padding: 12px 16px;
  border: 1px solid #e5e7eb;
  border-radius: 8px;
  margin-bottom: 8px;
  transition: border-color 0.2s;
}

.kontur-branch:hover {
  border-color: #d1d5db;
}

.kontur-branch.branch-available {
  border-left: 3px solid #10b981;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.kontur-branch.branch-booked {
  border-left: 3px solid #ef4444;
  background: #fef2f2;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.branch-info {
  flex: 1;
  min-width: 0;
}

.branch-address {
  font-weight: 600;
  font-size: 14px;
  color: var(--gray-900);
  margin-bottom: 4px;
  word-break: break-word;
}

.branch-meta {
  font-size: 12px;
  color: var(--gray-500);
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  align-items: center;
}

.branch-type-badge {
  background: var(--gray-100);
  color: var(--gray-600);
  padding: 1px 6px;
  border-radius: 4px;
  font-size: 11px;
  font-weight: 500;
  white-space: nowrap;
}

.branch-action {
  flex-shrink: 0;
  text-align: center;
}

.branch-booked-text {
  font-size: 12px;
  color: #ef4444;
  white-space: nowrap;
}

.kontur-branch.branch-booked-own {
  border-left: 3px solid #f59e0b;
  background: #fffbeb;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.branch-booked-own-text {
  font-size: 12px;
  color: #92400e;
  text-align: right;
}

.branches-filters {
  display: flex;
  gap: 12px;
  margin-bottom: 14px;
}

.branches-filters input,
.branches-filters select {
  flex: 1;
  min-width: 0;
  padding: 10px 14px;
  font-size: 15px;
  border: 1px solid var(--gray-300);
  border-radius: 8px;
  background: var(--white);
  transition: border-color 0.2s;
}

.branches-filters input:focus,
.branches-filters select:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

.branches-filters input::placeholder {
  color: var(--gray-400);
}

.branches-counter {
  font-size: 13px;
  color: var(--gray-500);
  margin-bottom: 10px;
}

/* .branch-status removed — replaced by .branch-action */

.branch-available-text {
  color: #10b981;
  font-weight: 500;
  font-size: 13px;
}

/* Баннеры в форме создания */
.kontur-verified-banner {
  background: #f0fdf4;
  border: 1px solid #bbf7d0;
  border-radius: 8px;
  padding: 12px 16px;
  margin-bottom: 16px;
  color: #166534;
  font-size: 14px;
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
}

.kontur-unverified-banner {
  background: #fffbeb;
  border: 1px solid #fde68a;
  border-radius: 8px;
  padding: 12px 16px;
  margin-bottom: 16px;
  color: #92400e;
  font-size: 14px;
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
}

/* Баннер предупреждения при ручном вводе адреса */
.manual-entry-warning {
  background: #fff7ed;
  border: 1px solid #fed7aa;
  border-left: 3px solid #f97316;
  border-radius: 8px;
  padding: 12px 16px;
  margin-bottom: 16px;
  font-size: 13px;
  color: #9a3412;
  line-height: 1.5;
}

/* Блок Контура в деталях брони */
.kontur-details-block {
  margin-top: 16px;
  padding: 12px 16px;
  background: #fafafa;
  border-radius: 8px;
  border-left: 3px solid #6366f1;
}

.kontur-details-block h4 {
  margin: 0 0 8px 0;
  color: #6366f1;
  font-size: 14px;
}

.kontur-details-block p {
  margin: 4px 0;
  font-size: 13px;
}

/* Бейдж верификации */
.verified-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: #10b981;
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  vertical-align: middle;
  margin-right: 4px;
  flex-shrink: 0;
}

.manual-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: #f59e0b;
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  vertical-align: middle;
  margin-right: 4px;
  flex-shrink: 0;
}