/* ============================================================
   SADI.KZ — AI Смета: Дизайн-система (Светлая тема)
   Вдохновлено дизайном sadi.kz
   ============================================================ */

:root {
  /* Цвета — светлая тема sadi.kz */
  --bg-primary: #ffffff;
  --bg-secondary: #f5f7fa;
  --bg-card: #ffffff;
  --bg-card-hover: #f8fafc;
  --bg-glass: rgba(26, 60, 110, 0.03);
  --border: #e2e8f0;
  --border-hover: #cbd5e1;

  --text-primary: #1a2b4a;
  --text-secondary: #5a6b8a;
  --text-muted: #8a95a8;

  /* Основной акцент — тёмно-синий (navy) как на sadi.kz */
  --accent-blue: #1a3c6e;
  --accent-blue-glow: rgba(26, 60, 110, 0.15);

  /* Бирюзовый акцент (teal) — фирменный цвет sadi.kz */
  --accent-teal: #2cb5a0;
  --accent-teal-glow: rgba(44, 181, 160, 0.2);

  --accent-green: #0fa87e;
  --accent-green-glow: rgba(15, 168, 126, 0.15);
  --accent-orange: #e8850c;
  --accent-orange-glow: rgba(232, 133, 12, 0.15);
  --accent-red: #dc3545;
  --accent-red-glow: rgba(220, 53, 69, 0.15);
  --accent-purple: #6f5ce6;
  --accent-purple-glow: rgba(111, 92, 230, 0.15);

  --gradient-main: linear-gradient(135deg, #1a3c6e, #2cb5a0);
  --gradient-green: linear-gradient(135deg, #0fa87e, #2cb5a0);
  --gradient-orange: linear-gradient(135deg, #e8850c, #dc3545);

  /* Размеры */
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --radius-xl: 20px;

  /* Тени — мягкие для светлой темы */
  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.06), 0 1px 2px rgba(0, 0, 0, 0.04);
  --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.07);
  --shadow-lg: 0 10px 30px rgba(0, 0, 0, 0.1);
  --shadow-glow-blue: 0 0 20px rgba(26, 60, 110, 0.1);
  --shadow-glow-teal: 0 0 20px rgba(44, 181, 160, 0.15);
  --shadow-glow-green: 0 0 20px rgba(15, 168, 126, 0.1);
}

/* ============================================================
   Base
   ============================================================ */

*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  scroll-behavior: smooth;
}

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  background: var(--bg-secondary);
  color: var(--text-primary);
  line-height: 1.6;
  min-height: 100vh;
  overflow-x: hidden;
}

/* Мягкий градиент фона как на sadi.kz */
body::before {
  content: '';
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: 400px;
  background: linear-gradient(180deg, rgba(26, 60, 110, 0.04) 0%, transparent 100%);
  pointer-events: none;
  z-index: 0;
}

/* ============================================================
   Navbar
   ============================================================ */

.navbar {
  position: sticky;
  top: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 32px;
  height: 64px;
  background: #ffffff;
  border-bottom: 1px solid var(--border);
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.04);
}

.nav-brand {
  display: flex;
  align-items: center;
  gap: 10px;
}

.logo-icon {
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--gradient-main);
  border-radius: var(--radius-sm);
  color: white;
  padding: 6px;
}

.logo-icon svg {
  width: 100%;
  height: 100%;
}

.logo-text {
  font-size: 22px;
  font-weight: 800;
  letter-spacing: -0.5px;
  color: var(--accent-blue);
}

.logo-text .accent {
  color: var(--accent-teal);
}

.logo-sub {
  font-size: 11px;
  font-weight: 600;
  color: var(--accent-teal);
  background: rgba(44, 181, 160, 0.1);
  padding: 2px 10px;
  border-radius: 20px;
  border: 1px solid rgba(44, 181, 160, 0.2);
}

.nav-links {
  display: flex;
  gap: 4px;
}

.nav-link {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 16px;
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  text-decoration: none;
  font-size: 14px;
  font-weight: 500;
  transition: all 0.2s ease;
  position: relative;
}

.nav-link svg {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
}

.nav-link:hover {
  color: var(--accent-blue);
  background: rgba(26, 60, 110, 0.05);
}

.nav-link.active {
  color: var(--accent-blue);
  background: rgba(26, 60, 110, 0.08);
  font-weight: 600;
}

/* Бирюзовый подчёркиватель — фирменный стиль sadi.kz */
.nav-link.active::after {
  content: '';
  position: absolute;
  bottom: -1px;
  left: 16px;
  right: 16px;
  height: 3px;
  background: var(--accent-teal);
  border-radius: 3px 3px 0 0;
}

.badge {
  position: absolute;
  top: 2px;
  right: 4px;
  background: var(--accent-red);
  color: white;
  font-size: 10px;
  font-weight: 700;
  min-width: 18px;
  height: 18px;
  border-radius: 9px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 4px;
  animation: badge-pulse 2s infinite;
}

@keyframes badge-pulse {

  0%,
  100% {
    transform: scale(1);
  }

  50% {
    transform: scale(1.1);
  }
}

/* ============================================================
   Main Content
   ============================================================ */

.main-content {
  position: relative;
  z-index: 1;
  max-width: 1800px;
  margin: 0 auto;
  padding: 32px;
}

.page {
  display: none;
  animation: fadeIn 0.3s ease;
}

.page.active {
  display: block;
}

@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(10px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.page-header {
  margin-bottom: 32px;
}

.page-header h1 {
  font-size: 28px;
  font-weight: 800;
  letter-spacing: -0.5px;
  margin-bottom: 8px;
  color: var(--accent-blue);
  position: relative;
  display: inline-block;
}

/* Бирюзовый подчёркиватель заголовков — стиль sadi.kz */
.page-header h1::after {
  content: '';
  display: block;
  width: 50px;
  height: 3px;
  background: var(--accent-teal);
  border-radius: 2px;
  margin-top: 8px;
}

.subtitle {
  color: var(--text-secondary);
  font-size: 15px;
}

/* ============================================================
   Stats Row
   ============================================================ */

.stats-row {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
  margin-bottom: 32px;
}

.stat-card {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 20px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-sm);
  transition: all 0.3s ease;
}

.stat-card:hover {
  border-color: var(--border-hover);
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}

.stat-icon {
  width: 48px;
  height: 48px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.stat-icon svg {
  width: 24px;
  height: 24px;
}

.stat-icon.blue {
  background: rgba(26, 60, 110, 0.1);
  color: var(--accent-blue);
}

.stat-icon.green {
  background: rgba(15, 168, 126, 0.1);
  color: var(--accent-green);
}

.stat-icon.orange {
  background: rgba(232, 133, 12, 0.1);
  color: var(--accent-orange);
}

.stat-icon.purple {
  background: rgba(111, 92, 230, 0.1);
  color: var(--accent-purple);
}

.stat-info {
  display: flex;
  flex-direction: column;
}

.stat-value {
  font-size: 24px;
  font-weight: 700;
  line-height: 1.2;
  color: var(--accent-blue);
}

.stat-label {
  font-size: 13px;
  color: var(--text-muted);
}

/* ============================================================
   Upload Zone
   ============================================================ */

.upload-zone {
  position: relative;
  border: 2px dashed var(--border-hover);
  border-radius: var(--radius-xl);
  padding: 60px;
  text-align: center;
  cursor: pointer;
  transition: all 0.3s ease;
  background: var(--bg-card);
  overflow: hidden;
}

.upload-zone::before {
  content: '';
  position: absolute;
  inset: 0;
  background: var(--gradient-main);
  opacity: 0;
  transition: opacity 0.3s ease;
}

.upload-zone:hover,
.upload-zone.dragover {
  border-color: var(--accent-teal);
  box-shadow: var(--shadow-glow-teal);
}

.upload-zone:hover::before,
.upload-zone.dragover::before {
  opacity: 0.03;
}

.upload-content {
  position: relative;
  z-index: 1;
}

.upload-icon {
  width: 80px;
  height: 80px;
  margin: 0 auto 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(44, 181, 160, 0.1);
  border-radius: 50%;
  color: var(--accent-teal);
  transition: transform 0.3s ease;
}

.upload-zone:hover .upload-icon {
  transform: scale(1.1);
}

.upload-icon svg {
  width: 40px;
  height: 40px;
}

.upload-content h3 {
  font-size: 20px;
  font-weight: 600;
  margin-bottom: 8px;
  color: var(--accent-blue);
}

.upload-content p {
  color: var(--text-secondary);
  margin-bottom: 12px;
}

.upload-formats {
  display: inline-block;
  font-size: 12px;
  color: var(--text-muted);
  padding: 4px 12px;
  background: var(--bg-secondary);
  border-radius: 20px;
  border: 1px solid var(--border);
}

/* ============================================================
   Analysis Progress
   ============================================================ */

.analysis-progress {
  margin-top: 32px;
}

.progress-card {
  text-align: center;
  padding: 48px;
  background: var(--bg-card);
  border-radius: var(--radius-lg);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
}

.spinner {
  width: 48px;
  height: 48px;
  border: 3px solid var(--border);
  border-top-color: var(--accent-teal);
  border-radius: 50%;
  animation: spin 1s linear infinite;
  margin: 0 auto 20px;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

.progress-card h3 {
  font-size: 18px;
  margin-bottom: 8px;
  color: var(--accent-blue);
}

.progress-card p {
  color: var(--text-secondary);
  margin-bottom: 20px;
}

.progress-bar {
  width: 100%;
  max-width: 400px;
  height: 6px;
  background: var(--bg-secondary);
  border-radius: 3px;
  margin: 0 auto;
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  width: 0%;
  background: var(--gradient-main);
  border-radius: 3px;
  transition: width 0.5s ease;
  animation: progress-pulse 2s ease-in-out infinite;
}

@keyframes progress-pulse {

  0%,
  100% {
    opacity: 1;
  }

  50% {
    opacity: 0.7;
  }
}

/* ============================================================
   Custom Prompt
   ============================================================ */

.custom-prompt-section {
  margin-bottom: 24px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  overflow: hidden;
  transition: all 0.3s ease;
  box-shadow: var(--shadow-sm);
}

.prompt-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  cursor: pointer;
}

.prompt-label {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-secondary);
  cursor: pointer;
}

.prompt-label svg {
  color: var(--accent-teal);
}

.prompt-body {
  padding: 0 16px 16px;
}

.prompt-body.collapsed {
  display: none;
}

#custom-prompt {
  width: 100%;
  min-height: 60px;
  max-height: 200px;
  padding: 12px 14px;
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-family: inherit;
  font-size: 13px;
  line-height: 1.5;
  resize: vertical;
  outline: none;
  transition: border-color 0.2s;
}

#custom-prompt::placeholder {
  color: var(--text-muted);
}

#custom-prompt:focus {
  border-color: var(--accent-teal);
  box-shadow: 0 0 0 3px rgba(44, 181, 160, 0.1);
}

/* ============================================================
   Upload Zones Row — две зоны рядом
   ============================================================ */

.upload-zones-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 24px;
}

@media (max-width: 768px) {
  .upload-zones-row {
    grid-template-columns: 1fr;
  }
}

/* KP Upload Zone — акцент оранжевый */
.upload-zone.kp-zone {
  border-color: rgba(232, 133, 12, 0.3);
}

.upload-zone.kp-zone:hover,
.upload-zone.kp-zone.dragover {
  border-color: var(--accent-orange);
  box-shadow: 0 0 20px rgba(232, 133, 12, 0.15);
}

.upload-zone.kp-zone:hover::before,
.upload-zone.kp-zone.dragover::before {
  opacity: 0.03;
}

.upload-icon.kp {
  background: rgba(232, 133, 12, 0.1);
  color: var(--accent-orange);
}

.upload-zone.kp-zone .upload-content h3 {
  color: var(--accent-orange);
}

.kp-supplier-input {
  margin-top: 16px;
}

.kp-input {
  width: 100%;
  padding: 8px 14px;
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-family: inherit;
  font-size: 13px;
  outline: none;
  transition: border-color 0.2s;
  text-align: center;
}

.kp-input::placeholder {
  color: var(--text-muted);
}

.kp-input:focus {
  border-color: var(--accent-orange);
  box-shadow: 0 0 0 3px rgba(232, 133, 12, 0.1);
}

.kp-file-name {
  margin-top: 8px;
  padding: 6px 12px;
  background: rgba(232, 133, 12, 0.08);
  border: 1px solid rgba(232, 133, 12, 0.2);
  border-radius: var(--radius-sm);
  font-size: 12px;
  color: var(--accent-orange);
  font-weight: 500;
  display: flex;
  align-items: center;
  gap: 6px;
}

.kp-file-name .remove-kp {
  margin-left: auto;
  cursor: pointer;
  color: var(--text-muted);
  font-size: 14px;
  transition: color 0.2s;
}

.kp-file-name .remove-kp:hover {
  color: var(--accent-red);
}

/* ============================================================
   Section Action Buttons (edit/delete)
   ============================================================ */

.btn-section-action {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  padding: 0;
  background: transparent;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: 14px;
  opacity: 0.5;
  transition: all 0.2s ease;
}

.btn-section-action:hover {
  opacity: 1;
  background: rgba(26, 60, 110, 0.08);
  border-color: var(--border);
}

.btn-section-action.btn-section-delete:hover {
  opacity: 1;
  background: rgba(239, 68, 68, 0.08);
  border-color: rgba(239, 68, 68, 0.2);
}

/* ============================================================
   AI Log Panel — Оставляем тёмный терминальный стиль
   ============================================================ */

.ai-log-panel {
  margin-top: 16px;
  background: #0d1117;
  border: 1px solid rgba(48, 54, 61, 0.8);
  border-radius: var(--radius-md);
  overflow: hidden;
}

.ai-log-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 14px;
  background: rgba(22, 27, 34, 0.9);
  border-bottom: 1px solid rgba(48, 54, 61, 0.8);
}

.ai-log-title {
  font-size: 12px;
  font-weight: 600;
  color: #8b949e;
}

.ai-log-status {
  font-size: 11px;
  font-weight: 500;
  color: #3fb950;
  animation: status-blink 1.5s ease infinite;
}

@keyframes status-blink {

  0%,
  100% {
    opacity: 1;
  }

  50% {
    opacity: 0.5;
  }
}

.ai-log-body {
  padding: 12px 14px;
  max-height: 300px;
  overflow-y: auto;
  font-family: 'Cascadia Code', 'Fira Code', 'Consolas', monospace;
  font-size: 12px;
  line-height: 1.7;
}

.ai-log-body::-webkit-scrollbar {
  width: 6px;
}

.ai-log-body::-webkit-scrollbar-track {
  background: transparent;
}

.ai-log-body::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.1);
  border-radius: 3px;
}

.ai-log-entry {
  padding: 2px 0;
  color: #8b949e;
  word-break: break-word;
}

.ai-log-entry::before {
  content: '› ';
  color: #484f58;
}

.ai-log-entry.system {
  color: #8b949e;
}

.ai-log-entry.system::before {
  content: '⚙ ';
  color: #58a6ff;
}

.ai-log-entry.info {
  color: #c9d1d9;
}

.ai-log-entry.info::before {
  content: '→ ';
  color: #58a6ff;
}

.ai-log-entry.success {
  color: #3fb950;
}

.ai-log-entry.success::before {
  content: '✓ ';
  color: #3fb950;
}

.ai-log-entry.warning {
  color: #d29922;
}

.ai-log-entry.warning::before {
  content: '⚠ ';
  color: #d29922;
}

.ai-log-entry.error {
  color: #f85149;
}

.ai-log-entry.error::before {
  content: '✗ ';
  color: #f85149;
}

.ai-log-entry.ai-chunk {
  color: #d2a8ff;
}

.ai-log-entry.ai-chunk::before {
  content: '🤖 ';
}

.ai-log-entry.highlight {
  color: #79c0ff;
  font-weight: 500;
}

.ai-log-entry.highlight::before {
  content: '★ ';
  color: #79c0ff;
}

/* ============================================================
   Analysis Result
   ============================================================ */

.analysis-result {
  margin-top: 32px;
}

.result-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  padding: 24px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  margin-bottom: 24px;
  gap: 24px;
  flex-wrap: wrap;
  box-shadow: var(--shadow-sm);
}

.result-title h2 {
  font-size: 22px;
  font-weight: 700;
  margin-bottom: 4px;
  color: var(--accent-blue);
}

.result-title p {
  color: var(--text-secondary);
  font-size: 14px;
}

.result-summary {
  display: flex;
  gap: 16px;
}

.summary-item {
  text-align: center;
  padding: 12px 20px;
  border-radius: var(--radius-md);
  min-width: 100px;
}

.summary-item.matched {
  background: rgba(15, 168, 126, 0.08);
  border: 1px solid rgba(15, 168, 126, 0.2);
}

.summary-item.unmatched {
  background: rgba(232, 133, 12, 0.08);
  border: 1px solid rgba(232, 133, 12, 0.2);
}

.summary-item.total {
  background: rgba(26, 60, 110, 0.06);
  border: 1px solid rgba(26, 60, 110, 0.15);
}

.summary-count {
  display: block;
  font-size: 22px;
  font-weight: 700;
  line-height: 1.2;
}

.summary-item.matched .summary-count {
  color: var(--accent-green);
}

.summary-item.unmatched .summary-count {
  color: var(--accent-orange);
}

.summary-item.total .summary-count {
  color: var(--accent-blue);
}

.summary-label {
  font-size: 12px;
  color: var(--text-muted);
}

.result-section {
  margin-bottom: 24px;
}

.section-title {
  font-size: 16px;
  font-weight: 600;
  margin-bottom: 12px;
  padding-left: 8px;
  color: var(--accent-blue);
}

.section-title.green-accent {
  border-left: 3px solid var(--accent-green);
}

.section-title.orange-accent {
  border-left: 3px solid var(--accent-orange);
}

.section-desc {
  color: var(--text-secondary);
  font-size: 13px;
  margin-bottom: 12px;
}

/* ============================================================
   Table
   ============================================================ */

.table-wrapper {
  overflow-x: auto;
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
  background: var(--bg-card);
  box-shadow: var(--shadow-sm);
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

.data-table th {
  text-align: left;
  padding: 12px 14px;
  font-weight: 600;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-muted);
  background: var(--bg-secondary);
  border-bottom: 2px solid var(--border);
  white-space: nowrap;
}

.data-table td {
  padding: 10px 14px;
  border-bottom: 1px solid var(--border);
  color: var(--text-secondary);
  vertical-align: middle;
}

.data-table tr:hover td {
  background: rgba(26, 60, 110, 0.02);
  color: var(--text-primary);
}

.data-table tr:last-child td {
  border-bottom: none;
}

/* Type badges */
.type-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 10px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 600;
  white-space: nowrap;
}

.type-badge.work {
  background: rgba(26, 60, 110, 0.1);
  color: var(--accent-blue);
}

.type-badge.material {
  background: rgba(232, 133, 12, 0.1);
  color: var(--accent-orange);
}

.type-badge.machine {
  background: rgba(111, 92, 230, 0.1);
  color: var(--accent-purple);
}

/* Match method badges */
.method-badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 20px;
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
}

.method-badge.code {
  background: rgba(15, 168, 126, 0.12);
  color: var(--accent-green);
}

.method-badge.fuzzy {
  background: rgba(26, 60, 110, 0.1);
  color: var(--accent-blue);
}

.method-badge.ai {
  background: rgba(111, 92, 230, 0.1);
  color: var(--accent-purple);
}

/* Confidence */
.confidence {
  font-weight: 600;
  font-size: 12px;
}

.confidence.high {
  color: var(--accent-green);
}

.confidence.medium {
  color: var(--accent-orange);
}

.confidence.low {
  color: var(--accent-red);
}

/* Status badge */
.status-badge {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 600;
}

.status-badge.pending {
  background: rgba(232, 133, 12, 0.1);
  color: var(--accent-orange);
}

.status-badge.approved {
  background: rgba(15, 168, 126, 0.1);
  color: var(--accent-green);
}

.status-badge.rejected {
  background: rgba(220, 53, 69, 0.1);
  color: var(--accent-red);
}

/* ============================================================
   Toolbar
   ============================================================ */

.toolbar {
  display: flex;
  align-items: center;
  gap: 16px;
  margin-bottom: 20px;
  flex-wrap: wrap;
}

.search-box {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 16px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  flex: 1;
  min-width: 200px;
  transition: border-color 0.2s;
  box-shadow: var(--shadow-sm);
}

.search-box:focus-within {
  border-color: var(--accent-teal);
  box-shadow: 0 0 0 3px rgba(44, 181, 160, 0.1);
}

.search-box svg {
  width: 18px;
  height: 18px;
  color: var(--text-muted);
  flex-shrink: 0;
}

.search-box input {
  flex: 1;
  background: none;
  border: none;
  outline: none;
  color: var(--text-primary);
  font-size: 14px;
  font-family: inherit;
}

.search-box input::placeholder {
  color: var(--text-muted);
}

.filter-group {
  display: flex;
  gap: 4px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 3px;
  box-shadow: var(--shadow-sm);
}

.filter-btn {
  padding: 6px 14px;
  border: none;
  background: none;
  color: var(--text-secondary);
  font-size: 13px;
  font-weight: 500;
  font-family: inherit;
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.2s;
}

.filter-btn:hover {
  color: var(--accent-blue);
  background: rgba(26, 60, 110, 0.05);
}

.filter-btn.active {
  background: var(--accent-blue);
  color: white;
}

/* ============================================================
   Buttons
   ============================================================ */

.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 18px;
  border: none;
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-weight: 500;
  font-family: inherit;
  cursor: pointer;
  transition: all 0.2s;
  white-space: nowrap;
}

.btn svg {
  width: 16px;
  height: 16px;
}

.btn-primary {
  background: var(--gradient-main);
  color: white;
  box-shadow: 0 2px 8px rgba(26, 60, 110, 0.25);
}

.btn-primary:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 16px rgba(26, 60, 110, 0.35);
}

.btn-success {
  background: var(--gradient-green);
  color: white;
}

.btn-success:hover {
  transform: translateY(-1px);
}

.btn-danger {
  background: rgba(220, 53, 69, 0.1);
  color: var(--accent-red);
  border: 1px solid rgba(220, 53, 69, 0.2);
}

.btn-danger:hover {
  background: rgba(220, 53, 69, 0.18);
}

.btn-ghost {
  background: var(--bg-card);
  color: var(--text-secondary);
  border: 1px solid var(--border);
}

.btn-ghost:hover {
  color: var(--accent-blue);
  border-color: var(--border-hover);
  background: var(--bg-secondary);
}

.btn-sm {
  padding: 5px 12px;
  font-size: 12px;
}

.btn-lg {
  padding: 12px 24px;
  font-size: 15px;
  margin-top: 20px;
}

.btn-icon {
  padding: 6px;
  border-radius: 6px;
}

.action-buttons {
  display: flex;
  gap: 4px;
}

/* ============================================================
   Cards Grid
   ============================================================ */

.cards-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(380px, 1fr));
  gap: 16px;
}

.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 20px;
  transition: all 0.3s ease;
  box-shadow: var(--shadow-sm);
}

.card:hover {
  border-color: var(--border-hover);
  box-shadow: var(--shadow-md);
  transform: translateY(-2px);
}

.card-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 14px;
}

.card-title {
  font-size: 15px;
  font-weight: 600;
  line-height: 1.4;
  flex: 1;
  color: var(--accent-blue);
}

.card-meta {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 14px;
  font-size: 13px;
  color: var(--text-secondary);
}

.card-meta-item {
  display: flex;
  align-items: center;
  gap: 6px;
}

.card-meta-item strong {
  color: var(--text-primary);
  font-weight: 500;
}

.card-actions {
  display: flex;
  gap: 8px;
  margin-top: 16px;
  padding-top: 14px;
  border-top: 1px solid var(--border);
}

/* ============================================================
   Empty State
   ============================================================ */

.empty-state {
  text-align: center;
  padding: 60px 20px;
  color: var(--text-muted);
}

.empty-state svg {
  width: 64px;
  height: 64px;
  margin-bottom: 16px;
  opacity: 0.4;
  color: var(--accent-teal);
}

.empty-state h3 {
  font-size: 18px;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 8px;
}

/* ============================================================
   Modal
   ============================================================ */

.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(26, 43, 74, 0.4);
  backdrop-filter: blur(8px);
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  animation: fadeIn 0.2s ease;
}

.modal {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  width: 90%;
  max-width: 560px;
  max-height: 80vh;
  overflow-y: auto;
  box-shadow: var(--shadow-lg);
  animation: slideUp 0.3s ease;
}

@keyframes slideUp {
  from {
    transform: translateY(20px);
    opacity: 0;
  }

  to {
    transform: translateY(0);
    opacity: 1;
  }
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 20px 24px;
  border-bottom: 1px solid var(--border);
}

.modal-header h3 {
  font-size: 18px;
  font-weight: 600;
  color: var(--accent-blue);
}

.modal-close {
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: none;
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text-secondary);
  font-size: 20px;
  cursor: pointer;
  transition: all 0.2s;
}

.modal-close:hover {
  background: var(--bg-secondary);
  color: var(--accent-red);
}

.modal-body {
  padding: 24px;
  overflow-y: auto;
}

/* Fullscreen modal for detailed estimate view */
.modal.fullscreen {
  width: 96vw;
  max-width: 96vw;
  height: 92vh;
  max-height: 92vh;
  display: flex;
  flex-direction: column;
}

.modal.fullscreen .modal-body {
  flex: 1;
  overflow-y: auto;
  padding: 24px 28px;
}

.modal.fullscreen .modal-header {
  flex-shrink: 0;
}

.modal.fullscreen .table-wrapper {
  max-height: none;
  overflow-y: visible;
}

.modal.fullscreen .estimate-summary-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 12px;
  margin-bottom: 20px;
}

.modal.fullscreen .estimate-summary-card {
  padding: 14px 18px;
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
}

.modal.fullscreen .estimate-summary-card .label {
  font-size: 11px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 4px;
}

.modal.fullscreen .estimate-summary-card .value {
  font-size: 18px;
  font-weight: 700;
  color: var(--text-primary);
}

.modal.fullscreen .estimate-summary-card .value.green {
  color: var(--accent-green);
}

.modal.fullscreen .estimate-summary-card .value.orange {
  color: var(--accent-orange);
}

.modal.fullscreen .estimate-summary-card .value.blue {
  color: var(--accent-blue);
}

/* ============================================================
   Form
   ============================================================ */

.form-group {
  margin-bottom: 16px;
}

.form-group label {
  display: block;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-secondary);
  margin-bottom: 6px;
}

.form-group input,
.form-group select,
.form-group textarea {
  width: 100%;
  padding: 10px 14px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-size: 14px;
  font-family: inherit;
  transition: border-color 0.2s;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
  outline: none;
  border-color: var(--accent-teal);
  box-shadow: 0 0 0 3px rgba(44, 181, 160, 0.1);
}

.form-group select {
  cursor: pointer;
}

.form-group textarea {
  resize: vertical;
  min-height: 80px;
}

.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.form-actions {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
  margin-top: 20px;
}

/* ============================================================
   Toast
   ============================================================ */

.toast-container {
  position: fixed;
  top: 80px;
  right: 20px;
  z-index: 300;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.toast {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 18px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-md);
  font-size: 14px;
  animation: slideIn 0.3s ease;
  min-width: 280px;
}

.toast.success {
  border-left: 3px solid var(--accent-green);
}

.toast.error {
  border-left: 3px solid var(--accent-red);
}

.toast.info {
  border-left: 3px solid var(--accent-teal);
}

@keyframes slideIn {
  from {
    transform: translateX(100%);
    opacity: 0;
  }

  to {
    transform: translateX(0);
    opacity: 1;
  }
}

/* ============================================================
   Pagination
   ============================================================ */

.pagination {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  margin-top: 20px;
}

.pagination button {
  padding: 6px 12px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text-secondary);
  font-size: 13px;
  font-family: inherit;
  cursor: pointer;
  transition: all 0.2s;
}

.pagination button:hover {
  border-color: var(--accent-teal);
  color: var(--accent-blue);
}

.pagination button.active {
  background: var(--accent-blue);
  border-color: var(--accent-blue);
  color: white;
}

.pagination button:disabled {
  opacity: 0.3;
  cursor: not-allowed;
}

/* ============================================================
   Responsive
   ============================================================ */

@media (max-width: 900px) {
  .navbar {
    flex-direction: column;
    height: auto;
    padding: 12px 16px;
    gap: 10px;
  }

  .nav-links {
    flex-wrap: wrap;
    justify-content: center;
  }

  .main-content {
    padding: 16px;
  }

  .stats-row {
    grid-template-columns: repeat(2, 1fr);
  }

  .result-header {
    flex-direction: column;
  }

  .result-summary {
    width: 100%;
    justify-content: space-between;
  }

  .cards-grid {
    grid-template-columns: 1fr;
  }

  .form-row {
    grid-template-columns: 1fr;
  }

  .upload-zone {
    padding: 40px 20px;
  }
}

/* ============================================================
   Market Price Deviation Indicators
   ============================================================ */

.deviation-good {
  color: var(--accent-green);
  font-weight: 600;
}

.deviation-warn {
  color: var(--accent-orange);
  font-weight: 600;
}

.deviation-bad {
  color: var(--accent-red);
  font-weight: 700;
}

/* ============================================================
   Scrollbar Styling (Light Theme)
   ============================================================ */

::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}

::-webkit-scrollbar-track {
  background: var(--bg-secondary);
}

::-webkit-scrollbar-thumb {
  background: var(--border-hover);
  border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
  background: var(--text-muted);
}

/* ============================================================
   SADI.KZ — Иерархическая таблица (CostRates)
   ============================================================ */

.sadi-tree-table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0 4px;
  margin-top: 10px;
}

.sadi-tree-table th {
  padding: 10px 12px;
  text-align: left;
  font-weight: 600;
  color: var(--text-secondary);
  font-size: 13px;
  background: var(--bg-primary);
  border-bottom: 2px solid var(--border);
}

.sadi-tree-table td {
  padding: 8px 12px;
  vertical-align: middle;
  border-bottom: 1px solid var(--border);
  background: transparent;
  color: var(--text-primary);
  font-size: 14px;
}

/* Разделы */
.sadi-row-section td {
  background: var(--bg-secondary);
  font-weight: 600;
  color: var(--text-primary);
  border-top: 1px solid var(--border);
}

.sadi-row-section:hover td {
  background: #e2e8f0;
}

/* Работы */
.sadi-row-work td {
  background: var(--bg-primary);
}

.sadi-row-work:hover td {
  background: var(--bg-card-hover);
}

/* Ресурсы */
.sadi-row-resource td {
  padding-top: 4px;
  padding-bottom: 4px;
  border: none;
  font-size: 13px;
  color: var(--text-secondary);
}

.sadi-row-resource:hover td {
  background: var(--bg-secondary);
}

/* Кнопка раскрытия */
.sadi-toggle-btn {
  width: 18px;
  height: 18px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--border);
  background: var(--bg-primary);
  color: var(--accent-blue);
  font-size: 14px;
  line-height: 1;
  border-radius: 4px;
  cursor: pointer;
  padding: 0;
  transition: all 0.2s;
  margin: 0 auto;
}

.sadi-toggle-btn:hover {
  background: var(--accent-blue-glow);
  border-color: var(--accent-blue);
}

.sadi-toggle-btn.expanded {
  background: var(--accent-blue);
  color: white;
  border-color: var(--accent-blue);
}

.sadi-toggle-btn.work {
  width: 16px;
  height: 16px;
  font-size: 12px;
  opacity: 0.8;
}

/* Чекбокс */
.sadi-cb {
  width: 16px;
  height: 16px;
  cursor: pointer;
  accent-color: var(--accent-teal);
  vertical-align: middle;
}

/* Ссылки */
.sadi-price-link {
  color: var(--text-primary);
  font-weight: 600;
  text-decoration: none;
  transition: color 0.2s;
}

.sadi-price-link:hover {
  color: var(--accent-teal);
  text-decoration: underline;
}

.sadi-offer-link {
  color: var(--accent-blue);
  text-decoration: none;
  border-bottom: 1px dashed var(--accent-blue);
  font-size: 13px;
  transition: all 0.2s;
}

/* ============================================================
   SADI.KZ — Matched Rates Table Style
   ============================================================ */

.sadi-table-header {
  background: white;
  border-bottom: 2px solid var(--accent-teal);
  /* Green line under title */
  padding: 16px 24px;
  display: flex;
  align-items: center;
  gap: 12px;
  border-radius: var(--radius-lg) var(--radius-lg) 0 0;
}

.sadi-table-title {
  color: var(--accent-blue);
  font-weight: 700;
  font-size: 16px;
  text-transform: uppercase;
}

.sadi-table {
  width: 100%;
  border-collapse: collapse;
  background: white;
  font-size: 13px;
}

.sadi-table th {
  background: #f8fafc;
  color: #94a3b8;
  font-weight: 600;
  text-transform: uppercase;
  font-size: 11px;
  padding: 12px 16px;
  border-bottom: 1px solid #e2e8f0;
  text-align: left;
}

.sadi-table td {
  padding: 12px 16px;
  border-bottom: 1px solid #f1f5f9;
  color: #334155;
  vertical-align: middle;
}

.sadi-table tr:hover td {
  background-color: #f8fafc;
}

.sadi-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 2px 8px;
  border-radius: 12px;
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  min-width: 60px;
}

.sadi-badge.ai {
  background: #f3f0ff;
  color: #7c3aed;
  /* Purple */
}

.sadi-badge.search {
  background: #f1f5f9;
  color: #64748b;
  /* Gray */
}

.sadi-percent {
  font-weight: 700;
}

.sadi-percent.high {
  color: #10b981;
}

/* Green */
.sadi-percent.med {
  color: #f59e0b;
}

/* Orange */
.sadi-percent.low {
  color: #ef4444;
}

/* Red */

.sadi-icon-check {
  color: #10b981;
  margin-right: 6px;
}

/* Бейдж модерации */
.pending-badge {
  position: absolute;
  top: -4px;
  right: -8px;
  background: var(--accent-red);
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  min-width: 18px;
  height: 18px;
  border-radius: 9px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0 5px;
  line-height: 1;
}

/* ============================================================
   Editable Cells — Inline editing for quantity/price
   ============================================================ */

.editable-cell {
  cursor: pointer;
  position: relative;
  padding: 4px 6px;
  border-radius: 4px;
  min-width: 50px;
  transition: background 0.15s, box-shadow 0.15s;
}

.editable-cell:hover {
  background: rgba(44, 181, 160, 0.08);
  box-shadow: inset 0 0 0 1px rgba(44, 181, 160, 0.3);
}

.editable-cell::after {
  content: '✎';
  position: absolute;
  right: 2px;
  top: 2px;
  font-size: 9px;
  color: var(--accent-teal);
  opacity: 0;
  transition: opacity 0.15s;
}

.editable-cell:hover::after {
  opacity: 0.7;
}

.editable-cell input {
  width: 100%;
  padding: 2px 4px;
  border: 1px solid var(--accent-teal);
  border-radius: 4px;
  background: var(--bg-card);
  color: var(--text-primary);
  font-family: inherit;
  font-size: inherit;
  font-weight: inherit;
  text-align: inherit;
  outline: none;
  box-shadow: 0 0 0 3px rgba(44, 181, 160, 0.12);
}

.editable-cell.saving {
  opacity: 0.6;
  pointer-events: none;
}

.editable-cell.saved {
  animation: cell-saved 0.6s ease;
}

@keyframes cell-saved {
  0% {
    background: rgba(15, 168, 126, 0.2);
  }

  100% {
    background: transparent;
  }
}

/* ============================================================
   Конструктор объектной сметы (.ob-*)
   ============================================================ */

.ob-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.55);
  backdrop-filter: blur(4px);
  z-index: 1100;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  animation: fadeIn 0.2s ease;
}

.ob-modal {
  background: var(--bg-primary);
  border: 1px solid var(--border);
  border-radius: 16px;
  width: 100%;
  max-width: 720px;
  max-height: 88vh;
  display: flex;
  flex-direction: column;
  box-shadow: 0 24px 80px rgba(0, 0, 0, 0.4);
  animation: slideUp 0.25s ease;
}

@keyframes slideUp {
  from {
    transform: translateY(24px);
    opacity: 0;
  }

  to {
    transform: translateY(0);
    opacity: 1;
  }
}

.ob-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 24px 16px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.ob-body {
  flex: 1;
  overflow-y: auto;
  padding: 20px 24px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.ob-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 24px;
  border-top: 1px solid var(--border);
  background: var(--bg-secondary);
  border-radius: 0 0 16px 16px;
  flex-shrink: 0;
}

.ob-label {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 6px;
}

.ob-name-row {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.ob-input {
  width: 100%;
  padding: 10px 14px;
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text-primary);
  font-size: 15px;
  font-family: inherit;
  transition: border-color 0.2s;
  box-sizing: border-box;
}

.ob-input:focus {
  outline: none;
  border-color: var(--accent-blue);
  box-shadow: 0 0 0 3px rgba(26, 115, 232, 0.15);
}

/* Аккордеон смет */
.ob-accordion {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.ob-loading {
  color: var(--text-muted);
  font-size: 14px;
  padding: 24px;
  text-align: center;
}

.ob-estimate-block {
  border: 1px solid var(--border);
  border-radius: 10px;
  overflow: hidden;
  transition: border-color 0.2s;
}

.ob-estimate-block.has-selected {
  border-color: var(--accent-blue);
}

.ob-estimate-header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 16px;
  background: var(--bg-secondary);
  cursor: pointer;
  user-select: none;
  transition: background 0.15s;
}

.ob-estimate-header:hover {
  background: var(--bg-hover);
}

.ob-estimate-toggle {
  font-size: 13px;
  color: var(--text-muted);
  transition: transform 0.2s;
  flex-shrink: 0;
}

.ob-estimate-block.open .ob-estimate-toggle {
  transform: rotate(90deg);
}

.ob-estimate-name {
  font-weight: 600;
  font-size: 14px;
  flex: 1;
  color: var(--text-primary);
}

.ob-estimate-meta {
  font-size: 12px;
  color: var(--text-muted);
}

.ob-estimate-badge {
  background: var(--accent-blue);
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 20px;
  display: none;
}

.ob-estimate-block.has-selected .ob-estimate-badge {
  display: inline-flex;
}

.ob-sections-list {
  display: none;
  flex-direction: column;
  border-top: 1px solid var(--border);
}

.ob-estimate-block.open .ob-sections-list {
  display: flex;
}

.ob-section-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 20px;
  cursor: pointer;
  transition: background 0.12s;
  border-bottom: 1px solid rgba(255, 255, 255, 0.04);
}

.ob-section-row:last-child {
  border-bottom: none;
}

.ob-section-row:hover {
  background: var(--bg-hover);
}

.ob-section-row.selected {
  background: rgba(26, 115, 232, 0.06);
}

.ob-section-cb {
  width: 16px;
  height: 16px;
  accent-color: var(--accent-blue);
  cursor: pointer;
  flex-shrink: 0;
}

.ob-section-name {
  font-size: 14px;
  color: var(--text-primary);
  flex: 1;
}

.ob-section-count {
  font-size: 12px;
  color: var(--text-muted);
  background: var(--bg-secondary);
  padding: 2px 8px;
  border-radius: 12px;
}

/* Счётчик */
.ob-counter {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  gap: 8px;
}

.ob-counter.active {
  color: var(--accent-blue);
}

/* ============================================================
   ССР — Сводный сметный расчёт
   ============================================================ */

.ssr-source-row {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 20px;
}

.ssr-table-wrap {
  overflow-x: auto;
  border: 1px solid var(--border);
  border-radius: 10px;
}

.ssr-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}

.ssr-table th {
  background: var(--bg-secondary);
  padding: 10px 14px;
  font-weight: 600;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border);
  text-align: left;
}

.ssr-table td {
  padding: 10px 14px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.04);
  vertical-align: middle;
}

.ssr-table tbody tr:last-child td {
  border-bottom: none;
}

.ssr-table tbody tr:hover {
  background: var(--bg-hover);
}

.ssr-table .ssr-row-smr td {
  font-weight: 600;
  background: rgba(26, 115, 232, 0.05);
}

.ssr-table .ssr-row-total td {
  font-weight: 700;
  font-size: 15px;
  background: rgba(15, 168, 126, 0.07);
  color: var(--accent-green);
}

.ssr-table .ssr-row-vat-total td {
  font-weight: 800;
  font-size: 16px;
  background: rgba(15, 168, 126, 0.14);
  color: var(--accent-green);
  border-top: 2px solid var(--accent-green);
}

.ssr-table .ssr-row-divider td {
  padding: 4px;
  background: var(--bg-secondary);
  color: var(--text-muted);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.ssr-pct-input {
  width: 60px;
  padding: 4px 6px;
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text-primary);
  font-size: 13px;
  text-align: right;
  font-family: inherit;
}

.ssr-pct-input:focus {
  outline: none;
  border-color: var(--accent-blue);
}

.ssr-sum {
  font-weight: 600;
  color: var(--text-primary);
  text-align: right;
}

/* Карточки сводных смет и ССР */
.sy-card {
  background: var(--bg-primary);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 20px;
  cursor: pointer;
  transition: border-color 0.2s, transform 0.15s;
}

.sy-card:hover {
  border-color: var(--accent-blue);
  transform: translateY(-2px);
}

.sy-card-title {
  font-weight: 700;
  font-size: 15px;
  margin-bottom: 8px;
}

.sy-card-meta {
  font-size: 13px;
  color: var(--text-muted);
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.sy-card-total {
  font-size: 18px;
  font-weight: 800;
  color: var(--accent-green);
  margin-top: 10px;
}

/* Summary estimate selector checkboxes */
.sy-estimate-row {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 12px 16px;
  border: 1px solid var(--border);
  border-radius: 10px;
  cursor: pointer;
  transition: background 0.12s, border-color 0.2s;
}

.sy-estimate-row:hover {
  background: var(--bg-hover);
}

.sy-estimate-row.selected {
  border-color: var(--accent-blue);
  background: rgba(26, 115, 232, 0.05);
}

.sy-estimate-cb {
  width: 18px;
  height: 18px;
  accent-color: var(--accent-blue);
  cursor: pointer;
  flex-shrink: 0;
}

.sy-estimate-name {
  flex: 1;
  font-size: 14px;
  font-weight: 600;
}

.sy-estimate-total {
  font-size: 14px;
  color: var(--accent-green);
  font-weight: 700;
}

/* ============================================================
   Кнопка запуска анализа
   ============================================================ */

.btn-launch {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 16px 28px;
  background: linear-gradient(135deg, #1a73e8 0%, #0f6fd1 50%, #0fa87e 100%);
  color: #fff;
  font-size: 16px;
  font-weight: 700;
  border: none;
  border-radius: 14px;
  cursor: pointer;
  justify-content: center;
  letter-spacing: 0.02em;
  box-shadow: 0 4px 24px rgba(26, 115, 232, 0.35);
  transition: transform 0.15s, box-shadow 0.15s, filter 0.15s;
  font-family: inherit;
}

.btn-launch:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 32px rgba(26, 115, 232, 0.5);
  filter: brightness(1.08);
}

.btn-launch:active {
  transform: translateY(0);
  box-shadow: 0 2px 12px rgba(26, 115, 232, 0.3);
}

.launch-mode-hint {
  padding: 10px 16px;
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: 10px;
  font-size: 13px;
  color: var(--text-muted);
  margin-bottom: 12px;
  line-height: 1.5;
}

.launch-mode-hint b {
  color: var(--text-primary);
}

/* ============================================================
   ГПР: Gantt Chart
   ============================================================ */

.gpr-scale-btn {
  padding: 5px 14px;
  border: none;
  background: transparent;
  color: var(--text-muted);
  font-size: 12px;
  font-weight: 500;
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.2s;
  font-family: inherit;
}

.gpr-scale-btn:hover {
  color: var(--accent-blue);
  background: rgba(26, 60, 110, 0.05);
}

.gpr-scale-btn.active {
  color: #fff;
  background: var(--accent-blue);
}

.gantt-bar:hover {
  filter: brightness(1.1);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
}

.gantt-resize-handle:hover {
  background: rgba(255, 255, 255, 0.5) !important;
  width: 8px !important;
}

.gantt-bar:active {
  opacity: 0.9;
}

#gantt-table::-webkit-scrollbar,
#gantt-timeline::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}

#gantt-table::-webkit-scrollbar-thumb,
#gantt-timeline::-webkit-scrollbar-thumb {
  background: rgba(128, 128, 128, 0.2);
  border-radius: 3px;
}

/* ============================================================
   Auth Screen
   ============================================================ */

.auth-overlay {
  position: fixed;
  inset: 0;
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg-primary);
  overflow-y: auto;
}

.auth-overlay::before {
  content: '';
  position: fixed;
  inset: 0;
  background:
    radial-gradient(ellipse 80% 50% at 50% 0%, rgba(59, 130, 246, 0.12), transparent),
    radial-gradient(ellipse 60% 40% at 50% 100%, rgba(139, 92, 246, 0.08), transparent);
  pointer-events: none;
}

.auth-overlay.hidden {
  display: none;
}

.auth-container {
  position: relative;
  z-index: 1;
  width: 100%;
  max-width: 420px;
  padding: 40px;
  margin: 40px 20px;
}

.auth-logo {
  text-align: center;
  margin-bottom: 40px;
}

.auth-logo .logo-icon {
  margin: 0 auto 16px;
}

.auth-title {
  font-size: 32px;
  font-weight: 800;
  letter-spacing: -0.5px;
  margin-bottom: 8px;
}

.auth-subtitle {
  color: var(--text-muted);
  font-size: 14px;
}

.auth-form {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 32px;
  backdrop-filter: blur(20px);
}

.auth-form h2 {
  font-size: 20px;
  font-weight: 700;
  margin-bottom: 24px;
  text-align: center;
}

.auth-field {
  margin-bottom: 18px;
}

.auth-field label {
  display: block;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-secondary);
  margin-bottom: 6px;
}

.auth-field input {
  width: 100%;
  padding: 12px 14px;
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-family: inherit;
  font-size: 14px;
  outline: none;
  transition: border-color 0.2s, box-shadow 0.2s;
  box-sizing: border-box;
}

.auth-field input::placeholder {
  color: var(--text-muted);
}

.auth-field input:focus {
  border-color: var(--accent-blue);
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.15);
}

.auth-btn {
  width: 100%;
  margin-top: 8px;
  font-size: 15px;
  padding: 14px;
  position: relative;
}

.auth-btn:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.auth-btn .spinner-inline {
  display: inline-block;
  width: 16px;
  height: 16px;
  border: 2px solid rgba(255, 255, 255, 0.3);
  border-top-color: white;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
  margin-right: 8px;
  vertical-align: middle;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

.auth-error {
  background: rgba(239, 68, 68, 0.1);
  border: 1px solid rgba(239, 68, 68, 0.3);
  color: var(--accent-red);
  border-radius: var(--radius-sm);
  padding: 10px 14px;
  font-size: 13px;
  margin-bottom: 12px;
}

.auth-success {
  background: rgba(16, 185, 129, 0.1);
  border: 1px solid rgba(16, 185, 129, 0.3);
  color: var(--accent-green);
  border-radius: var(--radius-sm);
  padding: 10px 14px;
  font-size: 13px;
  margin-bottom: 12px;
}

.auth-links {
  display: flex;
  justify-content: space-between;
  margin-top: 20px;
  padding-top: 16px;
  border-top: 1px solid var(--border);
}

.auth-links a {
  color: var(--accent-blue);
  text-decoration: none;
  font-size: 13px;
  font-weight: 500;
  transition: color 0.2s;
}

.auth-links a:hover {
  color: var(--accent-purple);
}

.auth-hint {
  color: var(--text-secondary);
  font-size: 13px;
  margin-bottom: 20px;
  text-align: center;
}

.auth-divider {
  display: flex;
  align-items: center;
  text-align: center;
  margin: 16px 0;
  color: var(--text-muted);
  font-size: 13px;
}

.auth-divider::before,
.auth-divider::after {
  content: '';
  flex: 1;
  border-bottom: 1px solid var(--border);
}

.auth-divider span {
  padding: 0 12px;
}

/* Google Sign-In Button */
.btn-google {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  width: 100%;
  padding: 12px 16px;
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-family: inherit;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s;
}

.btn-google:hover {
  background: var(--bg-hover);
  border-color: var(--border-hover);
}

.btn-google:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

/* Nav User */
.nav-user {
  display: flex;
  align-items: center;
  gap: 12px;
}

.user-email {
  font-size: 13px;
  color: var(--text-secondary);
  max-width: 200px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ============================================================
   Registration Wizard
   ============================================================ */

.wizard-form {
  padding: 0 !important;
  background: transparent !important;
  border: none !important;
}

.wizard-step {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 32px;
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
}

.wiz-progress-bar {
  height: 4px;
  background: var(--border);
  border-radius: 2px;
  margin-bottom: 24px;
  overflow: hidden;
}

.wiz-progress-fill {
  height: 100%;
  background: var(--accent-green);
  border-radius: 2px;
  transition: width 0.4s ease;
  width: 0%;
}

.wiz-step-label {
  font-size: 14px;
  color: var(--text-muted);
  margin-bottom: 20px;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.wiz-radio-group {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-bottom: 24px;
}

.wiz-radio-option {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all 0.2s ease;
  background: var(--bg-secondary);
  font-size: 15px;
  font-weight: 500;
  color: var(--text-primary);
}

.wiz-radio-option:hover,
.wiz-radio-option.selected {
  border-color: var(--accent-blue);
  background: rgba(59, 130, 246, 0.08);
}

.wiz-radio-btn {
  width: 22px;
  height: 22px;
  border: 2px solid var(--border-hover);
  border-radius: 4px;
  transition: all 0.2s ease;
  flex-shrink: 0;
  position: relative;
}

.wiz-radio-btn.active {
  border-color: var(--accent-blue);
  background: var(--accent-blue);
}

.wiz-radio-btn.active::after {
  content: '✓';
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  color: white;
  font-size: 13px;
  font-weight: 700;
}

.wiz-nav {
  display: flex;
  gap: 12px;
  margin-top: 24px;
  padding-top: 20px;
  border-top: 1px solid var(--border);
}

.auth-select {
  width: 100%;
  padding: 12px 14px;
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-family: inherit;
  font-size: 14px;
  outline: none;
  transition: border-color 0.2s, box-shadow 0.2s;
  cursor: pointer;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='%2364748b'%3E%3Cpath d='M7 10l5 5 5-5z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 14px center;
  padding-right: 36px;
}

.auth-select:focus {
  border-color: var(--accent-blue);
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.15);
}

.auth-select option {
  background: var(--bg-secondary);
  color: var(--text-primary);
}

.input-disabled {
  background: var(--bg-secondary) !important;
  color: var(--text-muted) !important;
  cursor: not-allowed;
}

/* Лимит-баннер */
.auth-limit-banner {
  background: linear-gradient(135deg, rgba(245, 158, 11, 0.15), rgba(239, 68, 68, 0.1));
  border: 1px solid rgba(245, 158, 11, 0.4);
  color: var(--accent-orange);
  border-radius: var(--radius-sm);
  padding: 12px 16px;
  font-size: 14px;
  font-weight: 500;
  margin-bottom: 20px;
  text-align: center;
}

@media (max-width: 768px) {
  .auth-container {
    padding: 20px;
  }

  .auth-form {
    padding: 24px;
  }

  .nav-user .user-email {
    display: none;
  }
}