/* =========================================================
   Glazing Quote Assistant — styles.css
   ========================================================= */

/* ---------- CSS Custom Properties ---------- */
:root {
  --bg-primary: #f4f6fb;
  --bg-secondary: #ffffff;
  --bg-tertiary: #e8f0fe;
  --bg-card: #ffffff;

  --text-primary: #1a2340;
  --text-secondary: #4a5568;
  --text-muted: #718096;
  --text-inverse: #ffffff;

  --accent-primary: #2563eb;
  --accent-primary-hover: #1d4ed8;
  --accent-primary-light: #dbeafe;
  --accent-secondary: #0ea5e9;
  --accent-success: #16a34a;
  --accent-warning: #d97706;
  --accent-danger: #dc2626;
  --accent-info: #0284c7;

  --border-color: #d1d5db;
  --border-focus: #2563eb;
  --border-radius: 8px;
  --border-radius-sm: 4px;
  --border-radius-lg: 12px;

  --shadow-sm: 0 1px 3px rgba(0,0,0,0.07), 0 1px 2px rgba(0,0,0,0.05);
  --shadow-md: 0 4px 12px rgba(0,0,0,0.1), 0 2px 4px rgba(0,0,0,0.06);
  --shadow-lg: 0 10px 30px rgba(0,0,0,0.12), 0 4px 8px rgba(0,0,0,0.08);

  --header-height: 64px;
  --sidebar-width: 320px;
  --transition: all 0.2s ease;

  --navy: #1a3a6b;
  --navy-light: #2563eb;
}

/* ---------- Dark Mode ---------- */
body.dark-mode {
  --bg-primary: #0f172a;
  --bg-secondary: #1e293b;
  --bg-tertiary: #1a2744;
  --bg-card: #1e293b;

  --text-primary: #f1f5f9;
  --text-secondary: #cbd5e1;
  --text-muted: #94a3b8;
  --text-inverse: #0f172a;

  --accent-primary: #3b82f6;
  --accent-primary-hover: #2563eb;
  --accent-primary-light: #1e3a5f;

  --border-color: #334155;
  --border-focus: #3b82f6;

  --shadow-sm: 0 1px 3px rgba(0,0,0,0.3);
  --shadow-md: 0 4px 12px rgba(0,0,0,0.4);
  --shadow-lg: 0 10px 30px rgba(0,0,0,0.5);
}

/* ---------- Reset & Base ---------- */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html { font-size: 15px; scroll-behavior: smooth; }

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  background: var(--bg-primary);
  color: var(--text-primary);
  line-height: 1.6;
  transition: background 0.3s ease, color 0.3s ease;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* ---------- Header ---------- */
.app-header {
  height: var(--header-height);
  background: var(--navy);
  color: #fff;
  display: flex;
  align-items: center;
  padding: 0 24px;
  gap: 16px;
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: 0 2px 8px rgba(0,0,0,0.25);
}

.app-header .logo-area {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-shrink: 0;
}

.app-header .logo-area img {
  height: 40px;
  width: auto;
  border-radius: 4px;
}

.app-header .app-title {
  font-size: 1.2rem;
  font-weight: 700;
  letter-spacing: -0.01em;
  color: #fff;
  white-space: nowrap;
}

.app-header .header-spacer { flex: 1; }

.header-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.btn-icon {
  background: rgba(255,255,255,0.1);
  border: 1px solid rgba(255,255,255,0.2);
  color: #fff;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1rem;
  transition: var(--transition);
}
.btn-icon:hover {
  background: rgba(255,255,255,0.2);
  transform: scale(1.05);
}

/* ---------- Step Wizard ---------- */
.wizard-nav {
  background: var(--bg-secondary);
  border-bottom: 1px solid var(--border-color);
  padding: 0 24px;
  display: flex;
  align-items: stretch;
  gap: 0;
  overflow-x: auto;
}

.wizard-step-tab {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 24px;
  cursor: pointer;
  border-bottom: 3px solid transparent;
  color: var(--text-muted);
  font-size: 0.9rem;
  font-weight: 500;
  transition: var(--transition);
  white-space: nowrap;
  user-select: none;
  background: none;
  border-top: none;
  border-left: none;
  border-right: none;
}

.wizard-step-tab:hover:not(.disabled) {
  color: var(--accent-primary);
  background: var(--accent-primary-light);
}

.wizard-step-tab.active {
  color: var(--accent-primary);
  border-bottom-color: var(--accent-primary);
  font-weight: 600;
}

.wizard-step-tab.completed {
  color: var(--accent-success);
}

.wizard-step-tab.disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.step-number {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.75rem;
  font-weight: 700;
  background: var(--bg-tertiary);
  color: var(--text-muted);
  flex-shrink: 0;
  transition: var(--transition);
}

.wizard-step-tab.active .step-number {
  background: var(--accent-primary);
  color: #fff;
}

.wizard-step-tab.completed .step-number {
  background: var(--accent-success);
  color: #fff;
}

/* ---------- Main Content ---------- */
.main-content {
  flex: 1;
  padding: 24px;
  max-width: 1400px;
  margin: 0 auto;
  width: 100%;
}

.step-panel { display: none; }
.step-panel.active { display: block; }

/* ---------- Cards ---------- */
.card {
  background: var(--bg-card);
  border-radius: var(--border-radius-lg);
  border: 1px solid var(--border-color);
  box-shadow: var(--shadow-sm);
  padding: 24px;
  margin-bottom: 20px;
}

.card-title {
  font-size: 1rem;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 16px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.card-title .card-icon {
  width: 28px;
  height: 28px;
  border-radius: 6px;
  background: var(--accent-primary-light);
  color: var(--accent-primary);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.85rem;
}

/* ---------- Upload Zone ---------- */
.upload-zone {
  border: 2px dashed var(--border-color);
  border-radius: var(--border-radius-lg);
  padding: 48px 32px;
  text-align: center;
  cursor: pointer;
  transition: var(--transition);
  background: var(--bg-primary);
  position: relative;
}

.upload-zone:hover, .upload-zone.drag-over {
  border-color: var(--accent-primary);
  background: var(--accent-primary-light);
  transform: scale(1.01);
}

.upload-zone.drag-over {
  box-shadow: 0 0 0 4px rgba(37,99,235,0.15);
}

.upload-zone input[type="file"] {
  position: absolute;
  inset: 0;
  opacity: 0;
  cursor: pointer;
  width: 100%;
  height: 100%;
}

.upload-icon {
  font-size: 3rem;
  margin-bottom: 12px;
  display: block;
}

.upload-zone h3 {
  font-size: 1.1rem;
  font-weight: 600;
  margin-bottom: 6px;
  color: var(--text-primary);
}

.upload-zone p {
  color: var(--text-muted);
  font-size: 0.875rem;
}

.upload-zone .upload-hint {
  margin-top: 12px;
  padding: 8px 16px;
  background: rgba(37,99,235,0.08);
  border-radius: 20px;
  font-size: 0.8rem;
  color: var(--accent-primary);
  display: inline-block;
}

/* ---------- File List ---------- */
.file-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 16px;
}

.file-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 14px;
  background: var(--bg-primary);
  border: 1px solid var(--border-color);
  border-radius: var(--border-radius);
  transition: var(--transition);
}

.file-item:hover { box-shadow: var(--shadow-sm); }

.file-item .file-icon { font-size: 1.3rem; }

.file-item .file-name {
  flex: 1;
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--text-primary);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.file-item .file-status {
  font-size: 0.8rem;
  color: var(--text-muted);
}

.file-item .file-remove {
  background: none;
  border: none;
  color: var(--accent-danger);
  cursor: pointer;
  padding: 2px 6px;
  border-radius: 4px;
  font-size: 0.85rem;
  opacity: 0.7;
  transition: var(--transition);
}
.file-item .file-remove:hover { opacity: 1; background: #fee2e2; }

/* ---------- Progress Bar ---------- */
.progress-container {
  margin: 12px 0;
}
.progress-label {
  display: flex;
  justify-content: space-between;
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-bottom: 4px;
}
.progress-bar-track {
  height: 8px;
  background: var(--bg-tertiary);
  border-radius: 999px;
  overflow: hidden;
}
.progress-bar-fill {
  height: 100%;
  background: var(--accent-primary);
  border-radius: 999px;
  transition: width 0.3s ease;
  width: 0%;
}

/* ---------- Step 2 Layout ---------- */
.step2-layout {
  display: grid;
  grid-template-columns: 1fr var(--sidebar-width);
  gap: 20px;
  align-items: start;
}

.step2-main { min-width: 0; }

.step2-sidebar {
  position: sticky;
  top: calc(var(--header-height) + 80px);
}

/* ---------- Data Table ---------- */
.table-toolbar {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 12px;
  flex-wrap: wrap;
}

.search-box {
  flex: 1;
  min-width: 180px;
  padding: 8px 12px 8px 36px;
  border: 1px solid var(--border-color);
  border-radius: var(--border-radius);
  background: var(--bg-primary);
  color: var(--text-primary);
  font-size: 0.875rem;
  transition: var(--transition);
  position: relative;
}

.search-wrapper {
  position: relative;
  flex: 1;
  min-width: 180px;
}
.search-wrapper .search-icon {
  position: absolute;
  left: 10px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
  pointer-events: none;
  font-size: 0.85rem;
}

.search-box:focus {
  outline: none;
  border-color: var(--border-focus);
  box-shadow: 0 0 0 3px rgba(37,99,235,0.12);
}

.filter-select {
  padding: 8px 10px;
  border: 1px solid var(--border-color);
  border-radius: var(--border-radius);
  background: var(--bg-secondary);
  color: var(--text-primary);
  font-size: 0.8rem;
  cursor: pointer;
  transition: var(--transition);
}
.filter-select:focus {
  outline: none;
  border-color: var(--border-focus);
}

.table-container {
  overflow-x: auto;
  border-radius: var(--border-radius);
  border: 1px solid var(--border-color);
}

.items-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.8rem;
}

.items-table th {
  padding: 10px 12px;
  text-align: left;
  background: var(--bg-tertiary);
  color: var(--text-secondary);
  font-weight: 600;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  border-bottom: 1px solid var(--border-color);
  white-space: nowrap;
  cursor: pointer;
  user-select: none;
}
.items-table th:hover { background: var(--accent-primary-light); color: var(--accent-primary); }
.items-table th.sorted-asc::after { content: ' ↑'; }
.items-table th.sorted-desc::after { content: ' ↓'; }

.items-table td {
  padding: 9px 12px;
  border-bottom: 1px solid var(--border-color);
  color: var(--text-primary);
  vertical-align: middle;
  max-width: 160px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.items-table tr:last-child td { border-bottom: none; }
.items-table tbody tr:nth-child(even) td { background: var(--bg-primary); }
.items-table tbody tr:hover td { background: var(--accent-primary-light); }

.items-table tbody tr.row-changed td {
  animation: rowFlash 0.6s ease;
}

@keyframes rowFlash {
  0% { background: rgba(37,99,235,0.2); }
  100% { background: transparent; }
}

.items-table tbody tr.row-highlight td {
  background: rgba(37,99,235,0.15) !important;
  outline: 2px solid var(--accent-primary);
  outline-offset: -2px;
}

/* Inline editing */
.editable-cell {
  cursor: pointer;
}
.editable-cell:hover {
  background: rgba(37,99,235,0.05);
  outline: 1px dashed var(--accent-primary);
  outline-offset: -1px;
}
.editable-cell.editing {
  padding: 0;
}
.cell-input, .cell-select {
  width: 100%;
  padding: 7px 8px;
  border: 2px solid var(--accent-primary);
  border-radius: 0;
  background: var(--bg-secondary);
  color: var(--text-primary);
  font-size: 0.8rem;
  outline: none;
}

/* ---------- Confidence Badges ---------- */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.badge.high {
  background: #dcfce7;
  color: #15803d;
}
.badge.medium {
  background: #fef9c3;
  color: #a16207;
}
.badge.low {
  background: #fee2e2;
  color: #dc2626;
}

body.dark-mode .badge.high { background: #14532d; color: #86efac; }
body.dark-mode .badge.medium { background: #451a03; color: #fcd34d; }
body.dark-mode .badge.low { background: #450a0a; color: #fca5a5; }

/* ---------- Row Action Buttons ---------- */
.row-actions {
  display: flex;
  gap: 4px;
  align-items: center;
}
.btn-row-action {
  background: none;
  border: 1px solid transparent;
  cursor: pointer;
  padding: 3px 6px;
  border-radius: 4px;
  font-size: 0.75rem;
  transition: var(--transition);
  color: var(--text-muted);
}
.btn-row-action:hover { border-color: var(--border-color); background: var(--bg-tertiary); color: var(--text-primary); }
.btn-row-action.delete:hover { color: var(--accent-danger); border-color: var(--accent-danger); background: #fee2e2; }
.btn-row-action.duplicate:hover { color: var(--accent-primary); border-color: var(--accent-primary); }

/* ---------- Warnings Panel ---------- */
.warnings-panel .warnings-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-height: 400px;
  overflow-y: auto;
}

.warning-item {
  padding: 10px 12px;
  border-radius: var(--border-radius);
  border-left: 3px solid var(--accent-warning);
  background: var(--bg-primary);
  font-size: 0.8rem;
}

.warning-item.error { border-left-color: var(--accent-danger); }
.warning-item.warning { border-left-color: var(--accent-warning); }
.warning-item.info { border-left-color: var(--accent-info); }

.warning-item .warning-msg {
  color: var(--text-primary);
  margin-bottom: 4px;
}
.warning-item .warning-link {
  color: var(--accent-primary);
  background: none;
  border: none;
  padding: 0;
  cursor: pointer;
  font-size: 0.75rem;
  text-decoration: underline;
}

.warning-count-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  border-radius: 999px;
  background: var(--accent-danger);
  color: #fff;
  font-size: 0.7rem;
  font-weight: 700;
}

/* ---------- Pricing Panel ---------- */
.pricing-settings .multiplier-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-top: 12px;
}

.multiplier-item {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.8rem;
}

.multiplier-item label {
  flex: 1;
  color: var(--text-secondary);
  font-size: 0.78rem;
}

.multiplier-item input {
  width: 70px;
  padding: 4px 6px;
  border: 1px solid var(--border-color);
  border-radius: var(--border-radius-sm);
  background: var(--bg-primary);
  color: var(--text-primary);
  font-size: 0.8rem;
  text-align: right;
}

/* ---------- Summary Bar ---------- */
.summary-bar {
  background: var(--navy);
  color: #fff;
  padding: 12px 24px;
  display: flex;
  align-items: center;
  gap: 24px;
  flex-wrap: wrap;
  position: sticky;
  top: var(--header-height);
  z-index: 90;
  border-bottom: 1px solid rgba(255,255,255,0.1);
}

.summary-stat {
  display: flex;
  flex-direction: column;
}
.summary-stat .stat-label {
  font-size: 0.7rem;
  opacity: 0.7;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}
.summary-stat .stat-value {
  font-size: 1rem;
  font-weight: 700;
}

.summary-bar .summary-spacer { flex: 1; }

/* ---------- Price Summary ---------- */
.price-summary-table {
  width: 100%;
  margin-top: 8px;
}
.price-summary-table tr td {
  padding: 5px 8px;
  font-size: 0.875rem;
}
.price-summary-table tr td:last-child {
  text-align: right;
  font-weight: 600;
}
.price-summary-table .total-row td {
  border-top: 2px solid var(--border-color);
  padding-top: 10px;
  font-size: 1rem;
  font-weight: 700;
  color: var(--accent-primary);
}

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 9px 18px;
  border-radius: var(--border-radius);
  font-size: 0.875rem;
  font-weight: 600;
  cursor: pointer;
  border: 1px solid transparent;
  transition: var(--transition);
  text-decoration: none;
  white-space: nowrap;
}

.btn-primary {
  background: var(--accent-primary);
  color: #fff;
  border-color: var(--accent-primary);
}
.btn-primary:hover { background: var(--accent-primary-hover); border-color: var(--accent-primary-hover); transform: translateY(-1px); box-shadow: var(--shadow-sm); }

.btn-secondary {
  background: var(--bg-secondary);
  color: var(--text-primary);
  border-color: var(--border-color);
}
.btn-secondary:hover { background: var(--bg-tertiary); border-color: var(--accent-primary); }

.btn-danger {
  background: var(--accent-danger);
  color: #fff;
  border-color: var(--accent-danger);
}
.btn-danger:hover { background: #b91c1c; }

.btn-ghost {
  background: transparent;
  color: var(--text-secondary);
  border-color: transparent;
}
.btn-ghost:hover { background: var(--bg-tertiary); color: var(--text-primary); }

.btn-success {
  background: var(--accent-success);
  color: #fff;
  border-color: var(--accent-success);
}
.btn-success:hover { background: #15803d; }

.btn-sm { padding: 5px 12px; font-size: 0.8rem; }
.btn-lg { padding: 12px 28px; font-size: 1rem; }

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none !important;
  box-shadow: none !important;
}

.btn-group {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
}

/* ---------- Form Inputs ---------- */
.form-group {
  margin-bottom: 14px;
}

.form-group label {
  display: block;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 5px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.form-control {
  width: 100%;
  padding: 9px 12px;
  border: 1px solid var(--border-color);
  border-radius: var(--border-radius);
  background: var(--bg-primary);
  color: var(--text-primary);
  font-size: 0.875rem;
  transition: var(--transition);
  font-family: inherit;
}

.form-control:focus {
  outline: none;
  border-color: var(--border-focus);
  box-shadow: 0 0 0 3px rgba(37,99,235,0.12);
}

.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.form-row {
  display: flex;
  gap: 12px;
}
.form-row .form-group { flex: 1; }

/* ---------- Modal ---------- */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  backdrop-filter: blur(2px);
}

.modal-backdrop.hidden { display: none; }

.modal-dialog {
  background: var(--bg-card);
  border-radius: var(--border-radius-lg);
  box-shadow: var(--shadow-lg);
  width: 100%;
  max-width: 600px;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  animation: modalIn 0.2s ease;
}

@keyframes modalIn {
  from { opacity: 0; transform: translateY(-16px) scale(0.97); }
  to { opacity: 1; transform: none; }
}

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

.modal-title {
  font-size: 1rem;
  font-weight: 700;
  color: var(--text-primary);
}

.modal-close {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 1.2rem;
  padding: 4px;
  border-radius: 4px;
  transition: var(--transition);
}
.modal-close:hover { color: var(--accent-danger); background: #fee2e2; }

.modal-body {
  padding: 24px;
  overflow-y: auto;
  flex: 1;
}

.modal-footer {
  padding: 16px 24px;
  border-top: 1px solid var(--border-color);
  display: flex;
  justify-content: flex-end;
  gap: 10px;
}

/* ---------- Toast Notifications ---------- */
.toast-container {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 2000;
  display: flex;
  flex-direction: column;
  gap: 8px;
  pointer-events: none;
}

.toast {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 12px 16px;
  border-radius: var(--border-radius);
  box-shadow: var(--shadow-lg);
  font-size: 0.875rem;
  min-width: 260px;
  max-width: 380px;
  pointer-events: all;
  animation: toastIn 0.3s ease;
  background: var(--bg-card);
  border-left: 4px solid;
}

@keyframes toastIn {
  from { opacity: 0; transform: translateX(40px); }
  to { opacity: 1; transform: none; }
}

@keyframes toastOut {
  from { opacity: 1; transform: none; }
  to { opacity: 0; transform: translateX(40px); }
}

.toast.hiding { animation: toastOut 0.25s ease forwards; }

.toast.success { border-left-color: var(--accent-success); }
.toast.error { border-left-color: var(--accent-danger); }
.toast.warning { border-left-color: var(--accent-warning); }
.toast.info { border-left-color: var(--accent-info); }

.toast-icon { font-size: 1rem; flex-shrink: 0; margin-top: 1px; }
.toast.success .toast-icon { color: var(--accent-success); }
.toast.error .toast-icon { color: var(--accent-danger); }
.toast.warning .toast-icon { color: var(--accent-warning); }
.toast.info .toast-icon { color: var(--accent-info); }

.toast-msg { flex: 1; color: var(--text-primary); line-height: 1.4; }

.toast-dismiss {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 0.85rem;
  padding: 0;
  flex-shrink: 0;
}

/* ---------- Loading Overlay ---------- */
.loading-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.55);
  z-index: 9999;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 16px;
  backdrop-filter: blur(3px);
}

.loading-overlay.hidden { display: none; }

.spinner {
  width: 48px;
  height: 48px;
  border: 4px solid rgba(255,255,255,0.2);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

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

.loading-text {
  color: #fff;
  font-size: 0.95rem;
  font-weight: 600;
  text-align: center;
}

.loading-sub {
  color: rgba(255,255,255,0.7);
  font-size: 0.8rem;
  text-align: center;
}

/* ---------- Stats Row ---------- */
.stats-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 12px;
  margin-bottom: 20px;
}

.stat-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--border-radius);
  padding: 14px 16px;
  text-align: center;
}

.stat-card .sc-label {
  font-size: 0.72rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  margin-bottom: 4px;
}

.stat-card .sc-value {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--text-primary);
}

.stat-card.accent-primary { border-top: 3px solid var(--accent-primary); }
.stat-card.accent-success { border-top: 3px solid var(--accent-success); }
.stat-card.accent-warning { border-top: 3px solid var(--accent-warning); }
.stat-card.accent-danger { border-top: 3px solid var(--accent-danger); }

/* ---------- Section Tabs (in card) ---------- */
.card-tabs {
  display: flex;
  gap: 0;
  border-bottom: 1px solid var(--border-color);
  margin: -24px -24px 20px -24px;
  padding: 0 24px;
}

.card-tab {
  padding: 12px 16px;
  border: none;
  background: none;
  cursor: pointer;
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--text-muted);
  border-bottom: 2px solid transparent;
  transition: var(--transition);
  white-space: nowrap;
}

.card-tab:hover { color: var(--accent-primary); }
.card-tab.active { color: var(--accent-primary); border-bottom-color: var(--accent-primary); font-weight: 600; }

/* ---------- Step 3 Layout ---------- */
.step3-layout {
  display: grid;
  grid-template-columns: 2fr 1fr;
  gap: 20px;
  align-items: start;
}

/* ---------- Quote Preview ---------- */
.quote-preview-box {
  background: #fff;
  border: 1px solid var(--border-color);
  border-radius: var(--border-radius);
  padding: 32px;
  min-height: 400px;
  box-shadow: var(--shadow-sm);
  color: #1a2340;
}

.qp-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  padding-bottom: 16px;
  border-bottom: 2px solid #1a3a6b;
  margin-bottom: 16px;
}

.qp-company-name {
  font-size: 1.4rem;
  font-weight: 800;
  color: #1a3a6b;
}

.qp-title {
  font-size: 1.6rem;
  font-weight: 700;
  color: #1a3a6b;
  text-align: right;
}

.qp-meta-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-bottom: 16px;
  font-size: 0.8rem;
}

.qp-meta-label { color: #555; }
.qp-meta-value { font-weight: 600; }

/* ---------- Empty State ---------- */
.empty-state {
  text-align: center;
  padding: 48px 24px;
  color: var(--text-muted);
}

.empty-state .empty-icon {
  font-size: 3.5rem;
  margin-bottom: 12px;
  display: block;
  opacity: 0.5;
}

.empty-state h3 {
  font-size: 1rem;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 6px;
}

.empty-state p {
  font-size: 0.875rem;
  margin-bottom: 16px;
}

/* ---------- Alert/Info boxes ---------- */
.alert {
  padding: 12px 14px;
  border-radius: var(--border-radius);
  font-size: 0.85rem;
  display: flex;
  gap: 10px;
  align-items: flex-start;
  margin-bottom: 12px;
}

.alert-icon { flex-shrink: 0; margin-top: 1px; }

.alert-info { background: #eff6ff; border: 1px solid #bfdbfe; color: #1d4ed8; }
.alert-warning { background: #fffbeb; border: 1px solid #fde68a; color: #92400e; }
.alert-success { background: #f0fdf4; border: 1px solid #bbf7d0; color: #166534; }
.alert-danger { background: #fef2f2; border: 1px solid #fecaca; color: #991b1b; }

body.dark-mode .alert-info { background: #1e3a5f; border-color: #1d4ed8; color: #93c5fd; }
body.dark-mode .alert-warning { background: #451a03; border-color: #92400e; color: #fcd34d; }
body.dark-mode .alert-success { background: #14532d; border-color: #166534; color: #86efac; }
body.dark-mode .alert-danger { background: #450a0a; border-color: #991b1b; color: #fca5a5; }

/* ---------- Section Divider ---------- */
.section-divider {
  border: none;
  border-top: 1px solid var(--border-color);
  margin: 20px 0;
}

/* ---------- Footer ---------- */
.app-footer {
  background: var(--bg-secondary);
  border-top: 1px solid var(--border-color);
  padding: 12px 24px;
  text-align: center;
  font-size: 0.75rem;
  color: var(--text-muted);
}

/* ---------- Logo upload ---------- */
.logo-upload-area {
  border: 2px dashed var(--border-color);
  border-radius: var(--border-radius);
  padding: 16px;
  text-align: center;
  cursor: pointer;
  transition: var(--transition);
  position: relative;
}
.logo-upload-area:hover { border-color: var(--accent-primary); background: var(--accent-primary-light); }
.logo-upload-area input { position: absolute; inset: 0; opacity: 0; cursor: pointer; width: 100%; height: 100%; }
.logo-preview { max-height: 60px; max-width: 160px; object-fit: contain; margin: 0 auto; display: block; }

/* ---------- Scroll ---------- */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border-color); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-muted); }

/* ---------- Responsive ---------- */
@media (max-width: 1100px) {
  .step2-layout { grid-template-columns: 1fr; }
  .step2-sidebar { position: static; }
  .step3-layout { grid-template-columns: 1fr; }
}

@media (max-width: 768px) {
  .main-content { padding: 12px; }
  .summary-bar { padding: 10px 16px; gap: 12px; }
  .form-grid { grid-template-columns: 1fr; }
  .multiplier-grid { grid-template-columns: 1fr; }
  .app-header .app-title { display: none; }
}

/* ---------- Utility ---------- */
.hidden { display: none !important; }
.text-right { text-align: right; }
.text-center { text-align: center; }
.text-muted { color: var(--text-muted); }
.font-mono { font-family: 'Courier New', monospace; }
.mt-2 { margin-top: 8px; }
.mb-2 { margin-bottom: 8px; }
.gap-8 { gap: 8px; }
.d-flex { display: flex; }
.align-center { align-items: center; }
.justify-between { justify-content: space-between; }

/* =========================================================
   PDF Viewer (pdfViewer.js) styles
   ========================================================= */

.pv-layout {
  display: grid;
  grid-template-columns: 1fr 320px;
  gap: 16px;
  align-items: start;
  min-height: 600px;
}

@media (max-width: 900px) {
  .pv-layout {
    grid-template-columns: 1fr;
  }
}

/* ---- Left panel: toolbar + canvas ---- */
.pv-toolbar {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 0 12px;
  border-bottom: 1px solid var(--border-color);
  margin-bottom: 12px;
  flex-wrap: wrap;
}

.pv-doc-name {
  font-weight: 600;
  font-size: 0.85rem;
  color: var(--text-primary);
  max-width: 280px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.pv-doc-select {
  padding: 4px 8px;
  border: 1px solid var(--border-color);
  border-radius: var(--border-radius-sm);
  background: var(--bg-card);
  color: var(--text-primary);
  font-size: 0.85rem;
  max-width: 280px;
}

.pv-page-nav {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-left: auto;
}

.pv-page-indicator {
  font-size: 0.85rem;
  color: var(--text-secondary);
  min-width: 80px;
  text-align: center;
}

.pv-canvas-wrap {
  overflow: auto;
  background: #888;
  border-radius: var(--border-radius);
  padding: 12px;
  min-height: 500px;
  display: flex;
  justify-content: center;
}

.pv-canvas-container {
  display: flex;
  justify-content: center;
  align-items: flex-start;
}

.pv-canvas-wrapper {
  position: relative;
  box-shadow: 0 4px 20px rgba(0,0,0,0.4);
  background: #fff;
}

.pv-pdf-canvas {
  display: block;
}

.pv-overlay-canvas {
  position: absolute;
  top: 0;
  left: 0;
  pointer-events: none;
}

.pv-loading {
  color: #fff;
  padding: 40px;
  font-size: 0.9rem;
  text-align: center;
}

.pv-error {
  color: #fca5a5;
}

/* ---- Right panel: sidebar ---- */
.pv-right {
  display: flex;
  flex-direction: column;
  gap: 12px;
  max-height: 700px;
}

.pv-sidebar-header {
  font-size: 0.8rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-secondary);
  padding-bottom: 6px;
  border-bottom: 1px solid var(--border-color);
}

.pv-items-list {
  overflow-y: auto;
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding-right: 2px;
}

.pv-no-items {
  font-size: 0.85rem;
  color: var(--text-muted);
  text-align: center;
  padding: 24px 0;
}

/* ---- Individual detected item card ---- */
.pv-item {
  border: 1px solid var(--border-color);
  border-radius: var(--border-radius-sm);
  padding: 8px 10px;
  background: var(--bg-card);
  transition: opacity 0.2s;
}

.pv-item.high   { border-left: 3px solid var(--accent-success); }
.pv-item.medium { border-left: 3px solid var(--accent-warning); }
.pv-item.low    { border-left: 3px solid var(--accent-danger); }

.pv-item-rejected {
  opacity: 0.5;
  background: var(--bg-primary);
}

.pv-item-header {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 4px;
}

.pv-item-ref {
  font-weight: 700;
  font-size: 0.9rem;
  font-family: 'Courier New', monospace;
}

.pv-rejected-label {
  font-size: 0.7rem;
  background: var(--accent-danger);
  color: #fff;
  border-radius: 3px;
  padding: 1px 5px;
  margin-left: auto;
}

.pv-item-meta,
.pv-item-spec {
  font-size: 0.75rem;
  color: var(--text-secondary);
  margin-bottom: 2px;
}

.pv-item-dims {
  font-size: 0.8rem;
  font-family: 'Courier New', monospace;
  color: var(--text-primary);
  margin-bottom: 4px;
}

.pv-dim-missing {
  color: var(--accent-danger);
  font-style: italic;
  font-family: inherit;
}

.pv-item-actions {
  display: flex;
  gap: 6px;
  margin-top: 6px;
}

/* ---- Confirm area ---- */
.pv-confirm-area {
  padding-top: 8px;
  border-top: 1px solid var(--border-color);
}

.pv-confirm-btn {
  width: 100%;
  margin-bottom: 8px;
}

.pv-hint {
  font-size: 0.75rem;
  color: var(--text-muted);
  line-height: 1.4;
}

.pv-legend {
  font-size: 0.75rem;
  color: var(--text-secondary);
  margin-bottom: 8px;
  display: flex;
  align-items: center;
  gap: 2px;
}

.pv-legend-dot {
  display: inline-block;
  width: 10px;
  height: 10px;
  border-radius: 50%;
}

.pv-legend-dot.high   { background: var(--accent-success); }
.pv-legend-dot.medium { background: var(--accent-warning); }
.pv-legend-dot.low    { background: var(--accent-danger); }

/* ---- Extra small button variant ---- */
.btn-xs {
  padding: 2px 8px;
  font-size: 0.75rem;
  line-height: 1.4;
  border-radius: 3px;
}

.btn-ghost {
  background: transparent;
  border: 1px solid var(--border-color);
  color: var(--text-secondary);
}

.btn-ghost:hover {
  background: var(--bg-tertiary);
}

.pv-doc-selector-wrap {
  flex: 1;
  min-width: 0;
}

/* ===== Diagnostics Panel ===== */
.diag-doc { margin-bottom: 12px; border: 1px solid var(--border-color); border-radius: 6px; overflow: hidden; }
.diag-doc-summary { padding: 8px 12px; cursor: pointer; display: flex; align-items: center; gap: 6px; background: var(--bg-secondary); font-weight: 600; font-size: 0.85rem; }
.diag-doc-name { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.diag-doc-body { padding: 12px; }
.diag-row { margin-bottom: 8px; font-size: 0.82rem; }
.diag-label { font-weight: 600; color: var(--text-secondary); }
.diag-badge { display: inline-block; padding: 2px 6px; border-radius: 10px; font-size: 0.72rem; font-weight: 600; margin: 0 2px; }
.diag-badge-success { background: #d1fae5; color: #059669; }
.diag-badge-warning { background: #fef3c7; color: #d97706; }
.diag-badge-danger  { background: #fee2e2; color: #dc2626; }
.diag-badge-info    { background: #dbeafe; color: #2563eb; }
.diag-badge-secondary { background: var(--bg-tertiary, #f1f5f9); color: var(--text-muted); }
.diag-badge-high    { background: #d1fae5; color: #059669; }
.diag-badge-medium  { background: #fef3c7; color: #d97706; }
.diag-badge-low     { background: #fee2e2; color: #dc2626; }
.diag-item-badge    { display: inline-block; padding: 1px 6px; border-radius: 8px; font-size: 0.72rem; margin: 2px; border: 1px solid currentColor; opacity: 0.9; }
.diag-warning       { color: var(--accent-warning, #d97706); font-size: 0.8rem; padding: 2px 0; }
.diag-raw summary   { cursor: pointer; color: var(--text-muted); font-size: 0.78rem; padding: 4px 0; }
.diag-pre           { font-family: monospace; font-size: 0.72rem; white-space: pre-wrap; word-break: break-all; background: var(--bg-tertiary, #f1f5f9); padding: 8px; border-radius: 4px; max-height: 300px; overflow-y: auto; margin-top: 4px; }
.diag-empty         { color: var(--text-muted); font-size: 0.85rem; padding: 12px; }
.btn-active         { background: rgba(255,255,255,0.2) !important; }
