@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700;800&display=swap');

/* =========================================================================================
   DESIGN TOKENS — portage du « HDF Temps Redesign » déjà en place sur Android
   (GestionTemps/.../ui/theme/DesignSystem.kt). Les valeurs sont celles d'Android, à deux
   exceptions près, imposées par le contraste WCAG AA et documentées plus bas.
   Toute couleur, tout rayon, toute taille de police vit ICI et nulle part ailleurs.
   ========================================================================================= */

:root {
  /* --- Couleurs de marque (identiques à RdNavy / RdCyan) --- */
  --navy: #0A2540;
  --navy-rgb: 10, 37, 64;
  --cyan: #00B2F0;
  --cyan-rgb: 0, 178, 240;

  /* Cyan de TEXTE, assombri à teinte constante (cyan x 0.68).
     Le cyan vif sur blanc ne donne que 2,43:1 : illisible au sens de WCAG AA. Celui-ci
     donne 4,93:1 sur blanc et 4,56:1 sur le fond de page. Le cyan vif reste réservé aux
     aplats, jauges, bordures et au fond du bouton primaire (navy dessus : 6,38:1). */
  --cyan-text: #0079A3;

  --success: #22C55E;
  --error: #DC2626;
  --warning: #F59E0B;

  /* --- Surfaces --- */
  --bg: #F4F6FB;
  --surface: #FFFFFF;
  --chip-bg: #EDF0F6;
  --chip-active-bg: rgba(var(--cyan-rgb), 0.14);

  /* --- Bordures et texte secondaire, dérivés du navy (un seul point de vérité) --- */
  --border: rgba(var(--navy-rgb), 0.08);
  --border-strong: rgba(var(--navy-rgb), 0.15);
  --overlay: rgba(var(--navy-rgb), 0.45);
  --hover-tint: rgba(var(--navy-rgb), 0.06);

  /* Texte secondaire à 0,65 d'opacité, et non 0,45 comme dans la maquette : 0,45 tombe à
     2,72:1 sur le fond de page, 0,65 remonte à 4,85:1 et passe AA. */
  --muted: rgba(var(--navy-rgb), 0.65);
  /* Réservé au texte purement décoratif, jamais porteur d'information seule. */
  --muted-soft: rgba(var(--navy-rgb), 0.5);

  /* --- Typographie --- */
  --fs-xs: 12px;
  --fs-sm: 13px;
  --fs-md: 14px;
  --fs-lg: 15px;
  --fs-xl: 17px;
  --fs-2xl: 22px;
  --fs-timer: 34px;

  /* --- Rayons (RadiusButton / RadiusRow / RadiusCard / RadiusTimer d'Android) --- */
  --r-btn: 12px;
  --r-row: 18px;
  --r-card: 20px;
  --r-timer: 24px;
  --r-pill: 999px;
  /* Conservé : plusieurs règles historiques nomment encore --radius. */
  --radius: var(--r-card);

  /* --- Espacements, échelle de 4 --- */
  --sp-1: 4px;
  --sp-2: 8px;
  --sp-3: 12px;
  --sp-4: 16px;
  --sp-5: 20px;
  --sp-6: 24px;

  /* --- Ombres (les deux couches du handoff, qu'Android approxime en une seule) --- */
  --shadow-card: 0 1px 2px rgba(var(--navy-rgb), 0.05), 0 1px 12px rgba(var(--navy-rgb), 0.04);
  --shadow-float: 0 4px 14px rgba(var(--navy-rgb), 0.18);
  --shadow-drawer: 2px 0 20px rgba(var(--navy-rgb), 0.18);

  /* --- Gabarit --- */
  --content-max: 760px;
  --sidebar-w: 232px;

  --apple-logo: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 384 512'%3E%3Cpath d='M318.7 268.7c-.2-36.7 16.4-64.4 50-84.8-18.8-26.9-47.2-41.7-84.7-44.6-35.5-2.8-74.3 20.7-88.5 20.7-15 0-49.4-19.7-76.4-19.7C63.3 141.2 4 184.8 4 273.5q0 39.3 14.4 81.2c12.8 36.7 59 126.7 107.2 125.2 25.2-.6 43-17.9 75.8-17.9 31.8 0 48.3 17.9 76.4 17.9 48.6-.7 90.4-82.5 102.6-119.3-65.2-30.7-61.7-90-61.7-91.9zm-56.6-164.2c27.3-32.4 24.8-61.9 24-72.5-24.1 1.4-52 16.4-67.9 34.9-17.5 19.8-27.8 44.3-25.6 71.9 26.1 2 49.9-11.4 69.5-34.3z'/%3E%3C/svg%3E");
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--navy);
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  -webkit-font-smoothing: antialiased;
}

#app {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.loading-screen {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 100vh;
  color: var(--navy);
  font-weight: 600;
}

/* --- Top bar ---
   Fond blanc, surtitre cyan et titre d'écran en gros, comme la maquette « Refonte ». Le
   navy plein est passé au menu latéral, qui devient le seul aplat sombre de l'interface. */
.topbar {
  background: var(--surface);
  color: var(--navy);
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  padding: 14px var(--sp-5) var(--sp-3);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 10;
}
.topbar-titles {
  flex: 1;
  min-width: 0;
}
.topbar-eyebrow {
  font-size: var(--fs-xs);
  font-weight: 700;
  color: var(--cyan-text);
  letter-spacing: 0.04em;
  text-transform: uppercase;
  /* Sans cela, « GESTION TEMPS » se coupait en deux lignes dès que la puce du chrono
     serrait le titre, et venait chevaucher le nom de l'écran. */
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.topbar h1 {
  font-size: 19px;
  font-weight: 800;
  color: var(--navy);
  margin: 1px 0 0;
  letter-spacing: -0.3px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.topbar-subtitle {
  font-size: var(--fs-xs);
  color: var(--muted);
  margin-top: 1px;
}
.topbar-timer {
  display: flex;
  align-items: center;
  gap: 7px;
  background: var(--chip-active-bg);
  padding: 7px 11px;
  border-radius: var(--r-btn);
  font-size: var(--fs-sm);
  font-weight: 600;
  color: var(--navy);
  cursor: pointer;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 260px;
  flex-shrink: 1;
  min-width: 0;
}
.topbar-timer:hover { background: rgba(var(--cyan-rgb), 0.22); }
.topbar-timer #topbarTimerDisplay { font-variant-numeric: tabular-nums; }
.topbar button.icon-btn {
  background: transparent;
  border: none;
  color: var(--navy);
  font-size: 18px;
  cursor: pointer;
  padding: 9px 10px;
  border-radius: var(--r-btn);
  line-height: 1;
}
.topbar button.icon-btn:hover { background: var(--hover-tint); }
/* Le burger, seule commande à porter un fond au repos : c'est lui qui ouvre la navigation. */
.topbar button.icon-btn.burger { background: var(--hover-tint); }
.topbar button.icon-btn.burger:hover { background: rgba(var(--navy-rgb), 0.12); }

.sync-dot {
  width: 9px; height: 9px; border-radius: 50%;
  background: var(--success);
  display: inline-block;
  flex-shrink: 0;
}
.sync-dot.syncing { background: var(--cyan); }
.sync-dot.error { background: var(--error); }

/* --- Layout --- */
.content {
  flex: 1;
  padding: var(--sp-5);
  padding-bottom: 96px;
  max-width: var(--content-max);
  width: 100%;
  margin: 0 auto;
}

/* --- Menu latéral (tiroir, épinglable) ---
   Deux états. Non épinglé : tiroir par-dessus le contenu, avec voile, fermé par défaut.
   Épinglé : rail permanent à gauche qui pousse le contenu, sans voile. L'épingle n'est
   proposée qu'au-dessus de 900 px, où il reste la place pour les deux. */
.drawer-scrim {
  position: fixed;
  inset: 0;
  background: var(--overlay);
  z-index: 30;
  border: none;
  padding: 0;
  cursor: pointer;
}
.drawer {
  position: fixed;
  top: 0; left: 0; bottom: 0;
  width: var(--sidebar-w);
  background: var(--surface);
  border-right: 1px solid var(--border);
  box-shadow: var(--shadow-drawer);
  z-index: 31;
  display: flex;
  flex-direction: column;
}
.drawer-head {
  background: var(--navy);
  color: #fff;
  padding: var(--sp-6) var(--sp-5);
  display: flex;
  align-items: flex-start;
  gap: var(--sp-2);
}
.drawer-head .dh-titles { flex: 1; min-width: 0; }
.drawer-head .dh-eyebrow {
  font-size: var(--fs-xs);
  font-weight: 700;
  color: var(--cyan);
  letter-spacing: 0.04em;
  text-transform: uppercase;
}
.drawer-head .dh-name { font-size: var(--fs-xl); font-weight: 800; margin-top: 2px; }
.drawer-head button {
  background: rgba(255, 255, 255, 0.14);
  border: none;
  color: #fff;
  font-size: var(--fs-md);
  cursor: pointer;
  padding: 7px 9px;
  border-radius: 10px;
  line-height: 1;
  flex-shrink: 0;
}
.drawer-head button:hover { background: rgba(255, 255, 255, 0.26); }
.drawer-nav { padding: var(--sp-3) 10px; display: flex; flex-direction: column; gap: var(--sp-1); }
.drawer-nav button {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 12px var(--sp-3);
  border-radius: var(--r-btn);
  border: none;
  background: transparent;
  cursor: pointer;
  font-family: inherit;
  font-size: var(--fs-md);
  font-weight: 500;
  color: var(--muted);
  text-align: left;
  width: 100%;
}
.drawer-nav button:hover { background: var(--hover-tint); }
.drawer-nav button.active {
  background: rgba(var(--cyan-rgb), 0.10);
  color: var(--navy);
  font-weight: 700;
}
.drawer-nav button .nav-icon { font-size: 18px; line-height: 1; }
.drawer-foot {
  margin-top: auto;
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  padding: var(--sp-3) var(--sp-5);
  border-top: 1px solid var(--border);
  font-size: var(--fs-xs);
  color: var(--muted);
}

/* Rail épinglé : plus de voile, plus d'ombre, et le corps de page se décale. Le burger
   disparaît — il n'ouvrirait qu'un menu déjà là. */
body.drawer-pinned .drawer { box-shadow: none; }
body.drawer-pinned .drawer-scrim { display: none; }
body.drawer-pinned .topbar .burger { display: none; }
body.drawer-pinned .topbar,
body.drawer-pinned .content,
body.drawer-pinned .bottom-nav,
body.drawer-pinned .fab { margin-left: var(--sidebar-w); }
body.drawer-pinned .toast { transform: translateX(calc(-50% + var(--sidebar-w) / 2)); }
/* Le rail rend la barre du bas redondante : sur grand écran, elle disparaît. */
body.drawer-pinned .bottom-nav { display: none; }
body.drawer-pinned .content { padding-bottom: var(--sp-6); }
body.drawer-pinned .fab { bottom: var(--sp-6); }

.bottom-nav {
  position: fixed;
  bottom: 0; left: 0; right: 0;
  background: var(--surface);
  border-top: 1px solid var(--border);
  display: flex;
  gap: 6px;
  padding: 10px var(--sp-3) var(--sp-4);
  z-index: 10;
}
.bottom-nav button {
  flex: 1;
  background: none;
  border: none;
  border-radius: 14px;
  padding: var(--sp-2) var(--sp-1);
  font-size: 11px;
  font-weight: 500;
  color: var(--muted);
  cursor: pointer;
  font-family: inherit;
}
.bottom-nav button .nav-icon { display: block; font-size: 18px; margin-bottom: 3px; }
.bottom-nav button.active {
  background: rgba(var(--cyan-rgb), 0.10);
  color: var(--navy);
  font-weight: 700;
}

/* --- Cards --- */
.card {
  background: var(--surface);
  border-radius: var(--r-row);
  padding: var(--sp-4) var(--sp-4);
  margin-bottom: var(--sp-3);
  box-shadow: var(--shadow-card);
  border: none;
}

.project-card {
  display: flex;
  align-items: center;
  gap: 14px;
  cursor: pointer;
  padding: var(--sp-4) 18px;
}
/* La pastille ronde devient une vignette carrée à coins arrondis, comme la maquette. */
.project-color-dot {
  width: 44px; height: 44px; border-radius: 14px; flex-shrink: 0;
}
.project-card .project-info { flex: 1; min-width: 0; }
.project-card .project-name { font-weight: 700; color: var(--navy); font-size: 16px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.project-card .project-sub { font-size: var(--fs-sm); color: var(--muted); margin-top: 3px; font-weight: 500; }
.project-card .running-badge {
  font-size: var(--fs-sm); font-weight: 700; color: var(--cyan-text);
  display: flex; align-items: center; gap: var(--sp-1);
}
.project-card .order-btns { display: flex; flex-direction: column; gap: 2px; }
.project-card .order-btns button {
  background: none; border: none; color: var(--muted); cursor: pointer; font-size: var(--fs-sm); padding: 2px var(--sp-1);
}
.project-card .order-btns button:disabled { opacity: 0.35; cursor: default; }

/* Jauge horizontale « consommé / vendu » sur la carte d'un projet à enveloppe. */
.card-gauge { width: 68px; flex-shrink: 0; }
.card-gauge .cg-bar {
  height: 7px; border-radius: 4px; background: var(--chip-bg); overflow: hidden;
}
.card-gauge .cg-fill { height: 100%; border-radius: 4px; background: var(--cyan); }
.card-gauge .cg-fill.over { background: var(--error); }
.card-gauge .cg-pct {
  font-size: 11px; font-weight: 700; color: var(--navy); margin-top: var(--sp-1); text-align: right;
}
.card-gauge .cg-pct.over { color: var(--error); }

.timer-toggle {
  width: 44px; height: 44px; border-radius: 22px;
  border: none; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  font-size: var(--fs-lg);
  background: var(--cyan); color: var(--navy);
  flex-shrink: 0;
}
.timer-toggle.running { background: var(--navy); color: #fff; }

/* --- Bandeau "chrono qui traîne" ---
   Volontairement plus voyant qu'une carte ordinaire (fond cyan clair, filet à gauche) :
   il doit accrocher l'oeil au retour sur l'onglet, sans pour autant bloquer l'écran. */
.long-timer-banner {
  background: var(--chip-active-bg);
  border: 1px solid var(--cyan);
  border-left-width: 4px;
  border-radius: var(--r-row);
  padding: 14px var(--sp-4);
  margin-bottom: 14px;
}
.long-timer-banner .ltb-text { font-size: var(--fs-sm); color: var(--navy); line-height: 1.45; }
.long-timer-banner .ltb-actions {
  display: flex; flex-wrap: wrap; gap: var(--sp-2); margin-top: var(--sp-3);
}
/* Les boutons passent en pleine largeur sur mobile plutôt que de se tasser sur une ligne. */
.long-timer-banner .ltb-actions .btn { padding: 9px 14px; font-size: var(--fs-sm); flex: 1 1 auto; }

/* --- Buttons --- */
button { font-family: inherit; }
.btn {
  display: inline-flex; align-items: center; justify-content: center;
  gap: 6px;
  padding: 12px 18px;
  border-radius: var(--r-btn);
  border: none;
  font-weight: 600;
  font-size: var(--fs-md);
  cursor: pointer;
  color: var(--navy);
}
.btn-primary { background: var(--cyan); color: var(--navy); font-weight: 700; }
.btn-primary:hover { filter: brightness(0.95); }
.btn-outline { background: transparent; color: var(--navy); border: 1.5px solid var(--border-strong); }
.btn-outline:hover { background: var(--hover-tint); }
.btn-danger { background: transparent; color: var(--error); }
.btn-block { width: 100%; }
/* Taille réduite, définie ICI et nulle part ailleurs : les trois actions du détail et le
   bouton « + Nouvelle catégorie » la partagent, donc ils font la même taille par
   construction et non par coïncidence. */
.btn-sm { padding: 11px var(--sp-3); font-size: var(--fs-sm); }
.btn:disabled { opacity: 0.5; cursor: default; }
.fab {
  position: fixed;
  right: var(--sp-5);
  bottom: 92px;
  width: 56px; height: 56px;
  border-radius: 50%;
  background: var(--cyan);
  color: var(--navy);
  border: none;
  font-size: 26px;
  box-shadow: var(--shadow-float);
  cursor: pointer;
  z-index: 9;
}

/* --- Forms --- */
label { font-size: var(--fs-xs); font-weight: 600; color: var(--muted); display: block; margin: 10px 0 var(--sp-1); }
input, select, textarea {
  width: 100%;
  padding: var(--sp-3) 14px;
  border-radius: var(--r-btn);
  border: 1.5px solid var(--border-strong);
  font-size: var(--fs-md);
  font-family: inherit;
  color: var(--navy);
  background: var(--surface);
}
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--cyan); }
/* Une case à cocher n'est pas un champ de saisie : le `width: 100%` ci-dessus l'étirait sur
   toute la ligne et rejetait son libellé à l'autre bout (visible au Reporting). */
input[type="checkbox"], input[type="radio"] {
  width: auto; flex-shrink: 0; margin: 0;
  accent-color: var(--cyan); cursor: pointer;
}
.field-row { display: flex; gap: 10px; }
.field-row > div { flex: 1; }

/* --- Chips --- */
.chip-row { display: flex; flex-wrap: wrap; gap: var(--sp-2); margin: var(--sp-2) 0; }
.chip {
  display: flex; align-items: center; gap: 6px;
  padding: 9px 14px;
  border-radius: var(--r-pill);
  background: var(--chip-bg);
  font-size: var(--fs-sm);
  font-weight: 600;
  cursor: pointer;
  border: 1.5px solid transparent;
  color: var(--navy);
}
.chip.active { border-color: var(--cyan); background: var(--chip-active-bg); }
.chip .dot { width: 10px; height: 10px; border-radius: 50%; }

/* "Démarrer le chrono" : grille de tuiles de catégories (maquette HDF Temps Web Démarrer). */
.start-cat-grid { display: grid; grid-template-columns: 1fr 1fr; gap: var(--sp-2); margin: 14px 0 10px; }
.start-cat-tile {
  display: flex; align-items: center; gap: 11px; text-align: left; min-width: 0;
  padding: var(--sp-3) 14px; border-radius: 14px; border: 1.5px solid var(--border-strong);
  background: var(--surface); cursor: pointer; font-family: inherit;
}
.start-cat-tile:hover { border-color: var(--cyan); }
.start-cat-tile .disc {
  width: 30px; height: 30px; border-radius: 50%; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center; color: #fff; font-size: 11px;
}
.start-cat-name { font-size: var(--fs-md); font-weight: 600; color: var(--navy); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.start-cat-actions { display: flex; gap: var(--sp-2); }
.start-cat-actions .btn { flex: 1; }

/* --- Détail d'un projet : en-tête --- */
.detail-head {
  display: flex; align-items: center; gap: var(--sp-3);
  margin-bottom: var(--sp-4);
}
.detail-head .dh-name {
  flex: 1; min-width: 0;
  font-size: 26px; font-weight: 800; color: var(--navy); letter-spacing: -0.4px;
}
/* Le rouage était un caractère de 18 px sans cible cliquable : 44 x 44, la cible tactile
   minimale, avec un fond au repos pour qu'il se voie comme un bouton. */
.detail-settings {
  width: 44px; height: 44px; flex-shrink: 0;
  border: none; border-radius: var(--r-btn);
  background: var(--hover-tint); color: var(--navy);
  font-size: 20px; line-height: 1; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
}
.detail-settings:hover { background: rgba(var(--navy-rgb), 0.12); }

/* --- Catégories du détail, en tuiles --- */
.cat-grid { display: grid; grid-template-columns: 1fr 1fr; gap: var(--sp-3); margin-bottom: var(--sp-3); }
.cat-tile {
  display: flex; flex-direction: column; gap: 10px;
  text-align: left; min-width: 0;
  padding: var(--sp-4) var(--sp-4) 14px;
  border-radius: var(--r-row);
  border: 1.5px solid transparent;
  background: var(--surface);
  box-shadow: var(--shadow-card);
  cursor: pointer; font-family: inherit;
}
.cat-tile:hover { border-color: var(--cyan); }
.cat-tile.active { border-color: var(--cyan); background: var(--chip-active-bg); box-shadow: none; }
.cat-tile .ct-head { display: flex; align-items: center; gap: 9px; }
.cat-tile .ct-dot { width: 10px; height: 10px; border-radius: 50%; flex-shrink: 0; }
.cat-tile .ct-name {
  flex: 1; min-width: 0; font-size: var(--fs-lg); font-weight: 700; color: var(--navy);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.cat-tile .ct-icon {
  width: 32px; height: 32px; border-radius: 16px; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  font-size: 11px; background: var(--chip-bg); color: var(--navy);
}
.cat-tile.active .ct-icon { background: var(--navy); color: #fff; }
.cat-tile .ct-total {
  font-size: 26px; font-weight: 800; color: var(--navy);
  letter-spacing: -0.8px; font-variant-numeric: tabular-nums;
}
.cat-tile .ct-caption { font-size: var(--fs-xs); font-weight: 600; color: var(--cyan-text); }
/* « + Nouvelle catégorie » n'est pas une catégorie : c'est une action, et elle sort donc de
   la grille. Bouton ordinaire à la taille des actions du détail, largeur au contenu. */
.cat-add-row { margin-bottom: var(--sp-5); }

/* Les trois actions du détail sur deux lignes plutôt que trois pleines largeurs. */
.detail-actions { display: flex; flex-wrap: wrap; gap: var(--sp-2); margin-bottom: var(--sp-4); }
.detail-actions .btn { flex: 1 1 45%; }
.detail-actions .btn.wide { flex-basis: 100%; }

/* --- Timer card --- */
.timer-card {
  background: var(--surface);
  border-radius: var(--r-timer);
  padding: 26px var(--sp-6);
  text-align: center;
  margin-bottom: var(--sp-4);
  box-shadow: var(--shadow-card);
}
.timer-card.running { background: var(--navy); color: #fff; }
.timer-eyebrow {
  font-size: var(--fs-xs); font-weight: 700; letter-spacing: 0.05em;
  text-transform: uppercase; color: var(--muted-soft);
}
.timer-card.running .timer-eyebrow { color: rgba(255, 255, 255, 0.7); }
.timer-display { font-size: 44px; font-weight: 800; margin: var(--sp-2) 0 18px; font-variant-numeric: tabular-nums; letter-spacing: -1px; }
.timer-card .btn-primary { min-width: 170px; }
.timer-card.running .btn-primary { background: #fff; color: var(--navy); }

/* Chrono à l'arrêt : l'encart se réduit à une ligne. Un « 00:00 » de 44 px occupait le haut
   de l'écran pour ne rien dire ; la place revient aux catégories et aux heures saisies. */
.timer-card.compact {
  display: flex; align-items: center; gap: var(--sp-4);
  text-align: left;
  padding: 14px var(--sp-4) 14px var(--sp-5);
}
.timer-card.compact .tc-text { flex: 1; min-width: 0; }
.timer-card.compact .tc-note {
  font-size: var(--fs-sm); color: var(--muted); line-height: 1.4; margin-top: 3px;
}
.timer-card.compact .btn { flex-shrink: 0; min-width: 0; }

/* --- Entries list --- */
.entry-row {
  display: flex; align-items: center; gap: 10px;
  padding: var(--sp-3) 0;
  border-bottom: 1px solid var(--border);
}
.entry-row:last-child { border-bottom: none; }
.entry-row .entry-date { font-size: var(--fs-xs); color: var(--muted); width: 70px; flex-shrink: 0; font-weight: 500; }
.entry-row .entry-cat { flex: 1; font-size: var(--fs-sm); min-width: 0; }
.entry-row .entry-min { font-weight: 700; color: var(--navy); font-size: var(--fs-sm); font-variant-numeric: tabular-nums; }
.entry-row .entry-actions { display: flex; gap: var(--sp-1); }
.entry-row .entry-actions button { background: none; border: none; cursor: pointer; font-size: var(--fs-md); padding: var(--sp-1); color: var(--muted); }

/* Historique replié par jour (fiche projet) : un en-tête-bouton par journée, date à gauche,
   total du jour et chevron à droite. Les saisies d'une journée dépliée gardent .entry-row,
   légèrement en retrait pour qu'on voie à quelle journée elles appartiennent. */
.history-day { border-bottom: 1px solid var(--border); }
.history-day:last-child { border-bottom: none; }
.history-day-head {
  display: flex; align-items: center; gap: 10px; width: 100%;
  padding: var(--sp-3) 0; background: none; border: none; cursor: pointer;
  font: inherit; color: var(--navy); text-align: left;
}
.history-day-head:hover { background: var(--hover-tint); }
.history-day-head .hd-date { flex: 1; font-size: var(--fs-sm); font-weight: 600; }
.history-day-head .hd-total { font-weight: 700; font-size: var(--fs-sm); font-variant-numeric: tabular-nums; }
.history-day-head .hd-chevron { width: 1em; text-align: center; color: var(--muted); font-size: var(--fs-md); line-height: 1; }
.history-day-entries { padding-left: var(--sp-3); }
.history-day-entries .entry-row:last-child { border-bottom: none; }

/* --- Gauge --- */
.gauge { margin: 10px 0; }
.gauge-label { display: flex; justify-content: space-between; font-size: var(--fs-xs); margin-bottom: var(--sp-1); color: var(--muted); }
.gauge-bar { height: 8px; border-radius: 4px; background: var(--chip-bg); overflow: hidden; }
.gauge-fill { height: 100%; background: var(--cyan); border-radius: 4px; }
.gauge-fill.over { background: var(--error); }

/* --- Auth --- */
.auth-wrap {
  min-height: 100vh;
  display: flex; align-items: center; justify-content: center;
  padding: var(--sp-6);
}
.auth-card { width: 100%; max-width: 380px; text-align: center; }
.auth-logo { font-size: var(--fs-2xl); font-weight: 800; color: var(--navy); margin-bottom: var(--sp-1); }
.auth-sub { font-size: var(--fs-sm); color: var(--muted); margin-bottom: var(--sp-6); }
.auth-card .btn { margin-top: var(--sp-2); }
.auth-error { color: var(--error); font-size: var(--fs-sm); margin-top: 10px; }
.auth-info { color: var(--navy); font-size: var(--fs-sm); margin-top: 10px; line-height: 1.45; }
/* « Mot de passe oublié ? » : lien texte sous le champ, aligné à droite comme l'usage le veut. */
.auth-forgot {
  display: block; margin: var(--sp-1) 0 0 auto; padding: 0; background: none; border: none;
  font: inherit; font-size: var(--fs-xs); color: var(--cyan-text); cursor: pointer; text-decoration: underline;
}
.auth-forgot:disabled { opacity: .6; cursor: default; }
.auth-switch { margin-top: var(--sp-4); font-size: var(--fs-sm); }
.auth-switch a { color: var(--cyan-text); font-weight: 600; cursor: pointer; text-decoration: underline; }
.auth-divider { display: flex; align-items: center; gap: 10px; margin: var(--sp-5) 0 var(--sp-2); color: var(--muted); font-size: var(--fs-xs); }
.auth-divider::before, .auth-divider::after { content: ""; flex: 1; height: 1px; background: var(--border-strong); }
/* Bouton Apple : noir + logo blanc, comme l'exige Apple pour "Sign in with Apple"
   (le logo est un masque SVG inline, donc aucun fichier ni requête réseau en plus). */
.btn-apple { background: #000; color: #fff; }
.btn-apple:hover { filter: brightness(1.25); }
.apple-logo {
  width: 15px; height: 17px; display: inline-block; background: currentColor;
  -webkit-mask: var(--apple-logo) center / contain no-repeat;
  mask: var(--apple-logo) center / contain no-repeat;
}
/* Fusion assistée de comptes (connexion Apple/Google sur un email déjà utilisé). */
.auth-notice {
  margin-top: var(--sp-3); padding: var(--sp-3); border-radius: var(--r-btn);
  background: var(--hover-tint); color: var(--navy);
  font-size: var(--fs-sm); text-align: left; line-height: 1.45;
}
.auth-notice strong { display: block; margin-bottom: var(--sp-1); }
.auth-notice a { display: inline-block; margin-top: var(--sp-2); font-size: var(--fs-xs); cursor: pointer; text-decoration: underline; }

/* --- Modal --- */
.modal-backdrop {
  position: fixed; inset: 0; background: var(--overlay);
  display: flex; align-items: center; justify-content: center;
  z-index: 100; padding: var(--sp-4);
}
.modal {
  background: var(--surface); border-radius: var(--r-timer); padding: var(--sp-6);
  max-width: 460px; width: 100%; max-height: 85vh; overflow-y: auto;
}
.modal h2 { margin-top: 0; font-size: 19px; font-weight: 800; color: var(--navy); letter-spacing: -0.3px; }
.modal-hint { font-size: var(--fs-sm); color: var(--muted); line-height: 1.45; margin-bottom: var(--sp-1); }
.modal-close {
  float: right; background: var(--hover-tint); border: none; width: 34px; height: 34px;
  border-radius: 17px; font-size: var(--fs-lg); cursor: pointer; color: var(--navy);
}

/* Bandeau d'alerte dans une modale (chrono déjà en cours ailleurs, etc.). */
.modal-alert {
  display: flex; gap: 11px; align-items: flex-start;
  margin-top: var(--sp-4); padding: var(--sp-3) var(--sp-4);
  border-radius: 14px;
  background: rgba(245, 158, 11, 0.12);
  border: 1px solid rgba(245, 158, 11, 0.4);
  font-size: var(--fs-sm); line-height: 1.45; color: var(--navy);
}
.modal-alert .ma-icon { font-size: var(--fs-lg); flex-shrink: 0; line-height: 1.3; }

.template-option {
  display: block; width: 100%; text-align: left;
  padding: 13px 14px; margin-bottom: var(--sp-2);
  border-radius: var(--r-btn); border: 1.5px solid var(--border-strong);
  background: var(--surface); cursor: pointer;
}
.template-option:hover { border-color: var(--cyan); }
.template-option .t-title { font-weight: 700; color: var(--navy); font-size: var(--fs-md); }
.template-option .t-desc { font-size: var(--fs-xs); color: var(--muted); margin-top: 2px; }

/* --- Misc --- */
.empty-state { text-align: center; padding: 40px var(--sp-5); color: var(--muted); font-size: var(--fs-md); }
.section-title {
  font-size: var(--fs-xs); font-weight: 700; text-transform: uppercase;
  letter-spacing: 0.05em; color: var(--muted); margin: 18px 0 var(--sp-2);
}
.back-row { display: flex; align-items: center; gap: var(--sp-1); }
.toast {
  position: fixed; bottom: 96px; left: 50%; transform: translateX(-50%);
  background: var(--navy); color: #fff; padding: var(--sp-3) 18px; border-radius: var(--r-btn);
  font-size: var(--fs-sm); z-index: 200;
}

/* Sur téléphone, la jauge de 68 px prise sur la même ligne rognait le nom du projet
   ("Dupon…", "Audit i…"). Le nom prime : la jauge passe sous lui, en pleine largeur. */
@media (max-width: 560px) {
  /* La puce du chrono ne garde que la durée : le nom du projet à côté d'elle ne laissait
     plus la place au titre de l'écran. Il reste dans l'infobulle, et un clic mène au projet. */
  .topbar-timer .tt-label { display: none; }
  .topbar-timer { max-width: none; padding: 7px 10px; }

  /* Deux tuiles de catégorie sur 375 px ne laissent que ~70 px au nom : "Réunio…",
     "Déplac…". La tuile passe sur une colonne et se couche en ligne — même carte, même
     total, mais le nom entier. */
  .cat-grid { grid-template-columns: 1fr; gap: var(--sp-2); }
  .cat-tile { flex-direction: row; flex-wrap: wrap; align-items: center; gap: 11px; padding: 14px var(--sp-4); }
  /* `display: contents` remonte pastille, nom et bouton au niveau de la tuile : ils
     deviennent des éléments flex frères du total, donc ordonnables entre eux. */
  .cat-tile .ct-head { display: contents; }
  .cat-tile .ct-total { font-size: var(--fs-2xl); margin-left: auto; }
  .cat-tile .ct-icon { order: 1; }
  .cat-tile .ct-caption { flex-basis: 100%; order: 2; margin-top: -6px; }

  .project-card { flex-wrap: wrap; }
  .card-gauge { order: 10; width: 100%; flex-basis: 100%; margin-top: var(--sp-1); }
  .card-gauge .cg-bar { height: 8px; }
  .card-gauge .cg-pct { text-align: right; }
}

/* En dessous de 900 px, le rail épinglé n'a plus la place : l'épingle est ignorée et tout
   redevient un tiroir ordinaire, burger et voile compris. La préférence n'est pas perdue —
   elle reprend effet dès que la fenêtre s'élargit. */
@media (max-width: 900px) {
  body.drawer-pinned .drawer:not(.is-open) { display: none; }
  body.drawer-pinned .drawer-scrim { display: block; }
  body.drawer-pinned .topbar .burger { display: inline-flex; }
  body.drawer-pinned .topbar,
  body.drawer-pinned .content,
  body.drawer-pinned .bottom-nav,
  body.drawer-pinned .fab { margin-left: 0; }
  body.drawer-pinned .toast { transform: translateX(-50%); }
  body.drawer-pinned .bottom-nav { display: flex; }
  body.drawer-pinned .content { padding-bottom: 96px; }
  body.drawer-pinned .fab { bottom: 92px; }
  body.drawer-pinned .drawer { box-shadow: var(--shadow-drawer); }
}

/* --- Écran API (SPEC_API_PUBLIQUE.md) ------------------------------------------------------
   La documentation est du HTML servi par `getApiDocumentation` : titres, listes, code. On ne
   style donc que des éléments génériques, à l'intérieur de `.api-doc-body`. */
.api-key-mask { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 12px; color: var(--cyan-text); margin-left: 6px; }
.api-new-key { border: 2px solid var(--cyan); }
.api-key-value { width: 100%; margin-top: 10px; font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 13px; }
.api-doc code { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 12.5px; background: var(--chip-bg); padding: 1px 5px; border-radius: 4px; overflow-wrap: anywhere; }
.api-doc-body { margin-top: 14px; color: var(--navy); font-size: 14px; line-height: 1.55; }
.api-doc-body h2 { font-size: 16px; margin: 22px 0 8px; color: var(--navy); }
.api-doc-body h3 { font-size: 14px; margin: 16px 0 6px; color: var(--navy); font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; }
.api-doc-body p, .api-doc-body ul, .api-doc-body ol { margin: 6px 0; }
.api-doc-body ul, .api-doc-body ol { padding-left: 20px; }
.api-doc-body pre.api-code { background: var(--navy); color: #E6EDF7; padding: 10px 12px; border-radius: 8px; overflow-x: auto; margin: 8px 0; }
.api-doc-body pre.api-code code { background: none; padding: 0; color: inherit; font-size: 12px; white-space: pre; overflow-wrap: normal; }
