/*
 * Admin Kannachak : feuille de style unique, sans étape de build (compatible cPanel).
 * Jetons issus de DESIGN.md. Aucune couleur en dur hors de :root.
 */

@font-face { font-family: "Readex Pro"; font-weight: 400; font-display: swap; src: url("../fonts/readex-pro-latin-400-normal.woff2") format("woff2"); }
@font-face { font-family: "Readex Pro"; font-weight: 500; font-display: swap; src: url("../fonts/readex-pro-latin-500-normal.woff2") format("woff2"); }
@font-face { font-family: "Readex Pro"; font-weight: 600 700; font-display: swap; src: url("../fonts/readex-pro-latin-600-normal.woff2") format("woff2"); }
@font-face { font-family: "Readex Pro"; font-weight: 400 700; font-display: swap; unicode-range: U+0600-06FF, U+0750-077F, U+FB50-FDFF, U+FE70-FEFF; src: url("../fonts/readex-pro-arabic-500-normal.woff2") format("woff2"); }

:root {
  --navy: #022E6B; --navy-2: #0A3C80; --blue: #015DB0; --vivid: #0887D6; --sky-10: #E8F2F9;
  --teal: #01ABA2; --teal-d: #037478; --teal-10: #E3F4F2; --teal-on-navy: #7FE3DB;
  --bg: #F4F7FA; --card: #FFFFFF; --line: #DCE5EC; --line-2: #93B2C4; --row: #EEF3F7;
  --ink: #0A1F3C; --ink-2: #4A5F78; --ink-3: #6B7E94;
  --amber: #8F5500; --amber-bg: #FFF3D9; --amber-dot: #E0A019; --badge: #F2B65A; --badge-ink: #3A2400;
  --red: #B42318; --red-bg: #FDECEA; --red-dot: #D64545; --grey: #5B6573; --grey-bg: #EDEFF2;
  --side: #022E6B; --side-ink: #C9D9EA; --side-soft: #9DB8D6; --side-line: rgba(255,255,255,.1); --side-hover: rgba(255,255,255,.07);
  --on-dark: #FFFFFF; --disabled-bg: #E4E9EE; --disabled-ink: #8A99A9;
  --shadow-seg: 0 1px 2px rgba(2,20,45,.12);
  --shadow-panel: 0 14px 30px -16px rgba(0,0,0,.5);
  --login-tag: #BFD6EA;
  --gradient-brand: linear-gradient(160deg, #022E6B 0%, #0B4F92 48%, #037478 100%);
  --font: "Readex Pro", "Segoe UI", system-ui, sans-serif;
  --r-sm: 7px; --r-md: 10px; --r-lg: 14px; --r-sheet: 22px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0D1828; --card: #132238; --line: #22354B; --line-2: #3A5470; --row: #18293F;
    --ink: #E4ECF4; --ink-2: #A9BDD1; --ink-3: #8399B0; --sky-10: #15304F; --teal-10: #113A3A;
    --amber: #F2B65A; --amber-bg: #3A2A10; --red: #F28B82; --red-bg: #3B1A18; --grey: #A9B3BF; --grey-bg: #222E3D;
    --teal-d: #3CC7BE; --blue: #5AA8F0; --disabled-bg: #22354B; --disabled-ink: #6E8399;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0D1828; --card: #132238; --line: #22354B; --line-2: #3A5470; --row: #18293F;
  --ink: #E4ECF4; --ink-2: #A9BDD1; --ink-3: #8399B0; --sky-10: #15304F; --teal-10: #113A3A;
  --amber: #F2B65A; --amber-bg: #3A2A10; --red: #F28B82; --red-bg: #3B1A18; --grey: #A9B3BF; --grey-bg: #222E3D;
  --teal-d: #3CC7BE; --blue: #5AA8F0; --disabled-bg: #22354B; --disabled-ink: #6E8399;
  color-scheme: dark;
}

/* ---------- base ---------- */
*, *::before, *::after { box-sizing: border-box; }
html, body { height: 100%; }
body { margin: 0; background: var(--bg); color: var(--ink); font-family: var(--font); font-size: 14px; line-height: 1.5; -webkit-font-smoothing: antialiased; }
::selection { background: var(--teal); color: var(--on-dark); }
a { color: var(--blue); text-underline-offset: 3px; }
:focus-visible { outline: 2px solid var(--vivid); outline-offset: 2px; }
input, select, textarea, button { font: inherit; color: inherit; caret-color: var(--blue); }
* { scrollbar-color: var(--line-2) transparent; scrollbar-width: thin; }
.num { font-variant-numeric: tabular-nums; white-space: nowrap; }
.muted { color: var(--ink-3); }
.ar { font-family: var(--font); }
svg.i { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; flex: none; }
.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* ---------- coque ---------- */
.shell { display: grid; grid-template-columns: 240px minmax(0, 1fr); min-height: 100%; }
.side-col { background: var(--side); }
.side { background: var(--side); color: var(--side-ink); display: flex; flex-direction: column; gap: 6px; padding: 20px 14px; position: sticky; top: 0; height: 100vh; }
.brand { display: flex; align-items: center; gap: 10px; padding: 0 8px 18px; border-bottom: 1px solid var(--side-line); margin-bottom: 8px; text-decoration: none; }
.brand .mk { width: 38px; height: 38px; border-radius: 10px; flex: none; box-shadow: 0 0 0 1px var(--side-line); }
.brand b { display: block; color: var(--on-dark); font-size: 16px; font-weight: 600; line-height: 1.1; }
.brand b em { font-style: normal; color: var(--teal-on-navy); }
.brand small { font-size: 11.5px; color: var(--side-soft); }
.nav { display: flex; flex-direction: column; gap: 2px; }
.nav a { display: flex; align-items: center; gap: 10px; padding: 9px 10px; border-radius: var(--r-md); color: var(--side-ink); text-decoration: none; font-weight: 500; }
.nav a:hover { background: var(--side-hover); color: var(--on-dark); }
.nav a[aria-current="page"] { background: var(--on-dark); color: var(--navy); }
.nav a .n { margin-inline-start: auto; background: var(--badge); color: var(--badge-ink); font-size: 11px; font-weight: 600; border-radius: 999px; padding: 0 7px; }
.me { margin-top: auto; display: flex; align-items: center; gap: 10px; padding: 12px 8px 0; border-top: 1px solid var(--side-line); font-size: 12.5px; }
.me .av { width: 32px; height: 32px; border-radius: var(--r-md); background: var(--navy-2); color: var(--on-dark); display: grid; place-items: center; font-weight: 600; font-size: 12px; flex: none; }
.me b { color: var(--on-dark); font-weight: 500; display: block; }
.me form { margin-inline-start: auto; }
.me button { background: none; border: 0; color: var(--side-soft); cursor: pointer; padding: 6px; border-radius: 8px; display: grid; place-items: center; }
.me button:hover { color: var(--on-dark); background: var(--side-hover); }

main { min-width: 0; padding: 22px 28px 48px; }
.page { display: flex; flex-direction: column; gap: 18px; max-width: 1180px; min-width: 0; }
.page > * { min-width: 0; }
.ph { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 12px; }
.ph h1 { margin: 0; font-size: 24px; font-weight: 600; letter-spacing: -0.015em; line-height: 1.2; text-wrap: balance; display: flex; flex-wrap: wrap; align-items: center; gap: 10px; }
.ph p { margin: 2px 0 0; color: var(--ink-2); }
.crumb { font-size: 12.5px; color: var(--ink-3); display: flex; gap: 6px; align-items: center; }
.crumb a { text-decoration: none; }
.crumb svg.i { width: 14px; height: 14px; }
.acts { display: flex; flex-wrap: wrap; gap: 8px; }

/* ---------- boutons ---------- */
.btn { font-weight: 500; display: inline-flex; align-items: center; justify-content: center; gap: 7px; border-radius: var(--r-md); padding: 0 14px; min-height: 38px; border: 1px solid var(--line-2); background: var(--card); color: var(--ink); cursor: pointer; text-decoration: none; white-space: nowrap; transition: border-color .15s ease-out, background-color .15s ease-out; }
.btn:hover { border-color: var(--blue); }
.btn.pri { background: var(--navy); border-color: var(--navy); color: var(--on-dark); }
.btn.pri:hover { background: var(--navy-2); }
.btn.danger { color: var(--red); border-color: color-mix(in srgb, var(--red) 45%, transparent); }
.btn.danger:hover { border-color: var(--red); background: var(--red-bg); }
.btn.danger.fill { background: var(--red); border-color: var(--red); color: var(--on-dark); }
.btn.sm { min-height: 32px; padding: 0 10px; font-size: 13px; }
.btn:disabled { background: var(--disabled-bg); border-color: var(--disabled-bg); color: var(--disabled-ink); cursor: not-allowed; }
.link { background: none; border: 0; padding: 0; color: var(--blue); cursor: pointer; text-decoration: underline; text-underline-offset: 3px; }

/* ---------- cartes ---------- */
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--r-lg); min-width: 0; }
.card .hd { margin: 0; padding: 14px 16px; font-size: 15px; font-weight: 600; display: flex; align-items: center; justify-content: space-between; gap: 10px; border-bottom: 1px solid var(--line); }
.card .hd small { font-weight: 400; color: var(--ink-3); font-size: 12.5px; }
.pad { padding: 16px; }
.empty { padding: 28px 16px; text-align: center; color: var(--ink-3); font-size: 13.5px; }
.empty b { display: block; color: var(--ink-2); font-weight: 500; margin-bottom: 2px; }

.kpis { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; }
.kpi { background: var(--card); border: 1px solid var(--line); border-radius: var(--r-lg); padding: 14px 16px; display: flex; flex-direction: column; gap: 4px; }
.kpi span { font-size: 12.5px; color: var(--ink-2); display: flex; align-items: center; gap: 7px; }
.kpi b { font-size: 26px; font-weight: 600; letter-spacing: -0.02em; line-height: 1.15; }
.kpi b small { font-size: 13px; font-weight: 500; color: var(--ink-3); letter-spacing: 0; }
.kpi > small { font-size: 12px; color: var(--ink-3); }
.dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; flex: none; }
.d-ok { background: var(--teal); } .d-exp { background: var(--amber-dot); } .d-blk { background: var(--red-dot); } .d-rev { background: var(--blue); }

.cols { display: grid; grid-template-columns: minmax(0, 1.6fr) minmax(0, 1fr); gap: 16px; align-items: start; }
.cols.eq { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
.stack { display: flex; flex-direction: column; gap: 16px; min-width: 0; }

/* ---------- tableaux ---------- */
.tw { overflow-x: auto; position: relative; }
table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
th { font-size: 12px; font-weight: 500; color: var(--ink-3); text-align: start; padding: 10px 16px; border-bottom: 1px solid var(--line); white-space: nowrap; }
td { padding: 11px 16px; border-bottom: 1px solid var(--row); vertical-align: middle; }
tr:last-child td { border-bottom: 0; }
tbody tr:hover td { background: color-mix(in srgb, var(--sky-10) 50%, transparent); }
td.r, th.r { text-align: end; }
td .sub { display: block; font-size: 12px; color: var(--ink-3); }
a.ag { color: var(--ink); font-weight: 500; text-decoration: none; white-space: nowrap; }
a.ag:hover { color: var(--blue); text-decoration: underline; }

.pill { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; font-weight: 500; border-radius: 999px; padding: 2px 10px; white-space: nowrap; letter-spacing: 0; }
.p-ok { background: var(--teal-10); color: var(--teal-d); }
.p-exp { background: var(--amber-bg); color: var(--amber); }
.p-blk { background: var(--red-bg); color: var(--red); }
.p-grey { background: var(--grey-bg); color: var(--grey); }
.p-blue { background: var(--sky-10); color: var(--blue); }

/* ---------- graphique ---------- */
.chart { padding: 12px 16px 16px; }
.chart svg { width: 100%; height: auto; display: block; }
.chart text { fill: var(--ink-3); font-size: 11px; font-family: var(--font); }
.chart .bar { fill: var(--line-2); }
.chart .bar.cur { fill: var(--blue); }
.chart .grid { stroke: var(--row); stroke-width: 1; }
.chart .val { fill: var(--ink); font-weight: 600; }

/* ---------- filtres ---------- */
.tools { min-width: 0; display: flex; flex-wrap: wrap; gap: 8px; align-items: center; padding: 12px 16px; border-bottom: 1px solid var(--line); }
.search { display: flex; align-items: center; gap: 8px; border: 1px solid var(--line-2); border-radius: var(--r-md); padding: 0 12px; min-height: 38px; color: var(--ink-3); flex: 1 1 220px; max-width: 340px; background: var(--card); }
.search:focus-within { border-color: var(--blue); box-shadow: 0 0 0 3px color-mix(in srgb, var(--blue) 18%, transparent); }
.search input { border: 0; outline: 0; background: transparent; flex: 1; min-width: 0; min-height: 36px; color: var(--ink); }
.search input::placeholder { color: var(--ink-3); }
.seg { display: inline-flex; max-width: 100%; overflow-x: auto; border: 1px solid var(--line); border-radius: var(--r-md); padding: 3px; gap: 2px; background: var(--bg); }
.seg a { padding: 4px 11px; border-radius: var(--r-sm); font-size: 13px; color: var(--ink-2); white-space: nowrap; text-decoration: none; }
.seg a:hover { color: var(--ink); }
.seg a[aria-current="true"] { background: var(--card); color: var(--ink); font-weight: 500; box-shadow: var(--shadow-seg); }

/* ---------- fiche ---------- */
.dl { display: grid; grid-template-columns: auto 1fr; gap: 9px 18px; margin: 0; font-size: 13.5px; }
.dl dt { color: var(--ink-3); }
.dl dd { margin: 0; font-weight: 500; min-width: 0; overflow-wrap: anywhere; }
.priv { display: flex; gap: 10px; align-items: flex-start; font-size: 12.5px; color: var(--ink-2); background: var(--sky-10); border-radius: var(--r-md); padding: 10px 12px; }
.priv svg { color: var(--blue); margin-top: 1px; }
.stats { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 1px; background: var(--line); }
.stats div { background: var(--card); padding: 12px 16px; display: flex; flex-direction: column; gap: 2px; }
.stats small { font-size: 12px; color: var(--ink-3); }
.stats b { font-size: 18px; font-weight: 600; }
.dz-list { display: flex; flex-direction: column; gap: 12px; }
.dz { display: flex; flex-direction: column; gap: 10px; padding-top: 12px; border-top: 1px solid var(--row); }
.dz:first-child { border-top: 0; padding-top: 0; }
.dz .row { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 10px; }
.dz p { margin: 0; font-size: 12.5px; color: var(--ink-2); max-width: 46ch; }
.dz b { display: block; font-size: 13.5px; font-weight: 500; color: var(--ink); }

/* Confirmation en place (details/summary) : pas de fenêtre modale, pas de JavaScript. */
details.confirm > summary { list-style: none; }
details.confirm > summary::-webkit-details-marker { display: none; }
details.confirm[open] > summary { display: none; }
.confirm-box { display: flex; flex-direction: column; gap: 10px; background: var(--bg); border: 1px solid var(--line); border-radius: var(--r-md); padding: 12px; }
.confirm-box p { max-width: none; }
.confirm-box .acts { justify-content: flex-end; }

/* ---------- formulaires ---------- */
.form { display: grid; grid-template-columns: 1fr 1fr; gap: 14px 16px; padding: 16px; }
.form.one { grid-template-columns: 1fr; }
.f { display: flex; flex-direction: column; gap: 5px; min-width: 0; }
.f.full { grid-column: 1 / -1; }
.f label, .f .lbl { font-size: 12.5px; font-weight: 500; color: var(--ink-2); }
.in { border: 1px solid var(--line-2); border-radius: var(--r-md); min-height: 40px; padding: 8px 12px; background: var(--card); color: var(--ink); width: 100%; transition: border-color .15s ease-out, box-shadow .15s ease-out; }
.in::placeholder { color: var(--ink-3); }
.in:focus { outline: 0; border-color: var(--blue); box-shadow: 0 0 0 3px color-mix(in srgb, var(--blue) 18%, transparent); }
.in[aria-invalid="true"] { border-color: var(--red); }
select.in { appearance: none; padding-inline-end: 34px; background-image: linear-gradient(45deg, transparent 50%, var(--ink-3) 50%), linear-gradient(135deg, var(--ink-3) 50%, transparent 50%); background-position: calc(100% - 18px) 50%, calc(100% - 13px) 50%; background-size: 5px 5px; background-repeat: no-repeat; }
textarea.in { min-height: 72px; resize: vertical; }
.affix { display: flex; align-items: stretch; }
.affix .in { border-start-end-radius: 0; border-end-end-radius: 0; }
.affix span { display: grid; place-items: center; padding: 0 12px; border: 1px solid var(--line-2); border-inline-start: 0; border-start-end-radius: var(--r-md); border-end-end-radius: var(--r-md); color: var(--ink-3); background: var(--bg); font-size: 13px; }
.hint { font-size: 12px; color: var(--ink-3); }
.hint b { color: var(--teal-d); font-weight: 600; }
.err { font-size: 12px; color: var(--red); }
.form .end { grid-column: 1 / -1; display: flex; justify-content: flex-end; gap: 8px; padding-top: 4px; }
fieldset { border: 0; margin: 0; padding: 0; min-width: 0; }
.radios { display: flex; flex-direction: column; gap: 8px; }
.radio { display: flex; align-items: flex-start; gap: 10px; border: 1px solid var(--line); border-radius: var(--r-md); padding: 10px 12px; cursor: pointer; }
.radio:has(input:checked) { border-color: var(--blue); background: color-mix(in srgb, var(--sky-10) 60%, transparent); }
.radio input { accent-color: var(--blue); margin-top: 3px; }
.radio b { font-weight: 500; display: block; }
.radio small { color: var(--ink-3); font-size: 12px; }
.radio .essai { display: flex; align-items: center; gap: 8px; margin-top: 8px; color: var(--ink-2); font-size: 13px; }
.radio .essai .in { width: 88px; }

/* ---------- interrupteurs (wallets) ---------- */
.wl { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 12px; }
.wc { background: var(--card); border: 1px solid var(--line); border-radius: var(--r-lg); padding: 14px 16px; display: flex; flex-direction: column; gap: 10px; }
.wc .t { display: flex; align-items: center; gap: 10px; }
.wc .t b { font-size: 15px; font-weight: 600; flex: 1; }
.wdot { width: 12px; height: 12px; border-radius: 50%; flex: none; }
.flds { display: flex; flex-direction: column; gap: 6px; font-size: 13px; }
.fl { display: flex; justify-content: space-between; align-items: center; gap: 8px; cursor: pointer; }
.fl span { color: var(--ink-2); }
.sw { appearance: none; width: 34px; height: 20px; border-radius: 999px; background: var(--line-2); position: relative; flex: none; margin: 0; cursor: pointer; transition: background-color .15s ease-out; }
.sw::after { content: ""; position: absolute; top: 2px; inset-inline-start: 2px; width: 16px; height: 16px; border-radius: 50%; background: var(--on-dark); box-shadow: 0 1px 2px rgba(0,0,0,.25); transition: inset-inline-start .15s ease-out; }
.sw:checked { background: var(--teal-d); }
.sw:checked::after { inset-inline-start: 16px; }
.sw:disabled { opacity: .55; cursor: not-allowed; }
.wc .f2 { font-size: 12px; color: var(--ink-3); border-top: 1px solid var(--row); padding-top: 8px; display: flex; justify-content: space-between; align-items: center; gap: 8px; }

/* ---------- journal ---------- */
.log { display: flex; flex-direction: column; }
.log > div { display: grid; grid-template-columns: auto 1fr auto; gap: 10px; padding: 10px 16px; border-bottom: 1px solid var(--row); font-size: 13px; align-items: baseline; }
.log > div:last-child { border-bottom: 0; }
.log time { color: var(--ink-3); font-size: 12px; }
.log em { font-style: normal; color: var(--ink-3); font-size: 12px; }

/* ---------- messages ---------- */
.flash { display: flex; gap: 10px; align-items: flex-start; border-radius: var(--r-md); padding: 10px 12px; font-size: 13.5px; border: 1px solid transparent; }
.flash.ok { background: var(--teal-10); color: var(--teal-d); border-color: color-mix(in srgb, var(--teal-d) 25%, transparent); }
.flash.ko { background: var(--red-bg); color: var(--red); border-color: color-mix(in srgb, var(--red) 25%, transparent); }

.pager { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 10px 16px; border-top: 1px solid var(--line); font-size: 12.5px; color: var(--ink-3); }

/* ---------- connexion ---------- */
.login { min-height: 100%; background: var(--gradient-brand); display: grid; place-items: center; padding: 32px 16px; }
.login-box { width: 100%; max-width: 380px; display: flex; flex-direction: column; gap: 22px; }
.login-brand { display: flex; flex-direction: column; align-items: center; gap: 6px; text-align: center; color: var(--on-dark); }
.login-brand .mark { width: 74px; height: 74px; border-radius: 20px; box-shadow: 0 10px 24px -10px rgba(0,0,0,.45), 0 0 0 1px rgba(255,255,255,.12); }
.login-brand .name { font-size: 23px; font-weight: 600; letter-spacing: -0.01em; margin-top: 8px; }
.login-brand .name em { font-style: normal; color: var(--teal-on-navy); }
.login-brand .ar { font-size: 18px; font-weight: 500; opacity: .92; }
.login-brand .tag { font-size: 12px; color: var(--login-tag); }
.login-brand .tag em { font-style: normal; color: var(--teal-on-navy); }
.panel { background: var(--card); color: var(--ink); border-radius: var(--r-sheet); padding: 20px; display: flex; flex-direction: column; gap: 14px; box-shadow: var(--shadow-panel); }
.panel h1 { margin: 0; font-size: 17px; color: var(--ink); font-weight: 600; }
.panel .btn { min-height: 44px; }
.check { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--ink-2); }
.check input { accent-color: var(--blue); width: 16px; height: 16px; }

/* ---------- responsive ---------- */
@media (max-width: 980px) {
  .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .cols, .cols.eq { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 760px) {
  .shell { grid-template-columns: minmax(0, 1fr); }
  .side { position: sticky; top: 0; height: auto; flex-direction: row; align-items: center; gap: 10px; padding: 10px 16px; overflow-x: auto; }
  .brand { border: 0; padding: 0; margin: 0; }
  .brand > div { display: none; }
  .nav { flex-direction: row; }
  .nav a { white-space: nowrap; padding: 7px 10px; }
  .nav a svg { display: none; }
  .me { margin: 0 0 0 auto; padding: 0; border: 0; }
  .me .av, .me > div { display: none; }
  main { padding-inline: 16px; }
  .form { grid-template-columns: 1fr; }
  .stats { grid-template-columns: 1fr 1fr; }
  .stats div:last-child:nth-child(odd) { grid-column: 1 / -1; }
  .side-col { position: sticky; top: 0; z-index: 5; }
  .log > div { grid-template-columns: 1fr; gap: 2px; }
}
@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; }
}
