/* Suivi technique — Karellis */
:root {
  --bg: #f4f6f8;
  --surface: #ffffff;
  --surface-2: #f8fafb;
  --border: #dfe4ea;
  --text: #1c2733;
  --text-2: #5b6876;
  --accent: #1f5f8b;
  --accent-hover: #184c70;
  --accent-soft: #e6f0f7;
  --nav-bg: #15222e;
  --nav-text: #c6d1db;
  --nav-active: #ffffff;
  --ok: #1d7a46; --ok-bg: #e3f4ea;
  --warn: #9a5b00; --warn-bg: #fdf1dc;
  --bad: #b3261e; --bad-bg: #fbe6e4;
  --info: #1f5f8b; --info-bg: #e6f0f7;
  --muted: #5b6876; --muted-bg: #eef1f4;
  --radius: 8px;
  --shadow: 0 1px 2px rgba(16, 24, 40, .06);
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #11181f; --surface: #182129; --surface-2: #1d2731; --border: #2b3844;
    --text: #e3e9ef; --text-2: #9aa8b5; --accent: #5fa6d6; --accent-hover: #7db8e0; --accent-soft: #1b3244;
    --nav-bg: #0c1217; --nav-text: #a9b6c2;
    --ok: #5cc98a; --ok-bg: #173323; --warn: #f0b457; --warn-bg: #3a2c12; --bad: #f28b82; --bad-bg: #3d1d1b;
    --info: #7db8e0; --info-bg: #1b3244; --muted: #9aa8b5; --muted-bg: #242f3a;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body { font-family: var(--font); font-size: 15px; line-height: 1.5; color: var(--text); background: var(--bg); }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3 { line-height: 1.25; margin: 0 0 .5rem; }
h1 { font-size: 1.5rem; }
h2 { font-size: 1.1rem; }
h3 { font-size: 1rem; }
p { margin: 0 0 .75rem; }
small, .small { font-size: .85em; }
.muted { color: var(--text-2); }
.nowrap { white-space: nowrap; }
.right { text-align: right; }
.mt { margin-top: 1rem; } .mb { margin-bottom: 1rem; }
.pre { white-space: pre-wrap; }
hr { border: 0; border-top: 1px solid var(--border); margin: 1rem 0; }

/* ---------- Structure ---------- */
.app { display: flex; min-height: 100vh; }
.sidebar {
  width: 236px; flex-shrink: 0; background: var(--nav-bg); color: var(--nav-text);
  display: flex; flex-direction: column; position: sticky; top: 0; height: 100vh; overflow-y: auto;
}
.brand { padding: 1.1rem 1.25rem; display: flex; align-items: center; gap: .6rem; color: #fff; font-weight: 700; letter-spacing: .01em; }
.brand-mark { width: 30px; height: 30px; border-radius: 7px; background: var(--accent); display: grid; place-items: center; font-size: .8rem; color: #fff; }
.brand small { display: block; font-weight: 400; color: var(--nav-text); font-size: .75rem; }
.nav { padding: .25rem .6rem 1rem; flex: 1; }
.nav-section { font-size: .7rem; text-transform: uppercase; letter-spacing: .08em; color: #7f8e9b; padding: 1rem .65rem .35rem; }
.nav a { display: flex; align-items: center; justify-content: space-between; gap: .5rem; padding: .5rem .65rem; border-radius: 6px; color: var(--nav-text); font-size: .93rem; }
.nav a:hover { background: rgba(255, 255, 255, .06); text-decoration: none; color: #fff; }
.nav a.active { background: rgba(255, 255, 255, .1); color: var(--nav-active); font-weight: 600; }
.nav .count { background: var(--bad); color: #fff; border-radius: 999px; font-size: .72rem; padding: 0 .45rem; font-weight: 600; }
.sidebar-user { border-top: 1px solid rgba(255, 255, 255, .08); padding: .9rem 1.25rem; font-size: .85rem; }
.sidebar-user strong { color: #fff; display: block; }
.sidebar-user form { display: inline; }
.sidebar-user .linkish { color: var(--nav-text); }

.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar { display: none; }
.content { padding: 1.5rem 2rem 3rem; max-width: 1280px; width: 100%; }

.page-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 1rem; margin-bottom: 1.25rem; flex-wrap: wrap; }
.page-head .sub { color: var(--text-2); margin-top: .15rem; }
.actions { display: flex; gap: .5rem; flex-wrap: wrap; align-items: center; }
.breadcrumb { font-size: .85rem; color: var(--text-2); margin-bottom: .35rem; }
.breadcrumb a { color: var(--text-2); }

/* ---------- Cartes ---------- */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); margin-bottom: 1.25rem; }
.card-head { display: flex; justify-content: space-between; align-items: center; gap: .75rem; padding: .85rem 1.1rem; border-bottom: 1px solid var(--border); flex-wrap: wrap; }
.card-head h2 { margin: 0; }
.card-body { padding: 1rem 1.1rem; }
.card-body.flush { padding: 0; }
.empty { padding: 1.25rem 1.1rem; color: var(--text-2); text-align: center; }
.grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 1.25rem; }
.grid-3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 1.25rem; }
.grid-2 > .card, .grid-3 > .card { margin-bottom: 0; }
.stack > * + * { margin-top: 1.25rem; }

.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 1rem; margin-bottom: 1.25rem; }
.kpi { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: .9rem 1rem; box-shadow: var(--shadow); display: block; color: inherit; }
.kpi:hover { text-decoration: none; border-color: var(--accent); }
.kpi .label { font-size: .8rem; color: var(--text-2); }
.kpi .value { font-size: 1.7rem; font-weight: 700; line-height: 1.2; font-variant-numeric: tabular-nums; }
.kpi .hint { font-size: .8rem; color: var(--text-2); }
.kpi.bad .value { color: var(--bad); }
.kpi.warn .value { color: var(--warn); }
.kpi.ok .value { color: var(--ok); }

dl.props { display: grid; grid-template-columns: minmax(120px, 190px) 1fr; gap: .45rem 1rem; margin: 0; }
dl.props dt { color: var(--text-2); font-size: .88rem; }
dl.props dd { margin: 0; }

/* ---------- Tableaux ---------- */
.table-wrap { overflow-x: auto; }
table.table { width: 100%; border-collapse: collapse; font-size: .92rem; }
.table th, .table td { padding: .6rem .8rem; text-align: left; border-bottom: 1px solid var(--border); vertical-align: top; }
.table th { font-size: .78rem; text-transform: uppercase; letter-spacing: .04em; color: var(--text-2); font-weight: 600; background: var(--surface-2); white-space: nowrap; }
.table tr:last-child td { border-bottom: 0; }
.table tbody tr:hover { background: var(--surface-2); }
.table td.num { text-align: right; font-variant-numeric: tabular-nums; }
.table .title-cell { min-width: 170px; }
.table .title-cell a { font-weight: 600; }
.row-bad td:first-child { box-shadow: inset 3px 0 0 var(--bad); }
.row-warn td:first-child { box-shadow: inset 3px 0 0 var(--warn); }

/* ---------- Badges ---------- */
.badge { display: inline-flex; align-items: center; gap: .35rem; padding: .1rem .55rem; border-radius: 999px; font-size: .78rem; font-weight: 600; white-space: nowrap; }
.badge .dot { width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.badge-ok { background: var(--ok-bg); color: var(--ok); }
.badge-warn { background: var(--warn-bg); color: var(--warn); }
.badge-bad { background: var(--bad-bg); color: var(--bad); }
.badge-info { background: var(--info-bg); color: var(--info); }
.badge-muted { background: var(--muted-bg); color: var(--muted); }
.text-bad { color: var(--bad); font-weight: 600; }
.text-warn { color: var(--warn); font-weight: 600; }

/* ---------- Boutons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .4rem; padding: .5rem .95rem; border-radius: 6px;
  border: 1px solid var(--border); background: var(--surface); color: var(--text); font: inherit; font-size: .9rem; font-weight: 600;
  cursor: pointer; text-decoration: none; line-height: 1.3; white-space: nowrap;
}
.btn:hover { text-decoration: none; background: var(--surface-2); }
.btn-primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); }
.btn-danger { color: var(--bad); border-color: var(--bad-bg); background: var(--surface); }
.btn-danger:hover { background: var(--bad-bg); }
.btn-sm { padding: .3rem .6rem; font-size: .82rem; }
.btn-block { width: 100%; }
.linkish { background: none; border: 0; padding: 0; color: var(--accent); font: inherit; cursor: pointer; }
.linkish:hover { text-decoration: underline; }
form.inline { display: inline; }

/* ---------- Formulaires ---------- */
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 1rem 1.25rem; }
.form-grid .full { grid-column: 1 / -1; }
.form-grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.field label, .field .label { display: block; font-weight: 600; font-size: .88rem; margin-bottom: .3rem; }
.field .help { font-size: .8rem; color: var(--text-2); margin-top: .25rem; }
.req::after { content: " *"; color: var(--bad); }
input[type=text], input[type=email], input[type=password], input[type=date], input[type=number], input[type=tel], input[type=search], select, textarea {
  width: 100%; padding: .5rem .65rem; border: 1px solid var(--border); border-radius: 6px; font: inherit; font-size: .93rem;
  background: var(--surface); color: var(--text);
}
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent-soft); border-color: var(--accent); }
textarea { min-height: 90px; resize: vertical; }
input[type=file] { font: inherit; font-size: .88rem; max-width: 100%; }
.check { display: flex; align-items: flex-start; gap: .5rem; font-weight: 400 !important; cursor: pointer; }
.check input { margin-top: .25rem; }
.checks { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: .35rem 1rem; padding: .6rem .75rem; border: 1px solid var(--border); border-radius: 6px; max-height: 260px; overflow-y: auto; }
.form-actions { display: flex; gap: .6rem; justify-content: flex-end; margin-top: 1.25rem; flex-wrap: wrap; }
fieldset { border: 1px solid var(--border); border-radius: var(--radius); padding: 1rem 1.1rem; margin: 0 0 1.25rem; }
legend { font-weight: 700; padding: 0 .4rem; }
.role-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: .6rem; }
.role-card { border: 1px solid var(--border); border-radius: 6px; padding: .6rem .75rem; cursor: pointer; display: flex; gap: .55rem; }
.role-card:has(input:checked) { border-color: var(--accent); background: var(--accent-soft); }
.role-card small { display: block; color: var(--text-2); font-weight: 400; }

.filters { display: flex; flex-wrap: wrap; gap: .6rem; align-items: flex-end; margin-bottom: 1rem; }
.filters .field { min-width: 170px; }
.filters .field label { font-size: .78rem; color: var(--text-2); }
.tabs { display: flex; gap: .25rem; border-bottom: 1px solid var(--border); margin-bottom: 1rem; flex-wrap: wrap; }
.tabs a { padding: .5rem .85rem; color: var(--text-2); border-bottom: 2px solid transparent; margin-bottom: -1px; font-weight: 600; font-size: .9rem; }
.tabs a.active { color: var(--accent); border-bottom-color: var(--accent); }
.tabs a:hover { text-decoration: none; color: var(--text); }

/* ---------- Messages ---------- */
.alert { padding: .7rem 1rem; border-radius: 6px; margin-bottom: 1rem; border: 1px solid transparent; }
.alert-success { background: var(--ok-bg); color: var(--ok); }
.alert-error { background: var(--bad-bg); color: var(--bad); }
.alert-info { background: var(--info-bg); color: var(--info); }
.alert-warn { background: var(--warn-bg); color: var(--warn); }
.alert ul { margin: 0; padding-left: 1.2rem; }

/* ---------- Fil d'activité ---------- */
.timeline { list-style: none; margin: 0; padding: 0; }
.timeline li { padding: .65rem 0; border-bottom: 1px solid var(--border); }
.timeline li:last-child { border-bottom: 0; }
.timeline .meta { font-size: .8rem; color: var(--text-2); }
.timeline .sys { color: var(--text-2); font-size: .88rem; font-style: italic; }

.doc-list { list-style: none; margin: 0; padding: 0; }
.doc-list li { display: flex; align-items: center; justify-content: space-between; gap: .75rem; padding: .5rem 0; border-bottom: 1px solid var(--border); }
.doc-list li:last-child { border-bottom: 0; }
.doc-list .doc-name { overflow-wrap: anywhere; }
.upload-form { display: flex; gap: .5rem; flex-wrap: wrap; align-items: center; margin-top: .75rem; }

/* ---------- Page de connexion ---------- */
.auth-page { min-height: 100vh; display: grid; place-items: center; padding: 1.5rem; background: linear-gradient(160deg, #15222e 0%, #1f5f8b 100%); }
.auth-card { width: 100%; max-width: 400px; background: var(--surface); border-radius: 12px; padding: 2rem 1.75rem; box-shadow: 0 10px 40px rgba(0, 0, 0, .25); }
.auth-card .brand { color: var(--text); padding: 0 0 1.25rem; }
.auth-card .brand small { color: var(--text-2); }
.auth-card .field { margin-bottom: 1rem; }
.secret { font-family: ui-monospace, Menlo, Consolas, monospace; font-size: 1.2rem; background: var(--surface-2); border: 1px dashed var(--border); padding: .6rem .9rem; border-radius: 6px; user-select: all; display: inline-block; }

/* ---------- Responsive ---------- */
@media (max-width: 980px) {
  .grid-3 { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 820px) {
  .sidebar { position: fixed; left: 0; top: 0; bottom: 0; z-index: 50; transform: translateX(-100%); transition: transform .2s ease; }
  body.nav-open .sidebar { transform: none; box-shadow: 0 0 40px rgba(0, 0, 0, .35); }
  body.nav-open .overlay { display: block; }
  .overlay { display: none; position: fixed; inset: 0; background: rgba(0, 0, 0, .35); z-index: 40; }
  .topbar { display: flex; align-items: center; gap: .75rem; padding: .6rem 1rem; background: var(--nav-bg); color: #fff; position: sticky; top: 0; z-index: 30; }
  .topbar button { background: none; border: 0; color: #fff; font-size: 1.4rem; cursor: pointer; padding: 0 .25rem; line-height: 1; }
  .topbar .title { font-weight: 700; }
  .content { padding: 1rem 1rem 3rem; }
  .grid-2, .grid-3, .form-grid, .form-grid-3 { grid-template-columns: 1fr; }
  dl.props { grid-template-columns: 1fr; gap: .1rem; }
  dl.props dd { margin-bottom: .5rem; }
  .table .hide-sm { display: none; }
  h1 { font-size: 1.3rem; }
}

/* ---------- Impression (dossier commission) ---------- */
.print-only { display: none; }
@media print {
  :root { --bg: #fff; --surface: #fff; --surface-2: #f3f3f3; --border: #bbb; --text: #000; --text-2: #444; color-scheme: light; }
  body { font-size: 11pt; background: #fff; }
  .sidebar, .topbar, .no-print, .actions, .overlay { display: none !important; }
  .print-only { display: block; }
  .content { padding: 0; max-width: none; }
  .card { box-shadow: none; break-inside: avoid; border-color: #bbb; }
  .table th { background: #eee !important; -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  .badge { border: 1px solid currentColor; -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  a { color: #000; }
}

/* ---------- Utilitaires (pas de style inline : CSP stricte) ---------- */
.narrow { max-width: 520px; }
.narrow-lg { max-width: 640px; }
.border-top { border-top: 1px solid var(--border); }
textarea.short { min-height: 64px; }
.align-field { margin-top: 1.8rem; }
.align-check { margin-bottom: .55rem; }
.mt-sm { margin-top: .5rem; }
.mt-xs { margin-top: .25rem; }
.m0 { margin: 0; }
.kpi .value.value-sm { font-size: 1.15rem; padding: .35rem 0; }
@media (max-width: 820px) { .align-field { margin-top: 0; } }
