/* ============================================================
   PROPHETdesign — PRDE Calibre : famille d'applications
   Navigation latérale sombre, cartes claires, teintes porteuses
   de sens (vert = en ordre, ambre = à surveiller, rouge = échu),
   chiffres monospace tabulaires. Une couleur d'accent par
   application : le « calibre ». Ici : teal profond.
   ============================================================ */

:root {
  --accent:      #1F5E63;
  --accent-soft: #E4EEEE;
  --accent-ink:  #FFFFFF;

  --bg:      #F2F3EF;
  --panel:   #FFFFFF;
  --panel-2: #F7F8F5;
  --ink:     #191B1F;
  --ink-2:   #3D4148;
  --muted:   #767B84;
  --line:    #E3E5E0;
  --line-2:  #EDEEEA;

  --ok:   #1E7F4F;
  --warn: #B26A00;
  --err:  #B3261E;
  --info: #2A5B92;
  --off:  #8A8F98;

  --t-ok:   #E6F2EB;
  --t-warn: #FBF0DF;
  --t-err:  #FBEAE8;
  --t-info: #E7EEF7;
  --t-off:  #EFF0F1;

  --side:       #1B1D22;
  --side-ink:   #A8ADB6;
  --side-hover: #262930;

  --mono: "SF Mono", "Cascadia Mono", Consolas, "Liberation Mono", monospace;
  --r: 14px;
  --r-s: 9px;
  --shadow:   0 1px 2px rgba(25,27,31,.04), 0 6px 20px -12px rgba(25,27,31,.14);
  --sidew: 232px;
}

[data-theme="dark"] {
  --accent-soft: #17282A;
  --bg:      #101215;
  --panel:   #191C20;
  --panel-2: #1F2328;
  --ink:     #E8EAE6;
  --ink-2:   #C3C7CC;
  --muted:   #8C939C;
  --line:    #2A2E34;
  --line-2:  #23272C;

  --ok:   #4FB183;
  --warn: #DE9B39;
  --err:  #E37167;
  --info: #6E9BD1;
  --off:  #7C838C;

  --t-ok:   #14291F;
  --t-warn: #2C2415;
  --t-err:  #2E1A19;
  --t-info: #1A2431;
  --t-off:  #22262B;

  --side:       #0B0D10;
  --side-ink:   #949BA5;
  --side-hover: #191C21;
  --shadow: 0 1px 2px rgba(0,0,0,.4);
}

* { box-sizing: border-box; }
html { color-scheme: light dark; }
[data-theme="light"] { color-scheme: light; }
[data-theme="dark"]  { color-scheme: dark; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 15px/1.55 -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  -webkit-text-size-adjust: 100%;
}
a { color: var(--accent); }
[data-theme="dark"] a { color: color-mix(in srgb, var(--accent) 50%, #FFFFFF); }

h1 { font-size: 24px; margin: 4px 0 18px; letter-spacing: -.01em; }
h2 { font-size: 16px; margin: 0 0 12px; letter-spacing: -.005em; }
hr { border: none; border-top: 1px solid var(--line); margin: 18px 0; }

.mono { font-family: var(--mono); font-variant-numeric: tabular-nums; }
.muted { color: var(--muted); }
.small { font-size: 12.5px; }
.pos { color: var(--ok); }
.neg { color: var(--err); }

/* ------------------------------ Coquille ------------------------------ */

.shell { display: flex; min-height: 100vh; }

.side {
  width: var(--sidew); flex: 0 0 var(--sidew);
  background: var(--side); color: var(--side-ink);
  display: flex; flex-direction: column; position: sticky; top: 0; height: 100vh;
}
.side-brand { padding: 20px 18px 14px; display: flex; flex-direction: column; gap: 2px; }
.suite { font-size: 11px; letter-spacing: .14em; text-transform: uppercase; color: var(--side-ink); }
.appname { font-size: 19px; color: #fff; font-weight: 600; letter-spacing: -.01em; }

.side-nav { display: flex; flex-direction: column; gap: 2px; padding: 8px 10px; flex: 1; overflow-y: auto; }
.side a.nav {
  display: flex; align-items: center; gap: 10px;
  color: var(--side-ink); text-decoration: none; font-size: 14px;
  padding: 9px 11px; border-radius: var(--r-s);
}
.side a.nav:hover { background: var(--side-hover); color: #fff; }
.side a.nav.on { background: var(--accent); color: var(--accent-ink); font-weight: 600; }
.side .ic { display: inline-flex; width: 19px; height: 19px; }
.side .ic svg { width: 100%; height: 100%; }

.side-foot { padding: 14px 16px 18px; border-top: 1px solid rgba(255,255,255,.08); }

/* Solde de crédits, visible depuis n'importe quelle page. */
.credits-pastille {
  display: flex; align-items: baseline; justify-content: space-between;
  gap: 8px; margin-bottom: 12px; padding: 8px 11px;
  border: 1px solid rgba(255,255,255,.14); border-radius: var(--r-s);
  text-decoration: none; color: var(--side-ink);
}
.credits-pastille:hover { background: var(--side-hover); }
.credits-pastille .lab { font-size: 11px; letter-spacing: .1em; text-transform: uppercase; }
.credits-pastille .val { font-size: 17px; color: #fff; font-weight: 600; }
.credits-pastille.bas { border-color: rgba(222,155,57,.5); }
.credits-pastille.bas .val { color: #DE9B39; }
.who { display: flex; flex-direction: column; margin-bottom: 10px; }
.who strong { color: #fff; font-size: 13.5px; }
.who span { font-size: 11.5px; }
.side-actions { display: flex; gap: 6px; flex-wrap: wrap; }
.mini {
  background: none; border: 1px solid rgba(255,255,255,.16); color: var(--side-ink);
  border-radius: var(--r-s); padding: 5px 9px; font: inherit; font-size: 12.5px;
  cursor: pointer; text-decoration: none;
}
.mini:hover { background: var(--side-hover); color: #fff; }
.ver { margin-top: 10px; font-size: 11px; opacity: .6; font-family: var(--mono); }

.mobar { display: none; }
.wrap { flex: 1; padding: 26px 28px 60px; max-width: 1280px; }

/* -------------------------------- Cartes ------------------------------ */

.card {
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--r);
  box-shadow: var(--shadow); padding: 20px; margin-bottom: 18px;
}
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }
.statrow { display: flex; gap: 14px; flex-wrap: wrap; margin-bottom: 18px; }
.card.stat { flex: 1 1 190px; margin: 0; padding: 16px 18px; }
.stat-lab { font-size: 12.5px; color: var(--muted); }
.stat-num { font-size: 30px; font-family: var(--mono); font-variant-numeric: tabular-nums; line-height: 1.25; }
.stat-sub { font-size: 12px; color: var(--muted); }
.card.t-ok   { background: var(--t-ok);   border-color: color-mix(in srgb, var(--ok) 30%, transparent); }
.card.t-warn { background: var(--t-warn); border-color: color-mix(in srgb, var(--warn) 30%, transparent); }
.card.t-err  { background: var(--t-err);  border-color: color-mix(in srgb, var(--err) 30%, transparent); }
.card.t-info { background: var(--t-info); border-color: color-mix(in srgb, var(--info) 30%, transparent); }

/* ------------------------------ Tableaux ------------------------------ */

table.full { width: 100%; border-collapse: collapse; font-size: 14px; }
table.full th {
  text-align: left; font-size: 11.5px; text-transform: uppercase; letter-spacing: .06em;
  color: var(--muted); font-weight: 600; padding: 6px 8px; border-bottom: 1px solid var(--line);
}
table.full th a.tri { color: inherit; text-decoration: none; display: inline-flex; gap: 2px; white-space: nowrap; }
table.full th a.tri:hover { color: var(--ink); }
table.full th a.tri.on { color: var(--accent); }
table.full th a.tri .fleche { font-weight: 700; }

table.full td { padding: 9px 8px; border-bottom: 1px solid var(--line-2); vertical-align: top; }
table.full tr:last-child td { border-bottom: none; }
table.full td.num, table.full th.num { text-align: right; }
table.full td.tick, table.full th.tick { width: 28px; }
td.msg { color: var(--ink-2); font-size: 13px; max-width: 380px; }

table.kv { width: 100%; border-collapse: collapse; font-size: 14px; }
table.kv th {
  text-align: left; font-weight: 500; color: var(--muted); width: 40%;
  padding: 7px 8px 7px 0; border-bottom: 1px solid var(--line-2); vertical-align: top;
}
table.kv td { padding: 7px 0; border-bottom: 1px solid var(--line-2); }

ul.plain { list-style: none; padding: 0; margin: 8px 0; font-size: 13.5px; }
ul.plain li { padding: 3px 0; border-bottom: 1px solid var(--line-2); }
pre.code {
  background: var(--panel-2); border: 1px solid var(--line); border-radius: var(--r-s);
  padding: 12px 14px; overflow-x: auto; font-family: var(--mono); font-size: 12.5px; margin: 8px 0;
}
code { font-family: var(--mono); font-size: .92em; background: var(--panel-2); padding: 1px 5px; border-radius: 4px; }

/* ------------------------------ Pastilles ----------------------------- */

.pill {
  display: inline-block; font-size: 11.5px; font-weight: 600; padding: 2px 8px;
  border-radius: 100px; white-space: nowrap;
}
.pill.ok   { background: var(--t-ok);   color: var(--ok); }
.pill.warn { background: var(--t-warn); color: var(--warn); }
.pill.err  { background: var(--t-err);  color: var(--err); }
.pill.info { background: var(--t-info); color: var(--info); }
.pill.off  { background: var(--t-off);  color: var(--off); }

/* ----------------------------- Formulaires ---------------------------- */

label { display: block; margin-bottom: 12px; font-size: 13px; color: var(--ink-2); }
label.checkline { display: flex; align-items: center; gap: 8px; }
input[type=text], input[type=password], input[type=email], input[type=date],
input[type=number], input[type=search], input[type=file], select, textarea {
  width: 100%; margin-top: 5px; padding: 9px 11px; font: inherit; font-size: 14px;
  color: var(--ink); background: var(--panel); border: 1px solid var(--line);
  border-radius: var(--r-s);
}
label.checkline input[type=checkbox] { width: auto; margin: 0; }
textarea { resize: vertical; }
input:focus, select:focus, textarea:focus {
  outline: none; border-color: var(--accent);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 18%, transparent);
}
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.row3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 12px; }

.btn {
  display: inline-flex; align-items: center; gap: 7px; cursor: pointer;
  background: var(--panel); color: var(--ink); border: 1px solid var(--line);
  border-radius: var(--r-s); padding: 9px 15px; font: inherit; font-size: 14px;
  text-decoration: none;
}
.btn:hover { background: var(--panel-2); }
.btn.primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.btn.primary:hover { filter: brightness(1.08); }
.btn.danger { color: var(--err); border-color: color-mix(in srgb, var(--err) 35%, var(--line)); }
.btn.small { padding: 5px 10px; font-size: 12.5px; }
.btn.wide { width: 100%; justify-content: center; }
.btnrow { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; margin: 12px 0; }
.btnrow form { margin: 0; }
.inline-form { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; margin-bottom: 16px; }
.inline-form input, .inline-form select { width: auto; min-width: 170px; margin-top: 0; }

/* ------------------------------- Onglets ------------------------------ */

.tabs { display: flex; gap: 4px; flex-wrap: wrap; margin-bottom: 16px; }
.tab {
  padding: 7px 13px; border-radius: 100px; text-decoration: none;
  color: var(--ink-2); font-size: 13.5px; border: 1px solid transparent;
}
.tab:hover { background: var(--panel); border-color: var(--line); }
.tab.on { background: var(--accent); color: var(--accent-ink); font-weight: 600; }
.tab .compte { opacity: .65; font-variant-numeric: tabular-nums; font-weight: 400; }

/* ------------------------------- Messages ----------------------------- */

.flash {
  padding: 11px 15px; border-radius: var(--r-s); margin-bottom: 16px;
  font-size: 14px; border: 1px solid;
}
.flash.ok   { background: var(--t-ok);   border-color: color-mix(in srgb, var(--ok) 35%, transparent);   color: var(--ok); }
.flash.warn { background: var(--t-warn); border-color: color-mix(in srgb, var(--warn) 35%, transparent); color: var(--warn); }
.flash.err  { background: var(--t-err);  border-color: color-mix(in srgb, var(--err) 35%, transparent);  color: var(--err); }

/* ------------------------------ Connexion ----------------------------- */

body.plain { display: block; }
.auth-card {
  max-width: 420px; margin: 8vh auto; background: var(--panel);
  border: 1px solid var(--line); border-radius: var(--r);
  box-shadow: var(--shadow); padding: 30px;
}
.auth-head { display: flex; flex-direction: column; gap: 2px; margin-bottom: 22px; }
.auth-head .suite { color: var(--muted); }
.auth-head .appname { color: var(--ink); font-size: 22px; font-weight: 600; }

.prose h2 { font-size: 17px; margin: 22px 0 10px; }
.prose h2:first-child { margin-top: 0; }
.prose h3 { font-size: 14px; margin: 16px 0 8px; color: var(--muted);
            text-transform: uppercase; letter-spacing: .05em; }
.prose p { margin: 8px 0; font-size: 14px; color: var(--ink-2); }
.prose ul.plain li { border-bottom: none; padding: 4px 0 4px 16px; position: relative; font-size: 14px; }
.prose ul.plain li::before { content: "—"; position: absolute; left: 0; color: var(--muted); }
.prose hr { margin: 26px 0; }

.m0 { margin: 0; }
.champ-titre { font-size: 13px; color: var(--ink-2); margin: 14px 0 6px; }
input.ed, select.ed {
  width: 100%; min-width: 130px; margin-top: 0; padding: 5px 8px;
  font-size: 13px; background: var(--panel-2);
}
.inline-lab { display: inline-flex; align-items: center; gap: 8px; margin: 0; font-size: 13px; }
.inline-lab select { width: auto; margin-top: 0; }

select.mini-select { width: auto; max-width: 260px; margin-top: 5px;
                     font-size: 12.5px; padding: 4px 8px; }
.mw-520 { max-width: 520px; }
.mt-18 { margin-top: 18px; }
form.inline { display: inline; }
.auth-card.wide { max-width: 560px; }

/* ------------------------------ Responsive ---------------------------- */

@media (max-width: 900px) {
  .side { display: none; }
  .shell { flex-direction: column; }
  .mobar {
    display: block; background: var(--side); color: var(--side-ink);
    position: sticky; top: 0; z-index: 20;
  }
  .mobrand { color: #fff; font-weight: 600; padding: 12px 14px 0; display: inline-block; }
  .mobar-actions { float: right; display: flex; gap: 7px; padding: 12px 14px 0; }
  .monav { display: flex; gap: 3px; overflow-x: auto; padding: 10px 12px; scrollbar-width: none; clear: both; }
  .monav::-webkit-scrollbar { display: none; }
  .monav a {
    color: var(--side-ink); text-decoration: none; font-size: 13.5px;
    padding: 7px 12px; border-radius: var(--r-s); white-space: nowrap;
  }
  .monav a.on { background: var(--accent); color: var(--accent-ink); font-weight: 600; }
  .wrap { padding: 20px 14px 56px; }
  .grid2, .row2, .row3 { grid-template-columns: 1fr; gap: 14px; }
  .card.stat { flex: 1 1 calc(50% - 7px); }
  h1 { font-size: 21px; }
  .stat-num { font-size: 26px; }
  td.msg { max-width: none; }
}

@media (max-width: 560px) {
  .card.stat { flex: 1 1 100%; }
  .btnrow { flex-direction: column; align-items: stretch; }
  .btnrow .btn, .btn.wide { width: 100%; justify-content: center; }
  .inline-form { flex-direction: column; align-items: stretch; }
  .inline-form input, .inline-form select, .inline-form .btn { width: 100%; }
  table.full, table.full tbody, table.full tr, table.full td { display: block; width: 100%; }
  table.full thead { display: none; }
  table.full tr { border-bottom: 1px solid var(--line); padding: 10px 0; }
  table.full td { border: none; padding: 3px 0; }
  table.full td:empty { display: none; }
  table.full td.num { text-align: left; }
}

@media (prefers-reduced-motion: no-preference) {
  .btn, .tab, .side a.nav, .monav a { transition: background .13s ease, color .13s ease, border-color .13s ease; }
}
