/* TravelX Console d'administration (v1.2) — aucune dépendance externe (CSP 'self') */
:root {
  color-scheme: light;
  --bg: #f4f5f8;
  --surface: #ffffff;
  --surface-2: #f8f9fb;
  --ink: #141824;
  --ink-2: #4a5065;
  --muted: #7d8396;
  --line: #e3e6ee;
  --brand: #0e3f91;
  --brand-ink: #ffffff;
  --brand-soft: #e7eefb;
  --accent: #f5a524;
  --good: #0ca30c;
  --good-ink: #0b6b1d;
  --good-soft: #e5f6e8;
  --warn: #fab219;
  --warn-ink: #7a5200;
  --warn-soft: #fff4dc;
  --bad: #d03b3b;
  --bad-ink: #a32121;
  --bad-soft: #fde9e9;
  --series-1: #2a78d6;
  --series-2: #eb6834;
  --grid: #e1e0d9;
  --axis: #c3c2b7;
  --shadow: 0 1px 2px rgba(20, 24, 36, .06), 0 4px 16px rgba(20, 24, 36, .05);
  --radius: 12px;
  --side: 240px;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --bg: #0f1117; --surface: #181b23; --surface-2: #1f232d; --ink: #eef0f5; --ink-2: #c0c5d3; --muted: #8a90a2; --line: #2b303c;
    --brand: #4f86e8; --brand-ink: #ffffff; --brand-soft: #1c2a45; --good-ink: #4cc75a; --good-soft: #15291a; --warn-ink: #f3c25a; --warn-soft: #2e2611;
    --bad-ink: #ef7d7d; --bad-soft: #341a1b; --series-1: #3987e5; --series-2: #d95926; --grid: #2c2c2a; --axis: #383835; --shadow: none;
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #0f1117; --surface: #181b23; --surface-2: #1f232d; --ink: #eef0f5; --ink-2: #c0c5d3; --muted: #8a90a2; --line: #2b303c;
  --brand: #4f86e8; --brand-ink: #ffffff; --brand-soft: #1c2a45; --good-ink: #4cc75a; --good-soft: #15291a; --warn-ink: #f3c25a; --warn-soft: #2e2611;
  --bad-ink: #ef7d7d; --bad-soft: #341a1b; --series-1: #3987e5; --series-2: #d95926; --grid: #2c2c2a; --axis: #383835; --shadow: none;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body { background: var(--bg); color: var(--ink); font-size: 14px; line-height: 1.45; -webkit-font-smoothing: antialiased; }
a { color: var(--brand); }
h1, h2, h3 { margin: 0; line-height: 1.2; }
h1 { font-size: 22px; font-weight: 700; }
h2 { font-size: 16px; font-weight: 650; }
h3 { font-size: 13px; font-weight: 650; color: var(--ink-2); text-transform: uppercase; letter-spacing: .04em; }
button, input, select, textarea { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; }
.num, td.num, .tabular { font-variant-numeric: tabular-nums; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.hidden { display: none !important; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* ---------- connexion ---------- */
.login { min-height: 100vh; display: grid; place-items: center; padding: 24px 16px; }
.login-card { width: 100%; max-width: 400px; background: var(--surface); border: 1px solid var(--line); border-radius: 16px; padding: 32px 28px; box-shadow: var(--shadow); }
.login-brand { display: flex; align-items: center; gap: 12px; margin-bottom: 24px; }
.logo { width: 40px; height: 40px; border-radius: 10px; background: var(--brand); color: #fff; display: grid; place-items: center; font-weight: 800; font-size: 20px; flex: none; position: relative; }
.logo::after { content: ""; position: absolute; right: 6px; bottom: 6px; width: 7px; height: 7px; border-radius: 50%; background: var(--accent); }
.login-card p { color: var(--ink-2); margin: 0 0 20px; }
.login-foot { margin-top: 20px; font-size: 12px; color: var(--muted); }

/* ---------- formulaires ---------- */
.field { display: grid; gap: 6px; margin-bottom: 14px; }
.field label { font-size: 12px; font-weight: 600; color: var(--ink-2); }
.input, select.input, textarea.input { width: 100%; min-height: 38px; padding: 8px 11px; border-radius: 8px; border: 1px solid var(--line); background: var(--surface); }
textarea.input { min-height: 76px; resize: vertical; }
.input:focus { border-color: var(--brand); outline: none; box-shadow: 0 0 0 3px var(--brand-soft); }
.row { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.row > .grow { flex: 1 1 200px; }
.row > .input { width: auto; flex: 0 1 auto; }
.row > input[type=search].input { flex: 1 1 220px; min-width: 0; }
.grid2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0 14px; }
.check { display: flex; gap: 8px; align-items: center; font-size: 13px; margin-bottom: 14px; }

.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: 36px; padding: 7px 14px; border-radius: 8px; border: 1px solid var(--line); background: var(--surface); cursor: pointer; font-weight: 600; white-space: nowrap; }
.btn:hover { background: var(--surface-2); }
.btn:disabled { opacity: .55; cursor: default; }
.btn.primary { background: var(--brand); border-color: var(--brand); color: var(--brand-ink); }
.btn.primary:hover { filter: brightness(1.08); }
.btn.danger { background: var(--bad); border-color: var(--bad); color: #fff; }
.btn.ghost { background: transparent; border-color: transparent; color: var(--ink-2); }
.btn.ghost:hover { background: var(--surface-2); }
.btn.sm { min-height: 30px; padding: 4px 10px; font-size: 12px; }
.btn.block { width: 100%; }
.seg { display: inline-flex; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; background: var(--surface); }
.seg button { border: 0; background: transparent; padding: 6px 12px; cursor: pointer; font-weight: 600; color: var(--ink-2); min-height: 32px; }
.seg button[aria-pressed="true"] { background: var(--brand-soft); color: var(--brand); }

.err { background: var(--bad-soft); color: var(--bad-ink); border-radius: 8px; padding: 9px 12px; margin-bottom: 14px; font-size: 13px; }

/* ---------- structure ---------- */
.shell { display: grid; grid-template-columns: var(--side) minmax(0, 1fr); min-height: 100vh; }
.side { background: var(--surface); border-right: 1px solid var(--line); padding: 18px 12px; position: sticky; top: 0; height: 100vh; overflow-y: auto; display: flex; flex-direction: column; }
.side .brand { display: flex; align-items: center; gap: 10px; padding: 4px 8px 18px; }
.side .brand b { font-size: 15px; display: block; }
.side .brand span { font-size: 12px; color: var(--muted); }
.nav { display: grid; gap: 2px; }
.nav-title { font-size: 11px; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: .06em; padding: 14px 10px 6px; }
.nav a { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 8px 10px; border-radius: 8px; color: var(--ink-2); text-decoration: none; font-weight: 550; }
.nav a:hover { background: var(--surface-2); color: var(--ink); }
.nav a[aria-current="page"] { background: var(--brand-soft); color: var(--brand); }
.badge { min-width: 20px; height: 20px; padding: 0 6px; border-radius: 10px; background: var(--bad); color: #fff; font-size: 11px; font-weight: 700; display: inline-grid; place-items: center; }
.side-foot { margin-top: auto; padding: 14px 8px 0; border-top: 1px solid var(--line); font-size: 12px; color: var(--muted); display: grid; gap: 8px; }
.who { display: flex; align-items: center; gap: 10px; }
.avatar { width: 32px; height: 32px; border-radius: 50%; background: var(--brand-soft); color: var(--brand); display: grid; place-items: center; font-weight: 700; flex: none; }
.who b { display: block; color: var(--ink); font-size: 13px; }
.main { padding: 24px 28px 48px; min-width: 0; }
.topbar { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 20px; }
.topbar p { margin: 4px 0 0; color: var(--ink-2); }
.menu-btn { display: none; }

/* ---------- cartes et tuiles ---------- */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 18px; min-width: 0; }
.card + .card, .section + .section { margin-top: 16px; }
.cols > .card, .cols-3 > .card { margin-top: 0; }
.cols { margin-bottom: 16px; }
.card-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 14px; }
.tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 12px; margin-bottom: 16px; }
.tile { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; box-shadow: var(--shadow); }
.tile .k { font-size: 12px; color: var(--ink-2); font-weight: 600; }
.tile .v { font-size: 24px; font-weight: 700; margin-top: 4px; letter-spacing: -.01em; }
.tile .v.long { font-size: 16px; overflow-wrap: anywhere; margin-top: 8px; }
.tile .s { font-size: 12px; color: var(--muted); margin-top: 2px; }
.tile.link { cursor: pointer; }
.tile.link:hover { border-color: var(--brand); }
.cols { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.cols-3 { display: grid; grid-template-columns: 2fr 1fr; gap: 16px; }

/* ---------- état des applications ---------- */
.health { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 8px; }
.app-st { display: flex; align-items: center; gap: 10px; padding: 9px 11px; border: 1px solid var(--line); border-radius: 9px; background: var(--surface-2); }
.app-st .dot { width: 10px; height: 10px; border-radius: 50%; flex: none; background: var(--muted); }
.app-st.ok .dot { background: var(--good); }
.app-st.ko .dot { background: var(--bad); }
.app-st.warn .dot { background: var(--warn); }
.app-st b { font-size: 12px; display: block; }
.app-st span { font-size: 11px; color: var(--muted); }

/* ---------- étiquettes ---------- */
.pill { display: inline-flex; align-items: center; gap: 5px; padding: 2px 9px; border-radius: 999px; font-size: 12px; font-weight: 600; background: var(--surface-2); color: var(--ink-2); border: 1px solid var(--line); white-space: nowrap; }
.pill::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; opacity: .8; }
.pill.good { background: var(--good-soft); color: var(--good-ink); border-color: transparent; }
.pill.warn { background: var(--warn-soft); color: var(--warn-ink); border-color: transparent; }
.pill.bad { background: var(--bad-soft); color: var(--bad-ink); border-color: transparent; }
.pill.info { background: var(--brand-soft); color: var(--brand); border-color: transparent; }
.pill.plain::before { display: none; }

/* ---------- tableaux ---------- */
.table-wrap { overflow-x: auto; margin: 0 -18px; padding: 0 18px; }
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 9px 10px; border-bottom: 1px solid var(--line); vertical-align: middle; }
th { font-size: 11px; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; white-space: nowrap; background: var(--surface); position: sticky; top: 0; }
td.num, th.num { text-align: right; }
tbody tr:hover { background: var(--surface-2); }
tr.clickable { cursor: pointer; }
td .sub { display: block; font-size: 12px; color: var(--muted); }
.empty { padding: 28px 10px; text-align: center; color: var(--muted); }
.actions { display: flex; gap: 6px; justify-content: flex-end; flex-wrap: wrap; }
tfoot td { font-weight: 700; border-top: 2px solid var(--line); }

/* ---------- graphiques ---------- */
.chart { position: relative; }
.chart svg { display: block; width: 100%; height: auto; overflow: visible; }
.chart .grid line { stroke: var(--grid); stroke-width: 1; }
.chart .axis line { stroke: var(--axis); }
.chart text { fill: var(--muted); font-size: 11px; font-variant-numeric: tabular-nums; }
.chart .s1 { stroke: var(--series-1); fill: none; stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.chart .s2 { stroke: var(--series-2); fill: none; stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.chart .b1 { fill: var(--series-1); }
.chart .b1:hover, .chart .b1:focus { opacity: .8; outline: none; }
.chart .cross { stroke: var(--ink-2); stroke-width: 1; stroke-dasharray: 3 3; }
.chart .m1 { fill: var(--series-1); stroke: var(--surface); stroke-width: 2; }
.chart .m2 { fill: var(--series-2); stroke: var(--surface); stroke-width: 2; }
.legend { display: flex; gap: 16px; flex-wrap: wrap; font-size: 12px; color: var(--ink-2); margin-bottom: 8px; }
.legend i { display: inline-block; width: 14px; height: 3px; border-radius: 2px; margin-right: 6px; vertical-align: middle; }
.tip { position: absolute; pointer-events: none; background: var(--surface); border: 1px solid var(--line); border-radius: 8px; box-shadow: 0 6px 24px rgba(0,0,0,.14); padding: 8px 10px; font-size: 12px; min-width: 140px; z-index: 5; }
.tip b { font-size: 13px; }
.tip .t { color: var(--muted); margin-bottom: 4px; }
.tip .r { display: flex; justify-content: space-between; gap: 12px; }
.tip .r i { display: inline-block; width: 10px; height: 3px; border-radius: 2px; margin-right: 6px; vertical-align: middle; }

/* ---------- panneau latéral et fenêtres ---------- */
.overlay { position: fixed; inset: 0; background: rgba(10, 12, 20, .45); z-index: 40; display: flex; justify-content: flex-end; }
.drawer { width: min(640px, 100%); height: 100%; background: var(--bg); overflow-y: auto; padding: 22px; box-shadow: -10px 0 40px rgba(0,0,0,.2); }
.drawer-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; margin-bottom: 16px; }
.modal-wrap { position: fixed; inset: 0; background: rgba(10, 12, 20, .5); z-index: 50; display: grid; place-items: center; padding: 16px; }
.modal { width: min(480px, 100%); background: var(--surface); border-radius: 14px; padding: 22px; box-shadow: 0 20px 60px rgba(0,0,0,.3); max-height: calc(100vh - 32px); overflow-y: auto; }
.modal h2 { margin-bottom: 8px; }
.modal p { color: var(--ink-2); margin: 0 0 14px; }
.modal .row { justify-content: flex-end; margin-top: 6px; }
.kv { display: grid; grid-template-columns: 150px minmax(0, 1fr); gap: 6px 12px; font-size: 13px; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; overflow-wrap: anywhere; }
.docs { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; }
.docs figure { margin: 0; border: 1px solid var(--line); border-radius: 10px; overflow: hidden; background: var(--surface-2); }
.docs img { width: 100%; height: 160px; object-fit: contain; display: block; background: #fff; }
.docs figcaption { font-size: 12px; padding: 6px 8px; color: var(--ink-2); }

#toasts { position: fixed; right: 16px; bottom: 16px; display: grid; gap: 8px; z-index: 60; }
.toast { background: var(--ink); color: var(--bg); padding: 10px 14px; border-radius: 10px; box-shadow: 0 8px 30px rgba(0,0,0,.25); max-width: 380px; font-size: 13px; }
.toast.bad { background: var(--bad); color: #fff; }
.loading { color: var(--muted); padding: 20px 0; }
.note { background: var(--brand-soft); color: var(--ink-2); border-radius: 10px; padding: 10px 12px; font-size: 13px; }

/* ---------- mobile ---------- */
@media (max-width: 900px) {
  .shell { grid-template-columns: minmax(0, 1fr); }
  .side { position: fixed; inset: 0 auto 0 0; width: 270px; z-index: 30; transform: translateX(-100%); transition: transform .2s; box-shadow: 10px 0 40px rgba(0,0,0,.2); }
  .side.open { transform: none; }
  .menu-btn { display: inline-flex; }
  .main { padding: 16px 16px 40px; }
  .cols, .cols-3 { grid-template-columns: minmax(0, 1fr); }
  .tiles { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .tile .v { font-size: 20px; }
  .grid2 { grid-template-columns: minmax(0, 1fr); }
  .kv { grid-template-columns: 110px minmax(0, 1fr); }
  .docs { grid-template-columns: minmax(0, 1fr); }
  .table-wrap { margin: 0 -18px; }
}
@media print {
  .side, .topbar .btn, .menu-btn, #toasts { display: none !important; }
  .shell { display: block; }
  .card, .tile { box-shadow: none; break-inside: avoid; }
}
