/* Panel d'administration d'IPTVista : jetons du design system, sombre et clair selon le système. */
@font-face {
  font-family: "Bricolage Grotesque";
  src: url("/bricolage-800.woff2") format("woff2");
  font-weight: 800;
  font-display: swap;
}

:root {
  color-scheme: light dark;
  --bg: #F3F3F8; --s1: #FFFFFF; --s2: #ECECF4; --ln: #E1E1EB; --tx: #0E0F1A; --mu: #5B5E72; --mu2: #6B6E84;
  --ac: #5B3FF0; --acm: rgba(91, 63, 240, 0.32); --at: #4F35E0; --acs: rgba(91, 63, 240, 0.10); --co: #E2522F;
  --ok: #12814A; --okbg: rgba(18, 129, 74, 0.10); --wn: #9A5B00; --wnbg: rgba(154, 91, 0, 0.10);
  --er: #C42A3A; --erbg: rgba(196, 42, 58, 0.08);
  --p1: #5B3FF0; --p2: #8E7CF5; --p3: #E2522F; --p4: #12814A; --p5: #0B7FBF; --p6: #6B6E84;
  --shadow: 0 16px 36px rgba(20, 20, 60, 0.12);
  --title: "Bricolage Grotesque", -apple-system, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, "SF Mono", Menlo, monospace;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #07070D; --s1: #12131C; --s2: #1B1C28; --ln: #262838; --tx: #F5F5FA; --mu: #A6A9BD; --mu2: #8C8FA6;
    --ac: #6E56F8; --acm: rgba(110, 86, 248, 0.42); --at: #A99BFF; --acs: rgba(110, 86, 248, 0.18); --co: #FF7A59;
    --ok: #34C77B; --okbg: rgba(52, 199, 123, 0.14); --wn: #F5B43D; --wnbg: rgba(245, 180, 61, 0.14);
    --er: #FF7A85; --erbg: rgba(255, 122, 133, 0.14);
    --p1: #6E56F8; --p2: #A99BFF; --p3: #FF7A59; --p4: #34C77B; --p5: #1FB6FF; --p6: #8C8FA6;
    --shadow: 0 24px 60px rgba(0, 0, 0, 0.5);
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--tx); font: 15px/1.45 -apple-system, BlinkMacSystemFont, "Inter", "Helvetica Neue", Arial, sans-serif; }
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--at); }
a:hover { color: var(--tx); }
:focus-visible { outline: 3px solid var(--at); outline-offset: 2px; }
h1, h2, h3 { margin: 0; }
[hidden] { display: none !important; }

/* Mise en page */
.shell { min-height: 100vh; display: flex; flex-wrap: wrap; align-items: stretch; }
.side { flex: 1 1 260px; padding: 28px 18px; border-right: 1px solid var(--ln); background: var(--s1); display: flex; flex-direction: column; gap: 24px; }
.content { flex: 999 1 560px; min-width: 0; padding: 32px 40px 64px; }
.content:focus { outline: none; }
.back { align-self: flex-start; }
.page { max-width: 1160px; margin: 0 auto; display: flex; flex-direction: column; gap: 24px; }
.row { display: flex; flex-wrap: wrap; gap: 16px; align-items: flex-start; }
.row > * { min-width: 0; }
.grow1 { flex: 1 1 300px; } .grow2 { flex: 2 1 480px; } .grow3 { flex: 3 1 480px; } .half { flex: 1 1 420px; }
.stack { display: flex; flex-direction: column; gap: 16px; }
.stack-s { display: flex; flex-direction: column; gap: 8px; }
.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 16px; }
.tiles-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.tiles-3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; }
@media (max-width: 760px) {
  .content { padding: 24px 16px 48px; }
  .side { border-right: 0; border-bottom: 1px solid var(--ln); }
  .tiles-3 { grid-template-columns: minmax(0, 1fr); }
}

/* Menu */
.brand { display: flex; align-items: center; gap: 12px; padding: 0 8px; }
.brand > div { display: flex; flex-direction: column; }
.wordmark { font-family: var(--title); font-weight: 800; font-size: 20px; letter-spacing: -0.4px; }
.coral { color: var(--co); }
.nav { display: flex; flex-direction: column; gap: 4px; }
.nav a { display: flex; align-items: center; gap: 12px; min-height: 44px; padding: 0 12px; border-radius: 12px; color: var(--mu); text-decoration: none; font-weight: 600; }
.nav a:hover { color: var(--tx); background: var(--s2); }
.nav a[aria-current="page"] { background: var(--acs); color: var(--at); }
.nav svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; flex-shrink: 0; }
.count { margin-left: auto; min-width: 22px; height: 22px; padding: 0 7px; border-radius: 11px; background: var(--wnbg); color: var(--wn); font-size: 12px; font-weight: 700; display: inline-flex; align-items: center; justify-content: center; }
.tunnel { margin-top: auto; border-radius: 16px; border: 1px solid var(--ln); background: var(--bg); padding: 14px; display: flex; flex-direction: column; gap: 6px; }
.tunnel-title { display: flex; align-items: center; gap: 8px; font-size: 13px; font-weight: 700; }

/* Textes */
.title { font-family: var(--title); font-size: 36px; line-height: 40px; font-weight: 800; letter-spacing: -1px; }
.subtitle { color: var(--mu); }
.h2 { font-size: 18px; font-weight: 700; }
.h3 { font-size: 16px; font-weight: 700; }
.label { font-size: 11px; font-weight: 700; letter-spacing: 0.6px; text-transform: uppercase; color: var(--mu2); }
.big { font-family: var(--title); font-size: 34px; line-height: 38px; font-weight: 800; letter-spacing: -1px; }
.mid { font-size: 22px; font-weight: 700; }
.muted { color: var(--mu); } .muted2 { color: var(--mu2); }
.small { font-size: 13px; line-height: 19px; }
.mono { font-family: var(--mono); }
.okc { color: var(--ok); } .wnc { color: var(--wn); } .erc { color: var(--er); }
.head { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 16px; }
.head > div:first-child { display: flex; flex-direction: column; gap: 6px; }
.between { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: baseline; gap: 8px; }

/* Cartes */
.card { border-radius: 20px; background: var(--s1); border: 1px solid var(--ln); padding: 22px; display: flex; flex-direction: column; gap: 14px; }
.card.tight { padding: 18px 20px; gap: 8px; }
.card.dashed { background: transparent; border-style: dashed; }
.card.danger { background: transparent; border-color: var(--er); }
.inset { border-radius: 14px; background: var(--bg); padding: 12px 14px; display: flex; flex-direction: column; gap: 2px; }
.banner { border-radius: 18px; padding: 14px 18px; display: flex; flex-wrap: wrap; align-items: center; gap: 12px 16px; }
.banner.warn { background: var(--wnbg); }
.banner.info { background: var(--acs); }
.banner.err { background: var(--erbg); }
.banner > span { flex: 1 1 320px; }
.lines > * { border-top: 1px solid var(--ln); padding: 10px 0; }
.line { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.line > .fill { flex: 1 1 220px; min-width: 0; }
.dot { width: 8px; height: 8px; border-radius: 4px; flex-shrink: 0; display: inline-block; background: var(--mu2); }
.dot.ok { background: var(--ok); } .dot.wn { background: var(--wn); } .dot.er { background: var(--er); }

/* Pastilles */
.badge { height: 24px; padding: 0 10px; border-radius: 12px; font-size: 12px; font-weight: 700; display: inline-flex; align-items: center; white-space: nowrap; background: var(--s2); color: var(--mu); }
.badge.ok { background: var(--okbg); color: var(--ok); }
.badge.wn { background: var(--wnbg); color: var(--wn); }
.badge.er { background: var(--erbg); color: var(--er); }
.badge.ac { background: var(--acs); color: var(--at); }

/* Boutons */
.btn { min-height: 44px; padding: 0 16px; border-radius: 22px; border: 1px solid var(--ln); background: var(--s1); color: var(--tx); font-size: 14px; font-weight: 600; display: inline-flex; align-items: center; justify-content: center; gap: 8px; cursor: pointer; text-decoration: none; white-space: nowrap; }
.btn:hover { border-color: var(--mu2); color: var(--tx); }
.btn.primary { background: var(--ac); border-color: transparent; color: #FFFFFF; font-weight: 700; }
.btn.danger { background: var(--erbg); border-color: transparent; color: var(--er); font-weight: 700; }
.btn.solid-danger { background: var(--er); border-color: transparent; color: #FFFFFF; font-weight: 700; }
.btn.warn { background: var(--wnbg); border-color: transparent; color: var(--wn); font-weight: 700; }
.btn.soft { background: var(--acs); border-color: transparent; color: var(--at); font-weight: 700; }
.btn.ghost-danger { background: transparent; color: var(--er); }
.btn.small { min-height: 36px; padding: 0 12px; border-radius: 18px; font-size: 13px; }
.btn[disabled] { opacity: 0.5; cursor: default; }
.btn svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 2.2; stroke-linecap: round; stroke-linejoin: round; }
.segmented { display: inline-flex; flex-wrap: wrap; padding: 4px; border-radius: 24px; background: var(--s2); gap: 4px; }
.segmented button { min-height: 40px; padding: 0 16px; border-radius: 20px; border: 0; background: transparent; color: var(--mu); font-size: 14px; font-weight: 600; cursor: pointer; }
.segmented button[aria-pressed="true"] { background: var(--s1); color: var(--tx); }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chips button { min-height: 36px; padding: 0 14px; border-radius: 18px; border: 1px solid var(--ln); background: transparent; color: var(--mu); font-size: 13px; font-weight: 600; cursor: pointer; }
.chips button[aria-pressed="true"] { background: var(--acs); border-color: transparent; color: var(--at); }
.switch { width: 60px; height: 34px; flex-shrink: 0; border-radius: 17px; border: 0; padding: 3px; background: var(--s2); display: flex; justify-content: flex-start; cursor: pointer; }
.switch::after { content: ""; width: 28px; height: 28px; border-radius: 14px; background: #FFFFFF; box-shadow: 0 1px 3px rgba(0, 0, 0, 0.3); }
.switch[aria-checked="true"] { background: var(--ok); justify-content: flex-end; }
.switch.warn[aria-checked="true"] { background: var(--wn); }

/* Champs */
.field { display: flex; flex-direction: column; gap: 6px; }
.field label, .field .legend { font-size: 13px; font-weight: 600; color: var(--mu); }
.input { min-height: 46px; padding: 0 14px; border-radius: 14px; border: 1px solid var(--ln); background: var(--bg); font-size: 15px; width: 100%; }
textarea.input { padding: 12px 14px; line-height: 21px; resize: vertical; min-height: 90px; }
.input.narrow { width: 110px; min-height: 40px; border-radius: 12px; }
.input.num { width: 84px; min-height: 40px; border-radius: 10px; text-align: right; background: var(--s1); }
.checks { display: flex; flex-wrap: wrap; gap: 8px 20px; }
.checks label { display: inline-flex; align-items: center; gap: 8px; min-height: 36px; font-size: 14px; color: var(--tx); font-weight: 400; }
.checks input { width: 20px; height: 20px; accent-color: var(--ac); margin: 0; }
fieldset { border: 0; padding: 0; margin: 0; }

/* Tableaux */
.table-box { overflow-x: auto; }
table { border-collapse: collapse; width: 100%; }
th { font-size: 11px; font-weight: 700; letter-spacing: 0.6px; text-transform: uppercase; color: var(--mu2); text-align: left; padding: 0 12px 10px; white-space: nowrap; }
td { padding: 11px 12px; border-top: 1px solid var(--ln); font-size: 14px; vertical-align: middle; }
td.nowrap, th.nowrap { white-space: nowrap; }
.right { text-align: right; } .center { text-align: center; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* Graphiques (tailles posées par le script : la CSP refuse les styles en ligne) */
.chart { display: flex; gap: 10px; }
.axis { display: flex; flex-direction: column; justify-content: space-between; height: 160px; font-size: 11px; color: var(--mu2); text-align: right; min-width: 18px; }
.plot { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 8px; }
.bars { height: 160px; border-bottom: 1px solid var(--ln); display: flex; align-items: flex-end; gap: 4px; padding: 0 2px; background-image: linear-gradient(var(--ln), var(--ln)), linear-gradient(var(--ln), var(--ln)); background-size: 100% 1px; background-repeat: no-repeat; background-position: 0 0, 0 50%; }
.bars.low { height: 120px; }
.bars > div { flex: 1; min-height: 2px; border-radius: 4px 4px 0 0; background: var(--acm); }
.bars > div.hot { background: var(--ac); }
.bars > div.warn { background: var(--wn); }
.ticks { display: flex; justify-content: space-between; font-size: 12px; color: var(--mu2); }
.hbar { display: grid; grid-template-columns: 150px minmax(0, 1fr) 56px; align-items: center; gap: 12px; font-size: 14px; }
.track { height: 12px; border-radius: 6px; background: var(--s2); overflow: hidden; }
.track.thin { height: 8px; border-radius: 4px; }
.track > div { height: 100%; border-radius: inherit; background: var(--ac); width: 0; }
.stacked { display: flex; height: 14px; border-radius: 7px; overflow: hidden; gap: 2px; background: var(--s2); }
.stacked > div { width: 0; }
.legend-dot { width: 10px; height: 10px; border-radius: 3px; display: inline-block; flex-shrink: 0; }
.c1 { background: var(--p1) !important; } .c2 { background: var(--p2) !important; } .c3 { background: var(--p3) !important; }
.c4 { background: var(--p4) !important; } .c5 { background: var(--p5) !important; } .c6 { background: var(--p6) !important; }
.cbad { background: var(--wn) !important; } .cok { background: var(--ok) !important; }
.heat { display: block; border-radius: 8px; padding: 6px 0; font-weight: 600; text-align: center; }
.heat.h0 { background: transparent; color: var(--mu2); }
.heat.h1 { background: rgba(110, 86, 248, 0.15); } .heat.h2 { background: rgba(110, 86, 248, 0.3); }
.heat.h3 { background: rgba(110, 86, 248, 0.45); } .heat.h4 { background: rgba(110, 86, 248, 0.62); color: #FFFFFF; }

/* Terminal et aperçus */
.terminal { border-radius: 14px; background: #0B0B12; border: 1px solid #262838; padding: 14px 16px; font-family: var(--mono); font-size: 13px; line-height: 22px; color: #D9DAE6; overflow-x: auto; white-space: pre; }
.terminal .dim { color: #8C8FA6; }
.preview { border-radius: 24px; background: #07070D; border: 1px solid #262838; padding: 16px 14px; display: flex; flex-direction: column; gap: 10px; color: #F5F5FA; }
.preview .label { color: #8C8FA6; }
.preview-banner { border-radius: 16px; padding: 12px 14px; display: flex; gap: 10px; align-items: flex-start; }
.preview-banner.info { background: rgba(110, 86, 248, 0.22); }
.preview-banner.maintenance { background: rgba(245, 180, 61, 0.18); }
.preview-banner.important { background: rgba(224, 64, 42, 0.22); }
.preview-chip { width: 28px; height: 28px; border-radius: 9px; color: #FFFFFF; font-weight: 800; display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.info .preview-chip { background: #6E56F8; } .maintenance .preview-chip { background: #B97A10; } .important .preview-chip { background: #E0402A; }
.preview-link { font-size: 12px; font-weight: 700; color: #A99BFF; }

/* Dialogue et message */
dialog { border: 1px solid var(--ln); border-radius: 28px; background: var(--s1); color: var(--tx); padding: 28px; width: min(600px, calc(100vw - 32px)); box-shadow: var(--shadow); }
dialog::backdrop { background: rgba(4, 4, 10, 0.62); }
dialog form { display: flex; flex-direction: column; gap: 18px; margin: 0; }
.dialog-title { font-family: var(--title); font-size: 26px; line-height: 30px; font-weight: 800; letter-spacing: -0.6px; }
.dialog-actions { display: flex; justify-content: flex-end; gap: 10px; flex-wrap: wrap; }
.toast { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); max-width: calc(100vw - 32px); border-radius: 16px; background: var(--tx); color: var(--bg); padding: 12px 18px; font-weight: 600; box-shadow: var(--shadow); z-index: 10; }
.toast.error { background: var(--er); color: #FFFFFF; }
.closed { max-width: 560px; margin: 10vh auto 0; text-align: center; display: flex; flex-direction: column; gap: 14px; align-items: center; }
.login { width: 100%; max-width: 380px; text-align: left; }
body.signed-out .nav { display: none; }

/* Plantages */
details.crash { border-top: 1px solid var(--ln); padding: 10px 0; }
details.crash summary { cursor: pointer; font-size: 13px; line-height: 1.6; }
pre.trace { margin: 0; padding: 12px 14px; border-radius: 12px; background: var(--bg); font-family: var(--mono); font-size: 12px; line-height: 1.5; white-space: pre-wrap; word-break: break-word; max-height: 420px; overflow: auto; }
