/* Thème sombre inspiré de Grafana. */
:root {
  --bg: #111217;
  --panel: #181b1f;
  --panel-2: #1f2228;
  --border: #ccccdc1f;
  --border-strong: #ccccdc33;
  --text: #ccccdc;
  --strong: #ffffff;
  --muted: #ccccdca6;
  --faint: #ccccdc73;
  --green: #73bf69;
  --yellow: #fade2a;
  --orange: #ff9830;
  --red: #f2495c;
  --blue: #5794f2;
  --purple: #b877d9;
  --font: "Inter", system-ui, -apple-system, "Segoe UI", sans-serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  color-scheme: dark;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { -webkit-text-size-adjust: 100%; }
body { min-height: 100vh; font-family: var(--font); font-size: 13px; line-height: 1.5; color: var(--text); background: var(--bg); -webkit-font-smoothing: antialiased; }
a { color: inherit; text-decoration: none; }
button { font: inherit; color: inherit; background: none; border: 0; cursor: pointer; }
:focus-visible { outline: 2px solid var(--blue); outline-offset: 2px; border-radius: 4px; }
svg { display: block; flex-shrink: 0; }
[hidden] { display: none !important; }
.spacer { flex: 1; }

/* ---------- Boutons ---------- */
.button { display: inline-flex; align-items: center; justify-content: center; gap: 6px; height: 28px; padding: 0 10px; font-size: 12px; font-weight: 500; color: var(--text); white-space: nowrap; background: var(--panel-2); border: 1px solid var(--border-strong); border-radius: 4px; transition: background .15s, border-color .15s; }
.button:hover { color: var(--strong); background: #2a2d33; }
.button:disabled { opacity: .45; cursor: not-allowed; }
.button-primary { color: #fff; background: #3d71d9; border-color: #3d71d9; }
.button-primary:hover { background: #4f80e2; }
.button-confirm { color: #111217; background: var(--orange); border-color: var(--orange); }
.button-confirm:hover { background: #ffab57; color: #111217; }
.tool { display: inline-flex; align-items: center; gap: 6px; height: 32px; padding: 0 9px; font-size: 12px; color: var(--muted); border: 1px solid var(--border); border-radius: 4px; transition: color .15s, border-color .15s; }
.tool:hover { color: var(--strong); border-color: var(--border-strong); }
.spin { animation: spin 1s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- Connexion ---------- */
.login { display: grid; place-items: center; min-height: 100vh; padding: 24px; background: radial-gradient(70% 50% at 50% 0%, #1d2433 0, var(--bg) 70%); }
.login-card { width: min(360px, 100%); padding: 28px 24px 24px; background: var(--panel); border: 1px solid var(--border); border-radius: 6px; }
.login-card .brand { display: flex; align-items: center; gap: 10px; margin-bottom: 20px; font-size: 16px; font-weight: 600; color: var(--strong); }
.login-card .brand span { color: var(--faint); font-weight: 500; }
.login-card h1 { font-size: 20px; font-weight: 600; color: var(--strong); }
.login-card p { margin-top: 4px; color: var(--muted); }
.login-card form { display: grid; gap: 10px; margin-top: 20px; }
.login-card label { font-size: 12px; font-weight: 500; color: var(--muted); }
.login-card input { width: 100%; height: 36px; padding: 0 10px; font: inherit; color: var(--strong); background: var(--bg); border: 1px solid var(--border-strong); border-radius: 4px; }
.login-card input:focus { outline: none; border-color: var(--blue); }
.login-card .button { width: 100%; height: 36px; margin-top: 4px; font-size: 13px; }
.login-error { padding: 8px 10px; font-size: 12px; color: #ffc2c9; background: #f2495c1f; border: 1px solid #f2495c66; border-radius: 4px; }
.brand-logo { width: auto; height: 22px; }

/* ---------- Barre du haut ---------- */
.topbar { position: sticky; top: 0; z-index: 10; background: var(--bg); border-bottom: 1px solid var(--border); }
.topbar-row { display: flex; align-items: center; gap: 12px; height: 52px; padding: 0 16px; }
.topbar .brand { display: grid; place-items: center; width: 34px; height: 34px; }
.crumbs { display: flex; align-items: center; gap: 6px; font-size: 14px; color: var(--muted); white-space: nowrap; }
.crumbs b { font-weight: 500; color: var(--strong); }
.range { display: flex; padding: 2px; background: var(--panel); border: 1px solid var(--border); border-radius: 4px; }
.range button { height: 26px; padding: 0 10px; font-size: 12px; color: var(--muted); border-radius: 3px; }
.range button[aria-pressed="true"] { color: var(--strong); background: #2a2d33; }
.range button:hover { color: var(--strong); }

/* ---------- Grille de panneaux ---------- */
.grid { display: grid; grid-template-columns: repeat(12, minmax(0, 1fr)); gap: 8px; padding: 8px 16px 24px; }
.panel { display: flex; flex-direction: column; min-width: 0; background: var(--panel); border: 1px solid var(--border); border-radius: 3px; }
.panel-h { display: flex; align-items: center; gap: 8px; min-height: 32px; padding: 8px 12px 0; }
.panel-h h2 { overflow: hidden; font-size: 13px; font-weight: 500; color: var(--strong); text-overflow: ellipsis; white-space: nowrap; }
.panel-meta { margin-left: auto; font-size: 12px; color: var(--faint); white-space: nowrap; }
.panel-b { position: relative; flex: 1; min-height: 0; padding: 6px 12px 12px; }

.p-views { grid-column: span 8; grid-row: span 2; }
.p-stat { grid-column: span 2; min-height: 168px; }
.p-bars { grid-column: span 4; }
.p-response { grid-column: span 8; }
.p-table { grid-column: span 12; }
.p-deploys { grid-column: span 7; }
.p-certs { grid-column: span 5; }

/* ---------- Panneaux « chiffre clé » ---------- */
.stat-b { position: relative; display: flex; flex: 1; flex-direction: column; align-items: center; justify-content: center; padding: 4px 12px 14px; overflow: hidden; }
.stat-value { position: relative; font-size: 34px; font-weight: 500; line-height: 1.1; color: var(--strong); font-variant-numeric: tabular-nums; }
.stat-sub { position: relative; margin-top: 4px; font-size: 12px; color: var(--muted); text-align: center; }
.stat-spark { position: absolute; inset: auto 0 0 0; height: 38%; opacity: .9; }
.stat-b:has(.stat-spark) { justify-content: flex-start; padding-top: 18px; }
.spark-area { width: 100%; height: 100%; }
.gauge-b { padding-bottom: 6px; }
.gauge { width: 100%; max-width: 190px; }
.gauge-track { fill: none; stroke: #ccccdc1a; stroke-width: 14; stroke-linecap: round; }
.gauge-value { fill: none; stroke-width: 14; stroke-linecap: round; }
.gauge-text { font-family: var(--font); font-size: 28px; font-weight: 500; }

/* ---------- Graphiques ---------- */
.chart { position: relative; }
.chart-svg { display: block; width: 100%; height: auto; overflow: visible; }
.chart .gl { stroke: #ccccdc14; stroke-width: 1; }
.chart .gl-v { stroke: #ccccdc0d; }
.chart .axis { font-size: 11px; fill: var(--faint); font-variant-numeric: tabular-nums; }
.chart .line { fill: none; stroke-width: 1.5; stroke-linejoin: round; }
.chart .crosshair { stroke: #ccccdc66; stroke-width: 1; stroke-dasharray: 3 3; }
.chart .dot { stroke: var(--panel); stroke-width: 1.5; }
.tooltip { position: absolute; z-index: 5; min-width: 180px; max-width: 280px; padding: 8px 10px; font-size: 12px; pointer-events: none; background: #22252b; border: 1px solid var(--border-strong); border-radius: 3px; box-shadow: 0 8px 24px #0009; }
.tooltip-time { margin-bottom: 6px; font-weight: 500; color: var(--strong); }
.tooltip-row { display: flex; align-items: center; gap: 8px; padding: 1px 0; }
.tooltip-row i, .legend-item i { width: 14px; height: 4px; border-radius: 2px; flex-shrink: 0; }
.tooltip-row span { flex: 1; overflow: hidden; color: var(--muted); text-overflow: ellipsis; white-space: nowrap; }
.tooltip-row b { font-weight: 500; color: var(--strong); font-variant-numeric: tabular-nums; }
.tooltip-total { margin-top: 4px; padding-top: 5px; border-top: 1px solid var(--border); }
.legend { display: flex; flex-wrap: wrap; gap: 2px 14px; margin-top: 6px; }
.legend-item { display: inline-flex; align-items: center; gap: 7px; padding: 3px 0; font-size: 12px; color: var(--text); }
.legend-item b { font-weight: 500; color: var(--faint); font-variant-numeric: tabular-nums; }
.legend-item.is-off { opacity: .4; }
.legend-item:hover { color: var(--strong); }

.bargauge { display: grid; gap: 7px; list-style: none; }
.bargauge li { display: grid; grid-template-columns: minmax(80px, 34%) 1fr 56px; align-items: center; gap: 10px; }
.bg-label { overflow: hidden; font-size: 12px; color: var(--muted); text-overflow: ellipsis; white-space: nowrap; }
.bg-track { height: 18px; background: #ccccdc0f; border-radius: 2px; overflow: hidden; }
.bg-fill { display: block; height: 100%; border-radius: 2px; opacity: .85; }
.bargauge b { font-size: 13px; font-weight: 500; color: var(--strong); text-align: right; font-variant-numeric: tabular-nums; }

.empty { padding: 24px 8px; font-size: 13px; color: var(--faint); text-align: center; }
.empty code { font-family: var(--mono); color: var(--text); }

/* ---------- Tableau des sites ---------- */
.table-wrap { overflow-x: auto; padding: 4px 0 6px; }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th { padding: 8px 12px; font-size: 12px; font-weight: 500; color: var(--muted); text-align: left; white-space: nowrap; border-bottom: 1px solid var(--border); }
td { padding: 9px 12px; vertical-align: middle; white-space: nowrap; border-bottom: 1px solid #ccccdc0d; }
tr:last-child td { border-bottom: 0; }
tbody tr:not(.group-row):hover td { background: #ccccdc08; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
.group-row td { padding: 14px 12px 6px; font-size: 11.5px; font-weight: 500; color: var(--faint); text-transform: uppercase; letter-spacing: .05em; border-bottom: 1px solid var(--border); }
.group-row .warn { margin-left: 6px; color: var(--orange); text-transform: none; letter-spacing: 0; }
.site-cell { display: flex; align-items: center; gap: 10px; }
.site-cell div { min-width: 0; }
.site-cell b { display: block; font-weight: 500; color: var(--strong); }
.site-cell a { font-size: 12px; color: var(--faint); }
.site-cell a:hover { color: var(--blue); text-decoration: underline; }
.dot { width: 9px; height: 9px; border-radius: 50%; background: var(--faint); flex-shrink: 0; }
.dot.ok { background: var(--green); box-shadow: 0 0 0 3px #73bf6926; }
.dot.bad { background: var(--red); box-shadow: 0 0 0 3px #f2495c33; animation: blink 1.4s ease-in-out infinite; }
.dot.run { background: var(--blue); box-shadow: 0 0 0 3px #5794f233; animation: blink 1s ease-in-out infinite; }
@keyframes blink { 50% { opacity: .4; } }
.ok-t { color: var(--green); }
.warn-t { color: var(--orange); }
.bad-t { color: var(--red); }
.muted-t { color: var(--faint); }
.up { color: var(--green); }
.down { color: var(--red); }
small.up, small.down, small.flat { margin-left: 4px; font-size: 11px; }
small.flat { color: var(--faint); }
.version { max-width: 280px; overflow: hidden; text-overflow: ellipsis; }
.version code { margin-right: 6px; font-family: var(--mono); font-size: 12px; color: var(--blue); }
.pill { display: inline-flex; align-items: center; height: 18px; padding: 0 6px; margin-left: 6px; font-size: 11px; font-weight: 500; border-radius: 2px; vertical-align: 1px; }
.pill-ok { color: var(--green); background: #73bf691f; }
.pill-warn { color: var(--orange); background: #ff98301f; }
.pill-bad { color: var(--red); background: #f2495c1f; }
.mini-spark { width: 90px; height: 24px; }
.mini-spark rect { fill: var(--blue); opacity: .75; }
.actions { display: flex; justify-content: flex-end; gap: 4px; }

/* ---------- Déploiements récents ---------- */
.deploy-list { display: grid; list-style: none; }
.deploy-list li { display: grid; grid-template-columns: 10px minmax(0, 1fr) auto auto; align-items: center; gap: 10px; padding: 7px 4px; border-bottom: 1px solid #ccccdc0d; }
.deploy-list li:last-child { border-bottom: 0; }
.deploy-list button { overflow: hidden; color: var(--strong); text-align: left; text-overflow: ellipsis; white-space: nowrap; }
.deploy-list button:hover { color: var(--blue); }
.deploy-list .when { font-size: 12px; color: var(--faint); }

/* ---------- Tiroir (journal, statistiques) ---------- */
.drawer-backdrop { position: fixed; inset: 0; z-index: 30; background: #000000a0; }
.drawer { position: fixed; top: 0; right: 0; bottom: 0; z-index: 31; display: flex; flex-direction: column; width: min(760px, 100%); background: var(--panel); border-left: 1px solid var(--border-strong); box-shadow: -12px 0 40px #0008; animation: slide .2s ease-out; }
@keyframes slide { from { transform: translateX(30px); opacity: 0; } }
.drawer-head { display: flex; align-items: center; gap: 12px; padding: 12px 16px; border-bottom: 1px solid var(--border); }
.drawer-head h2 { font-size: 15px; font-weight: 500; color: var(--strong); }
.drawer-status { font-size: 12px; color: var(--muted); }
.drawer-status.ok { color: var(--green); }
.drawer-status.bad { color: var(--red); }
.drawer-status.run { color: var(--blue); }
.log { flex: 1; overflow: auto; padding: 14px 16px; font-family: var(--mono); font-size: 12px; line-height: 1.6; color: #d8dce6; white-space: pre-wrap; word-break: break-word; background: #0b0c0e; }
.history { max-height: 34%; overflow: auto; border-top: 1px solid var(--border); }
.history h3 { padding: 10px 16px 4px; font-size: 12px; font-weight: 500; color: var(--muted); }
.history button { display: grid; grid-template-columns: 10px 1fr auto; align-items: center; gap: 10px; width: 100%; padding: 7px 16px; font-size: 12px; text-align: left; color: var(--muted); }
.history button:hover, .history button[aria-current] { color: var(--strong); background: #ccccdc0a; }
.history .dot { width: 7px; height: 7px; box-shadow: none; animation: none; }
.history code { font-family: var(--mono); color: var(--blue); }
.stats-detail { flex: 1; overflow: auto; padding: 16px; }
.stats-detail section { margin-top: 20px; }
.stats-detail h3 { margin-bottom: 8px; font-size: 12px; font-weight: 500; color: var(--muted); }
.stats-tiles { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px; }
.stats-tiles div { padding: 10px 12px; background: var(--panel-2); border: 1px solid var(--border); border-radius: 3px; }
.stats-tiles dt { font-size: 11px; color: var(--faint); }
.stats-tiles dd { font-size: 20px; font-weight: 500; color: var(--strong); }
.hint { margin-bottom: 8px; font-size: 12px; color: var(--faint); }
.hint code { font-family: var(--mono); color: var(--blue); }
.snippet { padding: 10px; margin-bottom: 10px; font-family: var(--mono); font-size: 11.5px; line-height: 1.5; color: #d8dce6; white-space: pre-wrap; word-break: break-all; background: #0b0c0e; border: 1px solid var(--border); border-radius: 3px; }

.toast { position: fixed; left: 50%; bottom: 20px; z-index: 40; max-width: calc(100% - 32px); padding: 9px 14px; font-size: 13px; color: #fff; background: #3d71d9; border-radius: 4px; transform: translateX(-50%); box-shadow: 0 8px 24px #0009; }
.toast.bad { background: #c4162a; }
.notice { grid-column: span 12; padding: 8px 12px; font-size: 12.5px; color: #ffd28a; background: #ff98301a; border: 1px solid #ff983055; border-radius: 3px; }

/* ---------- Responsive ---------- */
@media (max-width: 1200px) {
  .p-views { grid-column: span 12; grid-row: auto; }
  .p-stat { grid-column: span 3; }
  .p-bars { grid-column: span 5; }
  .p-response { grid-column: span 7; }
  .p-deploys, .p-certs { grid-column: span 6; }
}
@media (max-width: 800px) {
  .topbar-row { gap: 8px; padding: 0 10px; }
  .crumbs span, .crumbs svg, #updated { display: none; }
  .grid { gap: 6px; padding: 6px 8px 20px; }
  .p-stat { grid-column: span 6; min-height: 130px; }
  .stat-value { font-size: 28px; }
  .p-bars, .p-response, .p-deploys, .p-certs { grid-column: span 12; }
  .stats-tiles { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .drawer { width: 100%; }

  /* Le tableau devient une liste de cartes. */
  table, tbody, tr, td { display: block; width: 100%; }
  thead { display: none; }
  tbody tr { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px 12px; padding: 12px; border-bottom: 1px solid var(--border); }
  tbody tr.group-row { display: block; padding: 0; }
  td { padding: 0; white-space: normal; border: 0; }
  td[data-label]::before { content: attr(data-label); display: block; font-size: 11px; color: var(--faint); }
  td.cell-site, td.cell-version, td.cell-actions { grid-column: 1 / -1; }
  td.num { text-align: left; }
  .version { max-width: none; white-space: normal; }
  .actions { justify-content: stretch; }
  .actions .button { flex: 1; height: 32px; }
  td.cell-spark { display: none; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
