:root {
  --bg: #f4f6fb; --card: #fff; --text: #1a2233; --muted: #6b7489; --border: #e1e5ee;
  --primary: #1f4fd1; --primary-d: #183fa8; --accent: #e8590c; --ok: #13804b; --ok-bg: #e5f6ec;
  --warn: #9a6200; --warn-bg: #fff4dc; --danger: #c22c2c; --danger-bg: #fde8e8;
  --radius: 14px;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #10141d; --card: #1a202c; --text: #e7ebf3; --muted: #97a0b3; --border: #2c3444;
    --primary: #4d7cff; --primary-d: #3a66e0; --ok-bg: #12301f; --ok: #5bd08d; --warn-bg: #352a10; --warn: #f0be55;
    --danger-bg: #3a1717; --danger: #ff7a7a;
  }
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; font: 15px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; background: var(--bg); color: var(--text); }
a { color: var(--primary); }
h1, h2, h3 { line-height: 1.2; margin: 0 0 .5rem; }
h1 { font-size: 1.6rem; } h2 { font-size: 1.25rem; } h3 { font-size: 1.05rem; margin-top: 1.5rem; }

.topbar { display: flex; justify-content: space-between; align-items: center; gap: 1rem; padding: .75rem 1rem;
  background: var(--card); border-bottom: 1px solid var(--border); position: sticky; top: 0; z-index: 5; }
.brand { display: flex; align-items: center; gap: .5rem; font-weight: 700; }
.userbox { display: flex; align-items: center; gap: .75rem; font-size: .9rem; }
.userbox[hidden] { display: none; }

.container { max-width: 1000px; margin: 0 auto; padding: 1rem; }
.card { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); padding: 1.25rem; margin-bottom: 1rem; }
.muted { color: var(--muted); } .small { font-size: .85rem; }

.tabs { display: flex; gap: .25rem; overflow-x: auto; margin-bottom: 1rem; scrollbar-width: none; }
.tabs a { padding: .5rem .9rem; border-radius: 999px; text-decoration: none; color: var(--muted); white-space: nowrap; font-weight: 500; }
.tabs a.active { background: var(--primary); color: #fff; }

.form { display: grid; gap: .9rem; }
label { display: grid; gap: .3rem; font-weight: 500; font-size: .9rem; flex: 1; min-width: 140px; }
label.inline { display: flex; align-items: center; gap: .4rem; flex: 0 0 auto; min-width: 0; }
input { font: inherit; padding: .6rem .75rem; border: 1px solid var(--border); border-radius: 10px; background: var(--bg); color: var(--text); width: 100%; }
label.inline input { width: auto; }
input:focus { outline: 2px solid var(--primary); outline-offset: 1px; }

/* Champ mot de passe avec bouton « œil » */
.pw-wrap { position: relative; display: block; }
.pw-wrap input { padding-right: 2.9rem; }
.pw-toggle { position: absolute; right: .3rem; top: 50%; transform: translateY(-50%); width: 2.4rem; height: 2.4rem;
  display: grid; place-items: center; border: 0; background: transparent; color: var(--muted); cursor: pointer; border-radius: 8px; }
.pw-toggle:hover, .pw-toggle[aria-pressed="true"] { color: var(--primary); }
.pw-toggle:focus-visible { outline: 2px solid var(--primary); }
.hint { margin: -.5rem 0 0; }

/* Code de vérification */
.code-input { font-size: 1.8rem; letter-spacing: .5em; text-align: center; font-variant-numeric: tabular-nums; padding-left: 1rem; }
.link:disabled { color: var(--muted); cursor: default; }

.btn { font: inherit; font-weight: 600; border: 1px solid var(--border); background: var(--card); color: var(--text);
  padding: .6rem 1rem; border-radius: 10px; cursor: pointer; text-decoration: none; display: inline-block; text-align: center; }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn.primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn.primary:hover:not(:disabled) { background: var(--primary-d); }
.btn.accent { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.danger { color: var(--danger); border-color: var(--danger); }
.btn.ghost { background: transparent; }
.btn.small { padding: .35rem .7rem; font-size: .85rem; }
.btn.big { width: 100%; padding: 1.1rem; font-size: 1.15rem; border-radius: var(--radius); margin: 1rem 0; }
.link { background: none; border: 0; color: var(--primary); font: inherit; font-weight: 600; cursor: pointer; padding: 0; }

.row { display: flex; align-items: center; gap: .75rem; }
.row.wrap { flex-wrap: wrap; align-items: flex-end; margin-bottom: 1rem; }
.row.between { justify-content: space-between; flex-wrap: wrap; }
.row.between input { width: auto; }

.auth { max-width: 420px; margin: 2rem auto; }
.switch { text-align: center; margin: 1rem 0 0; }

.punch { max-width: 480px; margin: 0 auto 1rem; text-align: center; }
.clock { font-size: 2.6rem; font-weight: 700; font-variant-numeric: tabular-nums; margin: .5rem 0 1rem; }
.status-grid { display: grid; grid-template-columns: 1fr 1fr; gap: .75rem; }
.status { border: 1px solid var(--border); border-radius: 12px; padding: .75rem; display: grid; }
.status span { color: var(--muted); font-size: .85rem; }
.status strong { font-size: 1.3rem; }
.status.done { background: var(--ok-bg); border-color: transparent; }
.status.done strong { color: var(--ok); }
.status-grid.three { grid-template-columns: repeat(3, 1fr); gap: .5rem; }
.status.on-break { background: var(--warn-bg); border-color: transparent; }
.status.on-break strong { color: var(--warn); }

/* Pauses */
.punch-actions { display: grid; gap: .6rem; margin: 1rem 0; }
.punch-actions .btn.big { margin: 0; }
.btn.pause { background: var(--warn-bg); border-color: var(--warn); color: var(--warn); }
.break-box { background: var(--warn-bg); color: var(--warn); border-radius: var(--radius); padding: .8rem; display: grid; gap: .2rem; }
.break-box > strong { font-size: 2rem; font-variant-numeric: tabular-nums; }
.break-box .expected { font-size: 1.1rem; }
.break-box.overdue { background: var(--danger-bg); color: var(--danger); }
.break-list { list-style: none; padding: 0; margin: .75rem 0 0; font-size: .9rem; text-align: left; }
.break-list li { padding: .2rem 0; border-bottom: 1px dashed var(--border); }
.badge.pause { background: var(--warn-bg); color: var(--warn); border-color: transparent; }
.badge.ok { background: var(--ok-bg); color: var(--ok); border-color: transparent; }
.toast.warn { background: var(--warn); color: #fff; }

.alert { padding: .75rem 1rem; border-radius: 10px; text-align: left; }
.alert.ok { background: var(--ok-bg); color: var(--ok); }
.alert.warn { background: var(--warn-bg); color: var(--warn); }

.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); gap: .75rem; margin: 1rem 0; }
.kpis div { border: 1px solid var(--border); border-radius: 12px; padding: .75rem; display: grid; }
.kpis strong { font-size: 1.6rem; }
.kpis span { color: var(--muted); font-size: .85rem; }

.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: .92rem; }
th, td { text-align: left; padding: .55rem .6rem; border-bottom: 1px solid var(--border); vertical-align: top; }
th { color: var(--muted); font-weight: 600; font-size: .8rem; text-transform: uppercase; letter-spacing: .02em; }
tr.absent td { color: var(--muted); }
td.actions { white-space: nowrap; display: flex; gap: .4rem; }

.badge { display: inline-block; padding: .1rem .5rem; border-radius: 999px; font-size: .75rem; font-weight: 600; background: var(--bg); border: 1px solid var(--border); margin: 0 .2rem .2rem 0; }
.badge.warn { background: var(--warn-bg); color: var(--warn); border-color: transparent; }
.badge.danger { background: var(--danger-bg); color: var(--danger); border-color: transparent; }

.toast { position: fixed; left: 50%; bottom: 1.25rem; transform: translateX(-50%); max-width: min(92vw, 520px);
  padding: .8rem 1.1rem; border-radius: 12px; background: var(--text); color: var(--bg); box-shadow: 0 8px 24px rgba(0,0,0,.2); z-index: 10; }
.toast.ok { background: var(--ok); color: #fff; }
.toast.error { background: var(--danger); color: #fff; }
.toast[hidden] { display: none; }

/* ---------- Panneau d'administration ---------- */
.brand-tag { font-size: .75rem; font-weight: 600; color: #fff; background: var(--primary); padding: .15rem .5rem; border-radius: 999px; margin-left: .25rem; }
.admin-layout { display: flex; max-width: 1280px; margin: 0 auto; gap: 1rem; padding: 0 1rem; }
.sidenav { flex: 0 0 200px; display: flex; flex-direction: column; gap: .25rem; padding-top: 1rem; position: sticky; top: 60px; align-self: flex-start; }
.sidenav[hidden] { display: none; }
.sidenav a { padding: .6rem .9rem; border-radius: 10px; text-decoration: none; color: var(--text); font-weight: 500; }
.sidenav a:hover { background: var(--card); }
.sidenav a.active { background: var(--primary); color: #fff; }
.admin-main { flex: 1; min-width: 0; max-width: none; padding: 1rem 0; }
.admin td a { font-weight: 600; text-decoration: none; }
.admin td a:hover { text-decoration: underline; }
tr.selected td { background: var(--bg); }
select { font: inherit; padding: .45rem .6rem; border: 1px solid var(--border); border-radius: 10px; background: var(--bg); color: var(--text); }
input[type=search] { width: auto; min-width: 240px; }
fieldset.days { border: 1px solid var(--border); border-radius: 10px; display: flex; flex-wrap: wrap; gap: .5rem 1rem; padding: .6rem .9rem; margin: 0; }
fieldset.days legend { font-weight: 500; font-size: .9rem; padding: 0 .3rem; }
label.check { display: flex; align-items: center; gap: .35rem; flex: 0 0 auto; min-width: 0; font-weight: 400; text-transform: capitalize; }
label.check input { width: auto; }
details { margin-top: 1rem; }
details summary { cursor: pointer; font-weight: 600; }
.print-head, .print-foot { display: none; }
table.synthesis td, table.synthesis th { white-space: nowrap; }
table.synthesis td:first-child { white-space: normal; }

@media (max-width: 860px) {
  .admin-layout { flex-direction: column; padding: 0; gap: 0; }
  .sidenav { flex: 0 0 auto; flex-direction: row; overflow-x: auto; position: static; padding: .75rem .75rem 0; scrollbar-width: none; width: 100%; }
  .sidenav a { white-space: nowrap; }
  .admin-main { padding: .75rem; margin: 0; width: 100%; }
  input[type=search] { min-width: 0; width: 100%; }
}

/* Impression / PDF de la synthèse RH */
@media print {
  body { background: #fff; color: #000; font-size: 11pt; }
  .topbar, .sidenav, .no-print, .toast, .alert, p:has(> a[href="#/employees"]) { display: none !important; }
  .admin-layout, .admin-main { display: block; padding: 0; margin: 0; }
  .card { border: 0; padding: 0; }
  .print-head, .print-foot { display: block; }
  .print-head h1 { font-size: 16pt; margin-bottom: .2rem; }
  .kpis div { border: 1px solid #999; }
  th, td { border-bottom: 1px solid #bbb; color: #000; }
  .badge { border: 1px solid #999; background: none !important; color: #000 !important; }
  a { color: #000; text-decoration: none; }
  .muted { color: #444; }
  table { font-size: 10pt; }
}

@media (max-width: 600px) {
  .container { padding: .75rem; }
  .card { padding: 1rem; }
  .userbox #username { display: none; }
}
