/* Server Dashboard — thème sombre par défaut, clair si le système le demande. */
:root {
  --bg: #0c0e12;
  --surface: #14171c;
  --surface-2: #1a1e25;
  --surface-3: #222730;
  --border: #252a33;
  --border-strong: #333a45;
  --text: #e7e9ee;
  --text-2: #b4bac6;
  --muted: #7d8594;
  --accent: #5eead4;
  --accent-ink: #062a26;
  --accent-soft: rgba(94, 234, 212, 0.12);
  --ok: #3fb950;
  --warn: #e3a008;
  --error: #f47067;
  --info: #6cb6ff;
  --ok-soft: rgba(63, 185, 80, 0.14);
  --warn-soft: rgba(227, 160, 8, 0.14);
  --error-soft: rgba(244, 112, 103, 0.14);
  --info-soft: rgba(108, 182, 255, 0.14);
  --radius: 12px;
  --radius-sm: 8px;
  --shadow: 0 10px 30px rgba(0, 0, 0, 0.35);
  --mono: ui-monospace, 'SF Mono', 'Cascadia Code', Menlo, Consolas, monospace;
  --sans: system-ui, -apple-system, 'Segoe UI', Roboto, 'Helvetica Neue', sans-serif;
}

@media (prefers-color-scheme: light) {
  :root {
    --bg: #f4f5f7;
    --surface: #ffffff;
    --surface-2: #f7f8fa;
    --surface-3: #eef0f3;
    --border: #e2e5ea;
    --border-strong: #cfd4db;
    --text: #1a1d23;
    --text-2: #3d4450;
    --muted: #6a7280;
    --accent: #0f766e;
    --accent-ink: #ffffff;
    --accent-soft: rgba(15, 118, 110, 0.1);
    --ok: #1a7f37;
    --warn: #9a6700;
    --error: #cf222e;
    --info: #0969da;
    --ok-soft: rgba(26, 127, 55, 0.1);
    --warn-soft: rgba(154, 103, 0, 0.1);
    --error-soft: rgba(207, 34, 46, 0.09);
    --info-soft: rgba(9, 105, 218, 0.09);
    --shadow: 0 10px 30px rgba(20, 24, 31, 0.12);
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 14px/1.45 var(--sans);
  -webkit-font-smoothing: antialiased;
}
a { color: inherit; }
button, input, select, textarea { font: inherit; color: inherit; }
[hidden] { display: none !important; }
.mono { font-family: var(--mono); font-size: 0.92em; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.spacer { flex: 1; }
.num { font-variant-numeric: tabular-nums; text-align: right; white-space: nowrap; }
.i { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; flex: none; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.container { max-width: 1440px; margin: 0 auto; padding: 20px 20px 64px; }

/* ---------- barre du haut ---------- */
.topbar {
  position: sticky; top: 0; z-index: 20;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border);
}
.topbar-inner {
  max-width: 1440px; margin: 0 auto; padding: 12px 20px 8px;
  display: flex; align-items: center; gap: 16px; flex-wrap: wrap;
}
.brand { display: flex; align-items: center; gap: 10px; font-weight: 650; font-size: 15px; text-decoration: none; letter-spacing: 0.01em; }
.brand-mark {
  width: 22px; height: 22px; border-radius: 6px; flex: none;
  background:
    linear-gradient(var(--accent), var(--accent)) 3px 3px / 7px 7px no-repeat,
    linear-gradient(color-mix(in srgb, var(--accent) 55%, transparent), color-mix(in srgb, var(--accent) 55%, transparent)) 12px 3px / 7px 7px no-repeat,
    linear-gradient(color-mix(in srgb, var(--accent) 55%, transparent), color-mix(in srgb, var(--accent) 55%, transparent)) 3px 12px / 7px 7px no-repeat,
    linear-gradient(color-mix(in srgb, var(--accent) 28%, transparent), color-mix(in srgb, var(--accent) 28%, transparent)) 12px 12px / 7px 7px no-repeat,
    var(--surface-3);
}
.search {
  display: flex; align-items: center; gap: 8px;
  flex: 1 1 220px; max-width: 380px; min-width: 0;
  background: var(--surface); border: 1px solid var(--border); border-radius: 999px;
  padding: 6px 10px 6px 12px; color: var(--muted);
}
.search:focus-within { border-color: var(--accent); }
.search input[type=search] { flex: 1; min-width: 0; height: 22px; padding: 0; border: 0; background: none; outline: none; box-shadow: none; color: var(--text); }
.search input::-webkit-search-cancel-button { display: none; }
kbd { font: 11px var(--mono); border: 1px solid var(--border-strong); border-radius: 4px; padding: 0 5px; color: var(--muted); }

.meters { display: flex; gap: 14px; margin-left: auto; flex-wrap: wrap; }
.meter { display: grid; grid-template-columns: auto auto; column-gap: 8px; align-items: baseline; min-width: 74px; }
.meter-label { font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.06em; }
.meter-value { font-variant-numeric: tabular-nums; font-weight: 600; text-align: right; }
.meter-bar { grid-column: 1 / -1; height: 3px; margin-top: 4px; background: var(--surface-3); border-radius: 2px; overflow: hidden; }
.meter-bar span { display: block; height: 100%; background: var(--ok); border-radius: 2px; transition: width 0.4s; }
.meter-bar.warn span { background: var(--warn); }
.meter-bar.error span { background: var(--error); }
.meter.uptime .meter-value { font-weight: 500; color: var(--text-2); }
.topbar-actions { display: flex; align-items: center; gap: 4px; }

.tabs { max-width: 1440px; margin: 0 auto; padding: 0 20px; display: flex; gap: 4px; }
.tabs a {
  text-decoration: none; color: var(--muted); padding: 8px 12px 10px; font-weight: 550;
  border-bottom: 2px solid transparent; display: inline-flex; align-items: center; gap: 6px;
}
.tabs a:hover { color: var(--text); }
.tabs a.active { color: var(--text); border-bottom-color: var(--accent); }
.badge { font-size: 11px; font-weight: 700; min-width: 18px; height: 18px; padding: 0 5px; border-radius: 9px; display: inline-grid; place-items: center; }
.badge.error { background: var(--error-soft); color: var(--error); }
.badge.info { background: var(--info-soft); color: var(--info); }

/* ---------- boutons ---------- */
.btn {
  display: inline-flex; align-items: center; gap: 6px; justify-content: center;
  height: 34px; padding: 0 14px; border-radius: var(--radius-sm);
  border: 1px solid var(--border-strong); background: var(--surface-2); color: var(--text);
  font-weight: 550; cursor: pointer; white-space: nowrap; text-decoration: none;
}
.btn:hover { background: var(--surface-3); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn.small { height: 28px; padding: 0 10px; font-size: 13px; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.primary:hover { filter: brightness(1.08); }
.btn.danger { background: var(--error); border-color: var(--error); color: #fff; }
.btn.ghost { background: none; border-color: transparent; }
.btn.danger.ghost { color: var(--error); background: none; border-color: transparent; }
.btn.ghost:hover { background: var(--surface-3); }
.btn.block { width: 100%; }
.icon-btn {
  display: inline-grid; place-items: center; width: 32px; height: 32px; flex: none;
  border: 0; border-radius: var(--radius-sm); background: none; color: var(--muted); cursor: pointer;
}
.icon-btn:hover { background: var(--surface-3); color: var(--text); }
.icon-btn:disabled { opacity: 0.4; cursor: not-allowed; }
.spin .i { animation: spin 0.8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- pastilles ---------- */
.dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; flex: none; background: var(--muted); }
.dot.ok { background: var(--ok); box-shadow: 0 0 0 3px var(--ok-soft); }
.dot.warn { background: var(--warn); box-shadow: 0 0 0 3px var(--warn-soft); }
.dot.error { background: var(--error); box-shadow: 0 0 0 3px var(--error-soft); }
.dot.info { background: var(--info); }
.dot.muted { background: var(--border-strong); }
.pill {
  display: inline-flex; align-items: center; gap: 5px; height: 22px; padding: 0 8px;
  border-radius: 999px; font-size: 12px; font-weight: 550; white-space: nowrap;
  background: var(--surface-3); color: var(--text-2);
}
.pill .i { width: 13px; height: 13px; }
.pill.ok { background: var(--ok-soft); color: var(--ok); }
.pill.warn { background: var(--warn-soft); color: var(--warn); }
.pill.error { background: var(--error-soft); color: var(--error); }
.pill.info { background: var(--info-soft); color: var(--info); }
.pill.muted { background: var(--surface-3); color: var(--muted); }
.chip {
  display: inline-flex; align-items: center; height: 24px; padding: 0 9px; border-radius: 6px;
  border: 1px solid var(--border-strong); font-size: 12px; font-weight: 550; text-decoration: none; color: var(--text-2);
}
a.chip:hover { border-color: var(--accent); color: var(--text); }
.chip.soft { border: 0; background: var(--surface-3); height: 22px; }

/* ---------- sections ---------- */
.section { margin-bottom: 32px; }
.section-head { display: flex; align-items: center; gap: 12px; margin-bottom: 12px; }
.section-head h2, .unlisted summary h2 {
  margin: 0; font-size: 13px; font-weight: 650; text-transform: uppercase; letter-spacing: 0.07em; color: var(--text-2);
  display: flex; align-items: center; gap: 10px;
}
.count { font-size: 12px; font-weight: 550; color: var(--muted); text-transform: none; letter-spacing: 0; }
.empty { color: var(--muted); padding: 24px 0; }

/* ---------- cartes d'application ---------- */
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 320px), 1fr)); gap: 14px; }
.card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 14px 14px 12px; display: flex; flex-direction: column; gap: 10px; min-width: 0;
  transition: border-color 0.15s;
}
.card:hover { border-color: var(--border-strong); }
.card.s-down { border-left: 3px solid var(--error); }
.card.s-warn { border-left: 3px solid var(--warn); }
.card-head { display: flex; align-items: center; gap: 10px; min-width: 0; }
.card-icon {
  width: 38px; height: 38px; border-radius: 10px; display: grid; place-items: center; flex: none;
  background: var(--surface-3); font-size: 20px;
}
.card-title { display: flex; flex-direction: column; min-width: 0; flex: 1; }
.card-name { font-weight: 650; font-size: 15px; text-decoration: none; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
a.card-name:hover { color: var(--accent); }
.card-host { font-size: 12px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.card-desc { margin: 0; color: var(--text-2); font-size: 13px; }
.card-foot { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; margin-top: auto; padding-top: 2px; }
.status {
  display: inline-flex; align-items: center; gap: 6px; font-size: 12px; font-variant-numeric: tabular-nums;
  color: var(--muted); white-space: nowrap; flex: none;
}
.status.down { color: var(--error); }
.status.warn { color: var(--warn); }

/* ---------- widgets ---------- */
.widget { background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 10px; display: grid; gap: 10px; }
.widget.loading { gap: 6px; }
.skeleton { display: block; height: 10px; border-radius: 4px; background: var(--surface-3); animation: pulse 1.4s ease-in-out infinite; }
.skeleton.short { width: 60%; }
@keyframes pulse { 50% { opacity: 0.5; } }
.w-stats { margin: 0; display: grid; grid-template-columns: repeat(auto-fit, minmax(118px, 1fr)); gap: 8px 12px; }
.w-stat dt { font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.05em; }
.w-stat dd { margin: 1px 0 0; font-weight: 600; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
.w-stat.ok dd { color: var(--ok); }
.w-stat.warn dd { color: var(--warn); }
.w-stat.error dd { color: var(--error); }
.w-stat.muted dd { color: var(--muted); font-weight: 500; }
.w-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.w-list li { display: flex; align-items: center; gap: 9px; min-width: 0; }
.w-list-title { font-weight: 550; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.w-list-meta { margin-left: auto; color: var(--muted); font-size: 12px; white-space: nowrap; }
.w-media { display: flex; gap: 12px; align-items: center; min-width: 0; }
.w-media img { width: 46px; height: 64px; object-fit: cover; border-radius: 6px; flex: none; background: var(--surface-3); }
.w-media-body { display: flex; flex-direction: column; min-width: 0; flex: 1; gap: 1px; }
.w-media-body strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.w-media-sub { font-size: 13px; color: var(--text-2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.w-media-meta { font-size: 12px; color: var(--muted); }
.w-media.ok .w-media-meta { color: var(--ok); }
.w-media .bar { margin-top: 6px; }
.bar { height: 4px; border-radius: 2px; background: var(--surface-3); overflow: hidden; }
.bar span { display: block; height: 100%; background: var(--accent); border-radius: 2px; }
.bar.ok span { background: var(--ok); }
.bar.warn span { background: var(--warn); }
.bar.error span { background: var(--error); }
.w-progress-head { display: flex; justify-content: space-between; font-size: 12px; margin-bottom: 5px; color: var(--text-2); }
.w-text { margin: 0; font-size: 13px; }
.w-text.muted { color: var(--muted); }
.w-text.warn { color: var(--warn); }
.w-text.error { color: var(--error); }
.w-text.ok { color: var(--ok); }
a.plain { text-decoration: none; }
a.plain:hover { text-decoration: underline; }

/* ---------- liens externes ---------- */
.links { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 220px), 1fr)); gap: 10px; }
.link { position: relative; }
.link > a {
  display: flex; align-items: center; gap: 10px; padding: 10px 40px 10px 12px; text-decoration: none;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-sm);
}
.link > a:hover { border-color: var(--accent); }
.link-icon { font-size: 18px; width: 30px; height: 30px; border-radius: 8px; }
.link-icon.has-logo { padding: 4px; background: var(--surface-3); }

/* ---------- logos ---------- */
.logo-box { display: inline-grid; place-items: center; flex: none; overflow: hidden; line-height: 1; }
.logo-box img { width: 100%; height: 100%; object-fit: contain; display: block; }
.card-icon.has-logo { padding: 7px; }
.logo-box.logo-full { padding: 0; }
.logo-box.logo-full img { object-fit: cover; }
.logo-box.logo-on-light { background: #f4f5f7; } /* logo sombre sans fond */
.logo-box.logo-on-dark { background: #1f242c; } /* logo clair sans fond */
.chip-icon { width: 16px; height: 16px; border-radius: 4px; font-size: 12px; margin-right: 6px; }
.logo-preview { width: 56px; height: 56px; border-radius: 14px; background: var(--surface-3); font-size: 28px; }
.logo-preview.has-logo { padding: 8px; }
.logo-field { display: flex; gap: 12px; align-items: flex-start; }
.logo-field-controls { display: grid; gap: 6px; flex: 1; min-width: 0; }
.logo-field-row { display: flex; gap: 8px; }
.logo-field-row select { flex: 1; min-width: 0; }
.logo-field-row .btn { height: 36px; }
.link-body { display: flex; flex-direction: column; min-width: 0; }
.link-name { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.link-host { font-size: 12px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.link-edit { position: absolute; right: 4px; top: 50%; transform: translateY(-50%); opacity: 0; }
.link:hover .link-edit, .link-edit:focus-visible { opacity: 1; }
@media (hover: none) { .link-edit { opacity: 1; } }

/* ---------- sections ---------- */
.home-toolbar { display: flex; align-items: center; gap: 12px; margin: -4px 0 14px; min-height: 28px; }
.tone-error { color: var(--error); }
.section-toggle {
  display: inline-flex; align-items: center; gap: 6px; padding: 2px 6px 2px 2px; margin-left: -2px;
  border: 0; border-radius: 6px; background: none; cursor: pointer;
  font: inherit; color: inherit; text-transform: inherit; letter-spacing: inherit;
}
.section-toggle:hover { background: var(--surface-3); }
.section-toggle .chevron { width: 14px; height: 14px; color: var(--muted); }
.section.collapsed { margin-bottom: 14px; }
.section-head .open-all { margin-left: auto; color: var(--text-2); }
.section-head .open-all:hover { color: var(--text); }
.popup-help { display: grid; gap: 12px; }
.popup-help p, .popup-help ol { margin: 0; color: var(--text-2); }
.popup-help ol { padding-left: 20px; display: grid; gap: 6px; }
.popup-help-links { display: flex; flex-wrap: wrap; gap: 8px; }
.popup-help-links .chip { height: 32px; padding: 0 12px; }
.popup-help-links .chip.done { opacity: 0.5; }
.section-body { display: grid; gap: 12px; }

/* ---------- mode organisation ---------- */
.edit-banner {
  position: sticky; top: calc(var(--topbar-h, 96px) + 8px); z-index: 10;
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  margin-bottom: 18px; padding: 10px 12px 10px 14px;
  background: color-mix(in srgb, var(--accent) 12%, var(--surface)); border: 1px solid color-mix(in srgb, var(--accent) 45%, transparent);
  border-radius: var(--radius); box-shadow: var(--shadow);
}
.edit-banner > .i { color: var(--accent); }
.edit-banner .i { vertical-align: -3px; }
.editing .section {
  border: 1px dashed var(--border-strong); border-radius: var(--radius);
  padding: 10px 12px 14px; margin-bottom: 16px; background: color-mix(in srgb, var(--surface) 40%, transparent);
}
.section-head.editing { gap: 6px; flex-wrap: wrap; margin-bottom: 10px; }
.section-grip {
  display: inline-grid; place-items: center; width: 28px; height: 32px; flex: none;
  border-radius: 6px; color: var(--muted); cursor: grab; touch-action: none;
}
.section-grip:hover { background: var(--surface-3); color: var(--text); }
.section-grip .i { width: 18px; height: 18px; }
.section-head input.section-name { flex: 0 1 320px; width: auto; min-width: 140px; height: 32px; font-weight: 650; font-size: 15px; background: var(--surface); }
.editing .card, .editing .link { cursor: grab; user-select: none; -webkit-user-select: none; }
/* En organisation, rien à l'intérieur des éléments n'est cliquable : tout le bloc se saisit. */
.editing .card *, .editing .link * { pointer-events: none; }
.editing .card-head .icon-btn, .editing .link-edit { visibility: hidden; }
.editing .cards:empty, .editing .links:empty {
  min-height: 58px; display: grid; place-items: center;
  border: 1px dashed var(--border-strong); border-radius: var(--radius-sm); color: var(--muted); font-size: 12px;
}
.editing .cards:empty::before { content: 'Déposez des applications ici'; }
.editing .links:empty::before { content: 'Déposez des liens ici'; }
.sorting-sections .section-body, .sortable-fallback .section-body { display: none; }
.sorting-sections .section { margin-bottom: 8px; padding-bottom: 2px; }
.sorting-sections .section-head { margin-bottom: 0; }
.drag-ghost { opacity: 0.35; outline: 2px dashed var(--accent); outline-offset: -2px; }
.drag-chosen { box-shadow: var(--shadow); }
.sortable-fallback { opacity: 0.92 !important; box-shadow: var(--shadow); background: var(--surface-2); }
body.dragging, body.dragging * { cursor: grabbing !important; }

/* ---------- à ranger ---------- */
.unlisted { background: var(--surface); border: 1px dashed var(--border-strong); border-radius: var(--radius); padding: 12px 14px; }
.unlisted summary { cursor: pointer; display: flex; align-items: center; gap: 12px; flex-wrap: wrap; list-style: none; }
.unlisted summary::-webkit-details-marker { display: none; }
.unlisted-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 420px), 1fr)); gap: 20px; margin-top: 14px; }
.unlisted h3 { display: flex; align-items: center; gap: 6px; font-size: 13px; margin: 0 0 8px; color: var(--text-2); }
.plain-list { list-style: none; margin: 0; padding: 0; }
.plain-list li { display: flex; align-items: center; gap: 8px; padding: 6px 0; border-top: 1px solid var(--border); flex-wrap: wrap; }
.plain-list li:first-child { border-top: 0; }
.plain-list a { text-decoration: none; }
.plain-list a:hover { color: var(--accent); }

/* ---------- Docker ---------- */
.toolbar { display: flex; align-items: center; gap: 14px; margin-bottom: 16px; flex-wrap: wrap; }
.seg { display: inline-flex; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 2px; }
.seg-btn { border: 0; background: none; padding: 4px 12px; border-radius: 6px; cursor: pointer; color: var(--muted); font-weight: 550; }
.seg-btn.active { background: var(--surface-3); color: var(--text); }
.project { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); margin-bottom: 12px; overflow: hidden; }
.project-head { display: flex; align-items: center; gap: 12px; padding: 10px 12px 10px 14px; flex-wrap: wrap; }
.project-title { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; flex: 1; min-width: 200px; }
.project-actions { display: flex; gap: 6px; flex-wrap: wrap; }
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th { text-align: left; font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.05em; color: var(--muted); padding: 6px 10px; background: var(--surface-2); white-space: nowrap; }
td { padding: 7px 10px; border-top: 1px solid var(--border); vertical-align: middle; }
.containers td:first-child, .containers th:first-child { width: 28px; padding-left: 16px; }
.c-name { font-weight: 550; }
.c-image { max-width: 220px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.c-ports { max-width: 200px; }
.row-actions { display: flex; justify-content: flex-end; gap: 2px; }
.row-actions .icon-btn { width: 28px; height: 28px; }
.health { margin-left: 6px; font-size: 11px; padding: 1px 6px; border-radius: 4px; background: var(--surface-3); }
.health.healthy { color: var(--ok); background: var(--ok-soft); }
.health.unhealthy { color: var(--error); background: var(--error-soft); }
.jobs { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); }
.jobs td:last-child { text-align: right; }

/* ---------- alertes, toasts ---------- */
.alert { padding: 10px 14px; border-radius: var(--radius-sm); }
.alert.error { background: var(--error-soft); color: var(--error); }
.alert.warn { background: var(--warn-soft); color: var(--warn); }
.alert.banner { border-radius: 0; text-align: center; }
#toasts { position: fixed; right: 16px; bottom: 16px; display: grid; gap: 8px; z-index: 100; max-width: min(420px, calc(100vw - 32px)); }
.toast {
  padding: 10px 14px; border-radius: var(--radius-sm); background: var(--surface-3); color: var(--text);
  border-left: 3px solid var(--info); box-shadow: var(--shadow); transition: opacity 0.3s, transform 0.3s;
}
.toast.ok { border-left-color: var(--ok); }
.toast.error { border-left-color: var(--error); }
.toast.out { opacity: 0; transform: translateY(6px); }

/* ---------- menus ---------- */
.menu {
  position: fixed; z-index: 60; min-width: 220px; max-width: 320px; max-height: 70vh; overflow-y: auto; overscroll-behavior: contain;
  background: var(--surface-2); border: 1px solid var(--border-strong); border-radius: var(--radius-sm);
  box-shadow: var(--shadow); padding: 4px;
}
.menu-item {
  display: flex; align-items: center; gap: 10px; width: 100%; text-align: left;
  border: 0; background: none; padding: 7px 10px; border-radius: 6px; cursor: pointer;
}
.menu-item span:last-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.menu-item:hover:not(:disabled), .menu-item:focus-visible { background: var(--surface-3); outline: none; }
.menu-item:disabled { opacity: 0.4; cursor: not-allowed; }
.menu-item.danger { color: var(--error); }
.menu-item .i { color: var(--muted); }
.menu-item.danger .i { color: var(--error); }
.menu-sep { height: 1px; background: var(--border); margin: 4px 2px; }
.menu-heading { font-size: 11px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: 0.05em; padding: 6px 10px 2px; }

/* ---------- modales & formulaires ---------- */
.modal {
  width: min(560px, calc(100vw - 24px)); max-height: calc(100vh - 40px); padding: 0;
  border: 1px solid var(--border-strong); border-radius: var(--radius); background: var(--surface); color: var(--text);
  box-shadow: var(--shadow); display: flex; flex-direction: column;
}
.modal:not([open]) { display: none; }
.modal.wide { width: min(980px, calc(100vw - 24px)); }
.modal::backdrop { background: rgba(5, 7, 10, 0.6); backdrop-filter: blur(2px); }
.modal-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 12px 12px 18px; border-bottom: 1px solid var(--border); }
.modal-head h2 { margin: 0; font-size: 16px; }
.modal-body { padding: 16px 18px 18px; overflow-y: auto; }
.form { display: grid; gap: 14px; }
.field { display: grid; gap: 5px; min-width: 0; align-content: start; }
.field label { font-size: 12px; font-weight: 600; color: var(--text-2); }
.help { color: var(--muted); font-size: 12px; margin: 0; }
input:not([type=checkbox]), select, textarea {
  width: 100%; min-width: 0; height: 36px; padding: 0 10px; border-radius: var(--radius-sm);
  border: 1px solid var(--border-strong); background: var(--surface-2); color: var(--text);
}
textarea { height: auto; padding: 8px 10px; resize: vertical; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.icon-input { text-align: center; font-size: 18px; }
.name-row { display: grid; grid-template-columns: 64px 1fr; gap: 10px; }
.grid-2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 260px), 1fr)); gap: 12px; }
.grid-3 { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 180px), 1fr)); gap: 12px; }
fieldset { border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 12px; margin: 0; display: grid; gap: 10px; min-width: 0; }
fieldset > .btn { justify-self: start; }
legend { font-size: 12px; font-weight: 650; color: var(--text-2); padding: 0 6px; }
.rows { display: grid; gap: 8px; }
.rows:empty { display: none; }
.row { display: grid; grid-template-columns: minmax(90px, 1fr) 2fr auto; gap: 8px; }
details.more { border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 10px 12px; }
details.more > summary { cursor: pointer; font-size: 13px; font-weight: 600; color: var(--text-2); }
details.more[open] > summary { margin-bottom: 12px; }
details.more .grid-2 + .grid-2 { margin-top: 12px; }
.widget-options { display: grid; gap: 10px; }
.widget-preview:empty { display: none; }
.widget-preview { display: grid; gap: 6px; }
.form-actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.confirm p { margin: 0 0 18px; color: var(--text-2); }
.check { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; color: var(--text-2); cursor: pointer; }
.settings { display: grid; gap: 22px; }
.settings h3 { margin: 0; font-size: 14px; }
.user-list { list-style: none; padding: 0; margin: 0; }
.user-list li { display: flex; align-items: center; justify-content: space-between; padding: 6px 0; border-top: 1px solid var(--border); }
.user-list li:first-child { border-top: 0; }

/* ---------- console ---------- */
.console-wrap { display: grid; gap: 8px; }
.console-bar { display: flex; align-items: center; justify-content: space-between; }
.console-status { font-size: 12px; font-weight: 600; }
.console-status.running { color: var(--info); }
.console-status.done { color: var(--ok); }
.console-status.error { color: var(--error); }
.console {
  margin: 0; height: min(62vh, 640px); overflow: auto; padding: 12px 14px; border-radius: var(--radius-sm);
  background: #07090c; color: #c9d1d9; font: 12px/1.5 var(--mono); white-space: pre-wrap; word-break: break-word;
  border: 1px solid var(--border);
}
.console .err { color: #ff8a80; }
.console .cmd { color: #5eead4; }

/* ---------- connexion ---------- */
.login-page { min-height: 100vh; display: grid; place-items: center; padding: 20px; }
.login {
  width: min(360px, 100%); background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 28px 24px; display: grid; gap: 22px; box-shadow: var(--shadow);
}
.login .brand { justify-content: center; }

/* ---------- mobile ---------- */
@media (max-width: 720px) {
  .container { padding: 14px 14px 48px; }
  .topbar-inner { padding: 10px 14px 6px; gap: 10px; }
  .search { order: 3; max-width: none; flex-basis: 100%; }
  .meters { order: 4; margin-left: 0; width: 100%; justify-content: space-between; gap: 10px; }
  .meter { min-width: 0; }
  .topbar-actions { margin-left: auto; }
  .tabs { padding: 0 8px; }
  .search kbd { display: none; }
  .section-head input.section-name { flex: 1 1 140px; }
  .row { grid-template-columns: 1fr auto; }
  .row input[type=url] { grid-column: 1; }
}
