/* Webdav & Cloud FTP — style sobre inspiré de FileZilla.
 * Thèmes : clair (défaut), sombre, Solarized sombre ; « Auto » suit le système.
 * Toutes les couleurs sont des variables : un thème = un jeu de variables. */
:root {
  color-scheme: light;
  --bg: #f0f0f0;
  --panel: #ffffff;
  --border: #b9b9b9;
  --head: #e4e4e4;
  --text: #1e1e1e;
  --muted: #666;
  --select: #cce4ff;
  --select-active: #3399ff;
  --accent: #1b6ac9;
  --accent-fill: #1b6ac9;
  --accent-soft: rgba(27, 106, 201, .25);
  --on-accent: #fff;
  --on-accent-muted: #e6f0ff;
  --ok: #2e8b3a;
  --ok-bg: #e8f5e9;
  --warn: #d48806;
  --error: #c62828;
  --error-bg: #fdecea;
  --divider: #e0e0e0;
  --divider-strong: #d0d0d0;
  --button: #fafafa;
  --hover: #e8f0fb;
  --row-hover: #f2f7fd;
  --code-bg: #f3f3f3;
  --running-bg: #fff8e1;
  --drop-bg: #f5f9ff;
  --drop-row: #ffe9a8;
  --summary-bg: #eaf2fd;
  --log-bg: #fbfbfb;
  --backdrop: rgba(0, 0, 0, .35);
  --shadow: rgba(0, 0, 0, .18);
  font-family: "Segoe UI", Tahoma, Arial, sans-serif;
  font-size: 13px;
  color: var(--text);
}

/* Sombre : choisi explicitement, ou « Auto » quand le système est en mode sombre. */
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #1b1d20;
  --panel: #24272b;
  --border: #3d4148;
  --head: #2d3035;
  --text: #e2e4e7;
  --muted: #9aa0a8;
  --select: #2c4566;
  --select-active: #3a6fb8;
  --accent: #6aaaf2;
  --accent-fill: #2f6fb8;
  --accent-soft: rgba(106, 170, 242, .3);
  --on-accent: #fff;
  --on-accent-muted: #dbe9ff;
  --ok: #67c777;
  --ok-bg: #1f3a25;
  --warn: #e6ad45;
  --error: #f2716a;
  --error-bg: #4a2523;
  --divider: #33363c;
  --divider-strong: #43474e;
  --button: #2f3237;
  --hover: #35404e;
  --row-hover: #2b3037;
  --code-bg: #33363b;
  --running-bg: #3a3424;
  --drop-bg: #22303f;
  --drop-row: #5b4b1d;
  --summary-bg: #243449;
  --log-bg: #1a1c1f;
  --backdrop: rgba(0, 0, 0, .6);
  --shadow: rgba(0, 0, 0, .5);
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme]) {
    color-scheme: dark;
    --bg: #1b1d20;
    --panel: #24272b;
    --border: #3d4148;
    --head: #2d3035;
    --text: #e2e4e7;
    --muted: #9aa0a8;
    --select: #2c4566;
    --select-active: #3a6fb8;
    --accent: #6aaaf2;
    --accent-fill: #2f6fb8;
    --accent-soft: rgba(106, 170, 242, .3);
    --on-accent: #fff;
    --on-accent-muted: #dbe9ff;
    --ok: #67c777;
    --ok-bg: #1f3a25;
    --warn: #e6ad45;
    --error: #f2716a;
    --error-bg: #4a2523;
    --divider: #33363c;
    --divider-strong: #43474e;
    --button: #2f3237;
    --hover: #35404e;
    --row-hover: #2b3037;
    --code-bg: #33363b;
    --running-bg: #3a3424;
    --drop-bg: #22303f;
    --drop-row: #5b4b1d;
    --summary-bg: #243449;
    --log-bg: #1a1c1f;
    --backdrop: rgba(0, 0, 0, .6);
    --shadow: rgba(0, 0, 0, .5);
  }
}

/* Solarized sombre (palette d'Ethan Schoonover : base03 #002b36, base02 #073642, base01 #586e75,
 * base0 #839496, base1 #93a1a1, jaune #b58900, rouge #dc322f, bleu #268bd2, cyan #2aa198, vert #859900). */
:root[data-theme="solarized-dark"] {
  color-scheme: dark;
  --bg: #00212b;
  --panel: #002b36;
  --border: #0e4a5a;
  --head: #073642;
  --text: #93a1a1;
  --muted: #6c8189;
  --select: #0b4558;
  --select-active: #268bd2;
  --accent: #2aa198;
  --accent-fill: #268bd2;
  --accent-soft: rgba(38, 139, 210, .35);
  --on-accent: #fdf6e3;
  --on-accent-muted: #eee8d5;
  --ok: #859900;
  --ok-bg: #1d3300;
  --warn: #b58900;
  --error: #dc322f;
  --error-bg: #3b1716;
  --divider: #073642;
  --divider-strong: #0e4a5a;
  --button: #073642;
  --hover: #0b4558;
  --row-hover: #053844;
  --code-bg: #073642;
  --running-bg: #2c3410;
  --drop-bg: #06323f;
  --drop-row: #4a3d05;
  --summary-bg: #083f50;
  --log-bg: #001d25;
  --backdrop: rgba(0, 0, 0, .6);
  --shadow: rgba(0, 0, 0, .55);
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--text); }
input, select, textarea { color: var(--text); background: var(--panel); }
button { font: inherit; cursor: pointer; }
button:disabled { opacity: .5; cursor: default; }
select { font: inherit; }

/* --- Connexion ---------------------------------------------------------- */
.login-page { display: flex; align-items: center; justify-content: center; padding: 16px; }
.login {
  width: 100%; max-width: 340px; background: var(--panel); border: 1px solid var(--border);
  border-radius: 6px; padding: 24px; display: flex; flex-direction: column; gap: 12px;
}
.login h1 { margin: 0; font-size: 20px; }
.login-sub { margin: -8px 0 4px; color: var(--muted); }
.login label { display: flex; flex-direction: column; gap: 4px; font-weight: 600; }
.login input { font: inherit; font-weight: normal; padding: 7px 8px; border: 1px solid var(--border); border-radius: 4px; }
.login input[name="code"] { font-size: 18px; letter-spacing: 3px; text-align: center; }
.login button { padding: 8px; background: var(--accent-fill); color: var(--on-accent); border: 0; border-radius: 4px; font-weight: 600; }
.login-error { margin: 0; padding: 8px; background: var(--error-bg); color: var(--error); border-radius: 4px; }

/* --- Assistant de première installation ---------------------------------- */
.login.setup { max-width: 460px; }
.setup-text, .setup-note, .setup-ok { margin: 0; line-height: 1.45; }
.setup-note { color: var(--muted); font-size: 12px; }
.setup-ok { padding: 8px; background: var(--ok-bg); color: var(--ok); border-radius: 4px; }
.setup code { background: var(--code-bg); padding: 0 3px; }
.setup-steps { margin: 0; padding-left: 20px; line-height: 1.45; }
.setup-qr { display: flex; justify-content: center; }
.setup-qr svg { width: 230px; max-width: 100%; height: auto; border: 1px solid var(--border); border-radius: 4px; }
.setup-manual { color: var(--muted); font-size: 12px; }
.setup-manual summary { cursor: pointer; }
.setup-manual p { margin: 6px 0 0; }
.setup .secret { display: inline-block; font-family: Consolas, monospace; font-size: 14px; letter-spacing: 1px; color: var(--text); font-weight: 600; }
.login .setup-secondary { background: var(--button); color: var(--text); border: 1px solid var(--border); font-weight: normal; }
.setup-button { display: block; padding: 8px; text-align: center; background: var(--accent-fill); color: var(--on-accent); border-radius: 4px; font-weight: 600; text-decoration: none; }

/* --- Application -------------------------------------------------------- */
.app { display: flex; flex-direction: column; height: 100vh; overflow: hidden; }
.topbar {
  display: flex; align-items: center; gap: 12px; padding: 4px 10px;
  background: var(--head); border-bottom: 1px solid var(--border);
}
.brand { font-size: 15px; color: var(--accent); }
.topbar-user { margin-left: auto; color: var(--muted); }

/* Choix de la langue */
.lang-switch { display: flex; gap: 6px; font-size: 12px; }
.lang-switch a { color: var(--accent); text-decoration: none; padding: 1px 3px; border-radius: 3px; }
.lang-switch a:hover { background: var(--hover); }
.lang-current { padding: 1px 3px; border-radius: 3px; background: var(--accent-fill); color: var(--on-accent); }
.login .lang-switch { margin-top: 0; }

/* Choix de la langue et du thème */
.prefs { display: flex; align-items: center; gap: 12px; }
.login .prefs { justify-content: center; margin-top: -4px; }
.theme-switch { display: flex; gap: 4px; font-size: 13px; line-height: 1; }
.theme-switch a { color: var(--muted); text-decoration: none; padding: 2px 4px; border-radius: 3px; }
.theme-switch a:hover { background: var(--hover); color: var(--text); }
.theme-current { padding: 2px 4px; border-radius: 3px; background: var(--accent-fill); color: var(--on-accent); }
.logout { margin: 0; }
.topbar button, .pane-head button, .queue-head button, .dlg button {
  padding: 2px 8px; background: var(--button); border: 1px solid var(--border); border-radius: 3px;
}
.topbar button:hover, .pane-head button:hover, .queue-head button:hover:not(:disabled),
.dlg button:hover:not(:disabled) { background: var(--hover); }

.panes { flex: 1 1 60%; display: flex; min-height: 0; padding: 4px; gap: 4px; }
.pane {
  flex: 1 1 0; min-width: 0; display: flex; flex-direction: column;
  background: var(--panel); border: 1px solid var(--border);
}
.pane.active { border-color: var(--accent-fill); }
.pane-head { display: flex; align-items: center; gap: 4px; padding: 4px; background: var(--head); border-bottom: 1px solid var(--border); }
.conn-select { flex: 1 1 40%; min-width: 0; font-weight: 700; padding: 1px 2px; }
.fav-select { flex: 1 1 30%; min-width: 0; padding: 1px 2px; }
.head-sep { flex: 0 0 6px; }
.pathbar { margin: 0; padding: 3px 4px; border-bottom: 1px solid var(--divider); }
.path-input { width: 100%; font: inherit; padding: 2px 6px; border: 1px solid var(--border); }
.crumbs { display: flex; flex-wrap: wrap; align-items: center; gap: 2px; padding: 2px 6px; border-bottom: 1px solid var(--divider); min-height: 22px; }
.crumb { background: none; border: 0; padding: 1px 3px; color: var(--accent); }
.crumb:hover { text-decoration: underline; }
.crumb-sep { color: var(--muted); }

.list-wrap { flex: 1; overflow: auto; outline: none; position: relative; }
.pane.loading .list-wrap { opacity: .55; }
table { width: 100%; border-collapse: collapse; table-layout: fixed; }
th {
  position: sticky; top: 0; z-index: 1; background: var(--head); text-align: left; font-weight: 600;
  padding: 3px 6px; border-bottom: 1px solid var(--border); border-right: 1px solid var(--divider-strong);
  user-select: none; white-space: nowrap;
}
th[data-sort] { cursor: pointer; }
th.sorted::after { content: " ▲"; font-size: 9px; }

/* Colonnes réglables : bord droit = redimensionner, glisser = déplacer */
.list { min-width: 100%; }
.list th { overflow: hidden; text-overflow: ellipsis; } /* sticky : repère des poignées */
.list th.num { text-align: right; padding-right: 10px; }
.col-resize { position: absolute; top: 0; right: 0; width: 7px; height: 100%; cursor: col-resize; z-index: 2; }
.col-resize:hover, body.col-resizing .col-resize { background: var(--accent-soft); }
body.col-resizing, body.col-resizing * { cursor: col-resize !important; user-select: none; }
.list th.col-dragging { opacity: .45; }
.list th.drop-before { box-shadow: inset 3px 0 0 var(--accent); }
.list th.drop-after { box-shadow: inset -3px 0 0 var(--accent); }
th.sorted.desc::after { content: " ▼"; }
td { padding: 2px 6px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.num, .list td.date { font-variant-numeric: tabular-nums; }
.num { text-align: right; }
.list tbody tr { cursor: default; user-select: none; }
.list tbody tr:hover { background: var(--row-hover); }
.list tbody tr.selected { background: var(--select); }
.pane.active .list tbody tr.selected { background: var(--select-active); color: var(--on-accent); }
.row-empty td { padding: 16px; color: var(--muted); white-space: normal; }
/* Icônes de types de fichiers (SVG dessinés par app.js) */
.ficon { display: inline-block; width: 17px; height: 19px; margin: -3px 5px -4px 0; vertical-align: middle; flex: none; }
.ficon svg { display: block; }
.fname { vertical-align: middle; }
.list td.col-ext { color: var(--muted); }
.pane.active .list tbody tr.selected td.col-ext { color: inherit; }
.dot { display: inline-block; width: 9px; height: 9px; border-radius: 50%; }
.dot.same { background: var(--ok); }
.dot.diff { background: var(--warn); }
.pane-selection {
  padding: 4px 8px; border-top: 1px solid var(--border); background: var(--summary-bg); color: var(--accent);
  font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.pane-selection.empty { background: var(--panel); color: var(--muted); font-weight: normal; }
.pane-status { padding: 2px 6px; border-top: 1px solid var(--border); background: var(--head); color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* Glisser-déposer */
.pane.drop-over .list-wrap { outline: 2px dashed var(--accent); outline-offset: -3px; background: var(--drop-bg); }
.list tbody tr.drop-row, .pane.active .list tbody tr.drop-row { background: var(--drop-row); color: var(--text); }
.drop-hint {
  display: none; position: sticky; bottom: 8px; margin: 0 auto; width: max-content; padding: 4px 10px;
  background: var(--accent-fill); color: var(--on-accent); border-radius: 12px; font-size: 12px; pointer-events: none;
}
.pane.drop-files .drop-hint { display: block; }

/* Zone centrale : flèches et cartouche « Gestion des transferts » */
.middle { flex: 0 0 132px; display: flex; flex-direction: column; justify-content: center; align-items: center; gap: 10px; padding: 0 2px; }
.middle > .arrow {
  width: 46px; height: 40px; font-size: 22px; font-weight: 700; color: var(--on-accent);
  background: var(--accent-fill); border: 0; border-radius: 4px;
}
.middle > .arrow:hover { filter: brightness(1.1); }
.sync-nav {
  width: 100%; display: flex; align-items: flex-start; gap: 4px; padding: 4px 6px; font-size: 11px; line-height: 1.3;
  color: var(--text); background: var(--panel); border: 1px solid var(--border); border-radius: 4px; cursor: pointer;
}
.sync-nav input { margin: 1px 0 0; flex: 0 0 auto; }
.sync-nav:has(input:checked) { border-color: var(--accent); box-shadow: inset 0 0 0 1px var(--accent); }
.sync-nav:has(input:disabled) { opacity: .55; cursor: default; }
.panes.sync-nav-on .pathbar { box-shadow: inset 0 -2px 0 var(--accent); }
.transfer-box {
  width: 100%; margin: 6px 0 0; padding: 4px 6px 6px; display: flex; flex-direction: column; gap: 6px;
  background: var(--panel); border: 1px solid var(--border); border-radius: 4px;
}
.transfer-box legend { font-weight: 700; font-size: 11px; padding: 0 3px; }
.transfer-box label { display: flex; flex-direction: column; gap: 2px; font-size: 11px; color: var(--muted); }
.transfer-box select { width: 100%; color: var(--text); }
.threads-info { font-size: 11px; color: var(--muted); text-align: center; }
.transfer-box label.sync-delete { flex-direction: row; align-items: flex-start; gap: 4px; color: var(--text); }
.transfer-box label.sync-delete[hidden] { display: none; }
.link-button { padding: 0; border: 0; background: none; color: var(--accent); font-size: 11px; cursor: pointer; text-decoration: underline; }
body.busy, body.busy * { cursor: progress !important; }

/* --- Aperçu de synchronisation ---------------------------------------------- */
.dlg.dlg-sync { width: min(720px, calc(100vw - 32px)); }
.sync-body { padding: 12px 14px; max-height: min(560px, calc(100vh - 160px)); overflow: auto; }
.sync-route { margin: 0 0 10px; font-weight: 600; overflow-wrap: anywhere; }
.sync-counts { margin: 0 0 10px; padding-left: 20px; }
.sync-counts li { margin: 2px 0; }
.sync-counts li.zero { color: var(--muted); }
.sync-counts .sync-new, .sync-counts .sync-update { color: var(--ok); }
.sync-counts .sync-delete:not(.zero), .sync-counts .sync-conflict:not(.zero) { color: var(--error); }
.sync-counts .sync-total, .sync-counts .sync-nothing { list-style: none; margin-left: -20px; margin-top: 6px; font-weight: 600; color: var(--text); }
.sync-samples details { margin: 4px 0; }
.sync-samples summary { cursor: pointer; }
.sync-samples ul { list-style: none; margin: 4px 0 6px; padding: 4px 8px; max-height: 180px; overflow: auto; background: var(--log-bg); border: 1px solid var(--divider-strong); border-radius: 4px; }
.sync-samples li { display: flex; align-items: center; white-space: nowrap; font-size: 12px; padding: 1px 0; }
.sync-samples li .fname { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; }
.sync-samples .sync-size { margin-left: 10px; color: var(--muted); font-variant-numeric: tabular-nums; }
.sync-samples li.more { color: var(--muted); font-style: italic; }
.dlg-foot { display: flex; gap: 8px; justify-content: flex-end; padding: 8px 12px; border-top: 1px solid var(--border); background: var(--head); }
.dlg button.primary.danger { background: var(--error); border-color: var(--error); color: #fff; }

/* --- Section Aide ---------------------------------------------------------- */
.settings-section.help h4 { margin: 16px 0 4px; font-size: 14px; color: var(--accent); }
.settings-section.help p { margin: 0 0 6px; line-height: 1.5; max-width: 72ch; }

/* --- Fenêtre Paramètres ---------------------------------------------------- */
.dlg.dlg-settings { width: min(1040px, calc(100vw - 32px)); height: min(720px, calc(100vh - 32px)); }
.dlg-settings[open] { display: flex; flex-direction: column; }
.settings-layout { flex: 1; display: flex; min-height: 0; }
.settings-nav { flex: 0 0 210px; display: flex; flex-direction: column; gap: 2px; padding: 8px; background: var(--head); border-right: 1px solid var(--border); overflow: auto; }
.dlg .settings-nav button { display: flex; align-items: center; gap: 8px; width: 100%; padding: 7px 10px; text-align: left; background: none; border: 0; border-radius: 4px; color: var(--text); }
.dlg .settings-nav button:hover { background: var(--hover); }
.dlg .settings-nav button.active { background: var(--accent-fill); color: var(--on-accent); }
.settings-icon { width: 18px; text-align: center; }
.settings-content { flex: 1; min-width: 0; overflow: auto; padding: 12px 16px; }
.settings-section h3 { margin: 0 0 10px; font-size: 16px; }
.settings-section h4 { margin: 0 0 6px; font-size: 13px; }
.settings-section .dlg-body { padding: 0; }
.settings-form-grid { display: flex; flex-direction: column; gap: 8px; max-width: 520px; margin: 0 0 12px; }
.settings-form-grid label { display: flex; flex-direction: column; gap: 3px; font-weight: 600; }
.settings-form-grid input, .settings-form-grid select { font: inherit; font-weight: normal; padding: 5px 7px; border: 1px solid var(--border); border-radius: 3px; }
.settings-form-grid input[type="number"] { width: 90px; }
.settings-box { padding: 10px 12px; border: 1px solid var(--divider-strong); border-radius: 4px; }
.conn-warning { padding: 6px 8px; background: var(--running-bg); border-radius: 3px; color: var(--text); }
.theme-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 10px; margin-bottom: 8px; }
.dlg .theme-card { display: flex; flex-direction: column; gap: 6px; padding: 8px; background: var(--panel); border: 2px solid var(--divider-strong); border-radius: 6px; text-align: left; color: var(--text); }
.dlg .theme-card.active { border-color: var(--accent-fill); box-shadow: 0 0 0 2px var(--accent-soft); }
.theme-preview { display: grid; grid-template-columns: 2fr 1fr; grid-template-rows: 18px 26px; gap: 3px; padding: 4px; border-radius: 4px; height: 60px; }
.theme-preview i { display: block; border-radius: 2px; }
.theme-preview i:nth-child(1) { grid-column: 1 / 3; }
/* Aperçus : couleurs réelles de chaque thème (indépendantes du thème actif). */
.theme-preview-light { background: #f0f0f0; } .theme-preview-light i:nth-child(1) { background: #e4e4e4; } .theme-preview-light i:nth-child(2) { background: #fff; } .theme-preview-light i:nth-child(3) { background: #1b6ac9; } .theme-preview-light i:nth-child(4) { display: none; }
.theme-preview-dark { background: #1b1d20; } .theme-preview-dark i:nth-child(1) { background: #2d3035; } .theme-preview-dark i:nth-child(2) { background: #24272b; } .theme-preview-dark i:nth-child(3) { background: #2f6fb8; } .theme-preview-dark i:nth-child(4) { display: none; }
.theme-preview-solarized-dark { background: #00212b; } .theme-preview-solarized-dark i:nth-child(1) { background: #073642; } .theme-preview-solarized-dark i:nth-child(2) { background: #002b36; } .theme-preview-solarized-dark i:nth-child(3) { background: #268bd2; } .theme-preview-solarized-dark i:nth-child(4) { display: none; }
.theme-preview-auto { background: linear-gradient(135deg, #f0f0f0 50%, #1b1d20 50%); } .theme-preview-auto i:nth-child(1) { background: linear-gradient(135deg, #e4e4e4 50%, #2d3035 50%); } .theme-preview-auto i:nth-child(2) { background: linear-gradient(135deg, #fff 50%, #24272b 50%); } .theme-preview-auto i:nth-child(3) { background: #1b6ac9; } .theme-preview-auto i:nth-child(4) { display: none; }
.theme-name { font-weight: 600; }
.journal-head { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 8px; margin-bottom: 6px; }
.journal-head label { display: flex; flex-direction: column; gap: 3px; font-weight: 600; }
.journal-head input { font: inherit; font-weight: normal; padding: 4px 6px; border: 1px solid var(--border); border-radius: 3px; width: 260px; }
.journal-lines { margin: 0; padding: 8px; max-height: 460px; overflow: auto; background: var(--log-bg); border: 1px solid var(--divider-strong); border-radius: 4px; font-family: Consolas, monospace; font-size: 12px; white-space: pre-wrap; overflow-wrap: anywhere; }
.about-list { display: grid; grid-template-columns: max-content 1fr; gap: 6px 16px; margin: 12px 0 0; }
.about-list dt { color: var(--muted); }
.about-list dd { margin: 0; overflow-wrap: anywhere; }

/* --- Diagnostic -------------------------------------------------------------- */
.diag { padding: 8px 12px 12px; border-top: 1px solid var(--border); }
.diag-head { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.diag-results { max-height: 300px; overflow: auto; margin-top: 6px; }
.diag-results:empty { display: none; }
.diag-summary { margin: 6px 0; font-weight: 600; }
.diag-group { margin: 10px 0 4px; font-size: 12px; text-transform: uppercase; color: var(--muted); }
.diag-list { list-style: none; margin: 0; padding: 0; }
.diag-list li { display: grid; grid-template-columns: 18px minmax(160px, auto) 1fr; gap: 8px; padding: 2px 0; align-items: baseline; }
.diag-detail { color: var(--muted); overflow-wrap: anywhere; }
.diag-ok .diag-icon, .diag-summary.diag-ok { color: var(--ok); }
.diag-warn .diag-icon, .diag-summary.diag-warn { color: var(--warn); }
.diag-error .diag-icon, .diag-summary.diag-error { color: var(--error); }
.diag-error .diag-detail { color: var(--error); }

/* --- Menu contextuel (clic droit) ----------------------------------------- */
.ctx-menu {
  position: fixed; z-index: 1000; min-width: 250px; padding: 4px 0;
  background: var(--panel); border: 1px solid var(--border); border-radius: 4px;
  box-shadow: 0 4px 14px var(--shadow);
}
.ctx-menu[hidden] { display: none; }
.ctx-item {
  display: flex; align-items: baseline; gap: 16px; width: 100%; padding: 5px 14px;
  background: none; border: 0; text-align: left; color: var(--text);
}
.ctx-item:hover:not(:disabled), .ctx-item:focus { background: var(--select-active); color: var(--on-accent); outline: none; }
.ctx-item:hover:not(:disabled) .ctx-hint, .ctx-item:focus .ctx-hint { color: var(--on-accent-muted); }
.ctx-item.danger { color: var(--error); }
.ctx-label { flex: 1; white-space: nowrap; }
.ctx-hint { color: var(--muted); font-size: 11px; white-space: nowrap; max-width: 220px; overflow: hidden; text-overflow: ellipsis; }
.ctx-sep { height: 1px; margin: 4px 0; background: var(--divider); }

/* --- File de transfert et journal --------------------------------------- */
.bottom {
  flex: 0 0 34%; min-height: 160px; display: flex; flex-direction: column;
  margin: 0 4px 4px; background: var(--panel); border: 1px solid var(--border);
}
.queue-head { display: flex; align-items: center; gap: 8px; padding: 4px 6px; background: var(--head); border-bottom: 1px solid var(--border); }
.queue-head progress { flex: 0 1 260px; height: 14px; }
.queue-wrap { flex: 1 1 55%; overflow: auto; min-height: 0; }
.queue th:nth-child(2), .queue td:nth-child(2) { width: 200px; }
.queue th:nth-child(3), .queue td:nth-child(3) { width: 82px; }
.queue th:nth-child(4), .queue td:nth-child(4) { width: 72px; }
.queue th:nth-child(5), .queue td:nth-child(5) { width: 30%; }
.job.running { background: var(--running-bg); }
.job.copied .state, .job.moved .state, .job.created .state { color: var(--ok); }
.job.deleted .state { color: var(--warn); }
.job.skipped .state, .job.exists .state, .job.cancelled .state { color: var(--muted); }
.job.error .state { color: var(--error); font-weight: 600; }
.job.retry .state, .job.cron .state { color: var(--warn); }
.job-retry { margin-left: 8px; padding: 0 6px; font-size: 11px; background: var(--panel); border: 1px solid var(--border); border-radius: 3px; color: var(--text); }
.queue-hint { margin-left: auto; font-size: 12px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.queue-hint.warn { color: var(--warn); font-weight: 600; }
.log { flex: 1 1 45%; overflow: auto; min-height: 0; border-top: 1px solid var(--border); padding: 2px 6px; font-family: Consolas, monospace; font-size: 12px; background: var(--log-bg); }
.log-line.ok { color: var(--ok); }
.log-line.warn { color: var(--warn); }
.log-line.error { color: var(--error); }

/* --- Fenêtre des connexions ------------------------------------------------ */
.dlg { width: min(860px, calc(100vw - 32px)); padding: 0; border: 1px solid var(--border); border-radius: 6px; color: var(--text); background: var(--panel); }
.dlg::backdrop { background: var(--backdrop); }
.dlg-head { display: flex; align-items: center; justify-content: space-between; padding: 8px 12px; background: var(--head); border-bottom: 1px solid var(--border); }
.dlg-body { display: flex; gap: 12px; padding: 12px; }
.conn-side { flex: 0 0 210px; display: flex; flex-direction: column; gap: 8px; }
.conn-list { list-style: none; margin: 0; padding: 0; border: 1px solid var(--border); min-height: 60px; max-height: 320px; overflow: auto; }
.dlg .conn-list li button { width: 100%; text-align: left; border: 0; border-radius: 0; background: none; padding: 5px 8px; }
.dlg .conn-list li.current button { background: var(--select-active); color: var(--on-accent); }
.conn-form { flex: 1; min-width: 0; margin: 0; display: flex; flex-direction: column; gap: 8px; }
.conn-form label { display: flex; flex-direction: column; gap: 3px; font-weight: 600; }
.conn-form input { font: inherit; font-weight: normal; padding: 5px 7px; border: 1px solid var(--border); border-radius: 3px; }
.conn-hint { margin: 0; color: var(--muted); font-size: 12px; }
.conn-row { display: flex; gap: 8px; }
.conn-protocol { flex: 1; }
.conn-port { flex: 0 0 110px; }
.conn-form select { font: inherit; font-weight: normal; padding: 4px 5px; border: 1px solid var(--border); border-radius: 3px; }
.conn-proto-tag { font-size: 11px; color: var(--muted); font-weight: normal; margin-left: 4px; }
.conn-hint code { font-size: 11px; background: var(--code-bg); padding: 0 3px; }
.conn-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }
.dlg button.primary { background: var(--accent-fill); color: var(--on-accent); border-color: var(--accent-fill); }
.dlg button.danger { color: var(--error); }
.conn-msg { font-size: 12px; }
.conn-msg.ok { color: var(--ok); }
.conn-msg.error { color: var(--error); }
.fav-manage { border-top: 1px solid var(--divider); padding-top: 8px; }
.fav-list { list-style: none; margin: 6px 0 0; padding: 0; max-height: 150px; overflow: auto; }
.fav-list li { display: flex; align-items: center; gap: 8px; padding: 2px 0; }
.fav-list li.muted { color: var(--muted); }
.fav-name { font-weight: 600; }
.fav-path { flex: 1; min-width: 0; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dlg .fav-del { padding: 0 6px; }

/* --- Petits écrans : panneaux empilés ----------------------------------- */
@media (max-width: 900px) {
  .app { height: auto; min-height: 100vh; overflow: visible; }
  .panes { flex-direction: column; }
  .pane { min-height: 320px; }
  .middle { flex: 0 0 auto; flex-direction: row; flex-wrap: wrap; justify-content: center; padding: 4px 0; }
  .middle > .arrow { transform: rotate(90deg); }
  .sync-nav { width: auto; align-self: center; }
  .transfer-box { width: auto; flex-direction: row; align-items: flex-end; margin: 0; }
  .bottom { min-height: 280px; }
  .list .col-ctime { display: none; }
  .dlg-body { flex-direction: column; }
  .conn-side { flex: 0 0 auto; }
  .settings-layout { flex-direction: column; }
  .settings-nav { flex: 0 0 auto; flex-direction: row; overflow-x: auto; border-right: 0; border-bottom: 1px solid var(--border); }
  .dlg .settings-nav button { width: auto; white-space: nowrap; }
}

/* --- Synchronisations et notification e-mail -------------------------------- */
.tabs { display: flex; gap: 2px; margin: 0 0 10px; border-bottom: 1px solid var(--border); }
.dlg .tab { border: 1px solid transparent; border-bottom: 0; border-radius: 4px 4px 0 0; background: none; padding: 5px 12px; margin-bottom: -1px; }
.dlg .tab.active { background: var(--panel); border-color: var(--border); font-weight: 600; }
.tab-panel[hidden] { display: none; }
.conn-form label.check { flex-direction: row; align-items: center; gap: 6px; font-weight: normal; }
.conn-form .conn-row > label { min-width: 0; }
.conn-form .conn-row input { width: 100%; box-sizing: border-box; }
.syncs-cron { padding: 8px; border: 1px solid var(--divider-strong); border-radius: 4px; background: var(--log-bg); display: flex; flex-direction: column; gap: 4px; }
.syncs-cron[hidden] { display: none; }
.syncs-cron-line { display: flex; gap: 6px; align-items: center; }
.syncs-cron details { margin-top: 4px; display: flex; flex-direction: column; gap: 4px; }
.syncs-cron details summary { cursor: pointer; font-size: 12px; }
.syncs-cron details .conn-hint { display: block; margin-top: 6px; }
.conn-hint.warn { color: var(--warn); }
.syncs-cron-line code { flex: 1; min-width: 0; overflow-wrap: anywhere; font-size: 12px; background: var(--code-bg); padding: 3px 5px; border-radius: 3px; }
.sync-status { display: inline-block; width: 1.2em; text-align: center; color: var(--muted); }
.sync-status.ok { color: var(--ok); }
.sync-status.error { color: var(--error); }
.sync-status.running { color: var(--accent); }
.dlg .conn-list li.disabled button { color: var(--muted); font-style: italic; }
.dlg .conn-list li.current button .sync-status { color: inherit; }
.conn-list li.muted { padding: 6px 8px; color: var(--muted); }
.notify-form { max-width: 620px; }
.notify-events { border: 1px solid var(--divider-strong); border-radius: 4px; padding: 6px 10px; display: flex; flex-direction: column; gap: 4px; }
.notify-events legend { font-weight: 600; padding: 0 4px; }
.dlg-foot .sync-save-def { margin-right: auto; }

/* --- Journaux (Manuels / Synchronisations) ---------------------------------- */
.journals .tabs { margin-top: 0; }
.journal-layout { display: flex; gap: 10px; min-height: 0; }
.journal-files { flex: 0 0 260px; max-height: 480px !important; }
.dlg .journal-files li button { display: flex; align-items: center; gap: 4px; }
.journal-files .journal-size { margin-left: auto; color: var(--muted); font-size: 11px; font-variant-numeric: tabular-nums; }
.dlg .journal-files li.current button .journal-size { color: inherit; }
.journal-view { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.journal-view .journal-lines { height: 440px; max-height: none; white-space: normal; }
.journal-lines:focus { outline: 2px solid var(--accent); outline-offset: -2px; }
.jl { white-space: pre-wrap; overflow-wrap: anywhere; padding: 1px 0; }
.jl[hidden] { display: none; }
.jl-warning { color: var(--warn); }
.jl-error { color: var(--error); font-weight: 600; }
.syncs-options { font-style: italic; }
@media (max-width: 800px) {
  .journal-layout { flex-direction: column; }
  .journal-files { flex: none; max-height: 160px !important; }
}

/* --- Bandeau : paramètres de notification absents ---------------------------- */
.notify-banner { display: block; padding: 6px 12px; background: var(--warn); color: #1a1a1a; text-decoration: none; font-size: 13px; }
.notify-banner:hover, .notify-banner:focus { text-decoration: underline; filter: brightness(1.05); }
.notify-banner[hidden] { display: none; }
.login-hint { margin: -4px 0 6px; font-size: 12px; color: var(--muted); }

/* Disque local dans Paramètres › Connexions : affiché, non modifiable. */
.conn-virtual { display: flex; flex-direction: column; gap: 2px; padding: 6px 8px; border-bottom: 1px solid var(--border, #ccc); }
.conn-virtual-name { font-weight: 600; }
.conn-virtual .conn-hint { font-size: .85em; }

/* SFTP : clé privée, empreinte du serveur. */
.conn-ssh { display: flex; flex-direction: column; gap: 6px; }
.conn-ssh[hidden] { display: none; }
.conn-ssh textarea { width: 100%; font-family: monospace; font-size: .8em; resize: vertical; }
.conn-key-actions { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
.dlg-hostkey { max-width: 560px; }
.hostkey-list { display: grid; grid-template-columns: max-content 1fr; gap: 4px 12px; }
.hostkey-list dd { margin: 0; font-family: monospace; white-space: pre-wrap; word-break: break-all; }
.hostkey-list [hidden] { display: none; }
.dlg-hostkey.hostkey-warning h2 { color: var(--danger, #c0392b); }
