/* =====================================================================
   SRH - Feuille de style principale
   Design responsive : sidebar sur laptop, navigation basse sur mobile.
   Themes clair / sombre pilotes par [data-theme] sur <html>.
   ===================================================================== */

/* --- Jetons de design ------------------------------------------------ */
:root {
  --brand:        #4f46e5;
  --brand-600:    #4338ca;
  --brand-soft:   #eef2ff;
  --accent:       #0ea5e9;
  --ok:           #059669;
  --ok-soft:      #ecfdf5;
  --warn:         #d97706;
  --warn-soft:    #fffbeb;
  --danger:       #dc2626;
  --danger-soft:  #fef2f2;
  --info:         #0284c7;
  --info-soft:    #f0f9ff;

  --bg:           #f5f6fa;
  --surface:      #ffffff;
  --surface-2:    #fafbfd;
  --surface-3:    #f1f3f9;
  --border:       #e4e7ef;
  --border-strong:#cfd4e2;
  --text:         #171a26;
  --text-2:       #5a6178;
  --text-3:       #8b91a6;

  --sidebar-bg:   #14162b;
  --sidebar-text: #a8adc4;
  --sidebar-active:#ffffff;

  --radius:   14px;
  --radius-sm: 9px;
  --radius-lg: 20px;
  --shadow-1: 0 1px 2px rgba(16,20,40,.05), 0 1px 3px rgba(16,20,40,.04);
  --shadow-2: 0 4px 14px rgba(16,20,40,.07), 0 1px 3px rgba(16,20,40,.05);
  --shadow-3: 0 18px 45px rgba(16,20,40,.16);
  --sidebar-w: 254px;
  --topbar-h: 62px;
  --font: "Segoe UI", Inter, -apple-system, BlinkMacSystemFont, Roboto, Helvetica, Arial, sans-serif;
  --mono: ui-monospace, "Cascadia Mono", Consolas, monospace;
}

[data-theme="dark"] {
  --brand:        #818cf8;
  --brand-600:    #6366f1;
  --brand-soft:   #1e2140;
  --ok:           #34d399;
  --ok-soft:      #0d2b22;
  --warn:         #fbbf24;
  --warn-soft:    #2d2210;
  --danger:       #f87171;
  --danger-soft:  #2d1417;
  --info:         #38bdf8;
  --info-soft:    #0c2434;

  --bg:           #0c0e18;
  --surface:      #141724;
  --surface-2:    #191d2d;
  --surface-3:    #1f2436;
  --border:       #262b3d;
  --border-strong:#39405a;
  --text:         #e8eaf2;
  --text-2:       #a2a9c0;
  --text-3:       #767e97;
  --sidebar-bg:   #0a0c15;
  --shadow-1: 0 1px 2px rgba(0,0,0,.4);
  --shadow-2: 0 4px 16px rgba(0,0,0,.45);
  --shadow-3: 0 18px 45px rgba(0,0,0,.6);
}

* { box-sizing: border-box; }

html, body { height: 100%; }

body {
  margin: 0;
  font-family: var(--font);
  font-size: 14.5px;
  line-height: 1.55;
  color: var(--text);
  background: var(--bg);
  -webkit-text-size-adjust: 100%;
  -webkit-font-smoothing: antialiased;
}

/* Filet de securite : une image ne doit jamais deborder de son conteneur
   ni s afficher a sa taille naturelle si sa classe fait defaut. */
img { max-width: 100%; height: auto; }

a { color: var(--brand); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3, h4 { margin: 0 0 .4em; line-height: 1.25; font-weight: 650; letter-spacing: -.012em; }
h1 { font-size: 1.5rem; }
h2 { font-size: 1.18rem; }
h3 { font-size: 1.02rem; }
p  { margin: 0 0 .8em; }
small { font-size: .82em; }
.icon { flex: 0 0 auto; vertical-align: -.18em; }

/* =====================================================================
   MISE EN PAGE
   ===================================================================== */
.app { display: flex; min-height: 100vh; }

/* --- Barre laterale -------------------------------------------------- */
.sidebar {
  width: var(--sidebar-w);
  flex: 0 0 var(--sidebar-w);
  background: var(--sidebar-bg);
  color: var(--sidebar-text);
  display: flex;
  flex-direction: column;
  position: fixed;
  inset: 0 auto 0 0;
  z-index: 60;
  overflow-y: auto;
  overscroll-behavior: contain;
  scrollbar-width: thin;
}
.sidebar::-webkit-scrollbar { width: 6px; }
.sidebar::-webkit-scrollbar-thumb { background: #ffffff22; border-radius: 3px; }

.brand {
  display: flex; align-items: center; gap: 11px;
  padding: 18px 18px 16px;
  color: #fff; font-weight: 700; font-size: 1.06rem;
  letter-spacing: -.02em;
}
.brand-logo {
  width: 36px; height: 36px; border-radius: 11px;
  background: linear-gradient(140deg, var(--brand) 0%, var(--accent) 100%);
  display: grid; place-items: center;
  color: #fff; font-weight: 800; font-size: .95rem;
  box-shadow: 0 4px 14px rgba(79,70,229,.45);
}
.brand small { display: block; font-weight: 500; font-size: .68rem; color: #8b90ad; letter-spacing: .02em; }

.nav { padding: 4px 10px 20px; flex: 1; }
.nav-group { margin-top: 14px; }
.nav-group > span {
  display: block; padding: 0 10px 6px;
  font-size: .68rem; font-weight: 700; letter-spacing: .1em;
  text-transform: uppercase; color: #61668a;
}
.nav a {
  display: flex; align-items: center; gap: 11px;
  padding: 9px 11px; margin-bottom: 2px;
  border-radius: 10px;
  color: var(--sidebar-text);
  font-size: .89rem; font-weight: 500;
  text-decoration: none;
  transition: background .14s, color .14s;
}
.nav a:hover { background: #ffffff0f; color: #fff; text-decoration: none; }
.nav a.active { background: linear-gradient(100deg, var(--brand) 0%, #6d5ff0 100%); color: #fff; font-weight: 600; box-shadow: 0 4px 14px rgba(79,70,229,.35); }
.nav a .icon { opacity: .85; }
.nav a.active .icon { opacity: 1; }
.nav-pill {
  margin-left: auto; min-width: 20px; padding: 1px 6px;
  border-radius: 999px; background: var(--danger); color: #fff;
  font-size: .68rem; font-weight: 700; text-align: center;
}
.nav a.active .nav-pill { background: #ffffff2e; }

.sidebar-foot { padding: 12px; border-top: 1px solid #ffffff14; }
.side-user { display: flex; align-items: center; gap: 10px; padding: 6px; border-radius: 10px; }
.side-user:hover { background: #ffffff0f; }
.side-user b { color: #fff; font-size: .85rem; font-weight: 600; display: block; }
.side-user span { font-size: .73rem; color: #7d829f; }

/* --- Zone principale -------------------------------------------------- */
.main {
  flex: 1;
  min-width: 0;
  margin-left: var(--sidebar-w);
  display: flex; flex-direction: column;
}

.topbar {
  height: var(--topbar-h);
  position: sticky; top: 0; z-index: 40;
  display: flex; align-items: center; gap: 12px;
  padding: 0 20px;
  background: color-mix(in srgb, var(--surface) 88%, transparent);
  backdrop-filter: saturate(180%) blur(12px);
  border-bottom: 1px solid var(--border);
}
.topbar h1 { font-size: 1.06rem; margin: 0; font-weight: 650; }
.topbar .sub { color: var(--text-3); font-size: .78rem; }
.topbar-actions { margin-left: auto; display: flex; align-items: center; gap: 8px; }

.icon-btn {
  width: 38px; height: 38px; flex: 0 0 auto;
  display: grid; place-items: center;
  border: 1px solid var(--border); border-radius: 10px;
  background: var(--surface); color: var(--text-2);
  cursor: pointer; position: relative;
  transition: background .15s, color .15s, border-color .15s;
}
.icon-btn:hover { background: var(--surface-3); color: var(--text); }
.icon-btn .dot {
  position: absolute; top: 7px; right: 7px;
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--danger); border: 2px solid var(--surface);
}
.hamburger { display: none; }

.content { padding: 22px 20px 40px; max-width: 1560px; width: 100%; }

/* =====================================================================
   COMPOSANTS
   ===================================================================== */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-1);
}
.card + .card { margin-top: 16px; }
.card-head {
  display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
  padding: 15px 18px; border-bottom: 1px solid var(--border);
}
.card-head h2, .card-head h3 { margin: 0; }
.card-head .spacer { margin-left: auto; }
.card-body { padding: 18px; }
.card-body.tight { padding: 12px 14px; }
.card-foot { padding: 12px 18px; border-top: 1px solid var(--border); background: var(--surface-2); border-radius: 0 0 var(--radius) var(--radius); }
.muted { color: var(--text-3); }
.text-2 { color: var(--text-2); }
.center { text-align: center; }
.right { text-align: right; }
.nowrap { white-space: nowrap; }
.mono { font-family: var(--mono); font-size: .86em; }

/* --- Grilles ---------------------------------------------------------- */
.grid { display: grid; gap: 16px; }
.g2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.g3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.g4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.g-2-1 { grid-template-columns: minmax(0, 2fr) minmax(0, 1fr); }
.g-1-2 { grid-template-columns: minmax(0, 1fr) minmax(0, 2fr); }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.row.tight { gap: 6px; }
.stack { display: flex; flex-direction: column; gap: 14px; }
.spacer { margin-left: auto; }

/* --- Tuiles statistiques --------------------------------------------- */
.stat {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 15px 16px;
  box-shadow: var(--shadow-1);
  display: flex; flex-direction: column; gap: 6px;
  min-width: 0;
}
.stat-top { display: flex; align-items: center; gap: 9px; }
.stat-ico {
  width: 34px; height: 34px; border-radius: 10px;
  display: grid; place-items: center;
  background: var(--brand-soft); color: var(--brand);
}
.stat-ico.ok { background: var(--ok-soft); color: var(--ok); }
.stat-ico.warn { background: var(--warn-soft); color: var(--warn); }
.stat-ico.danger { background: var(--danger-soft); color: var(--danger); }
.stat-ico.info { background: var(--info-soft); color: var(--info); }
.stat-label { font-size: .78rem; color: var(--text-3); font-weight: 500; }
.stat-value { font-size: 1.62rem; font-weight: 700; letter-spacing: -.028em; line-height: 1.1; }
.stat-hint { font-size: .76rem; color: var(--text-3); }
.trend { font-size: .76rem; font-weight: 600; }
.trend.up { color: var(--ok); }
.trend.down { color: var(--danger); }

/* --- Boutons ---------------------------------------------------------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  padding: 9px 15px;
  border: 1px solid var(--border-strong);
  border-radius: 10px;
  background: var(--surface); color: var(--text);
  font: inherit; font-size: .875rem; font-weight: 550;
  cursor: pointer; white-space: nowrap;
  text-decoration: none;
  transition: transform .08s, box-shadow .15s, background .15s, border-color .15s;
}
.btn:hover { background: var(--surface-3); text-decoration: none; }
.btn:active { transform: translateY(1px); }
.btn:disabled, .btn[aria-disabled="true"] { opacity: .55; cursor: not-allowed; }
.btn-primary { background: var(--brand); border-color: var(--brand); color: #fff; box-shadow: 0 2px 8px rgba(79,70,229,.28); }
.btn-primary:hover { background: var(--brand-600); border-color: var(--brand-600); }
.btn-ok { background: var(--ok); border-color: var(--ok); color: #fff; }
.btn-ok:hover { filter: brightness(.93); }
.btn-danger { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn-danger:hover { filter: brightness(.93); }
.btn-ghost { background: transparent; border-color: transparent; color: var(--text-2); }
.btn-ghost:hover { background: var(--surface-3); color: var(--text); }
.btn-sm { padding: 6px 11px; font-size: .8rem; border-radius: 8px; }
.btn-lg { padding: 13px 22px; font-size: .97rem; border-radius: 12px; }
.btn-block { width: 100%; }

/* --- Badges & puces --------------------------------------------------- */
.badge {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 3px 9px; border-radius: 999px;
  font-size: .74rem; font-weight: 650; letter-spacing: .01em;
  white-space: nowrap;
}
.badge-ok     { background: var(--ok-soft); color: var(--ok); }
.badge-warn   { background: var(--warn-soft); color: var(--warn); }
.badge-danger { background: var(--danger-soft); color: var(--danger); }
.badge-info   { background: var(--info-soft); color: var(--info); }
.badge-muted  { background: var(--surface-3); color: var(--text-3); }
.badge-brand  { background: var(--brand-soft); color: var(--brand); }
.chip {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 4px 10px; border-radius: 999px;
  border: 1px solid var(--border); background: var(--surface-2);
  font-size: .78rem; color: var(--text-2);
}
.dot-color { width: 9px; height: 9px; border-radius: 50%; flex: 0 0 auto; }

/* --- Avatars ---------------------------------------------------------- */
.avatar {
  width: 38px; height: 38px; flex: 0 0 auto;
  border-radius: 11px; overflow: hidden;
  display: grid; place-items: center;
  color: #fff; font-weight: 650; font-size: .8rem;
  background: var(--brand);
}
.avatar img { width: 100%; height: 100%; object-fit: cover; }
.avatar.sm { width: 30px; height: 30px; border-radius: 9px; font-size: .7rem; }
.avatar.lg { width: 62px; height: 62px; border-radius: 18px; font-size: 1.25rem; }
.avatar.xl { width: 92px; height: 92px; border-radius: 24px; font-size: 1.8rem; }
.person { display: flex; align-items: center; gap: 10px; min-width: 0; }
.person b { font-weight: 600; display: block; font-size: .875rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.person span { font-size: .76rem; color: var(--text-3); display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.stack-avatars { display: flex; }
.stack-avatars .avatar { margin-left: -8px; border: 2px solid var(--surface); }
.stack-avatars .avatar:first-child { margin-left: 0; }

/* --- Tableaux --------------------------------------------------------- */
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
table.tbl { width: 100%; border-collapse: collapse; font-size: .875rem; }
table.tbl th {
  text-align: left; font-size: .72rem; font-weight: 700;
  letter-spacing: .06em; text-transform: uppercase; color: var(--text-3);
  padding: 10px 14px; border-bottom: 1px solid var(--border);
  background: var(--surface-2); white-space: nowrap; position: sticky; top: 0;
}
table.tbl td { padding: 11px 14px; border-bottom: 1px solid var(--border); vertical-align: middle; }
table.tbl tbody tr:hover { background: var(--surface-2); }
table.tbl tbody tr:last-child td { border-bottom: 0; }
table.tbl.compact td, table.tbl.compact th { padding: 7px 10px; }
.td-actions { text-align: right; white-space: nowrap; }
.empty { padding: 44px 20px; text-align: center; color: var(--text-3); }
.empty .icon { opacity: .35; margin-bottom: 8px; }
.empty b { display: block; color: var(--text-2); font-size: .95rem; margin-bottom: 3px; }

/* --- Formulaires ------------------------------------------------------ */
.field { margin-bottom: 14px; min-width: 0; }
.field > label {
  display: block; margin-bottom: 5px;
  font-size: .8rem; font-weight: 600; color: var(--text-2);
}
.field .hint { font-size: .74rem; color: var(--text-3); margin-top: 4px; }
.req { color: var(--danger); }
input[type=text], input[type=email], input[type=password], input[type=number],
input[type=date], input[type=time], input[type=datetime-local], input[type=tel],
input[type=search], input[type=month], select, textarea {
  width: 100%; padding: 9px 11px;
  border: 1px solid var(--border-strong); border-radius: var(--radius-sm);
  background: var(--surface); color: var(--text);
  font: inherit; font-size: .875rem;
  transition: border-color .15s, box-shadow .15s;
  -webkit-appearance: none; appearance: none;
}
select {
  background-image: url("data:image/svg+xml;charset=utf8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%238b91a6' stroke-width='2.2' stroke-linecap='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 10px center;
  padding-right: 30px;
}
textarea { min-height: 88px; resize: vertical; }
input:focus, select:focus, textarea:focus {
  outline: none; border-color: var(--brand);
  box-shadow: 0 0 0 3.5px color-mix(in srgb, var(--brand) 16%, transparent);
}
input[readonly], input:disabled, select:disabled, textarea:disabled {
  background: var(--surface-3); color: var(--text-3); cursor: not-allowed;
}
input[type=file] {
  width: 100%; padding: 8px; font-size: .82rem;
  border: 1px dashed var(--border-strong); border-radius: var(--radius-sm);
  background: var(--surface-2); color: var(--text-2);
}
.check { display: flex; align-items: flex-start; gap: 9px; font-size: .86rem; cursor: pointer; padding: 3px 0; }
.check input { width: 17px; height: 17px; margin: 1px 0 0; accent-color: var(--brand); flex: 0 0 auto; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0 16px; }
.form-grid.g3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.form-grid .full { grid-column: 1 / -1; }
fieldset { border: 0; padding: 0; margin: 0 0 6px; }
fieldset > legend {
  padding: 0; margin-bottom: 12px; font-size: .76rem; font-weight: 700;
  letter-spacing: .08em; text-transform: uppercase; color: var(--brand);
}
.inline-form { display: flex; gap: 8px; flex-wrap: wrap; align-items: flex-end; }
.inline-form .field { margin-bottom: 0; }
.search-box { position: relative; flex: 1 1 220px; min-width: 0; }
.search-box .icon { position: absolute; left: 10px; top: 50%; transform: translateY(-50%); color: var(--text-3); }
.search-box input { padding-left: 34px; }

/* --- Alertes ---------------------------------------------------------- */
.alert {
  display: flex; gap: 11px; align-items: flex-start;
  padding: 12px 14px; border-radius: var(--radius-sm);
  font-size: .875rem; margin-bottom: 14px;
  border: 1px solid transparent;
}
.alert-success { background: var(--ok-soft); color: var(--ok); border-color: color-mix(in srgb, var(--ok) 25%, transparent); }
.alert-error   { background: var(--danger-soft); color: var(--danger); border-color: color-mix(in srgb, var(--danger) 25%, transparent); }
.alert-warning { background: var(--warn-soft); color: var(--warn); border-color: color-mix(in srgb, var(--warn) 25%, transparent); }
.alert-info    { background: var(--info-soft); color: var(--info); border-color: color-mix(in srgb, var(--info) 25%, transparent); }
.alert b { font-weight: 650; }

/* --- Onglets ---------------------------------------------------------- */
.tabs {
  display: flex; gap: 3px; overflow-x: auto; scrollbar-width: none;
  border-bottom: 1px solid var(--border); margin-bottom: 18px;
}
.tabs::-webkit-scrollbar { display: none; }
.tabs a {
  padding: 10px 14px; font-size: .875rem; font-weight: 550;
  color: var(--text-2); border-bottom: 2px solid transparent;
  white-space: nowrap; text-decoration: none;
}
.tabs a:hover { color: var(--text); text-decoration: none; }
.tabs a.active { color: var(--brand); border-bottom-color: var(--brand); }

/* --- Barres de progression ------------------------------------------- */
.bar { height: 8px; border-radius: 999px; background: var(--surface-3); overflow: hidden; }
.bar > i { display: block; height: 100%; border-radius: 999px; background: var(--brand); transition: width .4s; }
.bar > i.ok { background: var(--ok); }
.bar > i.warn { background: var(--warn); }
.bar > i.danger { background: var(--danger); }
.bar.thin { height: 5px; }

/* --- Fenetres modales ------------------------------------------------- */
.modal-backdrop {
  position: fixed; inset: 0; z-index: 200;
  background: rgba(12,14,24,.55);
  backdrop-filter: blur(3px);
  display: none; align-items: center; justify-content: center;
  padding: 16px; overflow-y: auto;
}
.modal-backdrop.open { display: flex; }
.modal {
  background: var(--surface); border-radius: var(--radius-lg);
  box-shadow: var(--shadow-3);
  width: 100%; max-width: 560px; margin: auto;
  animation: pop .18s ease-out;
  border: 1px solid var(--border);
}
.modal.wide { max-width: 860px; }
@keyframes pop { from { opacity: 0; transform: translateY(12px) scale(.98); } }
.modal-head { display: flex; align-items: center; padding: 16px 18px; border-bottom: 1px solid var(--border); }
.modal-head h3 { margin: 0; }
.modal-head button { margin-left: auto; }
.modal-body { padding: 18px; max-height: 68vh; overflow-y: auto; }
.modal-foot { padding: 13px 18px; border-top: 1px solid var(--border); display: flex; gap: 8px; justify-content: flex-end; background: var(--surface-2); border-radius: 0 0 var(--radius-lg) var(--radius-lg); }

/* --- Bulles d aide --------------------------------------------------- */
[data-tip] { position: relative; }
[data-tip]:hover::after {
  content: attr(data-tip);
  position: absolute; bottom: 128%; left: 50%; transform: translateX(-50%);
  background: #12141f; color: #fff; padding: 5px 9px; border-radius: 7px;
  font-size: .73rem; white-space: nowrap; z-index: 90; pointer-events: none;
  box-shadow: var(--shadow-2);
}

/* =====================================================================
   POINTAGE
   ===================================================================== */
.punch-card {
  background: linear-gradient(150deg, #4f46e5 0%, #6d5ff0 45%, #0ea5e9 130%);
  border-radius: var(--radius-lg); color: #fff;
  padding: 24px 22px; text-align: center;
  box-shadow: 0 18px 40px rgba(79,70,229,.3);
  position: relative; overflow: hidden;
}
.punch-card::after {
  content: ''; position: absolute; width: 320px; height: 320px;
  right: -130px; top: -160px; border-radius: 50%;
  background: rgba(255,255,255,.09);
}
.punch-clock { font-size: 2.9rem; font-weight: 750; letter-spacing: -.04em; line-height: 1; font-variant-numeric: tabular-nums; }
.punch-date { opacity: .82; font-size: .84rem; margin-top: 4px; text-transform: capitalize; }
.punch-btn {
  width: 156px; height: 156px; margin: 20px auto 12px;
  border-radius: 50%; border: 0; cursor: pointer;
  background: #fff; color: var(--brand);
  display: grid; place-items: center; gap: 2px;
  font: inherit; font-weight: 700; font-size: 1rem;
  box-shadow: 0 12px 30px rgba(0,0,0,.22);
  transition: transform .12s, box-shadow .2s;
  position: relative; z-index: 1;
}
.punch-btn:hover { transform: scale(1.035); }
.punch-btn:active { transform: scale(.97); }
.punch-btn.out { background: #fff; color: var(--danger); }
.punch-btn:disabled { opacity: .6; cursor: progress; }
.punch-btn small { display: block; font-size: .7rem; font-weight: 600; opacity: .65; letter-spacing: .06em; text-transform: uppercase; }
.punch-btn .icon { margin-bottom: 2px; }
.punch-pulse::before {
  content: ''; position: absolute; inset: -10px; border-radius: 50%;
  border: 2px solid rgba(255,255,255,.5); animation: pulse 2.4s infinite;
}
@keyframes pulse { 0% { transform: scale(.96); opacity: .8; } 70% { transform: scale(1.16); opacity: 0; } 100% { opacity: 0; } }

.punch-meta { display: flex; justify-content: center; gap: 8px; flex-wrap: wrap; position: relative; z-index: 1; }
.punch-meta .chip { background: rgba(255,255,255,.16); border-color: rgba(255,255,255,.22); color: #fff; }
.punch-times { display: grid; grid-template-columns: repeat(3, 1fr); gap: 1px; margin-top: 18px; background: rgba(255,255,255,.2); border-radius: 12px; overflow: hidden; position: relative; z-index: 1; }
.punch-times div { background: rgba(255,255,255,.1); padding: 11px 6px; }
.punch-times b { display: block; font-size: 1.06rem; font-variant-numeric: tabular-nums; }
.punch-times span { font-size: .68rem; opacity: .8; text-transform: uppercase; letter-spacing: .06em; }

.geo-state {
  display: flex; align-items: center; justify-content: center; gap: 8px;
  font-size: .8rem; margin-top: 12px; position: relative; z-index: 1;
  padding: 7px 12px; border-radius: 999px;
  background: rgba(255,255,255,.14); color: #fff;
}
.geo-state.bad { background: rgba(220,38,38,.35); }
.geo-state.good { background: rgba(5,150,105,.35); }

/* Mini carte SVG (sans dependance externe) */
.minimap { width: 100%; height: 210px; border-radius: var(--radius-sm); background: var(--surface-3); display: block; }
.minimap-legend { display: flex; gap: 14px; flex-wrap: wrap; font-size: .76rem; color: var(--text-2); margin-top: 10px; }

/* =====================================================================
   CARTE INTERACTIVE (tuiles OpenStreetMap, composant maison)
   ===================================================================== */
.srh-map {
  position: relative; overflow: hidden;
  width: 100%; height: 340px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  background: var(--surface-3);
  cursor: crosshair;
  touch-action: none;
  user-select: none; -webkit-user-select: none;
  contain: paint;
}
.srh-map.dragging { cursor: grabbing; }
.srh-map-tiles, .srh-map-overlay { position: absolute; inset: 0; }
.srh-map-overlay { pointer-events: none; }
.srh-tile {
  position: absolute; width: 256px; height: 256px;
  pointer-events: none; -webkit-user-drag: none;
}
/* Le fond OSM est clair : on l harmonise en theme sombre */
[data-theme="dark"] .srh-tile { filter: invert(1) hue-rotate(180deg) brightness(.86) contrast(.92); }

.srh-map-pin {
  position: absolute; width: 0; height: 0;
  filter: drop-shadow(0 3px 5px rgba(0,0,0,.45));
}
.srh-map-pin svg { position: absolute; left: -15px; top: -30px; }

.srh-map-radius {
  position: absolute; border-radius: 50%;
  transform: translate(-50%, -50%);
  background: rgba(79,70,229,.16);
  border: 2px dashed #4f46e5;
  box-sizing: border-box;
}

.srh-map-static { position: absolute; width: 0; height: 0; }
.srh-map-static > i {
  position: absolute; left: -6px; top: -6px;
  width: 12px; height: 12px; border-radius: 3px;
  background: #0ea5e9; border: 2px solid #fff;
  box-shadow: 0 1px 4px rgba(0,0,0,.4);
}
.srh-map-static > span {
  position: absolute; left: 11px; top: -9px;
  padding: 1px 6px; border-radius: 5px; white-space: nowrap;
  background: rgba(14,165,233,.92); color: #fff;
  font-size: .68rem; font-weight: 600;
}

.srh-map-ctrl {
  position: absolute; top: 9px; right: 9px; z-index: 3;
  display: flex; flex-direction: column; gap: 4px;
}
.srh-map-ctrl button {
  width: 32px; height: 32px; padding: 0;
  border: 1px solid var(--border-strong); border-radius: 8px;
  background: var(--surface); color: var(--text);
  font: 600 16px/1 var(--font); cursor: pointer;
  box-shadow: var(--shadow-1);
}
.srh-map-ctrl button:hover { background: var(--surface-3); }

.srh-map-hint {
  position: absolute; left: 9px; top: 9px; z-index: 3;
  padding: 4px 9px; border-radius: 999px;
  background: color-mix(in srgb, var(--surface) 90%, transparent);
  border: 1px solid var(--border);
  font-size: .72rem; color: var(--text-2);
  max-width: calc(100% - 60px);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  pointer-events: none;
}
.srh-map-attr {
  position: absolute; right: 0; bottom: 0; z-index: 3;
  padding: 1px 6px; border-radius: 6px 0 0 0;
  background: rgba(255,255,255,.82); color: #333;
  font-size: .64rem;
}
.srh-map-attr a { color: #333; }
.srh-map-warn {
  position: absolute; inset: auto 9px 9px 9px; z-index: 4;
  padding: 9px 11px; border-radius: 9px;
  background: var(--warn-soft); color: var(--warn);
  border: 1px solid color-mix(in srgb, var(--warn) 30%, transparent);
  font-size: .76rem;
}

.geo-results {
  list-style: none; margin: 6px 0 0; padding: 0;
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  max-height: 168px; overflow-y: auto; background: var(--surface);
}
.geo-results:empty { display: none; }
.geo-results li {
  padding: 8px 11px; font-size: .8rem; cursor: pointer;
  border-bottom: 1px solid var(--border);
}
.geo-results li:last-child { border-bottom: 0; }
.geo-results li:hover { background: var(--brand-soft); color: var(--brand); }

@media (max-width: 860px) {
  .srh-map { height: 260px; }
}

/* Capture du visage / Face ID */
.selfie-box { position: relative; border-radius: var(--radius); overflow: hidden; background: #000; aspect-ratio: 4/3; }
.selfie-box video, .selfie-box canvas, .selfie-box img { width: 100%; height: 100%; object-fit: cover; display: block; }

/* Paire photo de reference / capture du moment.
   Les largeurs sont bornees en dur : une photo de profil ne doit jamais
   s afficher a sa taille naturelle, meme si une classe manque. */
.face-pair { display: grid; grid-template-columns: repeat(2, minmax(0, 170px)); gap: 12px; }
.face-pair.compact { grid-template-columns: repeat(2, minmax(0, 140px)); }
.face-pair.mini { grid-template-columns: repeat(2, minmax(0, 96px)); gap: 10px; }
.face-shot {
  width: 100%; max-width: 170px; aspect-ratio: 4/3;
  border-radius: var(--radius-sm);
  overflow: hidden; background: var(--surface-3);
  border: 1px solid var(--border); display: block; object-fit: cover;
}
.face-pair.compact .face-shot { max-width: 140px; }
.face-pair.mini .face-shot { max-width: 96px; }
.face-missing {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 7px; color: var(--text-3); text-align: center; padding: 10px;
  border-style: dashed; font-size: .74rem; line-height: 1.35;
}
.face-thumbs { display: inline-flex; gap: 4px; align-items: center; }
.face-thumbs img, .face-thumbs .ph {
  width: 38px; height: 38px; border-radius: 8px; object-fit: cover;
  border: 1px solid var(--border); background: var(--surface-3);
  display: grid; place-items: center; color: var(--text-3);
}
.face-thumbs button { padding: 0; border: 0; background: none; cursor: pointer; line-height: 0; }
/* Comparaison cote a cote (validation RH, controle d un pointage) */
.face-compare { display: grid; grid-template-columns: repeat(2, minmax(0, 200px)); gap: 14px; }
.face-compare.sm { grid-template-columns: repeat(2, minmax(0, 130px)); gap: 10px; }
.face-compare figure { margin: 0; min-width: 0; }
.face-compare figcaption, .face-cap {
  font-size: .72rem; color: var(--text-3); margin-bottom: 5px;
  font-weight: 600; text-transform: uppercase; letter-spacing: .05em;
}
.face-compare img {
  width: 100%; max-width: 200px; aspect-ratio: 4/3; object-fit: cover;
  border-radius: var(--radius-sm); border: 1px solid var(--border); display: block;
}
.face-compare.sm img, .face-compare.sm .face-shot { max-width: 130px; }
.face-compare .face-shot { max-width: 200px; }

/* Sur telephone les vignettes restent cote a cote et petites : les
   empiler en pleine largeur donnait des portraits enormes. */
@media (max-width: 860px) {
  .face-pair { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .face-pair .face-shot { max-width: 100%; }
  .face-pair.mini { grid-template-columns: repeat(2, minmax(0, 92px)); }
  .face-pair.mini .face-shot { max-width: 92px; }
  .face-compare { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .face-compare img, .face-compare .face-shot { max-width: 100%; }
  .face-compare.sm { grid-template-columns: repeat(2, minmax(0, 120px)); }
  .face-compare.sm img, .face-compare.sm .face-shot { max-width: 120px; }
}

/* =====================================================================
   CALENDRIER / PLANNING
   ===================================================================== */
.cal { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 5px; }
.cal-head {
  font-size: .7rem; font-weight: 700; text-transform: uppercase;
  letter-spacing: .06em; color: var(--text-3); text-align: center; padding: 5px 0;
}
.cal-cell {
  min-height: 82px; border: 1px solid var(--border); border-radius: 9px;
  padding: 5px 6px; background: var(--surface); font-size: .76rem;
  display: flex; flex-direction: column; gap: 3px; overflow: hidden;
}
.cal-cell.dim { background: var(--surface-2); color: var(--text-3); }
.cal-cell.rest { background: var(--surface-3); }
.cal-cell.today { border-color: var(--brand); box-shadow: 0 0 0 2px color-mix(in srgb, var(--brand) 18%, transparent); }
.cal-cell > b { font-size: .8rem; font-weight: 650; }
.cal-ev {
  font-size: .68rem; padding: 2px 5px; border-radius: 5px;
  background: var(--brand-soft); color: var(--brand); font-weight: 600;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}

/* Barre de charge horaire (planning) */
.timeline { position: relative; height: 26px; background: var(--surface-3); border-radius: 6px; overflow: hidden; }
.timeline i { position: absolute; top: 0; bottom: 0; background: var(--brand); opacity: .85; }
.timeline i.actual { background: var(--ok); top: 50%; bottom: 0; opacity: 1; }
.timeline i.planned { bottom: 50%; }

/* =====================================================================
   KANBAN (recrutement)
   ===================================================================== */
.kanban { display: flex; gap: 12px; overflow-x: auto; padding-bottom: 10px; align-items: flex-start; }
.kan-col { flex: 0 0 262px; background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius); }
.kan-head { padding: 11px 13px; border-bottom: 1px solid var(--border); display: flex; align-items: center; gap: 8px; font-size: .82rem; font-weight: 650; }
.kan-head .badge { margin-left: auto; }
.kan-body { padding: 9px; display: flex; flex-direction: column; gap: 8px; min-height: 70px; }
.kan-card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius-sm); padding: 10px 11px;
  box-shadow: var(--shadow-1); font-size: .82rem;
}
.kan-card b { display: block; font-size: .875rem; }
.kan-card .row { margin-top: 7px; }

/* =====================================================================
   DIVERS
   ===================================================================== */
.stars { display: inline-flex; gap: 2px; color: var(--warn); }
.stars .off { color: var(--border-strong); }

.timeline-list { list-style: none; margin: 0; padding: 0 0 0 22px; position: relative; }
.timeline-list::before { content: ''; position: absolute; left: 5px; top: 6px; bottom: 6px; width: 2px; background: var(--border); }
.timeline-list li { position: relative; padding: 0 0 15px; font-size: .85rem; }
.timeline-list li::before {
  content: ''; position: absolute; left: -21px; top: 5px;
  width: 10px; height: 10px; border-radius: 50%;
  background: var(--surface); border: 2px solid var(--brand);
}
.timeline-list li.ok::before { border-color: var(--ok); background: var(--ok); }
.timeline-list li.danger::before { border-color: var(--danger); background: var(--danger); }
.timeline-list li.pending::before { border-color: var(--warn); }
.timeline-list time { display: block; font-size: .73rem; color: var(--text-3); }

.notif-item { display: flex; gap: 11px; padding: 12px 14px; border-bottom: 1px solid var(--border); }
.notif-item.unread { background: var(--brand-soft); }
.notif-item .stat-ico { width: 30px; height: 30px; }
.notif-item b { font-size: .86rem; }
.notif-item p { margin: 2px 0 0; font-size: .8rem; color: var(--text-2); }
.notif-item time { font-size: .72rem; color: var(--text-3); }

.sig-pad {
  width: 100%; height: 190px; touch-action: none;
  border: 2px dashed var(--border-strong); border-radius: var(--radius-sm);
  background: var(--surface-2); display: block; cursor: crosshair;
}
.sig-preview { max-width: 240px; border: 1px solid var(--border); border-radius: 8px; background: #fff; padding: 6px; }

.doc-tile { display: flex; gap: 12px; align-items: center; padding: 12px 14px; border-bottom: 1px solid var(--border); }
.doc-ico { width: 40px; height: 40px; border-radius: 10px; display: grid; place-items: center; background: var(--surface-3); color: var(--text-2); font-size: .68rem; font-weight: 700; }

/* Bulletin de paie */
.slip { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; }
.slip-head { padding: 20px; background: var(--surface-2); border-bottom: 1px solid var(--border); display: flex; gap: 18px; flex-wrap: wrap; }
.slip-net { margin-left: auto; text-align: right; }
.slip-net b { display: block; font-size: 1.75rem; font-weight: 750; letter-spacing: -.03em; color: var(--ok); }
.slip table { width: 100%; border-collapse: collapse; font-size: .86rem; }
.slip th { text-align: left; padding: 9px 20px; font-size: .7rem; text-transform: uppercase; letter-spacing: .06em; color: var(--text-3); background: var(--surface-2); }
.slip td { padding: 9px 20px; border-bottom: 1px solid var(--border); }
.slip tr.total td { font-weight: 700; background: var(--surface-2); }

/* Organigramme */
.org { display: flex; flex-direction: column; gap: 8px; }
.org-node { border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 9px 11px; background: var(--surface); }
.org-children { margin-left: 22px; padding-left: 14px; border-left: 2px dashed var(--border); display: flex; flex-direction: column; gap: 8px; margin-top: 8px; }

/* Connexion */
.login-wrap { min-height: 100vh; display: grid; grid-template-columns: 1fr 1fr; }
.login-side {
  background: linear-gradient(160deg, #14162b 0%, #2c2a6b 55%, #4f46e5 130%);
  color: #fff; padding: 46px; display: flex; flex-direction: column; justify-content: space-between;
  position: relative; overflow: hidden;
}
.login-side::after {
  content: ''; position: absolute; width: 460px; height: 460px; border-radius: 50%;
  right: -180px; bottom: -200px; background: rgba(255,255,255,.07);
}
.login-side h2 { font-size: 1.85rem; letter-spacing: -.03em; max-width: 15em; }
.login-side ul { list-style: none; padding: 0; margin: 22px 0 0; display: flex; flex-direction: column; gap: 11px; position: relative; z-index: 1; }
.login-side li { display: flex; gap: 10px; align-items: center; font-size: .9rem; color: #cfd2e8; }
.login-side li .icon { color: #a5b4fc; }
.login-form { display: grid; place-items: center; padding: 34px 20px; }
.login-form-inner { width: 100%; max-width: 380px; }
.demo-accounts { margin-top: 18px; border-top: 1px solid var(--border); padding-top: 14px; }
.demo-accounts button {
  width: 100%; text-align: left; padding: 8px 11px; margin-bottom: 6px;
  border: 1px solid var(--border); border-radius: 9px; background: var(--surface-2);
  cursor: pointer; font: inherit; font-size: .8rem; color: var(--text-2);
  display: flex; align-items: center; gap: 8px;
}
.demo-accounts button:hover { border-color: var(--brand); color: var(--text); }

/* Navigation basse mobile */
.mobile-nav { display: none; }

/* Impression */
@media print {
  .sidebar, .topbar, .mobile-nav, .no-print { display: none !important; }
  .main { margin: 0; }
  .content { padding: 0; }
  body { background: #fff; }
  .card, .slip { box-shadow: none; border-color: #ddd; }
}

/* =====================================================================
   ADAPTATIF
   ===================================================================== */
@media (max-width: 1280px) {
  .g4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 1080px) {
  .g3, .g-2-1, .g-1-2 { grid-template-columns: minmax(0, 1fr); }
}

@media (max-width: 860px) {
  :root { --topbar-h: 56px; }

  .sidebar {
    transform: translateX(-100%);
    transition: transform .24s ease;
    box-shadow: var(--shadow-3);
    width: 280px; flex-basis: 280px;
  }
  body.nav-open .sidebar { transform: none; }
  body.nav-open::after {
    content: ''; position: fixed; inset: 0; z-index: 55;
    background: rgba(10,12,22,.5);
  }
  .main { margin-left: 0; }
  .hamburger { display: grid; }
  .content { padding: 16px 14px 96px; }

  .g2, .g4, .form-grid, .form-grid.g3 { grid-template-columns: minmax(0, 1fr); }
  .topbar { padding: 0 12px; }
  .topbar h1 { font-size: .97rem; }
  .topbar .sub { display: none; }
  h1 { font-size: 1.28rem; }

  .card-head { padding: 13px 14px; }
  .card-body { padding: 14px; }
  .modal-body { max-height: 62vh; }

  /* Tableaux -> cartes empilees */
  table.tbl.responsive thead { display: none; }
  table.tbl.responsive, table.tbl.responsive tbody,
  table.tbl.responsive tr, table.tbl.responsive td { display: block; width: 100%; }
  table.tbl.responsive tr {
    border: 1px solid var(--border); border-radius: var(--radius-sm);
    margin-bottom: 9px; padding: 5px 2px; background: var(--surface);
  }
  table.tbl.responsive td {
    border: 0; padding: 6px 12px;
    display: flex; align-items: center; justify-content: space-between; gap: 12px;
  }
  table.tbl.responsive td::before {
    content: attr(data-label);
    font-size: .7rem; font-weight: 700; letter-spacing: .05em;
    text-transform: uppercase; color: var(--text-3);
    flex: 0 0 auto;
  }
  table.tbl.responsive td[data-label=""]::before,
  table.tbl.responsive td.no-label::before { content: none; }
  table.tbl.responsive td.td-actions { justify-content: flex-end; border-top: 1px solid var(--border); margin-top: 4px; padding-top: 9px; }

  /* Navigation basse */
  .mobile-nav {
    display: flex; position: fixed; z-index: 50;
    inset: auto 0 0 0; height: 62px;
    background: color-mix(in srgb, var(--surface) 94%, transparent);
    backdrop-filter: saturate(180%) blur(10px);
    border-top: 1px solid var(--border);
    padding-bottom: env(safe-area-inset-bottom);
  }
  .mobile-nav a {
    flex: 1; display: flex; flex-direction: column; align-items: center;
    justify-content: center; gap: 2px;
    font-size: .66rem; font-weight: 600; color: var(--text-3);
    text-decoration: none; position: relative;
  }
  .mobile-nav a.active { color: var(--brand); }
  .mobile-nav a.punch {
    flex: 0 0 68px;
  }
  .mobile-nav a.punch .icon-wrap {
    width: 48px; height: 48px; border-radius: 50%; margin-top: -20px;
    background: var(--brand); color: #fff; display: grid; place-items: center;
    box-shadow: 0 6px 18px rgba(79,70,229,.45); border: 3px solid var(--surface);
  }
  .mobile-nav .nav-pill { position: absolute; top: 6px; right: 22%; }

  .punch-btn { width: 138px; height: 138px; }
  .punch-clock { font-size: 2.4rem; }
  .login-wrap { grid-template-columns: 1fr; }
  .login-side { display: none; }
  .cal { gap: 3px; }
  .cal-cell { min-height: 62px; font-size: .68rem; padding: 3px; }
  .kan-col { flex-basis: 84vw; }
  .slip-head { padding: 14px; }
  .slip th, .slip td { padding: 8px 12px; }
  .btn { padding: 9px 13px; }
  .inline-form { gap: 8px; }
  .inline-form > * { flex: 1 1 100%; }
  .inline-form .btn { flex: 0 0 auto; }
}

@media (max-width: 420px) {
  .stat-value { font-size: 1.4rem; }
  .avatar.xl { width: 72px; height: 72px; font-size: 1.5rem; }
  .punch-times b { font-size: .95rem; }
}

/* Accessibilite : reduction des animations */
@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; transition: none !important; }
}
