/* ============================================================
   OmniRenovation AI — App CSS
   Full HTML/CSS control (no Streamlit restrictions)
   ============================================================ */

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

:root {
  --bg:           #0f1117;
  --surface:      #1a1d27;
  --surface-2:    #22263a;
  --border:       #2e3248;
  --accent:       #7c6af7;
  --accent-dark:  #5b4fcf;
  --accent-glow:  rgba(124, 106, 247, 0.25);
  --text:         #e8eaf6;
  --text-primary: #e8eaf6;
  --text-muted:   #8e93ad;
  --success:      #22c55e;
  --error:        #ef4444;
  --warning:      #f59e0b;
  --radius:       12px;
  --radius-sm:    8px;
  --shadow:       0 4px 24px rgba(0, 0, 0, 0.4);
  --font:         'Inter', system-ui, -apple-system, sans-serif;
}

html { font-size: 16px; scroll-behavior: smooth; }
body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* ── Header ─────────────────────────────────────────────────────────────── */
.app-header {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 0 2rem;
  height: 60px;
  display: flex;
  align-items: center;
  position: sticky;
  top: 0;
  z-index: 100;
}
.header-inner { max-width: 1200px; width: 100%; margin: 0 auto; }
.logo {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  text-decoration: none;
  color: var(--text);
}
.logo-icon { font-size: 1.4rem; }
.logo-text { font-size: 1.1rem; letter-spacing: -0.02em; }
.logo-text strong { color: var(--accent); }

/* ── Phase navigation ────────────────────────────────────────────────────── */
.phase-nav {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 0 2rem;
  overflow-x: auto;
}
.phase-nav-inner {
  max-width: 1200px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  padding: 0.75rem 0;
  gap: 0;
}
.phase-step {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  opacity: 0.4;
  transition: opacity 0.2s;
  flex-shrink: 0;
}
.phase-step.done   { opacity: 0.7; }
.phase-step.active { opacity: 1; }
.phase-dot {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--surface-2);
  border: 2px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.7rem;
  font-weight: 700;
  transition: all 0.2s;
}
.phase-step.done .phase-dot {
  background: var(--success);
  border-color: var(--success);
  color: #fff;
}
.phase-step.active .phase-dot {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
  box-shadow: 0 0 12px var(--accent-glow);
}
.phase-label {
  font-size: 0.65rem;
  font-weight: 500;
  color: var(--text-muted);
  white-space: nowrap;
}
.phase-step.active .phase-label { color: var(--accent); }
.phase-step.done  .phase-label  { color: var(--text); }
.phase-connector {
  flex: 1;
  min-width: 16px;
  height: 2px;
  background: var(--border);
  margin-bottom: 16px;
  transition: background 0.2s;
}
.phase-connector.done { background: var(--success); }

/* ── Flash messages ──────────────────────────────────────────────────────── */
.flash {
  max-width: 1200px;
  margin: 1rem auto 0;
  padding: 0.75rem 1rem;
  border-radius: var(--radius-sm);
  font-size: 0.875rem;
}
.flash-error   { background: rgba(239,68,68,0.15); border: 1px solid var(--error); color: var(--error); }
.flash-success { background: rgba(34,197,94,0.15); border: 1px solid var(--success); color: var(--success); }

/* ── Main layout ─────────────────────────────────────────────────────────── */
.app-main {
  flex: 1;
  max-width: 1200px;
  width: 100%;
  margin: 0 auto;
  padding: 2rem;
}
.phase-content { display: flex; flex-direction: column; gap: 2rem; }

/* ── Phase header ────────────────────────────────────────────────────────── */
.phase-header h1 {
  font-size: 2rem;
  font-weight: 700;
  letter-spacing: -0.03em;
  background: linear-gradient(135deg, var(--text) 0%, var(--accent) 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}
.phase-subtitle {
  margin-top: 0.5rem;
  color: var(--text-muted);
  font-size: 1rem;
  line-height: 1.6;
}

/* ── Cards ───────────────────────────────────────────────────────────────── */
.placeholder-card {
  background: var(--surface);
  border: 1px dashed var(--border);
  border-radius: var(--radius);
  padding: 2rem;
  color: var(--text-muted);
  line-height: 1.7;
}
.placeholder-card code {
  background: var(--surface-2);
  padding: 0.1em 0.4em;
  border-radius: 4px;
  font-size: 0.85em;
  color: var(--accent);
}

/* ── Upload dropzone ─────────────────────────────────────────────────────── */
.upload-form { display: flex; flex-direction: column; gap: 1.5rem; }
.dropzone {
  position: relative;
  border: 2px dashed var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  min-height: 240px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: border-color 0.2s, background 0.2s;
  overflow: hidden;
}
.dropzone:hover, .dropzone.drag-over {
  border-color: var(--accent);
  background: rgba(124,106,247,0.06);
}
.dropzone-input {
  position: absolute;
  inset: 0;
  opacity: 0;
  cursor: pointer;
  width: 100%;
  height: 100%;
}
.dropzone-label {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.5rem;
  color: var(--text-muted);
  pointer-events: none;
}
.dropzone-icon { font-size: 3rem; }
.dropzone-hint { font-size: 0.8rem; }
.dropzone-preview {
  width: 100%;
  max-height: 400px;
  object-fit: contain;
}
.hidden { display: none !important; }

/* ── Form elements ───────────────────────────────────────────────────────── */
.form-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 1rem;
}
.form-col { display: flex; flex-direction: column; gap: 1rem; }
.form-group { display: flex; flex-direction: column; gap: 0.4rem; }
.form-group label {
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--text-muted);
}
.form-input, .form-select {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  padding: 0.6rem 0.8rem;
  font-size: 0.95rem;
  font-family: var(--font);
  transition: border-color 0.2s;
  width: 100%;
}
.form-input:focus, .form-select:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-glow);
}

/* ── Buttons ─────────────────────────────────────────────────────────────── */
.form-actions { display: flex; gap: 1rem; flex-wrap: wrap; }
.btn {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.65rem 1.4rem;
  border-radius: var(--radius-sm);
  font-size: 0.95rem;
  font-weight: 600;
  font-family: var(--font);
  border: none;
  cursor: pointer;
  transition: all 0.15s;
  text-decoration: none;
}
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn-primary {
  background: var(--accent);
  color: #fff;
}
.btn-primary:hover:not(:disabled) {
  background: var(--accent-dark);
  box-shadow: 0 4px 16px var(--accent-glow);
}
.btn-secondary {
  background: var(--surface-2);
  color: var(--text);
  border: 1px solid var(--border);
}
.btn-secondary:hover:not(:disabled) { border-color: var(--accent); }
.btn-outline {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text-muted);
}
.btn-outline:hover:not(:disabled) { border-color: var(--text); color: var(--text); }
.disabled-link {
  opacity: 0.5;
  pointer-events: none;
  cursor: not-allowed;
}
.btn-large { padding: 0.85rem 2rem; font-size: 1.05rem; }
.btn-small { padding: 0.35rem 0.75rem; font-size: 0.8rem; }
.btn-icon { font-size: 1.1em; }

/* ── Job spinner / progress ──────────────────────────────────────────────── */
.job-spinner {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1.25rem;
  padding: 3rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}
.spinner-ring {
  width: 52px;
  height: 52px;
  border: 4px solid var(--surface-2);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.9s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.spinner-message { color: var(--text-muted); font-size: 0.95rem; }
.progress-bar-wrap {
  width: 100%;
  max-width: 360px;
  height: 6px;
  background: var(--surface-2);
  border-radius: 3px;
  overflow: hidden;
}
.progress-bar {
  height: 100%;
  background: linear-gradient(90deg, var(--accent), #a78bfa);
  border-radius: 3px;
  transition: width 0.4s ease;
}

/* ── Footer ──────────────────────────────────────────────────────────────── */
.app-footer {
  text-align: center;
  padding: 1.5rem;
  color: var(--text-muted);
  font-size: 0.8rem;
  border-top: 1px solid var(--border);
  margin-top: auto;
}

/* ── Upload choice UI ────────────────────────────────────────────────────── */
.upload-choice-section {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: calc(100vh - 120px);
  padding: 2rem 1rem;
}
.upload-choice-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 2.5rem 2rem;
  width: 100%;
  max-width: 760px;
  box-shadow: var(--shadow);
}
.upload-choice-header {
  text-align: center;
  margin-bottom: 2rem;
}
.upload-choice-header h1 {
  font-size: 1.6rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--text);
  margin-bottom: 0.4rem;
}
.upload-choice-header p {
  color: var(--text-muted);
  font-size: 0.95rem;
}
.upload-choice-grid {
  display: flex;
  gap: 0;
  align-items: stretch;
}
.upload-choice-divider {
  width: 1px;
  background: var(--border);
  flex-shrink: 0;
  margin: 0 0.5rem;
}
.upload-option {
  flex: 1;
  border: 2px dashed var(--border);
  border-radius: var(--radius);
  padding: 2rem 1.5rem;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  gap: 0.75rem;
  transition: border-color 0.2s, background 0.2s;
  min-height: 260px;
  position: relative;
}
.upload-option:hover, .upload-option.drag-over {
  border-color: var(--accent);
  background: rgba(124,106,247,0.05);
}
.upload-option-icon-wrap {
  width: 64px;
  height: 64px;
  border-radius: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 0.25rem;
}
.upload-option-icon-blue {
  background: rgba(56,189,248,0.12);
  color: #38bdf8;
}
.upload-option-icon-purple {
  background: rgba(124,106,247,0.15);
  color: var(--accent);
}
.upload-option h2 {
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--text);
}
.upload-option p {
  font-size: 0.85rem;
  color: var(--text-muted);
  line-height: 1.5;
  max-width: 220px;
}
.upload-option-hint {
  font-size: 0.72rem;
  color: var(--text-muted);
  opacity: 0.7;
}
.upload-option-body { display: flex; flex-direction: column; align-items: center; gap: 0.5rem; }
.upload-option-preview {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.5rem;
  width: 100%;
}
.upload-option-preview img {
  max-height: 160px;
  max-width: 100%;
  border-radius: var(--radius-sm);
  object-fit: cover;
}
.upload-option-filename {
  font-size: 0.78rem;
  color: var(--text-muted);
  word-break: break-all;
}
.upload-option-loading {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.6rem;
  font-size: 0.85rem;
  color: var(--text-muted);
}
.upload-lang-row {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.6rem;
  margin-top: 1.75rem;
  font-size: 0.85rem;
  color: var(--text-muted);
}

/* ── Generic card ────────────────────────────────────────────────────────── */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem;
}

/* ── Inline alerts ───────────────────────────────────────────────────────── */
.alert {
  padding: 0.75rem 1rem;
  border-radius: var(--radius-sm);
  font-size: 0.9rem;
  line-height: 1.5;
}
.alert-error   { background: rgba(239,68,68,0.12);  border: 1px solid var(--error);   color: var(--error); }
.alert-success { background: rgba(34,197,94,0.12);  border: 1px solid var(--success); color: var(--success); }
.alert a { color: inherit; text-decoration: underline; }

/* ── Badges ──────────────────────────────────────────────────────────────── */
.badge {
  display: inline-block;
  padding: 0.15em 0.55em;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 600;
  background: var(--surface-2);
  color: var(--text-muted);
  border: 1px solid var(--border);
}
.badge-success {
  background: rgba(34,197,94,0.15);
  color: var(--success);
  border-color: rgba(34,197,94,0.3);
}

/* ── Button size variants ────────────────────────────────────────────────── */
.btn-sm { padding: 0.3rem 0.75rem; font-size: 0.8rem; }

/* ── Misc text helpers ───────────────────────────────────────────────────── */
.text-error { color: var(--error); font-size: 0.875rem; }
.form-input-sm { max-width: 220px; padding: 0.4rem 0.65rem; font-size: 0.85rem; }

/* ── Mini per-item spinner ───────────────────────────────────────────────── */
.mini-spinner {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.5rem 0;
}
.spinner-ring-sm {
  width: 20px;
  height: 20px;
  border: 3px solid var(--surface-2);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.9s linear infinite;
  flex-shrink: 0;
}
.spinner-msg-sm { font-size: 0.85rem; color: var(--text-muted); }

/* ── Metrics row (valuation & BOM) ───────────────────────────────────────── */
.metrics-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
  gap: 0.75rem;
}
.metric-card {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 0.85rem 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}
.metric-label {
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
}
.metric-value {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--text-primary);
}

/* ── Feature list (valuation notable features) ───────────────────────────── */
.feature-list {
  list-style: none;
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  margin-top: 0.5rem;
}
.feature-list li {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 0.25em 0.7em;
  font-size: 0.8rem;
  color: var(--text-muted);
}

/* ── Design option cards ─────────────────────────────────────────────────── */
.design-options-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 1.25rem;
}
.design-option-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  transition: border-color 0.2s;
}
.design-option-card:hover { border-color: var(--accent); }
.design-option-card.selected { border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent-glow); }
.design-option-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.75rem 1rem;
  border-bottom: 1px solid var(--border);
  background: var(--surface-2);
}
.design-option-body { padding: 1rem; flex: 1; display: flex; flex-direction: column; gap: 0.75rem; }
.design-option-image { width: 100%; aspect-ratio: 16/9; object-fit: cover; border-radius: var(--radius-sm); }
.design-img { width: 100%; border-radius: var(--radius-sm); }
.design-option-details { font-size: 0.85rem; color: var(--text-muted); line-height: 1.6; }
.design-option-details strong { color: var(--text-primary); }
.design-option-actions { display: flex; gap: 0.5rem; flex-wrap: wrap; margin-top: auto; }
.palette-preview { display: flex; gap: 0.3rem; flex-wrap: wrap; }
.swatch {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  border: 2px solid rgba(255,255,255,0.15);
  display: inline-block;
  flex-shrink: 0;
}

/* ── Furniture analysis grid ─────────────────────────────────────────────── */
.furniture-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 1rem;
}
.furniture-item-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}
.furniture-item-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.65rem 0.9rem;
  background: var(--surface-2);
  border-bottom: 1px solid var(--border);
}
.furniture-item-body { padding: 0.9rem; display: flex; flex-direction: column; gap: 0.5rem; }
.furniture-attrs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.3rem 0.75rem;
  font-size: 0.82rem;
}
.furniture-attrs dt { color: var(--text-muted); }
.furniture-attrs dd { color: var(--text-primary); }
.furniture-measurements { font-size: 0.8rem; color: var(--text-muted); }
.color-dot-row { display: flex; gap: 0.3rem; align-items: center; flex-wrap: wrap; margin-top: 0.25rem; }
.color-dot {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  border: 2px solid rgba(255,255,255,0.15);
  display: inline-block;
}
.confidence-badge {
  font-size: 0.7rem;
  padding: 0.1em 0.5em;
  border-radius: 999px;
  background: rgba(124,106,247,0.15);
  color: var(--accent);
  border: 1px solid rgba(124,106,247,0.3);
  font-weight: 600;
}

/* ── Product search ───────────────────────────────────────────────────────── */
.product-item-section {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}
.product-item-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.75rem 1rem;
  background: var(--surface-2);
  border-bottom: 1px solid var(--border);
  flex-wrap: wrap;
  gap: 0.5rem;
}
.product-results-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 0.75rem;
  padding: 0.75rem;
}
.product-card {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  transition: border-color 0.2s, box-shadow 0.2s;
}
.product-card:hover { border-color: var(--accent); }
.product-card-selected { border-color: var(--accent) !important; box-shadow: 0 0 0 2px var(--accent-glow); }
.product-card-img { width: 100%; aspect-ratio: 1/1; overflow: hidden; background: var(--surface); }
.product-card-img img { width: 100%; height: 100%; object-fit: contain; }
.product-card-img-placeholder {
  width: 100%;
  aspect-ratio: 1/1;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 2.5rem;
  background: var(--surface);
}
.product-card-body { padding: 0.6rem; display: flex; flex-direction: column; gap: 0.3rem; flex: 1; }
.product-card-title { font-size: 0.8rem; line-height: 1.4; flex: 1; }
.product-card-title a { color: var(--text); text-decoration: none; }
.product-card-title a:hover { color: var(--accent); text-decoration: underline; }
.product-card-meta { display: flex; align-items: center; gap: 0.4rem; flex-wrap: wrap; }
.product-price { font-size: 0.85rem; font-weight: 700; color: var(--accent); }
.product-domain { font-size: 0.72rem; color: var(--text-muted); }
.product-thumb { width: 36px; height: 36px; border-radius: 4px; object-fit: cover; }
.product-title-link { font-weight: 600; text-decoration: none; color: var(--text); }
.product-title-link:hover { color: var(--accent); }
.selected-product-card {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.6rem 1rem;
  background: rgba(124,106,247,0.08);
  border-top: 1px solid rgba(124,106,247,0.25);
  font-size: 0.85rem;
  flex-wrap: wrap;
}

/* ── Furniture comparison row (detected card + product carousel) ─────────── */
.furniture-comparison-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.75rem;
  min-height: 260px;
}
.detected-furniture-card {
  flex: 0 0 160px;
  background: var(--surface-2);
  border: 2px solid var(--accent);
  border-radius: var(--radius-sm);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  align-self: stretch;
}
.detected-card-label {
  font-size: 0.68rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--accent);
  padding: 0.3rem 0.5rem;
  background: rgba(124,106,247,0.07);
  border-bottom: 1px solid rgba(124,106,247,0.2);
}
.detected-card-img {
  width: 100%;
  aspect-ratio: 1 / 1;
  overflow: hidden;
  background: var(--surface);
  display: flex;
  align-items: center;
  justify-content: center;
}
.detected-card-img img { width: 100%; height: 100%; object-fit: cover; }
.detected-card-placeholder { font-size: 2.5rem; }
.detected-card-body { padding: 0.4rem 0.5rem; flex: 1; }
.detected-card-name { font-size: 0.8rem; font-weight: 600; color: var(--text); margin: 0 0 0.1rem; line-height: 1.3; }
.detected-card-attrs { font-size: 0.7rem; color: var(--text-muted); margin: 0; line-height: 1.4; }
.carousel-arrow {
  flex: 0 0 28px;
  width: 28px;
  height: 28px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 50%;
  cursor: pointer;
  font-size: 1.2rem;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text);
  transition: background 0.15s, border-color 0.15s, color 0.15s;
  padding: 0;
  line-height: 1;
  flex-shrink: 0;
}
.carousel-arrow:hover:not(:disabled) { background: var(--surface); border-color: var(--accent); color: var(--accent); }
.carousel-arrow:disabled { opacity: 0.3; cursor: not-allowed; }
.product-carousel {
  flex: 1;
  overflow-x: scroll;
  overflow-y: hidden;
  scrollbar-width: none;
  -ms-overflow-style: none;
  scroll-behavior: smooth;
  min-width: 0;
}
.product-carousel::-webkit-scrollbar { display: none; }
.product-carousel-track {
  display: flex;
  flex-direction: row;
  gap: 0.5rem;
}

/* ── BOM table ───────────────────────────────────────────────────────────── */
.bom-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.85rem;
}
.bom-table th {
  padding: 0.5rem 0.75rem;
  text-align: left;
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
.bom-table td {
  padding: 0.55rem 0.75rem;
  border-bottom: 1px solid rgba(46,50,72,0.5);
  vertical-align: middle;
  color: var(--text);
}
.bom-table td a { color: var(--accent); text-decoration: none; }
.bom-table td a:hover { text-decoration: underline; }
.bom-row-active td { background: rgba(124,106,247,0.06); }

/* ── Preferences ─────────────────────────────────────────────────────────── */
.pref-item {
  border-bottom: 1px solid var(--border);
  padding: 0.9rem 0;
}
.pref-item:last-child { border-bottom: none; }
.pref-item-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.75rem;
  flex-wrap: wrap;
}
.pref-toggle {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  cursor: pointer;
}
.pref-toggle input[type="checkbox"] {
  width: 16px;
  height: 16px;
  accent-color: var(--accent);
  cursor: pointer;
  flex-shrink: 0;
}
.pref-item-name { display: flex; align-items: center; gap: 0.4rem; flex-wrap: wrap; font-size: 0.9rem; }
.pref-selected-badge { display: flex; align-items: center; gap: 0.4rem; flex-wrap: wrap; font-size: 0.82rem; }
.pref-item-notes { margin-top: 0.5rem; }

/* ── Procurement layout ──────────────────────────────────────────────────── */
.proc-layout {
  display: grid;
  grid-template-columns: 1fr 300px;
  gap: 1.5rem;
  align-items: start;
}
.proc-items { display: flex; flex-direction: column; gap: 0.75rem; }
.proc-items-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-weight: 600;
  font-size: 0.9rem;
  margin-bottom: 0.25rem;
}
.proc-item {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  display: flex;
  gap: 0.85rem;
  padding: 0.75rem;
  align-items: center;
}
.proc-item-img {
  width: 72px;
  height: 72px;
  border-radius: var(--radius-sm);
  object-fit: cover;
  flex-shrink: 0;
}
.proc-item-img-placeholder {
  width: 72px;
  height: 72px;
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.8rem;
  flex-shrink: 0;
}
.proc-item-info { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 0.2rem; }
.proc-item-subtitle { font-size: 0.7rem; font-weight: 600; color: var(--text-muted); letter-spacing: 0.05em; }
.proc-item-title { font-size: 0.85rem; line-height: 1.4; }
.proc-item-title a { color: var(--text); text-decoration: none; }
.proc-item-title a:hover { color: var(--accent); }
.proc-item-domain { font-size: 0.72rem; color: var(--text-muted); }
.proc-item-price { font-size: 0.95rem; font-weight: 700; color: var(--accent); white-space: nowrap; flex-shrink: 0; }
.proc-summary { position: sticky; top: 80px; }
.proc-summary-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}
.proc-summary-label {
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
  margin-bottom: 0.25rem;
}
.proc-summary-row {
  display: flex;
  justify-content: space-between;
  font-size: 0.85rem;
  color: var(--text-muted);
  gap: 0.5rem;
}
.proc-summary-row span:last-child { font-weight: 600; color: var(--text); white-space: nowrap; }
.proc-summary-total {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding-top: 0.75rem;
  margin-top: 0.25rem;
  border-top: 1px solid var(--border);
}
.proc-total-label { font-size: 0.75rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.06em; color: var(--text-muted); }
.proc-total-value { font-size: 1.3rem; font-weight: 800; color: var(--text); }

/* ── Before / After grid ─────────────────────────────────────────────────── */
.before-after-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.25rem;
}

/* ── Responsive ──────────────────────────────────────────────────────────── */
@media (max-width: 768px) {
  .app-main { padding: 1rem; }
  .phase-header h1 { font-size: 1.5rem; }
  .form-row { grid-template-columns: 1fr; }
  .proc-layout { grid-template-columns: 1fr; }
  .before-after-grid { grid-template-columns: 1fr; }
  .design-options-grid { grid-template-columns: 1fr; }
  .product-results-grid { grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); }
  .proc-summary { position: static; }
  .upload-choice-grid { flex-direction: column; }
  .upload-choice-divider { width: 100%; height: 1px; margin: 0.5rem 0; }
  .upload-choice-card { padding: 1.5rem 1rem; }
}

/* ── Header nav (auth) ───────────────────────────────────────────────────── */
.header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}
.header-nav {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex-shrink: 0;
}
.header-nav-link {
  color: var(--text-muted);
  text-decoration: none;
  font-size: 0.9rem;
  transition: color 0.15s;
}
.header-nav-link:hover { color: var(--text); }
.header-user {
  font-size: 0.85rem;
  color: var(--text-muted);
  max-width: 140px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.plan-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.25em;
  font-size: 0.7rem;
  font-weight: 700;
  padding: 0.2em 0.55em;
  border-radius: 4px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.plan-badge-link:hover .plan-badge {
  opacity: 0.8;
}
.plan-badge-chevron {
  opacity: 0.7;
  flex-shrink: 0;
}
.plan-free       { background: var(--surface-2); color: var(--text-muted); border: 1px solid var(--border); }
.plan-pro        { background: rgba(124,106,247,0.2); color: var(--accent); border: 1px solid var(--accent); }
.plan-enterprise { background: rgba(245,158,11,0.2); color: var(--warning); border: 1px solid var(--warning); }

/* ── Auth pages ──────────────────────────────────────────────────────────── */
.auth-page {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: calc(100vh - 120px);
  padding: 2rem 1rem;
}
.auth-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 2.5rem 2rem;
  width: 100%;
  max-width: 420px;
  box-shadow: var(--shadow);
}
.auth-header {
  text-align: center;
  margin-bottom: 1.75rem;
}
.auth-icon { font-size: 2.5rem; display: block; margin-bottom: 0.75rem; }
.auth-header h1 {
  font-size: 1.5rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  margin-bottom: 0.35rem;
}
.auth-header p { color: var(--text-muted); font-size: 0.9rem; }
.auth-form { display: flex; flex-direction: column; gap: 1rem; }
.auth-forgot {
  text-align: right;
  font-size: 0.82rem;
}
.auth-forgot a { color: var(--text-muted); text-decoration: none; }
.auth-forgot a:hover { color: var(--accent); }
.auth-footer {
  margin-top: 1.5rem;
  text-align: center;
  font-size: 0.875rem;
  color: var(--text-muted);
}
.auth-footer a { color: var(--accent); text-decoration: none; }
.auth-footer a:hover { text-decoration: underline; }

/* ── Projects list ───────────────────────────────────────────────────────── */
.projects-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
}
.projects-title {
  font-size: 2rem;
  font-weight: 700;
  letter-spacing: -0.03em;
  background: linear-gradient(135deg, var(--text) 0%, var(--accent) 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}
.projects-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 1.25rem;
}
.project-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 1rem;
  transition: border-color 0.2s;
}
.project-card:hover { border-color: var(--accent); }
.project-info { display: flex; flex-direction: column; gap: 0.2rem; }
.project-date   { font-size: 0.85rem; font-weight: 500; color: var(--text); }
.project-updated { font-size: 0.78rem; color: var(--text-muted); }
.project-progress-wrap { display: flex; flex-direction: column; gap: 0.4rem; }
.project-progress-label { font-size: 0.78rem; color: var(--text-muted); }
.project-phase-name { font-weight: 600; color: var(--accent); }
.project-phase-name.phase-name-complete { color: var(--success); }
.project-name-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}
.project-name {
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--text);
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.btn-icon-edit {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 0.9rem;
  padding: 0.15rem 0.3rem;
  border-radius: 4px;
  flex-shrink: 0;
  transition: color 0.15s, background 0.15s;
}
.btn-icon-edit:hover { color: var(--accent); background: var(--surface-2); }
.project-name-edit { display: flex; flex-direction: column; gap: 0.25rem; }
.project-actions {
  display: flex;
  gap: 0.5rem;
  align-items: center;
  margin-top: auto;
}
.projects-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1rem;
  padding: 4rem 2rem;
  text-align: center;
  background: var(--surface);
  border: 1px dashed var(--border);
  border-radius: var(--radius);
}
.projects-empty-icon { font-size: 3.5rem; }
.projects-empty h2 { font-size: 1.4rem; font-weight: 600; }
.projects-empty p { color: var(--text-muted); max-width: 320px; }

/* ── Subscription plans ──────────────────────────────────────────────────── */
.plans-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 1.25rem;
}
.plan-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.75rem 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 1rem;
  position: relative;
  transition: border-color 0.2s;
}
.plan-card-current {
  border-color: var(--accent);
  box-shadow: 0 0 0 1px var(--accent), 0 4px 24px var(--accent-glow);
}
.plan-current-badge {
  position: absolute;
  top: -1px;
  right: 1.25rem;
  font-size: 0.7rem;
  font-weight: 700;
  background: var(--accent);
  color: #fff;
  padding: 0.2em 0.65em;
  border-radius: 0 0 6px 6px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.plan-name  { font-size: 1.15rem; font-weight: 700; }
.plan-price { font-size: 1.6rem; font-weight: 800; letter-spacing: -0.03em; color: var(--accent); }
.plan-features {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  flex: 1;
}
.plan-features li {
  display: flex;
  align-items: flex-start;
  gap: 0.5rem;
  font-size: 0.875rem;
  color: var(--text-muted);
}
.plan-check { color: var(--success); font-weight: 700; flex-shrink: 0; }
.plan-action { margin-top: 0.5rem; }
