/* Administration Tacite-IA : fond blanc, Helvetica, bleu marine et sarcelle ; rouge et ambre pour les alertes. */
:root {
  --bg: #ffffff;
  --soft: #f6f8fa;
  --soft-2: #eef2f6;
  --line: #e3e8ee;
  --ink: #0b1b2e;
  --text: #1a2433;
  --muted: #5a6677;
  --navy: #0b2545;
  --navy-2: #13355f;
  --teal: #0f766e;
  --teal-soft: #e6f4f2;
  --mint: #5eead4;
  --amber: #b45309;
  --amber-soft: #fef3e2;
  --red: #b42318;
  --red-soft: #fdecea;
  --radius: 14px;
  --font: Helvetica, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, monospace;
  color-scheme: light;
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--text); font: 15px/1.5 var(--font); -webkit-font-smoothing: antialiased; }
a { color: var(--teal); }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
h1, h2, h3 { color: var(--ink); letter-spacing: -0.02em; margin: 0; }
:focus-visible { outline: 3px solid var(--teal); outline-offset: 2px; }

/* ---------- Écrans d'accès ---------- */
.auth { min-height: 100vh; display: grid; place-items: center; padding: 24px 16px; background:
  radial-gradient(60% 50% at 80% 0%, rgba(94, 234, 212, .18), transparent 70%),
  radial-gradient(50% 40% at 0% 100%, rgba(15, 118, 110, .10), transparent 70%), var(--bg); }
.auth-card { width: min(440px, 100%); background: #fff; border: 1px solid var(--line); border-radius: 20px; padding: 32px 28px; box-shadow: 0 30px 70px -40px rgba(11, 37, 69, .45); }
.auth-card.wide { width: min(560px, 100%); }
.brand { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 18px; color: var(--ink); letter-spacing: -0.02em; text-decoration: none; }
.brand svg { width: 32px; height: 32px; flex: none; }
.brand b { color: var(--teal); }
.auth h1 { font-size: 24px; margin: 22px 0 6px; }
.auth p.sub { color: var(--muted); margin: 0 0 22px; }
.field { display: grid; gap: 6px; margin-bottom: 14px; }
.field label { font-size: 13px; font-weight: 700; color: var(--ink); }
.field .hint { font-size: 12.5px; color: var(--muted); }
.input, select.input, textarea.input { width: 100%; padding: 11px 13px; border: 1.5px solid var(--line); border-radius: 10px; background: #fff; transition: border-color .15s, box-shadow .15s; }
.input:focus { border-color: var(--teal); box-shadow: 0 0 0 4px rgba(15, 118, 110, .12); outline: none; }
textarea.input { min-height: 90px; font-family: var(--mono); font-size: 13px; resize: vertical; }
.code-input { font-family: var(--mono); font-size: 22px; letter-spacing: .35em; text-align: center; }
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; border: 1.5px solid transparent; border-radius: 10px; padding: 10px 16px; font-weight: 700; font-size: 14px; background: var(--soft); color: var(--ink); transition: background .15s, box-shadow .15s, transform .1s; white-space: nowrap; }
.btn svg { width: 18px; height: 18px; flex: none; }
a.btn { text-decoration: none; }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn.primary { background: var(--navy); color: #fff; }
.btn.primary:hover:not(:disabled) { background: var(--navy-2); box-shadow: 0 10px 24px -12px rgba(11, 37, 69, .6); }
.btn.teal { background: var(--teal); color: #fff; }
.btn.ghost { background: #fff; border-color: var(--line); }
.btn.ghost:hover { border-color: var(--ink); }
.btn.danger { background: #fff; border-color: var(--red); color: var(--red); }
.btn.danger.solid { background: var(--red); color: #fff; }
.btn.block { width: 100%; padding: 12px 16px; }
.error { background: var(--red-soft); color: var(--red); border-radius: 10px; padding: 10px 12px; font-size: 13.5px; margin-bottom: 14px; }
.steps { display: flex; gap: 8px; margin: 18px 0 20px; }
.steps span { flex: 1; height: 4px; border-radius: 4px; background: var(--soft-2); }
.steps span.on { background: var(--teal); }
.qr { display: grid; place-items: center; padding: 16px; background: var(--soft); border: 1px solid var(--line); border-radius: 14px; margin: 6px 0 12px; }
.qr svg { width: 200px; height: 200px; }
.secret { font-family: var(--mono); font-size: 13px; background: var(--soft); border: 1px dashed var(--line); border-radius: 8px; padding: 8px 10px; word-break: break-all; user-select: all; }

/* ---------- Application ---------- */
.shell { display: grid; grid-template-columns: 250px 1fr; min-height: 100vh; }
.side { position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column; gap: 20px; padding: 22px 16px; border-right: 1px solid var(--line); background: var(--soft); }
.company { padding: 12px; border-radius: 12px; background: #fff; border: 1px solid var(--line); }
.company b { display: block; color: var(--ink); font-size: 14px; }
.company span { font-size: 12.5px; color: var(--muted); }
.nav { display: grid; gap: 2px; }
.nav a { display: flex; align-items: center; gap: 10px; padding: 9px 12px; border-radius: 10px; color: var(--text); text-decoration: none; font-weight: 600; font-size: 14px; }
.nav a svg { width: 18px; height: 18px; color: var(--muted); flex: none; }
.nav a:hover { background: #fff; }
.nav a.on { background: var(--navy); color: #fff; }
.nav a.on svg { color: var(--mint); }
.side .foot { margin-top: auto; display: grid; gap: 8px; font-size: 12.5px; color: var(--muted); }
.main { min-width: 0; padding: 28px clamp(16px, 3vw, 40px) 60px; }
.top { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 22px; }
.top h1 { font-size: 26px; }
.top p { margin: 4px 0 0; color: var(--muted); }
.top .actions { display: flex; gap: 8px; flex-wrap: wrap; }
.seg { display: inline-flex; background: var(--soft); border: 1px solid var(--line); border-radius: 10px; padding: 3px; }
.seg button { border: 0; background: transparent; padding: 6px 12px; border-radius: 8px; font-weight: 700; font-size: 13px; color: var(--muted); }
.seg button.on { background: #fff; color: var(--ink); box-shadow: 0 1px 3px rgba(11, 27, 46, .12); }

.alerts { display: grid; gap: 10px; margin-bottom: 18px; }
.alert { display: flex; gap: 12px; align-items: flex-start; padding: 12px 14px; border-radius: 12px; border: 1px solid; font-size: 14px; }
.alert svg { width: 20px; height: 20px; flex: none; margin-top: 1px; }
.alert.warn { background: var(--amber-soft); border-color: #f6d9a8; color: #7a3b06; }
.alert.bad { background: var(--red-soft); border-color: #f5c2bd; color: #7a1a12; }
.alert.info { background: var(--teal-soft); border-color: #b9e3dd; color: #0b4f4a; }

.kpis { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 12px; margin-bottom: 18px; }
.kpi { background: #fff; border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; }
.kpi span { display: block; font-size: 12.5px; color: var(--muted); font-weight: 600; }
.kpi b { display: block; font-size: 30px; line-height: 1.1; color: var(--ink); letter-spacing: -0.03em; margin-top: 6px; font-variant-numeric: tabular-nums; }
.kpi small { color: var(--muted); font-size: 12.5px; }
.kpi.red b { color: var(--red); }
.kpi.teal b { color: var(--teal); }
.kpi.amber b { color: var(--amber); }

.grid2 { display: grid; grid-template-columns: 1.5fr 1fr; gap: 12px; }
.grid3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; margin-top: 12px; }
.card { background: #fff; border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; min-width: 0; }
.card h2 { font-size: 16px; margin-bottom: 4px; }
.card .sub { font-size: 13px; color: var(--muted); margin: 0 0 14px; }
.legend { display: flex; gap: 14px; flex-wrap: wrap; font-size: 12.5px; color: var(--muted); margin-top: 10px; }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 6px; vertical-align: -1px; }
.chart svg { width: 100%; height: 220px; display: block; }
.bars { display: grid; gap: 10px; }
.bar { display: grid; gap: 4px; }
.bar div { display: flex; justify-content: space-between; font-size: 13.5px; gap: 8px; }
.bar div span:first-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bar div b { font-variant-numeric: tabular-nums; color: var(--ink); }
.bar i { display: block; height: 6px; border-radius: 6px; background: var(--soft-2); overflow: hidden; }
.bar i em { display: block; height: 100%; border-radius: inherit; background: linear-gradient(90deg, var(--teal), var(--mint)); }
.empty { color: var(--muted); font-size: 13.5px; padding: 10px 0; }

.table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: var(--radius); background: #fff; }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th { text-align: left; font-size: 12px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); font-weight: 700; padding: 12px 14px; border-bottom: 1px solid var(--line); background: var(--soft); white-space: nowrap; }
td { padding: 12px 14px; border-bottom: 1px solid var(--line); vertical-align: middle; }
tr:last-child td { border-bottom: 0; }
td.mono { font-family: var(--mono); font-size: 12.5px; }
td.right, th.right { text-align: right; }
.pill { display: inline-flex; align-items: center; gap: 6px; padding: 3px 9px; border-radius: 999px; font-size: 12px; font-weight: 700; white-space: nowrap; }
.pill.ok { background: var(--teal-soft); color: var(--teal); }
.pill.warn { background: var(--amber-soft); color: var(--amber); }
.pill.bad { background: var(--red-soft); color: var(--red); }
.pill.off { background: var(--soft-2); color: var(--muted); }
.chips { display: flex; flex-wrap: wrap; gap: 4px; }
.chip { font-size: 12px; padding: 2px 8px; border-radius: 6px; background: var(--soft); border: 1px solid var(--line); white-space: nowrap; }
.filters { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; margin-bottom: 14px; }
.filters select { width: auto; }

.form { display: grid; gap: 14px; max-width: 900px; }
.section { background: #fff; border: 1px solid var(--line); border-radius: var(--radius); padding: 20px; }
.section h2 { font-size: 16px; }
.section > p { color: var(--muted); font-size: 13.5px; margin: 4px 0 16px; }
.choices { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.choice { display: flex; gap: 12px; align-items: flex-start; padding: 14px; border: 1.5px solid var(--line); border-radius: 12px; cursor: pointer; }
.choice input { margin-top: 3px; accent-color: var(--teal); }
.choice b { display: block; color: var(--ink); }
.choice span { font-size: 13px; color: var(--muted); }
.choice:has(input:checked) { border-color: var(--teal); background: var(--teal-soft); }
.rule-row { display: flex; justify-content: space-between; align-items: center; gap: 16px; padding: 12px 0; border-bottom: 1px solid var(--line); }
.rule-row:last-child { border-bottom: 0; }
.rule-row span { font-size: 14px; }
.rule-row select { width: 190px; flex: none; }
.row2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.switch { display: flex; gap: 12px; align-items: flex-start; }
.switch input { width: 40px; height: 22px; appearance: none; background: var(--soft-2); border-radius: 999px; position: relative; cursor: pointer; flex: none; transition: background .2s; }
.switch input::after { content: ''; position: absolute; top: 3px; left: 3px; width: 16px; height: 16px; border-radius: 50%; background: #fff; box-shadow: 0 1px 3px rgba(0, 0, 0, .2); transition: left .2s; }
.switch input:checked { background: var(--teal); }
.switch input:checked::after { left: 21px; }
.savebar { position: sticky; bottom: 0; display: flex; justify-content: flex-end; gap: 10px; padding: 14px 0; background: linear-gradient(transparent, #fff 30%); }

.keybox { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; font-family: var(--mono); font-size: 15px; padding: 14px 16px; background: var(--soft); border: 1px solid var(--line); border-radius: 12px; }
.keybox.fresh { background: var(--teal-soft); border-color: #b9e3dd; }
pre.snippet { margin: 0; padding: 14px; background: #0b1b2e; color: #d7e0ec; border-radius: 12px; overflow-x: auto; font: 12.5px/1.6 var(--mono); white-space: pre; }
.tabs { display: flex; gap: 6px; flex-wrap: wrap; margin: 14px 0 10px; }
.dl { display: grid; grid-template-columns: max-content 1fr; gap: 10px 20px; font-size: 14px; }
.dl dt { color: var(--muted); }
.dl dd { margin: 0; color: var(--ink); font-weight: 600; }

/* Fenêtre de confirmation (centrée, dans la page) */
.veil { position: fixed; inset: 0; background: rgba(11, 27, 46, .45); display: grid; place-items: center; padding: 16px; z-index: 50; }
.modal { width: min(460px, 100%); background: #fff; border-radius: 16px; padding: 22px; box-shadow: 0 30px 70px -20px rgba(11, 27, 46, .5); }
.modal h2 { font-size: 18px; margin-bottom: 8px; }
.modal p { color: var(--muted); margin: 0 0 18px; font-size: 14px; }
.modal .acts { display: flex; justify-content: flex-end; gap: 8px; flex-wrap: wrap; }

.toasts { position: fixed; right: 16px; bottom: 16px; display: grid; gap: 8px; z-index: 60; max-width: min(380px, calc(100vw - 32px)); }
.toast { background: var(--ink); color: #fff; padding: 12px 14px; border-radius: 12px; font-size: 14px; box-shadow: 0 14px 34px -14px rgba(11, 27, 46, .6); }
.toast.bad { background: var(--red); }
.loading { color: var(--muted); padding: 40px 0; }
.print-only { display: none; }

@media (max-width: 1100px) {
  .kpis { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .grid2, .grid3 { grid-template-columns: 1fr; }
}
@media (max-width: 768px) {
  .shell { grid-template-columns: minmax(0, 1fr); }
  .side, .nav, .main { min-width: 0; max-width: 100vw; }
  .rule-row select { width: 100%; }
  .side { position: static; height: auto; flex-direction: row; flex-wrap: wrap; align-items: center; gap: 10px; padding: 12px 16px; border-right: 0; border-bottom: 1px solid var(--line); }
  .side .company, .side .foot { display: none; }
  .nav { grid-auto-flow: column; overflow-x: auto; width: 100%; gap: 4px; }
  .nav a { padding: 8px 10px; font-size: 13px; }
  .nav a svg { display: none; }
  .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .choices, .row2 { grid-template-columns: 1fr; }
  .rule-row { flex-direction: column; align-items: flex-start; }
  .top h1 { font-size: 22px; }
}
@media print {
  .side, .top .actions, .savebar, .toasts, .no-print { display: none !important; }
  .shell { grid-template-columns: 1fr; }
  .main { padding: 0; }
  .print-only { display: block; }
  .card, .kpi { break-inside: avoid; }
}

.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; }
