/* ==========================================================================
   SI Mobile — habillage du site (charte TPWeb)
   Actif uniquement avec html.site (interface servie par le site).
   ========================================================================== */

html.site {
  --bg: #fff; --surface: #fff; --surface-2: #f6f6f6; --border: #ddd; --border-strong: #929292;
  --text: #161616; --text-2: #3a3a3a; --muted: #666;
  --accent: #000091; --accent-hover: #1212ff; --accent-soft: #e3e3fd; --accent-softer: #f5f5fe;
  --danger: #ce0500; --danger-soft: #ffe9e9; --warn: #b34000; --warn-soft: #ffe9e6; --ok: #18753c; --ok-soft: #b8fec9;
  --input: #eee; --radius: 0; --shadow: none; --tab-h: 0px;
  --w-container: 1240px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  html.site:not([data-theme="light"]) {
    --bg: #161616; --surface: #1e1e1e; --surface-2: #262626; --border: #383838; --border-strong: #6a6a6a;
    --text: #e3e3e3; --text-2: #c2c2c2; --muted: #9a9a9a;
    --accent: #8585f6; --accent-hover: #a5a5f8; --accent-soft: #26264a; --accent-softer: #1c1c36;
    --danger: #ff7a78; --danger-soft: #3a1b1b; --warn: #ffa066; --warn-soft: #33231a; --ok: #4cd889; --ok-soft: #173b24;
    --input: #2b2b2b; color-scheme: dark;
  }
}
html.site[data-theme="dark"] {
  --bg: #161616; --surface: #1e1e1e; --surface-2: #262626; --border: #383838; --border-strong: #6a6a6a;
  --text: #e3e3e3; --text-2: #c2c2c2; --muted: #9a9a9a;
  --accent: #8585f6; --accent-hover: #a5a5f8; --accent-soft: #26264a; --accent-softer: #1c1c36;
  --danger: #ff7a78; --danger-soft: #3a1b1b; --warn: #ffa066; --warn-soft: #33231a; --ok: #4cd889; --ok-soft: #173b24;
  --input: #2b2b2b; color-scheme: dark;
}

html.site body { font-size: 16px; line-height: 1.5; background: var(--bg); }
.site .app { min-height: 100vh; display: flex; flex-direction: column; }
.site .w-container { width: 100%; max-width: var(--w-container); margin: 0 auto; padding: 0 1.5rem; }
.site .tabbar { display: none; }

/* ---------- En-tête ---------- */
.site .w-header { background: var(--surface); border-top: 4px solid var(--accent); box-shadow: 0 1px 0 var(--border), 0 4px 12px -6px rgba(0, 0, 18, .12); position: relative; z-index: 10; }
.site .w-header__inner { display: flex; align-items: center; justify-content: space-between; gap: 1.5rem; min-height: 5.5rem; padding-top: .75rem; padding-bottom: .75rem; }
.site .w-brand { display: flex; align-items: center; gap: 1rem; text-decoration: none; color: var(--text); min-width: 0; }
.site .w-brand:hover .w-brand__name { text-decoration: underline; text-underline-offset: 4px; }
.site .w-brand__mark { width: 3.25rem; height: 3.25rem; object-fit: contain; background: #fff; padding: .2rem; border: 1px solid var(--border); flex: none; }
.site .w-brand__text { display: flex; flex-direction: column; min-width: 0; }
.site .w-brand__name { font-size: 1.25rem; font-weight: 700; line-height: 1.2; }
.site .w-brand__tagline { font-size: .875rem; color: var(--text-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.site .w-tools { display: flex; gap: .25rem; flex: none; }
.site .w-link { display: inline-flex; align-items: center; gap: .5rem; padding: .5rem .75rem; font: inherit; font-size: .875rem; font-weight: 500; color: var(--accent); text-decoration: none; background: none; border: 0; cursor: pointer; }
.site .w-link .ic { width: 1rem; height: 1rem; }
.site .w-link:hover { background: var(--surface-2); }

/* ---------- Mise en page : menu latéral + contenu ---------- */
.site .w-admin { flex: 1; display: grid; grid-template-columns: 250px minmax(0, 1fr); gap: 2.5rem; padding-top: 2rem; padding-bottom: 4rem; align-items: start; }
.site .sidemenu { position: sticky; top: 1.5rem; border-right: 1px solid var(--border); padding-right: 1rem; }
.site .sidemenu ul { list-style: none; margin: 0; padding: 0; }
.site .sidemenu hr { border: 0; border-top: 1px solid var(--border); margin: 1rem 0; }
.site .sidemenu__title { font-size: .75rem; font-weight: 700; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); margin: 1.25rem 0 .5rem; }
.site .sidemenu__link { display: flex; align-items: center; gap: .75rem; width: 100%; padding: .7rem .75rem; font: inherit; font-size: .9375rem; text-align: left; color: var(--text); text-decoration: none; background: none; border: 0; border-left: 2px solid transparent; cursor: pointer; }
.site .sidemenu__link .ic { width: 1.1rem; height: 1.1rem; color: var(--text-2); }
.site .sidemenu__link:hover { background: var(--surface-2); }
.site .sidemenu__link.is-active { color: var(--accent); font-weight: 700; border-left-color: var(--accent); background: var(--accent-softer); }
.site .sidemenu__link.is-active .ic { color: var(--accent); }
.site .sidemenu__user { display: flex; align-items: center; gap: .75rem; padding: 0 .25rem 1rem; margin-bottom: .5rem; border-bottom: 1px solid var(--border); }
.site .sidemenu__user > span:last-child { display: flex; flex-direction: column; line-height: 1.3; min-width: 0; }
.site .sidemenu__user strong { font-size: .9375rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.site .sidemenu__user small { font-size: .75rem; color: var(--muted); }
.site .sidemenu__avatar { width: 2.25rem; height: 2.25rem; flex: none; display: grid; place-items: center; background: var(--accent); color: #fff; font-weight: 700; }
html.site[data-theme="dark"] .sidemenu__avatar { color: #0d0d2b; }

.site .w-content { min-width: 0; }
.site main#view { padding: 0; max-width: none; margin: 0; }

/* En-tête de page (titre + actions) à la place de la barre de l'appli */
.site .top { position: static; padding: 0 0 1.5rem; margin-bottom: 1.5rem; background: none; border: 0; border-bottom: 1px solid var(--border); box-shadow: none; backdrop-filter: none; -webkit-backdrop-filter: none; align-items: flex-end; gap: 1rem; flex-wrap: wrap; }
.site .top::before { display: none; }
.site .top h1 { font-size: 2rem; font-weight: 700; line-height: 1.25; white-space: normal; }
.site .top .sub { display: none; }
.site .top-actions { gap: .5rem; align-items: center; flex-wrap: wrap; }
.site .top .icon-btn { width: 2.5rem; height: 2.5rem; color: var(--accent); box-shadow: inset 0 0 0 1px var(--border); }
.site .top .icon-btn:hover { background: var(--accent-softer); }
.site #back { align-self: center; }
.site .w-add { min-height: 2.5rem; padding: .5rem 1.25rem; }

/* ---------- Composants ---------- */
.site .btn { min-height: 2.5rem; height: auto; padding: .5rem 1.5rem; font-size: 1rem; font-weight: 500; border-radius: 0; }
.site .btn.primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); }
.site .btn:not(.primary):hover { background: var(--accent-softer); }
.site .btns .btn { flex: 0 1 auto; }
.site .card { border-radius: 0; border: 1px solid var(--border); box-shadow: none; }
.site .section { margin: 2rem 0 1rem; }
.site .section h2 { font-size: 1.375rem; text-transform: none; letter-spacing: 0; color: var(--text); font-weight: 700; }
.site .section a { font-size: .9375rem; }

/* Listes façon « liste de documents » */
.site .list { border: 1px solid var(--border); border-radius: 0; background: var(--surface); }
.site .row { padding: .9rem 1rem; min-height: 64px; gap: 1rem; }
.site .row:hover { background: var(--surface-2); }
.site .row .lead { width: 2.75rem; height: 2.75rem; border-radius: 0; background: var(--accent-softer); color: var(--accent); }
.site .row .t { color: var(--accent); font-weight: 700; }
.site .row:hover .t { text-decoration: underline; text-underline-offset: 3px; }
.site .row .s { font-size: .8125rem; }

/* Chiffres clés (figures TPWeb) */
.site .stats { grid-template-columns: repeat(4, 1fr); gap: 0; border: 1px solid var(--border); }
.site .stats .stat { border: 0; border-right: 1px solid var(--border); border-bottom: 0; padding: 1rem 1.25rem; }
.site .stats .stat:last-child { border-right: 0; }
.site .stat .n { color: var(--accent); font-size: 2rem; }
.site .stat.alert .n { color: var(--danger); }
.site .kpis { grid-template-columns: repeat(6, 1fr); }
.site .quick { grid-template-columns: repeat(4, minmax(0, 200px)); }
.site .quick button { border-radius: 0; padding: 1rem .5rem; font-size: .9375rem; }
.site .notes { grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); }
.site .note { border-radius: 0; }
.site .note .t { color: var(--accent); }

/* Formulaires */
.site .f input, .site .f select, .site .f textarea { border-radius: 4px 4px 0 0; background: var(--input); box-shadow: inset 0 -2px 0 var(--text-2); border: 0; }
.site .search { background: var(--input); max-width: 520px; }
.site .seg { max-width: 640px; }
.site .grid2 { gap: 1.5rem; }
.site form { gap: 1.25rem; }

/* Panneaux : fenêtres centrées sur grand écran */
.site .sheet-backdrop { align-items: center; padding: 2rem 1rem; background: rgba(22, 22, 22, .55); }
.site .sheet { max-width: 760px; max-height: 92vh; border-radius: 0; box-shadow: inset 0 4px 0 var(--accent), 0 20px 50px rgba(0, 0, 0, .25); background: var(--surface); }
.site .sheet.full { height: auto; }
.site .sheet-h { padding: 1.25rem 1.25rem 1rem 1.75rem; border-bottom: 1px solid var(--border); }
.site .sheet-h h3 { font-size: 1.375rem; }
.site .sheet-b { padding: 1.5rem 1.75rem 2rem; }

/* Barre de sélection, bulle d'information */
.site .selbar { bottom: 0; left: auto; right: 1.5rem; bottom: 1.5rem; width: min(560px, calc(100% - 3rem)); border: 1px solid var(--border); border-top: 4px solid var(--accent); }
.site #toast { left: auto; right: 1.5rem; bottom: 1.5rem; transform: translateY(20px); background: var(--surface); color: var(--text); border: 1px solid var(--accent); border-left: 4px solid var(--accent); font-weight: 500; }
.site #toast.show { transform: none; }

/* Connexion : carte centrée, sans menu */
.site body.auth .sidemenu { display: none; }
.site body.auth .w-admin { grid-template-columns: minmax(0, 1fr); max-width: 880px; }
.site body.auth .auth-wrap { max-width: 560px; margin: 0 auto; width: 100%; }
.site body.auth .top { border-bottom: 0; margin-bottom: 0; }
.site .auth-wrap { max-width: none; margin: 0; }
.site .auth-wrap form.card { padding: 2.5rem; box-shadow: inset 0 4px 0 var(--accent); }
.site .auth-logo { display: none; }
.site .auth-wrap > p.muted { display: none; }

/* ---------- Pied de page ---------- */
.site .w-footer { border-top: 2px solid var(--accent); background: var(--surface); margin-top: auto; }
.site .w-footer__inner { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: 1rem 2rem; padding-top: 1.75rem; padding-bottom: 1.75rem; }
.site .w-footer__brand { display: flex; flex-direction: column; gap: .15rem; }
.site .w-footer__brand strong { font-size: 1.125rem; }
.site .w-footer__brand span { font-size: .875rem; color: var(--text-2); }
.site .w-footer__links { list-style: none; margin: 0; padding: 0; display: flex; gap: 1.5rem; flex-wrap: wrap; }
.site .w-footer__links a { font-size: .875rem; color: var(--text-2); }
.site .w-footer__bottom { border-top: 1px solid var(--border); padding: .75rem 0; font-size: .75rem; color: var(--muted); }

/* ---------- Écrans plus petits ---------- */
@media (max-width: 1100px) {
  .site .kpis { grid-template-columns: repeat(3, 1fr); }
}
@media (max-width: 860px) {
  .site .w-admin { grid-template-columns: minmax(0, 1fr); gap: 1.5rem; padding-top: 1.25rem; }
  .site .sidemenu { position: static; border-right: 0; border-bottom: 1px solid var(--border); padding: 0 0 1rem; }
  .site .sidemenu ul { display: flex; flex-wrap: wrap; gap: .25rem; }
  .site .sidemenu hr, .site .sidemenu__title, .site .sidemenu__user { display: none; }
  .site .sidemenu__link { width: auto; border-left: 0; border-bottom: 2px solid transparent; padding: .5rem .75rem; }
  .site .sidemenu__link.is-active { border-bottom-color: var(--accent); }
  .site .stats { grid-template-columns: repeat(2, 1fr); }
  .site .stats .stat:nth-child(2n) { border-right: 0; }
  .site .stats .stat:nth-child(-n+2) { border-bottom: 1px solid var(--border); }
}
@media (max-width: 640px) {
  .site .w-container { padding: 0 1rem; }
  .site .w-header__inner { min-height: 4.5rem; }
  .site .w-brand__mark { width: 2.6rem; height: 2.6rem; }
  .site .w-brand__tagline { font-size: .75rem; }
  .site .w-link span { display: none; }
  .site .w-link .ic { width: 1.25rem; height: 1.25rem; }
  .site .top h1 { font-size: 1.625rem; }
  .site .w-add span { display: none; }
  .site .w-add { padding: .5rem .75rem; }
  .site .quick { grid-template-columns: repeat(2, 1fr); }
  .site .kpis { grid-template-columns: repeat(2, 1fr); }
  .site .sheet-backdrop { padding: 0; align-items: flex-end; }
  .site .auth-wrap form.card { padding: 1.25rem; }
}
@media print {
  .site .w-header, .site .w-footer, .site .sidemenu, .site .top-actions { display: none !important; }
  .site .w-admin { display: block; }
}

/* Le menu latéral remplace le bouton retour ; pas d'accès rapides avant connexion */
.site #back { display: none !important; }
.site body.auth .w-tools { display: none; }

/* 1.6 — accueil public du site (portails) */
.portal-home { display: grid; gap: 1.25rem; margin-bottom: 1.25rem; }
.portal-org { background: var(--surface); border: 1px solid var(--border); box-shadow: inset 0 4px 0 var(--accent); padding: 1.5rem; }
.po-head { display: flex; gap: 1rem; align-items: center; margin-bottom: 1.1rem; }
.po-head img { width: 56px; height: 56px; object-fit: contain; background: #fff; }
.po-name { font-size: 1.25rem; font-weight: 700; }
.po-tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: .9rem; }
.po-tile { display: grid; gap: .35rem; padding: 1.1rem 1.2rem; border: 1px solid var(--border); text-decoration: none; color: inherit; background: var(--surface-2); transition: border-color .15s, transform .15s; }
.po-tile:hover { border-color: var(--accent); transform: translateY(-1px); }
.po-tile svg { width: 28px; height: 28px; color: var(--accent); }
.po-tile strong { font-size: 1.05rem; }
.po-tile span { font-size: .9rem; opacity: .75; }
.po-login { display: flex; justify-content: center; }
.site .auth-wrap.compact form.card { padding: 1.5rem; }
