/* Минимальный сброс для SteelKP */
*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  font-size: 14px;
}

body {
  margin: 0;
  min-width: 320px;
  min-height: 100vh;
  font-family: 'Inter', 'Roboto', 'Helvetica Neue', sans-serif;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

a {
  text-decoration: none;
  color: inherit;
}

/* ============================================================
   SteelKP — Глобальные стили
   ============================================================ */

/* --- CSS-переменные --- */
:root {
  /* Индустриальный / Утилитарный (Dark) */
  --primary: #ff5722; /* Оранжевый (раскаленный металл) */
  --primary-hover: #e64a19;
  --primary-light: rgba(255, 87, 34, 0.15);
  --success: #00e676; /* Неоновый зеленый */
  --success-light: rgba(0, 230, 118, 0.15);
  --warning: #ffc107; /* Янтарный */
  --warning-light: rgba(255, 193, 7, 0.15);
  --danger: #ff1744; /* Неоновый красный */
  --danger-light: rgba(255, 23, 68, 0.15);
  --info: #00e5ff; /* Циан */

  --bg: #0a0a0a; /* Очень темный фон */
  --bg-white: #141414; /* Фон карточек */
  --bg-sidebar: #0f0f0f;
  --bg-sidebar-hover: #1f1f1f;
  --bg-header: #141414;

  --text: #e0e0e0;
  --text-secondary: #9e9e9e;
  --text-light: #757575;
  --text-sidebar: #9e9e9e;
  --text-sidebar-active: #ffffff;

  --border: #333333;
  --border-focus: #ff5722;
  --radius: 0px; /* Строгие формы */
  --radius-sm: 0px;
  --shadow: 0 0 0 1px rgba(255, 255, 255, 0.05);
  --shadow-md: 0 4px 6px rgba(0, 0, 0, 0.5);
  --shadow-lg: 0 10px 25px rgba(0, 0, 0, 0.8);

  --font-mono: 'JetBrains Mono', 'Roboto Mono', 'Space Mono', 'Courier New', monospace;
  --font-sans: 'Inter', 'Roboto', 'Helvetica Neue', sans-serif;

  --sidebar-width: 260px;
  --header-height: 60px;
  --transition: 0.2s ease;
  --grid-color: rgba(255, 255, 255, 0.02);
}

/* --- Мягкая / Женская тема (Light) --- */
[data-theme="theme-soft"] {
  --primary: #d81b60; /* Мягкий розовый/малиновый */
  --primary-hover: #ad1457;
  --primary-light: rgba(216, 27, 96, 0.15);
  --success: #43a047;
  --success-light: rgba(67, 160, 71, 0.15);
  --warning: #fbc02d;
  --warning-light: rgba(251, 192, 45, 0.15);
  --danger: #e53935;
  --danger-light: rgba(229, 57, 53, 0.15);
  --info: #00acc1;

  --bg: #fce4ec; /* Очень светлый розовый фон */
  --bg-white: #ffffff; /* Белый фон карточек */
  --bg-sidebar: #f8bbd0;
  --bg-sidebar-hover: #f48fb1;
  --bg-header: #ffffff;

  --text: #37474f;
  --text-secondary: #546e7a;
  --text-light: #90a4ae;
  --text-sidebar: #455a64;
  --text-sidebar-active: #880e4f;

  --border: #f48fb1;
  --border-focus: #d81b60;
  --radius: 16px; /* Скругленные формы */
  --radius-sm: 8px;
  --shadow: 0 4px 12px rgba(216, 27, 96, 0.08);
  --shadow-md: 0 8px 24px rgba(216, 27, 96, 0.12);
  --shadow-lg: 0 16px 32px rgba(216, 27, 96, 0.16);

  --font-mono: 'Courier New', monospace;
  --font-sans: 'Nunito', 'Segoe UI', 'Helvetica Neue', sans-serif;
  --grid-color: rgba(216, 27, 96, 0.05);
}

/* --- Классическая тема (Light) --- */
[data-theme="theme-classic"] {
  --primary: #1976d2; /* Классический синий */
  --primary-hover: #1565c0;
  --primary-light: rgba(25, 118, 210, 0.15);
  --success: #2e7d32;
  --success-light: rgba(46, 125, 50, 0.15);
  --warning: #f57f17;
  --warning-light: rgba(245, 127, 23, 0.15);
  --danger: #c62828;
  --danger-light: rgba(198, 40, 40, 0.15);
  --info: #0277bd;

  --bg: #f5f7fa; /* Светло-серый фон */
  --bg-white: #ffffff; /* Белый фон карточек */
  --bg-sidebar: #ffffff;
  --bg-sidebar-hover: #f0f4f8;
  --bg-header: #ffffff;

  --text: #263238;
  --text-secondary: #607d8b;
  --text-light: #b0bec5;
  --text-sidebar: #455a64;
  --text-sidebar-active: #1976d2;

  --border: #cfd8dc;
  --border-focus: #1976d2;
  --radius: 6px; /* Слегка скругленные формы */
  --radius-sm: 4px;
  --shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
  --shadow-md: 0 4px 8px rgba(0, 0, 0, 0.08);
  --shadow-lg: 0 8px 16px rgba(0, 0, 0, 0.12);

  --font-mono: 'Consolas', monospace;
  --font-sans: 'Inter', 'Roboto', 'Helvetica Neue', sans-serif;
  --grid-color: rgba(0, 0, 0, 0.03);
}

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

html {
  font-size: 14px;
}

body {
  font-family: var(--font-sans);
  color: var(--text);
  background-color: var(--bg);
  background-image: 
    linear-gradient(var(--grid-color) 1px, transparent 1px),
    linear-gradient(90deg, var(--grid-color) 1px, transparent 1px);
/* ============================================================
   ЛЕЙАУТ
   ============================================================ */

.app-layout {
  display: flex;
  min-height: 100vh;
}

/* --- Боковая панель --- */
.sidebar {
  width: var(--sidebar-width);
  background: var(--bg-sidebar);
  color: var(--text-sidebar);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  z-index: 100;
  transition: transform var(--transition);
  overflow-y: auto;
  border-right: 1px solid var(--border);
}

.sidebar-logo {
  padding: 1.25rem 1.5rem;
  border-bottom: 1px solid var(--border);
  background: #000;
}

.sidebar-logo h1 {
  color: var(--primary);
  font-size: 1.5rem;
  font-weight: 800;
  letter-spacing: 1px;
  text-transform: uppercase;
  text-shadow: 0 0 10px var(--primary-light);
}

.sidebar-nav {
  padding: 0.75rem 0;
  flex: 1;
}

.nav-link {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.65rem 1.5rem;
  color: var(--text-sidebar);
  text-decoration: none;
  font-size: 0.95rem;
  transition: all var(--transition);
  border: none;
  background: none;
  width: 100%;
  text-align: left;
  cursor: pointer;
  border-left: 3px solid transparent;
}

.nav-link:hover {
  background: var(--bg-sidebar-hover);
  color: var(--text-sidebar-active);
  border-left-color: var(--primary);
}

.nav-link.active {
  background: rgba(255, 87, 34, 0.1);
  color: var(--primary);
  border-left-color: var(--primary);
  text-shadow: 0 0 8px var(--primary-light);
}

.nav-link--sub {
  padding-left: 3.5rem;
  font-size: 0.9rem;
}

.nav-icon {
  font-size: 1.15rem;
  width: 1.5rem;
  text-align: center;
  flex-shrink: 0;
}

.nav-arrow {
  margin-left: auto;
  font-size: 0.8rem;
}

.nav-group-toggle {
  font-weight: 500;
}

.nav-group-items {
  background: rgba(0, 0, 0, 0.15);
}

/* --- Основная область --- */
.main-area {
  flex: 1;
  margin-left: var(--sidebar-width);
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

/* --- Шапка --- */
.header {
  height: var(--header-height);
  background: var(--bg-header);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 1.5rem;
  position: sticky;
  top: 0;
  z-index: 50;
  box-shadow: var(--shadow);
}

.header-left {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.header-title {
  font-weight: 600;
  font-size: 1.1rem;
  color: var(--text);
  display: none;
}

.hamburger {
  display: none;
  background: none;
  border: none;
  font-size: 1.5rem;
  cursor: pointer;
  color: var(--text);
  padding: 0.25rem;
}

.header-right {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.company-selector {
  padding: 0.4rem 0.75rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: rgba(0, 0, 0, 0.2);
  font-size: 0.9rem;
  color: var(--text);
  max-width: 200px;
}

.notification-bell {
  position: relative;
  background: none;
  border: none;
  font-size: 1.3rem;
  cursor: pointer;
  padding: 0.25rem;
  color: var(--text);
}

.notification-bell:hover {
  color: var(--primary);
}

.notification-badge {
  position: absolute;
  top: -4px;
  right: -6px;
  background: var(--danger);
  color: #fff;
  font-size: 0.65rem;
  font-weight: 700;
  padding: 0.1rem 0.35rem;
  border-radius: 2px;
  min-width: 18px;
  text-align: center;
  line-height: 1.3;
  box-shadow: 0 0 8px var(--danger-light);
}

/* User menu */
.user-menu-wrapper {
  position: relative;
}

.user-menu-toggle {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  background: none;
  border: none;
  cursor: pointer;
  padding: 0.35rem;
  border-radius: var(--radius);
  transition: background var(--transition);
}

.user-menu-toggle:hover {
  background: rgba(255, 255, 255, 0.05);
}

.user-avatar {
  width: 32px;
  height: 32px;
  border-radius: 2px;
  background: var(--primary);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 0.9rem;
  box-shadow: 0 0 10px var(--primary-light);
}

.user-name {
  font-size: 0.9rem;
  font-weight: 500;
  color: var(--text);
}

.user-role-badge {
  font-size: 0.7rem;
  background: var(--primary-light);
  color: var(--primary);
  padding: 0.1rem 0.4rem;
  border-radius: 3px;
  font-weight: 600;
  text-transform: uppercase;
}

.user-menu-dropdown {
  position: absolute;
  top: 100%;
  right: 0;
  width: 220px;
  background: var(--bg-white);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.8);
  z-index: 200;
  padding: 0.5rem 0;
  margin-top: 0.35rem;
}

.user-menu-info {
  padding: 0.75rem 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
}

.user-menu-info strong {
  font-size: 0.9rem;
}

.user-menu-info span {
  font-size: 0.8rem;
  color: var(--text-secondary);
}

.user-menu-dropdown hr {
  border: none;
  border-top: 1px solid var(--border);
  margin: 0.25rem 0;
}

.user-menu-item {
  display: block;
  width: 100%;
  text-align: left;
  background: none;
  border: none;
  padding: 0.6rem 1rem;
  cursor: pointer;
  font-size: 0.9rem;
  color: var(--text);
  transition: background var(--transition);
}

.user-menu-item:hover {
  background: rgba(255, 255, 255, 0.05);
}

.user-menu-item--danger {
  color: var(--danger);
}

/* --- Контент --- */
.content {
  flex: 1;
  padding: 1.5rem;
}

/* Overlay для мобильного сайдбара */
.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  z-index: 90;
}

/* ============================================================
   СТРАНИЦЫ
   ============================================================ */

.page {
  max-width: 1400px;
}

.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1.5rem;
  flex-wrap: wrap;
}

.page-header h1 {
  font-size: 1.6rem;
  font-weight: 700;
  color: var(--text);
}

/* --- Секции --- */
.section {
  margin-top: 1.5rem;
}

.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1rem;
}

.section-header h2 {
  font-size: 1.2rem;
}

/* ============================================================
   ТАБЛИЦЫ
   ============================================================ */

.table-wrapper {
  overflow-x: auto;
  background: var(--bg-white);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  border: 1px solid var(--border);
}

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

.table th,
.table td {
  padding: 0.7rem 1rem;
  text-align: left;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

.table th {
  background: rgba(255, 255, 255, 0.02);
  font-weight: 700;
  font-size: 0.75rem;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 1px;
}

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

.table tbody tr:hover {
  background: rgba(255, 255, 255, 0.03);
}

.table-row-clickable {
  cursor: pointer;
}

.table-row-clickable:hover {
  background: var(--primary-light) !important;
}

.table tfoot td {
  font-weight: 600;
  background: rgba(255, 255, 255, 0.02);
  border-top: 2px solid var(--border);
}

.table--compact th,
.table--compact td {
  padding: 0.4rem 0.75rem;
  font-size: 0.85rem;
}

/* Строки просроченных / истекающих */
.row-expired {
  background: var(--danger-light) !important;
}

.row-expiring {
  background: var(--warning-light) !important;
}

/* ============================================================
   ФОРМЫ
   ============================================================ */

.form-group {
  margin-bottom: 1rem;
}

.form-group label {
  display: block;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 0.35rem;
}

.form-group input,
.form-group select,
.form-group textarea {
  width: 100%;
  padding: 0.55rem 0.75rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 0.95rem;
  color: var(--text);
  background: rgba(0, 0, 0, 0.2);
  transition: border-color var(--transition), box-shadow var(--transition);
  font-family: inherit;
}

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

.form-group input.input-match {
  border-color: var(--success);
  box-shadow: 0 0 0 2px var(--success-light);
}

.form-group input.input-mismatch {
  border-color: var(--danger);
  box-shadow: 0 0 0 2px var(--danger-light);
}

.form-group textarea {
  resize: vertical;
}

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

.form-group--inline {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 0;
}

.form-group--inline label {
  margin-bottom: 0;
  white-space: nowrap;
}

.form-group--inline input,
.form-group--inline select {
  width: auto;
  min-width: 150px;
}

/* ============================================================
   КНОПКИ
   ============================================================ */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  padding: 0.55rem 1.1rem;
  font-size: 0.85rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 1px;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all var(--transition);
  font-family: inherit;
  text-decoration: none;
  white-space: nowrap;
}

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  filter: grayscale(100%);
}

.btn-primary {
  background: var(--primary);
  color: #fff;
  box-shadow: 0 0 10px var(--primary-light);
}

.btn-primary:hover:not(:disabled) {
  background: var(--primary-hover);
  box-shadow: 0 0 15px rgba(255, 87, 34, 0.4);
}

.btn-secondary {
  background: rgba(255, 255, 255, 0.05);
  color: var(--text);
  border-color: var(--border);
}

.btn-secondary:hover:not(:disabled) {
  background: rgba(255, 255, 255, 0.1);
  border-color: var(--text-light);
}

.btn-danger {
  background: var(--danger);
  color: #fff;
  box-shadow: 0 0 10px var(--danger-light);
}

.btn-danger:hover:not(:disabled) {
  background: #d50000;
  box-shadow: 0 0 15px rgba(255, 23, 68, 0.4);
}

.btn-warning {
  background: var(--warning);
  color: #000;
  box-shadow: 0 0 10px var(--warning-light);
}

.btn-warning:hover:not(:disabled) {
  background: #ffb300;
  box-shadow: 0 0 15px rgba(255, 193, 7, 0.4);
}

.btn-sm {
  padding: 0.3rem 0.65rem;
  font-size: 0.8rem;
}

.btn-block {
  width: 100%;
}

.btn-group {
  display: flex;
  gap: 0.5rem;
  align-items: center;
}

/* ============================================================
   АЛЕРТЫ
   ============================================================ */

.alert {
  padding: 0.75rem 1rem;
  border-radius: var(--radius-sm);
  font-size: 0.9rem;
  margin-bottom: 1rem;
  border-left: 4px solid transparent;
}

.alert-error {
  background: rgba(255, 23, 68, 0.1);
  color: var(--danger);
  border-left-color: var(--danger);
}

.alert-success {
  background: rgba(0, 230, 118, 0.1);
  color: var(--success);
  border-left-color: var(--success);
}

.alert-warning {
  background: rgba(255, 193, 7, 0.1);
  color: var(--warning);
  border-left-color: var(--warning);
}

/* ============================================================
   МОДАЛЬНЫЕ ОКНА
   ============================================================ */

.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.8);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  padding: 1rem;
}

.modal {
  background: var(--bg-white);
  border-radius: var(--radius);
  box-shadow: 0 0 30px rgba(0, 0, 0, 1);
  border: 1px solid var(--border);
  width: 100%;
  max-width: 550px;
  max-height: 90vh;
  overflow-y: auto;
}

.modal--wide {
  max-width: 750px;
}

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

.modal-header h2 {
  font-size: 1.15rem;
  font-weight: 600;
}

.modal-close {
  background: none;
  border: none;
  font-size: 1.25rem;
  cursor: pointer;
  color: var(--text-secondary);
  padding: 0.25rem;
  line-height: 1;
}

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

.modal-body {
  padding: 1.25rem;
}

.modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: 0.5rem;
  padding: 1rem 1.25rem;
  border-top: 1px solid var(--border);
}

/* ============================================================
   КАРТОЧКИ / ДАШБОРД
   ============================================================ */

.card {
  background: var(--bg-white);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 1.25rem;
  border: 1px solid var(--border);
}

.dashboard-cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 1rem;
  margin-bottom: 2rem;
}

.dashboard-card {
  background: var(--bg-white);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 1.25rem;
  border: 1px solid var(--border);
  border-top: 3px solid var(--text-light);
  position: relative;
  overflow: hidden;
  transition: transform var(--transition), box-shadow var(--transition);
}

.dashboard-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 1px;
  background: rgba(255, 255, 255, 0.1);
}

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

.dashboard-card--primary {
  border-top-color: var(--primary);
}

.dashboard-card--primary .dashboard-card-value {
  color: var(--primary);
  text-shadow: 0 0 15px var(--primary-light);
}

.dashboard-card--success {
  border-top-color: var(--success);
}

.dashboard-card--success .dashboard-card-value {
  color: var(--success);
  text-shadow: 0 0 15px var(--success-light);
}

.dashboard-card--warning {
  border-top-color: var(--warning);
}

.dashboard-card--warning .dashboard-card-value {
  color: var(--warning);
  text-shadow: 0 0 15px var(--warning-light);
}

.dashboard-card--danger {
  border-top-color: var(--danger);
}

.dashboard-card--danger .dashboard-card-value {
  color: var(--danger);
  text-shadow: 0 0 15px var(--danger-light);
}

.dashboard-card-value {
  font-family: var(--font-mono);
  font-size: 2rem;
  font-weight: 700;
  color: var(--text);
  line-height: 1.2;
  letter-spacing: -1px;
}

.dashboard-card-label {
  font-size: 0.85rem;
  color: var(--text-secondary);
  margin-top: 0.5rem;
  text-transform: uppercase;
  letter-spacing: 1px;
  font-weight: 600;
}

/* --- Status grid --- */
.status-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
}

.status-grid-item {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  background: var(--bg-white);
  padding: 0.5rem 1rem;
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow);
  border: 1px solid var(--border);
}

.status-grid-count {
  font-weight: 700;
  font-size: 1.1rem;
}

/* ============================================================
   БЕЙДЖИ СТАТУСОВ
   ============================================================ */

.status-badge {
  display: inline-block;
  padding: 0.2rem 0.65rem;
  border-radius: 2px;
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1px;
  border: 1px solid transparent;
}

.status-badge--draft {
  background: rgba(255, 255, 255, 0.05);
  color: var(--text-secondary);
  border-color: rgba(255, 255, 255, 0.1);
}

.status-badge--sent {
  background: var(--primary-light);
  color: var(--primary);
  border-color: rgba(255, 87, 34, 0.3);
}

.status-badge--approved {
  background: var(--success-light);
  color: var(--success);
  border-color: rgba(0, 230, 118, 0.3);
}

.status-badge--rejected {
  background: var(--danger-light);
  color: var(--danger);
  border-color: rgba(255, 23, 68, 0.3);
}

.status-badge--in_progress {
  background: var(--warning-light);
  color: var(--warning);
  border-color: rgba(255, 193, 7, 0.3);
}

.status-badge--completed {
  background: rgba(124, 58, 237, 0.15);
  color: #b19cd9;
  border-color: rgba(124, 58, 237, 0.3);
}

/* Role badges */
.role-badge {
  display: inline-block;
  padding: 0.2rem 0.55rem;
  border-radius: 3px;
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
}

.role-badge--super_admin {
  background: #fae8ff;
  color: #a21caf;
}

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

.role-badge--manager {
  background: #e0f2fe;
  color: #0284c7;
}

/* ============================================================
   ДЕТАЛИ КП
   ============================================================ */

.detail-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 1rem;
  background: var(--bg-white);
  padding: 1.25rem;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  border: 1px solid var(--border);
}

.detail-item {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
}

.detail-label {
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 1px;
}

.detail-value {
  font-size: 1rem;
  color: var(--text);
  font-family: var(--font-mono);
}

.detail-value--big {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--primary);
  text-shadow: 0 0 10px var(--primary-light);
}

/* ============================================================
   ФИЛЬТРЫ
   ============================================================ */

.filters-bar {
  display: flex;
  align-items: center;
  gap: 1rem;
  flex-wrap: wrap;
  margin-bottom: 1.5rem;
  background: var(--bg-white);
  padding: 0.75rem 1rem;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  border: 1px solid var(--border);
}

.actions-bar {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin: 0.5rem 0 1rem 0;
}

.filters-bar select {
  background: var(--bg-white);
  color: var(--text);
  border: 1px solid var(--border);
}

.filters-bar select option {
  background: var(--bg-white);
  color: var(--text);
}

/* ============================================================
   ШАГИ (ProposalCreate)
   ============================================================ */

.steps-bar {
  display: flex;
  gap: 0;
  margin-bottom: 1.5rem;
  background: var(--bg-white);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow);
  border: 1px solid var(--border);
}

.step {
  flex: 1;
  text-align: center;
  padding: 0.85rem 1rem;
  font-weight: 600;
  color: var(--text-light);
  cursor: pointer;
  border-bottom: 3px solid transparent;
  transition: all var(--transition);
  text-transform: uppercase;
  letter-spacing: 1px;
  font-size: 0.85rem;
}

.step--active {
  color: var(--primary);
  border-bottom-color: var(--primary);
  background: rgba(255, 87, 34, 0.1);
  text-shadow: 0 0 8px var(--primary-light);
}

/* ============================================================
   ПОИСК (Autocomplete)
   ============================================================ */

.search-results {
  background: var(--bg-white);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  max-height: 200px;
  overflow-y: auto;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.8);
}

.search-result-item {
  padding: 0.6rem 1rem;
  cursor: pointer;
  transition: background var(--transition);
}

.search-result-item:hover {
  background: rgba(255, 255, 255, 0.05);
}

.selected-client-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: rgba(0, 230, 118, 0.1);
  padding: 0.85rem 1rem;
  border-radius: var(--radius);
  border: 1px solid rgba(0, 230, 118, 0.3);
}

/* ============================================================
   ТАБЫ
   ============================================================ */

.tabs {
  display: flex;
  gap: 0;
  border-bottom: 2px solid var(--border);
  margin-bottom: 1.5rem;
}

.tab {
  padding: 0.7rem 1.25rem;
  background: none;
  border: none;
  cursor: pointer;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-secondary);
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
  transition: all var(--transition);
  text-transform: uppercase;
  letter-spacing: 1px;
}

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

.tab--active {
  color: var(--primary);
  border-bottom-color: var(--primary);
  text-shadow: 0 0 8px var(--primary-light);
}

/* ============================================================
   ВОРОНКА (Reports)
   ============================================================ */

.funnel {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  margin-top: 1rem;
}

.funnel-stage {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.funnel-label {
  display: flex;
  align-items: center;
  gap: 1rem;
  font-size: 0.9rem;
}

.funnel-count {
  font-weight: 700;
}

.funnel-amount {
  color: var(--text-secondary);
  font-size: 0.85rem;
}

.funnel-bar-wrapper {
  background: rgba(255, 255, 255, 0.05);
  border-radius: 2px;
  height: 28px;
  overflow: hidden;
  border: 1px solid var(--border);
}

.funnel-bar {
  height: 100%;
  border-radius: 0;
  transition: width 0.5s ease;
  min-width: 20px;
  background: linear-gradient(90deg, var(--primary-hover), var(--primary));
  box-shadow: 0 0 10px var(--primary-light);
}

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

.notifications-list {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.notification-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--bg-white);
  padding: 0.85rem 1rem;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  cursor: pointer;
  transition: background var(--transition);
  border: 1px solid var(--border);
}

.notification-item:hover {
  background: rgba(255, 255, 255, 0.03);
}

.notification-item--unread {
  border-left: 3px solid var(--primary);
  background: rgba(255, 87, 34, 0.05);
}

.notification-content {
  flex: 1;
}

.notification-message {
  font-size: 0.9rem;
  color: var(--text);
}

.notification-date {
  font-size: 0.78rem;
  color: var(--text-light);
  margin-top: 0.2rem;
  display: block;
}

.notification-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--text-light);
  flex-shrink: 0;
  margin-left: 0.75rem;
}

.notification-dot--read {
  background: var(--text-light);
  opacity: 0.55;
}

.notification-dot--unread {
  background: var(--primary);
  box-shadow: 0 0 10px var(--primary-light);
  opacity: 1;
}

/* Inline product detail */
.product-detail-inline {
  padding: 0.75rem 0;
}

.product-detail-inline ul {
  margin: 0.35rem 0 0 1.25rem;
}

.product-detail-inline li {
  font-size: 0.9rem;
  color: var(--text-secondary);
}

/* Price history inline */
.price-history-inline {
  padding: 0.5rem 0;
}

/* ============================================================
   СТРАНИЦА ЛОГИНА
   ============================================================ */

.login-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg);
  background-image:
    linear-gradient(var(--grid-color) 1px, transparent 1px),
    linear-gradient(90deg, var(--grid-color) 1px, transparent 1px);
  background-size: 20px 20px;
  padding: 1rem;
}

.login-card {
  background: var(--bg-white);
  border-radius: var(--radius);
  box-shadow: 0 0 40px rgba(0, 0, 0, 0.8);
  border: 1px solid var(--border);
  border-top: 4px solid var(--primary);
  width: 100%;
  max-width: 420px;
  padding: 2.5rem 2rem;
}

.login-header {
  text-align: center;
  margin-bottom: 2rem;
}

.login-header h1 {
  font-size: 2.5rem;
  font-weight: 800;
  color: var(--primary);
  letter-spacing: 2px;
  text-transform: uppercase;
  text-shadow: 0 0 15px var(--primary-light);
}

.login-header p {
  color: var(--text-secondary);
  margin-top: 0.5rem;
}

.login-form .form-group {
  margin-bottom: 1.25rem;
}

/* ============================================================
   ЗАГРУЗКА
   ============================================================ */

.loading {
  text-align: center;
  padding: 3rem;
  color: var(--text-secondary);
  font-size: 1rem;
}

.loading-screen {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1rem;
}

.spinner {
  width: 40px;
  height: 40px;
  border: 3px solid rgba(255, 87, 34, 0.2);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  box-shadow: 0 0 15px var(--primary-light);
}

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

/* ============================================================
   УТИЛИТЫ
   ============================================================ */

.text-center {
  text-align: center;
}

.text-right {
  text-align: right;
}

.text-muted {
  color: var(--text-secondary);
}

.text-danger {
  color: var(--danger);
}

.text-success {
  color: var(--success);
}

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

@media (max-width: 768px) {
  .sidebar {
    transform: translateX(-100%);
  }

  .sidebar--open {
    transform: translateX(0);
  }

  .sidebar-overlay {
    display: block;
  }

  .main-area {
    margin-left: 0;
  }

  .hamburger {
    display: block;
  }

  .header-title {
    display: inline;
  }

  .user-name {
    display: none;
  }

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

  .filters-bar {
    flex-direction: column;
    align-items: stretch;
  }

  .form-group--inline {
    flex-direction: column;
    align-items: stretch;
  }

  .form-group--inline input,
  .form-group--inline select {
    width: 100%;
    min-width: 0;
  }

  .dashboard-cards {
    grid-template-columns: 1fr 1fr;
  }

  .steps-bar {
    flex-direction: column;
  }

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

  .btn-group {
    flex-wrap: wrap;
  }
}

@media (max-width: 480px) {
  .dashboard-cards {
    grid-template-columns: 1fr;
  }

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

/* ============================================================
  THEME SWITCHER
  ============================================================ */
.theme-switcher {
  display: flex;
  align-items: center;
  margin-right: 1rem;
}

.theme-select {
  background: var(--bg-white);
  color: var(--text);
  border: 1px solid var(--border);
  padding: 0.4rem 0.75rem;
  border-radius: var(--radius-sm);
  font-size: 0.85rem;
  cursor: pointer;
  outline: none;
  transition: all var(--transition);
}

.theme-select:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 2px var(--primary-light);
}

/* ============================================================
   КОНСТРУКТОР ШАБЛОНА КП
   ============================================================ */

.tpl-layout {
  display: grid;
  grid-template-columns: 240px 1fr;
  gap: 1.5rem;
  min-height: 600px;
}

.tpl-layout--with-preview {
  grid-template-columns: 240px 1fr 420px;
}

/* Sidebar — список шаблонов */
.tpl-sidebar {
  background: var(--bg-white);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}

.tpl-sidebar__title {
  padding: 0.75rem 1rem;
  font-size: 0.85rem;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--text-secondary);
  border-bottom: 1px solid var(--border);
  margin: 0;
}

.tpl-sidebar__item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.65rem 1rem;
  cursor: pointer;
  border-bottom: 1px solid var(--border);
  transition: background var(--transition);
  font-size: 0.9rem;
}

.tpl-sidebar__item:hover {
  background: var(--bg-sidebar-hover);
}

.tpl-sidebar__item--active {
  background: var(--primary-light);
  border-left: 3px solid var(--primary);
}

.tpl-sidebar__item-name {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  color: var(--text);
  min-width: 0;
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.tpl-sidebar__item-count {
  font-size: 0.75rem;
  color: var(--text-secondary);
  white-space: nowrap;
  flex-shrink: 0;
}

.tpl-badge {
  font-size: 0.65rem;
  background: var(--primary);
  color: #fff;
  padding: 1px 6px;
  border-radius: 2px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

/* Редактор */
.tpl-editor {
  background: var(--bg-white);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem;
  min-height: 500px;
}

.tpl-placeholder {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 300px;
  color: var(--text-secondary);
  font-size: 0.95rem;
}

.tpl-editor__header {
  display: flex;
  align-items: center;
  gap: 1rem;
  margin-bottom: 1rem;
  padding-bottom: 1rem;
  border-bottom: 1px solid var(--border);
}

.tpl-editor__name-input {
  width: 100%;
  padding: 0.5rem 0.75rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--text);
  background: transparent;
  font-family: inherit;
  transition: border-color var(--transition);
}

.tpl-editor__name-input:focus {
  outline: none;
  border-color: var(--border-focus);
  box-shadow: 0 0 0 2px var(--primary-light);
}

/* Вкладки */
.tpl-tabs {
  display: flex;
  gap: 0;
  border-bottom: 1px solid var(--border);
  margin-bottom: 1.25rem;
  overflow-x: auto;
}

.tpl-tab {
  padding: 0.6rem 1rem;
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  cursor: pointer;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-secondary);
  transition: all var(--transition);
  white-space: nowrap;
  font-family: inherit;
}

.tpl-tab:hover {
  color: var(--text);
  background: rgba(255, 255, 255, 0.03);
}

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

.tpl-tab-content {
  animation: fadeIn 0.2s ease;
}

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

.tpl-hint {
  font-size: 0.85rem;
  color: var(--text-secondary);
  margin-bottom: 1rem;
}

/* SVG Preview */
.tpl-svg-preview {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 1rem;
  max-height: 300px;
  overflow: auto;
}

.tpl-svg-preview svg {
  max-width: 100%;
  height: auto;
}

.tpl-empty-preview {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 2rem;
  border: 2px dashed var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  font-size: 0.9rem;
}

/* Seal preview */
.tpl-seal-preview {
  display: inline-block;
  padding: 1rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: #fff;
}

.tpl-seal-preview img {
  max-width: 200px;
  height: auto;
}

/* Блоки контента */
.tpl-block-item {
  display: flex;
  gap: 0.5rem;
  margin-bottom: 0.75rem;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 0.75rem;
  transition: box-shadow var(--transition);
}

.tpl-block-item:hover {
  box-shadow: var(--shadow-md);
}

.tpl-block-item__drag {
  display: flex;
  align-items: center;
  cursor: grab;
  font-size: 1.1rem;
  color: var(--text-secondary);
  padding: 0 0.25rem;
  user-select: none;
}

.tpl-block-item__drag:active {
  cursor: grabbing;
}

.tpl-block-item__body {
  flex: 1;
  min-width: 0;
}

.tpl-block-item__row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 0.5rem;
}

.tpl-block-item__title-input {
  flex: 1;
  padding: 0.35rem 0.5rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--text);
  background: transparent;
  font-family: inherit;
}

.tpl-block-item__title-input:focus {
  outline: none;
  border-color: var(--border-focus);
}

.tpl-block-item__content {
  width: 100%;
  padding: 0.45rem 0.6rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 0.85rem;
  color: var(--text);
  background: rgba(0, 0, 0, 0.15);
  font-family: inherit;
  resize: vertical;
}

.tpl-block-item__content:focus {
  outline: none;
  border-color: var(--border-focus);
  box-shadow: 0 0 0 2px var(--primary-light);
}

/* ── System block styles ── */
.tpl-block-item--system {
  border-left: 3px solid var(--primary);
  background: rgba(var(--primary-rgb, 100, 149, 237), 0.04);
}

.tpl-block-item__title-text {
  flex: 1;
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--text);
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.tpl-system-badge {
  font-size: 0.65rem;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--primary);
  background: rgba(var(--primary-rgb, 100, 149, 237), 0.12);
  padding: 0.15rem 0.45rem;
  border-radius: 10px;
  white-space: nowrap;
}

.tpl-system-note {
  font-size: 0.78rem;
  color: var(--text-secondary);
  font-style: italic;
  padding: 0.35rem 0;
  line-height: 1.3;
}

/* ── Terms block in preview ── */
.kpp-terms-block {
  margin-top: 8px;
  font-size: calc(8px * var(--kp-font-scale, 1));
  color: #666;
}

/* Toggle */
.tpl-toggle {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  cursor: pointer;
  white-space: nowrap;
  font-size: 0.8rem;
  color: var(--text-secondary);
}

.tpl-toggle input[type="checkbox"] {
  width: 16px;
  height: 16px;
  accent-color: var(--primary);
  cursor: pointer;
}

.tpl-toggle__label {
  user-select: none;
}

/* Добавление блока */
.tpl-add-block {
  display: flex;
  gap: 0.5rem;
  align-items: center;
  margin-bottom: 1rem;
  padding: 0.75rem;
  background: var(--bg);
  border: 1px dashed var(--primary);
  border-radius: var(--radius-sm);
}

.tpl-add-block__input {
  flex: 1;
  padding: 0.4rem 0.6rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 0.9rem;
  color: var(--text);
  background: transparent;
  font-family: inherit;
}

.tpl-add-block__input:focus {
  outline: none;
  border-color: var(--border-focus);
}

/* Responsive */
@media (max-width: 1400px) {
  .tpl-layout--with-preview {
    grid-template-columns: 220px 1fr 360px;
  }
}

@media (max-width: 1100px) {
  .tpl-layout,
  .tpl-layout--with-preview {
    grid-template-columns: 1fr;
  }

  .tpl-sidebar {
    max-height: 200px;
    overflow-y: auto;
  }

  .tpl-preview-panel {
    order: -1;
  }
}

/* ============================================================
   KP PREVIEW — имитация листа A4
   ============================================================ */

.tpl-preview-panel {
  position: sticky;
  top: calc(var(--header-height) + 1rem);
  max-height: calc(100vh - var(--header-height) - 2rem);
  overflow-y: auto;
}

.kp-preview-wrapper {
  background: var(--bg-white);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.75rem;
}

.kp-preview-label {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--text-secondary);
  margin-bottom: 0.75rem;
  padding-bottom: 0.5rem;
  border-bottom: 1px solid var(--border);
}

.kp-preview-warn {
  font-size: 0.65rem;
  color: var(--warning);
  text-transform: none;
  letter-spacing: 0;
}

/* Лист A4 */
.kp-preview-page {
  /* A4 ratio: 210/297 ≈ 0.707 */
  background: #ffffff;
  color: #333;
  padding: 5px 18px;
  font-size: calc(8px * var(--kp-font-scale, 1));
  line-height: 1.5;
  min-height: 530px;
  border: 1px solid #ddd;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
  overflow: hidden;
}

/* Header */
.kpp-header {
  border-bottom: 2px solid;
  padding-bottom: 6px;
  margin-bottom: 12px;
}

.kpp-header-svg {
  margin-bottom: 6px;
}

.kpp-header-svg svg {
  max-width: 100%;
  height: auto;
  max-height: 60px;
}

.kpp-title {
  font-size: calc(13px * var(--kp-font-scale, 1));
  font-weight: bold;
  margin: 0;
}

.kpp-company {
  font-size: calc(10px * var(--kp-font-scale, 1));
  color: #7f8c8d;
}

.kpp-number {
  font-size: calc(9px * var(--kp-font-scale, 1));
  margin-top: 4px;
}

/* Info section */
.kpp-section {
  margin-bottom: 10px;
}

.kpp-section-title {
  font-size: calc(9px * var(--kp-font-scale, 1));
  font-weight: bold;
  margin: 0 0 3px;
  border-bottom: 1px solid;
  padding-bottom: 2px;
}

.kpp-info-table {
  width: 100%;
  border-collapse: collapse;
  margin-bottom: 4px;
}

.kpp-info-table td {
  padding: 1px 3px;
  vertical-align: top;
  font-size: calc(7.5px * var(--kp-font-scale, 1));
}

.kpp-label {
  font-weight: bold;
  width: 90px;
  color: #555;
}

.kpp-valid {
  font-size: calc(8px * var(--kp-font-scale, 1));
  margin-bottom: 8px;
}

/* Items table */
.kpp-items {
  width: 100%;
  border-collapse: collapse;
  margin: 8px 0;
}

.kpp-items th {
  color: white;
  padding: 4px 3px;
  text-align: left;
  font-size: calc(7px * var(--kp-font-scale, 1));
  font-weight: bold;
}

.kpp-items td {
  padding: 3px;
  border-bottom: 1px solid #ecf0f1;
  font-size: calc(7px * var(--kp-font-scale, 1));
}

/* Total */
.kpp-total {
  font-weight: bold;
  font-size: calc(10px * var(--kp-font-scale, 1));
  text-align: right;
  margin-top: 6px;
  padding: 6px;
  background-color: #ecf0f1;
}

/* Terms */
.kpp-terms {
  margin-top: 8px;
  font-size: calc(7.5px * var(--kp-font-scale, 1));
  color: #666;
}

.kpp-terms p {
  margin: 2px 0;
}

/* Content blocks */
.kpp-content-block {
  margin-top: 8px;
}

.kpp-block-body {
  font-size: calc(7.5px * var(--kp-font-scale, 1));
  color: #555;
  white-space: pre-line;
  margin-top: 2px;
}

.kpp-empty {
  color: #ccc;
  font-style: italic;
}

/* Signatures */
.kpp-signatures {
  margin-top: 20px;
  font-size: calc(8px * var(--kp-font-scale, 1));
}

.kpp-sign-line {
  border-bottom: 1px solid #333;
  margin-top: 16px;
  width: 120px;
}

.kpp-signatures small {
  font-size: calc(6.5px * var(--kp-font-scale, 1));
  color: #999;
}

.kpp-seal {
  margin-top: 6px;
}

.kpp-seal img {
  max-width: 80px;
  height: auto;
  opacity: 0.8;
}
