/* ==========================================================
   ТЕМА ПО УМОЛЧАНИЮ: ТЁМНАЯ С КРАСНЫМИ АКЦЕНТАМИ 🔴
   ========================================================== */
:root, [data-theme="dark"] {
  --bg-main: #0c1017;
  --bg-sidebar: #121721;
  --bg-card: #171f2c;
  --bg-card-hover: #1f2a3a;
  --bg-input: #0f141d;
  --border-color: #242f40;
  --border-focus: #ef4444;

  --text-primary: #f1f5f9;
  --text-secondary: #94a3b8;
  --text-muted: #64748b;

  --bg-table-header: #131922;
  --text-table-header: #94a3b8;
  --border-table-header: #242f40;

  /* Красный акцент для кнопок и интерактива */
  --accent-primary: #ef4444;
  --accent-primary-hover: #dc2626;
  --accent-primary-gradient: linear-gradient(135deg, #ef4444, #b91c1c);
  --accent-glow: rgba(239, 68, 68, 0.45);
  --accent-light-bg: rgba(239, 68, 68, 0.15);
  --accent-border: rgba(239, 68, 68, 0.35);

  --btn-shadow: 0 4px 14px rgba(239, 68, 68, 0.35);
  --btn-hover-shadow: 0 6px 20px rgba(239, 68, 68, 0.6);

  --nav-active-bg: rgba(239, 68, 68, 0.16);
  --nav-active-text: #fca5a5;

  --accent-blue: #3b82f6;
  --accent-cyan: #f87171;
  --accent-green: #10b981;
  --accent-amber: #f59e0b;
  --accent-orange: #f97316;
  --accent-rose: #ef4444;

  /* Статусы заявок */
  --status-progress-bg: rgba(245, 158, 11, 0.16);
  --status-progress-text: #fbbf24;
  --status-pending-bg: rgba(249, 115, 22, 0.16);
  --status-pending-text: #fb923c;
  --status-completed-bg: rgba(16, 185, 129, 0.16);
  --status-completed-text: #34d399;

  --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  --sidebar-width: 260px;
  --header-height: 56px;

  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 16px);
  --safe-left: env(safe-area-inset-left, 0px);
  --safe-right: env(safe-area-inset-right, 0px);
}

/* ==========================================================
   СВЕТЛАЯ ТЕМА С СИНИМИ АКЦЕНТАМИ 🔵
   ========================================================== */
[data-theme="light"] {
  --bg-main: #f1f5f9;
  --bg-sidebar: #ffffff;
  --bg-card: #ffffff;
  --bg-card-hover: #f8fafc;
  --bg-input: #f8fafc;
  --border-color: #e2e8f0;
  --border-focus: #2563eb;

  --text-primary: #0f172a;
  --text-secondary: #475569;
  --text-muted: #94a3b8;

  --bg-table-header: #e2e8f0;
  --text-table-header: #334155;
  --border-table-header: #cbd5e1;

  /* Синий акцент для кнопок и интерактива */
  --accent-primary: #2563eb;
  --accent-primary-hover: #1d4ed8;
  --accent-primary-gradient: linear-gradient(135deg, #3b82f6, #1d4ed8);
  --accent-glow: rgba(37, 99, 235, 0.35);
  --accent-light-bg: rgba(37, 99, 235, 0.12);
  --accent-border: rgba(37, 99, 235, 0.3);

  --btn-shadow: 0 4px 14px rgba(37, 99, 235, 0.25);
  --btn-hover-shadow: 0 6px 20px rgba(37, 99, 235, 0.5);

  --nav-active-bg: rgba(37, 99, 235, 0.12);
  --nav-active-text: #2563eb;

  --accent-blue: #2563eb;
  --accent-cyan: #0284c7;
  --accent-green: #059669;
  --accent-amber: #d97706;
  --accent-orange: #ea580c;
  --accent-rose: #e11d48;

  /* Статусы заявок */
  --status-progress-bg: rgba(245, 158, 11, 0.14);
  --status-progress-text: #b45309;
  --status-pending-bg: rgba(249, 115, 22, 0.14);
  --status-pending-text: #c2410c;
  --status-completed-bg: rgba(16, 185, 129, 0.14);
  --status-completed-text: #047857;
}

*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
}

body {
  font-family: var(--font-sans);
  background-color: var(--bg-main);
  color: var(--text-primary);
  min-height: 100vh;
  min-height: 100dvh;
  line-height: 1.5;
  overflow-x: hidden;
  user-select: none;
  -webkit-user-select: none;
}

/* Общий макет с боковым меню */
.layout-wrapper {
  display: flex;
  min-height: 100vh;
  min-height: 100dvh;
  width: 100%;
}

/* ==========================================================
   БОКОВАЯ ПАНЕЛЬ (SIDEBAR)
   ========================================================== */

.sidebar {
  width: var(--sidebar-width);
  background-color: var(--bg-sidebar);
  border-right: 1px solid var(--border-color);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  z-index: 1000;
  transition: transform 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

.sidebar-header {
  height: var(--header-height);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 16px;
  border-bottom: 1px solid var(--border-color);
}

.logo-box {
  display: flex;
  align-items: center;
  gap: 10px;
}

.logo-icon {
  width: 24px;
  height: 24px;
  color: var(--accent-cyan);
}

.logo-text {
  font-size: 1.1rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--text-primary);
}

.sidebar-close-btn {
  display: none;
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-size: 1.2rem;
  cursor: pointer;
}

/* Профиль инженера в сайдбаре */
.user-profile-card {
  padding: 16px;
  margin: 12px 14px;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: 12px;
  display: flex;
  align-items: center;
  gap: 12px;
}

.user-avatar {
  width: 38px;
  height: 38px;
  border-radius: 10px;
  background: linear-gradient(135deg, #2563eb, #06b6d4);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 1rem;
  flex-shrink: 0;
}

.user-info {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.user-name {
  font-size: 0.88rem;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.user-role {
  font-size: 0.75rem;
  color: var(--accent-cyan);
}

.role-pill-badge {
  font-size: 0.72rem;
  padding: 2px 8px;
  border-radius: 6px;
  background: rgba(245, 158, 11, 0.15);
  border: 1px solid rgba(245, 158, 11, 0.3);
  color: #fbbf24;
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  white-space: nowrap;
  max-width: 100%;
}

.role-pill-badge.user {
  background: rgba(59, 130, 246, 0.15);
  border-color: rgba(59, 130, 246, 0.3);
  color: #60a5fa;
}

[data-theme="light"] .role-pill-badge {
  background: rgba(217, 119, 6, 0.12);
  border-color: rgba(217, 119, 6, 0.3);
  color: #b45309;
}

[data-theme="light"] .role-pill-badge.user {
  background: rgba(37, 99, 235, 0.12);
  border-color: rgba(37, 99, 235, 0.3);
  color: #1d4ed8;
}

/* Меню навигации */
.sidebar-nav {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 8px 12px;
  flex: 1;
  overflow-y: auto;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 14px;
  border-radius: 10px;
  border: none;
  background: transparent;
  color: var(--text-secondary);
  font-size: 0.88rem;
  font-weight: 500;
  cursor: pointer;
  text-align: left;
  transition: all 0.15s ease;
  width: 100%;
}

.nav-item:hover {
  background: var(--bg-card);
  color: var(--text-primary);
}

.nav-item.active {
  background: var(--nav-active-bg);
  color: var(--nav-active-text);
  font-weight: 600;
  box-shadow: inset 3px 0 0 var(--accent-primary);
}

.nav-icon {
  font-size: 1.1rem;
}

.nav-label {
  flex: 1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.nav-badge {
  font-size: 0.72rem;
  padding: 2px 7px;
  border-radius: 99px;
  background: rgba(255, 255, 255, 0.1);
  color: var(--text-primary);
}

.nav-badge.highlight {
  background: rgba(16, 185, 129, 0.2);
  color: #34d399;
  font-weight: 600;
}

.nav-badge.success {
  background: rgba(16, 185, 129, 0.18);
  color: #10b981;
  font-weight: 600;
}

.sidebar-footer {
  padding: 14px 16px;
  border-top: 1px solid var(--border-color);
}

.cloud-status {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.78rem;
  color: var(--text-muted);
}

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background-color: var(--accent-green);
  box-shadow: 0 0 8px rgba(16, 185, 129, 0.6);
}

/* ==========================================================
   ОСНОВНАЯ ОБЛАСТЬ (MAIN WRAPPER & HEADER)
   ========================================================== */

.main-wrapper {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 100vh;
}

.top-header {
  height: var(--header-height);
  background-color: var(--bg-sidebar);
  border-bottom: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 20px;
  position: sticky;
  top: 0;
  z-index: 100;
}

.header-left {
  display: flex;
  align-items: center;
  gap: 12px;
}

.menu-toggle-btn {
  display: none;
  background: transparent;
  border: 1px solid var(--border-color);
  color: var(--text-primary);
  width: 36px;
  height: 36px;
  border-radius: 8px;
  font-size: 1.1rem;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}

.header-title-box {
  display: flex;
  align-items: center;
  gap: 8px;
}

.header-cube-icon {
  width: 20px;
  height: 20px;
  color: var(--accent-cyan);
}

.page-title {
  font-size: 1.05rem;
  font-weight: 600;
  letter-spacing: -0.01em;
}

.header-right {
  display: flex;
  align-items: center;
  gap: 12px;
}

.cloud-badge {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.78rem;
  color: var(--text-secondary);
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  padding: 4px 10px;
  border-radius: 20px;
}

.theme-btn {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  color: var(--text-primary);
  width: 36px;
  height: 36px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 1.1rem;
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

.theme-btn:hover {
  background: var(--accent-light-bg);
  border-color: var(--accent-border);
  box-shadow: 0 0 12px var(--accent-glow);
  transform: scale(1.05);
}

.theme-btn:active {
  transform: scale(0.92);
}

/* Рабочее тело контента */
.content-body {
  flex: 1;
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  max-width: 1400px;
  width: 100%;
  margin: 0 auto;
}

/* ==========================================================
   СЕКЦИЯ 1: ТАБЛИЦА ЗАЯВОК (КАК НА СКРИНШОТЕ)
   ========================================================== */

.section-top-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 12px;
}

.section-heading h2 {
  font-size: 1.25rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 8px;
}

.counter-badge {
  font-size: 0.95rem;
  color: var(--accent-cyan);
  font-weight: 600;
}

.subtitle-text {
  font-size: 0.82rem;
  color: var(--text-secondary);
  margin-top: 2px;
}

.search-and-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.search-input-wrap {
  position: relative;
  display: flex;
  align-items: center;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: 8px;
  padding: 0 12px;
  width: 320px;
  max-width: 100%;
}

.search-input-wrap input {
  width: 100%;
  border: none;
  background: transparent;
  padding: 8px 0;
  font-size: 0.85rem;
  color: var(--text-primary);
  outline: none;
  font-family: inherit;
}

.search-input-wrap input::placeholder {
  color: var(--text-muted);
}

/* Панель фильтров */
.filters-panel {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: 10px;
  overflow: hidden;
}

.filters-header {
  padding: 10px 16px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  cursor: pointer;
  background: rgba(255, 255, 255, 0.02);
}

.filters-title {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-secondary);
}

.filters-arrow {
  font-size: 0.75rem;
  color: var(--text-muted);
  transition: transform 0.2s;
}

.filters-body {
  padding: 14px 16px;
  display: flex;
  align-items: center;
  gap: 20px;
  flex-wrap: wrap;
  border-top: 1px solid var(--border-color);
}

.filter-group {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.82rem;
}

.filter-chips {
  display: flex;
  gap: 6px;
}

.chip {
  background: var(--bg-main);
  border: 1px solid var(--border-color);
  color: var(--text-secondary);
  border-radius: 6px;
  padding: 5px 10px;
  font-size: 0.78rem;
  cursor: pointer;
  transition: all 0.15s;
}

.chip.active {
  background: var(--accent-primary-gradient);
  color: #fff;
  border-color: var(--accent-primary);
  box-shadow: var(--btn-shadow);
}

.styled-select {
  background: var(--bg-main);
  border: 1px solid var(--border-color);
  color: var(--text-primary);
  border-radius: 6px;
  padding: 5px 10px;
  font-size: 0.82rem;
  outline: none;
}

/* Таблица заявок */
.table-container {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: 10px;
  overflow-x: auto;
}

.tickets-table {
  width: 100%;
  border-collapse: collapse;
  text-align: left;
  font-size: 0.82rem;
}

.tickets-table th {
  background: var(--bg-table-header, #131922);
  color: var(--text-table-header, var(--text-secondary));
  font-weight: 600;
  padding: 12px 14px;
  border-bottom: 1px solid var(--border-table-header, var(--border-color));
  white-space: nowrap;
  transition: background 0.2s ease, color 0.2s ease, border-color 0.2s ease;
}

[data-theme="light"] .tickets-table th {
  background: #e2e8f0;
  color: #334155;
  border-bottom: 1px solid #cbd5e1;
}

.tickets-table td {
  padding: 12px 14px;
  border-bottom: 1px solid var(--border-color);
  color: var(--text-primary);
  vertical-align: middle;
}

.tickets-table tbody tr {
  transition: background 0.15s;
}

.tickets-table tbody tr:hover {
  background: var(--bg-card-hover);
}

[data-theme="light"] .tickets-table tbody tr:hover {
  background: #f8fafc;
}

/* Бейджи колонок таблицы */
.ticket-num-badge {
  color: #60a5fa;
  font-weight: 600;
  cursor: pointer;
  display: inline-block;
}

.ticket-type-pill {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 4px;
  border: 1px solid rgba(239, 68, 68, 0.4);
  color: #f87171;
  font-size: 0.72rem;
  font-weight: 500;
}

.ticket-private-pill {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 8px;
  border-radius: 4px;
  background: rgba(245, 158, 11, 0.15);
  border: 1px solid rgba(245, 158, 11, 0.35);
  color: #fbbf24;
  font-size: 0.72rem;
  font-weight: 600;
}

[data-theme="light"] .ticket-private-pill {
  background: rgba(217, 119, 6, 0.12);
  border-color: rgba(217, 119, 6, 0.35);
  color: #b45309;
}

.ticket-store-badge {
  background: rgba(6, 182, 212, 0.12);
  color: #22d3ee;
  border: 1px solid rgba(6, 182, 212, 0.3);
  padding: 3px 8px;
  border-radius: 4px;
  font-weight: 600;
  font-size: 0.75rem;
}

.ticket-status-pill {
  padding: 4px 10px;
  border-radius: 20px;
  font-size: 0.75rem;
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.ticket-status-pill.in_progress {
  background: var(--status-progress-bg);
  color: var(--status-progress-text);
}

.ticket-status-pill.pending {
  background: var(--status-pending-bg);
  color: var(--status-pending-text);
}

.ticket-status-pill.completed {
  background: var(--status-completed-bg);
  color: var(--status-completed-text);
}

.ticket-priority-pill {
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 0.72rem;
  font-weight: 500;
}

.ticket-priority-pill.urgent {
  background: rgba(239, 68, 68, 0.2);
  color: #ef4444;
}

.ticket-priority-pill.medium {
  background: rgba(37, 99, 235, 0.2);
  color: #60a5fa;
}

.ticket-priority-pill.normal {
  background: rgba(16, 185, 129, 0.2);
  color: #34d399;
}

.ticket-reward-text {
  color: var(--accent-green);
  font-weight: 600;
}

.row-actions {
  display: flex;
  align-items: center;
  gap: 6px;
  white-space: nowrap;
}

.icon-action-btn {
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid var(--border-color);
  color: var(--text-secondary);
  border-radius: 6px;
  padding: 5px 8px;
  cursor: pointer;
  font-size: 0.85rem;
  transition: all 0.15s ease;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.icon-action-btn:hover {
  background: rgba(255, 255, 255, 0.15);
  color: var(--text-primary);
  border-color: var(--border-focus);
}

.icon-action-btn.delete-btn {
  color: #f87171;
  background: rgba(239, 68, 68, 0.1);
  border-color: rgba(239, 68, 68, 0.3);
}

.icon-action-btn.delete-btn:hover {
  background: rgba(239, 68, 68, 0.25);
  border-color: #ef4444;
}

[data-theme="light"] .icon-action-btn {
  background: #f1f5f9;
  border-color: #cbd5e1;
  color: #475569;
}

[data-theme="light"] .icon-action-btn:hover {
  background: #e2e8f0;
  color: #0f172a;
  border-color: var(--accent-primary);
}

[data-theme="light"] .icon-action-btn.delete-btn {
  color: #dc2626;
  background: rgba(239, 68, 68, 0.08);
  border-color: rgba(239, 68, 68, 0.25);
}

[data-theme="light"] .icon-action-btn.delete-btn:hover {
  background: rgba(239, 68, 68, 0.18);
  border-color: #dc2626;
}

/* Мобильный список карточек (скрыт на десктопе) */
.mobile-tickets-list {
  display: none;
  flex-direction: column;
  gap: 10px;
  padding: 12px;
}

.mobile-ticket-card {
  background: var(--bg-main);
  border: 1px solid var(--border-color);
  border-radius: 10px;
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.mobile-card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.mobile-card-desc {
  font-size: 0.88rem;
  color: var(--text-primary);
  line-height: 1.35;
}

.mobile-card-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
}

/* Пагинация */
.pagination-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 4px;
  font-size: 0.8rem;
  color: var(--text-secondary);
}

.page-size-selector select {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  color: var(--text-primary);
  border-radius: 4px;
  padding: 2px 6px;
  margin-left: 6px;
}

.pagination-buttons {
  display: inline-flex;
  gap: 6px;
  margin-left: 12px;
}

.page-nav-btn {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  color: var(--text-secondary);
  border-radius: 4px;
  padding: 2px 8px;
  cursor: pointer;
}

/* ==========================================================
   СЕКЦИЯ 2: ЗАРПЛАТА И ФИНАНСЫ
   ========================================================== */

.finance-metrics-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 14px;
}

.metric-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: 12px;
  padding: 16px 18px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  position: relative;
  overflow: hidden;
}

.metric-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
}

.income-card::before { background: linear-gradient(90deg, #10b981, #06b6d4); }
.expense-card::before { background: linear-gradient(90deg, #ef4444, #f97316); }
.balance-card::before { background: linear-gradient(90deg, #2563eb, #8b5cf6); }
.rate-card::before { background: linear-gradient(90deg, #f59e0b, #eab308); }

.metric-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.metric-title {
  font-size: 0.82rem;
  color: var(--text-secondary);
  font-weight: 500;
}

.metric-icon {
  font-size: 1.2rem;
}

.metric-value {
  font-size: 1.45rem;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.income-card .metric-value { color: #34d399; }
.expense-card .metric-value { color: #f87171; }
.balance-card .metric-value { color: #60a5fa; }

.metric-breakdown {
  font-size: 0.75rem;
  color: var(--text-muted);
  display: flex;
  gap: 8px;
}

.metric-breakdown strong {
  color: var(--text-primary);
}

.metric-rates {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 0.78rem;
}

.rate-item {
  display: flex;
  justify-content: space-between;
}

.rate-val {
  font-weight: 600;
  color: var(--accent-amber);
}

/* Прогресс бюджета */
.budget-progress-section {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: 12px;
  padding: 14px 18px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.budget-progress-header {
  display: flex;
  justify-content: space-between;
  font-size: 0.82rem;
  font-weight: 600;
}

.budget-bar-track {
  width: 100%;
  height: 8px;
  background: var(--bg-main);
  border-radius: 99px;
  overflow: hidden;
}

.budget-bar-fill {
  height: 100%;
  background: linear-gradient(90deg, #10b981, #f59e0b, #ef4444);
  border-radius: 99px;
  transition: width 0.4s ease;
}

/* Две колонки расходов */
.finance-columns-grid {
  display: grid;
  grid-template-columns: 1.5fr 1fr;
  gap: 16px;
}

.finance-panel {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: 12px;
  padding: 18px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.panel-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.panel-header h3 {
  font-size: 1rem;
  font-weight: 600;
}

.panel-badge {
  font-size: 0.75rem;
  color: var(--text-muted);
}

.expenses-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-height: 400px;
  overflow-y: auto;
}

.expense-item {
  background: var(--bg-main);
  border: 1px solid var(--border-color);
  border-radius: 8px;
  padding: 10px 12px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.expense-info-left {
  display: flex;
  align-items: center;
  gap: 10px;
}

.expense-cat-icon {
  font-size: 1.2rem;
}

.expense-desc-title {
  font-size: 0.85rem;
  font-weight: 600;
}

.expense-date-sub {
  font-size: 0.72rem;
  color: var(--text-muted);
}

.expense-amount-right {
  display: flex;
  align-items: center;
  gap: 10px;
}

.expense-amount-val {
  color: #f87171;
  font-weight: 700;
  font-size: 0.95rem;
}

.expense-delete-btn {
  background: transparent;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 0.85rem;
  padding: 2px 4px;
}

.expense-delete-btn:hover {
  color: var(--accent-rose);
}

.categories-breakdown-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.cat-breakdown-row {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 0.8rem;
}

.cat-breakdown-info {
  display: flex;
  justify-content: space-between;
}

.cat-progress-track {
  width: 100%;
  height: 6px;
  background: var(--bg-main);
  border-radius: 99px;
  overflow: hidden;
}

.cat-progress-fill {
  height: 100%;
  background: var(--accent-cyan);
  border-radius: 99px;
}

/* ==========================================================
   СЕКЦИЯ 3 & 4: ДАШБОРД, МАГАЗИНЫ И НАСТРОЙКИ
   ========================================================== */

.analytics-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 16px;
}

.analytics-card, .settings-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: 12px;
  padding: 20px;
}

.status-summary-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-top: 14px;
}

.summary-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 12px;
  background: var(--bg-main);
  border-radius: 8px;
}

.efficiency-box {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 24px;
  text-align: center;
}

.efficiency-number {
  font-size: 2.8rem;
  font-weight: 800;
  color: var(--accent-green);
}

.role-locked-notice {
  background: rgba(239, 68, 68, 0.12);
  border: 1px solid rgba(239, 68, 68, 0.3);
  color: #fca5a5;
  padding: 10px 14px;
  border-radius: 8px;
  font-size: 0.82rem;
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 12px;
}

.notification-toggle-group {
  background: var(--bg-main);
  border: 1px solid var(--border-color);
  border-radius: 10px;
  padding: 12px 14px;
}

.toggle-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
}

.toggle-title {
  font-size: 0.88rem;
  font-weight: 600;
  color: var(--text-primary);
  display: block;
}

.toggle-desc {
  font-size: 0.75rem;
  color: var(--text-secondary);
  margin-top: 2px;
}

/* Переключатель Switch */
.switch {
  position: relative;
  display: inline-block;
  width: 44px;
  height: 24px;
  flex-shrink: 0;
}

.switch input {
  opacity: 0;
  width: 0;
  height: 0;
}

.slider {
  position: absolute;
  cursor: pointer;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: var(--bg-card);
  border: 1px solid var(--border-color);
  transition: .3s cubic-bezier(0.4, 0, 0.2, 1);
  border-radius: 24px;
}

.slider:before {
  position: absolute;
  content: "";
  height: 16px;
  width: 16px;
  left: 3px;
  bottom: 3px;
  background-color: var(--text-secondary);
  transition: .3s cubic-bezier(0.4, 0, 0.2, 1);
  border-radius: 50%;
}

input:checked + .slider {
  background: var(--accent-primary-gradient);
  border-color: var(--accent-primary);
  box-shadow: 0 0 10px var(--accent-glow);
}

input:checked + .slider:before {
  transform: translateX(20px);
  background-color: #ffffff;
}

/* Бейдж онлайн / последнего визита */
.last-seen-badge {
  font-size: 0.72rem;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 6px;
  border-radius: 4px;
  background: rgba(255, 255, 255, 0.04);
}

.last-seen-badge.online {
  color: #34d399;
  background: rgba(16, 185, 129, 0.12);
  font-weight: 600;
}

.last-seen-badge.offline {
  color: var(--text-muted);
}

/* Отключенные поля */
select:disabled, input:disabled {
  opacity: 0.6;
  cursor: not-allowed;
  background: var(--bg-main) !important;
}

/* ==========================================================
   СЕКЦИЯ МОЯ СЕМЬЯ (.team-grid и .family-hero-card)
   ========================================================== */

.family-hero-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: 14px;
  padding: 18px 20px;
  margin-bottom: 20px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  box-shadow: var(--card-shadow);
  transition: all 0.2s ease;
  position: relative;
  overflow: hidden;
}

.family-hero-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  background: var(--accent-primary-gradient);
}

.family-hero-main {
  display: flex;
  align-items: center;
  gap: 16px;
}

.family-hero-emblem {
  font-size: 2.2rem;
  width: 54px;
  height: 54px;
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.family-hero-info {
  flex: 1;
  min-width: 0;
}

.family-hero-title-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}

.family-hero-name {
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--text-primary);
  margin: 0;
}

.family-hero-motto {
  font-size: 0.85rem;
  color: var(--text-secondary);
  margin: 4px 0 0 0;
}

.family-stats-pills {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
  gap: 10px;
  padding-top: 14px;
  border-top: 1px solid var(--border-color);
}

.family-stat-pill {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--bg-main);
  border: 1px solid var(--border-color);
  border-radius: 8px;
  padding: 8px 12px;
  font-size: 0.8rem;
}

.family-stat-icon {
  font-size: 1rem;
}

.family-stat-label {
  color: var(--text-muted);
}

.family-stat-pill strong {
  margin-left: auto;
  color: var(--accent-primary);
  font-size: 0.95rem;
}

@media (max-width: 600px) {
  .family-hero-main {
    flex-direction: column;
    align-items: flex-start;
  }
  .family-stats-pills {
    grid-template-columns: 1fr 1fr;
  }
}

.team-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 16px;
}

.user-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: 14px;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  transition: all 0.2s ease;
}

.user-card:hover {
  border-color: var(--border-focus);
  transform: translateY(-2px);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.25);
}

.user-card-header {
  display: flex;
  align-items: center;
  gap: 12px;
}

.user-avatar-lg {
  width: 46px;
  height: 46px;
  border-radius: 12px;
  background: var(--accent-primary-gradient);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 1.2rem;
  flex-shrink: 0;
  box-shadow: var(--btn-shadow);
}

.user-card-title-box {
  display: flex;
  flex-direction: column;
  min-width: 0;
  flex: 1;
}

.user-card-name {
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.user-card-pos {
  font-size: 0.75rem;
  color: var(--text-secondary);
  margin-top: 1px;
}

.user-card-meta {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 10px 12px;
  background: var(--bg-main);
  border-radius: 8px;
  font-size: 0.8rem;
}

.user-meta-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.user-meta-label {
  color: var(--text-muted);
}

.user-meta-val {
  color: var(--text-primary);
  font-weight: 500;
}

.user-card-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding-top: 6px;
  border-top: 1px solid var(--border-color);
}

.user-tickets-badge {
  font-size: 0.75rem;
  color: var(--accent-primary);
  font-weight: 600;
}

.user-card-actions {
  display: flex;
  gap: 6px;
}

/* Кнопки */
.btn {
  border: none;
  border-radius: 8px;
  padding: 9px 16px;
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  font-family: inherit;
  transition: all 0.15s ease;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
}

.btn-accent {
  background: var(--accent-primary-gradient);
  color: #ffffff;
  box-shadow: var(--btn-shadow);
  border: 1px solid transparent;
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

.btn-accent:hover {
  background: var(--accent-primary-hover);
  box-shadow: var(--btn-hover-shadow);
  transform: translateY(-1px);
}

.btn-accent:active {
  transform: translateY(0) scale(0.98);
}

.btn-secondary {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  color: var(--text-primary);
}

.btn-danger {
  background: rgba(239, 68, 68, 0.2);
  color: #ef4444;
}

/* ==========================================================
   МОДАЛЬНЫЕ ОКНА (<dialog>)
   ========================================================== */

.custom-modal {
  margin: auto;
  border: none;
  border-radius: 16px;
  background: var(--bg-card);
  color: var(--text-primary);
  box-shadow: 0 25px 50px rgba(0, 0, 0, 0.45);
  width: 92%;
  max-width: 520px;
  max-height: 90vh;
  max-height: 90dvh;
  overflow: hidden;
  padding: 0;
}

.custom-modal::backdrop {
  background: rgba(0, 0, 0, 0.65);
  backdrop-filter: blur(4px);
}

.modal-form {
  display: flex;
  flex-direction: column;
  max-height: 90vh;
}

.modal-header {
  padding: 16px 20px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 1px solid var(--border-color);
}

.modal-header h3 {
  font-size: 1.1rem;
  font-weight: 700;
}

.modal-close-btn {
  background: transparent;
  border: none;
  font-size: 1.2rem;
  color: var(--text-muted);
  cursor: pointer;
}

.modal-body {
  padding: 18px 20px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.form-group label {
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--text-secondary);
}

.form-group input,
.form-group select,
.form-group textarea {
  background: var(--bg-input);
  border: 1px solid var(--border-color);
  border-radius: 8px;
  padding: 10px 12px;
  font-size: 0.88rem;
  color: var(--text-primary);
  font-family: inherit;
  outline: none;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
  border-color: var(--border-focus);
}

.form-row {
  display: flex;
  gap: 12px;
}

.half-width {
  flex: 1;
}

.modal-footer {
  padding: 14px 20px;
  border-top: 1px solid var(--border-color);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.modal-actions-right {
  display: flex;
  gap: 8px;
  margin-left: auto;
}

/* ==========================================================
   КОНСТРУКТОР ЗАКАЗА ПРОДУКТОВ И ЖИДКОСТЕЙ (КГ / ЛИТРЫ)
   ========================================================== */

.order-items-builder {
  background: var(--bg-main);
  border: 1px solid var(--border-color);
  border-radius: 10px;
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.builder-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.builder-header label {
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--accent-cyan);
}

.btn-sm {
  padding: 4px 10px;
  font-size: 0.75rem;
  border-radius: 6px;
}

.items-rows-container {
  display: flex;
  flex-direction: column;
  gap: 10px;
  max-height: 250px;
  overflow-y: auto;
  padding-right: 2px;
}

.item-row {
  display: flex;
  flex-direction: column;
  gap: 8px;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: 8px;
  padding: 10px;
  transition: all 0.15s ease;
}

.item-row:focus-within {
  border-color: var(--border-focus);
}

.item-row-header {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
}

.item-name-input {
  flex: 1;
  min-width: 0;
  background: var(--bg-input);
  border: 1px solid var(--border-color);
  border-radius: 6px;
  padding: 8px 10px;
  font-size: 0.88rem;
  color: var(--text-primary);
  outline: none;
  font-family: inherit;
}

.item-name-input:focus {
  border-color: var(--border-focus);
}

.remove-item-btn {
  background: rgba(239, 68, 68, 0.1);
  border: 1px solid rgba(239, 68, 68, 0.25);
  color: #f87171;
  cursor: pointer;
  width: 34px;
  height: 34px;
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.95rem;
  font-weight: bold;
  flex-shrink: 0;
  transition: all 0.15s ease;
}

.remove-item-btn:hover {
  background: rgba(239, 68, 68, 0.25);
  color: #fff;
  border-color: #ef4444;
}

.item-row-details {
  display: grid;
  grid-template-columns: 1fr 1.1fr 1.3fr;
  gap: 8px;
  width: 100%;
}

.item-field-col {
  display: flex;
  flex-direction: column;
  gap: 3px;
  min-width: 0;
}

.item-mini-label {
  font-size: 0.72rem;
  font-weight: 500;
  color: var(--text-secondary);
  white-space: nowrap;
}

.item-mini-input,
.item-mini-select {
  width: 100%;
  min-width: 0;
  background: var(--bg-input);
  border: 1px solid var(--border-color);
  border-radius: 6px;
  padding: 7px 8px;
  font-size: 0.84rem;
  color: var(--text-primary);
  outline: none;
  font-family: inherit;
  box-sizing: border-box;
}

.item-mini-input:focus,
.item-mini-select:focus {
  border-color: var(--border-focus);
}

.builder-total-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding-top: 8px;
  border-top: 1px dashed var(--border-color);
  font-size: 0.85rem;
}

.builder-total-row strong {
  color: var(--accent-green);
  font-size: 1rem;
}

/* Бейджи продуктов в строке заявки */
.ticket-items-preview {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-top: 4px;
}

.product-item-chip {
  background: rgba(6, 182, 212, 0.1);
  border: 1px solid rgba(6, 182, 212, 0.25);
  color: #22d3ee;
  padding: 1px 6px;
  border-radius: 4px;
  font-size: 0.72rem;
  font-weight: 500;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.product-item-chip.liquid {
  background: rgba(59, 130, 246, 0.1);
  border-color: rgba(59, 130, 246, 0.25);
  color: #60a5fa;
}

.product-item-chip.weight {
  background: rgba(245, 158, 11, 0.1);
  border-color: rgba(245, 158, 11, 0.25);
  color: #fbbf24;
}

/* ==========================================================
   АДАПТИВНОСТЬ (МОБИЛЬНЫЕ УСТРОЙСТВА)
   ========================================================== */

@media (max-width: 900px) {
  .finance-columns-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 768px) {
  .menu-toggle-btn {
    display: flex;
  }

  .sidebar {
    position: fixed;
    top: 0;
    bottom: 0;
    left: 0;
    transform: translateX(-100%);
    box-shadow: 10px 0 30px rgba(0, 0, 0, 0.5);
  }

  .sidebar.open {
    transform: translateX(0);
  }

  .sidebar-close-btn {
    display: block;
  }

  .sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(2px);
    z-index: 999;
  }

  .sidebar-overlay.open {
    display: block;
  }

  /* На мобильных скрываем громоздкую таблицу и показываем карточки */
  .tickets-table {
    display: none;
  }

  .mobile-tickets-list {
    display: flex;
  }

  .search-input-wrap {
    width: 100%;
  }

  .content-body {
    padding: 14px;
  }

  .custom-modal {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    width: 100%;
    max-width: 100%;
    margin: 0;
    border-radius: 20px 20px 0 0;
  }

  .modal-body {
    padding: 14px 12px;
  }

  .modal-header {
    padding: 14px 16px;
  }

  .modal-footer {
    padding: 12px 14px;
  }

  .form-row {
    flex-direction: column;
    gap: 10px;
  }
}
