:root {
  /* Основная палитра: Teal (морская волна) и Slate (сланец) */
  --primary: #0f766e; /* Глубокий бирюзовый */
  --primary-hover: #0d9488;
  --primary-light: #ccfbf1; /* Светлый мятный фон */
  --primary-gradient: linear-gradient(135deg, #0f766e 0%, #0d9488 100%);
  --secondary: #475569; /* Сланцевый серый для текста */
  --bg-body: #f1f5f9; /* Очень светлый серо-голубой фон страницы */
  --bg-card: #ffffff;
  
  /* --- ЦВЕТА СТАТУСОВ --- */
  --success-bg: #dcfce7;
  --success-text: #166534;
  --process-bg: #fef9c3;
  --process-text: #a16207;
  --new-bg: #a2c5e2;
  --new-text: #043a5c;
  --new-border: #74bdfd;
  --danger-bg: #fee2e2;
  --danger-text: #991b1b;
  
  /* Тени и границы */
  --shadow-sm: 0 1px 3px rgba(0,0,0,0.1);
  --shadow-md: 0 4px 6px -1px rgba(0,0,0,0.1);
  --shadow-lg: 0 10px 15px -3px rgba(0,0,0,0.1), 0 4px 6px -2px rgba(0,0,0,0.05);
  --shadow-hover: 0 10px 15px -3px rgba(0,0,0,0.1);
  --border-radius: 12px;
  --border-color: #e2e8f0;
  --transition: all 0.2s ease-in-out;
}

* { 
  margin: 0; 
  padding: 0; 
  box-sizing: border-box; 
}

body {
  font-family: 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
  background-color: var(--bg-body);
  color: var(--secondary);
  line-height: 1.6;
}

body.login-page-body {
  display: flex;
  justify-content: center;
  align-items: center;
  min-height: 100vh;
}

.container {
  max-width: 1400px;
  margin: 0 auto;
  padding: 0 24px;
}

/* ================= HEADER ================= */
.header {
  background: var(--bg-card);
  border-bottom: 1px solid #e2e8f0;
  padding: 1rem 0;
  position: sticky;
  top: 0;
  z-index: 50;
  box-shadow: var(--shadow-sm);
}

.header .container {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.header h1 {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--primary);
  display: flex;
  align-items: center;
  gap: 10px;
  white-space: nowrap;
  margin-bottom: 0;
}

.header nav ul {
  display: flex;
  list-style: none;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.header nav a {
  text-decoration: none;
  color: var(--secondary);
  font-weight: 500;
  padding: 0.5rem 1rem;
  border-radius: 8px;
  transition: var(--transition);
  font-size: 0.95rem;
}

.header nav a:hover {
  background-color: var(--primary-light);
  color: var(--primary);
}

.header nav a.active {
  background-color: var(--primary);
  color: white;
  box-shadow: var(--shadow-md);
}

/* ================= КНОПКА ВЫХОДА ================= */
.logout {
  background-color: var(--primary);
  border: 1px solid var(--primary);
  color: white;
  padding: 0.55rem 1.25rem;
  border-radius: 8px;
  cursor: pointer;
  font-weight: 600;
  font-size: 0.9rem;
  transition: var(--transition);
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  white-space: nowrap;
}

.logout:hover {
  background-color: var(--primary-hover);
  border-color: var(--primary-hover);
  color: white;
  transform: translateY(-1px);
  box-shadow: var(--shadow-md);
}

.logout:active {
  transform: translateY(0);
  box-shadow: var(--shadow-sm);
}

.logout:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
}

.logout::before {
  content: '↪';
  font-size: 1rem;
  font-weight: 700;
  transition: transform 0.2s ease;
}

.logout:hover::before {
  transform: translateX(2px);
}

/* ================= MAIN ================= */
.main { 
  padding: 2rem 0; 
}

.main h2 {
  font-size: 1.8rem;
  color: #1e293b;
  margin-bottom: 1.5rem;
  font-weight: 700;
}

/* ================= SEARCH PANEL ================= */
.search-container {
  background: var(--bg-card);
  padding: 1.5rem;
  border-radius: var(--border-radius);
  box-shadow: var(--shadow-sm);
  margin-bottom: 2rem;
  border: 1px solid #e2e8f0;
}

.search-input {
  width: 100%;
  padding: 0.8rem 1rem;
  font-size: 1rem;
  border: 1px solid #cbd5e1;
  border-radius: 8px;
  transition: var(--transition);
  background-color: #f8fafc;
}

.search-input:focus {
  outline: none;
  border-color: var(--primary);
  background-color: #fff;
  box-shadow: 0 0 0 3px var(--primary-light);
}

/* ================= CARDS & DASHBOARD ================= */
.summary-cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 1.5rem;
  margin-bottom: 2rem;
}

.card {
  background: var(--bg-card);
  border-radius: var(--border-radius);
  padding: 1.5rem;
  box-shadow: var(--shadow-sm);
  border: 1px solid #e2e8f0;
  transition: var(--transition);
}

.card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-hover);
}

.card h3 {
  font-size: 0.9rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: #64748b;
  margin-bottom: 0.5rem;
}

.card p {
  font-size: 2rem;
  font-weight: 700;
  color: var(--primary);
}

/* ================= TABLES ================= */
.table-container {
  background: var(--bg-card);
  border-radius: var(--border-radius);
  box-shadow: var(--shadow-sm);
  border: 1px solid #e2e8f0;
  overflow: hidden;
  margin-bottom: 2rem;
  padding: 1.5rem;
}

.table-container h4 {
  margin-bottom: 1rem;
  color: var(--primary);
}

.badge-count {
  background: var(--primary-light);
  color: var(--primary);
  padding: 0.25rem 0.75rem;
  border-radius: 9999px;
  font-size: 0.85rem;
  font-weight: 600;
  margin-left: 0.5rem;
}

table, .unified-table {
  width: 100%;
  border-collapse: collapse;
}

th {
  background-color: #f1f5f9;
  color: #475569;
  font-weight: 600;
  text-align: left;
  padding: 1rem;
  font-size: 0.9rem;
  border-bottom: 2px solid #e2e8f0;
}

.unified-table th {
  background-color: var(--primary-light);
  color: var(--primary);
  border-bottom: 2px solid #cbd5e1;
}

td {
  padding: 1rem;
  border-bottom: 1px solid #e2e8f0;
  color: #334155;
}

.unified-table td {
  border-bottom: 1px solid #f1f5f9;
  vertical-align: middle;
}

tbody tr:last-child td { 
  border-bottom: none; 
}

tbody tr:hover { 
  background-color: #f8fafc; 
}

.unified-table tr:last-child td {
  border-bottom: none;
}

.unified-table tr:hover td {
  background-color: #f8fafc;
}

/* ================= STATUS BADGES ================= */
.status, .badge {
  display: inline-block;
  padding: 0.25rem 0.75rem;
  border-radius: 9999px;
  font-size: 0.8rem;
  font-weight: 700;
  text-transform: capitalize;
}

.badge {
  border-radius: 6px;
  font-size: 0.8rem;
  font-weight: 600;
  text-align: center;
  padding: 0.35rem 0.75rem;
}

.status--new, .badge--new {
  background: var(--new-bg);
  color: var(--new-text);
  border: 1px solid var(--new-border);
}

.status--success {
  background: var(--success-bg);
  color: var(--success-text);
}

.status--in-progress {
  background: var(--process-bg);
  color: var(--process-text);
}

.status--canceled {
  background: var(--danger-bg);
  color: var(--danger-text);
}

.badge--komplekt {
  background-color: #dbeafe;
  color: #1e40af;
  border: 1px solid #93c5fd;
}

.badge--technika {
  background-color: #fef3c7;
  color: #92400e;
  border: 1px solid #fcd34d;
}

.unified-table .price {
  font-weight: 500;
  color: #475569;
  white-space: nowrap;
}

.unified-table .total {
  font-weight: 700;
  color: var(--primary);
  white-space: nowrap;
}

/* ================= ЗАГОЛОВОК С ПЕРЕКЛЮЧАТЕЛЕМ ================= */
.section-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1.5rem;
  padding-bottom: 1rem;
  border-bottom: 1px solid var(--border-color);
}

.section-header h3 {
  font-size: 1.3rem;
  color: var(--primary);
  margin: 0;
  font-weight: 600;
}

.tab-switcher {
  display: flex;
  gap: 0.5rem;
}

.tab-btn {
  padding: 0.5rem 1.25rem;
  border: 1px solid var(--border-color);
  background-color: var(--bg-card);
  color: var(--text-main);
  border-radius: 8px;
  cursor: pointer;
  font-weight: 500;
  font-size: 0.9rem;
  transition: var(--transition);
}

.tab-btn:hover {
  background-color: var(--primary-light);
  color: var(--primary);
  border-color: var(--primary);
}

.tab-btn.active {
  background-color: var(--primary);
  color: white;
  border-color: var(--primary);
  box-shadow: var(--shadow-md);
}

/* ================= КОНТЕНТ ВКЛАДОК ================= */
.tab-content {
  position: relative;
}

.tab-pane {
  display: none;
}

.tab-pane.active {
  display: block;
  animation: fadeIn 0.3s ease-in-out;
}

@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(-10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* ================= ORDER TOGGLE BUTTON ================= */
.toggle-btn {
  background: none;
  border: none;
  cursor: pointer;
  font-size: 1rem;
  color: var(--primary);
  transition: transform 0.2s ease-in-out;
  width: 24px;
  text-align: center;
  padding: 0.25rem;
  border-radius: 4px;
}

.toggle-btn:hover {
  background-color: var(--primary-light);
  color: var(--primary);
}

.toggle-btn.rotated {
  transform: rotate(180deg);
}

.toggle-btn:focus {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
}

/* ================= ORDER DETAILS ROW ================= */
.order-details {
  display: none;
  background-color: #f8fafc;
}

.order-details.show {
  display: table-row;
  animation: slideDown 0.2s ease-in-out;
}

@keyframes slideDown {
  from {
    opacity: 0;
    transform: translateY(-10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.order-details td {
  padding: 0;
  border-bottom: none;
}

.details-wrapper {
  padding: 1.5rem 2rem;
}

/* ================= DETAILS GRID ================= */
.details-grid, .details-columns {
  display: grid;
  gap: 1.5rem;
}

.details-grid {
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
}

.details-columns {
  grid-template-columns: 1fr 1fr;
}

.details-section, .details-column {
  background: var(--bg-card);
  border-radius: 8px;
  padding: 1rem;
  border: 1px solid #e2e8f0;
  box-shadow: var(--shadow-sm);
}

.details-section h3, .details-title {
  font-size: 1rem;
  color: var(--primary);
  margin-bottom: 0.75rem;
  padding-bottom: 0.5rem;
  border-bottom: 1px solid #e2e8f0;
  font-weight: 600;
}

.details-title {
  margin-bottom: 1rem;
  padding-bottom: 0.5rem;
  border-bottom: 2px solid var(--primary-light);
}

/* ================= DETAILS TABLES ================= */
.details-table, .details-subtable {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
}

.details-table th, .details-subtable th {
  background-color: var(--primary-light);
  color: var(--primary);
  padding: 0.5rem 0.75rem;
  font-weight: 600;
  font-size: 0.85rem;
  border-bottom: 1px solid #cbd5e1;
  text-align: left;
}

.details-table td, .details-subtable td {
  padding: 0.5rem 0.75rem;
  border-bottom: 1px solid #f1f5f9;
  color: #334155;
}

.details-table tr:last-child td, .details-subtable tr:last-child td {
  border-bottom: none;
}

.details-table tr:hover td, .details-subtable tr:hover td {
  background-color: #f8fafc;
}

.details-table .price, .details-subtable .price {
  font-weight: 600;
  color: var(--secondary);
  white-space: nowrap;
}

.details-table .total, .details-subtable .total {
  font-weight: 700;
  color: var(--primary);
  white-space: nowrap;
}

/* ================= EMPTY STATE ================= */
.empty-list {
  color: #94a3b8;
  font-style: italic;
  text-align: center;
  padding: 1rem;
  font-size: 0.9rem;
}

/* ================= LOADING & ERROR STATES ================= */
.loading-state,
.error-state {
  text-align: center;
  padding: 3rem 1rem;
  color: #64748b;
}

.error-state {
  color: var(--danger-text);
  background-color: var(--danger-bg);
  border-radius: 8px;
  margin: 1rem;
}

.error-state strong {
  display: block;
  margin-bottom: 0.5rem;
  font-size: 1.1rem;
}

/* ================= DATE CELL ================= */
.date-cell {
  white-space: nowrap;
  font-size: 0.9rem;
  color: #64748b;
}

/* ================= AMOUNT CELL ================= */
.amount-cell {
  font-weight: 600;
  color: var(--primary);
  white-space: nowrap;
}

/* ================= FOOTER ================= */
.footer {
  text-align: center;
  padding: 2rem;
  color: #94a3b8;
  font-size: 0.9rem;
  margin-top: auto;
}

/* ================= LOGIN FORM STYLES ================= */
.login-container {
  width: 100%;
  max-width: 400px;
  padding: 20px;
}

.login-form {
  background: var(--bg-card);
  padding: 2.5rem;
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  border: 1px solid var(--border-color);
}

.login-form h2 {
  text-align: center;
  margin-bottom: 2rem;
  color: var(--primary);
  font-size: 1.8rem;
  font-weight: 700;
}

.input-group {
  margin-bottom: 1.5rem;
}

.input-group label {
  display: block;
  margin-bottom: 0.5rem;
  font-weight: 500;
  color: var(--text-dark);
  font-size: 0.95rem;
}

.input-group input {
  width: 100%;
  padding: 0.75rem 1rem;
  font-size: 1rem;
  border: 1px solid var(--border-color);
  border-radius: 8px;
  transition: var(--transition);
  background-color: #f8fafc;
  color: var(--text-dark);
}

.input-group input:focus {
  outline: none;
  border-color: var(--primary);
  background-color: #ffffff;
  box-shadow: 0 0 0 3px rgba(15, 118, 110, 0.2);
}

.btn--primary {
  background-color: var(--primary);
  color: white;
  border: none;
  font-weight: 600;
  cursor: pointer;
  transition: var(--transition);
}

.btn--primary:hover {
  background-color: var(--primary-hover);
  transform: translateY(-1px);
}

.btn--full {
  width: 100%;
  padding: 0.85rem;
  border-radius: 8px;
  font-size: 1rem;
  margin-top: 1rem;
}

.error-message {
  color: #dc2626;
  background-color: #fef2f2;
  border: 1px solid #fee2e2;
  padding: 0.75rem;
  border-radius: 8px;
  text-align: center;
  margin-bottom: 1.5rem;
  font-size: 0.9rem;
  display: none;
}

/* ================= RESPONSIVE ================= */
@media (max-width: 1024px) {
  .details-grid,
  .details-columns {
    grid-template-columns: 1fr;
    gap: 1rem;
  }
  
  .header .container {
    flex-wrap: wrap;
    gap: 1rem;
  }
  
  .header nav ul {
    order: 3;
    width: 100%;
    justify-content: center;
  }
}

@media (max-width: 768px) {
  .header .container { 
    flex-direction: column; 
    gap: 1rem; 
  }
  
  .header nav ul { 
    justify-content: center; 
  }
  
  .table-container {
    overflow-x: auto;
  }
  
  table, .unified-table {
    min-width: 800px;
  }
  
  .details-wrapper {
    padding: 1rem;
  }
  
  .toggle-btn {
    font-size: 0.9rem;
  }
  
  .logout {
    width: 100%;
    justify-content: center;
  }
  
  .section-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 1rem;
  }
  
  .tab-switcher {
    width: 100%;
  }
  
  .tab-btn {
    flex: 1;
    text-align: center;
  }
  
  .card {
    overflow-x: auto;
  }
}

/* ================= ACCESSIBILITY ================= */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

.toggle-btn:focus-visible,
.logout:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
}