/* Plesk Backup Hub - interface d'administration.
   Couleurs definies par role ; le theme sombre est choisi explicitement (data-theme) ou suit le
   systeme en mode automatique. Palette des graphiques validee (daltonisme, contraste) sur les
   surfaces de carte des deux themes. */

@font-face {
  font-family: "Inter";
  src: url("/static/fonts/inter-latin-wght-normal.woff2") format("woff2");
  font-weight: 100 900;
  font-style: normal;
  font-display: swap;
}

:root {
  color-scheme: light;
  --bg: #f4f5f8;
  --bg-side: #fbfbfd;
  --surface: #ffffff;
  --surface-2: #f5f6f9;
  --surface-3: #eceef3;
  --border: rgba(16, 24, 40, 0.08);
  --border-strong: rgba(16, 24, 40, 0.15);
  --text: #101828;
  --text-2: #475467;
  --muted: #8a93a3;
  --accent: #2a78d6;
  --accent-hover: #256abf;
  --accent-soft: rgba(42, 120, 214, 0.10);
  --accent-ink: #1c5cab;
  --on-accent: #ffffff;
  --grid: #eceef2;
  --axis: #d5d9e0;
  --shadow: 0 1px 2px rgba(16, 24, 40, 0.04), 0 1px 3px rgba(16, 24, 40, 0.06);
  --shadow-pop: 0 12px 32px rgba(16, 24, 40, 0.16);
  --good: #0ca30c;
  --warning: #fab219;
  --serious: #ec835a;
  --critical: #d03b3b;
  --good-soft: rgba(12, 163, 12, 0.10);
  --warning-soft: rgba(250, 178, 25, 0.16);
  --critical-soft: rgba(208, 59, 59, 0.10);
  --none-cell: #e9ebf0;
  --series-1: #2a78d6;
  --series-2: #eb6834;
  --series-3: #1baf7a;
  --series-4: #eda100;
  --series-5: #e87ba4;
  --series-6: #008300;
  --series-7: #4a3aa7;
  --series-8: #8a93a3;
  --mono: ui-monospace, "SF Mono", SFMono-Regular, Menlo, Consolas, monospace;
  --radius: 12px;
  --radius-sm: 8px;
}

@media (prefers-color-scheme: dark) {
  :root:where(:not([data-theme="light"])) {
    color-scheme: dark;
    --bg: #0b0e14;
    --bg-side: #0e1219;
    --surface: #141922;
    --surface-2: #1a202b;
    --surface-3: #222938;
    --border: rgba(255, 255, 255, 0.07);
    --border-strong: rgba(255, 255, 255, 0.13);
    --text: #e8ebf1;
    --text-2: #a9b1bf;
    --muted: #707a8c;
    --accent: #3987e5;
    --accent-hover: #5598e7;
    --accent-soft: rgba(57, 135, 229, 0.15);
    --accent-ink: #86b6ef;
    --on-accent: #ffffff;
    --grid: #202735;
    --axis: #2d3544;
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.3);
    --shadow-pop: 0 16px 40px rgba(0, 0, 0, 0.5);
    --good-soft: rgba(12, 163, 12, 0.16);
    --warning-soft: rgba(250, 178, 25, 0.14);
    --critical-soft: rgba(208, 59, 59, 0.18);
    --none-cell: #1f2632;
    --series-1: #3987e5;
    --series-2: #d95926;
    --series-3: #199e70;
    --series-4: #c98500;
    --series-5: #d55181;
    --series-6: #008300;
    --series-7: #9085e9;
    --series-8: #707a8c;
  }
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #0b0e14;
  --bg-side: #0e1219;
  --surface: #141922;
  --surface-2: #1a202b;
  --surface-3: #222938;
  --border: rgba(255, 255, 255, 0.07);
  --border-strong: rgba(255, 255, 255, 0.13);
  --text: #e8ebf1;
  --text-2: #a9b1bf;
  --muted: #707a8c;
  --accent: #3987e5;
  --accent-hover: #5598e7;
  --accent-soft: rgba(57, 135, 229, 0.15);
  --accent-ink: #86b6ef;
  --on-accent: #ffffff;
  --grid: #202735;
  --axis: #2d3544;
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.3);
  --shadow-pop: 0 16px 40px rgba(0, 0, 0, 0.5);
  --good-soft: rgba(12, 163, 12, 0.16);
  --warning-soft: rgba(250, 178, 25, 0.14);
  --critical-soft: rgba(208, 59, 59, 0.18);
  --none-cell: #1f2632;
  --series-1: #3987e5;
  --series-2: #d95926;
  --series-3: #199e70;
  --series-4: #c98500;
  --series-5: #d55181;
  --series-6: #008300;
  --series-7: #9085e9;
  --series-8: #707a8c;
}

/* Base ------------------------------------------------------------------------------------ */

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 14px/1.5 "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  font-feature-settings: "cv11", "ss01";
  -webkit-font-smoothing: antialiased;
}

a { color: var(--accent-ink); text-decoration: none; }
a:hover { color: var(--accent); }
h1 { font-size: 22px; line-height: 1.25; margin: 0; font-weight: 650; letter-spacing: -0.01em; }
h2 { font-size: 15px; margin: 0; font-weight: 600; }
h3 { font-size: 13px; margin: 18px 0 8px; font-weight: 600; }
p { margin: 0 0 10px; }
.muted { color: var(--muted); }
.secondary { color: var(--text-2); }
.mono, code, pre { font-family: var(--mono); font-size: 12.5px; }
code { background: var(--surface-2); border: 1px solid var(--border); padding: 1px 5px; border-radius: 5px; }
.num { font-variant-numeric: tabular-nums; }

.icon {
  width: 16px; height: 16px; flex: none;
  fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round;
  vertical-align: -3px;
}
.icon.lg { width: 20px; height: 20px; }
.icon.spin { animation: spin 1s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* Structure -------------------------------------------------------------------------------- */

.app {
  display: grid; grid-template-columns: 252px minmax(0, 1fr); min-height: 100vh;
  /* la colonne de la barre laterale garde son fond sur toute la hauteur de la page */
  background: linear-gradient(90deg, var(--bg-side) 0 251px, var(--border) 251px 252px, transparent 252px);
}

.sidebar {
  position: sticky; top: 0; height: 100vh;
  display: flex; flex-direction: column; gap: 4px;
  background: var(--bg-side);
  border-right: 1px solid var(--border);
  padding: 18px 12px 14px;
  overflow-y: auto;
}

.brand { display: flex; align-items: center; gap: 10px; padding: 2px 8px 18px; color: var(--text); font-weight: 650; }
.brand:hover { color: var(--text); }
.brand-mark {
  width: 30px; height: 30px; border-radius: 9px;
  display: grid; place-items: center;
  background: linear-gradient(145deg, #3987e5, #1c5cab);
  color: #fff; box-shadow: 0 4px 12px rgba(42, 120, 214, 0.35);
}
.brand small { display: block; font-weight: 500; font-size: 11.5px; color: var(--muted); letter-spacing: 0; }

.nav a, .side-server {
  display: flex; align-items: center; gap: 10px;
  padding: 7px 10px; border-radius: var(--radius-sm);
  color: var(--text-2); font-weight: 500;
}
.nav a:hover, .side-server:hover { background: var(--surface-3); color: var(--text); }
.nav a.active { background: var(--accent-soft); color: var(--accent-ink); }
.nav a .count { margin-left: auto; font-size: 11.5px; background: var(--accent); color: var(--on-accent); border-radius: 999px; padding: 0 7px; }

.side-title {
  margin: 18px 10px 6px; font-size: 11px; font-weight: 600; letter-spacing: 0.06em;
  text-transform: uppercase; color: var(--muted);
  display: flex; justify-content: space-between; align-items: center;
}
.side-title a { color: var(--muted); }
.side-title a:hover { color: var(--text); }
.side-server { font-size: 13px; }
.side-server.active { background: var(--surface-3); color: var(--text); }
.side-server span.name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.dot { width: 8px; height: 8px; border-radius: 50%; flex: none; background: var(--muted); box-shadow: 0 0 0 3px var(--surface-3); }
.dot.good { background: var(--good); box-shadow: 0 0 0 3px var(--good-soft); }
.dot.warning { background: var(--warning); box-shadow: 0 0 0 3px var(--warning-soft); }
.dot.critical { background: var(--critical); box-shadow: 0 0 0 3px var(--critical-soft); }
.dot.running { background: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); animation: pulse 1.6s ease-in-out infinite; }
@keyframes pulse { 50% { box-shadow: 0 0 0 5px var(--accent-soft); } }

.side-foot { margin-top: auto; padding-top: 14px; display: flex; flex-direction: column; gap: 10px; }

.theme-switch {
  display: grid; grid-template-columns: repeat(3, 1fr); gap: 2px;
  background: var(--surface-3); border-radius: 9px; padding: 3px;
}
.theme-switch button {
  border: 0; background: transparent; color: var(--muted); border-radius: 7px; padding: 5px 0;
  cursor: pointer; display: grid; place-items: center;
}
.theme-switch button:hover { color: var(--text); }
.theme-switch button[aria-pressed="true"] { background: var(--surface); color: var(--text); box-shadow: var(--shadow); }

.main { min-width: 0; display: flex; flex-direction: column; }

.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; gap: 12px;
  height: 56px; padding: 0 32px;
  background: color-mix(in srgb, var(--bg) 82%, transparent);
  backdrop-filter: saturate(160%) blur(10px);
  border-bottom: 1px solid var(--border);
}
.crumbs { display: flex; align-items: center; gap: 6px; color: var(--muted); font-size: 13px; min-width: 0; }
.crumbs a { color: var(--text-2); }
.crumbs a:hover { color: var(--text); }
.crumbs .current { color: var(--text); font-weight: 550; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.crumbs .icon { width: 14px; height: 14px; }
.btn.menu-toggle { display: none; }

.content { width: 100%; max-width: 1320px; margin: 0 auto; padding: 28px 32px 56px; }

.page-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 16px; margin-bottom: 24px; flex-wrap: wrap; }
.page-head .sub { color: var(--text-2); margin-top: 6px; display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }

/* Cartes et grilles ---------------------------------------------------------------------- */

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 20px;
  min-width: 0;
}
.stack > * + * { margin-top: 20px; }
.card-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-bottom: 16px; }
.card-head .hint { color: var(--muted); font-size: 12.5px; margin-top: 2px; }
.card.flush { padding: 0; }
.card.flush .card-head { padding: 18px 20px 0; }
.card.danger { border-color: color-mix(in srgb, var(--critical) 45%, var(--border)); }

.grid { display: grid; gap: 20px; }
.grid.kpis { grid-template-columns: repeat(4, minmax(0, 1fr)); margin-bottom: 20px; }
.grid.two { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid.side { grid-template-columns: minmax(0, 1.6fr) minmax(0, 1fr); align-items: start; }
.section { margin-top: 20px; }

/* Indicateurs ----------------------------------------------------------------------------- */

.kpi { display: flex; flex-direction: column; gap: 4px; padding: 18px 20px; }
.kpi .label { color: var(--text-2); font-size: 12.5px; font-weight: 500; display: flex; align-items: center; gap: 8px; }
.kpi .label .icon { color: var(--muted); }
.kpi .value { font-size: 26px; font-weight: 650; letter-spacing: -0.02em; line-height: 1.2; }
.kpi .value small { font-size: 14px; color: var(--muted); font-weight: 500; letter-spacing: 0; }
.kpi .foot { color: var(--muted); font-size: 12.5px; display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.kpi .spark { height: 40px; margin-top: 8px; }
.kpi .spark .chart-box { height: 40px; }

.meter { height: 6px; border-radius: 999px; background: var(--accent-soft); overflow: hidden; margin-top: 8px; }
.meter > span { display: block; height: 100%; border-radius: 999px; background: var(--accent); }
.meter.warning > span { background: var(--warning); }
.meter.critical > span { background: var(--critical); }

/* Pastilles d'etat : icone + libelle, jamais la couleur seule */
.pill {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 2px 9px 2px 7px; border-radius: 999px;
  font-size: 12px; font-weight: 550; line-height: 18px; white-space: nowrap;
  background: var(--surface-3); color: var(--text-2);
}
.pill .icon { width: 13px; height: 13px; }
.pill.good { background: var(--good-soft); color: var(--text); }
.pill.good .icon { color: var(--good); }
.pill.warning { background: var(--warning-soft); color: var(--text); }
.pill.warning .icon { color: #c98500; }
.pill.critical { background: var(--critical-soft); color: var(--text); }
.pill.critical .icon { color: var(--critical); }
.pill.running { background: var(--accent-soft); color: var(--accent-ink); }
.pill.none .icon { color: var(--muted); }
.tag { display: inline-flex; align-items: center; gap: 5px; font-size: 12px; color: var(--text-2);
       background: var(--surface-2); border: 1px solid var(--border); border-radius: 6px; padding: 1px 7px; }

/* Boutons et formulaires ----------------------------------------------------------------- */

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  height: 34px; padding: 0 14px; border-radius: var(--radius-sm);
  border: 1px solid var(--border-strong); background: var(--surface); color: var(--text);
  font: inherit; font-weight: 550; cursor: pointer; white-space: nowrap;
  transition: background 0.12s, border-color 0.12s, box-shadow 0.12s;
}
.btn:hover { background: var(--surface-2); color: var(--text); }
.btn:focus-visible, .input:focus-visible, select:focus-visible, textarea:focus-visible {
  outline: 2px solid var(--accent); outline-offset: 1px;
}
.btn.primary { background: var(--accent); border-color: transparent; color: var(--on-accent); box-shadow: 0 1px 2px rgba(42, 120, 214, 0.3); }
.btn.primary:hover { background: var(--accent-hover); }
.btn.ghost { border-color: transparent; background: transparent; color: var(--text-2); }
.btn.ghost:hover { background: var(--surface-3); color: var(--text); }
.btn.danger { color: var(--critical); border-color: color-mix(in srgb, var(--critical) 40%, transparent); }
.btn.danger:hover { background: var(--critical-soft); }
.btn.danger.solid { background: var(--critical); color: #fff; border-color: transparent; }
.btn.sm { height: 28px; padding: 0 10px; font-size: 12.5px; border-radius: 7px; }
.btn.icon-only { width: 34px; padding: 0; }
.btn[disabled] { opacity: 0.5; cursor: not-allowed; }
form.inline { display: inline; }

.field { margin-bottom: 14px; }
.field label, .label-text { display: block; font-weight: 550; font-size: 12.5px; margin-bottom: 6px; color: var(--text); }
.field .hint { color: var(--muted); font-size: 12px; margin-top: 5px; }
.row { display: flex; gap: 12px; flex-wrap: wrap; }
.row > .field { flex: 1; min-width: 110px; }

.input, select, textarea {
  width: 100%; height: 36px; padding: 0 11px;
  border: 1px solid var(--border-strong); border-radius: var(--radius-sm);
  background: var(--surface); color: var(--text); font: inherit;
}
textarea { height: auto; min-height: 96px; padding: 9px 11px; font-family: var(--mono); font-size: 12.5px; resize: vertical; }
.input::placeholder, textarea::placeholder { color: var(--muted); }

.check { display: flex; align-items: flex-start; gap: 10px; font-size: 13.5px; cursor: pointer; margin-bottom: 10px; }
.check input { margin: 2px 0 0; accent-color: var(--accent); width: 16px; height: 16px; flex: none; }
.check small { display: block; color: var(--muted); font-size: 12px; }

.choice { display: grid; gap: 8px; margin-bottom: 14px; }
.choice label {
  display: flex; gap: 10px; align-items: flex-start; cursor: pointer;
  padding: 11px 12px; border: 1px solid var(--border-strong); border-radius: var(--radius-sm);
}
.choice label:has(input:checked) { border-color: var(--accent); background: var(--accent-soft); }
.choice input { accent-color: var(--accent); margin-top: 3px; }
.choice strong { display: block; font-weight: 600; }
.choice span { color: var(--text-2); font-size: 12.5px; }

/* Tableaux -------------------------------------------------------------------------------- */

.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--border); vertical-align: middle; }
th { color: var(--muted); font-weight: 550; font-size: 12px; white-space: nowrap; }
tbody tr:hover td { background: var(--surface-2); }
tr:last-child td { border-bottom: 0; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
td .primary-cell { font-weight: 550; color: var(--text); display: block; }
td .secondary-cell { color: var(--muted); font-size: 12px; font-family: var(--mono); }
.card.flush table th:first-child, .card.flush table td:first-child { padding-left: 20px; }
.card.flush table th:last-child, .card.flush table td:last-child { padding-right: 20px; }
td.actions-cell { text-align: right; white-space: nowrap; }

/* Graphiques ------------------------------------------------------------------------------ */

.chart { margin: 0; }
.chart-box { position: relative; height: 240px; }
.chart-box.tall { height: 280px; }
.chart-box.short { height: 200px; }
.chart-table { display: none; margin-top: 8px; max-height: 280px; overflow: auto; }
.chart.show-table .chart-box { display: none; }
.chart.show-table .chart-table { display: block; }
.chart-empty { height: 100%; display: grid; place-items: center; color: var(--muted); text-align: center; font-size: 13px; }
.legend { display: flex; gap: 14px; flex-wrap: wrap; font-size: 12.5px; color: var(--text-2); }
.legend .key { display: inline-flex; align-items: center; gap: 6px; }
.legend .swatch { width: 10px; height: 10px; border-radius: 3px; }
.seg { display: inline-flex; background: var(--surface-3); border-radius: 8px; padding: 2px; }
.seg button { border: 0; background: transparent; color: var(--muted); font: inherit; font-size: 12px; font-weight: 550; padding: 3px 10px; border-radius: 6px; cursor: pointer; }
.seg button[aria-pressed="true"] { background: var(--surface); color: var(--text); box-shadow: var(--shadow); }

/* Grille de sante */
.health { display: grid; grid-template-columns: minmax(150px, 220px) minmax(0, 1fr) 52px; gap: 6px 14px; align-items: center; }
.health .site { min-width: 0; }
.health .site a { color: var(--text); font-weight: 550; display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.health .site small { color: var(--muted); font-size: 11.5px; }
.health .cells { display: grid; grid-template-columns: repeat(30, minmax(0, 1fr)); gap: 3px; }
.health .cell { height: 22px; border-radius: 4px; background: var(--none-cell); cursor: default; outline-offset: 1px; }
.health .cell:hover, .health .cell:focus { outline: 2px solid var(--text-2); }
.health .cell.good { background: var(--good); }
.health .cell.warning { background: var(--warning); }
.health .cell.critical { background: var(--critical); }
.health .cell.running { background: var(--accent); }
.health .rate { text-align: right; font-variant-numeric: tabular-nums; color: var(--text-2); font-size: 12.5px; }
.health .axis { font-size: 11px; color: var(--muted); display: flex; justify-content: space-between; }
.health-legend { display: flex; gap: 16px; flex-wrap: wrap; font-size: 12.5px; color: var(--text-2); }
.health-legend span { display: inline-flex; align-items: center; gap: 6px; }
.health-legend i { width: 11px; height: 11px; border-radius: 3px; display: inline-block; background: var(--none-cell); }
.health-legend i.good { background: var(--good); }
.health-legend i.warning { background: var(--warning); }
.health-legend i.critical { background: var(--critical); }

.tooltip {
  position: fixed; z-index: 100; pointer-events: none;
  background: var(--surface); color: var(--text);
  border: 1px solid var(--border-strong); border-radius: 8px; box-shadow: var(--shadow-pop);
  padding: 7px 10px; font-size: 12.5px; max-width: 320px;
  opacity: 0; transform: translateY(4px); transition: opacity 0.1s, transform 0.1s;
}
.tooltip.visible { opacity: 1; transform: none; }

/* Progression ----------------------------------------------------------------------------- */

.progress { height: 8px; border-radius: 999px; background: var(--accent-soft); overflow: hidden; }
.progress > span { display: block; height: 100%; background: var(--accent); border-radius: 999px; transition: width 0.6s ease; }
.progress.indeterminate > span { width: 30%; animation: slide 1.4s ease-in-out infinite; }
@keyframes slide { 0% { margin-left: -30%; } 100% { margin-left: 100%; } }
.live-job { padding: 14px 0; border-bottom: 1px solid var(--border); }
.live-job:last-child { border-bottom: 0; padding-bottom: 0; }
.live-job:first-child { padding-top: 0; }
.live-job .line { display: flex; justify-content: space-between; gap: 12px; margin-bottom: 8px; align-items: center; }
.live-job .stats { display: flex; gap: 14px; color: var(--text-2); font-size: 12.5px; margin-top: 7px; flex-wrap: wrap; }

/* Commandes, journaux --------------------------------------------------------------------- */

.command {
  display: flex; align-items: flex-start; gap: 10px;
  background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius-sm);
  padding: 10px 10px 10px 12px;
}
.command code { flex: 1; background: none; border: 0; padding: 0; font-size: 12px; word-break: break-all; max-height: 92px; overflow: auto; color: var(--text-2); }

.terminal {
  background: #0a0d12; color: #d7dde8; border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  padding: 14px 16px; margin: 0; max-height: 520px; overflow: auto;
  font: 12.5px/1.6 var(--mono); white-space: pre-wrap;
}
.terminal .warn { color: #fab219; }
.terminal .fail { color: #ff7b72; }

.steps { list-style: none; padding: 0; margin: 0; display: grid; gap: 20px; }
.steps > li { display: grid; grid-template-columns: 30px minmax(0, 1fr); gap: 14px; }
.steps .n {
  width: 30px; height: 30px; border-radius: 50%; display: grid; place-items: center;
  background: var(--accent-soft); color: var(--accent-ink); font-weight: 650; font-size: 13px;
}
.steps h3 { margin: 4px 0 6px; font-size: 14px; }

/* Explorateur de fichiers */
.browser td { padding-top: 8px; padding-bottom: 8px; }
.browser .entry { display: inline-flex; align-items: center; gap: 9px; font-family: var(--mono); font-size: 13px; color: var(--text); }
.browser .entry .icon { color: var(--muted); }
.browser .entry.dir .icon { color: var(--accent); }
.path { display: flex; align-items: center; gap: 2px; flex-wrap: wrap; font-family: var(--mono); font-size: 13px; }
.path a { padding: 2px 6px; border-radius: 6px; color: var(--text-2); }
.path a:hover { background: var(--surface-3); color: var(--text); }
.path .sep { color: var(--muted); }

/* Etats vides, notifications, fenetres ---------------------------------------------------- */

.empty { text-align: center; padding: 36px 16px; color: var(--text-2); }
.empty .icon-wrap { width: 48px; height: 48px; margin: 0 auto 12px; border-radius: 14px; display: grid; place-items: center; background: var(--accent-soft); color: var(--accent-ink); }
.empty h3 { margin: 0 0 6px; font-size: 15px; color: var(--text); }

.toasts { position: fixed; right: 20px; bottom: 20px; z-index: 200; display: grid; gap: 10px; }
.toast {
  display: flex; gap: 10px; align-items: flex-start; min-width: 280px; max-width: 420px;
  background: var(--surface); border: 1px solid var(--border-strong); border-radius: 10px;
  box-shadow: var(--shadow-pop); padding: 12px 14px; animation: toast-in 0.2s ease;
}
.toast .icon { margin-top: 1px; }
.toast.ok .icon { color: var(--good); }
.toast.err .icon { color: var(--critical); }
.toast button { margin-left: auto; border: 0; background: none; color: var(--muted); cursor: pointer; padding: 0; }
@keyframes toast-in { from { opacity: 0; transform: translateY(8px); } }

.banner { display: flex; gap: 12px; align-items: center; padding: 12px 16px; border-radius: var(--radius);
          background: var(--warning-soft); border: 1px solid color-mix(in srgb, var(--warning) 35%, transparent); margin-bottom: 20px; }
.banner .icon { color: #c98500; }
.banner a { font-weight: 600; margin-left: auto; white-space: nowrap; }

dialog {
  border: 1px solid var(--border-strong); border-radius: 14px; padding: 0; width: min(460px, calc(100vw - 32px));
  background: var(--surface); color: var(--text); box-shadow: var(--shadow-pop);
}
dialog::backdrop { background: rgba(5, 8, 13, 0.55); backdrop-filter: blur(2px); }
dialog .dialog-body { padding: 22px 22px 8px; }
dialog .dialog-body h2 { font-size: 16px; margin-bottom: 8px; display: flex; gap: 10px; align-items: center; }
dialog .dialog-foot { display: flex; justify-content: flex-end; gap: 8px; padding: 14px 22px 20px; }

/* Connexion ------------------------------------------------------------------------------- */

.auth-page {
  min-height: 100vh; display: grid; place-items: center; padding: 24px;
  background:
    radial-gradient(900px 500px at 15% -10%, var(--accent-soft), transparent 60%),
    radial-gradient(700px 400px at 110% 110%, var(--accent-soft), transparent 60%),
    var(--bg);
}
.auth-card { width: min(400px, 100%); padding: 32px; }
.auth-card .brand { padding: 0 0 22px; }

/* Petits ecrans ---------------------------------------------------------------------------- */

@media (max-width: 1100px) {
  .grid.kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .grid.side, .grid.two { grid-template-columns: minmax(0, 1fr); }
}

@media (max-width: 820px) {
  .app { grid-template-columns: minmax(0, 1fr); }
  .sidebar {
    position: fixed; z-index: 50; left: 0; top: 0; width: 272px;
    transform: translateX(-100%); transition: transform 0.2s ease; box-shadow: var(--shadow-pop);
  }
  body.nav-open .sidebar { transform: none; }
  .btn.menu-toggle { display: inline-flex; }
  .topbar { padding: 0 16px; }
  .content { padding: 20px 16px 48px; }
  .app { background: none; }
  .health { grid-template-columns: minmax(0, 1fr) 44px; }
  .health .head { display: none; }
  .health .cells { grid-column: 1 / -1; grid-row: auto; }
  .health .site { grid-column: 1; }
}

@media (max-width: 520px) {
  .grid.kpis { grid-template-columns: minmax(0, 1fr); }
  .toasts { left: 16px; right: 16px; }
  .toast { min-width: 0; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}

/* Choix des exclusions --------------------------------------------------------------------- */

.tree { border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--surface-2); padding: 8px; max-height: 560px; overflow: auto; }
.tree-list { list-style: none; margin: 0; padding: 0; }
.tree-list .tree-list { padding-left: 22px; border-left: 1px solid var(--border); margin-left: 11px; }
.tree-row { display: flex; align-items: center; gap: 6px; padding: 3px 4px; border-radius: 6px; min-height: 34px; }
.tree-row:hover { background: var(--surface-3); }
.tree-toggle { width: 24px; height: 24px; border: 0; background: none; color: var(--muted); border-radius: 6px; cursor: pointer; display: grid; place-items: center; flex: none; }
.tree-toggle:hover { background: var(--surface); color: var(--text); }
.tree-toggle .icon { transition: transform 0.15s; }
.tree-item.open > .tree-row .tree-toggle .icon { transform: rotate(90deg); }
.tree-item:not(.open) > .tree-children { display: none; }
.tree-spacer { width: 24px; flex: none; }
.tree-label { display: flex; align-items: center; gap: 8px; cursor: pointer; flex: 1; min-width: 0; font-size: 13px; }
.tree-label input { accent-color: var(--critical); width: 15px; height: 15px; margin: 0; flex: none; }
.tree-label .icon { color: var(--accent); }
.tree-label .mono { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tree-item.excluded > .tree-row .tree-label .mono { text-decoration: line-through; color: var(--muted); }
.tree-item.excluded > .tree-row .tree-label .icon { color: var(--muted); }
.tree-item.inherited > .tree-row { opacity: 0.6; }
.tree-size { margin-left: auto; font-size: 12.5px; color: var(--text-2); white-space: nowrap; }
.tree-size .btn { height: 24px; }
.tree-note { color: var(--text-2); font-size: 13px; padding: 10px; display: flex; gap: 8px; align-items: flex-start; }
.tree-files { font-size: 12px; padding: 4px 8px 6px 34px; }

.presets { display: flex; flex-wrap: wrap; gap: 6px; }
.chip {
  display: inline-flex; align-items: center; gap: 6px; height: 30px; padding: 0 11px;
  border: 1px solid var(--border-strong); border-radius: 999px; background: var(--surface);
  color: var(--text-2); font: inherit; font-size: 12.5px; font-weight: 550; cursor: pointer;
}
.chip .icon { width: 13px; height: 13px; display: none; }
.chip:hover { color: var(--text); background: var(--surface-2); }
.chip[aria-pressed="true"] { background: var(--accent-soft); border-color: var(--accent); color: var(--accent-ink); }
.chip[aria-pressed="true"] .icon { display: inline; }

.excluded-list { display: flex; flex-wrap: wrap; gap: 6px; }
.excluded-list .tag { padding-right: 3px; }
.excluded-list .tag.common { background: transparent; border-style: dashed; padding-right: 7px; }
.common-group { flex-basis: 100%; }
.common-group > summary { cursor: pointer; font-size: 12.5px; color: var(--text-2); margin-bottom: 6px; }
.common-group[open] > summary { margin-bottom: 8px; }
.common-group > .excluded-list { margin-bottom: 4px; }
.tree-note-inline { font-size: 11.5px; color: var(--muted); border: 1px dashed var(--border); border-radius: 5px;
                    padding: 0 6px; margin-left: 6px; white-space: nowrap; }
.chip:disabled { opacity: 0.6; cursor: default; }
.tag-close { border: 0; background: none; color: var(--muted); cursor: pointer; font-size: 15px; line-height: 1; padding: 0 4px; border-radius: 4px; }
.tag-close:hover { color: var(--critical); background: var(--critical-soft); }

.advanced { margin-top: 16px; }
.advanced summary { cursor: pointer; font-weight: 550; font-size: 12.5px; color: var(--text-2); margin-bottom: 8px; }
.dirty-note { display: inline-flex; gap: 6px; align-items: center; font-size: 12.5px; color: #c98500; }
.dirty-note[hidden] { display: none; }

/* Aide -------------------------------------------------------------------------------------- */

.doc-layout { display: grid; grid-template-columns: 220px minmax(0, 1fr); gap: 24px; align-items: start; }
.doc-toc { position: sticky; top: 76px; display: flex; flex-direction: column; gap: 2px; padding: 16px; }
.doc-toc strong { font-size: 12px; text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted); margin-bottom: 8px; }
.doc-toc a { color: var(--text-2); padding: 5px 8px; border-radius: 6px; font-size: 13px; }
.doc-toc a:hover { background: var(--surface-3); color: var(--text); }
.doc { display: flex; flex-direction: column; gap: 20px; max-width: 860px; }
.doc section { scroll-margin-top: 76px; }
.doc h2 { font-size: 17px; margin-bottom: 12px; }
.doc p, .doc li, .doc dd { color: var(--text-2); line-height: 1.65; }
.doc p strong, .doc li strong { color: var(--text); }
.doc ul, .doc ol { padding-left: 20px; margin: 0 0 10px; }
.doc li { margin-bottom: 6px; }
.doc li ul { margin-top: 6px; }
.doc table td:first-child { white-space: nowrap; }
.doc .terminal { margin: 8px 0 0; }
.faq dt { font-weight: 600; margin-top: 14px; color: var(--text); }
.faq dt:first-child { margin-top: 0; }
.faq dd { margin: 4px 0 0; }
.diagram { margin: 16px 0; padding: 12px; background: var(--surface-2); border-radius: var(--radius-sm); border: 1px solid var(--border); }
.diagram svg { display: block; max-width: 720px; margin: 0 auto; font-family: inherit; }
.d-box { fill: var(--surface); stroke: var(--border-strong); stroke-width: 1.5; }
.d-agent { fill: var(--accent-soft); stroke: var(--accent); stroke-width: 1.5; }
.d-title { fill: var(--text); font-size: 15px; font-weight: 650; text-anchor: middle; }
.d-text { fill: var(--text-2); font-size: 12.5px; text-anchor: middle; }
.d-strong { fill: var(--accent-ink); font-weight: 600; }
.d-label { fill: var(--text-2); font-size: 12px; text-anchor: middle; }
.d-line { stroke: var(--muted); stroke-width: 2; fill: none; }
.d-line.d-accent { stroke: var(--accent); }
.d-arrow-head { fill: var(--muted); }
.card-head h2 a { color: var(--muted); display: inline-flex; vertical-align: middle; }
.card-head h2 a:hover { color: var(--text); }

@media (max-width: 900px) {
  .doc-layout { grid-template-columns: minmax(0, 1fr); }
  .doc-toc { position: static; flex-direction: row; flex-wrap: wrap; }
  .doc-toc strong { width: 100%; }
}

.mount-line { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-bottom: 4px; font-size: 12.5px; }
.mount-line:last-child { margin-bottom: 0; }
.mount-line .tag { white-space: nowrap; }

/* Visualiseur de fichiers, recherche, galerie, comparaison ------------------------------------ */

.search-box { position: relative; display: flex; align-items: center; min-width: min(360px, 100%); }
.search-box .icon { position: absolute; left: 11px; color: var(--muted); pointer-events: none; }
.search-box .input { padding-left: 34px; }
.search-box.big .input { height: 42px; font-size: 15px; }
.search-card { display: grid; gap: 12px; margin-bottom: 20px; }
.search-card .hint { font-size: 12.5px; }
.zone { margin-left: 8px; font-size: 12.5px; }
.seg-link { color: var(--muted); font-size: 12px; font-weight: 550; padding: 3px 10px; border-radius: 6px; display: inline-flex; gap: 5px; align-items: center; }
.seg-link .icon { width: 13px; height: 13px; }
.seg-link[aria-pressed="true"] { background: var(--surface); color: var(--text); box-shadow: var(--shadow); }
.file-title { word-break: break-all; }

.gallery-folders { display: flex; gap: 6px; flex-wrap: wrap; padding: 0 20px 14px; }
.gallery { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 12px; padding: 0 20px 20px; }
.thumb { display: flex; flex-direction: column; gap: 6px; color: var(--text-2); font-size: 12px; min-width: 0; }
.thumb img { width: 100%; aspect-ratio: 1; object-fit: cover; border-radius: var(--radius-sm); background: var(--surface-3); border: 1px solid var(--border); transition: transform 0.15s; }
.thumb:hover img { transform: scale(1.02); border-color: var(--accent); }
.thumb span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pager { display: flex; justify-content: center; align-items: center; gap: 12px; padding: 0 20px 20px; }

.viewer-layout { grid-template-columns: minmax(0, 2.2fr) minmax(280px, 1fr); }
.viewer { overflow: hidden; }
.viewer-note { display: flex; gap: 8px; align-items: center; padding: 10px 16px; background: var(--warning-soft); font-size: 13px; }
.viewer-foot { padding: 10px 16px; font-size: 12.5px; border-top: 1px solid var(--border); }
.code-view { display: flex; max-height: 75vh; overflow: auto; background: var(--code-bg); font: 12.5px/1.6 var(--mono); }
.code-view pre { margin: 0; padding: 14px 0; }
.code-view .gutter { position: sticky; left: 0; padding: 14px 12px 14px 16px; text-align: right; color: var(--muted); background: var(--code-bg); border-right: 1px solid var(--border); user-select: none; min-width: 52px; }
.code-view .code { padding-left: 16px; padding-right: 20px; flex: 1; }
.code-view code { font: inherit; white-space: pre; color: var(--code-text); background: none; border: 0; padding: 0; }

.image-stage { position: relative; display: grid; place-items: center; min-height: 360px; max-height: 78vh; overflow: auto; padding: 16px;
  background: repeating-conic-gradient(var(--surface-2) 0 25%, var(--surface) 0 50%) 0 0 / 20px 20px; }
.image-stage img { max-width: 100%; max-height: calc(78vh - 32px); object-fit: contain; cursor: zoom-in; border-radius: 4px; box-shadow: var(--shadow); }
.image-stage.zoomed { place-items: start; }
.image-stage.zoomed img { max-width: none; max-height: none; cursor: zoom-out; }
.nav-arrow { position: absolute; top: 50%; transform: translateY(-50%); z-index: 2; width: 42px; height: 42px; border-radius: 50%;
  display: grid; place-items: center; background: color-mix(in srgb, var(--surface) 85%, transparent); color: var(--text); box-shadow: var(--shadow-pop); }
.nav-arrow:hover { background: var(--surface); color: var(--accent); }
.nav-arrow.prev { left: 14px; }
.nav-arrow.next { right: 14px; }
.pdf-frame { display: block; width: 100%; height: 78vh; border: 0; background: var(--surface-2); }

.versions td { font-size: 13px; }
.versions tr.current td { background: var(--accent-soft); }

.diff-legend { padding: 1px 8px; border-radius: 6px; font-size: 12.5px; font-weight: 600; }
.diff-legend.del { background: var(--critical-soft); }
.diff-legend.add { background: var(--good-soft); }
.diff-wrap { overflow: auto; max-height: 78vh; }
.diff { font: 12.5px/1.55 var(--mono); border-collapse: collapse; width: 100%; }
.diff td { padding: 0 10px; border: 0; vertical-align: top; }
.diff .no { width: 1%; text-align: right; color: var(--muted); user-select: none; white-space: nowrap; }
.diff .sign { width: 1%; user-select: none; color: var(--muted); }
.diff .text { white-space: pre-wrap; word-break: break-all; }
.diff tr.add td { background: var(--good-soft); }
.diff tr.del td { background: var(--critical-soft); }
.diff tr.add .sign { color: var(--good); }
.diff tr.del .sign { color: var(--critical); }
.diff tr.gap td { background: var(--surface-2); color: var(--muted); text-align: center; padding: 3px; font-family: inherit; }
.diff tbody tr:hover td { background: inherit; }

/* Coloration syntaxique (highlight.js), couleurs selon le theme */
:root { --code-bg: #f7f8fa; --code-text: #24292f; --hl-keyword: #cf222e; --hl-string: #0a3069; --hl-number: #0550ae;
  --hl-comment: #6e7781; --hl-title: #8250df; --hl-attr: #116329; --hl-meta: #953800; }
:root[data-theme="dark"] { --code-bg: #0f131a; --code-text: #d7dde8; --hl-keyword: #ff7b72; --hl-string: #a5d6ff; --hl-number: #79c0ff;
  --hl-comment: #8b949e; --hl-title: #d2a8ff; --hl-attr: #7ee787; --hl-meta: #ffa657; }
@media (prefers-color-scheme: dark) {
  :root:where(:not([data-theme="light"])) { --code-bg: #0f131a; --code-text: #d7dde8; --hl-keyword: #ff7b72; --hl-string: #a5d6ff;
    --hl-number: #79c0ff; --hl-comment: #8b949e; --hl-title: #d2a8ff; --hl-attr: #7ee787; --hl-meta: #ffa657; }
}
.hljs-keyword, .hljs-selector-tag, .hljs-built_in, .hljs-type, .hljs-literal { color: var(--hl-keyword); }
.hljs-string, .hljs-regexp, .hljs-template-tag, .hljs-addition { color: var(--hl-string); }
.hljs-number, .hljs-symbol, .hljs-bullet, .hljs-variable, .hljs-template-variable { color: var(--hl-number); }
.hljs-comment, .hljs-quote, .hljs-deletion { color: var(--hl-comment); font-style: italic; }
.hljs-title, .hljs-section, .hljs-function .hljs-title, .hljs-title.class_ { color: var(--hl-title); }
.hljs-attr, .hljs-attribute, .hljs-name, .hljs-selector-class, .hljs-selector-id, .hljs-tag { color: var(--hl-attr); }
.hljs-meta, .hljs-params, .hljs-property { color: var(--hl-meta); }

@media (max-width: 1100px) { .viewer-layout { grid-template-columns: minmax(0, 1fr); } }

[data-restore-card] .hint.mono { word-break: break-all; }

/* Comptes et double authentification ----------------------------------------------------- */

fieldset.plain { border: 0; padding: 0; margin: 0; min-width: 0; }
.side-account { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: var(--radius-sm); color: var(--text); text-decoration: none; }
.side-account:hover, .side-account.active { background: var(--surface-2); }
.side-account .avatar { width: 28px; height: 28px; border-radius: 50%; display: grid; place-items: center; flex: none;
                        background: var(--accent-soft); color: var(--accent-ink); font-weight: 650; font-size: 13px; }
.side-account .who { display: flex; flex-direction: column; min-width: 0; line-height: 1.25; }
.side-account .name { font-weight: 550; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.side-account small { color: var(--muted); font-size: 11.5px; }
.side-account .ext { color: var(--accent-ink); }
.code-input { font-size: 20px; letter-spacing: 0.18em; text-align: center; height: 44px; }
.totp-setup { max-width: 640px; }
.totp-setup .steps > li + li { padding-top: 20px; border-top: 1px solid var(--border); }
.totp-setup h3 { margin-bottom: 14px; }
.totp-setup .qr { background: #fff; border-radius: var(--radius-sm); padding: 8px; display: inline-block; line-height: 0; border: 1px solid var(--border); }
.totp-setup .qr svg { width: 200px; height: 200px; }
.totp-setup .secret { display: inline-block; margin: 0; font-size: 13px; letter-spacing: 0.06em; word-break: break-all; background: var(--surface-2); padding: 8px 10px; border-radius: var(--radius-sm); }
.recovery-codes { list-style: none; margin: 0; padding: 14px; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px 24px;
                  background: var(--surface-2); border-radius: var(--radius-sm); font-size: 15px; letter-spacing: 0.04em; }
.warning-text { color: var(--text); background: var(--warning-soft); padding: 8px 10px; border-radius: var(--radius-sm); font-size: 13px; margin-top: 12px; }
.inline-form { display: inline; }
.inline-form select { height: 30px; min-width: 150px; }
.row-menu { display: inline-block; text-align: left; }
.row-menu > summary { list-style: none; }
.row-menu > summary::-webkit-details-marker { display: none; }
/* Deplie dans la ligne : un menu flottant serait coupe par le defilement horizontal du tableau. */
.row-menu-body { width: 290px; margin-top: 8px; padding: 12px; display: flex; flex-direction: column; gap: 10px;
                 background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius-sm); }
.row-menu-body form > .btn { justify-content: flex-start; width: 100%; }
.btn.danger.ghost, .btn.ghost.danger { color: var(--critical); }
.roles dt { font-weight: 600; margin-top: 12px; }
.roles dt:first-child { margin-top: 0; }
.roles dd { margin: 4px 0 0; color: var(--text-2); font-size: 13px; }
.event.bad { color: var(--critical); font-weight: 550; }
tr.muted td { opacity: 0.6; }
