/* === Переменные и корневые стили === */
:root {
  /* Фоны */
  --bg-primary: #0f1117;
  --bg-secondary: #1a1d27;
  --bg-card: #222632;
  --bg-hover: #2a2f3e;
  --bg-input: #181b24;

  /* Акцентные цвета */
  --accent: #6c5ce7;
  --accent-hover: #7f71ef;
  --accent-light: rgba(108, 92, 231, 0.15);
  --accent-glow: rgba(108, 92, 231, 0.4);

  /* Зелёный (успех) */
  --success: #00cec9;
  --success-light: rgba(0, 206, 201, 0.15);

  /* Красный (опасность) */
  --danger: #ff6b6b;
  --danger-hover: #ee5a5a;
  --danger-light: rgba(255, 107, 107, 0.15);

  /* Жёлтый (предупреждение) */
  --warning: #fdcb6e;
  --warning-light: rgba(253, 203, 110, 0.15);

  /* Текст */
  --text-primary: #e8e8ed;
  --text-secondary: #8b8e9b;
  --text-muted: #5a5d6d;

  /* Границы */
  --border: #2d3140;
  --border-hover: #3d4155;

  /* Тени */
  --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.2);
  --shadow-md: 0 4px 16px rgba(0, 0, 0, 0.3);
  --shadow-lg: 0 8px 32px rgba(0, 0, 0, 0.4);
  --shadow-glow: 0 0 20px var(--accent-glow);

  /* Радиусы и отступы */
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --radius-xl: 20px;

  /* Размеры */
  --sidebar-width: 260px;

  /* Анимации */
  --transition-fast: 0.15s ease;
  --transition: 0.25s ease;
  --transition-slow: 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

/* === Сброс и базовые стили === */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  background: var(--bg-primary);
  color: var(--text-primary);
  font-size: 14px;
  line-height: 1.5;
  overflow: hidden;
  height: 100vh;
}

/* Скроллбары */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-muted); }

/* === Экран входа === */
.login-screen {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 100vh;
  background: var(--bg-primary);
  background-image:
    radial-gradient(ellipse at 20% 50%, rgba(108, 92, 231, 0.08) 0%, transparent 60%),
    radial-gradient(ellipse at 80% 30%, rgba(0, 206, 201, 0.06) 0%, transparent 50%);
  animation: fadeIn 0.6s ease;
}

.login-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  padding: 48px 40px;
  width: 420px;
  max-width: 90vw;
  box-shadow: var(--shadow-lg);
  animation: slideUp 0.5s ease;
}

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

.login-icon {
  font-size: 56px;
  color: var(--accent);
  display: block;
  margin-bottom: 12px;
  filter: drop-shadow(0 0 12px var(--accent-glow));
}

.login-logo h1 {
  font-size: 22px;
  font-weight: 700;
  margin-bottom: 4px;
}

.login-logo p {
  color: var(--text-secondary);
  font-size: 13px;
}

.login-form {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.input-group {
  position: relative;
}

.input-icon {
  position: absolute;
  left: 14px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
  font-size: 20px;
  pointer-events: none;
  transition: color var(--transition-fast);
}

.input-group input {
  width: 100%;
  padding: 12px 14px 12px 44px;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  color: var(--text-primary);
  font-family: inherit;
  font-size: 14px;
  transition: all var(--transition-fast);
  outline: none;
}

.input-group input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-light);
}

.input-group input:focus + .input-icon,
.input-group input:focus ~ .input-icon {
  color: var(--accent);
}

.checkbox-group {
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  color: var(--text-secondary);
  font-size: 13px;
}

.checkbox-group input[type="checkbox"] {
  accent-color: var(--accent);
  width: 16px;
  height: 16px;
}

.login-error {
  color: var(--danger);
  text-align: center;
  font-size: 13px;
  padding: 8px;
  background: var(--danger-light);
  border-radius: var(--radius-sm);
  animation: shake 0.4s ease;
}

/* === Кнопки === */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 20px;
  border: none;
  border-radius: var(--radius-md);
  font-family: inherit;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: all var(--transition-fast);
  outline: none;
  white-space: nowrap;
}

.btn .material-icons-round { font-size: 18px; }

.btn-primary {
  background: var(--accent);
  color: #fff;
}
.btn-primary:hover {
  background: var(--accent-hover);
  box-shadow: var(--shadow-glow);
}

.btn-success {
  background: var(--success);
  color: #0f1117;
}
.btn-success:hover { filter: brightness(1.1); }

.btn-danger {
  background: var(--danger);
  color: #fff;
}
.btn-danger:hover { background: var(--danger-hover); }

.btn-ghost {
  background: transparent;
  color: var(--text-secondary);
  border: 1px solid var(--border);
}
.btn-ghost:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
  border-color: var(--border-hover);
}

.btn-icon {
  padding: 8px;
  border-radius: var(--radius-sm);
}

.btn-sm { padding: 6px 12px; font-size: 12px; }
.btn-full { width: 100%; }

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  pointer-events: none;
}

/* === Основной макет === */
.main-app {
  display: flex;
  height: 100vh;
  animation: fadeIn 0.5s ease;
}

/* === Боковая панель === */
.sidebar {
  width: var(--sidebar-width);
  min-width: var(--sidebar-width);
  background: var(--bg-secondary);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  padding: 20px 12px;
  overflow-y: auto;
}

.sidebar-header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 12px;
}

.sidebar-logo {
  font-size: 36px;
  color: var(--accent);
  filter: drop-shadow(0 0 8px var(--accent-glow));
}

.sidebar-title h2 {
  font-size: 16px;
  font-weight: 700;
  line-height: 1.2;
}

.sidebar-subtitle {
  font-size: 12px;
  color: var(--text-muted);
  font-weight: 500;
  letter-spacing: 1px;
  text-transform: uppercase;
}

.sidebar-divider {
  height: 1px;
  background: var(--border);
  margin: 16px 12px;
}

.sidebar-menu {
  list-style: none;
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.menu-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 16px;
  border-radius: var(--radius-md);
  cursor: pointer;
  color: var(--text-secondary);
  transition: all var(--transition-fast);
  user-select: none;
}

.menu-item:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
}

.menu-item.active {
  background: var(--accent-light);
  color: var(--accent);
  font-weight: 600;
}

.menu-item .material-icons-round { font-size: 22px; }

.sidebar-footer {
  margin-top: auto;
  padding-top: 12px;
}

/* === Контент === */
.content {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  padding: 28px 32px;
}

/* Для страниц без таблиц — обычный скролл всего контента */
.content.scrollable {
  overflow-y: auto;
}

/* === Заголовок страницы === */
.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 24px;
  animation: fadeIn 0.4s ease;
  flex-shrink: 0;
}

.page-title {
  display: flex;
  align-items: center;
  gap: 12px;
}

.page-title h1 {
  font-size: 24px;
  font-weight: 700;
}

.page-title .material-icons-round {
  font-size: 28px;
  color: var(--accent);
}

.page-actions {
  display: flex;
  gap: 8px;
}

/* === Панель инструментов === */
.toolbar {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 20px;
  flex-wrap: wrap;
  flex-shrink: 0;
}

.search-box {
  position: relative;
  flex: 1;
  min-width: 200px;
  max-width: 400px;
}

.search-box input {
  width: 100%;
  padding: 10px 14px 10px 40px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  color: var(--text-primary);
  font-family: inherit;
  font-size: 13px;
  outline: none;
  transition: all var(--transition-fast);
}

.search-box input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-light);
}

.search-box .material-icons-round {
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
  font-size: 20px;
  pointer-events: none;
}

.badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 4px 12px;
  background: var(--accent-light);
  color: var(--accent);
  border-radius: 20px;
  font-size: 12px;
  font-weight: 600;
}

/* === Таблицы === */
.data-table-wrapper {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow-y: auto;
  animation: slideUp 0.4s ease;
  flex: 1;
  min-height: 0;
}

.data-table {
  width: 100%;
  border-collapse: collapse;
}

.data-table th {
  padding: 12px 16px;
  text-align: left;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-muted);
  background: var(--bg-secondary);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 1;
  cursor: pointer;
  user-select: none;
  white-space: nowrap;
}

.data-table th:hover { color: var(--text-secondary); }

.data-table td {
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  font-size: 13px;
  max-width: 250px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.data-table tbody tr {
  cursor: pointer;
  transition: background var(--transition-fast);
}

.data-table tbody tr:hover { background: var(--bg-hover); }

.data-table tbody tr.selected {
  background: var(--accent-light);
}

.data-table tbody tr:last-child td { border-bottom: none; }

.activation-badge {
  display: inline-flex;
  align-items: center;
  padding: 3px 10px;
  border-radius: 12px;
  font-size: 12px;
  font-weight: 600;
}

.activation-badge.high {
  background: var(--success-light);
  color: var(--success);
}

.activation-badge.low {
  background: var(--warning-light);
  color: var(--warning);
}

.activation-badge.zero {
  background: var(--bg-hover);
  color: var(--text-muted);
}

.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 60px 20px;
  color: var(--text-muted);
}

.empty-state .material-icons-round {
  font-size: 56px;
  margin-bottom: 12px;
  opacity: 0.4;
}

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

/* === Модальные окна === */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(6px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  animation: fadeIn 0.2s ease;
}

.modal-container {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  width: 600px;
  max-width: 90vw;
  max-height: 85vh;
  display: flex;
  flex-direction: column;
  box-shadow: var(--shadow-lg);
  animation: scaleIn 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 24px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.modal-header h2 {
  font-size: 18px;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 8px;
}

.modal-body {
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  overflow-y: auto;
  flex: 1;
  min-height: 0;
}

.modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  padding: 16px 24px;
  border-top: 1px solid var(--border);
  flex-shrink: 0;
}

/* === Формы в модальных окнах === */
.form-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.form-group label {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.form-input {
  width: 100%;
  padding: 10px 14px;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-family: inherit;
  font-size: 14px;
  outline: none;
  transition: all var(--transition-fast);
}

.form-input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-light);
}

.form-input::placeholder { color: var(--text-muted); }

.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

/* === Диалог подтверждения === */
.dialog-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  padding: 32px;
  max-width: 420px;
  text-align: center;
  box-shadow: var(--shadow-lg);
  animation: scaleIn 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.dialog-icon .material-icons-round {
  font-size: 48px;
  color: var(--warning);
  margin-bottom: 12px;
}

.dialog-text {
  font-size: 15px;
  line-height: 1.6;
  color: var(--text-secondary);
  margin-bottom: 24px;
  white-space: pre-line;
}

.dialog-actions {
  display: flex;
  gap: 8px;
  justify-content: center;
}

/* === Уведомления === */
.toast {
  position: fixed;
  bottom: 24px;
  right: 24px;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 20px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-md);
  z-index: 2000;
  animation: slideInRight 0.4s ease;
}

.toast-icon { color: var(--success); font-size: 22px; }

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

/* === Спиннер загрузки === */
.spinner {
  display: inline-block;
  width: 20px;
  height: 20px;
  border: 2px solid var(--border);
  border-top: 2px solid var(--accent);
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
}

.page-loading {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 80px;
}

.page-loading .spinner {
  width: 36px;
  height: 36px;
  border-width: 3px;
}

/* === Списки в формах === */
.list-panel {
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  max-height: 200px;
  overflow-y: auto;
}

.list-panel-item {
  padding: 8px 12px;
  border-bottom: 1px solid var(--border);
  font-size: 13px;
  cursor: pointer;
  transition: background var(--transition-fast);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.list-panel-item:hover { background: var(--bg-hover); }
.list-panel-item.selected { background: var(--accent-light); color: var(--accent); }
.list-panel-item:last-child { border-bottom: none; }

.list-panel-actions {
  display: flex;
  gap: 4px;
  margin-top: 8px;
}

/* === Страница «О программе» === */
.about-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 40px;
  text-align: center;
  max-width: 500px;
  margin: 60px auto;
  animation: slideUp 0.4s ease;
}

.about-card .about-icon {
  font-size: 64px;
  color: var(--accent);
  filter: drop-shadow(0 0 16px var(--accent-glow));
  margin-bottom: 16px;
}

.about-card h2 { font-size: 22px; margin-bottom: 4px; }
.about-card .version { color: var(--text-muted); font-size: 13px; margin-bottom: 20px; }

.about-card .about-text {
  color: var(--text-secondary);
  font-size: 14px;
  line-height: 1.7;
}

.about-card a {
  color: var(--accent);
  text-decoration: none;
}
.about-card a:hover { text-decoration: underline; }

/* === Настройки === */
.settings-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 28px;
  max-width: 500px;
  animation: slideUp 0.4s ease;
}

.settings-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 0;
  border-bottom: 1px solid var(--border);
}

.settings-item:last-child { border-bottom: none; }

.settings-item label { font-weight: 500; }
.settings-item span { color: var(--text-secondary); font-size: 13px; }

/* === Модальное окно — широкое === */
.modal-container.wide {
  width: 800px;
}

/* === Анимации === */
@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

@keyframes slideUp {
  from { opacity: 0; transform: translateY(24px); }
  to { opacity: 1; transform: translateY(0); }
}

@keyframes slideInRight {
  from { opacity: 0; transform: translateX(40px); }
  to { opacity: 1; transform: translateX(0); }
}

@keyframes scaleIn {
  from { opacity: 0; transform: scale(0.9); }
  to { opacity: 1; transform: scale(1); }
}

@keyframes shake {
  0%, 100% { transform: translateX(0); }
  20% { transform: translateX(-8px); }
  40% { transform: translateX(8px); }
  60% { transform: translateX(-4px); }
  80% { transform: translateX(4px); }
}

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