:root {
    --ink: #253856;
    --muted: #6b6b6b;
    --line: #d5e2ef;
    --bg: #e3ecf5;
    --card: #ffffff;
    --green: #0c8f62;
    --green-soft: #e5f6ee;
    --amber: #9a6700;
    --amber-soft: #fff4dc;
    --red: #b42318;
    --red-soft: #fdecea;
    --blue: #428dc9;
    --navy: #253856;
    --sky: #428dc9;
    --shadow: 0 16px 40px rgba(37, 56, 86, 0.12);
    font-family: "Segoe UI", sans-serif;
    color: var(--ink);
}

* { box-sizing: border-box; }
body { margin: 0; }
button, input, select { font: inherit; }
a { color: var(--blue); }

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 999px;
    border: 1px solid transparent;
    padding: 0.65rem 1rem;
    text-decoration: none;
    cursor: pointer;
    background: #fff;
    color: var(--ink);
}
.btn-primary { background: var(--navy); color: #fff; }
.btn-primary:hover { background: var(--sky); }
.btn-ghost { border-color: var(--line); background: transparent; color: inherit; }
.btn-danger { background: transparent; color: var(--red); border-color: #f0c3bf; }
.btn:disabled { opacity: 0.45; cursor: not-allowed; }

.brand-elaraki { display: flex; align-items: center; justify-content: center; gap: 14px; }
.brand-elaraki-texte { display: grid; gap: 2px; text-align: left; }
.brand-elaraki-texte strong { font-size: 1.35rem; letter-spacing: 0.08em; color: #fff; }
.campus-nom { font-size: 1.05rem; font-weight: 700; color: var(--sky); letter-spacing: 0.04em; }
.logo-elaraki { width: min(160px, 42vw); height: auto; display: block; }
.brand-login .logo-elaraki { width: min(180px, 55vw); margin: 0 auto 8px; }
.slogan-elaraki { margin: 10px 0 0; color: rgba(255,255,255,.82); font-size: 0.95rem; max-width: 34rem; margin-inline: auto; line-height: 1.35; }
.slogan-elaraki em { color: var(--sky); font-style: normal; font-weight: 700; }
.slogan-login { color: var(--muted); margin: 0 0 14px; }
.campus-nom-login { margin: 0 0 8px; color: var(--sky); font-weight: 700; }

.kiosk {
    min-height: 100vh;
    background:
        radial-gradient(900px 420px at 100% -10%, rgba(66, 141, 201, 0.28), transparent 55%),
        linear-gradient(160deg, #1a2a42 0%, #253856 48%, #1c314d 100%);
    color: #f4f7f5;
}
.kiosk-top, .kiosk-main, .kiosk-controls { width: min(1280px, calc(100% - 32px)); margin: 0 auto; }
.kiosk-top { text-align: center; padding: 10px 0 4px; }
.kiosk-clock { text-align: center; margin-top: 6px; }
.kiosk .logo-elaraki { width: min(110px, 28vw); }
.kiosk .brand-elaraki-texte strong { font-size: 1.1rem; }
.kiosk .slogan-elaraki { font-size: 0.85rem; margin-top: 6px; }
.kiosk #clock { font-size: clamp(2.8rem, 7vw, 5.2rem); }
.kiosk .phase { font-size: clamp(1.1rem, 2.4vw, 1.7rem); margin-top: 4px; }
.kiosk-lieu { margin: 8px 0 0; color: #8ea197; letter-spacing: 0.08em; text-transform: uppercase; }
.kiosk-actions { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; margin-top: 12px; }
.kiosk-actions form { margin: 0; }
.campus-choix { min-height: 100vh; display: grid; align-content: center; justify-items: center; gap: 18px; padding: 32px 16px; text-align: center; }
.campus-choix h1 { margin: 0; font-size: clamp(2rem, 4vw, 3rem); }
.campus-login { min-width: 260px; text-align: center; text-decoration: none; }
.campus-grille { display: grid; grid-template-columns: repeat(2, minmax(180px, 280px)); gap: 16px; margin-top: 10px; }
.campus-bloc { display: grid; gap: 8px; }
.campus-carte { display: grid; place-items: center; min-height: 120px; padding: 18px; border-radius: 22px; background: #172028; color: #f4f7f5; text-decoration: none; font-size: 1.45rem; font-weight: 700; border: 1px solid rgba(255,255,255,.08); }
.campus-admin { color: #d5e0da; text-decoration: none; font-size: 0.95rem; }
.campus-admin:hover { color: #3DDC97; }
.campus-carte:hover { border-color: #3DDC97; color: #3DDC97; }
.filtre-campus { margin-top: 8px; }
.filtre-campus select { background: #fff; color: var(--ink); min-width: 180px; }
#clock { font-size: clamp(4.4rem, 10vw, 8rem); font-weight: 750; line-height: 0.92; font-variant-numeric: tabular-nums; letter-spacing: -0.04em; }
.phase { margin-top: 8px; font-size: clamp(1.7rem, 3.4vw, 2.6rem); font-weight: 750; letter-spacing: 0.16em; }
#today { color: #b7c4bc; margin-top: 4px; }
.kiosk-clock.is-entree #clock, .kiosk-clock.is-entree .phase { color: #5fd0a5; }
.kiosk-clock.is-sortie #clock, .kiosk-clock.is-sortie .phase { color: #7eb6ff; }
.kiosk-clock.is-hors #clock, .kiosk-clock.is-hors .phase { color: #ff8a7a; }
.eyebrow { margin: 0; letter-spacing: 0.14em; text-transform: uppercase; font-size: 0.75rem; color: var(--sky); }
.kiosk h1 { margin: 4px 0 0; font-size: 1.8rem; font-weight: 650; }
.kiosk-main {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 16px;
    align-items: stretch;
    padding-bottom: 12px;
}
.kiosk-zone {
    min-width: 0;
    height: min(52vh, 420px);
    background: #172028;
    border: 1px solid rgba(255,255,255,.08);
    border-radius: 24px;
    overflow: hidden;
}
.stage { padding: 0; background: #000; }
.stage-frame { position: relative; width: 100%; height: 100%; background: #000; border-radius: 24px; overflow: hidden; box-shadow: none; aspect-ratio: auto; }
.stage-media { position: absolute; inset: 0; transform: scaleX(-1); }
.stage-media video, .stage-media canvas { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.face-guide {
    position: absolute; z-index: 2; left: 50%; top: 46%;
    width: min(34%, 160px); aspect-ratio: 3 / 3.8;
    transform: translate(-50%, -52%);
    border: 3px solid rgba(61, 220, 151, 0.95);
    border-radius: 46% 46% 42% 42%;
    box-shadow: 0 0 0 999px rgba(0, 0, 0, 0.28);
    pointer-events: none;
}
.face-guide span {
    position: absolute; left: 50%; bottom: -36px; transform: translateX(-50%);
    white-space: nowrap; font-size: 0.8rem; padding: 5px 10px; border-radius: 999px;
    background: rgba(8, 12, 16, 0.82);
}
.stage-status { position: absolute; z-index: 3; left: 12px; right: 12px; bottom: 12px; margin: 0; padding: 8px 12px; border-radius: 12px; background: rgba(8, 12, 16, 0.72); font-size: 0.9rem; }
.presents-panel { display: flex; flex-direction: column; }
.presents-head {
    display: flex; align-items: center; justify-content: space-between; gap: 8px;
    padding: 12px 14px; border-bottom: 1px solid rgba(255,255,255,.08); flex-shrink: 0;
}
.presents-head h2 { margin: 0; font-size: 1rem; letter-spacing: 0.04em; }
.presents-count {
    min-width: 28px; height: 28px; padding: 0 8px; border-radius: 999px;
    display: grid; place-items: center; background: var(--sky); color: #fff; font-weight: 700; font-size: 0.9rem;
}
.presents-list {
    flex: 1; min-height: 0; overflow-y: auto; overflow-x: hidden;
    padding: 10px; display: grid; gap: 8px; align-content: start;
    scrollbar-width: thin; scrollbar-color: #428dc9 transparent;
}
.presents-list::-webkit-scrollbar { width: 8px; }
.presents-list::-webkit-scrollbar-thumb { background: #428dc9; border-radius: 8px; }
.presents-empty { margin: 18px 8px; color: #9aadc4; text-align: center; font-size: 0.95rem; }
.present-item {
    display: grid; grid-template-columns: 56px 1fr; gap: 10px; align-items: center;
    padding: 8px; border-radius: 14px; background: rgba(255,255,255,.04); border: 1px solid rgba(255,255,255,.06);
}
.present-photo, .present-lettre {
    width: 56px; height: 56px; border-radius: 12px; object-fit: cover; background: #243038;
}
.present-lettre { display: grid; place-items: center; font-weight: 700; color: #fff; }
.present-meta { min-width: 0; }
.present-meta strong { display: block; font-size: 0.95rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.present-heures { margin: 4px 0 0; color: #b7c4bc; font-size: 0.82rem; font-variant-numeric: tabular-nums; }
.present-heures .entree { color: #5fd0a5; }
.present-heures .sortie { color: #7eb6ff; }
.present-heures .retard { color: #ff8d86; }
.cam-row { display: flex; flex-wrap: wrap; gap: 10px; align-items: end; }
.cam-row label, .form-grid label, .inline-form label { display: grid; gap: 6px; font-size: 0.92rem; }
.kiosk select, .kiosk .btn { background: #1b242c; color: #f4f7f5; border-color: #314049; }
.kiosk-controls { display: grid; gap: 12px; padding-bottom: 24px; }
.result-panel { display: flex; flex-direction: column; min-height: 0; }
.result-idle, .result-card {
    flex: 1; min-height: 0; overflow: auto; background: transparent; border: 0; border-radius: 0;
    padding: 18px 16px; text-align: center;
}
.result-idle p { font-size: 1.05rem; margin: 12px 0 0; }
.manuel { margin: 0; }
.manuel > .btn { width: auto; }
.hint { color: #b7c4bc; font-size: 0.95rem !important; }
.hint.warn { color: #ffd089; }
.pulse { width: 74px; height: 74px; margin: 0 auto; border-radius: 50%; border: 2px solid rgba(61,220,151,.8); box-shadow: 0 0 0 0 rgba(61,220,151,.45); animation: pulse 1.8s infinite; }
@keyframes pulse { 70% { box-shadow: 0 0 0 16px rgba(61,220,151,0); } 100% { box-shadow: 0 0 0 0 rgba(61,220,151,0); } }
.mark { width: 112px; height: 112px; margin: 0 auto 8px; }
.result-photo, .result-lettre { width: 148px; height: 148px; margin: 12px auto 4px; border-radius: 24px; object-fit: cover; display: block; border: 3px solid #3DDC97; }
.result-photo[hidden], .result-lettre[hidden] { display: none; }
.result-lettre { display: grid; place-items: center; font-size: 2.4rem; font-weight: 700; background: #243038; color: #fff; }
.result-card.is-warn .result-photo, .result-card.is-warn .result-lettre { border-color: #f0b429; }
.result-card.is-bad .result-photo, .result-card.is-bad .result-lettre { border-color: #f07167; }
.result-parole { margin: 8px 0 0; font-size: 1.15rem; line-height: 1.45; }
.mark svg { width: 100%; height: 100%; fill: none; stroke: #3DDC97; stroke-width: 4; stroke-linecap: round; stroke-linejoin: round; }
.mark path { stroke-dasharray: 60; stroke-dashoffset: 60; animation: draw .45s ease forwards; }
.result-card.is-warn .mark svg { stroke: #f0b429; }
.result-card.is-bad .mark svg { stroke: #f07167; }
.result-title { margin: 0; letter-spacing: 0.12em; text-transform: uppercase; color: #8ea197; }
.result-card h2 { margin: 8px 0; font-size: 2rem; }
.result-time { margin: 0; font-size: 3.4rem; font-variant-numeric: tabular-nums; letter-spacing: -0.04em; }
.kiosk .result-time.heure-ok { color: #3DDC97; }
.kiosk .result-time.heure-retard { color: #ff8d86; }
.result-detail { color: #d5e0da; }
@keyframes draw { to { stroke-dashoffset: 0; } }

.login-body {
    min-height: 100vh;
    display: grid;
    place-items: center;
    background:
        radial-gradient(700px 320px at 10% 0%, rgba(66, 141, 201, 0.22), transparent 60%),
        linear-gradient(165deg, #e3ecf5 0%, #f7fafc 55%, #dbe7f3 100%);
}
.login-card { width: min(440px, calc(100% - 32px)); background: var(--card); border-radius: 24px; padding: 32px; box-shadow: var(--shadow); border-top: 4px solid var(--sky); }
.login-card h1 { margin: 0 0 8px; }
.lead { color: var(--muted); }
.login-card form, .form-grid { display: grid; gap: 14px; }
.hint-box, .flash { border-radius: 12px; padding: 12px 14px; margin: 12px 0; }
.hint-box { background: var(--amber-soft); color: #6d4b00; }
.flash-ok { background: var(--green-soft); color: #085c40; }
.flash-err { background: var(--red-soft); color: var(--red); }
.login-foot { margin-top: 18px; }
input, select { width: 100%; border: 1px solid var(--line); border-radius: 12px; padding: 0.7rem 0.8rem; background: #fff; color: var(--ink); }
.checkline { display: flex !important; align-items: center; gap: 8px; }
.checkline input { width: auto; }
.alerte-choix { border: 1px solid var(--line); border-radius: 16px; padding: 14px 16px; display: grid; gap: 10px; }
.alerte-choix legend { padding: 0 6px; font-weight: 700; color: var(--navy); }
.alerte-personnes { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 8px; max-height: 220px; overflow: auto; }

.admin { min-height: 100vh; display: grid; grid-template-columns: 250px 1fr; background: var(--bg); }
.sidebar { background: var(--navy); color: #e8eef6; padding: 22px 16px; display: flex; flex-direction: column; gap: 18px; }
.brand { display: flex; gap: 12px; align-items: center; color: inherit; text-decoration: none; }
.brand strong, .brand small { display: block; }
.brand small { color: #9aadc4; }
.logo-admin { width: 48px; height: auto; flex-shrink: 0; background: #fff; border-radius: 10px; padding: 4px; }
.slogan-admin { margin: 0; font-size: 0.72rem; line-height: 1.35; color: #9aadc4; }
.slogan-admin em { color: var(--sky); font-style: normal; font-weight: 700; }
.brand-mark { width: 36px; height: 36px; border-radius: 10px; background: var(--sky); }
.sidebar nav { display: grid; gap: 6px; }
.sidebar a { color: #d5e0ec; text-decoration: none; padding: 10px 12px; border-radius: 12px; }
.sidebar a.active, .sidebar a:hover { background: rgba(255,255,255,.08); color: white; }
.logout { margin-top: auto; }
.logout button { width: 100%; background: transparent; color: #d5e0ec; border: 1px solid rgba(255,255,255,.15); border-radius: 12px; padding: 10px; cursor: pointer; }
.content { padding: 28px; }
.topbar { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; }
.topbar h1 { margin: 0; font-size: 1.7rem; }
.who, .sub, .muted { color: var(--muted); }
.sub { margin-top: 0; }
.cards { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 14px; margin: 18px 0; }
.cards-tight { grid-template-columns: repeat(5, minmax(0, 1fr)); }
.card { background: var(--card); border-radius: 18px; padding: 16px 18px; box-shadow: var(--shadow); }
.card span, .card small { color: var(--muted); }
.card strong { display: block; font-size: 2rem; margin-top: 6px; font-variant-numeric: tabular-nums; }
.card-amber strong { color: var(--amber); }
.card-red strong { color: var(--red); }
.card-green strong { color: var(--green); }
.panel { background: var(--card); border-radius: 20px; padding: 18px; margin: 16px 0 22px; box-shadow: var(--shadow); }
.panel-head, .inline-form, .row-actions, .pager { display: flex; flex-wrap: wrap; gap: 10px; align-items: end; justify-content: space-between; }
.panel-head h2 { margin: 0; font-size: 1.1rem; }
.table-wrap { overflow-x: auto; margin-top: 12px; }
.table { width: 100%; border-collapse: collapse; }
.table th { text-align: left; font-size: 0.78rem; letter-spacing: 0.04em; text-transform: uppercase; color: var(--muted); padding: 10px 8px; border-bottom: 1px solid var(--line); }
.table td { padding: 12px 8px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.table small { display: block; }
.badge { display: inline-flex; border-radius: 999px; padding: 0.2rem 0.6rem; font-size: 0.82rem; background: #eef2f6; }
.badge-a_lheure, .badge-sorti, .badge-normale { background: var(--green-soft); color: #085c40; }
.badge-retard, .badge-en_attente, .badge-sorti_anticipe, .badge-anticipe { background: var(--amber-soft); color: #6d4b00; }
.badge-absent, .badge-hors_plage { background: var(--red-soft); color: var(--red); }
.badge-repos { background: #eef2f6; color: var(--muted); }
.empty { color: var(--muted); padding: 18px 0; }
.form-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); margin-top: 12px; }
.span-2, .form-actions { grid-column: 1 / -1; }
fieldset { border: 1px solid var(--line); border-radius: 14px; }
.days { display: flex; flex-wrap: wrap; gap: 12px; }
.people { display: grid; gap: 12px; }
.person { display: grid; grid-template-columns: 84px 1fr; gap: 14px; padding: 12px 0; border-bottom: 1px solid var(--line); }
.person.is-off { opacity: 0.62; }
.avatar { width: 84px; height: 84px; border-radius: 18px; object-fit: cover; background: #d7e3ea; }
.avatar-letter { display: grid; place-items: center; font-weight: 700; color: #1d4f91; }
.person h3 { margin: 0 0 4px; }
.person p { margin: 0 0 8px; }
details { margin-top: 8px; }
dialog { width: min(720px, calc(100% - 24px)); border: 0; border-radius: 24px; padding: 22px; box-shadow: var(--shadow); }
dialog::backdrop { background: rgba(16, 22, 28, 0.62); }
.dialog-head { display: flex; justify-content: space-between; gap: 12px; align-items: start; }
.enroll-stage { background: #111; border-radius: 18px; overflow: hidden; aspect-ratio: 4 / 3; }
.enroll-stage video { width: 100%; height: 100%; object-fit: cover; transform: scaleX(-1); }
.previews { display: flex; gap: 8px; min-height: 72px; margin: 8px 0 14px; }
.previews img { width: 72px; height: 72px; object-fit: cover; border-radius: 12px; }
.heure-panel { text-align: left; }
.heure-grande { margin: 0; font-size: 3.2rem; font-variant-numeric: tabular-nums; letter-spacing: -0.04em; }
.manuel { width: 100%; margin: 0; }
.manuel > p, #manuel-panel > p { color: #d5e0da; }
#manuel-panel { margin-top: 12px; text-align: left; background: #172028; border: 1px solid rgba(255,255,255,.08); border-radius: 18px; padding: 14px; }
.manuel-grille { display: flex; flex-wrap: wrap; gap: 12px; margin: 14px 0; }
.manuel-personne { width: 128px; padding: 8px; border-radius: 16px; border: 2px solid #314049; background: #172028; color: #f4f7f5; cursor: pointer; text-align: center; }
.manuel-personne.is-selected { border-color: #3DDC97; }
.manuel-personne img, .manuel-lettre { width: 100%; height: 120px; object-fit: cover; border-radius: 12px; background: #243038; display: grid; place-items: center; font-size: 1.4rem; }
.manuel-personne span { display: block; margin-top: 6px; font-size: 0.85rem; }
.paie-regles { display: flex; flex-wrap: wrap; gap: 12px; align-items: end; margin-top: 12px; }
.paie-regles label { min-width: 180px; }
.extra-ligne { display: flex; gap: 6px; margin-bottom: 6px; }
.extra-ligne input { width: 110px; }
.paie-calc { font-variant-numeric: tabular-nums; white-space: nowrap; }
.paie-note { margin: 8px 0 0; }
.jour-grille { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 14px; margin-top: 16px; }
.jour-carte { border: 1px solid var(--line); border-radius: 18px; padding: 12px; background: #fff; }
.jour-carte img, .jour-lettre { width: 100%; height: 168px; object-fit: cover; border-radius: 14px; background: #d7e3ea; }
.jour-lettre { display: grid; place-items: center; font-size: 2rem; font-weight: 700; color: var(--blue); }
.jour-prenom { margin: 10px 0 0; color: var(--muted); }
.jour-carte h3 { margin: 0 0 8px; }
.jour-carte p { margin: 4px 0; }
.heure-ok, input.heure-ok { color: var(--green); font-weight: 700; }
.heure-retard, input.heure-retard { color: var(--red); font-weight: 700; }
th.date-tri { cursor: pointer; }
th.date-tri::after { content: " ↕"; color: var(--muted); font-weight: 500; }
.heure-anticipe, input.heure-anticipe { color: var(--amber); font-weight: 700; }
.non-pointe { color: var(--red); font-weight: 700; }
.captures-pointage { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.capture-lien { display: grid; gap: 2px; justify-items: center; text-decoration: none; color: var(--muted); font-size: 0.72rem; }
.capture-lien img { width: 56px; height: 56px; object-fit: cover; border-radius: 10px; border: 1px solid var(--line); background: #111; }
.capture-lien:hover img { border-color: #3DDC97; }
.alarmes { display: flex; flex-wrap: wrap; gap: 12px; margin: 0 0 18px; }
.alarme { display: flex; align-items: center; justify-content: space-between; gap: 18px; min-width: 260px; padding: 14px 16px; border: 1px solid #f0b4ae; border-radius: 16px; background: #fff5f4; color: var(--red); cursor: pointer; text-align: left; }
.alarme strong { font-size: 1.8rem; }
.alarme.is-actif, .alarme-forte { background: #b42318; color: #fff; border-color: #b42318; }
.alarme-forte.is-actif { outline: 3px solid #f0b429; }
.cherche { position: relative; min-width: 260px; }
.suggestions { position: absolute; z-index: 8; left: 0; right: 0; top: calc(100% + 4px); background: #fff; border: 1px solid var(--line); border-radius: 14px; max-height: 280px; overflow: auto; box-shadow: var(--shadow); }
.suggestion { display: flex; gap: 10px; align-items: center; width: 100%; padding: 8px 10px; border: 0; background: #fff; cursor: pointer; text-align: left; color: inherit; }
.suggestion:hover { background: #f3f7fb; }
.suggestion img, .suggestion-lettre { width: 42px; height: 42px; border-radius: 10px; object-fit: cover; background: #d7e3ea; display: grid; place-items: center; flex: 0 0 auto; }
.jour-carte.is-filtre { display: none; }
.jour-carte.is-choisie { border-color: var(--blue); }
a.jour-carte, .jour-photo { display: block; color: inherit; text-decoration: none; }
.jour-photo img, .jour-photo .jour-lettre { width: 100%; height: 168px; }

@media (max-width: 1100px) {
    .kiosk-main { grid-template-columns: 1fr; }
    .kiosk-zone { height: min(48vh, 380px); }
}
@media (max-width: 980px) {
    .admin, .cards, .cards-tight, .form-grid { grid-template-columns: 1fr; }
    .admin { display: block; }
    .sidebar nav { grid-template-columns: 1fr 1fr; }
    .kiosk-top { align-items: start; }
}
@media (prefers-reduced-motion: reduce) {
    .pulse, .mark path { animation: none; }
    .mark path { stroke-dashoffset: 0; }
}
