/* Valida — feuille de style unique, sans dépendance externe. */

:root {
    --ink:        #141d2b;
    --ink-soft:   #22304a;
    --paper:      #eceff3;
    --surface:    #ffffff;
    --line:       #d8dfe7;
    --line-soft:  #eaeef3;
    --text:       #16202e;
    --muted:      #5d6d80;
    --primary:    #1f4fd8;
    --primary-dk: #163bA5;
    --pending:    #9a5b00;
    --pending-bg: #fdf1dd;
    --approved:   #0c7350;
    --approved-bg:#e0f3ea;
    --rejected:   #b32338;
    --rejected-bg:#fbe4e7;
    --cancel:     #5d6d80;
    --cancel-bg:  #e7ebf0;
    --radius:     10px;
    --shadow:     0 1px 2px rgba(20,29,43,.06), 0 8px 24px -16px rgba(20,29,43,.35);

    --font-ui:   system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    --font-mono: ui-monospace, "Cascadia Mono", "SFMono-Regular", Consolas, "Liberation Mono", monospace;
}

* { box-sizing: border-box; }

html, body {
    margin: 0;
    padding: 0;
    background: var(--paper);
    color: var(--text);
    font-family: var(--font-ui);
    font-size: 15px;
    line-height: 1.5;
    -webkit-text-size-adjust: 100%;
}

a { color: var(--primary); }
h1, h2, h3 { margin: 0; font-weight: 650; letter-spacing: -.01em; }
h1 { font-size: 1.5rem; }
h2 { font-size: 1.05rem; }
h3 { font-size: .95rem; }

.mono { font-family: var(--font-mono); font-size: .86em; letter-spacing: -.02em; }
.muted { color: var(--muted); }
.small { font-size: .84rem; }

/* ------------------------------------------------------------- structure */

.shell { display: grid; grid-template-columns: 244px 1fr; min-height: 100vh; }

.sidebar {
    background: var(--ink);
    color: #c9d3e2;
    padding: 22px 16px;
    display: flex;
    flex-direction: column;
    gap: 26px;
    position: sticky;
    top: 0;
    height: 100vh;
}

.brand { display: flex; align-items: center; gap: 10px; padding: 0 6px; }
.brand-mark {
    width: 30px; height: 30px; flex: none;
    border: 2px solid #7f97c7; border-radius: 7px;
    display: grid; place-items: center;
    color: #cfe0ff; font-weight: 800; font-size: 14px;
    transform: rotate(-6deg);
}
.brand-name {
    color: #fff; font-weight: 700; font-size: 14px;
    text-transform: uppercase; letter-spacing: .22em;
}

.nav { display: flex; flex-direction: column; gap: 2px; }
.nav-title {
    font-size: 10.5px; text-transform: uppercase; letter-spacing: .18em;
    color: #6d7f9c; padding: 14px 8px 6px;
}
.nav a {
    display: flex; align-items: center; gap: 10px;
    padding: 9px 10px; border-radius: 8px;
    color: #c9d3e2; text-decoration: none; font-size: 14.5px;
}
.nav a:hover { background: var(--ink-soft); color: #fff; }
.nav a.active { background: #fff; color: var(--ink); font-weight: 620; }
.nav .count {
    margin-left: auto; font-family: var(--font-mono); font-size: 11.5px;
    background: var(--ink-soft); color: #dbe5f5;
    padding: 1px 7px; border-radius: 20px;
}
.nav a.active .count { background: var(--paper); color: var(--ink); }
.nav .count.alert { background: #d5442f; color: #fff; }

.sidebar-foot { margin-top: auto; border-top: 1px solid #2a3852; padding-top: 14px; }
.who { display: flex; align-items: center; gap: 10px; padding: 0 6px 10px; }
.avatar {
    width: 32px; height: 32px; flex: none; border-radius: 50%;
    background: #33456a; color: #dbe5f5;
    display: grid; place-items: center; font-size: 12px; font-weight: 700;
}
.who-name { color: #fff; font-size: 13.5px; font-weight: 600; }
.who-role { color: #7c8ea9; font-size: 11.5px; }
.sidebar-foot a { color: #93a5c0; font-size: 13px; text-decoration: none; padding: 0 6px; }
.sidebar-foot a:hover { color: #fff; text-decoration: underline; }

.main { padding: 28px 34px 60px; max-width: 1100px; }
.page-head { display: flex; align-items: flex-start; gap: 16px; margin-bottom: 22px; }
.page-head .grow { flex: 1; }
.eyebrow {
    font-size: 11px; text-transform: uppercase; letter-spacing: .16em;
    color: var(--muted); margin-bottom: 4px;
}

/* ----------------------------------------------------------------- cartes */

.card {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    margin-bottom: 18px;
}
.card-head {
    padding: 14px 18px;
    border-bottom: 1px solid var(--line-soft);
    display: flex; align-items: center; gap: 12px;
}
.card-head .grow { flex: 1; }
.card-body { padding: 18px; }
.card-body > :last-child { margin-bottom: 0; }

.grid-2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 18px; }

.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 14px; margin-bottom: 22px; }
.kpi {
    background: var(--surface); border: 1px solid var(--line);
    border-radius: var(--radius); padding: 14px 16px;
}
.kpi .n { font-size: 1.9rem; font-weight: 700; font-variant-numeric: tabular-nums; line-height: 1.1; }
.kpi .l { font-size: 12px; text-transform: uppercase; letter-spacing: .1em; color: var(--muted); margin-top: 2px; }
.kpi.is-pending .n  { color: var(--pending); }
.kpi.is-approved .n { color: var(--approved); }
.kpi.is-rejected .n { color: var(--rejected); }

/* --------------------------------------------------------------- tableaux */

.table { width: 100%; border-collapse: collapse; }
.table th {
    text-align: left; font-size: 11px; text-transform: uppercase; letter-spacing: .12em;
    color: var(--muted); font-weight: 600;
    padding: 10px 18px; border-bottom: 1px solid var(--line-soft);
}
.table td { padding: 13px 18px; border-bottom: 1px solid var(--line-soft); vertical-align: middle; }
.table tr:last-child td { border-bottom: 0; }
.table tbody tr:hover { background: #f7f9fb; }
.table a.title { color: var(--text); text-decoration: none; font-weight: 600; }
.table a.title:hover { color: var(--primary); text-decoration: underline; }
.num { font-variant-numeric: tabular-nums; text-align: right; white-space: nowrap; }

/* ----------------------------------------------------------------- statuts */

.chip {
    display: inline-flex; align-items: center; gap: 6px;
    padding: 3px 10px; border-radius: 20px;
    font-size: 12px; font-weight: 600; white-space: nowrap;
}
.chip::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.chip-pending   { background: var(--pending-bg);  color: var(--pending); }
.chip-approved  { background: var(--approved-bg); color: var(--approved); }
.chip-rejected  { background: var(--rejected-bg); color: var(--rejected); }
.chip-cancelled { background: var(--cancel-bg);   color: var(--cancel); }

/* Élément signature : le tampon apposé sur la demande clôturée. */
.stamp {
    display: inline-block;
    padding: 10px 20px 8px;
    border: 3px double currentColor;
    border-radius: 6px;
    font-weight: 800; font-size: 1.15rem;
    text-transform: uppercase; letter-spacing: .22em;
    transform: rotate(-7deg);
    opacity: .88;
    text-align: center;
    line-height: 1.15;
}
.stamp small {
    display: block; font-size: 10px; letter-spacing: .1em;
    font-weight: 600; opacity: .8; margin-top: 3px;
}
.stamp-approved  { color: var(--approved); }
.stamp-rejected  { color: var(--rejected); }
.stamp-cancelled { color: var(--cancel); }
.stamp-pending   { color: var(--pending); border-style: dashed; border-width: 2px; transform: rotate(-3deg); }

/* Piste de validation : la fiche de circulation du parapheur. */
.trail { list-style: none; margin: 0; padding: 0 0 0 6px; }
.trail li {
    position: relative; padding: 0 0 18px 26px;
    border-left: 2px solid var(--line);
}
.trail li:last-child { border-left-color: transparent; padding-bottom: 0; }
.trail li::before {
    content: ""; position: absolute; left: -7px; top: 3px;
    width: 12px; height: 12px; border-radius: 50%;
    background: var(--surface); border: 2px solid var(--line);
}
.trail li.done-approved::before { border-color: var(--approved); background: var(--approved); }
.trail li.done-rejected::before { border-color: var(--rejected); background: var(--rejected); }
.trail .who-line { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.trail .name { font-weight: 600; }
.trail .comment {
    margin-top: 6px; padding: 8px 12px; border-radius: 8px;
    background: #f5f7fa; border-left: 3px solid var(--line);
    font-size: 14px;
}

/* ------------------------------------------------------------- formulaires */

.field { margin-bottom: 16px; }
.field label { display: block; font-size: 13px; font-weight: 600; margin-bottom: 5px; }
.field .hint { font-size: 12.5px; color: var(--muted); margin-top: 5px; }

input[type=text], input[type=email], input[type=password], input[type=number],
input[type=date], input[type=search], select, textarea {
    width: 100%; padding: 9px 11px;
    border: 1px solid var(--line); border-radius: 8px;
    background: var(--surface); color: var(--text);
    font: inherit;
}
textarea { min-height: 110px; resize: vertical; }
select[multiple] { min-height: 168px; }
input:focus, select:focus, textarea:focus {
    outline: 2px solid var(--primary); outline-offset: 1px; border-color: var(--primary);
}
input[disabled], select[disabled] { background: #f3f5f8; color: var(--muted); }

.check { display: flex; align-items: flex-start; gap: 9px; margin-bottom: 10px; font-size: 14px; }
.check input { margin-top: 3px; }

.form-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 0 16px; }
.form-actions { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; padding-top: 4px; }

/* ---------------------------------------------------------------- boutons */

.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 7px;
    padding: 9px 16px; border-radius: 8px;
    border: 1px solid var(--line); background: var(--surface); color: var(--text);
    font: inherit; font-weight: 600; font-size: 14px;
    cursor: pointer; text-decoration: none;
}
.btn:hover { background: #f4f7fa; }
.btn:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }
.btn-primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-dk); }
.btn-approve { background: var(--approved); border-color: var(--approved); color: #fff; }
.btn-approve:hover { filter: brightness(.92); }
.btn-reject { background: var(--surface); border-color: var(--rejected); color: var(--rejected); }
.btn-reject:hover { background: var(--rejected-bg); }
.btn-sm { padding: 6px 11px; font-size: 13px; }
.btn-link { border: 0; background: none; color: var(--primary); padding: 0; text-decoration: underline; }

/* ---------------------------------------------------------------- divers  */

.flash {
    padding: 11px 16px; border-radius: 8px; margin-bottom: 16px;
    border: 1px solid; font-size: 14.5px;
}
.flash-success { background: var(--approved-bg); border-color: #bfe3d2; color: var(--approved); }
.flash-error   { background: var(--rejected-bg); border-color: #f0c2c9; color: var(--rejected); }
.flash-info    { background: #e6edfb; border-color: #c5d6f7; color: var(--primary-dk); }

.empty { padding: 40px 18px; text-align: center; color: var(--muted); }
.empty p { margin: 0 0 14px; }

.dl { display: grid; grid-template-columns: 150px 1fr; gap: 9px 16px; margin: 0; font-size: 14.5px; }
.dl dt { color: var(--muted); }
.dl dd { margin: 0; }

.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin-bottom: 18px; flex-wrap: wrap; }
.tabs a {
    padding: 8px 14px; text-decoration: none; color: var(--muted);
    font-size: 14px; font-weight: 600; border-bottom: 2px solid transparent; margin-bottom: -1px;
}
.tabs a.active { color: var(--text); border-bottom-color: var(--primary); }

.notif { display: flex; gap: 12px; padding: 13px 18px; border-bottom: 1px solid var(--line-soft); }
.notif.unread { background: #f4f8ff; }
.notif .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--primary); margin-top: 7px; flex: none; }
.notif.read .dot { background: var(--line); }

.badge-role { font-size: 11px; text-transform: uppercase; letter-spacing: .1em; color: var(--muted); }

/* --------------------------------------------------------------- connexion */

.auth-shell { display: grid; grid-template-columns: 1fr 1fr; min-height: 100vh; }
.auth-side {
    background: var(--ink); color: #fff;
    padding: 44px; display: flex; flex-direction: column; justify-content: space-between;
}
.auth-side h2 { font-size: 1.7rem; max-width: 15em; line-height: 1.3; color: #fff; }
.auth-side p { color: #93a5c0; max-width: 26em; }
.auth-stamps { display: flex; gap: 18px; flex-wrap: wrap; margin-top: 26px; }
.auth-stamps .stamp { opacity: .55; font-size: .85rem; }
.auth-main { display: grid; place-items: center; padding: 30px; }
.auth-card { width: 100%; max-width: 380px; }
.auth-card h1 { margin-bottom: 4px; }
.auth-card .lead { color: var(--muted); margin: 0 0 22px; }

/* -------------------------------------------------------------- responsive */

@media (max-width: 860px) {
    .shell { grid-template-columns: 1fr; }
    .sidebar {
        position: sticky; top: 0; height: auto; z-index: 20;
        flex-direction: row; align-items: center; gap: 14px;
        padding: 10px 14px; overflow-x: auto;
    }
    .sidebar .nav-title, .sidebar .who-role { display: none; }
    .nav { flex-direction: row; gap: 4px; }
    .nav a { white-space: nowrap; padding: 7px 11px; font-size: 13.5px; }
    .sidebar-foot { margin: 0 0 0 auto; border: 0; padding: 0; display: flex; align-items: center; gap: 10px; }
    .who { padding: 0; }
    .who-name { display: none; }
    .main { padding: 20px 16px 48px; }
    .auth-shell { grid-template-columns: 1fr; }
    .auth-side { display: none; }
    .dl { grid-template-columns: 1fr; gap: 2px 0; }
    .dl dd { margin-bottom: 10px; }
    .table thead { display: none; }
    .table tr { display: block; border-bottom: 1px solid var(--line-soft); padding: 12px 16px; }
    .table td { display: flex; justify-content: space-between; gap: 14px; border: 0; padding: 3px 0; }
    .table td::before { content: attr(data-label); color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: .08em; }
    .num { text-align: left; }
}

@media (prefers-reduced-motion: reduce) {
    * { animation: none !important; transition: none !important; }
}

@media print {
    .sidebar, .form-actions, .tabs { display: none; }
    .shell { display: block; }
    .card { box-shadow: none; }
}

/* ------------------------------------------------- installation sur mobile */

.install-banner {
    display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
    background: var(--ink); color: #d7e1f2;
    border-radius: var(--radius); padding: 12px 16px; margin-bottom: 18px;
    font-size: 14px;
}
.install-banner-text { flex: 1; min-width: 200px; }
.install-banner .btn { background: #fff; border-color: #fff; }
.install-banner .btn-link { background: none; border: 0; color: #93a5c0; }
.install-banner .btn-link:hover { color: #fff; }

.lead-text { font-size: 16px; color: var(--muted); max-width: 62ch; margin: 0 0 22px; }

.platform-guides { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 18px; }
.platform-guides .card { margin-bottom: 0; }
.platform-guides .card-head { flex-direction: column; align-items: flex-start; gap: 4px; }

.guide-mark {
    font-family: var(--font-mono); font-size: 10.5px;
    text-transform: uppercase; letter-spacing: .16em;
    color: var(--primary); background: #e6edfb;
    padding: 2px 8px; border-radius: 4px;
}
.guide h2 { font-size: .98rem; }
.guide-note {
    font-size: 13px; color: var(--muted);
    border-top: 1px solid var(--line-soft); padding-top: 12px; margin: 14px 0 0;
}

.steps { margin: 0; padding-left: 0; list-style: none; counter-reset: step; }
.steps li {
    position: relative; padding-left: 34px; margin-bottom: 11px; font-size: 14.5px;
    counter-increment: step;
}
.steps li::before {
    content: counter(step);
    position: absolute; left: 0; top: 0;
    width: 22px; height: 22px; border-radius: 50%;
    background: var(--paper); color: var(--muted);
    font-family: var(--font-mono); font-size: 11.5px; font-weight: 700;
    display: grid; place-items: center;
}

.install-now { border-color: var(--primary); background: #f7faff; }

/* Page affichée quand le réseau manque */
.offline-page {
    min-height: 100vh; display: grid; place-items: center; padding: 30px; text-align: center;
}
.offline-page .stamp { margin-bottom: 22px; }

/* ------------------------------------------- circuit, étapes et délégation */

.mode-choice { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 10px; }
.mode-option {
    display: flex; gap: 10px; align-items: flex-start;
    border: 1px solid var(--line); border-radius: var(--radius);
    padding: 12px 14px; background: var(--surface);
}
.mode-option:has(input:checked) { border-color: var(--primary); background: #f7faff; }
.mode-option input { margin-top: 3px; flex: none; }
.mode-option label { display: block; font-weight: 400; margin: 0; cursor: pointer; }
.mode-option strong { display: block; font-size: 14.5px; margin-bottom: 2px; }
.mode-option span { font-size: 13px; color: var(--muted); }

.picker { border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.picker-filter { border: 0; border-bottom: 1px solid var(--line); border-radius: 0; }
.picker-filter:focus { outline-offset: -2px; }
.picker-list { max-height: 300px; overflow-y: auto; }
.picker-row {
    display: flex; align-items: center; gap: 10px;
    padding: 8px 12px; border-bottom: 1px solid var(--line-soft);
}
.picker-row:last-child { border-bottom: 0; }
.picker-row:hover { background: #f7f9fb; }
.picker-row input[type=checkbox] { flex: none; }
.picker-name { flex: 1; margin: 0; font-weight: 500; font-size: 14.5px; cursor: pointer; }
.picker-name .small { display: block; font-weight: 400; }
.picker-row[hidden] { display: none; }

.step-select { width: auto; min-width: 108px; flex: none; padding: 4px 8px; font-size: 13px; display: none; }
.step-select.is-visible { display: block; }

.absent-tag, .behalf-tag {
    display: inline-block; font-size: 11px; font-weight: 600;
    padding: 1px 7px; border-radius: 4px; margin-left: 6px; white-space: nowrap;
}
.absent-tag { background: var(--pending-bg); color: var(--pending); }
.behalf-tag { background: var(--paper); color: var(--muted); }

.step-head {
    display: flex; align-items: center; gap: 10px;
    margin: 4px 0 12px; font-size: 13.5px; font-weight: 600;
}
.step-head:not(:first-child) { margin-top: 22px; }
.step-badge {
    width: 22px; height: 22px; border-radius: 50%; flex: none;
    display: grid; place-items: center;
    font-family: var(--font-mono); font-size: 11.5px;
    background: var(--paper); color: var(--muted); border: 1px solid var(--line);
}
.step-head.is-done .step-badge { background: var(--approved); border-color: var(--approved); color: #fff; }
.step-head.is-open .step-badge { background: var(--pending); border-color: var(--pending); color: #fff; }
.step-head.is-later { opacity: .6; }

.plain-list { list-style: none; margin: 0; padding: 0; }
.plain-list li { padding: 9px 0; border-bottom: 1px solid var(--line-soft); }
.plain-list li:last-child { border-bottom: 0; }

input[type=file] {
    width: 100%; padding: 8px; font: inherit; font-size: 14px;
    border: 1px dashed var(--line); border-radius: 8px; background: var(--surface);
}
input[type=file]:focus { outline: 2px solid var(--primary); outline-offset: 1px; }

/* -------------------------------------------------- relevé des notifications */

.push-report {
    list-style: none; margin: 14px 0 0; padding: 0;
    border: 1px solid var(--line); border-radius: 8px; overflow: hidden;
}
.push-report li {
    display: flex; align-items: baseline; gap: 9px;
    padding: 8px 12px; font-size: 13.5px;
    border-bottom: 1px solid var(--line-soft);
}
.push-report li:last-child { border-bottom: 0; }
.push-report .mark { font-family: var(--font-mono); font-weight: 700; flex: none; width: 12px; }
.push-report li.ok  { color: var(--text); }
.push-report li.ok .mark { color: var(--approved); }
.push-report li.ko { background: #fdf3f4; color: var(--rejected); }
.push-report li.ko .mark { color: var(--rejected); }
.push-report li.na { color: var(--muted); }
.push-report .detail { color: var(--muted); font-size: 12.5px; }
.push-report li.ko .detail { color: var(--rejected); opacity: .85; }

.push-ok  { color: var(--approved) !important; font-weight: 600; }
.push-err { color: var(--rejected) !important; font-weight: 600; }

/* ------------------------------------------------- logo de l'organisation */

.org-logo {
    display: block;
    width: 118px; height: auto;
    margin: 0 6px 16px;
    border-radius: 6px;
}

@media (max-width: 860px) {
    /* en bandeau horizontal, le logo passerait devant la navigation */
    .org-logo { display: none; }
}

@media print {
    .org-logo { display: none; }
}

/* ------------------------------------------------------ champ de recherche */

.search-box {
    display: flex; gap: 8px; align-items: center; flex-wrap: wrap;
    flex: 1; min-width: 240px; max-width: 520px;
}
.search-box input[type=search] { flex: 1; min-width: 160px; }

.search-summary {
    font-size: 13px; color: var(--muted);
    padding: 10px 18px; border-bottom: 1px solid var(--line-soft);
    background: #f7f9fb;
}
.search-summary strong { color: var(--text); }

@media (max-width: 860px) {
    .search-box { max-width: none; }
    .card-head { flex-wrap: wrap; }
}
