/* Design system TikTak -- tokens et classes communes extraits de la maquette
   UI/extracted/design_handoff_tiktak/. Valeurs exactes, ne pas approximer. */

@font-face {
  font-family: 'Inter';
  font-style: normal;
  font-weight: 400 700;
  font-display: swap;
  src: url('../fonts/inter-variable-latin-ext.woff2') format('woff2');
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF,
    U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020,
    U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}
@font-face {
  font-family: 'Inter';
  font-style: normal;
  font-weight: 400 700;
  font-display: swap;
  src: url('../fonts/inter-variable-latin.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;
}

:root {
  --fond: #F7F4EF;
  --carte: #ffffff;
  --sidebar-bg: #26221D;
  --sidebar-hover: #332E28;
  --sidebar-divider: #352F29;
  --sidebar-texte: #C9C0B2;
  --sidebar-texte-vif: #F5F1EA;
  --sidebar-sous-label: #8A8072;

  --texte: #2A251F;
  --texte-secondaire: #857C6E;
  --texte-tertiaire: #9A8F7E;

  --bordure-carte: #E8E1D6;
  --bordure-section: #EFEAE1;
  --bordure-ligne: #F2EDE5;
  --bordure-champ: #E2DACD;
  --bordure-segmente: #E4DCCE;

  --accent: #C4653B;
  --accent-hover: #A9542F;

  --succes-texte: #3D8F68;
  --succes-fond: #EAF4EF;
  --succes-bordure: #CDE7DA;
  --succes-point: #3D9970;

  --neutre-texte: #9A8F7E;
  --neutre-fond: #F3EFE8;
  --neutre-bordure: #E4DCCE;

  --pause-texte: #9A6A2E;
  --pause-fond: #FBF1E2;
  --pause-bordure: #EEDFC2;

  --facture-texte: #7A4A2E;
  --facture-fond: #FBF3EC;
  --facture-bordure: #E9D9C9;

  --danger: #D64545;
  --danger-hover: #BE3A3A;
  --danger-texte: #B5504A;
  --danger-texte-hover: #963C37;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
body {
  font-family: 'Inter', system-ui, sans-serif;
  -webkit-font-smoothing: antialiased;
  color: var(--texte);
  background: var(--fond);
}
a { color: var(--accent); text-decoration: none; }
a:hover { color: var(--accent-hover); }
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { background: #D9D0C2; border-radius: 6px; }

.tabular-nums { font-variant-numeric: tabular-nums; }

/* Shell -- sidebar + contenu */
.app-shell { display: flex; min-height: 100vh; }

.sidebar {
  width: 236px;
  flex-shrink: 0;
  background: var(--sidebar-bg);
  color: var(--sidebar-texte);
  position: sticky;
  top: 0;
  height: 100vh;
  max-height: 100dvh;
  display: flex;
  flex-direction: column;
  padding: 20px 12px;
  overflow: hidden;
}
.brand-row { display: flex; align-items: center; gap: 10px; padding: 0 8px 20px; flex-shrink: 0; }
.sidebar nav {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
}
.brand-logo {
  width: 32px; height: 32px; border-radius: 9px;
  background: var(--accent);
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.brand-text { color: var(--sidebar-texte-vif); font-weight: 700; font-size: 15px; }
.brand-sub { color: var(--sidebar-sous-label); font-size: 11px; }

.nav-item {
  display: flex; align-items: center; gap: 11px;
  padding: 10px 12px; border-radius: 8px;
  font-size: 14px; color: var(--sidebar-texte);
  cursor: pointer;
}
.nav-item:hover { background: var(--sidebar-hover); color: var(--sidebar-texte-vif); }
.nav-item.actif { background: var(--accent); color: #fff; font-weight: 600; }
.nav-divider { height: 1px; background: var(--sidebar-divider); margin: 10px 12px; }
.nav-section-label {
  font-size: 10.5px; font-weight: 700; color: var(--sidebar-sous-label);
  text-transform: uppercase; letter-spacing: 0.05em;
  padding: 4px 12px 6px;
}
.nav-dot-chrono {
  width: 8px; height: 8px; border-radius: 50%;
  background: #E53E3E; margin-left: auto; flex-shrink: 0;
}

.user-row {
  flex-shrink: 0;
  padding-top: 14px;
  border-top: 1px solid var(--sidebar-divider);
  display: flex; align-items: center; gap: 10px;
  padding: 14px 8px 4px;
}
.user-avatar {
  width: 32px; height: 32px; border-radius: 50%;
  background: #4A433A; color: var(--sidebar-texte-vif);
  display: flex; align-items: center; justify-content: center;
  font-size: 13px; font-weight: 600; flex-shrink: 0;
}
.user-nom { font-size: 13px; font-weight: 500; color: var(--sidebar-texte-vif); }
.user-sous { font-size: 11px; color: var(--sidebar-sous-label); }

/* Sous 720px (iPhone), la sidebar laisse place a la barre de navigation
   du bas (.nav-mobile, plus adaptee au pouce qu'une colonne d'icones). */
@media (max-width: 720px) {
  .sidebar { display: none; }
}

.app-body {
  flex: 1;
  min-width: 0;
  max-width: 1240px;
  width: 100%;
  margin: 0 auto;
  padding: 20px 34px 44px;
  display: flex;
  flex-direction: column;
  gap: 18px;
}

/* Barre de navigation mobile (bas d'ecran, sous 720px uniquement) */
.nav-mobile { display: none; }
@media (max-width: 720px) {
  [x-cloak] { display: none !important; }

  .app-body { padding: 16px 16px 84px; }

  .nav-mobile {
    display: flex;
    position: fixed;
    left: 0; right: 0; bottom: 0;
    z-index: 40;
    background: var(--sidebar-bg);
    border-top: 1px solid var(--sidebar-divider);
    padding: 4px 4px calc(4px + env(safe-area-inset-bottom, 0px));
  }
  .nav-mobile-item {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 2px;
    min-height: 56px;
    padding: 6px 4px;
    font-size: 10.5px;
    font-weight: 600;
    color: var(--sidebar-texte);
    background: none;
    border: none;
    cursor: pointer;
  }
  .nav-mobile-item.actif { color: var(--accent); }
  .nav-mobile-icone { font-size: 20px; line-height: 1; }

  .nav-mobile-sheet-backdrop {
    position: fixed; inset: 0;
    background: rgba(0, 0, 0, .35);
    z-index: 45;
  }
  .nav-mobile-sheet {
    position: fixed;
    left: 0; right: 0; bottom: 0;
    z-index: 46;
    background: var(--sidebar-bg);
    border-radius: 16px 16px 0 0;
    padding: 8px 8px calc(12px + env(safe-area-inset-bottom, 0px));
    display: flex;
    flex-direction: column;
  }
  .nav-mobile-sheet-poignee {
    width: 36px; height: 4px;
    border-radius: 3px;
    background: var(--sidebar-divider);
    margin: 6px auto 10px;
  }
  .nav-mobile-sheet-item {
    display: flex;
    align-items: center;
    gap: 12px;
    min-height: 48px;
    padding: 10px 16px;
    border-radius: 10px;
    font-size: 15px;
    color: var(--sidebar-texte);
  }
  .nav-mobile-sheet-item.actif { background: var(--accent); color: #fff; font-weight: 600; }
  .nav-mobile-sheet-item:not(.actif):active { background: var(--sidebar-hover); }
}
@media (max-width: 720px) {
  .app-body { padding: 16px; }
}

.app-head {
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px; flex-wrap: wrap;
}
.app-head h1 { font-size: 22px; font-weight: 700; letter-spacing: -0.01em; }

/* Cartes */
.card {
  background: var(--carte);
  border: 1px solid var(--bordure-carte);
  border-radius: 14px;
  box-shadow: 0 1px 2px rgba(42, 37, 31, .04);
}

/* Messages flash */
.flash { padding: 10px 16px; border-radius: 10px; font-size: 13.5px; font-weight: 500; }
.flash-success { background: var(--succes-fond); color: var(--succes-texte); border: 1px solid var(--succes-bordure); }
.flash-error { background: #FCE8E6; color: #611A15; border: 1px solid #F3C6C1; }

/* Pills de statut */
.pill {
  display: inline-block;
  font-size: 11px; font-weight: 600;
  padding: 3px 10px; border-radius: 20px;
  white-space: nowrap;
}
.pill-yes { color: var(--succes-texte); background: var(--succes-fond); border: 1px solid var(--succes-bordure); }
.pill-no { color: var(--neutre-texte); background: var(--neutre-fond); border: 1px solid var(--neutre-bordure); }
.pill-pause { color: var(--pause-texte); background: var(--pause-fond); border: 1px solid var(--pause-bordure); }
.pill-facture { color: var(--facture-texte); background: var(--facture-fond); border: 1px solid var(--facture-bordure); }

/* Boutons */
.btn {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 13.5px; font-weight: 600;
  padding: 10px 18px; border-radius: 9px;
  border: 1px solid transparent; cursor: pointer;
}
.btn-primary { background: var(--accent); color: #fff; box-shadow: 0 1px 2px rgba(196, 101, 59, .3); }
.btn-primary:hover { background: var(--accent-hover); }
.btn-secondary { background: #fff; border-color: var(--bordure-champ); color: var(--texte); }
.btn-secondary:hover { border-color: #C9BFAE; }
.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover { background: var(--danger-hover); }
.btn-danger-text { background: transparent; border: none; color: var(--danger-texte); padding: 8px 4px; }
.btn-danger-text:hover { color: var(--danger-texte-hover); }
.btn-icon {
  width: 32px; height: 32px; display: inline-flex; align-items: center; justify-content: center;
  background: transparent; border: none; border-radius: 7px; color: #B7AD9D; cursor: pointer;
}
.btn-icon:hover { background: #F0EAE1; }

/* Segmented control */
.segmented {
  display: inline-flex; flex-wrap: wrap; background: var(--neutre-fond);
  border: 1px solid var(--bordure-segmente); border-radius: 9px; padding: 3px;
}
.segmented button {
  font-size: 13px; font-weight: 600; padding: 7px 16px;
  border-radius: 7px; border: none; cursor: pointer;
  background: transparent; color: var(--texte-secondaire);
}
.segmented button.actif {
  background: #fff; color: var(--texte);
  box-shadow: 0 1px 2px rgba(42, 37, 31, .12);
}

/* Toggle switch */
.toggle { display: inline-flex; align-items: center; cursor: pointer; }
.toggle-track {
  width: 42px; height: 24px; border-radius: 20px;
  background: #D9D0C2; position: relative; transition: background .15s;
}
.toggle-track.actif { background: var(--accent); }
.toggle-thumb {
  width: 18px; height: 18px; border-radius: 50%; background: #fff;
  box-shadow: 0 1px 2px rgba(0, 0, 0, .2);
  position: absolute; top: 3px; left: 3px; transition: left .15s;
}
.toggle-track.actif .toggle-thumb { left: 21px; }

/* Formulaires */
.champ label {
  display: block; font-size: 11px; font-weight: 600;
  color: var(--texte-tertiaire); text-transform: uppercase; letter-spacing: .04em;
  margin-bottom: 6px;
}
input[type=text], input[type=date], input[type=time], input[type=number],
input[type=password], input:not([type]), select, textarea {
  border: 1px solid var(--bordure-champ); border-radius: 9px;
  padding: 10px 13px; font-size: 14px; font-family: inherit;
  background: #fff; color: var(--texte);
}
.champ input, .champ select, .champ textarea {
  width: 100%;
}

/* Tables */
table.tk-table { width: 100%; border-collapse: collapse; }
table.tk-table th {
  font-size: 11px; font-weight: 700; color: var(--texte-secondaire);
  text-transform: uppercase; letter-spacing: .03em; text-align: left;
  padding: 10px 16px; background: #FBF9F5; border-bottom: 1px solid var(--bordure-section);
}
table.tk-table td {
  padding: 13px 16px; border-bottom: 1px solid var(--bordure-ligne); font-size: 14px;
}
table.tk-table tr:hover td { background: #FCFBF8; }
table.tk-table tr.rappel-visuel td { background: #FBF3EC; transition: background 0.6s ease; }
.rappel-visuel { background: #FBF3EC !important; transition: background 0.6s ease; }

/* Modales */
.modal-backdrop {
  position: fixed; inset: 0; background: rgba(38, 34, 29, .42);
  display: flex; align-items: center; justify-content: center;
  z-index: 100; padding: 20px;
}
.modal-carte {
  background: #fff; border-radius: 16px;
  box-shadow: 0 20px 60px rgba(38, 34, 29, .28);
  max-width: 520px; width: 100%;
  max-height: 90vh; overflow-y: auto;
}
.modal-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 20px 22px; border-bottom: 1px solid var(--bordure-section);
}
.modal-header h2 { font-size: 17px; font-weight: 700; }
.modal-fermer { background: transparent; border: none; color: var(--texte-tertiaire); cursor: pointer; font-size: 18px; }
.modal-corps { padding: 20px 22px; display: flex; flex-direction: column; gap: 16px; }
.modal-footer {
  display: flex; align-items: center; gap: 10px;
  padding: 16px 22px; border-top: 1px solid var(--bordure-section);
}

/* Zones tactiles agrandies sous 720px (iPhone) -- cible Apple/Google de
   44x44px minimum. Le desktop/tablette (souris) garde les tailles
   d'origine, plus denses. */
@media (max-width: 720px) {
  .btn-icon {
    width: 44px; height: 44px;
  }
  .btn-icon + .btn-icon,
  .btn-icon + form .btn-icon,
  form + .btn-icon {
    margin-left: 4px;
  }
  .btn { min-height: 44px; padding: 10px 18px; }
  .segmented button { min-height: 40px; padding: 9px 16px; }
  .pill { padding: 6px 12px; }
  input[type=checkbox] { width: 22px; height: 22px; }
  .nav-item, .nav-mobile-sheet-item { min-height: 48px; }
  table.tk-table td, table.tk-table th { padding: 14px 12px; }
}

/* Tableaux -> cartes empilees sous 720px (Gestion des entrees, Temps des
   ressources externes) -- un tableau a 6-10 colonnes est illisible sur
   iPhone, mieux vaut une petite carte par ligne comme Suivi du temps. */
.tk-cartes-mobile { display: none; }
@media (max-width: 720px) {
  .tk-table-desktop { display: none; }
  .tk-cartes-mobile { display: flex; flex-direction: column; gap: 10px; }
}
/* Colonnes secondaires cachees entre le seuil cartes-mobiles (720px) et
   1024px (tablette/petite fenetre desktop) -- desengorge le tableau sans
   perdre l'info (deja visible dans les cartes mobiles en dessous de
   720px, ou en elargissant la fenetre au-dessus de 1024px). */
@media (max-width: 1024px) {
  .tk-col-masquable { display: none; }
}
.tk-carte-ligne { padding: 12px 14px; display: flex; flex-direction: column; gap: 8px; }
.tk-carte-ligne-tete { display: flex; align-items: center; gap: 10px; }
.tk-carte-ligne-titre {
  flex: 1; min-width: 0;
  display: flex; align-items: center; gap: 8px;
  font-size: 14.5px; font-weight: 600; color: var(--texte);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.tk-carte-ligne-corps {
  display: flex; flex-direction: column; gap: 3px;
  font-size: 12.5px; color: var(--texte-secondaire);
}
.tk-carte-ligne-pied {
  display: flex; align-items: center; flex-wrap: wrap; gap: 8px;
}
.tk-carte-ligne-montant { margin-left: auto; font-size: 13.5px; font-weight: 600; color: var(--texte); }
.modal-footer .spacer { margin-left: auto; display: flex; gap: 10px; }
