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

:root {
    --navy: #14532d;
    --navy-2: #1b7a3d;
    --ink: #12301c;
    --muted: #5a7260;
    --line: rgba(20, 83, 45, 0.12);
    --paper: #f4faf5;
    --card: #ffffff;
    --amber: #7cb342;
    --amber-2: #aed581;
    --ok: #2e7d32;
    --warn: #c47b1a;
    --danger: #b3392b;
    --info: #2b6cb0;
    --shadow: 0 18px 50px rgba(20, 83, 45, 0.12);
    --radius: 18px;
    --sidebar: 268px;
    --leaf: #3d8b4a;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
    margin: 0;
    font-family: Outfit, system-ui, sans-serif;
    color: var(--ink);
    background: var(--paper);
}
h1, h2, h3, .brand strong, .kpi-value, .login-aside h1 {
    font-family: "Barlow Condensed", Outfit, sans-serif;
    font-weight: 800;
    letter-spacing: 0.02em;
}
button, input, select, textarea { font: inherit; }
button { cursor: pointer; }
a { color: var(--navy-2); }
code { background: rgba(16, 35, 61, 0.06); padding: 0.1em 0.4em; border-radius: 6px; font-size: 0.9em; }
.muted { color: var(--muted); }

.btn-primary, .btn-ghost, .btn-danger, .btn-gold, .btn-ok {
    border: 0;
    border-radius: 999px;
    padding: 0.68rem 1.1rem;
    font-weight: 700;
    letter-spacing: 0.01em;
}
.btn-primary { background: linear-gradient(180deg, #1b7a3d, #14532d); color: #fff; box-shadow: 0 8px 20px rgba(20, 83, 45, 0.28); }
.btn-primary:hover { filter: brightness(1.08); }
.btn-ghost { background: transparent; border: 1px solid var(--line); color: var(--navy); }
.btn-danger { background: var(--danger); color: #fff; }
.btn-gold { background: var(--amber); color: #fff; }
.btn-ok { background: var(--ok); color: #fff; }
.btn-sm { padding: 0.35rem 0.75rem; font-size: 0.85rem; }
button:disabled, button[disabled], button.is-busy, input[type="submit"]:disabled, input[type="submit"][disabled] {
    opacity: 0.6;
    cursor: not-allowed !important;
    pointer-events: none !important;
    filter: none;
}

/* Login */
.login-body { min-height: 100%; }
.login-bg {
    position: fixed; inset: 0;
    background:
        radial-gradient(900px 500px at 10% 0%, rgba(124, 179, 66, 0.35), transparent 55%),
        radial-gradient(700px 500px at 100% 100%, rgba(20, 83, 45, 0.55), transparent 50%),
        linear-gradient(160deg, #0d2a18, #14532d 45%, #0a2214);
}
.login-shell {
    position: relative;
    min-height: 100%;
    display: grid;
    grid-template-columns: 1.1fr 0.9fr;
    gap: 2rem;
    align-items: center;
    max-width: 1120px;
    margin: 0 auto;
    padding: 2.4rem 1.4rem;
}
.login-aside { color: #f7f1e4; max-width: 520px; }
.login-aside h1 { font-size: clamp(2.2rem, 5vw, 3.6rem); margin: 0.4rem 0 0.8rem; line-height: 0.95; }
.login-aside p { color: rgba(247, 241, 228, 0.78); line-height: 1.5; }
.kicker { text-transform: uppercase; letter-spacing: 0.2em; font-size: 0.75rem; font-weight: 700; color: var(--amber-2); margin: 0; }
.login-points { padding: 0; list-style: none; }
.login-points li {
    margin: 0.55rem 0;
    padding-left: 1.1rem;
    position: relative;
    color: #f7f1e4;
}
.login-points li:before {
    content: "";
    position: absolute; left: 0; top: 0.55em;
    width: 8px; height: 8px; background: var(--amber); border-radius: 1px;
}
.login-logo {
    width: 168px;
    height: auto;
    background: #fff;
    border-radius: 18px;
    padding: 0.55rem 0.7rem;
    margin-bottom: 0.8rem;
}
.brand-logo {
    width: 52px;
    height: 52px;
    object-fit: contain;
    background: #fff;
    border-radius: 14px;
    padding: 4px;
}
.mark {
    width: 56px; height: 56px;
    display: grid; place-items: center;
    background: var(--navy);
    color: var(--amber);
    font-weight: 800;
    letter-spacing: 0.08em;
    border-radius: 14px;
    border: 2px solid var(--amber);
    font-family: "Barlow Condensed", sans-serif;
    font-size: 1.3rem;
}
.login-card {
    background: var(--card);
    border-radius: 28px;
    padding: 2rem 2rem 1.4rem;
    box-shadow: var(--shadow);
}
.login-kicker { text-transform: uppercase; letter-spacing: 0.18em; font-size: 0.72rem; color: var(--amber); margin: 0; font-weight: 800; }
.login-card h2 { margin: 0.25rem 0 0.3rem; font-size: 2rem; }
.login-sub { color: var(--muted); margin-top: 0; }
label { display: block; font-size: 0.86rem; font-weight: 600; margin: 0.75rem 0; color: var(--navy); }
input, select, textarea {
    width: 100%;
    margin-top: 0.35rem;
    border: 1px solid var(--line);
    background: #fff;
    border-radius: 12px;
    padding: 0.7rem 0.85rem;
}
textarea { min-height: 88px; resize: vertical; }
.form-error { color: var(--danger); font-weight: 600; }
.login-hint { font-size: 0.82rem; margin-top: 1.1rem; }

/* App shell */
body.app-body { height: 100%; overflow: hidden; }
html:has(body.app-body) { height: 100%; overflow: hidden; }
.app-body { display: grid; grid-template-columns: var(--sidebar) 1fr; height: 100vh; overflow: hidden; }
.sidebar {
    background: var(--navy);
    color: #fff;
    display: flex;
    flex-direction: column;
    padding: 1.1rem 0.85rem 1rem;
    height: 100vh;
    overflow: hidden;
    position: sticky;
    top: 0;
    align-self: start;
}
.brand { display: flex; gap: 0.75rem; align-items: center; padding: 0.3rem 0.5rem 1rem; }
.brand small { display: block; color: rgba(247, 241, 228, 0.55); font-size: 0.75rem; }
.side-nav { display: flex; flex-direction: column; gap: 0.2rem; flex: 1; overflow: auto; }
.side-nav a {
    color: rgba(247, 241, 228, 0.78);
    text-decoration: none;
    padding: 0.62rem 0.8rem;
    border-radius: 12px;
    font-weight: 600;
    font-size: 0.94rem;
}
.side-nav a:hover, .side-nav a.active { background: rgba(124, 179, 66, 0.22); color: #fff; }
.side-nav a.active { box-shadow: inset 3px 0 0 var(--amber); }
.side-user {
    display: grid;
    grid-template-columns: 40px 1fr auto;
    gap: 0.6rem;
    align-items: center;
    padding: 0.8rem 0.5rem 0.2rem;
    border-top: 1px solid rgba(255,255,255,0.08);
}
.avatar {
    width: 40px; height: 40px; border-radius: 12px;
    background: var(--amber); color: #fff;
    display: grid; place-items: center; font-weight: 800;
}
.side-user small { display: block; color: rgba(247, 241, 228, 0.5); font-size: 0.75rem; }
.logout { color: #f7f1e4; text-decoration: none; font-size: 1.2rem; padding: 0.3rem; }
.app-main { min-width: 0; height: 100vh; overflow: auto; }
.topbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 1rem;
    padding: 1.1rem 1.5rem 0.4rem;
}
.menu-btn { display: none; background: #fff; border: 1px solid var(--line); border-radius: 10px; padding: 0.4rem 0.6rem; }
.eyebrow { text-transform: uppercase; letter-spacing: 0.16em; font-size: 0.7rem; color: var(--amber); font-weight: 800; margin: 0; }
.topbar h1 { margin: 0.1rem 0 0; font-size: 1.85rem; }
.top-actions { display: flex; gap: 0.5rem; flex-wrap: wrap; }
.view { padding: 0.8rem 1.5rem 2.4rem; }

.kpis { display: grid; grid-template-columns: repeat(4, 1fr); gap: 0.9rem; }
.kpi {
    background: var(--card);
    border-radius: var(--radius);
    padding: 1rem 1.1rem;
    box-shadow: var(--shadow);
    border: 1px solid rgba(16, 35, 61, 0.05);
}
.kpi span { display: block; color: var(--muted); font-size: 0.82rem; font-weight: 600; }
.kpi-value { font-size: 2rem; margin-top: 0.2rem; }
.kpi.warn .kpi-value { color: var(--warn); }
.kpi.danger .kpi-value { color: var(--danger); }

.grid-2 { display: grid; grid-template-columns: 1.4fr 1fr; gap: 1rem; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 1rem; }
.card {
    background: var(--card);
    border-radius: var(--radius);
    padding: 1rem 1.15rem 1.15rem;
    box-shadow: var(--shadow);
    border: 1px solid rgba(16, 35, 61, 0.05);
}
.card h3 { margin: 0 0 0.8rem; font-size: 1.25rem; }
.toolbar { display: flex; gap: 0.55rem; flex-wrap: wrap; margin: 0 0 0.9rem; align-items: end; }
.toolbar label { margin: 0; flex: 1; min-width: 140px; }

table.data { width: 100%; border-collapse: collapse; font-size: 0.92rem; }
table.data th, table.data td { text-align: left; padding: 0.62rem 0.5rem; border-bottom: 1px solid var(--line); vertical-align: top; }
table.data th { font-size: 0.75rem; text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted); }
table.data tr:hover td { background: rgba(124, 179, 66, 0.08); }
.mat { font-family: "Barlow Condensed", sans-serif; font-weight: 800; letter-spacing: 0.06em; color: var(--navy); }
.linkish { background: none; border: 0; padding: 0; color: var(--navy-2); font-weight: 700; text-decoration: underline; text-underline-offset: 3px; }

.badge {
    display: inline-block;
    padding: 0.15rem 0.5rem;
    border-radius: 999px;
    font-size: 0.75rem;
    font-weight: 700;
    background: #e8edf3;
}
.badge.ok { background: #d9f0e3; color: #1e5c38; }
.badge.warn { background: #fbe8c8; color: #8a5208; }
.badge.critical, .badge.expired, .badge.danger { background: #f8d4d0; color: #8a2218; }
.badge.info { background: #d9e8fa; color: #1d4e86; }

.person { display: flex; gap: 0.65rem; align-items: center; }
.dot {
    width: 36px; height: 36px; border-radius: 11px;
    background: var(--navy); color: #fff;
    display: grid; place-items: center; font-weight: 800; font-size: 0.78rem; flex: none;
}
.alert-list { display: flex; flex-direction: column; gap: 0.55rem; }
.alert-item {
    display: grid;
    grid-template-columns: 8px 1fr auto;
    gap: 0.7rem;
    padding: 0.7rem 0.75rem;
    border-radius: 12px;
    background: #fff;
    border: 1px solid var(--line);
}
.alert-item i { display: block; border-radius: 8px; background: var(--warn); }
.alert-item.expired i, .alert-item.critical i { background: var(--danger); }
.alert-item.warn i { background: var(--warn); }
.bars { display: flex; flex-direction: column; gap: 0.55rem; }
.bar-row { display: grid; grid-template-columns: 120px 1fr 32px; gap: 0.5rem; align-items: center; font-size: 0.88rem; }
.bar { height: 8px; background: #e8edf3; border-radius: 99px; overflow: hidden; }
.bar span { display: block; height: 100%; background: linear-gradient(90deg, var(--navy), var(--amber)); }

.empty { text-align: center; color: var(--muted); padding: 2rem 1rem; }

.modal {
    position: fixed; inset: 0;
    background: rgba(10, 18, 30, 0.46);
    display: none;
    place-items: center;
    padding: 1rem;
    z-index: 40;
}
.modal:not([hidden]) {
    display: grid;
}
.modal-card {
    background: var(--card);
    width: min(640px, 100%);
    max-height: 90vh;
    overflow: auto;
    border-radius: 22px;
    padding: 1.3rem 1.3rem 1.1rem;
    box-shadow: var(--shadow);
}
.modal-card h2 { margin: 0 0 0.8rem; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0 0.8rem; }
.form-actions { display: flex; justify-content: flex-end; gap: 0.5rem; margin-top: 0.6rem; }
.check-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0.3rem 0.8rem; max-height: 180px; overflow: auto; margin: 0.5rem 0; }
.check-grid label { font-weight: 500; display: flex; gap: 0.4rem; align-items: center; margin: 0; }
.check-grid input { width: auto; margin: 0; }

.toasts { position: fixed; right: 1rem; bottom: 1rem; display: flex; flex-direction: column; gap: 0.5rem; z-index: 50; }
.toast { background: var(--navy); color: #fff; padding: 0.75rem 0.95rem; border-radius: 12px; min-width: 220px; box-shadow: var(--shadow); }
.toast b { display: block; }

.profile-head { display: flex; gap: 1rem; align-items: center; margin-bottom: 1rem; }
.profile-head .dot { width: 64px; height: 64px; font-size: 1.2rem; border-radius: 18px; }
img.dot { object-fit: cover; padding: 0; }
.field-plus { display: grid; grid-template-columns: 1fr auto; gap: 0.4rem; align-items: end; }
.field-plus label { margin: 0; }
.btn-plus { width: 42px; height: 42px; padding: 0; font-size: 1.3rem; line-height: 1; font-weight: 700; }
.quick-add { grid-column: 1 / -1; display: flex; gap: 0.5rem; align-items: center; background: #f3f8f1; padding: 0.55rem; border-radius: 12px; margin: 0.2rem 0 0.5rem; }
.quick-add[hidden] { display: none !important; }
.quick-add input { margin: 0; }
.photo-pick { display: flex; align-items: center; gap: 0.85rem; }
.photo-pick img, .photo-ph {
    width: 76px; height: 76px; border-radius: 18px; object-fit: cover;
    background: var(--navy); color: #fff; display: grid; place-items: center; font-size: 0.75rem;
}
.photo-pick img[hidden], .photo-ph[hidden] { display: none !important; }
.photo-ph { border: 1px dashed rgba(20, 83, 45, 0.25); background: #eef6ef; color: var(--muted); }
.tabs { display: flex; gap: 0.4rem; flex-wrap: wrap; margin: 0 0 0.8rem; }
.tabs button { border: 0; background: #e8edf3; border-radius: 999px; padding: 0.4rem 0.8rem; font-weight: 700; }
.tabs button.on { background: var(--navy); color: #fff; }

.job-cards, .cand-cards { display: grid; gap: 0.8rem; }
.job-card { border: 1px solid var(--line); border-radius: 14px; padding: 0.9rem; background: #fff; }
.job-card h4 { margin: 0 0 0.3rem; }

@media (max-width: 1100px) {
    .kpis, .grid-2, .grid-3 { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 860px) {
    .app-body { grid-template-columns: 1fr; }
    .sidebar { position: fixed; z-index: 30; transform: translateX(-110%); transition: 0.2s; width: var(--sidebar); }
    .app-body.nav-open .sidebar { transform: none; }
    .menu-btn { display: inline-block; }
    .login-shell { grid-template-columns: 1fr; }
    .kpis, .grid-2, .grid-3, .form-grid { grid-template-columns: 1fr; }
    .login-aside { display: none; }
}

/* Borne kiosk */
html:has(body.borne-body) { height: 100%; overflow: hidden; }
.borne-body {
    height: 100vh;
    height: 100dvh;
    overflow: hidden;
    background:
        radial-gradient(900px 500px at 10% 0%, rgba(124, 179, 66, 0.28), transparent 50%),
        linear-gradient(160deg, #0d2a18, #14532d 55%, #0a2214);
    color: #fff;
    display: grid;
    grid-template-rows: auto minmax(0, 1fr) auto;
}
.borne-top {
    display: flex; gap: 1rem; align-items: center;
    padding: 0.85rem 1.4rem;
    flex: none;
}
.borne-top .brand-logo { width: 56px; height: 56px; }
.borne-top small { display: block; opacity: .65; }
.borne-top .logout { margin-left: auto; color: #fff; }
.borne-main {
    min-height: 0;
    display: grid;
    grid-template-columns: 1.15fr 0.85fr;
    gap: 1rem;
    padding: 0 1.4rem 0.8rem;
}
.borne-cam {
    background: #07180e;
    border-radius: 22px;
    overflow: hidden;
    position: relative;
    min-height: 0;
    height: 100%;
}
.borne-cam video {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
    min-height: 0;
}
.borne-hint {
    position: absolute; left: 0; right: 0; bottom: 0;
    margin: 0; padding: .8rem 1rem;
    background: linear-gradient(transparent, #07180e);
    font-size: .92rem;
}
.borne-result {
    background: #fff;
    color: var(--ink);
    border-radius: 22px;
    padding: 1.5rem 1.4rem;
    display: flex; flex-direction: column; justify-content: center;
    min-height: 0;
    height: 100%;
    position: relative;
    overflow: auto;
}
.borne-result h1 { margin: .2rem 0 .6rem; font-size: clamp(1.4rem, 3vw, 2.3rem); }
.borne-result.ok { box-shadow: inset 8px 0 0 var(--ok); }
.borne-result.out { box-shadow: inset 8px 0 0 var(--leaf); }
.borne-result.err { box-shadow: inset 8px 0 0 var(--danger); }
.borne-result.pop { animation: scanPop .55s ease, scanFlash .85s ease; }
.scan-face {
    width: 72px; height: 72px; border-radius: 50%;
    object-fit: cover; margin-bottom: 0.8rem;
    animation: scanRing 1s ease-out;
    border: 3px solid var(--leaf);
}
.borne-result.ok .scan-mark { background: var(--ok); }
.borne-result.out .scan-mark { background: var(--leaf); }
.borne-result.err .scan-mark { background: var(--danger); }
@keyframes scanPop {
    0% { transform: translateY(18px) scale(0.94); opacity: 0.2; }
    55% { transform: translateY(-4px) scale(1.03); opacity: 1; }
    100% { transform: none; opacity: 1; }
}
@keyframes scanFlash {
    0% { background: #dcf7e4; }
    100% { background: #fff; }
}
@keyframes scanRing {
    0% { box-shadow: 0 0 0 0 rgba(124, 179, 66, 0.55); transform: scale(0.7); }
    70% { box-shadow: 0 0 0 26px rgba(124, 179, 66, 0); transform: scale(1.05); }
    100% { box-shadow: 0 0 0 0 rgba(124, 179, 66, 0); transform: scale(1); }
}
.borne-fallback {
    display: flex; gap: .8rem; align-items: end;
    padding: 0 1.4rem 1.1rem;
    flex: none;
}
.borne-fallback label { flex: 1; color: #fff; margin: 0; }
.borne-fallback input { background: #fff; }
@media (max-width: 860px) {
    .borne-main { grid-template-columns: 1fr; grid-template-rows: minmax(180px, 1fr) minmax(160px, 1fr); }
}

/* Popup OTP Sortie avant 17h30 (RH & Borne) */
.otp-modal-wrap { z-index: 60; }
.otp-modal-card { max-width: 540px; border-top: 6px solid #e3a31a; }
.otp-head { display: flex; justify-content: space-between; align-items: center; gap: .5rem; margin-bottom: .4rem; }
.otp-box {
    background: #f3f8f1; border: 2px dashed #14532d; border-radius: 14px;
    padding: .9rem 1rem; text-align: center; margin: .7rem 0 .9rem;
}
.otp-box-label { font-size: .75rem; font-weight: 800; letter-spacing: .14em; color: #14532d; text-transform: uppercase; }
.otp-box-code {
    font-size: 2.3rem; font-weight: 900; letter-spacing: .22em; color: #12301c;
    font-family: "Consolas", "Courier New", monospace; margin: .25rem 0;
}
.otp-box-sub { font-size: .82rem; color: var(--muted); }
.otp-choices { display: grid; grid-template-columns: 1fr 1fr; gap: .65rem; }
.otp-choices button {
    display: flex; flex-direction: column; align-items: center; justify-content: center;
    padding: .75rem .7rem; border-radius: 12px; text-align: center; line-height: 1.25;
}
.otp-choices button small { font-weight: 500; font-size: .76rem; opacity: .9; margin-top: .2rem; }
.otp-rule-banner {
    background: #fff8e6; border-left: 4px solid #e3a31a; color: #6b4c00;
    padding: .65rem .8rem; border-radius: 8px; font-size: .86rem; margin-bottom: .7rem;
}
.otp-confirmed {
    background: #dcf7e4; border: 1px solid #1b7a3d; color: #14532d;
    padding: .75rem .9rem; border-radius: 10px; text-align: center;
}
.borne-otp-head { display: flex; align-items: center; gap: .9rem; margin-bottom: .6rem; }
.borne-otp-head .scan-face, .borne-otp-head .scan-mark { margin-bottom: 0; width: 58px; height: 58px; flex: none; }
.borne-rh-status {
    background: #f3f8f1; border-left: 4px solid #14532d; padding: .55rem .75rem;
    border-radius: 8px; font-size: .88rem; margin-bottom: .65rem;
}
.borne-rh-status.err { background: #fdecec; border-left-color: #b42318; color: #b42318; }
.borne-rh-status.ok { background: #dcf7e4; border-left-color: #1b7a3d; color: #14532d; }
.borne-otp-types { display: grid; grid-template-columns: 1fr 1fr; gap: .5rem; margin-bottom: .65rem; }
.borne-type-opt {
    display: flex; gap: .45rem; align-items: flex-start; border: 1px solid #d5dce4;
    border-radius: 10px; padding: .5rem .65rem; cursor: pointer; background: #f9fbf9; margin: 0;
}
.borne-type-opt input { width: auto; margin-top: .2rem; }
.borne-type-opt span { display: flex; flex-direction: column; font-size: .84rem; line-height: 1.2; }
.borne-type-opt small { color: var(--muted); font-size: .74rem; font-weight: 400; margin-top: .15rem; }
.borne-otp-rule {
    background: #fff8e6; border-left: 4px solid #e3a31a; color: #6b4c00;
    padding: .5rem .7rem; border-radius: 8px; font-size: .83rem; margin-bottom: .65rem;
}
.borne-otp-row { display: flex; gap: .5rem; align-items: center; }
.borne-otp-row input {
    font-size: 1.5rem; font-weight: 800; letter-spacing: .28em; text-align: center;
    max-width: 190px; margin: 0; padding: .45rem .6rem;
}

/* Regroupement par service dans les listes (Effectif, Pointages, Absences) */
.dept-section { margin-bottom: 1.15rem; }
.dept-section:last-child { margin-bottom: 0; }
.dept-group-head {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: #e8efe9;
    border-left: 4px solid var(--navy);
    padding: 0.5rem 0.85rem;
    border-radius: 6px;
    margin: 0.75rem 0 0.35rem;
    font-weight: 700;
    color: var(--navy);
}
.dept-group-head span.dept-sub {
    font-size: 0.82rem;
    font-weight: 600;
    color: var(--muted);
}
td.num-col, th.num-col { text-align: right; width: 105px; }
td.abs-hot { font-weight: 800; color: #b42318; }
.abs-foot-note {
    margin-top: 0.9rem;
    padding-top: 0.65rem;
    border-top: 1px solid var(--line);
    font-weight: 700;
    color: var(--navy);
    font-size: 0.9rem;
}
