/* Espace privé — design system repris de Finance Heiwa (Manrope + Inter, icônes au trait, jamais d'émoji).
   CSS héritée de l'app Finance retirée (vague de corrections IF5) : tests/css-dead.test.js interdit toute classe inconnue. */

/* ===== Polices auto-hébergées (aucune requête tierce, disponibles hors ligne) =====
   Inter et Manrope variables, sous-ensemble latin (français, « », ’, −, €), @fontsource-variable 5.3.0,
   licence SIL OFL 1.1 : fonts/LICENSE-Inter.txt, fonts/LICENSE-Manrope.txt. */
@font-face {
  font-family: "Inter"; font-style: normal; font-display: swap; font-weight: 100 900;
  src: url("/fonts/inter-latin-wght-normal.woff2") format("woff2-variations"), url("/fonts/inter-latin-wght-normal.woff2") format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F,
    U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: "Manrope"; font-style: normal; font-display: swap; font-weight: 200 800;
  src: url("/fonts/manrope-latin-wght-normal.woff2") format("woff2-variations"), url("/fonts/manrope-latin-wght-normal.woff2") format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F,
    U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

/* ===== Tokens (source: swiss-piscine-app/frontend/css/app.css :root) ===== */
:root {
  --navy: #0c2b38;
  --ink: #14313c;
  --muted: #6a7d85;
  --line: #e4eaec;
  --line-soft: #eef2f3;
  --aqua: #127d89;
  --aqua-dark: #0c5e68;
  --aqua-soft: #e8f2f3;
  --bg: #f5f7f8;
  --white: #ffffff;
  --ok: #2f8f63;
  --ok-soft: #e3f3ea;
  --danger: #c0463a;
  --danger-soft: #f7e3e1;
  --violet: #5957c9;
  --violet-soft: #ececfa;
  --coral: #e0735a;
  --coral-soft: #fceae5;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(12,43,56,.04), 0 8px 24px rgba(12,43,56,.05);
  --sidebar-w: 236px;
  --header-h: 60px;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --font-display: "Manrope", system-ui, sans-serif;
  --font-body: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  /* Couleur d'accent de la société active — surchargée en JS par les tâches
     suivantes (ex: applyTheme() pose --co-accent selon la société sélectionnée). */
  --co-accent: var(--aqua-dark);
  /* Palette des graphiques — validée (bandes de clarté, chroma, séparation CVD,
     contraste sur fond blanc) ; ne pas remplacer par des teintes « au feeling ». */
  font-family: var(--font-body);
}

/* ===== Base ===== */
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; }
body { background: var(--bg); color: var(--ink); font-family: var(--font-body); -webkit-font-smoothing: antialiased; }
#app { min-height: 100%; }
a { color: var(--aqua-dark); text-decoration: none; }
h1, h2, h3, strong{ font-family: var(--font-display); font-weight: 700; letter-spacing: -.022em; color: var(--navy); }
h1 { font-size: 1.5rem; }
h2 { font-size: 1rem; }
.eyebrow { font-size: .68rem; font-weight: 600; letter-spacing: .14em; text-transform: uppercase; color: var(--muted); }
.muted { color: var(--muted); }
.num { font-variant-numeric: tabular-nums; }

.loading { padding: 40px; text-align: center; color: var(--muted); font-size: .9rem; }

/* --- Icônes au trait (jamais d'émoji) --- */
svg { stroke-width: 2; stroke: currentColor; fill: none; stroke-linecap: round; stroke-linejoin: round; }
.icon { width: 20px; height: 20px; stroke: currentColor; stroke-width: 1.6; fill: none; stroke-linecap: round; stroke-linejoin: round; flex: 0 0 auto; vertical-align: middle; }
.icon-sm { width: 16px; height: 16px; }
.icon-lg { width: 26px; height: 26px; }

/* ===== Sidebar / nav (source: mockups/finance-redesign.html, motif tabbar→sidebar de l'app RH) ===== */
.sidebar {
  position: fixed; top: 0; left: 0; bottom: 0; width: var(--sidebar-w);
  background: var(--white); border-right: 1px solid var(--line);
  display: flex; flex-direction: column; padding: 16px 12px; gap: 4px; z-index: 20;
}
.brand { display: flex; align-items: center; gap: 10px; padding: 6px 8px 16px; }
.brand-mark {
  width: 34px; height: 34px; border-radius: 9px; flex: 0 0 auto;
  background: linear-gradient(150deg, var(--navy), var(--aqua-dark));
  display: flex; align-items: center; justify-content: center; color: var(--on-accent);
}
.brand b { font-family: var(--font-display); font-weight: 800; font-size: 1.02rem; color: var(--navy); line-height: 1.05; letter-spacing: -.02em; }
.brand span { display: block; font-size: .72rem; color: var(--muted); font-weight: 500; }

.nav-item {
  display: flex; align-items: center; gap: 11px; padding: 10px 12px; border-radius: 10px; border: 0; background: none;
  width: 100%; text-align: left; color: var(--ink); font-family: var(--font-body); font-size: .92rem; font-weight: 500;
  cursor: pointer; position: relative;
}
.nav-item .icon { width: 20px; height: 20px; color: var(--muted); flex: 0 0 auto; }
.nav-item:hover { background: var(--line-soft); }
.nav-item.active { background: var(--aqua-soft); color: var(--co-accent, var(--aqua-dark)); font-weight: 600; }
.nav-item.active .icon { color: var(--co-accent, var(--aqua-dark)); }
.nav-item.active::before {
  content: ""; position: absolute; left: -12px; top: 9px; bottom: 9px; width: 3px;
  border-radius: 0 3px 3px 0; background: var(--co-accent, var(--aqua-dark));
}
.nav-sep { flex: 1; }

/* Groupe de navigation et utilisateur connecté (barre latérale) */
.nav-group { display: flex; flex-direction: column; gap: 4px; }

.who { display: flex; align-items: center; gap: 9px; padding: 10px 8px 2px; margin-top: 6px; }
.avatar { width: 30px; height: 30px; border-radius: 50%; background: var(--aqua-dark); color: var(--on-accent); display: flex; align-items: center; justify-content: center; font-weight: 600; font-size: .78rem; flex: 0 0 auto; }
.who small { color: var(--muted); font-size: .74rem; display: block; }
.who b { font-size: .82rem; font-weight: 600; color: var(--ink); }

/* ===== Main / page head ===== */
.main { margin-left: var(--sidebar-w); padding: 30px 40px 60px; max-width: 1080px; }
.page-head { display: flex; align-items: flex-start; justify-content: space-between; margin-bottom: 22px; flex-wrap: wrap; gap: 12px; }
.page-head h1 { font-size: 1.5rem; }
.page-head .sub, .sub { color: var(--muted); font-size: .9rem; }

/* ===== Onglets internes (sous-écrans) ===== */
.subtabs { display: flex; gap: 2px; border-bottom: 1px solid var(--line); margin-bottom: 18px; flex-wrap: wrap; }
.subtab {
  background: none; border: none; padding: 9px 14px; font-size: .86rem; font-weight: 600;
  color: var(--muted); cursor: pointer; border-bottom: 2px solid transparent; margin-bottom: -1px; font-family: var(--font-body);
}
.subtab:hover { color: var(--ink); }
.subtab.active { color: var(--co-accent, var(--aqua-dark)); border-bottom-color: var(--co-accent, var(--aqua-dark)); }

/* Actions d'en-tête de page */
.head-actions { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }

/* ===== Graphiques ===== */
.chart-box { background: transparent; border: 0; padding: 6px 2px 2px; }
/* Le reset SVG global (stroke: currentColor, 2px) donnerait un contour sombre à
   chaque barre : dans un graphique, chaque marque déclare son propre trait. */
.chart-box svg { stroke: none; fill: none; }

/* ===== Recherche dans une liste ===== */
.search-box { display: flex; align-items: center; gap: 8px; padding: 0 12px; min-width: 280px;
  flex: 1 1 280px; border: 1px solid var(--line); border-radius: 11px; background: var(--field-bg);
  color: var(--muted); }
.search-box input { flex: 1; min-width: 0; border: 0; outline: none; background: none;
  padding: 10px 0; font-family: var(--font-body); font-size: .88rem; color: var(--ink); }
.search-box input::-webkit-search-cancel-button { -webkit-appearance: none; }

/* ===== Fenêtre modale ===== */
.modal-overlay { position: fixed; inset: 0; z-index: 60; display: flex; align-items: center;
  justify-content: center; padding: 20px; background: rgba(12,43,56,0);
  transition: background .18s; overflow-y: auto; }
.modal-overlay.open { background: rgba(12,43,56,.42); }
.modal { width: min(560px, 100%); max-height: 92vh; overflow-y: auto; background: var(--bg);
  border-radius: 18px; box-shadow: 0 18px 60px rgba(12,43,56,.28);
  transform: translateY(10px) scale(.99); opacity: 0; transition: transform .18s, opacity .18s; }
.modal.large { width: min(980px, 100%); }
.modal-overlay.open .modal { transform: none; opacity: 1; }
.modal-head { position: sticky; top: 0; z-index: 1; display: flex; align-items: center;
  justify-content: space-between; gap: 12px; padding: 16px 18px 12px; background: var(--bg);
  border-bottom: 1px solid var(--line); }
.modal-head h3 { font-size: 1.05rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.modal-close { width: 32px; height: 32px; flex: 0 0 auto; border: 1px solid var(--line);
  border-radius: 9px; background: var(--white); color: var(--muted); cursor: pointer;
  display: flex; align-items: center; justify-content: center; }
.modal-close:hover { background: var(--line-soft); color: var(--ink); }
.modal-body { padding: 16px 18px 20px; overflow-wrap: anywhere; }   /* texte saisi sans espace (120 x) : jamais coupé par le bord */
.modal-body .panel { margin-top: 0; }

/* ===== Formulaire en grille ===== */
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0 14px; }
.form-grid .span2 { grid-column: 1 / -1; }
.form-grid .field input[type="file"] { padding: 9px 12px; font-size: .86rem; background: var(--white); }
.field-hint { font-size: .76rem; color: var(--muted); margin: -8px 0 12px; }
@media (max-width: 620px) { .form-grid { grid-template-columns: 1fr; } }

/* ===== Interrupteur (case à cocher en bascule) ===== */
.switch { display: inline-flex; align-items: center; gap: 9px; margin: 4px 0 16px;
  font-size: .86rem; color: var(--ink); cursor: pointer; }
.switch input { width: 38px; height: 22px; appearance: none; -webkit-appearance: none;
  background: var(--line); border-radius: 999px; position: relative; cursor: pointer;
  transition: background .16s; flex: 0 0 auto; margin: 0; }
.switch input::after { content: ""; position: absolute; top: 3px; left: 3px; width: 16px; height: 16px;
  border-radius: 50%; background: var(--white); transition: transform .16s; }
.switch input:checked { background: var(--co-accent, var(--aqua-dark)); }
.switch input:checked::after { transform: translateX(16px); }
.switch input:focus-visible { outline: 2px solid var(--aqua); outline-offset: 2px; }

/* ===== Panneaux et tableaux ===== */

.panel { background: var(--white); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 18px 20px; margin-top: 4px; }
.panel + .panel { margin-top: 14px; }
.panel .ptitle { font-family: var(--font-display); font-weight: 700; color: var(--navy); margin-bottom: 10px; font-size: 1rem; }
.panel-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; }
.panel-head .ptitle { margin-bottom: 10px; }

table { width: 100%; border-collapse: collapse; font-size: .9rem; }
td, th { padding: 8px 0; border-top: 1px solid var(--line-soft); text-align: left; }
/* Respiration entre colonnes : sans elle « 4009 » et « Frais de nettoyage »
   se touchent dès que la colonne précédente est alignée à droite. */
td + td, th + th { padding-left: 14px; }
tr:first-child td, tr:first-child th { border-top: 0; }
td.num, th.num { text-align: right; }
td.num, th.num, .num { font-variant-numeric: tabular-nums; color: var(--ink); }

.neg { color: var(--danger); }

/* ===== Pastilles / puces (badges de statut, chips) ===== */

.chip { display: inline-block; border-radius: 6px; padding: 2px 8px; font-size: .78rem; font-weight: 600; cursor: pointer; margin: 2px 2px 2px 0; }

/* ===== Boutons (source: app RH) ===== */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 44px; border: 0; border-radius: 11px; cursor: pointer;
  font-family: var(--font-body); font-size: .96rem; font-weight: 600; padding: 0 18px;
  background: var(--navy); color: var(--white); letter-spacing: .01em;
  transition: background .15s, transform .12s, box-shadow .15s;
}
.btn:hover { background: var(--aqua-dark); }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .5; cursor: default; }
.btn.secondary { background: var(--white); color: var(--navy); border: 1px solid var(--line); }
.btn.secondary:hover { background: var(--line-soft); }
.btn.secondary.active { background: var(--aqua-soft); color: var(--aqua-dark); border-color: var(--aqua); }

/* ===== Champs (source: app RH) ===== */
.field { margin-bottom: 14px; }
.field label, .field .field-label { display: block; font-size: .82rem; font-weight: 600; margin-bottom: 6px; color: var(--ink); }
.field input, .field select, .field textarea{
  width: 100%; min-height: 44px; border: 1px solid var(--line); border-radius: 11px; padding: 0 13px;
  font-size: 1rem; background: var(--field-bg); font-family: var(--font-body); color: var(--ink);
}
.field input:focus, .field select:focus, .field textarea:focus{ outline: 2px solid var(--aqua); border-color: var(--aqua); }
.form-error, .err{ color: var(--danger); font-size: .88rem; margin: 0 0 12px; min-height: 1.1em; }

/* ===== Responsive ===== */
/* ≥900px : layout desktop par défaut (sidebar fixe à gauche, cf. règles ci-dessus). */
/* <820px : la sidebar se replie ; on garde le contenu simple (pleine largeur) pour
   cette tâche — la barre de navigation basse dédiée mobile sera affinée par les
   tâches d'écrans suivantes (4-7). */
@media (max-width: 820px) {
  .sidebar { transform: translateX(-100%); transition: transform .2s ease; }
  .sidebar.open { transform: translateX(0); box-shadow: 0 0 0 2000px rgba(12,43,56,.35); }
  .main { margin-left: 0; padding: 20px 16px 40px; }
  
  #dash-content { grid-template-columns: 1fr; }
   
  
  body { padding-top: env(safe-area-inset-top); }
}

