/* ═══════════════════════════════════════════════════════════
   FiscalImmo 2026 — Feuille de styles
   Design : Editorial / Finance — Propre, lisible, professionnel
   ═══════════════════════════════════════════════════════════ */

@import url('https://fonts.googleapis.com/css2?family=Playfair+Display:ital,wght@0,700;0,900;1,700&family=Source+Sans+3:wght@300;400;500;600;700&family=JetBrains+Mono:wght@400;500;600&display=swap');

/* ── VARIABLES ── */
:root {
  --paper:    #f7f5ef;
  --paper2:   #edeae0;
  --paper3:   #e4e0d4;
  --ink:      #1c1814;
  --ink2:     #3d3830;
  --ink3:     #7a7268;
  --ink4:     #b0a898;
  --rule:     #d4cfc4;
  --surface:  #ffffff;
  --rouge:    #c0392b;
  --rouge-bg: #fdf0ee;
  --vert:     #1a6b45;
  --vert-bg:  #e8f5ec;
  --or:       #8b6914;
  --or-bg:    #fef9e7;
  --bleu:     #1a4b8c;
  --bleu-bg:  #edf2fb;

  --f-head: 'Playfair Display', Georgia, serif;
  --f-body: 'Source Sans 3', system-ui, sans-serif;
  --f-mono: 'JetBrains Mono', 'Courier New', monospace;

  --r: 8px;
  --r-lg: 14px;
  --shadow: 0 2px 10px rgba(0,0,0,0.08);
  --shadow-lg: 0 4px 24px rgba(0,0,0,0.12);
}

/* ── RESET ── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 14px; scroll-behavior: smooth; }

body {
  font-family: var(--f-body);
  background: var(--paper);
  color: var(--ink);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

/* ── HEADER ── */
.site-header {
  background: var(--ink);
  border-bottom: 3px solid var(--rouge);
  padding: 0 24px;
  height: 56px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 100;
}

.header-brand {
  display: flex;
  align-items: center;
  gap: 14px;
}

.brand-logo {
  font-family: var(--f-head);
  font-style: italic;
  font-size: 20px;
  color: #fff;
}
.brand-logo em { color: var(--rouge); font-style: normal; }

.brand-tags {
  display: flex;
  gap: 8px;
}

.brand-tag {
  background: rgba(255,255,255,0.08);
  border: 1px solid rgba(255,255,255,0.14);
  border-radius: 20px;
  padding: 2px 10px;
  font-size: 11px;
  color: rgba(255,255,255,0.6);
  font-weight: 500;
}
.brand-tag.live {
  background: rgba(26,107,69,0.3);
  border-color: rgba(26,107,69,0.5);
  color: #6ee7a7;
}

.header-actions {
  display: flex;
  gap: 8px;
}

.header-btn {
  background: rgba(255,255,255,0.07);
  border: 1px solid rgba(255,255,255,0.14);
  border-radius: 6px;
  padding: 5px 13px;
  color: rgba(255,255,255,0.75);
  font-family: var(--f-body);
  font-size: 12px;
  cursor: pointer;
  transition: all 0.15s;
}
.header-btn:hover { background: rgba(255,255,255,0.14); color: #fff; }

/* ── LAYOUT ── */
.app-layout {
  display: grid;
  grid-template-columns: 260px 1fr 280px;
  gap: 0;
  min-height: calc(100vh - 56px);
}

/* Colonnes */
.col-crm,
.col-main,
.col-crm-right {
  padding: 20px 16px;
  border-right: 1px solid var(--rule);
}
.col-crm-right { border-right: none; }

/* ── SECTION TITLES ── */
.section-title {
  font-family: var(--f-head);
  font-size: 17px;
  font-weight: 700;
  color: var(--ink);
  margin-bottom: 14px;
  padding-bottom: 8px;
  border-bottom: 2px solid var(--ink);
}

.col-title {
  font-family: var(--f-head);
  font-size: 15px;
  font-weight: 700;
  padding-bottom: 6px;
  border-bottom: 2px solid var(--ink);
  margin-bottom: 14px;
}

.col-sub {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--ink3);
  margin: 16px 0 7px;
  padding-bottom: 4px;
  border-bottom: 1px solid var(--rule);
}

/* ── FORMULAIRE ── */
.form-field {
  margin-bottom: 12px;
}

.form-field label {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: 11px;
  font-weight: 600;
  color: var(--ink2);
  margin-bottom: 4px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.form-field input,
.form-field select {
  width: 100%;
  background: var(--surface);
  border: 1.5px solid var(--rule);
  border-radius: var(--r);
  padding: 7px 10px;
  font-family: var(--f-mono);
  font-size: 12px;
  color: var(--ink);
  outline: none;
  transition: border-color 0.15s, background 0.15s;
  -webkit-appearance: none;
}

.form-field input:focus,
.form-field select:focus {
  border-color: var(--rouge);
  box-shadow: 0 0 0 3px rgba(192,57,43,0.1);
}

/* États validation */
.form-field input.field-valid   { border-color: var(--vert);  background: var(--vert-bg); }
.form-field input.field-invalid { border-color: var(--rouge); background: var(--rouge-bg); }

.field-error {
  display: none;
  font-size: 10.5px;
  color: var(--rouge);
  margin-top: 3px;
  font-family: var(--f-mono);
}

.g2 { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.g3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 6px; }

/* Slider */
.slider-row { display: flex; align-items: center; gap: 8px; }

input[type="range"] {
  flex: 1;
  -webkit-appearance: none;
  height: 3px;
  background: var(--rule);
  border-radius: 2px;
  border: none;
  padding: 0;
  outline: none;
}
input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 14px; height: 14px;
  background: var(--rouge);
  border-radius: 50%;
  cursor: pointer;
  border: 2px solid #fff;
  box-shadow: 0 1px 4px rgba(0,0,0,0.2);
}

.slider-val {
  font-family: var(--f-mono);
  font-size: 12px;
  font-weight: 600;
  color: var(--rouge);
  background: var(--rouge-bg);
  border: 1px solid rgba(192,57,43,0.2);
  border-radius: 5px;
  padding: 3px 8px;
  min-width: 52px;
  text-align: center;
  flex-shrink: 0;
}

/* Checkbox */
.check-row {
  display: flex;
  align-items: center;
  gap: 7px;
  font-size: 12.5px;
  color: var(--ink2);
  cursor: pointer;
  margin-bottom: 8px;
  user-select: none;
}
.check-row input[type="checkbox"] {
  width: 14px; height: 14px;
  accent-color: var(--rouge);
  cursor: pointer;
}

/* Tooltip */
.tip {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 14px; height: 14px;
  background: var(--paper3);
  border: 1px solid var(--rule);
  border-radius: 50%;
  font-size: 9px;
  font-weight: 700;
  color: var(--ink3);
  cursor: help;
  position: relative;
}
.tip::after {
  content: attr(data-tip);
  display: none;
  position: absolute;
  left: calc(100% + 6px);
  top: 50%;
  transform: translateY(-50%);
  background: var(--ink);
  color: #f0f0f0;
  font-family: var(--f-body);
  font-size: 11.5px;
  font-weight: 400;
  text-transform: none;
  letter-spacing: 0;
  line-height: 1.5;
  width: 220px;
  padding: 8px 11px;
  border-radius: 6px;
  z-index: 200;
  white-space: normal;
  box-shadow: var(--shadow-lg);
}
.tip:hover::after { display: block; }

/* ── BOUTONS ── */
.btn-run {
  width: 100%;
  background: var(--rouge);
  color: #fff;
  border: none;
  border-radius: 10px;
  padding: 13px 20px;
  font-family: var(--f-head);
  font-style: italic;
  font-size: 15px;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.2s;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  box-shadow: 0 3px 14px rgba(192,57,43,0.35);
  margin-top: 16px;
}
.btn-run:hover   { background: #a93226; transform: translateY(-1px); box-shadow: 0 5px 20px rgba(192,57,43,0.45); }
.btn-run:disabled{ opacity: 0.6; cursor: not-allowed; transform: none; box-shadow: none; }

.btn {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 6px 13px;
  border-radius: 6px;
  border: 1.5px solid var(--rule);
  background: var(--surface);
  font-family: var(--f-body);
  font-size: 12px;
  font-weight: 500;
  color: var(--ink2);
  cursor: pointer;
  transition: all 0.15s;
  text-decoration: none;
}
.btn:hover { border-color: var(--rouge); color: var(--rouge); }
.btn-email { background: var(--vert-bg); border-color: rgba(26,107,69,0.35); color: var(--vert); }
.btn-email:hover { border-color: var(--vert); }
.btn-sm { padding: 4px 9px; font-size: 11px; }
.btn-full { width: 100%; justify-content: center; margin-top: 6px; }

/* ── MESSAGES ── */
.error-box {
  display: none;
  align-items: center;
  gap: 10px;
  background: var(--rouge-bg);
  border: 1.5px solid rgba(192,57,43,0.4);
  border-radius: var(--r);
  padding: 11px 14px;
  font-size: 13px;
  color: var(--rouge);
  margin: 12px 0;
}
.error-icon { font-size: 18px; flex-shrink: 0; }
.btn-retry {
  margin-left: auto;
  background: none;
  border: 1px solid currentColor;
  border-radius: 5px;
  padding: 3px 10px;
  color: inherit;
  font-size: 11px;
  cursor: pointer;
  flex-shrink: 0;
}

.success-msg {
  display: none;
  background: var(--vert-bg);
  border: 1.5px solid rgba(26,107,69,0.4);
  border-radius: var(--r);
  padding: 9px 14px;
  font-size: 13px;
  color: var(--vert);
  margin: 12px 0;
}

.storage-warning {
  display: none;
  background: var(--or-bg);
  border: 1.5px solid rgba(139,105,20,0.3);
  border-radius: var(--r);
  padding: 7px 12px;
  font-size: 11px;
  color: var(--or);
  margin-top: 10px;
}

.no-results {
  background: var(--or-bg);
  border: 1.5px solid rgba(139,105,20,0.3);
  border-radius: var(--r);
  padding: 12px 16px;
  font-size: 13px;
  color: var(--or);
}

/* ── LOADER ── */
.loader {
  display: none;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 20px;
  font-size: 13px;
  color: var(--ink3);
}
.spinner {
  width: 18px; height: 18px;
  border: 2.5px solid var(--rule);
  border-top-color: var(--rouge);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ── BOUTONS EXEMPLE ── */
.exemples-strip {
  display: flex;
  gap: 6px;
  margin-bottom: 14px;
  flex-wrap: wrap;
}
.btn-ex {
  flex: 1;
  min-width: 80px;
  background: var(--bleu-bg);
  border: 1.5px solid rgba(26,75,140,0.25);
  border-radius: 6px;
  padding: 5px 8px;
  font-size: 11px;
  font-weight: 500;
  color: var(--bleu);
  cursor: pointer;
  transition: all 0.15s;
  text-align: center;
}
.btn-ex:hover { border-color: var(--bleu); }

/* ── TOP CARDS ── */
.top-cards {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
  margin-bottom: 20px;
}

.top-card {
  background: var(--surface);
  border: 1.5px solid var(--rule);
  border-radius: var(--r-lg);
  padding: 16px;
  text-align: center;
  transition: all 0.15s;
}
.top-card:hover { box-shadow: var(--shadow); }
.top-card--winner {
  border-color: var(--rouge);
  border-width: 2px;
  background: linear-gradient(135deg, #fff 70%, var(--rouge-bg));
}

.card-medal { font-size: 24px; margin-bottom: 4px; }
.card-rank  { font-family: var(--f-mono); font-size: 11px; color: var(--ink3); }
.card-regime {
  font-family: var(--f-head);
  font-size: 13px;
  font-weight: 700;
  margin: 6px 0;
  line-height: 1.3;
}

.card-score {
  font-family: var(--f-mono);
  font-size: 28px;
  font-weight: 700;
  line-height: 1;
  margin: 8px 0;
}
.card-score small { font-size: 14px; color: var(--ink3); }

.score-green  { color: var(--vert);  }
.score-yellow { color: var(--or);    }
.score-red    { color: var(--rouge); }

.card-metrics { text-align: left; border-top: 1px solid var(--rule); padding-top: 10px; }

.metric {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 11.5px;
  padding: 2px 0;
}
.metric-label { color: var(--ink3); }
.metric-value { font-family: var(--f-mono); font-size: 11px; font-weight: 600; }
.metric-rouge { color: var(--rouge); }
.metric-vert  { color: var(--vert);  }
.metric-or    { color: var(--or);    }

.card-avantages {
  font-size: 10.5px;
  color: var(--vert);
  margin-top: 8px;
  text-align: left;
  border-top: 1px solid var(--vert-bg);
  padding-top: 6px;
}

/* ── TABLEAU COMPARATIF ── */
.table-scroll { overflow-x: auto; }

.cmp-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12.5px;
  margin-bottom: 16px;
}
.cmp-table thead { background: var(--paper2); }
.cmp-table th {
  padding: 8px 10px;
  text-align: left;
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--ink3);
  border-bottom: 1px solid var(--rule);
  white-space: nowrap;
}
.cmp-table td {
  padding: 9px 10px;
  border-bottom: 1px solid var(--paper2);
  vertical-align: middle;
  font-family: var(--f-mono);
  font-size: 12px;
}
.cmp-table tr:last-child td { border-bottom: none; }
.cmp-table tr.row-winner { background: rgba(192,57,43,0.04); }
.cmp-table tr.row-second { background: rgba(139,105,20,0.03); }
.cmp-table tr.row-inapplicable { opacity: 0.5; font-style: italic; }
.regime-name { font-family: var(--f-body); font-weight: 600; }
.na-badge { display: inline-block; font-size: 10px; background: var(--paper3); border-radius: 4px; padding: 1px 6px; margin-left: 6px; color: var(--ink3); }
.na-reason { font-size: 11px; color: var(--ink3); margin-left: 8px; }

/* Score bar dans le tableau */
.score-bar-wrap { display: flex; align-items: center; gap: 6px; }
.score-bar {
  height: 5px;
  background: var(--vert);
  border-radius: 3px;
  transition: width 0.8s ease;
}
.score-bar[data-score] {
  max-width: 80px;
}

/* ── DÉTAILS PAR RÉGIME ── */
.detail-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 12px;
  margin-bottom: 20px;
}

.detail-card {
  background: var(--surface);
  border: 1.5px solid var(--rule);
  border-radius: var(--r-lg);
  padding: 14px 15px;
  transition: border-color 0.15s;
}
.detail-card:hover { border-color: var(--rouge); }
.detail-card--winner { border-color: var(--rouge); border-width: 2px; }
.detail-card--na { opacity: 0.5; }

.dc-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 10px;
}
.dc-name { font-family: var(--f-head); font-size: 13.5px; font-weight: 700; line-height: 1.3; }
.dc-score { font-family: var(--f-mono); font-size: 13px; font-weight: 700; }
.dc-badge--na {
  font-size: 10px;
  background: var(--paper3);
  color: var(--ink3);
  border-radius: 4px;
  padding: 2px 7px;
}
.dc-reason { font-size: 12px; color: var(--rouge); }

.dc-metrics {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 6px;
  margin-bottom: 10px;
}
.dc-m { background: var(--paper); border-radius: 6px; padding: 7px 8px; text-align: center; }
.dc-ml { font-size: 9px; color: var(--ink3); text-transform: uppercase; letter-spacing: 0.06em; }
.dc-mv { font-family: var(--f-mono); font-size: 12px; font-weight: 700; margin-top: 2px; }

details { margin-top: 8px; }
summary {
  font-size: 11.5px;
  font-weight: 600;
  color: var(--ink2);
  cursor: pointer;
  user-select: none;
  padding: 4px 0;
  list-style: none;
}
summary::marker, summary::-webkit-details-marker { display: none; }
summary::before { content: '▶ '; font-size: 9px; }
details[open] summary::before { content: '▼ '; }

.dc-detail-body {
  background: var(--paper2);
  border-radius: 6px;
  padding: 9px 11px;
  margin-top: 6px;
  font-size: 11.5px;
}
.detail-row {
  display: flex;
  justify-content: space-between;
  padding: 2px 0;
  border-bottom: 1px dashed var(--rule);
}
.detail-row:last-child { border-bottom: none; }

.dc-formula pre {
  background: var(--ink);
  color: #c8d4e0;
  border-radius: 6px;
  padding: 9px 12px;
  font-family: var(--f-mono);
  font-size: 10px;
  line-height: 1.8;
  margin-top: 6px;
  white-space: pre-wrap;
}

.vert-text  { font-size: 11.5px; color: var(--vert);  margin-bottom: 3px; }
.rouge-text { font-size: 11.5px; color: var(--rouge); }

/* ── GRAPHIQUES ── */
.charts-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-bottom: 16px;
}

.chart-card {
  background: var(--surface);
  border: 1.5px solid var(--rule);
  border-radius: var(--r-lg);
  padding: 14px;
}
.chart-card--full { grid-column: 1 / -1; }
.chart-title {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--ink2);
  margin-bottom: 12px;
}

/* ── EMAIL ── */
.email-card {
  background: var(--surface);
  border: 1.5px solid var(--rule);
  border-radius: var(--r-lg);
  padding: 16px;
}
.email-body {
  background: var(--paper2);
  border-radius: 6px;
  padding: 12px 14px;
  font-family: var(--f-mono);
  font-size: 11px;
  line-height: 1.8;
  white-space: pre-wrap;
  max-height: 220px;
  overflow-y: auto;
  margin: 10px 0;
  color: var(--ink2);
}
.email-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.no-email { font-size: 12px; color: var(--ink3); font-style: italic; }

/* ── CRM ── */
.crm-card {
  background: var(--surface);
  border: 1.5px solid var(--rule);
  border-radius: var(--r);
  padding: 9px 11px;
  margin-bottom: 7px;
  cursor: pointer;
  transition: all 0.15s;
}
.crm-card:hover { border-color: var(--rouge); }
.crm-card-head { display: flex; justify-content: space-between; margin-bottom: 3px; }
.crm-nom { font-weight: 600; font-size: 13px; }
.crm-badge { font-family: var(--f-mono); font-size: 9.5px; font-weight: 600; padding: 2px 7px; border-radius: 10px; }
.badge-hot  { background: var(--rouge-bg); color: var(--rouge); }
.badge-warm { background: var(--or-bg);    color: var(--or);    }
.badge-cold { background: var(--paper3);   color: var(--ink3);  }
.crm-info   { font-size: 11px; color: var(--ink3); }
.crm-regime { font-family: var(--f-mono); font-size: 10.5px; color: var(--ink2); margin-top: 3px; }
.crm-empty  { font-size: 12px; color: var(--ink3); text-align: center; padding: 20px; }

/* ── VALIDATION BOX ── */
.validation-box {
  background: var(--paper2);
  border: 1.5px solid var(--rule);
  border-radius: var(--r);
  padding: 9px 11px;
  margin-bottom: 12px;
  font-size: 11.5px;
  color: var(--ink2);
  line-height: 1.9;
}

/* ── RÉSULTATS SECTION ── */
#resultsSection { padding: 20px 0; }

/* ── PRINT ── */
@media print {
  .site-header, .col-crm, .col-crm-right, .exemples-strip,
  .email-actions, .header-actions, .btn-run { display: none !important; }
  .app-layout { display: block; }
  .col-main { padding: 0; border: none; }
  .charts-grid { grid-template-columns: 1fr 1fr; }
}

/* ── RESPONSIVE ── */
@media (max-width: 1100px) {
  .app-layout { grid-template-columns: 240px 1fr; }
  .col-crm-right { display: none; }
  .top-cards { grid-template-columns: 1fr 1fr; }
  .charts-grid { grid-template-columns: 1fr; }
}

@media (max-width: 768px) {
  .app-layout { grid-template-columns: 1fr; }
  .col-crm { display: none; }
  .top-cards { grid-template-columns: 1fr; }
  .detail-grid { grid-template-columns: 1fr; }
}
