/* ============================================================
   APP.CSS — Application patrimoniale Julien DUVAL
   Charte reprise du site patrimoine-toulouse.fr :
   navy #1B2B4B / or #C4973A, Playfair Display + Inter.
   Conçue mobile d'abord, installable en PWA.
============================================================ */

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

:root {
  --navy:        #1B2B4B;
  --navy-dark:   #111E35;
  --navy-mid:    #243A65;
  --navy-light:  #2E4A7A;
  --gold:        #C4973A;
  --gold-light:  #DFB35A;
  --gold-pale:   #FDF5E6;
  --cream:       #FAF8F4;
  --cream-dark:  #F0EBE1;
  --white:       #FFFFFF;
  --text-dark:   #1E2A3A;
  --text-mid:    #3D4F64;
  --text-light:  #6B7C93;
  --text-xlight: #9AAABB;
  --border:      #E4EAF0;
  --border-dark: #CDD5DF;
  --success:     #2E9E6B;
  --success-bg:  #EAF7F1;
  --warn:        #C8891F;
  --warn-bg:     #FDF3E3;
  --danger:      #C4523A;
  --danger-bg:   #FBEEEB;
  --shadow-sm:   0 2px 8px  rgba(27,43,75,.07);
  --shadow-md:   0 4px 24px rgba(27,43,75,.10);
  --shadow-lg:   0 8px 48px rgba(27,43,75,.14);
  --radius:      14px;
  --radius-lg:   20px;
  --tab-h:       64px;
}

html { -webkit-text-size-adjust: 100%; }

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  font-size: 16px;
  line-height: 1.6;
  color: var(--text-dark);
  background: var(--cream);
  -webkit-font-smoothing: antialiased;
  padding-bottom: calc(var(--tab-h) + env(safe-area-inset-bottom));
  overflow-x: hidden;
}

h1, h2, h3, h4 { font-family: 'Playfair Display', Georgia, serif; line-height: 1.2; color: var(--navy); font-weight: 700; }
h1 { font-size: 26px; }
h2 { font-size: 21px; }
h3 { font-size: 17px; }
a  { color: inherit; text-decoration: none; }
img { max-width: 100%; display: block; }
button { font-family: inherit; cursor: pointer; border: none; background: none; color: inherit; }
input, select, textarea { font-family: inherit; font-size: 16px; }

/* ============================================================
   EN-TÊTE
============================================================ */
.app-header {
  position: sticky; top: 0; z-index: 60;
  background: var(--navy);
  color: var(--white);
  padding: calc(env(safe-area-inset-top) + 12px) 18px 12px;
  display: flex; align-items: center; gap: 12px;
  box-shadow: var(--shadow-sm);
}
.app-header__back {
  width: 34px; height: 34px; flex-shrink: 0;
  display: grid; place-items: center;
  border-radius: 10px; background: rgba(255,255,255,.10);
  color: var(--white); font-size: 18px; line-height: 1;
}
.app-header__back:active { background: rgba(255,255,255,.2); }
.app-header__title {
  font-family: 'Playfair Display', Georgia, serif;
  font-size: 18px; font-weight: 700; color: var(--white);
  flex: 1; min-width: 0;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.app-header__logo { height: 30px; width: auto; border-radius: 6px; }
.app-header--hero { padding-bottom: 26px; }

/* ============================================================
   STRUCTURE
============================================================ */
.screen { max-width: 760px; margin: 0 auto; padding: 18px 16px 32px; }
.screen--wide { max-width: 1000px; }
.section { margin-top: 26px; }
.section__title {
  font-size: 12px; font-weight: 700; letter-spacing: 1.4px; text-transform: uppercase;
  color: var(--text-light); margin-bottom: 12px;
}
.stack > * + * { margin-top: 12px; }
.muted { color: var(--text-light); }
.small { font-size: 13px; }
.tiny  { font-size: 11.5px; }
.center { text-align: center; }
.gold { color: var(--gold); }
.nowrap { white-space: nowrap; }

/* ============================================================
   CARTES
============================================================ */
.card {
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px;
  box-shadow: var(--shadow-sm);
}
.card--flat { box-shadow: none; }
.card--navy { background: var(--navy); border-color: var(--navy); color: var(--white); }
.card--navy h2, .card--navy h3 { color: var(--white); }
.card--gold { background: var(--gold-pale); border-color: #EFDFC0; }
.card__label {
  font-size: 11px; font-weight: 700; letter-spacing: 1.2px;
  text-transform: uppercase; color: var(--text-light);
}
.card--navy .card__label { color: var(--gold-light); }

/* Tuiles de l'accueil */
.tiles { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; }
.tile {
  display: block; background: var(--white); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 16px; box-shadow: var(--shadow-sm);
  transition: transform .15s, box-shadow .15s;
}
.tile:active { transform: scale(.98); }
.tile__icon {
  width: 40px; height: 40px; border-radius: 11px;
  display: grid; place-items: center; margin-bottom: 10px;
  background: var(--gold-pale); color: var(--gold);
}
.tile__icon svg { width: 21px; height: 21px; }
.tile__title { font-weight: 700; font-size: 15px; color: var(--navy); line-height: 1.3; }
.tile__desc  { font-size: 12.5px; color: var(--text-light); margin-top: 3px; line-height: 1.4; }
.tile--wide { grid-column: 1 / -1; }

/* Liste de liens */
.list { background: var(--white); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; }
.list__item {
  display: flex; align-items: center; gap: 13px;
  padding: 14px 16px; border-bottom: 1px solid var(--border);
}
.list__item:last-child { border-bottom: none; }
.list__item:active { background: var(--cream); }
.list__icon {
  width: 34px; height: 34px; flex-shrink: 0; border-radius: 9px;
  display: grid; place-items: center; background: var(--cream-dark); color: var(--navy);
  font-size: 15px;
}
.list__body { flex: 1; min-width: 0; }
.list__title { font-weight: 600; font-size: 14.5px; color: var(--navy); }
.list__desc  { font-size: 12.5px; color: var(--text-light); }
.list__chev  { color: var(--text-xlight); font-size: 17px; }

/* ============================================================
   BOUTONS
============================================================ */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  font-weight: 600; font-size: 15px; padding: 13px 22px;
  border-radius: 11px; border: 2px solid transparent;
  transition: transform .12s, box-shadow .18s, background .18s;
  text-align: center;
}
.btn:active { transform: scale(.98); }
.btn--primary { background: var(--navy); color: var(--white); border-color: var(--navy); }
.btn--gold    { background: var(--gold); color: var(--white); border-color: var(--gold); }
.btn--ghost   { background: transparent; color: var(--navy); border-color: var(--border-dark); }
.btn--ghost-light { background: rgba(255,255,255,.12); color: var(--white); border-color: rgba(255,255,255,.3); }
.btn--block   { display: flex; width: 100%; }
.btn--lg      { padding: 16px 26px; font-size: 16px; }
.btn:disabled { opacity: .45; pointer-events: none; }

/* ============================================================
   FORMULAIRES
============================================================ */
.field { margin-bottom: 18px; }
.field__label { display: block; font-weight: 600; font-size: 14.5px; color: var(--navy); margin-bottom: 3px; }
.field__hint  { display: block; font-size: 12.5px; color: var(--text-light); margin-bottom: 9px; line-height: 1.45; }

.input, select.input {
  width: 100%; padding: 12px 14px;
  border: 1.5px solid var(--border-dark); border-radius: 11px;
  background: var(--white); color: var(--text-dark); font-weight: 600;
  transition: border-color .15s, box-shadow .15s;
}
.input:focus { outline: none; border-color: var(--gold); box-shadow: 0 0 0 3px rgba(196,151,58,.15); }
.input--euro { padding-right: 34px; }
.input-wrap { position: relative; }
.input-wrap__suffix {
  position: absolute; right: 14px; top: 50%; transform: translateY(-50%);
  color: var(--text-light); font-weight: 600; pointer-events: none;
}

/* Choix segmentés */
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  padding: 10px 15px; border-radius: 10px;
  border: 1.5px solid var(--border-dark); background: var(--white);
  font-size: 14px; font-weight: 600; color: var(--text-mid);
  transition: all .15s;
}
.chip.is-active { background: var(--navy); border-color: var(--navy); color: var(--white); }
.chip--gold.is-active { background: var(--gold); border-color: var(--gold); }
.chips--grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); }
.chip--stack { flex-direction: column; align-items: flex-start; text-align: left; display: flex; gap: 2px; }
.chip--stack .chip__sub { font-size: 12px; font-weight: 500; opacity: .75; }

/* Curseur */
input[type=range] {
  -webkit-appearance: none; appearance: none;
  width: 100%; height: 6px; border-radius: 3px;
  background: var(--cream-dark); outline: none; margin: 14px 0 6px;
}
input[type=range]::-webkit-slider-thumb {
  -webkit-appearance: none; appearance: none;
  width: 26px; height: 26px; border-radius: 50%;
  background: var(--gold); border: 3px solid var(--white);
  box-shadow: var(--shadow-sm); cursor: pointer;
}
input[type=range]::-moz-range-thumb {
  width: 26px; height: 26px; border-radius: 50%;
  background: var(--gold); border: 3px solid var(--white);
  box-shadow: var(--shadow-sm); cursor: pointer; border-color: var(--white);
}
.range-value {
  display: flex; align-items: baseline; gap: 5px;
  font-family: 'Playfair Display', Georgia, serif;
  font-size: 27px; font-weight: 700; color: var(--navy);
}
.range-value input {
  width: 5.5ch; border: none; border-bottom: 2px dashed var(--border-dark);
  font: inherit; color: inherit; text-align: right; background: transparent; padding: 0;
}
.range-value input:focus { outline: none; border-bottom-color: var(--gold); }
.range-bounds { display: flex; justify-content: space-between; font-size: 11.5px; color: var(--text-xlight); }

/* Interrupteur */
.switch { display: flex; align-items: center; justify-content: space-between; gap: 14px; padding: 4px 0; }
.switch__track {
  width: 50px; height: 30px; border-radius: 15px; background: var(--border-dark);
  position: relative; flex-shrink: 0; transition: background .2s;
}
.switch__track::after {
  content: ''; position: absolute; top: 3px; left: 3px;
  width: 24px; height: 24px; border-radius: 50%; background: var(--white);
  box-shadow: var(--shadow-sm); transition: transform .2s;
}
.switch.is-on .switch__track { background: var(--gold); }
.switch.is-on .switch__track::after { transform: translateX(20px); }

/* ============================================================
   RÉSULTATS
============================================================ */
.result {
  background: linear-gradient(135deg, var(--navy) 0%, var(--navy-mid) 100%);
  color: var(--white); border-radius: var(--radius-lg);
  padding: 22px; text-align: center;
}
.result__label { font-size: 12px; font-weight: 700; letter-spacing: 1.3px; text-transform: uppercase; color: var(--gold-light); }
.result__value {
  font-family: 'Playfair Display', Georgia, serif;
  font-size: 40px; font-weight: 700; line-height: 1.1; margin: 8px 0 4px;
  letter-spacing: -1px;
}
.result__value .unit { font-size: 24px; margin-left: 2px; }
.result__sub { font-size: 13.5px; color: rgba(255,255,255,.8); line-height: 1.5; }
.result__split { display: grid; grid-template-columns: 1fr 1fr; gap: 1px; margin-top: 18px; background: rgba(255,255,255,.14); border-radius: 12px; overflow: hidden; }
.result__split > div { background: rgba(0,0,0,.14); padding: 12px 8px; }
.result__split .k { font-size: 11px; text-transform: uppercase; letter-spacing: .8px; color: rgba(255,255,255,.65); }
.result__split .v { font-size: 17px; font-weight: 700; margin-top: 2px; }

.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 10px; }
.stat { background: var(--white); border: 1px solid var(--border); border-radius: 12px; padding: 13px 15px; }
.stat__k { font-size: 11.5px; color: var(--text-light); font-weight: 600; text-transform: uppercase; letter-spacing: .6px; }
.stat__v { font-family: 'Playfair Display', Georgia, serif; font-size: 22px; font-weight: 700; color: var(--navy); margin-top: 2px; }
.stat__v--gold { color: var(--gold); }
.stat__v--pos  { color: var(--success); }
.stat__v--neg  { color: var(--danger); }
.stat__sub { font-size: 12px; color: var(--text-light); }

/* Encadrés */
.callout { border-left: 4px solid var(--gold); background: var(--gold-pale); border-radius: 0 12px 12px 0; padding: 14px 16px; font-size: 14px; line-height: 1.55; }
.callout--info    { border-color: var(--navy-light); background: #EEF2FA; }
.callout--success { border-color: var(--success); background: var(--success-bg); }
.callout--warn    { border-color: var(--warn); background: var(--warn-bg); }
.callout--danger  { border-color: var(--danger); background: var(--danger-bg); }
.callout strong { color: var(--navy); }

/* Tableaux */
.table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.table th {
  background: var(--navy); color: var(--white); font-weight: 600;
  padding: 10px 8px; text-align: right; font-size: 12px;
}
.table th:first-child, .table td:first-child { text-align: left; }
.table td { padding: 9px 8px; text-align: right; border-bottom: 1px solid var(--border); }
.table tbody tr:nth-child(even) { background: var(--cream); }
.table td strong { color: var(--navy); }
.table-scroll { overflow-x: auto; border-radius: 12px; border: 1px solid var(--border); }

/* Barres de répartition */
.bars { display: flex; flex-direction: column; gap: 10px; }
.bar__head { display: flex; justify-content: space-between; font-size: 13.5px; margin-bottom: 4px; }
.bar__head .n { font-weight: 600; color: var(--navy); }
.bar__track { height: 9px; border-radius: 5px; background: var(--cream-dark); overflow: hidden; }
.bar__fill  { height: 100%; border-radius: 5px; background: var(--navy); transition: width .5s ease; }

/* Progression / score */
.gauge { position: relative; width: 168px; height: 168px; margin: 0 auto; }
.gauge svg { transform: rotate(-90deg); }
.gauge__center {
  position: absolute; inset: 0; display: flex; flex-direction: column;
  align-items: center; justify-content: center; text-align: center;
}
.gauge__score { font-family: 'Playfair Display', Georgia, serif; font-size: 46px; font-weight: 700; color: var(--navy); line-height: 1; }
.gauge__max   { font-size: 13px; color: var(--text-light); }

.progress { height: 5px; background: var(--cream-dark); border-radius: 3px; overflow: hidden; }
.progress__fill { height: 100%; background: var(--gold); transition: width .3s; }

.badge {
  display: inline-block; padding: 4px 10px; border-radius: 20px;
  font-size: 11.5px; font-weight: 700; letter-spacing: .4px;
  background: var(--cream-dark); color: var(--text-mid);
}
.badge--gold    { background: var(--gold-pale); color: var(--gold); }
.badge--success { background: var(--success-bg); color: var(--success); }
.badge--warn    { background: var(--warn-bg); color: var(--warn); }
.badge--danger  { background: var(--danger-bg); color: var(--danger); }
.badge--navy    { background: var(--navy); color: var(--white); }

/* ============================================================
   BARRE D'ONGLETS
============================================================ */
.tabbar {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 70;
  display: flex; background: rgba(255,255,255,.97);
  backdrop-filter: blur(12px);
  border-top: 1px solid var(--border);
  padding-bottom: env(safe-area-inset-bottom);
}
.tabbar__item {
  flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 3px; height: var(--tab-h); color: var(--text-xlight); font-size: 10.5px; font-weight: 600;
}
.tabbar__item svg { width: 22px; height: 22px; }
.tabbar__item.is-active { color: var(--navy); }
.tabbar__item.is-active svg { color: var(--gold); }

/* ============================================================
   APPEL À L'ACTION CONSEILLER
============================================================ */
.cta-advisor {
  background: linear-gradient(135deg, var(--navy) 0%, var(--navy-dark) 100%);
  color: var(--white); border-radius: var(--radius-lg); padding: 22px; text-align: center;
}
.cta-advisor__photo {
  width: 66px; height: 66px; border-radius: 50%; margin: 0 auto 12px;
  border: 2.5px solid var(--gold); object-fit: cover;
}
.cta-advisor h3 { color: var(--white); font-size: 19px; margin-bottom: 6px; }
.cta-advisor p  { font-size: 14px; color: rgba(255,255,255,.82); line-height: 1.55; margin-bottom: 16px; }
.cta-advisor .btn { width: 100%; }
.cta-advisor__legal { font-size: 11px; color: rgba(255,255,255,.5); margin-top: 12px; line-height: 1.45; }

/* Bandeau de bas de simulateur */
.sim-footer { margin-top: 26px; }
.hyp {
  font-size: 12.5px; color: var(--text-light); line-height: 1.6;
  background: var(--white); border: 1px dashed var(--border-dark);
  border-radius: 12px; padding: 14px 16px;
}
.hyp b { color: var(--text-mid); }

.disclaimer {
  font-size: 11.5px; color: var(--text-xlight); line-height: 1.55;
  text-align: center; margin-top: 22px; padding: 0 4px;
}

/* ============================================================
   DIVERS
============================================================ */
.hero-app { background: var(--navy); color: var(--white); padding: 0 18px 30px; }
.hero-app h1 { color: var(--white); font-size: 27px; }
.hero-app p { color: rgba(255,255,255,.78); font-size: 14.5px; margin-top: 7px; }

.stepper { display: flex; align-items: center; gap: 8px; margin-bottom: 18px; }
.stepper__bar { flex: 1; height: 4px; border-radius: 2px; background: var(--cream-dark); overflow: hidden; }
.stepper__fill { height: 100%; background: var(--gold); transition: width .3s ease; }
.stepper__txt { font-size: 12px; font-weight: 700; color: var(--text-light); white-space: nowrap; }

.q-title { font-family: 'Playfair Display', Georgia, serif; font-size: 22px; font-weight: 700; color: var(--navy); line-height: 1.28; }
.q-help  { font-size: 13.5px; color: var(--text-light); margin-top: 7px; line-height: 1.5; }

.fade-in { animation: fadeIn .35s ease both; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

.row { display: flex; gap: 10px; }
.row > * { flex: 1; }
.between { display: flex; align-items: center; justify-content: space-between; gap: 12px; }

/* ============================================================
   GRAND ÉCRAN
============================================================ */
@media (min-width: 860px) {
  body { padding-bottom: 0; padding-top: 0; }
  .tabbar {
    position: sticky; top: 0; bottom: auto;
    max-width: none; border-top: none; border-bottom: 1px solid var(--border);
    justify-content: center; gap: 6px; padding: 0 16px;
  }
  .tabbar__item { flex: 0 0 auto; flex-direction: row; gap: 8px; padding: 0 18px; height: 56px; font-size: 13.5px; }
  .tiles { grid-template-columns: repeat(3, 1fr); }
  h1 { font-size: 32px; }
  .screen { padding: 26px 24px 60px; }
}

/* ============================================================
   IMPRESSION — rapport de synthèse
============================================================ */
@media print {
  @page { size: A4; margin: 14mm 12mm; }
  body { background: var(--white); padding: 0; font-size: 11pt; }
  .tabbar, .app-header, .no-print, .btn { display: none !important; }
  .print-only { display: block !important; }
  .screen { max-width: none; padding: 0; }
  .card, .result, .cta-advisor { box-shadow: none; break-inside: avoid; }
  .result { background: var(--navy) !important; -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  .card--navy, .table th, .cta-advisor { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  .page-break { break-before: page; }
  a[href]::after { content: ''; }
}
.print-only { display: none; }
