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

:root {
  --green-900: #04342C;
  --green-800: #085041;
  --green-700: #0F6E56;
  --green-500: #1D9E75;
  --green-200: #9FE1CB;
  --green-50:  #E1F5EE;
  --gray-900: #2C2C2A;
  --gray-700: #5F5E5A;
  --gray-400: #888780;
  --gray-200: #D3D1C7;
  --gray-100: #F1EFE8;
  --purple-800: #3C3489;
  --purple-50:  #EEEDFE;
  --blue-50: #E6F1FB;
  --amber-50: #FAEEDA;
  --white: #ffffff;
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --font-sans: 'DM Sans', system-ui, sans-serif;
  --font-serif: 'DM Serif Display', Georgia, serif;
}

body {
  font-family: var(--font-sans);
  background: var(--gray-100);
  color: var(--gray-900);
  line-height: 1.6;
  min-height: 100vh;
}

/* ── TOPBAR ── */
.topbar {
  background: var(--white);
  border-bottom: 1px solid var(--gray-200);
  position: sticky; top: 0; z-index: 100;
}
.topbar-inner {
  max-width: 960px; margin: 0 auto;
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 1.5rem; height: 56px;
}
.brand { display: flex; align-items: center; gap: 10px; }
.brand-logo {
  width: 32px; height: 32px; border-radius: 8px;
  background: var(--green-700); color: white;
  display: flex; align-items: center; justify-content: center;
  font-weight: 500; font-size: 16px;
}
.brand-name { font-size: 15px; font-weight: 500; }
.brand-sep { color: var(--gray-400); margin: 0 4px; }
.topnav { display: flex; gap: 4px; }
.nav-link {
  font-size: 14px; color: var(--gray-700); text-decoration: none;
  padding: 6px 12px; border-radius: var(--radius-sm);
  transition: background 0.15s;
}
.nav-link:hover, .nav-link.active {
  background: var(--green-50); color: var(--green-700);
}

/* ── MAIN ── */
.main {
  max-width: 960px; margin: 0 auto;
  padding: 2.5rem 1.5rem 4rem;
}

/* ── HERO ── */
.hero { text-align: center; margin-bottom: 2rem; }
.hero-badge {
  display: inline-flex; align-items: center; gap: 6px;
  background: var(--green-50); color: var(--green-700);
  font-size: 12px; font-weight: 500;
  padding: 5px 14px; border-radius: 20px;
  margin-bottom: 1rem;
}
.hero-title {
  font-family: var(--font-serif);
  font-size: 36px; font-weight: 400; line-height: 1.2;
  color: var(--gray-900); margin-bottom: 0.75rem;
}
.hero-sub { font-size: 15px; color: var(--gray-700); }

/* ── CARD ── */
.card {
  background: var(--white);
  border: 1px solid var(--gray-200);
  border-radius: var(--radius-lg);
  padding: 2rem;
}
.app-card { margin-bottom: 2rem; }

/* ── STEPS ── */
.step-row {
  display: flex; gap: 1rem;
  padding-bottom: 1.75rem;
  margin-bottom: 1.75rem;
  border-bottom: 1px solid var(--gray-100);
}
.step-row:last-child { padding-bottom: 0; margin-bottom: 0; border-bottom: none; }
.step-num {
  width: 30px; height: 30px; border-radius: 50%;
  background: var(--green-50); color: var(--green-700);
  font-size: 14px; font-weight: 500;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0; margin-top: 2px;
}
.step-content { flex: 1; }
.step-label {
  font-size: 11px; font-weight: 500;
  color: var(--gray-400); text-transform: uppercase;
  letter-spacing: 0.08em; margin-bottom: 10px;
}

/* ── UPLOAD ── */
.upload-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.upload-card {
  border: 1.5px dashed var(--gray-200);
  border-radius: var(--radius-md);
  padding: 1.25rem 1rem;
  text-align: center; cursor: pointer;
  transition: all 0.15s; position: relative;
  background: var(--white);
}
.upload-card:hover { border-color: var(--green-500); background: var(--green-50); }
.upload-card.has-file { border-style: solid; border-color: var(--green-500); background: var(--green-50); }
.upload-card input[type=file] { position: absolute; inset: 0; opacity: 0; cursor: pointer; width: 100%; height: 100%; }
.upload-icon { font-size: 26px; color: var(--gray-400); display: block; margin-bottom: 8px; }
.upload-card.has-file .upload-icon { color: var(--green-700); }
.upload-title { font-size: 13px; font-weight: 500; margin-bottom: 3px; }
.upload-subtitle { font-size: 11px; color: var(--gray-400); }
.upload-card.has-file .upload-subtitle { color: var(--green-700); }
.file-name { font-size: 11px; color: var(--green-700); font-weight: 500; margin-top: 5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* ── FORM ── */
.proj-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.field {
  width: 100%; font-size: 14px; font-family: var(--font-sans);
  padding: 10px 14px;
  border: 1px solid var(--gray-200);
  border-radius: var(--radius-sm);
  background: var(--white); color: var(--gray-900);
  appearance: none; transition: border-color 0.15s;
}
.field::placeholder { color: var(--gray-400); }
.field:focus { outline: none; border-color: var(--green-500); }

/* ── BUTTON ── */
.analyze-btn {
  width: 100%; padding: 13px;
  background: var(--green-700); color: white;
  border: none; border-radius: var(--radius-sm);
  font-family: var(--font-sans); font-size: 15px; font-weight: 500;
  cursor: pointer; display: flex; align-items: center; justify-content: center; gap: 8px;
  transition: background 0.15s;
}
.analyze-btn:hover { background: var(--green-800); }
.analyze-btn:disabled { background: var(--gray-200); cursor: not-allowed; }

/* ── PROGRESS ── */
.progress-bar-wrap { background: var(--gray-100); border-radius: 4px; height: 5px; margin: 14px 0 6px; overflow: hidden; }
.progress-bar { height: 5px; border-radius: 4px; background: var(--green-500); width: 0%; transition: width 0.4s ease; }
.progress-label { font-size: 12px; color: var(--gray-400); text-align: center; }

.spinner { width: 18px; height: 18px; border: 2px solid rgba(255,255,255,0.3); border-top-color: white; border-radius: 50%; animation: spin 0.7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ── ERROR ── */
.error-box {
  display: none; margin-top: 12px;
  background: #FCEBEB; border: 1px solid #F09595;
  border-radius: var(--radius-sm); padding: 12px 14px;
  font-size: 13px; color: #A32D2D;
}
.error-box.visible { display: block; }

/* ── RESULTS ── */
.results { display: none; }
.results.visible { display: block; }
.results-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 1.25rem; }
.results-title { font-family: var(--font-serif); font-size: 24px; font-weight: 400; }
.reset-btn {
  background: var(--white); border: 1px solid var(--gray-200);
  border-radius: var(--radius-sm); padding: 8px 16px;
  font-family: var(--font-sans); font-size: 13px;
  color: var(--gray-700); cursor: pointer;
  display: flex; align-items: center; gap: 6px;
  transition: all 0.15s;
}
.reset-btn:hover { background: var(--gray-100); }

/* ── METRICS ── */
.metrics-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; margin-bottom: 1.25rem; }
.metric-card {
  background: var(--gray-100); border-radius: var(--radius-md);
  padding: 1rem 1.25rem;
}
.metric-card.accent { background: var(--green-50); }
.metric-label { font-size: 12px; color: var(--gray-700); margin-bottom: 6px; }
.metric-value { font-size: 24px; font-weight: 500; }
.metric-card.accent .metric-value { color: var(--green-700); }
.metric-unit { font-size: 11px; color: var(--gray-400); margin-top: 3px; }

/* ── PANELS ── */
.two-col { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-bottom: 1.25rem; }
.panel {
  background: var(--white); border: 1px solid var(--gray-200);
  border-radius: var(--radius-md); padding: 1.25rem;
}
.panel-title { font-size: 14px; font-weight: 500; margin-bottom: 1rem; display: flex; align-items: center; gap: 8px; color: var(--gray-900); }
.panel-title i { font-size: 16px; color: var(--green-500); }
.sketch-panel { margin-bottom: 1.25rem; }
.sketch-panel canvas { width: 100%; display: block; border-radius: 8px; }

/* ── BREAKDOWN ── */
.breakdown-row { display: flex; justify-content: space-between; align-items: flex-start; padding: 9px 0; border-bottom: 1px solid var(--gray-100); font-size: 13px; }
.breakdown-row:last-child { border-bottom: none; }
.breakdown-label { color: var(--gray-700); margin-bottom: 4px; }
.breakdown-bar { height: 3px; border-radius: 2px; background: var(--gray-100); width: 120px; margin-top: 5px; }
.breakdown-fill { height: 3px; border-radius: 2px; background: var(--green-500); }
.breakdown-val { font-weight: 500; text-align: right; }

/* ── INFO GRID ── */
.info-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.info-item .lbl { font-size: 11px; color: var(--gray-400); margin-bottom: 2px; }
.info-item .val { font-size: 13px; font-weight: 500; }

/* ── RECO ── */
.reco-item { display: flex; gap: 10px; padding: 9px 0; border-bottom: 1px solid var(--gray-100); font-size: 13px; color: var(--gray-700); }
.reco-item:last-child { border-bottom: none; }
.reco-dot { width: 6px; height: 6px; border-radius: 50%; background: var(--green-500); margin-top: 6px; flex-shrink: 0; }

/* ── FOOTER ── */
.footer { background: var(--white); border-top: 1px solid var(--gray-200); margin-top: 4rem; }
.footer-inner {
  max-width: 960px; margin: 0 auto;
  padding: 1.25rem 1.5rem;
  display: flex; justify-content: space-between; align-items: center;
  font-size: 13px; color: var(--gray-400);
}

/* ── AUTH NAV ── */
.nav-user { font-size: 13px; color: var(--gray-400); padding: 6px 8px; }
.nav-logout {
  background: none; border: none; cursor: pointer;
  font-family: var(--font-sans); display: flex; align-items: center; gap: 4px;
}
.nav-logout:hover { background: #FCEBEB; color: #A32D2D; }
.nav-role-badge {
  font-size: 11px; font-weight: 500;
  padding: 3px 10px; border-radius: 20px;
}
.badge-admin { background: var(--green-50); color: var(--green-700); }
.badge-user  { background: var(--gray-100); color: var(--gray-400); }

/* ── SCENARIO BUTTONS ── */
.scenario-btn {
  background: var(--white); border: 1px solid var(--gray-200);
  border-radius: var(--radius-sm); padding: 7px 16px;
  font-family: var(--font-sans); font-size: 13px;
  color: var(--gray-700); cursor: pointer;
  transition: all 0.15s;
}
.scenario-btn:hover  { background: var(--green-50); border-color: var(--green-500); color: var(--green-700); }
.scenario-btn.active { background: var(--green-700); border-color: var(--green-700); color: white; font-weight: 500; }

/* ── VALIDATION TABLE ── */
.val-field:focus { border-color: var(--green-500); }

/* ── SKETCH PANELS ── */
.sketch-panel div { overflow: hidden; border-radius: 8px; background: #F8F7F3; }

/* ── FOOTER NOTE ── */
.footer-note { font-size: 13px; color: var(--gray-400); }

/* ── RESPONSIVE ── */
@media (max-width: 640px) {
  .upload-grid { grid-template-columns: 1fr; }
  .proj-grid { grid-template-columns: 1fr; }
  .metrics-grid { grid-template-columns: 1fr 1fr; }
  .two-col { grid-template-columns: 1fr; }
  .info-grid { grid-template-columns: 1fr 1fr; }
  .hero-title { font-size: 26px; }
  .topnav { display: none; }
}

/* ── IMPRESSION / EXPORT PDF ── */
@media print {
  /* Masquer tout sauf les résultats */
  .topbar, .footer, #screen-input, #screen-extracting, #screen-validation,
  #mode-btn-scenarios, #mode-btn-custom, #row-scenarios, #row-custom,
  .reset-btn, [onclick="window.print()"],
  #trace-toggle { display: none !important; }

  #screen-results { display: block !important; }

  body { background: white; font-size: 12px; }

  .main { max-width: 100%; padding: 1rem; }

  /* Forcer la traçabilité visible */
  #trace-body { display: block !important; }

  /* Éviter les coupures au milieu d'un panel */
  .panel, .metric-card { break-inside: avoid; }
  .metrics-grid { grid-template-columns: repeat(4, 1fr); }
  .two-col { grid-template-columns: 1fr 1fr; }

  /* Sketches — autoriser overflow pour que le SVG s'affiche */
  .sketch-panel div { overflow: visible; }
  .sketch-panel svg { max-width: 100%; }

  /* Supprimer les ombres et bordures lourdes */
  .card, .panel { box-shadow: none; border: 1px solid #ccc; }

  /* Filigrane bas de page */
  .results-title::after {
    content: ' — Résultat indicatif, non contractuel';
    font-size: 11px; color: #999; font-weight: 400;
  }
}
