/* =====================================================================
   NSync — feuille de style refondue (direction "Atelier")
   Rail latéral sombre constant, contenu clair ou sombre au choix,
   accent vert olive. Aucun nom de classe ou d'id n'a été renommé :
   ce fichier remplace static/style.css tel quel.
   Voir NOTES.md pour les 3 ajouts HTML/JS (police, thème, bascule).
   ===================================================================== */



:root {
  --bg: #f6f5f2;
  --card: #ffffff;
  --card-alt: #fbfaf7;
  --border: #e3e0d9;
  --border-strong: #d3cfc5;
  --input-bg: #f2f0ea;
  --text: #1a1a18;
  --muted: #6d6b64;
  --accent: #5f7d3a;
  --accent-fill: #7c8f4e;
  --accent-soft: #eef2e4;
  --ok: #4d6b2e;
  --ok-soft: #eef2e4;
  --fail: #b23e30;
  --fail-soft: #f8ecea;
  --running: #8a5a12;
  --running-soft: #f6efdf;

  /* Le rail reste sombre dans les deux thèmes — c'est la signature. */
  --sidebar-bg: #1f2320;
  --sidebar-text: #e8e7e2;
  --sidebar-muted: #8b8f86;
  --sidebar-border: #2f342f;
  --sidebar-hover: #2c312c;

  --radius: 10px;
  --radius-lg: 14px;
  --shadow-sm: 0 1px 2px rgba(26, 26, 24, 0.04);
  --shadow-md: 0 6px 20px rgba(26, 26, 24, 0.08);
  --shadow-lg: 0 24px 60px rgba(26, 26, 24, 0.22);

  --font: "Instrument Sans", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --mono: "IBM Plex Mono", "SF Mono", Menlo, monospace;
}

html[data-theme="dark"] {
  --bg: #161815;
  --card: #1d201c;
  --card-alt: #212420;
  --border: #2e322c;
  --border-strong: #3c413a;
  --input-bg: #23261f;
  --text: #e9e8e3;
  --muted: #9a9a91;
  --accent: #9ab063;
  --accent-fill: #7c8f4e;
  --accent-soft: #262b1f;
  --ok: #9ab063;
  --ok-soft: #232a1c;
  --fail: #e08479;
  --fail-soft: #2c1c1a;
  --running: #dda94f;
  --running-soft: #2b2416;
  --shadow-sm: none;
  --shadow-md: 0 6px 20px rgba(0, 0, 0, 0.35);
  --shadow-lg: 0 24px 60px rgba(0, 0, 0, 0.5);
}

* { box-sizing: border-box; min-width: 0; }

html, body { height: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 14px;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}
a { color: var(--accent); }
a:hover { color: var(--text); }

/* -------------------- Infobulles -------------------- */

.info-icon {
  display: inline-flex; align-items: center; justify-content: center; width: 15px; height: 15px;
  border-radius: 50%; background: var(--input-bg); border: 1px solid var(--border-strong);
  color: var(--muted); font-size: 10px; font-weight: 700;
  font-style: normal; cursor: help; position: relative; flex-shrink: 0; margin-left: 7px;
}
.info-icon:hover, .info-icon:focus { background: var(--accent-fill); border-color: var(--accent-fill); color: #fff; }
.info-icon .tip { display: none !important; }
h2 .info-icon, .inline-h2 .info-icon { transform: translateY(1px); }

.global-tooltip {
  position: fixed; z-index: 300; max-width: 280px;
  background: #1f2320; color: #e8e7e2; border: 1px solid #3c413a; border-radius: 8px;
  padding: 10px 12px; font-size: 12px; line-height: 1.55; text-align: left;
  box-shadow: var(--shadow-lg); pointer-events: none;
  opacity: 0; transform: translateY(4px);
  transition: opacity 0.12s ease, transform 0.12s ease;
}
.global-tooltip.visible { opacity: 1; transform: translateY(0); }

/* -------------------- Écran de chargement (mise à jour) -------------------- */

.update-loading-overlay {
  position: fixed; inset: 0; background: var(--bg); z-index: 500;
  display: flex; align-items: center; justify-content: center;
}
.update-loading-box { text-align: center; max-width: 320px; padding: 20px; }
.update-spinner {
  width: 40px; height: 40px; border-radius: 50%;
  border: 3px solid var(--border); border-top-color: var(--accent-fill);
  margin: 0 auto 20px; animation: update-spin 0.8s linear infinite;
}
@keyframes update-spin { to { transform: rotate(360deg); } }
.update-loading-title { font-size: 17px; font-weight: 700; margin-bottom: 6px; letter-spacing: -0.01em; }
.update-loading-sub { font-size: 13px; color: var(--muted); margin-bottom: 16px; line-height: 1.55; }
.update-loading-counter {
  display: inline-block; font-family: var(--mono); font-size: 13px;
  color: var(--muted); background: var(--card); border: 1px solid var(--border);
  border-radius: 999px; padding: 5px 14px;
}
.update-loading-counter.ok { color: var(--ok); border-color: var(--accent-fill); background: var(--ok-soft); }
.update-loading-counter.fail { color: var(--fail); border-color: var(--fail); background: var(--fail-soft); }

/* -------------------- Assistants / modales -------------------- */

.wizard-overlay {
  position: fixed; inset: 0; background: rgba(20, 22, 19, 0.5); display: flex;
  align-items: center; justify-content: center; z-index: 100; padding: 20px;
  animation: overlayFadeIn 0.15s ease;
}
@keyframes overlayFadeIn { from { opacity: 0; } to { opacity: 1; } }
#picker-overlay { z-index: 200; }
#confirm-overlay, #run-detail-overlay { z-index: 250; }
.wizard-modal {
  background: var(--card); border: 1px solid var(--border); border-radius: var(--radius-lg);
  width: 100%; max-width: min(560px, calc(100vw - 40px)); max-height: 88vh;
  display: flex; flex-direction: column; box-shadow: var(--shadow-lg); overflow: hidden;
  animation: modalPopIn 0.18s cubic-bezier(0.2, 0.8, 0.3, 1);
}
@keyframes modalPopIn {
  from { opacity: 0; transform: translateY(10px) scale(0.98); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}
.wizard-steps { display: flex; gap: 6px; padding: 20px 26px 0; }
.wizard-step-dot { flex: 1; height: 3px; border-radius: 2px; background: var(--border); }
.wizard-step-dot.done { background: var(--accent-fill); }
.wizard-step-dot.current { background: var(--accent-fill); opacity: 0.4; }
.wizard-body { padding: 22px 26px; overflow-y: auto; overflow-x: hidden; flex: 1; }
.wizard-step { display: none; }
.wizard-step:first-of-type { display: block; }
.wizard-title { font-size: 19px; font-weight: 700; letter-spacing: -0.02em; margin: 2px 0 6px; }
.wizard-subtitle { font-size: 13px; color: var(--muted); margin: 0 0 18px; line-height: 1.6; }
.wizard-footer {
  display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center;
  gap: 8px; padding: 16px 26px; border-top: 1px solid var(--border); background: var(--card-alt);
}
.wizard-footer .spacer { flex: 1; }
.wizard-summary-row {
  display: flex; justify-content: space-between; gap: 12px; padding: 11px 0;
  border-bottom: 1px solid var(--border); font-size: 13px;
}
.wizard-summary-row:last-child { border-bottom: none; }
.wizard-summary-row .k { color: var(--muted); flex-shrink: 0; }
.wizard-summary-row .v { font-family: var(--mono); text-align: right; word-break: break-word; overflow-wrap: anywhere; min-width: 0; flex: 1; }

/* -------------------- Lignes de tâches + panneau de détail -------------------- */

.main-tab.back-tab { color: var(--accent); font-weight: 700; border-bottom-color: transparent; }

.task-row {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  cursor: pointer; margin-bottom: 8px; background: var(--card);
  border: 1px solid var(--border); border-left: 3px solid var(--border-strong);
  border-radius: var(--radius); padding: 14px 16px;
  transition: border-color 0.15s, background 0.15s;
}
.task-row:hover { border-color: var(--border-strong); border-left-color: var(--accent-fill); background: var(--card-alt); }
.task-row.expanded { border-left-color: var(--accent-fill); background: var(--accent-soft); }
.task-row-main { display: flex; align-items: center; gap: 12px; }
.task-row-name { font-size: 14px; font-weight: 600; }
.task-row-sub { font-size: 12px; color: var(--muted); margin-top: 3px; font-family: var(--mono); }
.task-row-status { display: flex; align-items: center; gap: 10px; font-size: 12px; color: var(--muted); white-space: nowrap; }
.task-row-chevron { font-size: 11px; color: var(--muted); transition: transform 0.15s; }
.task-row.expanded .task-row-chevron { transform: rotate(90deg); color: var(--accent); }

.task-detail-header {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 20px 28px 14px; border-bottom: 1px solid var(--border);
  flex-wrap: wrap; flex-shrink: 0; background: var(--card);
}
.task-detail-header .main-tabs { flex-wrap: wrap; }
.panel-close-x {
  background: none; border: none; color: var(--muted); font-size: 24px; line-height: 1;
  padding: 4px 10px; cursor: pointer; border-radius: 8px; flex-shrink: 0;
}
.panel-close-x:hover { color: var(--text); background: var(--input-bg); }

.task-detail-backdrop {
  position: fixed; inset: 0; background: rgba(20, 22, 19, 0.4);
  z-index: 140; opacity: 0; pointer-events: none; transition: opacity 0.2s ease;
}
.task-detail-backdrop.visible { opacity: 1; pointer-events: auto; }

.task-detail-block {
  position: fixed; top: 0; right: 0; bottom: 0; width: min(860px, 100vw);
  background: var(--card); border-left: 1px solid var(--border);
  box-shadow: var(--shadow-lg); z-index: 150;
  display: flex; flex-direction: column; overflow: hidden;
  transform: translateX(100%); transition: transform 0.25s cubic-bezier(0.2, 0.8, 0.3, 1);
}
.task-detail-block.open { transform: translateX(0); }
.task-detail-scroll { flex: 1; overflow-y: auto; padding: 22px 28px; background: var(--bg); }

@media (max-width: 640px) {
  .task-detail-block { width: 100vw; }
}

#conn-panel-settings.conn-settings-fixed.active {
  display: flex; flex-direction: column;
  max-height: calc(100vh - 79px);
}
.conn-settings-scroll { flex: 1; overflow-y: auto; }
#conn-save-bar {
  flex-shrink: 0; margin-top: 14px; padding-top: 14px; border-top: 1px solid var(--border);
}

/* -------------------- Authentification -------------------- */

.auth-page {
  min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 20px;
  background: var(--bg);
}
.auth-card {
  background: var(--card); border: 1px solid var(--border); border-radius: var(--radius-lg);
  width: 100%; max-width: 400px; padding: 36px 32px; box-shadow: var(--shadow-md);
  border-top: 3px solid var(--accent-fill);
}
.auth-title { font-size: 24px; font-weight: 700; letter-spacing: -0.025em; margin-bottom: 8px; }
.auth-subtitle { font-size: 13px; color: var(--muted); margin: 0 0 24px; line-height: 1.6; }

/* -------------------- Shell -------------------- */

.app-shell { display: flex; height: 100vh; overflow: hidden; }

.sidebar {
  width: 248px; flex-shrink: 0; height: 100vh;
  background: var(--sidebar-bg); color: var(--sidebar-text);
  border-right: 1px solid var(--sidebar-border);
  padding: 22px 16px; display: flex; flex-direction: column; gap: 18px; overflow: hidden;
}

.sidebar-brand {
  font-size: 18px; font-weight: 700; letter-spacing: -0.02em; color: var(--sidebar-text);
  display: flex; align-items: center; gap: 8px; padding: 0 8px 2px;
}

.sidebar-add-btn {
  background: var(--accent-fill); color: #14170f; border: none; border-radius: 8px;
  padding: 11px 14px; font-size: 13px; font-weight: 700; cursor: pointer;
  display: flex; align-items: center; gap: 6px; justify-content: center;
  transition: filter 0.15s ease;
}
.sidebar-add-btn:hover { filter: brightness(1.08); }
.sidebar-add-btn .plus { font-size: 15px; line-height: 1; }

.sidebar-dashboard-btn {
  background: none; border: none; color: var(--sidebar-muted); padding: 9px 12px; border-radius: 7px;
  font-size: 13px; font-weight: 600; cursor: pointer; text-align: left; font-family: var(--font);
  transition: background 0.15s ease, color 0.15s ease;
}
.sidebar-dashboard-btn:hover { background: var(--sidebar-hover); color: var(--sidebar-text); }
.sidebar-dashboard-btn.active { background: var(--sidebar-hover); color: var(--sidebar-text); }

.dashboard-title { font-size: 24px; font-weight: 700; letter-spacing: -0.02em; }

.sidebar-list { display: flex; flex-direction: column; gap: 2px; overflow-y: auto; flex: 1; }

.sidebar-item {
  display: flex; align-items: center; gap: 10px; background: none; border: none;
  color: #c8c9c2; padding: 9px 12px; border-radius: 7px; font-size: 13px;
  cursor: pointer; text-align: left; font-family: var(--font);
  transition: background 0.15s ease, color 0.15s ease;
}
.sidebar-item:hover { background: var(--sidebar-hover); color: var(--sidebar-text); }
.sidebar-item.active { background: var(--sidebar-hover); color: var(--sidebar-text); font-weight: 600; }
.sidebar-item-name { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* La pastille de statut devient un trait vertical — plus lisible qu'un point. */
.sidebar-item-dot {
  width: 3px; height: 16px; border-radius: 2px; background: #3a3f3a; flex-shrink: 0; order: -1;
}
.sidebar-item-dot.ok { background: var(--accent-fill); }
.sidebar-item-dot.fail { background: #c8564a; }
.sidebar-item-dot.running { background: #dda94f; }

.sidebar-footer {
  border-top: 1px solid var(--sidebar-border); padding-top: 14px; display: flex;
  flex-direction: column; gap: 4px; flex-shrink: 0;
}
.version-label { font-size: 11px; color: var(--sidebar-muted); font-family: var(--mono); padding: 0 12px 6px; }
.sidebar-update-btn {
  background: none; border: none; color: #b6b8b0;
  border-radius: 7px; padding: 8px 12px; font-size: 13px; font-weight: 500;
  cursor: pointer; text-align: left; font-family: var(--font);
  transition: background 0.15s ease, color 0.15s ease;
}
.sidebar-update-btn:hover { background: var(--sidebar-hover); color: var(--sidebar-text); }

.main-area { flex: 1; height: 100vh; overflow-y: auto; padding: 28px 32px 100px; min-width: 0; position: relative; }

.empty-state {
  text-align: center; padding: 80px 20px; color: var(--muted); font-size: 14px;
  max-width: 480px; margin: 60px auto;
}
.empty-state button { margin-top: 16px; }

/* -------------------- Barre du haut -------------------- */

.main-topbar { display: flex; align-items: center; justify-content: space-between; gap: 20px; margin-bottom: 24px; flex-wrap: wrap; }

.topbar-clock {
  font-size: 12.5px; color: var(--muted); font-family: var(--mono);
  white-space: nowrap; text-transform: capitalize;
}

.main-tabs { display: flex; gap: 4px; flex-wrap: wrap; }
.main-tab {
  background: none; border: none; color: var(--muted); font-size: 13px; font-weight: 600;
  padding: 8px 14px; border-radius: 7px; cursor: pointer; font-family: var(--font);
  transition: color 0.15s ease, background 0.15s ease;
}
.main-tab:hover { color: var(--text); background: var(--input-bg); }
.main-tab.active { color: var(--text); background: var(--input-bg); box-shadow: inset 0 -2px 0 var(--accent-fill); }

.main-panel { display: none; }
.main-panel.active { display: block; animation: panelFadeIn 0.22s ease; }
@keyframes panelFadeIn {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}

.status-actions { display: flex; gap: 10px; flex-wrap: wrap; }

.history-row { cursor: pointer; transition: background 0.12s ease; }
.history-row:hover { background: var(--input-bg); }
.dashboard-row-fail { background: var(--fail-soft); }
.dashboard-row-fail:hover { background: var(--fail-soft); box-shadow: inset 2px 0 0 var(--fail); }
.dashboard-row-disabled { opacity: 0.55; }
.dashboard-relative-time { font-size: 11px; color: var(--muted); }

/* -------------------- Graphique d'activité -------------------- */

.activity-chart-legend {
  display: inline-flex; gap: 16px; font-size: 12px; font-weight: 500;
  text-transform: none; letter-spacing: 0; color: var(--muted);
}
.activity-chart-legend span { display: inline-flex; align-items: center; gap: 6px; }
.activity-chart-legend .dot { width: 9px; height: 9px; border-radius: 3px; display: inline-block; flex-shrink: 0; }
.activity-chart-legend .dot.ok { background: var(--accent-fill); }
.activity-chart-legend .dot.fail { background: var(--fail); }

.activity-chart {
  display: flex; align-items: flex-end; gap: 9px; padding: 20px 22px 16px;
  background: var(--card); border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: var(--shadow-sm); min-height: 172px;
}
.activity-chart .empty { color: var(--muted); font-size: 13px; margin: auto; }
.activity-bar-col { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 9px; min-width: 0; }
.activity-bar-track {
  height: 118px; width: 100%; max-width: 30px; display: flex; flex-direction: column-reverse;
  gap: 3px; background: none; border-radius: 4px; overflow: hidden;
}
.activity-bar-seg { width: 100%; min-height: 3px; border-radius: 4px; }
.activity-bar-seg.ok { background: var(--accent-fill); }
.activity-bar-seg.fail { background: var(--fail); }
.activity-bar-label { font-size: 10.5px; color: var(--muted); white-space: nowrap; font-family: var(--mono); }

/* -------------------- Glisser-déposer -------------------- */

.dropzone {
  border: 1px dashed var(--border-strong); border-radius: var(--radius); padding: 32px 20px;
  text-align: center; cursor: pointer; background: var(--card-alt);
  transition: border-color 0.15s ease, background 0.15s ease;
}
.dropzone:hover, .dropzone:focus-visible { border-color: var(--accent-fill); outline: none; }
.dropzone.dropzone-active { border-color: var(--accent-fill); background: var(--accent-soft); }
.dropzone-icon { font-size: 26px; line-height: 1; margin-bottom: 8px; color: var(--muted); }
.dropzone-text { font-size: 13px; color: var(--muted); }
.dropzone-browse { color: var(--accent); font-weight: 600; text-decoration: underline; }
.dropzone-filename { font-size: 12px; color: var(--text); font-weight: 700; margin-top: 10px; font-family: var(--mono); }

/* -------------------- Liens d'action + pagination -------------------- */

.link-action { font-size: 12.5px; font-weight: 600; color: var(--accent); text-decoration: none; text-transform: none; letter-spacing: 0; }
.link-action:hover { text-decoration: underline; }
.link-action.subtle { color: var(--muted); font-weight: 500; }

.notify-scope-group { border: 1px solid var(--border); border-radius: var(--radius); padding: 12px 14px; margin-bottom: 10px; background: var(--card-alt); }
.notify-scope-group:last-child { margin-bottom: 0; }
.notify-scope-group-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 4px; gap: 10px; }
.notify-scope-group-header strong { font-size: 13px; }
.notify-scope-bulk { display: flex; gap: 12px; flex-shrink: 0; }
.notify-scope-group .setting-row { padding: 8px 0; font-size: 12.5px; }

.pager { display: flex; align-items: center; justify-content: center; gap: 16px; margin-top: 20px; }
.pager-info { font-size: 13px; color: var(--muted); font-family: var(--mono); }
.pager button:disabled { opacity: 0.4; cursor: not-allowed; }

.run-detail-head { display: flex; align-items: center; gap: 14px; margin-bottom: 18px; }

/* -------------------- Contenus communs -------------------- */

h2 {
  font-size: 15px; color: var(--text); font-weight: 600; text-transform: none;
  letter-spacing: -0.01em; margin: 30px 0 12px; display: flex; align-items: center;
}
.inline-h2 { margin: 0 0 6px; }
.hint { font-size: 12.5px; color: var(--muted); margin: 0 0 12px; line-height: 1.6; }
.hint code, .module-callout-text code {
  background: var(--input-bg); border: 1px solid var(--border); border-radius: 4px;
  padding: 1px 5px; font-family: var(--mono); font-size: 0.92em;
}

.banner {
  background: var(--running-soft); border: 1px solid transparent; border-left: 3px solid var(--running);
  color: var(--running); border-radius: var(--radius); padding: 13px 16px; font-size: 13px; margin-bottom: 18px;
}

.task-header-row { display: flex; align-items: flex-end; gap: 14px; flex-wrap: wrap; margin-bottom: 20px; }
.task-name-field { flex: 1; min-width: 220px; }
.enabled-toggle { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--muted); padding-bottom: 9px; }
.enabled-toggle input { width: 16px; height: 16px; accent-color: var(--accent-fill); }

/* -------------------- Boutons -------------------- */

button {
  background: var(--accent-fill); color: #14170f; border: none; border-radius: 8px;
  padding: 10px 18px; font-size: 13.5px; font-weight: 700; cursor: pointer;
  font-family: var(--font); transition: filter 0.15s ease, background 0.15s ease;
}
button:hover { filter: brightness(1.06); }
button:disabled { opacity: 0.45; cursor: not-allowed; filter: none; }
.secondary-btn { background: var(--card); color: var(--text); border: 1px solid var(--border-strong); font-weight: 600; }
.secondary-btn:hover { background: var(--input-bg); filter: none; }
.small-btn {
  background: var(--card); color: var(--text); border: 1px solid var(--border-strong);
  padding: 6px 12px; font-size: 12px; font-weight: 600; margin-left: 10px;
}
.danger-btn { background: var(--fail-soft); color: var(--fail); border: 1px solid transparent; font-weight: 600; }
.danger-btn:hover { border-color: var(--fail); filter: none; }

/* -------------------- Carte de statut + progression -------------------- */

.status-card {
  background: var(--card); border: 1px solid var(--border); border-left: 3px solid var(--border-strong);
  border-radius: var(--radius); padding: 20px 24px;
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  box-shadow: var(--shadow-sm); flex-wrap: wrap;
}
.status-left { display: flex; align-items: center; gap: 16px; }
.badge {
  width: 42px; height: 42px; border-radius: 10px; display: flex; align-items: center; justify-content: center;
  font-size: 19px; font-weight: 700; background: var(--input-bg); color: var(--muted); flex-shrink: 0;
}
.badge.ok { background: var(--ok-soft); color: var(--ok); }
.badge.fail { background: var(--fail-soft); color: var(--fail); }
.badge.running { background: var(--running-soft); color: var(--running); }
.status-title { font-size: 18px; font-weight: 700; letter-spacing: -0.015em; }
.status-sub { font-size: 13px; color: var(--muted); margin-top: 3px; }

.progress-card {
  background: var(--card); border: 1px solid var(--border); border-left: 3px solid var(--accent-fill);
  border-radius: var(--radius); padding: 16px 22px; margin-top: 12px; box-shadow: var(--shadow-sm);
}
.progress-file {
  font-size: 12px; color: var(--muted); font-family: var(--mono);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; margin-bottom: 10px;
}
.progress-bar-track {
  width: 100%; height: 6px; border-radius: 999px; background: var(--input-bg);
  border: none; overflow: hidden;
}
.progress-bar-fill {
  height: 100%; background: var(--accent-fill); border-radius: 999px;
  transition: width 0.4s ease;
}
.progress-meta {
  display: flex; gap: 16px; margin-top: 10px; font-size: 12px; color: var(--muted);
  font-family: var(--mono); flex-wrap: wrap;
}
.progress-meta span:first-child { font-weight: 700; color: var(--text); }

/* -------------------- Cartes KPI -------------------- */

.metrics { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; margin-top: 16px; }
.metric {
  background: var(--card); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 16px 18px; box-shadow: var(--shadow-sm); min-width: 0;
}
.metric-label { font-size: 12px; color: var(--muted); margin-bottom: 8px; }
.metric-value { font-size: 26px; font-weight: 700; letter-spacing: -0.025em; word-break: break-word; overflow-wrap: anywhere; }

/* -------------------- Informations de connexion -------------------- */

.info-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 18px 26px; }
.info-grid > div { display: flex; flex-direction: column; gap: 5px; min-width: 0; }
.info-label { font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.1em; font-weight: 600; }
.info-value { font-size: 13.5px; font-family: var(--mono); word-break: break-all; overflow-wrap: anywhere; }

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

.history-table {
  width: 100%; border-collapse: collapse; background: var(--card);
  border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden;
  font-size: 13px; box-shadow: var(--shadow-sm);
}
.history-table th, .history-table td { padding: 12px 16px; text-align: left; border-bottom: 1px solid var(--border); }
.history-table th {
  color: var(--muted); font-weight: 700; font-size: 10.5px; text-transform: uppercase;
  letter-spacing: 0.12em; background: var(--input-bg); border-bottom: 1px solid var(--border);
}
.history-table tbody tr:nth-child(even) { background: var(--card-alt); }
.history-table tr:last-child td { border-bottom: none; }
.empty { color: var(--muted); text-align: center; padding: 24px; }

/* -------------------- Badges de statut -------------------- */

.pill {
  display: inline-block; padding: 3px 9px; border-radius: 5px; font-size: 11px;
  font-weight: 700; letter-spacing: 0.04em; text-transform: uppercase;
  background: var(--input-bg); color: var(--muted);
}
.pill.ok { background: var(--ok-soft); color: var(--ok); }
.pill.fail { background: var(--fail-soft); color: var(--fail); }
.pill.running { background: var(--running-soft); color: var(--running); }
.pill.ready { background: var(--accent-soft); color: var(--accent); }
.pill.disabled-pill { background: var(--input-bg); color: var(--muted); }

.live-dot {
  display: inline-block; width: 6px; height: 6px; border-radius: 50%; background: var(--ok);
  margin-right: 6px; animation: livePulse 1.6s ease-in-out infinite;
}
.pill.running .live-dot { background: var(--running); }
@keyframes livePulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.45; transform: scale(0.8); }
}
.live-indicator {
  display: inline-flex; align-items: center; font-size: 12.5px; font-weight: 500; color: var(--muted);
  background: var(--input-bg); border-radius: 999px; padding: 5px 12px; white-space: nowrap;
}

.logs-box {
  background: #1f2320; border: 1px solid #2f342f; border-radius: var(--radius); padding: 16px 18px;
  font-family: var(--mono); font-size: 12px; line-height: 1.65; color: #d5d7cf;
  max-height: 320px; overflow-y: auto; white-space: pre-wrap;
}

/* -------------------- Cartes de configuration -------------------- */

.config-card {
  background: var(--card); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 22px 24px; margin-bottom: 16px; box-shadow: var(--shadow-sm);
}

.mode-switch { display: flex; gap: 10px; margin: 12px 0 16px; flex-wrap: wrap; }
.mode-option {
  flex: 1 1 160px; display: flex; align-items: center; gap: 9px; background: var(--card-alt);
  border: 1px solid var(--border); border-radius: 8px; padding: 11px 14px; font-size: 13px; cursor: pointer;
  transition: border-color 0.15s ease, background 0.15s ease;
}
.mode-option:hover { border-color: var(--border-strong); }
.mode-option input { accent-color: var(--accent-fill); }
.mode-option > span { display: inline-flex; align-items: center; white-space: nowrap; }

.field-error { color: var(--fail); font-size: 12px; margin-top: 4px; }
.form-field.invalid input { border-color: var(--fail); }

.schedule-mode-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 10px; margin: 12px 0 16px; }
.mode-card {
  background: var(--card-alt); border: 1px solid var(--border); border-radius: 8px;
  padding: 14px 16px; cursor: pointer; display: block; position: relative;
  transition: border-color 0.15s ease, background 0.15s ease;
}
.mode-card:hover { border-color: var(--border-strong); }
.mode-card input { position: absolute; opacity: 0; pointer-events: none; }
.mode-card.selected { border-color: var(--accent-fill); background: var(--accent-soft); box-shadow: inset 3px 0 0 var(--accent-fill); }
.mode-card-title { font-size: 13px; font-weight: 700; margin-bottom: 4px; }
.mode-card-desc { font-size: 11.5px; color: var(--muted); line-height: 1.45; }
.schedule-field { margin-bottom: 10px; }

/* -------------------- Formulaires -------------------- */

.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 14px; }
.form-field { display: flex; flex-direction: column; gap: 6px; font-size: 12.5px; color: var(--muted); }
.form-field input, .form-field select {
  background: var(--card); border: 1px solid var(--border-strong); color: var(--text); border-radius: 8px;
  padding: 10px 12px; font-size: 13.5px; font-family: var(--font);
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
.form-field input:focus, .form-field select:focus,
.setting-row input:focus, .setting-row select:focus {
  outline: none; border-color: var(--accent-fill);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent-fill) 22%, transparent);
}
.field-hint { font-size: 11.5px; color: var(--muted); line-height: 1.5; font-weight: 400; }
.webdav-only { display: none; }

.module-callout {
  display: flex; flex-direction: column; gap: 10px;
  background: var(--accent-soft); border: 1px solid transparent; border-left: 3px solid var(--accent-fill);
  border-radius: var(--radius); padding: 16px 18px; margin-top: 16px;
}
.module-callout-title { font-size: 14px; font-weight: 700; display: flex; align-items: center; gap: 8px; }
.module-callout-text { font-size: 13px; color: var(--text); line-height: 1.6; margin: 0; }
.module-callout-error { color: var(--fail); font-size: 12px; margin: 0; }

.form-actions { display: flex; align-items: center; gap: 12px; margin-top: 16px; flex-wrap: wrap; }
.test-feedback { font-size: 13px; color: var(--muted); }
.test-feedback.ok { color: var(--ok); }
.test-feedback.fail { color: var(--fail); }

/* -------------------- Explorateur de dossiers -------------------- */

.browser {
  background: var(--card-alt); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 14px 16px; max-height: 220px; display: flex; flex-direction: column;
}
.breadcrumb { font-size: 12px; color: var(--muted); margin-bottom: 10px; font-family: var(--mono); word-break: break-all; }
.breadcrumb .crumb { cursor: pointer; color: var(--accent); }
.breadcrumb .crumb:hover { text-decoration: underline; }
.folder-list { overflow-y: auto; flex: 1; }
.folder-item { padding: 8px 10px; font-size: 13px; border-radius: 6px; cursor: pointer; }
.folder-item:hover { background: var(--accent-soft); }
.empty-folder { color: var(--muted); font-size: 12px; padding: 8px; }

.selected-path { margin-top: 10px; font-size: 13px; color: var(--muted); display: flex; align-items: center; flex-wrap: wrap; gap: 6px; }
.selected-path code {
  background: var(--input-bg); border: 1px solid var(--border); border-radius: 6px; padding: 4px 9px;
  color: var(--text); font-family: var(--mono); font-size: 12px; word-break: break-all;
}

/* -------------------- Réglages avancés -------------------- */

.settings-category { border: 1px solid var(--border); border-radius: 8px; margin-bottom: 8px; overflow: hidden; }
.settings-category summary {
  padding: 12px 16px; font-size: 13px; font-weight: 600; cursor: pointer; list-style: none;
  display: flex; align-items: center; justify-content: space-between; background: var(--card-alt);
}
.settings-category summary::-webkit-details-marker { display: none; }
.settings-category summary::after { content: "+"; color: var(--muted); font-weight: 400; }
.settings-category[open] summary::after { content: "–"; }
.settings-category[open] summary { border-bottom: 1px solid var(--border); }
.settings-box { background: var(--card); padding: 4px 16px; }
.setting-row { display: flex; align-items: center; gap: 12px; padding: 12px 0; border-bottom: 1px solid var(--border); font-size: 13px; flex-wrap: wrap; }
.setting-row:last-child { border-bottom: none; }
.setting-row input[type="checkbox"] { width: 17px; height: 17px; accent-color: var(--accent-fill); flex-shrink: 0; }
.setting-row-input { justify-content: space-between; }
.setting-row-input span { flex: 1; }
.setting-row input[type="number"], .setting-row input[type="text"], .setting-row select {
  background: var(--card); border: 1px solid var(--border-strong); color: var(--text); border-radius: 8px;
  padding: 8px 11px; font-size: 13px; width: 220px; max-width: 100%; font-family: var(--font);
}

.sticky-save {
  position: sticky; bottom: 0; margin-top: -18px; background: var(--card);
  padding: 14px 0 6px; border-top: 1px solid var(--border);
}
.save-feedback { font-size: 13px; color: var(--ok); }

#task-save-bar {
  position: static; margin: 0; flex-shrink: 0;
  padding: 14px 28px; border-top: 1px solid var(--border); background: var(--card);
}

/* -------------------- Bascule de thème (nouveau) -------------------- */

.theme-toggle {
  display: flex; gap: 4px; background: #171a16; border: 1px solid var(--sidebar-border);
  border-radius: 8px; padding: 3px; margin-bottom: 4px;
}
.theme-toggle button {
  flex: 1; background: none; color: var(--sidebar-muted); border: none; border-radius: 6px;
  padding: 6px 8px; font-size: 12px; font-weight: 600; cursor: pointer;
}
.theme-toggle button:hover { filter: none; color: var(--sidebar-text); }
.theme-toggle button.active { background: var(--sidebar-hover); color: var(--sidebar-text); }

/* -------------------- Responsive -------------------- */

@media (max-width: 860px) {
  .app-shell { flex-direction: column; height: auto; overflow: visible; }
  .sidebar { width: 100%; height: auto; border-right: none; border-bottom: 1px solid var(--sidebar-border); }
  .sidebar-list { flex-direction: row; overflow-x: auto; }
  .sidebar-item { white-space: nowrap; }
  .main-area { height: auto; overflow-y: visible; padding: 20px 16px 80px; }
  .history-table { display: block; overflow-x: auto; }
}

@media (max-width: 640px) {
  .metrics { grid-template-columns: repeat(2, 1fr); }
  .info-grid { grid-template-columns: 1fr; }
  .status-card { flex-direction: column; align-items: stretch; }
  button { width: 100%; }
  .small-btn { width: auto; }
  .setting-row input[type="number"], .setting-row input[type="text"] { width: 140px; }
  .main-tabs { overflow-x: auto; }
  .dashboard-title { font-size: 21px; }
}
