/* manageMyApps — styles communs (tableau de bord et application de notifications) */
:root {
  --bg: #f4f6f8;
  --surface: #ffffff;
  --surface-2: #eef1f4;
  --text: #16202a;
  --muted: #5d6b78;
  --border: #dde3e9;
  --accent: #0f766e;
  --accent-text: #ffffff;
  --ok: #15803d;
  --ok-bg: #dcfce7;
  --warn: #b45309;
  --warn-bg: #fef3c7;
  --down: #b91c1c;
  --down-bg: #fee2e2;
  --unknown: #64748b;
  --unknown-bg: #e2e8f0;
  --bar: #0f766e;
  --bar-track: #e5eaef;
  --spark-cpu: #0f766e;
  --spark-mem: #7c3aed;
  --radius: 12px;
  --shadow: 0 1px 2px rgba(16, 24, 40, .06), 0 1px 3px rgba(16, 24, 40, .08);
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0d1318;
    --surface: #151d24;
    --surface-2: #1c262f;
    --text: #e6edf3;
    --muted: #93a1ae;
    --border: #26323d;
    --accent: #2dd4bf;
    --accent-text: #062a26;
    --ok: #4ade80;
    --ok-bg: #0f2e1d;
    --warn: #fbbf24;
    --warn-bg: #33260a;
    --down: #f87171;
    --down-bg: #3a1414;
    --unknown: #94a3b8;
    --unknown-bg: #1e2833;
    --bar: #2dd4bf;
    --bar-track: #26323d;
    --spark-cpu: #2dd4bf;
    --spark-mem: #a78bfa;
    --shadow: none;
  }
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  padding-bottom: env(safe-area-inset-bottom);
}
a { color: var(--accent); }
h1, h2, h3 { margin: 0; font-weight: 650; }
h2 { font-size: 13px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); margin: 22px 0 10px; }

.topbar {
  position: sticky; top: 0; z-index: 5;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: calc(10px + env(safe-area-inset-top)) 16px 10px;
  background: var(--surface); border-bottom: 1px solid var(--border);
}
.brand { display: flex; align-items: center; gap: 10px; font-weight: 650; font-size: 16px; }
.brand img { border-radius: 7px; }
.topbar-right { display: flex; align-items: center; gap: 10px; font-size: 13px; color: var(--muted); }
.page { max-width: 1100px; margin: 0 auto; padding: 8px 16px 32px; }

/* Pastilles d'état */
.pill {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 2px 10px; border-radius: 999px; font-size: 12.5px; font-weight: 600; white-space: nowrap;
}
.pill::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.lv-ok { color: var(--ok); background: var(--ok-bg); }
.lv-warn { color: var(--warn); background: var(--warn-bg); }
.lv-down { color: var(--down); background: var(--down-bg); }
.lv-unknown { color: var(--unknown); background: var(--unknown-bg); }

.banner { margin: 12px 0; padding: 10px 14px; border-radius: var(--radius); font-size: 14px; }
.banner.lv-warn, .banner.lv-down { font-weight: 500; }

.card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 14px 16px;
}
.grid { display: grid; gap: 12px; grid-template-columns: repeat(auto-fill, minmax(290px, 1fr)); }

/* Jauges serveur */
.gauges { display: grid; gap: 12px 20px; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); }
.gauge-label { display: flex; justify-content: space-between; font-size: 13px; color: var(--muted); margin-bottom: 5px; }
.gauge-label b { color: var(--text); font-weight: 600; font-variant-numeric: tabular-nums; }
.bar { height: 8px; border-radius: 4px; background: var(--bar-track); overflow: hidden; }
.bar > span { display: block; height: 100%; border-radius: 4px; background: var(--bar); width: 0; transition: width .4s; }
.bar.lv-warn > span { background: var(--warn); }
.bar.lv-down > span { background: var(--down); }
.bar.lv-warn, .bar.lv-down { background: var(--bar-track); }

.spark-row { display: grid; gap: 14px; grid-template-columns: 1fr 1fr; margin-top: 14px; }
.spark-title { font-size: 12px; color: var(--muted); display: flex; justify-content: space-between; }
svg.spark { width: 100%; height: 36px; display: block; overflow: visible; }
.spark-empty { height: 36px; display: flex; align-items: center; font-size: 12px; color: var(--muted); }
svg.spark polyline { fill: none; stroke-width: 1.6; vector-effect: non-scaling-stroke; stroke-linejoin: round; }
svg.spark .cpu { stroke: var(--spark-cpu); }
svg.spark .mem { stroke: var(--spark-mem); }
svg.spark .area-cpu { fill: var(--spark-cpu); opacity: .12; stroke: none; }
svg.spark .area-mem { fill: var(--spark-mem); opacity: .12; stroke: none; }

/* Applications */
.app-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.app-name { font-size: 16px; font-weight: 650; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.app-id { font: 12px var(--mono); color: var(--muted); }
.kv { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-top: 12px; }
.kv div { background: var(--surface-2); border-radius: 8px; padding: 6px 8px; min-width: 0; }
.kv span { display: block; font-size: 11.5px; color: var(--muted); }
.kv b { display: block; font-size: 14px; font-weight: 600; font-variant-numeric: tabular-nums;
        overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.app-foot { margin-top: 10px; font-size: 12.5px; color: var(--muted); display: flex; flex-wrap: wrap; gap: 4px 12px; }
.app-foot .err { color: var(--down); width: 100%; font-family: var(--mono); font-size: 12px; word-break: break-all; }
.tag { font-size: 11px; padding: 1px 7px; border-radius: 6px; background: var(--surface-2); color: var(--muted); }

/* Listes */
.list { list-style: none; margin: 0; padding: 0; }
.list li { display: flex; align-items: center; justify-content: space-between; gap: 10px;
           padding: 9px 0; border-bottom: 1px solid var(--border); font-size: 14px; }
.list li:last-child { border-bottom: 0; }
.list .main { min-width: 0; }
.list .main b { font-weight: 600; }
.list .sub { font-size: 12.5px; color: var(--muted); }
.list .mono { font-family: var(--mono); font-size: 13px; }
.empty { color: var(--muted); font-size: 14px; padding: 6px 0; }

/* Formulaires et boutons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  border: 1px solid var(--border); background: var(--surface); color: var(--text);
  padding: 9px 14px; border-radius: 10px; font: inherit; font-weight: 600; cursor: pointer;
}
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-text); }
.btn:disabled { opacity: .55; cursor: default; }
.btn.small { padding: 5px 10px; font-size: 13px; }
.actions-row { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }
.login { max-width: 380px; margin: 8vh auto 0; }
.login h1 { font-size: 20px; margin-bottom: 4px; }
.login p { color: var(--muted); margin: 0 0 18px; font-size: 14px; }
.field { display: block; margin-bottom: 14px; }
.field span { display: block; font-size: 13px; font-weight: 600; margin-bottom: 5px; }
.field input {
  width: 100%; padding: 11px 12px; border-radius: 10px; border: 1px solid var(--border);
  background: var(--surface-2); color: var(--text); font: inherit; font-size: 16px;
}
.field input:focus { outline: 2px solid var(--accent); outline-offset: 1px; }
.error { color: var(--down); background: var(--down-bg); padding: 9px 12px; border-radius: 10px; font-size: 14px; margin-bottom: 14px; }
.hint { font-size: 13px; color: var(--muted); }
.muted { color: var(--muted); }

@media (max-width: 520px) {
  .page { padding: 4px 12px 28px; }
  .grid { grid-template-columns: 1fr; }
  .gauges { grid-template-columns: 1fr 1fr; }
  .kv { grid-template-columns: repeat(3, 1fr); }
  .spark-row { grid-template-columns: 1fr; }
}

/* ── Phase 2 : navigation, graphiques, tableaux ───────────────────────────── */
:root { --c1: #0f766e; --c2: #2563eb; --c3: #d97706; --c4: #dc2626; --c5: #7c3aed; }
@media (prefers-color-scheme: dark) {
  :root { --c1: #2dd4bf; --c2: #60a5fa; --c3: #fbbf24; --c4: #f87171; --c5: #a78bfa; }
}
.nav { display: flex; gap: 4px; flex: 1; margin-left: 12px; overflow-x: auto; }
.nav a { color: var(--muted); text-decoration: none; padding: 6px 10px; border-radius: 8px; font-size: 14px; white-space: nowrap; }
.nav a:hover { background: var(--surface-2); color: var(--text); }
.nav a[aria-current="page"] { background: var(--surface-2); color: var(--text); font-weight: 600; }
a.app-name { color: var(--text); text-decoration: none; display: block; }
a.app-name:hover { color: var(--accent); }
.app-title { font-size: 20px; }
.kv .bad b, .bad-text { color: var(--down); }
.app-foot .err-line { color: var(--down); width: 100%; }
.traffic { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 8px; margin-top: 12px; align-items: center; }
.traffic span { display: block; font-size: 11.5px; color: var(--muted); }
.traffic b { font-size: 15px; font-variant-numeric: tabular-nums; }
.traffic .bad b { color: var(--down); }
.traffic .more { font-size: 13px; justify-self: end; }
.range-bar { display: flex; gap: 6px; margin: 16px 0 4px; }
.grid.charts { grid-template-columns: repeat(auto-fill, minmax(340px, 1fr)); margin-top: 12px; }
.chart-title { font-size: 13px; font-weight: 600; color: var(--muted); margin-bottom: 6px; }
.chart-box { position: relative; }
svg.chart { display: block; touch-action: pan-y; }
svg.chart .grid { stroke: var(--border); stroke-width: 1; }
svg.chart .axis { fill: var(--muted); font-size: 11px; font-variant-numeric: tabular-nums; }
svg.chart .line { fill: none; stroke-width: 1.8; stroke-linejoin: round; }
svg.chart .cursor { stroke: var(--muted); stroke-dasharray: 3 3; }
.line.c1, .tip-row.c1 i { stroke: var(--c1); background: var(--c1); }
.line.c2, .tip-row.c2 i { stroke: var(--c2); background: var(--c2); }
.line.c3, .tip-row.c3 i { stroke: var(--c3); background: var(--c3); }
.line.c4, .tip-row.c4 i { stroke: var(--c4); background: var(--c4); }
.line.c5, .tip-row.c5 i { stroke: var(--c5); background: var(--c5); }
.chart-tip { position: absolute; top: 4px; width: 150px; background: var(--surface); border: 1px solid var(--border);
             border-radius: 8px; padding: 6px 8px; font-size: 12px; box-shadow: var(--shadow); pointer-events: none; }
.tip-row { display: flex; align-items: center; gap: 6px; }
.tip-row i { display: inline-block; width: 10px; height: 3px; border-radius: 2px; }
.chart-legend { display: flex; flex-wrap: wrap; gap: 4px 14px; font-size: 12px; color: var(--muted); margin-top: 4px; }
.table-wrap { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.table th { text-align: left; font-size: 12px; color: var(--muted); font-weight: 600; padding: 6px 8px; border-bottom: 1px solid var(--border); white-space: nowrap; }
.table td { padding: 7px 8px; border-bottom: 1px solid var(--border); vertical-align: top; font-variant-numeric: tabular-nums; }
.table tr:last-child td { border-bottom: 0; }
.mono { font-family: var(--mono); font-size: 12.5px; }
.clip { display: inline-block; max-width: 520px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; vertical-align: bottom; }
details.exception, details.event { border-bottom: 1px solid var(--border); padding: 8px 0; }
details.exception:last-child, details.event:last-child { border-bottom: 0; }
details summary { cursor: pointer; }
details .sub, summary .sub { font-size: 12.5px; color: var(--muted); }
pre.stack { background: var(--surface-2); border-radius: 8px; padding: 10px; font: 12px/1.45 var(--mono);
            overflow-x: auto; white-space: pre; max-height: 360px; }
.list.compact li { padding: 5px 0; font-size: 13px; }
.list.compact .main { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.filters { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 0 14px; }
.field select { width: 100%; padding: 10px 12px; border-radius: 10px; border: 1px solid var(--border);
                background: var(--surface-2); color: var(--text); font: inherit; }
@media (max-width: 520px) {
  .grid.charts { grid-template-columns: 1fr; }
  .nav { margin-left: 4px; }
}
