:root {
    --bg:#EEEEF7; --surface:#FFFFFF; --border:#DDDDF0;
    --text-1:#0A0A1E; --text-2:#6060A0; --text-3:#9090C0;
    --accent:#10A37F; --accent-soft:rgba(16,163,127,.12);
    --err:#EF4444; --ok:#10B981; --warn:#F59E0B; --info:#3B82F6;
}
@media (prefers-color-scheme:dark) {
    :root {
        --bg:#07070F; --surface:#111122; --border:#1C1C38;
        --text-1:#DCDCF4; --text-2:#7A7AA8; --text-3:#48487A;
        --accent:#19C37D; --accent-soft:rgba(25,195,125,.14);
    }
}
*,*::before,*::after { box-sizing:border-box; margin:0; padding:0; }
body { font-family:system-ui,-apple-system,'Segoe UI',sans-serif; background:var(--bg); color:var(--text-1); min-height:100vh; min-height:100dvh; line-height:1.5; -webkit-text-size-adjust:100%; }
input, textarea, select, button { font:inherit; color:inherit; }
input, textarea, select {
    width:100%; padding:8px 11px; background:var(--bg); border:1.5px solid var(--border);
    border-radius:10px; outline:none; transition:border-color .15s;
}
input[type=checkbox] { width:auto; }
input:focus, textarea:focus, select:focus { border-color:var(--accent); }
textarea { resize:vertical; }
a { color:var(--accent); }
code { font-family:ui-monospace,Menlo,Consolas,monospace; font-size:.85em; background:var(--accent-soft); padding:1px 5px; border-radius:5px; overflow-wrap:anywhere; }

.btn { border:none; border-radius:10px; padding:7px 13px; cursor:pointer; font-weight:600; font-size:.8125rem; transition:opacity .15s; background:var(--accent-soft); color:var(--accent); text-decoration:none; display:inline-block; white-space:nowrap; }
.btn:hover { opacity:.85; }
.btn:disabled { opacity:.4; cursor:default; }
.btn-primary { background:var(--accent); color:#fff; }
.btn-danger { background:rgba(239,68,68,.1); color:var(--err); }

.card { background:var(--surface); border:1px solid var(--border); border-radius:16px; padding:18px 20px; margin-bottom:16px; }
.logo { font-size:1.375rem; font-weight:800; letter-spacing:-.02em; display:flex; align-items:center; gap:8px; }
.logo span { color:var(--accent); }
.logo-img { width:30px; height:30px; }
.subtitle { font-size:.875rem; color:var(--text-2); }
.muted { color:var(--text-3); }
.small { font-size:.75rem; }

.login-body { display:flex; align-items:center; justify-content:center; padding:24px; }
.login-card { width:100%; max-width:360px; padding:32px; display:flex; flex-direction:column; gap:14px; }
.alert { padding:10px 14px; border-radius:8px; font-size:.875rem; background:rgba(239,68,68,.1); color:var(--err); }
.back { text-align:center; font-size:.8125rem; color:var(--text-3); text-decoration:none; }

.wrap { max-width:1150px; margin:0 auto; padding:24px 16px 80px; }
header { display:flex; align-items:center; justify-content:space-between; gap:12px; margin-bottom:20px; flex-wrap:wrap; }
header nav { display:flex; gap:8px; flex-wrap:wrap; }
h2 { font-size:1.05rem; }
.section-head { display:flex; align-items:center; justify-content:space-between; gap:12px; flex-wrap:wrap; margin-bottom:12px; }
.inline-form { display:flex; gap:8px; flex-wrap:wrap; }
.inline-form input { width:auto; min-width:150px; }
.inline-form select { width:auto; }
.grid-form { display:grid; grid-template-columns:repeat(auto-fit,minmax(150px,1fr)); gap:10px; align-items:end; margin-bottom:14px; }
.grid-form label { display:flex; flex-direction:column; gap:4px; font-size:.75rem; color:var(--text-2); font-weight:600; }
.grid-form label.check { flex-direction:row; align-items:center; gap:6px; padding-bottom:8px; }
.grid-form .wide { grid-column:1 / -1; }
.thumbs { display:flex; gap:8px; flex-wrap:wrap; }
.output img { display:block; max-width:100%; max-height:420px; margin-top:10px; border-radius:10px; }
.live-info { font-size:.8125rem; color:var(--text-2); margin-bottom:10px; }
.live-shot { display:block; width:100%; border-radius:10px; border:1px solid var(--border); }
.live-shot[hidden] { display:none; }
.thumbs:empty { display:none; }
.thumbs img { width:72px; height:72px; object-fit:cover; border-radius:8px; border:1px solid var(--border); }
.notice { font-size:.8125rem; color:var(--text-2); background:var(--accent-soft); border-radius:10px; padding:10px 14px; margin-bottom:12px; }

.status-bar { display:flex; align-items:center; gap:8px; justify-content:space-between; font-size:.875rem; flex-wrap:wrap; }
.dot { width:10px; height:10px; border-radius:50%; display:inline-block; }
.dot.ok { background:var(--ok); } .dot.err { background:var(--err); }

.table { width:100%; border-collapse:collapse; font-size:.8125rem; }
.table th { text-align:left; font-size:.6875rem; text-transform:uppercase; letter-spacing:.06em; color:var(--text-3); padding:6px 8px; border-bottom:1px solid var(--border); }
.table td { padding:9px 8px; border-bottom:1px solid var(--border); vertical-align:top; }
.table tr.revoked td { opacity:.55; }
.table td.actions { display:flex; gap:6px; flex-wrap:wrap; justify-content:flex-end; }
.table.small td { padding:6px 8px; }
.log-content pre { white-space:pre-wrap; font-size:.75rem; margin-top:6px; max-height:300px; overflow:auto; }

.badge { display:inline-block; font-size:.6875rem; font-weight:700; padding:2px 8px; border-radius:999px; background:var(--accent-soft); color:var(--text-2); }
.badge.ok { background:rgba(16,185,129,.14); color:var(--ok); }
.badge.warn { background:rgba(245,158,11,.14); color:var(--warn); }
.badge.err { background:rgba(239,68,68,.12); color:var(--err); }
.badge.info { background:rgba(59,130,246,.12); color:var(--info); }

.output { white-space:pre-wrap; word-break:break-word; font-family:ui-monospace,Menlo,Consolas,monospace; font-size:.8125rem; background:var(--bg); border:1px solid var(--border); border-radius:10px; padding:12px; max-height:480px; overflow:auto; }

.modal { position:fixed; inset:0; background:rgba(0,0,0,.45); display:flex; align-items:center; justify-content:center; padding:16px; z-index:10; }
.modal[hidden], .toast[hidden] { display:none; }
.modal-card { max-width:560px; width:100%; max-height:100%; overflow-y:auto; margin-bottom:0; display:flex; flex-direction:column; gap:12px; }
.modal-actions { display:flex; gap:8px; justify-content:flex-end; }
.toast { position:fixed; bottom:20px; left:50%; transform:translateX(-50%); background:var(--text-1); color:var(--bg); padding:10px 18px; border-radius:10px; font-size:.875rem; z-index:20; max-width:90vw; }
.toast.error { background:var(--err); color:#fff; }

.meter { height:4px; border-radius:2px; background:var(--accent-soft); margin:2px 0 3px; min-width:70px; overflow:hidden; }
.meter span { display:block; height:100%; border-radius:2px; background:var(--accent); }
.meter span.full { background:var(--err); }
select[multiple] { padding:4px 6px; }

.viz-root { --series-1:#2a78d6; --series-2:#eb6834; --critical:#d03b3b; }
@media (prefers-color-scheme:dark) { .viz-root { --series-1:#3987e5; --series-2:#d95926; } }
.filters { display:flex; gap:8px; flex-wrap:wrap; align-items:center; }
.filters select { width:auto; }
.seg { display:inline-flex; border:1.5px solid var(--border); border-radius:10px; overflow:hidden; }
.seg button { border:none; background:none; padding:6px 12px; cursor:pointer; font-size:.8125rem; font-weight:600; color:var(--text-2); }
.seg button.active { background:var(--accent-soft); color:var(--text-1); }
.tiles { display:grid; grid-template-columns:repeat(auto-fit,minmax(170px,1fr)); gap:10px; margin-bottom:8px; }
.tile { border:1px solid var(--border); border-radius:12px; padding:10px 14px; display:flex; flex-direction:column; }
.tile span { font-size:.75rem; color:var(--text-2); font-weight:600; }
.tile strong { font-size:1.6rem; font-weight:600; line-height:1.3; }
.tile small { font-size:.75rem; color:var(--text-2); }
.charts { display:grid; grid-template-columns:repeat(auto-fit,minmax(min(420px,100%),1fr)); gap:14px 20px; margin:12px 0; align-items:start; }
.chart figcaption { display:flex; justify-content:space-between; gap:10px; flex-wrap:wrap; font-size:.8125rem; margin-bottom:4px; }
.chart .legend { display:flex; gap:12px; color:var(--text-2); font-size:.75rem; }
.chart .legend i, .viz-tip i { display:inline-block; width:8px; height:8px; border-radius:2px; margin-right:5px; }
.chart .plot { position:relative; }
.chart svg { display:block; width:100%; height:auto; }
.chart .grid { stroke:var(--border); stroke-width:1; }
.chart .axis { stroke:var(--text-3); stroke-width:1; }
.chart .tick { font-size:10px; fill:var(--text-2); font-variant-numeric:tabular-nums; }
.chart .line { fill:none; stroke-width:2; stroke-linejoin:round; stroke-linecap:round; }
.chart .dot { stroke:var(--surface); stroke-width:2; }
.chart .band { fill:var(--text-1); opacity:.06; }
.chart .hit { fill:transparent; }
.viz-tip { position:absolute; top:4px; background:var(--surface); border:1px solid var(--border); border-radius:8px; padding:6px 10px; font-size:.75rem; pointer-events:none; white-space:nowrap; box-shadow:0 4px 14px rgba(0,0,0,.12); z-index:2; }
.viz-tip[hidden] { display:none; }
.viz-tip div { display:flex; align-items:center; color:var(--text-2); }
.viz-tip b { margin-left:auto; padding-left:14px; color:var(--text-1); font-variant-numeric:tabular-nums; }

.doc { max-width:900px; }
.doc h2 { margin:26px 0 10px; font-size:1.2rem; }
.doc h3 { margin:18px 0 6px; font-size:1rem; }
.doc p, .doc li { font-size:.9rem; color:var(--text-1); }
.doc ul { padding-left:20px; margin:6px 0; }
.table-scroll { overflow-x:auto; }
.doc table { width:100%; border-collapse:collapse; font-size:.8125rem; margin:10px 0; }
.doc th, .doc td { border:1px solid var(--border); padding:6px 8px; text-align:left; vertical-align:top; }
.doc th { background:var(--accent-soft); }
.tag { font-size:.6875rem; font-weight:700; padding:1px 7px; border-radius:999px; }
.tag.ok { background:rgba(16,185,129,.14); color:var(--ok); }
.tag.warn { background:rgba(245,158,11,.14); color:var(--warn); }
.tag.err { background:rgba(239,68,68,.12); color:var(--err); }

/* Mobile : formulaires en pleine largeur, cibles tactiles élargies, tableaux transformés en cartes (libellés posés par app.js) */
@media (max-width:760px) {
    input, textarea, select { font-size:1rem; padding:10px 12px; }
    input[type=checkbox] { width:20px; height:20px; flex:none; }
    input[type=file] { font-size:.8125rem; }
    .btn { padding:10px 14px; font-size:.875rem; text-align:center; }

    .wrap { padding:14px 10px 72px; }
    .card { padding:14px; border-radius:14px; margin-bottom:12px; }
    .login-body { padding:16px; }
    .login-card { padding:24px 20px; }
    header { margin-bottom:14px; }
    .logo { font-size:1.2rem; }
    .subtitle { font-size:.8125rem; }
    header nav { width:100%; }
    header nav .btn { flex:1 1 auto; }

    .status-bar { font-size:.8125rem; }
    .status-bar .btn, .section-head > .btn { flex:1 1 100%; }
    .section-head > div:not(.filters) { display:flex; gap:8px; flex:1 1 100%; }
    .section-head > div:not(.filters) .btn { flex:1; }
    .inline-form { width:100%; }
    .inline-form input, .inline-form select { flex:1 1 140px; min-width:0; }
    .inline-form select[multiple], .inline-form .btn { flex:1 1 100%; }
    .grid-form { grid-template-columns:repeat(2,minmax(0,1fr)); }
    .grid-form label.check, .grid-form > .btn { grid-column:1 / -1; }
    .grid-form label.check { padding:4px 0; font-size:.8125rem; }
    .notice { padding:10px 12px; }
    .notice .btn { margin:4px 0; }
    .output { font-size:.75rem; padding:10px; max-height:60vh; }

    .filters { width:100%; }
    .filters .seg { display:flex; flex:1 1 100%; }
    .filters .seg button { flex:1; padding:10px 12px; }
    .filters select, .filters .btn { flex:1 1 130px; min-width:0; }
    .tiles { grid-template-columns:repeat(2,minmax(0,1fr)); gap:8px; }
    .tile { padding:10px 12px; }
    .tile strong { font-size:1.3rem; }
    .viz-tip { white-space:normal; max-width:70%; }

    .table, .table tbody { display:block; }
    .table thead { position:absolute; width:1px; height:1px; overflow:hidden; clip-path:inset(50%); }
    .table tr { display:grid; grid-template-columns:repeat(2,minmax(0,1fr)); gap:10px 12px; background:var(--bg); border:1px solid var(--border); border-radius:12px; padding:12px; margin-bottom:10px; }
    .table td, .table.small td { display:block; padding:0; border:none; min-width:0; overflow-wrap:anywhere; }
    .table td[data-label]::before { content:attr(data-label); display:block; font-size:.6875rem; text-transform:uppercase; letter-spacing:.06em; color:var(--text-3); margin-bottom:2px; }
    .table td:first-child, .table td.actions, .table td[colspan] { grid-column:1 / -1; }
    .table td:first-child::before { display:none; }
    .table td.actions { display:flex; justify-content:flex-start; gap:8px; padding-top:10px; border-top:1px solid var(--border); }
    .table td.actions:empty { display:none; }
    .table td.actions .btn { flex:1 1 auto; }
    .table td select { background:var(--surface); }
    .table tr:has(+ tr.log-content) { margin-bottom:0; border-bottom:none; border-radius:12px 12px 0 0; padding-bottom:6px; }
    .table tr.log-content { border-top:none; border-radius:0 0 12px 12px; padding-top:0; }
    .log-content summary { padding:6px 0; }

    .modal { align-items:flex-end; padding:0; }
    .modal-card { max-width:none; max-height:92dvh; border-radius:16px 16px 0 0; padding-bottom:calc(14px + env(safe-area-inset-bottom)); }
    .modal-actions .btn { flex:1; }
    .toast { left:10px; right:10px; bottom:calc(12px + env(safe-area-inset-bottom)); transform:none; max-width:none; text-align:center; }

    .doc h2 { margin:20px 0 8px; font-size:1.1rem; }
    .doc h2:first-child { margin-top:0; }
    .doc table { min-width:560px; }
}
