/* ====================================
   Энергокомфорт - Unified Design System
   ==================================== */

:root {
  /* Color Palette */
  --bg: #FFFFFF;
  --surface: #FAFAFA;
  --elevated: #F7F7F8;
  --text-primary: #111111;
  --text-secondary: #4A4A4A;
  --muted: #8A8A8A;
  --divider: rgba(0,0,0,0.08);
  --accent: #FFA500;
  --accent-hover: #FF8C00;
  --accent-muted: #FFF4E6;
  --link: #1F3A93;
  --success: #16A34A;
  --success-light: rgba(22, 163, 74, 0.03);
  --warning: #D97706;
  --danger: #DC2626;
  --yellow-gradient-start: #FFD93D;
  --yellow-gradient-end: #FFA500;
  
  /* Spacing */
  --space-xs: 4px;
  --space-sm: 8px;
  --space-md: 16px;
  --space-lg: 24px;
  --space-xl: 32px;
  --space-2xl: 48px;
  
  /* Border Radius */
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --radius-xl: 20px;
  --radius-full: 999px;
  
  /* Shadows */
  --shadow-sm: 0 1px 2px rgba(0,0,0,0.05);
  --shadow-md: 0 4px 16px rgba(0, 0, 0, 0.04);
  --shadow-lg: 0 12px 32px rgba(0, 0, 0, 0.12);
  --shadow-accent: 0 2px 8px rgba(255, 165, 0, 0.3);
  
  /* Transitions */
  --transition-fast: 0.2s ease;
  --transition-base: 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
}

/* ====================================
   Reset & Base Styles
   ==================================== */

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: 'Inter', -apple-system, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  background: var(--bg);
  color: var(--text-primary);
  line-height: 1.5;
  overflow-x: hidden;
  position: relative;
  min-height: 100vh;
}

/* ====================================
   Background Effects
   ==================================== */

.gradient-orb {
  position: fixed;
  top: -300px;
  left: 50%;
  transform: translateX(-50%);
  width: 100vw;
  height: 800px;
  background: linear-gradient(
    180deg,
    #FFE082 0%,
    #FFD54F 15%,
    #FFC107 30%,
    #FFA726 50%,
    rgba(255, 167, 38, 0.6) 70%,
    transparent 100%
  );
  border-radius: 0 0 50% 50%;
  filter: blur(60px);
  opacity: 0.7;
  animation: pulseGradient 4s ease-in-out infinite;
  pointer-events: none;
  z-index: 0;
}

@keyframes pulseGradient {
  0%, 100% {
    transform: translateX(-50%) translateY(0) scale(1);
    opacity: 0.6;
  }
  50% {
    transform: translateX(-50%) translateY(-20px) scale(1.03);
    opacity: 0.8;
  }
}

/* ====================================
   Login Page Styles
   ==================================== */

.login-container {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: var(--space-xl);
}

.login-card {
  background: rgba(255, 255, 255, 0.95);
  backdrop-filter: blur(20px);
  border-radius: var(--radius-xl);
  padding: 60px 50px;
  width: 100%;
  max-width: 500px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.15);
  border: 1px solid rgba(255, 255, 255, 0.5);
}

.login-title {
  color: var(--text-primary);
  font-size: 28px;
  font-weight: 300;
  letter-spacing: 4px;
  text-align: center;
  margin-bottom: 50px;
  text-transform: uppercase;
}

.input-group {
  position: relative;
  margin-bottom: 28px;
}

.input-icon {
  position: absolute;
  left: 0;
  top: 0;
  width: 60px;
  height: 56px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--surface);
  border-radius: var(--radius-md) 0 0 var(--radius-md);
  color: var(--muted);
  font-size: 20px;
  z-index: 1;
}

.login-input {
  width: 100%;
  height: 56px;
  padding: 0 50px 0 70px;
  background: var(--bg);
  border: 1px solid var(--divider);
  border-radius: var(--radius-md);
  color: var(--text-primary);
  font-size: 15px;
  font-family: inherit;
  transition: all 0.3s ease;
}

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

.login-input:focus {
  outline: none;
  background: var(--bg);
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(255, 165, 0, 0.15);
}

.password-toggle {
  position: absolute;
  right: 15px;
  top: 50%;
  transform: translateY(-50%);
  background: none;
  border: none;
  color: var(--muted);
  cursor: pointer;
  padding: 8px;
  font-size: 18px;
  transition: color 0.2s ease;
  z-index: 2;
}

.password-toggle:hover {
  color: var(--text-primary);
}

.login-btn {
  width: 100%;
  height: 56px;
  margin-top: 40px;
  background: linear-gradient(135deg, var(--accent) 0%, var(--accent-hover) 100%);
  border: none;
  border-radius: var(--radius-md);
  color: #FFFFFF;
  font-size: 16px;
  font-weight: 600;
  letter-spacing: 2px;
  text-transform: uppercase;
  cursor: pointer;
  transition: all 0.3s ease;
  box-shadow: 0 4px 20px rgba(255, 165, 0, 0.3);
}

.login-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 30px rgba(255, 165, 0, 0.4);
}

.login-btn:active {
  transform: translateY(0);
}

/* ====================================
   Layout Components
   ==================================== */

header {
  position: relative;
  padding: var(--space-xl) var(--space-xl) var(--space-lg);
  background: transparent;
  z-index: 10;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

header h1 {
  font-size: 36px;
  font-weight: 700;
  color: #FFFFFF;
  margin: 0;
  letter-spacing: 2px;
  text-transform: uppercase;
  text-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
}

header nav a {
  transition: opacity 0.2s ease, transform 0.2s ease;
  color: white !important;
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  background: rgba(255, 255, 255, 0.1);
  backdrop-filter: blur(10px);
}

header nav a:hover {
  opacity: 1;
  background: rgba(255, 165, 0, 0.2);
  transform: translateY(-2px);
}

main {
  position: relative;
  padding: 40px var(--space-xl);
  max-width: 1600px;
  margin: 0 auto;
  z-index: 10;
}

footer {
  position: relative;
  padding: var(--space-lg) var(--space-xl);
  text-align: center;
  color: var(--muted);
  font-size: 14px;
  z-index: 10;
  margin-top: var(--space-2xl);
}

/* ====================================
   Card Components
   ==================================== */

.card {
  background: rgba(255, 255, 255, 0.8);
  border: 1px solid rgba(0, 0, 0, 0.08);
  border-radius: var(--radius-lg);
  padding: var(--space-lg);
  margin-bottom: var(--space-lg);
  backdrop-filter: blur(10px);
  animation: fadeInUp 0.5s ease;
}

.card h3 {
  font-size: 20px;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: var(--space-md);
}

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

/* ====================================
   Upload Container
   ==================================== */

.upload-container {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--space-xl);
  margin-bottom: var(--space-xl);
}

.upload-box {
  position: relative;
  background: rgba(255, 255, 255, 0.85);
  border: 2px solid rgba(0, 0, 0, 0.1);
  border-radius: var(--radius-xl);
  padding: var(--space-2xl) 36px;
  min-height: 420px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: space-between;
  transition: all var(--transition-base);
  cursor: pointer;
  backdrop-filter: blur(12px);
  box-shadow: var(--shadow-md);
}

.upload-box:hover {
  border-color: rgba(0, 0, 0, 0.2);
  box-shadow: var(--shadow-lg);
  transform: translateY(-4px);
  background: rgba(255, 255, 255, 0.95);
}

.upload-box.dragover {
  border-color: var(--accent);
  background: rgba(255, 165, 0, 0.05);
  box-shadow: 0 8px 32px rgba(255, 165, 0, 0.15);
}

.upload-box.has-file {
  border-color: var(--success);
  background: var(--success-light);
}

.upload-box .logo {
  width: 140px;
  height: 140px;
  margin-bottom: 0;
  flex-shrink: 0;
  opacity: 0.7;
  transition: opacity var(--transition-base), transform var(--transition-base);
  filter: drop-shadow(0 4px 12px rgba(0, 0, 0, 0.08));
  object-fit: contain;
}

.upload-box:hover .logo {
  opacity: 0.9;
  transform: scale(1.08) translateY(-4px);
  filter: drop-shadow(0 8px 20px rgba(0, 0, 0, 0.12));
}

.upload-box h3 {
  font-size: 20px;
  font-weight: 600;
  color: var(--text-primary);
  margin: var(--space-lg) 0 var(--space-sm) 0;
  text-align: center;
  min-height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.upload-box .subtitle {
  font-size: 14px;
  color: var(--muted);
  margin-bottom: var(--space-xl);
  text-align: center;
  min-height: 42px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.upload-box .file-name {
  font-size: 13px;
  color: var(--text-secondary);
  padding: var(--space-sm) var(--space-md);
  background: var(--elevated);
  border-radius: var(--radius-sm);
  max-width: 90%;
  min-width: 200px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  text-align: center;
  margin-top: 0;
  flex-shrink: 0;
}

input[type=file] {
  display: none;
}

/* ====================================
   Button Styles
   ==================================== */

.btn {
  display: inline-flex;
  align-items: center;
  gap: var(--space-sm);
  background: var(--accent);
  color: #FFFFFF;
  font-weight: 600;
  font-size: 16px;
  border: none;
  padding: 14px 28px;
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: all var(--transition-fast);
  box-shadow: var(--shadow-accent);
  text-decoration: none;
}

.btn:hover {
  background: var(--accent-hover);
  box-shadow: 0 4px 16px rgba(255, 165, 0, 0.4);
  transform: translateY(-1px);
}

.btn:disabled {
  background: var(--muted);
  cursor: not-allowed;
  box-shadow: none;
  transform: none;
}

.btn.secondary {
  background: var(--elevated);
  color: var(--text-primary);
  box-shadow: var(--shadow-sm);
}

.btn.secondary:hover {
  background: #EFEFF3;
  box-shadow: 0 2px 8px rgba(0,0,0,0.08);
}

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

.btn.success:hover {
  background: #15803d;
}

.btn.loading {
  position: relative;
}

.spinner {
  width: 16px;
  height: 16px;
  border: 2px solid rgba(255,255,255,0.3);
  border-top-color: #FFFFFF;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  display: none;
}

.btn.loading .spinner {
  display: inline-block;
}

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

/* ====================================
   Actions & Pills
   ==================================== */

.actions {
  display: flex;
  justify-content: center;
  flex-wrap: wrap;
  gap: var(--space-md);
  margin-top: var(--space-xl);
}

.pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  border-radius: var(--radius-full);
  background: var(--accent-muted);
  color: var(--accent);
  font-size: 13px;
  font-weight: 500;
  margin-right: var(--space-sm);
  margin-bottom: var(--space-sm);
}

.pill.success {
  background: rgba(22, 163, 74, 0.1);
  color: var(--success);
}

.pill.warning {
  background: rgba(217, 119, 6, 0.1);
  color: var(--warning);
}

.pill.danger {
  background: rgba(220, 38, 38, 0.1);
  color: var(--danger);
}

/* ====================================
   Statistics Grid
   ==================================== */

.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: var(--space-md);
  margin-top: var(--space-md);
}

.stat {
  background: var(--elevated);
  border: 1px solid rgba(0, 0, 0, 0.06);
  border-radius: var(--radius-md);
  padding: var(--space-md);
  text-align: center;
  transition: all var(--transition-fast);
}

.stat:hover {
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
  transform: translateY(-2px);
}

.stat .label {
  font-size: 13px;
  color: var(--muted);
  margin-bottom: var(--space-sm);
}

.stat .value {
  font-size: 24px;
  font-weight: 600;
  color: var(--text-primary);
}

.stat.success .value {
  color: var(--success);
}

.stat.warning .value {
  color: var(--warning);
}

.stat.danger .value {
  color: var(--danger);
}

/* ====================================
   Table Styles
   ==================================== */

.table-container {
  overflow-x: auto;
  margin-top: var(--space-md);
  border-radius: var(--radius-md);
  border: 1px solid var(--divider);
}

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

th, td {
  padding: 12px;
  text-align: left;
  border-bottom: 1px solid var(--divider);
}

th {
  font-weight: 600;
  color: var(--text-secondary);
  background: var(--elevated);
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

td {
  color: var(--text-primary);
  font-size: 14px;
}

tr:hover {
  background: rgba(0, 0, 0, 0.02);
}

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

/* ====================================
   Utility Classes
   ==================================== */

.muted {
  color: var(--muted);
  font-size: 14px;
}

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

.mb-0 { margin-bottom: 0; }
.mb-1 { margin-bottom: var(--space-sm); }
.mb-2 { margin-bottom: var(--space-md); }
.mb-3 { margin-bottom: var(--space-lg); }
.mb-4 { margin-bottom: var(--space-xl); }

.mt-0 { margin-top: 0; }
.mt-1 { margin-top: var(--space-sm); }
.mt-2 { margin-top: var(--space-md); }
.mt-3 { margin-top: var(--space-lg); }
.mt-4 { margin-top: var(--space-xl); }

/* ====================================
   Result Page Enhancements
   ==================================== */

.result-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: var(--space-lg);
  flex-wrap: wrap;
  gap: var(--space-md);
}

.result-status {
  display: flex;
  align-items: center;
  gap: var(--space-md);
}

.status-icon {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 24px;
  background: var(--success-light);
  color: var(--success);
}

.diff-type-badge {
  padding: 4px 8px;
  border-radius: 4px;
  font-size: 12px;
  font-weight: 500;
  text-transform: uppercase;
}

.diff-type-badge.missing_in_1c {
  background: rgba(220, 38, 38, 0.1);
  color: var(--danger);
}

.diff-type-badge.missing_in_kd {
  background: rgba(217, 119, 6, 0.1);
  color: var(--warning);
}

.diff-type-badge.mismatch {
  background: rgba(255, 165, 0, 0.1);
  color: var(--accent);
}

/* ====================================
   Responsive Design
   ==================================== */

@media (max-width: 768px) {
  .upload-container {
    grid-template-columns: 1fr;
  }
  
  header h1 {
    font-size: 24px;
  }
  
  main {
    padding: var(--space-lg) var(--space-md);
  }
  
  .stats-grid {
    grid-template-columns: repeat(2, 1fr);
  }
  
  .actions {
    flex-direction: column;
  }
  
  .actions .btn {
    width: 100%;
    justify-content: center;
  }
  
  .result-header {
    flex-direction: column;
    align-items: flex-start;
  }
}

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

/* ====================================
   Loading States
   ==================================== */

.skeleton {
  background: linear-gradient(
    90deg,
    var(--elevated) 0%,
    var(--surface) 50%,
    var(--elevated) 100%
  );
  background-size: 200% 100%;
  animation: skeleton-loading 1.5s ease-in-out infinite;
  border-radius: var(--radius-sm);
}

@keyframes skeleton-loading {
  0% {
    background-position: 200% 0;
  }
  100% {
    background-position: -200% 0;
  }
}

/* ====================================
   Print Styles
   ==================================== */

/* ====================================
   Inline Statistics
   ==================================== */

.stat-inline {
  display: inline-flex;
  align-items: center;
  gap: var(--space-sm);
  padding: var(--space-sm) var(--space-md);
  background: var(--elevated);
  border-radius: var(--radius-md);
  border: 1px solid rgba(0, 0, 0, 0.06);
}

.stat-inline i {
  font-size: 18px;
}

.stat-inline .label {
  font-size: 13px;
  color: var(--muted);
  margin-right: var(--space-sm);
}

.stat-inline .value {
  font-size: 20px;
  font-weight: 600;
}

.stat-inline.success {
  border-color: var(--success);
  background: rgba(22, 163, 74, 0.05);
}

.stat-inline.success i,
.stat-inline.success .value {
  color: var(--success);
}

.stat-inline.warning {
  border-color: var(--warning);
  background: rgba(217, 119, 6, 0.05);
}

.stat-inline.warning i,
.stat-inline.warning .value {
  color: var(--warning);
}

.stat-inline.danger {
  border-color: var(--danger);
  background: rgba(220, 38, 38, 0.05);
}

.stat-inline.danger i,
.stat-inline.danger .value {
  color: var(--danger);
}

/* ====================================
   Dropdown
   ==================================== */

.dropdown {
  position: relative;
  display: inline-block;
}

.dropdown-toggle {
  cursor: pointer;
}

.dropdown-menu {
  display: none;
  position: absolute;
  top: 100%;
  left: 0;
  margin-top: var(--space-sm);
  background: white;
  border: 1px solid var(--divider);
  border-radius: var(--radius-md);
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.12);
  min-width: 280px;
  z-index: 9999;
}

.dropdown.show .dropdown-menu {
  display: block;
}

.dropdown-item {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  padding: 12px 16px;
  color: var(--text-primary);
  text-decoration: none;
  transition: background var(--transition-fast);
}

.dropdown-item:hover {
  background: var(--surface);
}

.dropdown-item i {
  font-size: 16px;
  color: var(--muted);
}

/* ====================================
   Filters
   ==================================== */

.table-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: var(--space-lg);
  flex-wrap: wrap;
  gap: var(--space-md);
}

.filter-group {
  display: flex;
  gap: var(--space-sm);
  flex-wrap: wrap;
}

.filter-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  background: var(--elevated);
  border: 1px solid var(--divider);
  border-radius: var(--radius-md);
  color: var(--text-secondary);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: all var(--transition-fast);
}

.filter-btn:hover {
  background: var(--surface);
  border-color: var(--accent);
}

.filter-btn.active {
  background: var(--accent);
  border-color: var(--accent);
  color: white;
}

.filter-btn i {
  font-size: 14px;
}

/* ====================================
   Actions Toolbar
   ==================================== */

.actions-toolbar {
  display: flex;
  gap: var(--space-md);
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
}

/* ====================================
   Table Improvements
   ==================================== */

.table-container {
  overflow-x: auto;
  margin-top: var(--space-md);
  border-radius: var(--radius-md);
  border: 1px solid var(--divider);
  background: white;
}

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

th, td {
  padding: 14px 16px;
  text-align: left;
  border-bottom: 1px solid var(--divider);
}

th {
  font-weight: 600;
  color: var(--text-secondary);
  background: var(--elevated);
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  position: sticky;
  top: 0;
  z-index: 10;
}

td {
  color: var(--text-primary);
  font-size: 14px;
  line-height: 1.6;
}

/* Ограничение ширины колонки Тип */
th:first-child,
td:first-child {
  width: 200px;
  min-width: 180px;
  max-width: 220px;
}

/* Ширина остальных колонок */
th:nth-child(2),
td:nth-child(2),
th:nth-child(4),
td:nth-child(4) {
  width: 140px;
}

th:nth-child(3),
td:nth-child(3),
th:nth-child(5),
td:nth-child(5) {
  width: auto;
  min-width: 250px;
}

tr:hover {
  background: rgba(0, 0, 0, 0.02);
}

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

td.danger {
  color: var(--danger);
  font-weight: 600;
}

td.warning {
  color: var(--warning);
  font-weight: 600;
}

td.success {
  color: var(--success);
  font-weight: 600;
}

.btn-link {
  color: var(--accent);
  text-decoration: none;
  font-weight: 500;
  padding: 4px 12px;
  border-radius: var(--radius-sm);
  transition: all var(--transition-fast);
  display: inline-block;
}

.btn-link:hover {
  background: var(--accent-muted);
}

/* ====================================
   Print Styles
   ==================================== */

@media print {
  .gradient-orb,
  .actions,
  .actions-toolbar,
  .filter-group,
  .btn {
    display: none !important;
  }
  
  body {
    background: white;
  }
  
  .card {
    border: 1px solid #000;
    page-break-inside: avoid;
  }
  
  table {
    page-break-inside: auto;
  }
  
  tr {
    page-break-inside: avoid;
    page-break-after: auto;
  }
}

