/* ===== Charte graphique — à ajuster ici (une seule zone) ===== */
:root {
  --brand: #23343b;        /* ardoise */
  --brand-dark: #1a272c;
  --accent: #e02623;       /* rouge d'accent */
  --accent-dark: #b91f1d;
  --bg: #f5f5f5;
  --card: #ffffff;
  --text: #222222;
  --muted: #4f5e67;
  --line: #e2e8f0;
  --radius: 8px;
  --font: "Brandon Grotesque", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body { margin: 0; font-family: var(--font); color: var(--text); background: var(--bg); font-size: 15px; }
[hidden] { display: none !important; }
svg { fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }

/* ===== Boutons / champs ===== */
.btn { border: 0; border-radius: 4px; padding: 11px 18px; font: inherit; font-weight: 600; cursor: pointer; }
.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-dark); }
.btn:disabled { opacity: .6; cursor: default; }
.link { background: none; border: 0; color: var(--brand); text-decoration: underline; cursor: pointer; font: inherit; padding: 4px; align-self: flex-start; }
input[type=email], input[type=password], input[type=text] { width: 100%; padding: 11px 12px; border: 1px solid var(--line); border-radius: 8px; font: inherit; background: #fff; margin-top: 4px; }
input:focus { outline: 2px solid var(--accent); outline-offset: 1px; border-color: var(--accent); }

/* ===== Connexion ===== */
.auth-page { display: flex; align-items: center; justify-content: center; min-height: 100%; padding: 24px 16px; background: linear-gradient(160deg, rgba(35,52,59,.80) 0%, rgba(26,39,44,.90) 100%), url("tuile-implantation.jpg") center / cover no-repeat, var(--brand-dark); }
.auth { width: 100%; max-width: 440px; }
.card { background: var(--card); border-radius: 12px; padding: 30px 28px 26px; box-shadow: 0 18px 50px rgba(0,0,0,.28); border-top: 4px solid var(--accent); }
.auth-logo { display: flex; justify-content: center; margin: 0 auto 16px; }
.auth-logo .wm img { height: 46px; width: 46px; }
.auth-logo .wm b { font-size: 30px; }
.card h1 { margin: 0 0 6px; font-size: 22px; text-align: center; color: var(--brand); }
.card h2 { margin: 0 0 6px; font-size: 17px; color: var(--brand); }
.muted { color: var(--muted); }
.small { font-size: 12.5px; }
.card > .muted { text-align: center; margin: 0 0 18px; font-size: 14px; }
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin-bottom: 16px; }
.tab { flex: 1; background: none; border: 0; padding: 10px 6px; font: inherit; font-weight: 600; color: var(--muted); cursor: pointer; border-bottom: 3px solid transparent; margin-bottom: -1px; }
.tab.active { color: var(--brand); border-bottom-color: var(--accent); }
.form { display: flex; flex-direction: column; gap: 12px; }
.form label { font-size: 13px; font-weight: 600; color: var(--brand); display: block; }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
#profileFields { display: flex; flex-direction: column; gap: 12px; }
.msg { margin-top: 14px; padding: 10px 12px; border-radius: 6px; font-size: 13.5px; line-height: 1.4; }
.msg.err { background: #fdecec; color: #8a1c1a; border: 1px solid #f3b9b8; }
.msg.ok { background: #e8f5ec; color: #1b5e33; border: 1px solid #b6dfc4; }

/* ===== Portail : barre d'onglets ===== */
.shell-page { display: flex; flex-direction: column; height: 100%; overflow: hidden; }
.topbar { background: #fff; display: flex; align-items: stretch; gap: 14px; padding: 0 16px; padding-top: env(safe-area-inset-top); border-bottom: 3px solid var(--accent); flex: none; height: calc(56px + env(safe-area-inset-top)); }
.brand { display: flex; align-items: center; flex: none; text-decoration: none; }
.brand-logo { height: 34px; width: auto; display: block; }
.wm { display: inline-flex; align-items: center; gap: 10px; color: var(--brand); }
.wm img { height: 34px; width: 34px; display: block; }
.wm b { font-size: 22px; font-weight: 800; letter-spacing: -.01em; }
.tabs-bar { display: flex; align-items: stretch; gap: 4px; flex: 1; min-width: 0; overflow-x: auto; scrollbar-width: none; padding-left: 8px; border-left: 1px solid var(--line); margin-left: 4px; }
.tabs-bar::-webkit-scrollbar { display: none; }
.ptab { display: flex; align-items: center; gap: 8px; padding: 0 16px; color: var(--muted); text-decoration: none; font-weight: 600; font-size: 14.5px; white-space: nowrap; border-bottom: 3px solid transparent; margin-bottom: -3px; transition: color .15s, background .15s; }
.ptab svg { width: 19px; height: 19px; flex: none; }
.ptab:hover { color: var(--brand); background: #f3f6f7; }
.ptab.active { color: var(--brand); border-bottom-color: var(--brand); background: #eef2f3; }
.ptab.active svg { color: var(--accent); }
.topright { display: flex; align-items: center; gap: 8px; flex: none; }
.usr { position: relative; }
.usr-btn { display: flex; align-items: center; gap: 8px; background: none; border: 1px solid var(--line); border-radius: 22px; padding: 4px 12px 4px 4px; cursor: pointer; font: inherit; color: var(--brand); }
.usr-btn:hover { background: #f3f6f7; }
.av { position: relative; overflow: hidden; flex: none; width: 28px; height: 28px; border-radius: 50%; background: var(--brand); color: #fff; font-size: 12px; font-weight: 700; display: flex; align-items: center; justify-content: center; }
.av img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.av.has-img .av-i { visibility: hidden; }
.av-lg { width: 72px; height: 72px; font-size: 24px; }
.usr-n { font-size: 13.5px; font-weight: 600; max-width: 160px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.usr-menu { position: absolute; right: 0; top: calc(100% + 8px); min-width: 230px; background: #fff; border: 1px solid var(--line); border-radius: 8px; box-shadow: 0 10px 30px rgba(0,0,0,.16); z-index: 50; overflow: hidden; }
.usr-menu .who { padding: 12px 14px; border-bottom: 1px solid var(--line); display: flex; flex-direction: column; gap: 2px; }
.usr-menu .who span { font-size: 12.5px; color: var(--muted); word-break: break-all; }
.usr-menu a { display: block; padding: 11px 14px; color: var(--text); text-decoration: none; font-size: 14px; }
.usr-menu a:hover { background: #f3f6f7; color: var(--accent); }

/* ===== Portail : zone centrale ===== */
.stage { position: relative; flex: 1; min-height: 0; }
.home { position: absolute; inset: 0; display: none; flex-direction: column; padding: 28px 32px 32px; gap: 22px; overflow-y: auto; }
.home.active { display: flex; }
.home-head h1 { margin: 0 0 4px; font-size: clamp(24px, 3vw, 34px); color: var(--brand); }
.home-head p { margin: 0; color: var(--muted); font-size: 15.5px; }
.tiles { flex: 1; min-height: 0; display: grid; grid-template-columns: repeat(auto-fit, minmax(min(420px, 100%), 1fr)); grid-auto-rows: minmax(230px, 1fr); gap: 24px; }
.tile { position: relative; display: flex; align-items: flex-end; border-radius: 16px; overflow: hidden; text-decoration: none; color: #fff; background: var(--brand); box-shadow: 0 6px 22px rgba(35,52,59,.22); transition: transform .22s ease, box-shadow .22s ease; isolation: isolate; }
.tile:hover, .tile:focus-visible { transform: translateY(-4px); box-shadow: 0 16px 36px rgba(35,52,59,.34); outline: none; }
.tile:focus-visible { outline: 3px solid var(--accent); outline-offset: 3px; }
.tile-bg { position: absolute; inset: 0; z-index: -2; background-size: cover; background-position: center; transition: transform .5s ease; }
.tile:hover .tile-bg { transform: scale(1.04); }
.tile::after { content: ""; position: absolute; inset: 0; z-index: -1; background: linear-gradient(180deg, rgba(26,39,44,.05) 0%, rgba(26,39,44,.55) 52%, rgba(26,39,44,.93) 100%); }
.tile-cadastre .tile-bg { background-image: url("tuile-cadastre.svg"); }
.tile-implant .tile-bg { background-image: url("tuile-implantation.jpg"); }
.tile-visu3d .tile-bg { background-image: url("tuile-visu3d.svg"); }
.tile-documents .tile-bg { background-image: url("tuile-documents.svg"); }
.tile-financement .tile-bg { background-image: url("tuile-financement.svg"); }
.tile-crm .tile-bg { background-image: url("tuile-crm.svg"); }
.tile-equipe .tile-bg { background-image: url("tuile-equipe.svg"); }
.tile-body { display: flex; flex-direction: column; gap: 8px; padding: clamp(18px, 2.2vw, 28px); max-width: 560px; }
.tile-ico { width: 46px; height: 46px; border-radius: 12px; background: var(--accent); display: flex; align-items: center; justify-content: center; }
.tile-ico svg { width: 26px; height: 26px; color: #fff; }
.tile-title { font-size: clamp(22px, 2.4vw, 30px); font-weight: 800; line-height: 1.1; }
.tile-desc { font-size: clamp(14px, 1.1vw, 16px); line-height: 1.4; opacity: .92; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.appview { position: absolute; inset: 0; visibility: hidden; background: #fff; }
.appview.active { visibility: visible; z-index: 2; }
.appview iframe { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; background: #fff; }
.loading { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; gap: 12px; color: var(--muted); font-weight: 600; background: var(--bg); z-index: 1; }
.loading.done { display: none; }
.spin { width: 20px; height: 20px; border: 3px solid var(--line); border-top-color: var(--accent); border-radius: 50%; animation: sp .8s linear infinite; }
@keyframes sp { to { transform: rotate(360deg); } }

@media (max-width: 720px) {
  .topbar { gap: 8px; padding: 0 8px; }
  .wm b { display: none; }
  .ptab { padding: 0 11px; font-size: 13.5px; }
  .ptab svg { display: none; }
  .usr-n { display: none; }
  .usr-btn { padding: 4px; }
  .home { padding: 18px 14px 22px; }
  .tiles { grid-auto-rows: minmax(240px, auto); }
}
@media (prefers-reduced-motion: reduce) { .tile, .tile-bg { transition: none; } }
/* ===== Fenêtre Mon compte ===== */
.modal { position: fixed; inset: calc(59px + env(safe-area-inset-top)) 0 0 0; z-index: 40; background: rgba(26,39,44,.55); display: flex; align-items: center; justify-content: center; padding: 16px; overflow-y: auto; }
.modal-box { position: relative; background: #fff; border-radius: 12px; border-top: 4px solid var(--accent); width: 100%; max-width: 480px; max-height: 100%; overflow-y: auto; padding: 24px 24px 20px; box-shadow: 0 18px 50px rgba(0,0,0,.3); }
.modal-box h2 { margin: 0 0 14px; color: var(--brand); font-size: 20px; }
.modal-box h3 { margin: 0; color: var(--brand); font-size: 15px; }
.modal-box hr { border: 0; border-top: 1px solid var(--line); margin: 18px 0; }
.modal-x { position: absolute; top: 8px; right: 12px; background: none; border: 0; font-size: 26px; line-height: 1; color: var(--muted); cursor: pointer; }
.btn-light { display: inline-block; background: #eef2f3; color: var(--brand); }
.acc-photo { display: flex; align-items: center; gap: 16px; }
.chk { display: block; margin-top: 8px; font-size: 13px; font-weight: 400 !important; }
