:root {
  --bg: #0d1117;
  --bg-panel: #161b22;
  --bg-elev: #1c2230;
  --border: #2a3140;
  --text: #e6edf3;
  --text-dim: #9198a1;
  --accent: #4f8cff;
  --accent-hover: #3b78f0;
  --danger: #f04f5a;
  --danger-hover: #d63a45;
  --row-hover: #202634;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
}

.hidden { display: none !important; }

/* ---------- Login ---------- */
.login-screen {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: radial-gradient(circle at 50% 30%, #16203a, var(--bg));
}
.login-card {
  width: min(360px, 90vw);
  background: var(--bg-panel);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 32px 28px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  box-shadow: 0 20px 60px rgba(0,0,0,.5);
}
.login-card h1 { margin: 0; font-size: 22px; text-align: center; }
.login-sub { margin: 0 0 8px; text-align: center; color: var(--text-dim); font-size: 13px; }
.login-card label { display: flex; flex-direction: column; gap: 6px; font-size: 13px; color: var(--text-dim); }
.login-card input {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px 12px;
  color: var(--text);
  font-size: 15px;
}
.login-card input:focus { outline: none; border-color: var(--accent); }
.login-card button {
  margin-top: 6px;
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: 8px;
  padding: 11px;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
}
.login-card button:hover { background: var(--accent-hover); }
.login-error { color: var(--danger); font-size: 13px; text-align: center; min-height: 18px; margin: 0; }

/* ---------- App layout ---------- */
.app { display: flex; flex-direction: column; height: 100vh; }

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 18px;
  background: var(--bg-panel);
  border-bottom: 1px solid var(--border);
  flex: 0 0 auto;
}
.topbar-left { display: flex; align-items: baseline; gap: 12px; }
.logo { font-weight: 700; letter-spacing: .5px; color: var(--accent); }
.server-label { color: var(--text-dim); font-size: 13px; }
.topbar-right { display: flex; align-items: center; gap: 14px; }
.user-name { font-size: 13px; color: var(--text-dim); }

.btn-ghost {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 7px;
  padding: 6px 12px;
  font-size: 13px;
  cursor: pointer;
}
.btn-ghost:hover { background: var(--bg-elev); }

.workspace { flex: 1 1 auto; display: flex; min-height: 0; }

/* ---------- Explorer ---------- */
.explorer {
  display: flex;
  flex-direction: column;
  min-width: 260px;
  flex: 1 1 55%;
  min-height: 0;
}
.explorer-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 8px 12px;
  border-bottom: 1px solid var(--border);
  background: var(--bg-panel);
}
.breadcrumb {
  font-size: 13px;
  color: var(--text-dim);
  overflow-x: auto;
  white-space: nowrap;
  flex: 1 1 auto;
}
.breadcrumb .crumb { color: var(--accent); cursor: pointer; }
.breadcrumb .crumb:hover { text-decoration: underline; }
.breadcrumb .sep { color: var(--text-dim); margin: 0 4px; }

.toolbar-actions { display: flex; gap: 6px; flex: 0 0 auto; }
.btn-ico {
  background: var(--bg-elev);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 7px;
  padding: 5px 9px;
  font-size: 13px;
  cursor: pointer;
}
.btn-ico:hover { background: var(--row-hover); }

/* Barre de favoris */
.fav-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
  padding: 8px 12px;
  border-bottom: 1px solid var(--border);
  background: var(--bg);
}
.fav-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 4px 6px 4px 11px;
  font-size: 13px;
  color: var(--text);
  cursor: pointer;
  max-width: 220px;
}
.fav-chip:hover { background: var(--row-hover); border-color: var(--accent); }
.fav-chip .fav-star { color: #f0c14f; flex: 0 0 auto; }
.fav-chip .fav-label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.fav-chip .fav-remove {
  border: none;
  background: transparent;
  color: var(--text-dim);
  cursor: pointer;
  font-size: 14px;
  line-height: 1;
  padding: 2px 4px;
  border-radius: 50%;
  flex: 0 0 auto;
}
.fav-chip .fav-remove:hover { background: var(--danger); color: #fff; }

/* Étoile active dans la barre d'outils / lignes */
.btn-ico.is-fav, .row-actions button.fav-on { color: #f0c14f; }

.file-list-wrap { position: relative; flex: 1 1 auto; overflow: auto; }
.file-list { width: 100%; border-collapse: collapse; font-size: 14px; }
.file-list thead th {
  position: sticky;
  top: 0;
  background: var(--bg-panel);
  text-align: left;
  color: var(--text-dim);
  font-weight: 500;
  font-size: 12px;
  padding: 8px 12px;
  border-bottom: 1px solid var(--border);
}
.file-list td { padding: 7px 12px; border-bottom: 1px solid rgba(42,49,64,.5); }
.file-list tbody tr:hover { background: var(--row-hover); }
.file-list .name-cell { display: flex; align-items: center; gap: 8px; cursor: pointer; }
.file-list .name-cell.is-dir { color: var(--text); font-weight: 500; }
.file-list .fico { width: 18px; text-align: center; }
.col-size, .col-date { color: var(--text-dim); white-space: nowrap; }
.col-act { width: 1%; white-space: nowrap; text-align: right; }
.row-actions { display: inline-flex; gap: 4px; opacity: 0; transition: opacity .1s; }
.file-list tbody tr:hover .row-actions { opacity: 1; }
.row-actions button {
  background: transparent;
  border: none;
  color: var(--text-dim);
  cursor: pointer;
  font-size: 14px;
  padding: 2px 5px;
  border-radius: 5px;
}
.row-actions button:hover { background: var(--bg-elev); color: var(--text); }
.row-actions button.del:hover { color: var(--danger); }

.drop-hint {
  position: absolute;
  inset: 0;
  display: none;
  align-items: center;
  justify-content: center;
  background: rgba(79,140,255,.12);
  border: 2px dashed var(--accent);
  color: var(--accent);
  font-size: 15px;
  pointer-events: none;
}
.file-list-wrap.dragover .drop-hint { display: flex; }

.explorer-status {
  flex: 0 0 auto;
  padding: 6px 12px;
  font-size: 12px;
  color: var(--text-dim);
  border-top: 1px solid var(--border);
  background: var(--bg-panel);
  min-height: 26px;
}

/* ---------- Divider ---------- */
.divider {
  flex: 0 0 6px;
  cursor: col-resize;
  background: var(--border);
}
.divider:hover { background: var(--accent); }

/* ---------- Terminal ---------- */
.terminal-pane {
  display: flex;
  flex-direction: column;
  flex: 1 1 45%;
  min-width: 280px;
  min-height: 0;
  background: #000;
}
.terminal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 6px 10px;
  background: var(--bg-panel);
  border-bottom: 1px solid var(--border);
  font-size: 13px;
  color: var(--text-dim);
}
.term-tabs { display: flex; gap: 4px; overflow-x: auto; flex: 1 1 auto; }
.term-tab {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 8px;
  border: 1px solid var(--border);
  border-radius: 7px 7px 0 0;
  background: var(--bg);
  color: var(--text-dim);
  cursor: pointer;
  white-space: nowrap;
  font-size: 12px;
}
.term-tab.active { background: #000; color: var(--text); border-color: var(--accent); }
.term-tab .tab-close {
  border: none;
  background: transparent;
  color: var(--text-dim);
  cursor: pointer;
  font-size: 13px;
  line-height: 1;
  padding: 0 2px;
  border-radius: 4px;
}
.term-tab .tab-close:hover { background: var(--danger); color: #fff; }
.term-header-actions { display: flex; gap: 6px; flex: 0 0 auto; }
.term-header-actions .btn-ghost { padding: 4px 8px; }
.term-header-actions .btn-ghost.is-on { color: #4f8cff; border-color: var(--accent); }

.terminals-host { position: relative; flex: 1 1 auto; min-height: 0; }
.terminal-host {
  position: absolute;
  inset: 0;
  padding: 6px 8px;
}
.terminal-host.hidden { display: none !important; }

/* ---------- Modale de conflit ---------- */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, .6);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
}
.modal {
  width: min(440px, 92vw);
  background: var(--bg-panel);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 24px 24px 18px;
  box-shadow: 0 24px 70px rgba(0, 0, 0, .6);
}
.modal h2 { margin: 0 0 12px; font-size: 18px; }
.modal-body { margin: 0 0 16px; color: var(--text-dim); font-size: 14px; line-height: 1.5; }
.modal-strong { color: var(--text); font-weight: 600; word-break: break-all; }
.modal-all {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: var(--text-dim);
  margin-bottom: 18px;
  cursor: pointer;
}
.modal-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.modal-actions button { flex: 1 1 auto; padding: 10px 12px; border-radius: 8px; font-size: 13px; cursor: pointer; border: 1px solid var(--border); }
.btn-primary { background: var(--accent); color: #fff; border-color: var(--accent) !important; font-weight: 600; }
.btn-primary:hover { background: var(--accent-hover); }
.btn-secondary { background: var(--bg-elev); color: var(--text); }
.btn-secondary:hover { background: var(--row-hover); }
.modal-actions .btn-ghost { background: transparent; color: var(--text-dim); flex: 0 0 auto; }
.modal-cancel {
  display: block;
  width: 100%;
  margin-top: 14px;
  background: transparent;
  border: none;
  color: var(--text-dim);
  font-size: 12px;
  cursor: pointer;
  padding: 6px;
}
.modal-cancel:hover { color: var(--danger); }

@media (max-width: 820px) {
  .workspace { flex-direction: column; }
  .divider { display: none; }
  .terminal-pane, .explorer { flex: 1 1 auto; min-height: 240px; }
}
