:root {
  --navy: #0b1f4d;
  --navy-2: #12306e;
  --primary: #0050d7;
  --primary-dark: #003da6;
  --bg: #f3f5f9;
  --surface: #ffffff;
  --border: #dde3ee;
  --text: #17223b;
  --muted: #5d6b86;
  --success: #12805c;
  --danger: #c62f3a;
  --warning: #b86e00;
  --prod: #c62f3a;
  --dev: #5b4bd6;
  --radius: 8px;
  --shadow: 0 1px 2px rgba(16, 32, 72, .06), 0 2px 8px rgba(16, 32, 72, .05);
  font-family: "Inter", "Segoe UI", system-ui, -apple-system, Roboto, sans-serif;
  font-size: 15px;
  color: var(--text);
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; background: var(--bg); min-height: 100vh; }
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 1.45rem; margin: 0; font-weight: 650; }
h2 { font-size: 1.05rem; margin: 0 0 .25rem; font-weight: 650; }
h2 a { color: inherit; }
.muted { color: var(--muted); }
.small { font-size: .82rem; }
.right { text-align: right; }
.nowrap { white-space: nowrap; }
code { font-family: ui-monospace, "Cascadia Code", Consolas, monospace; font-size: .85em; background: #eef2f8; padding: 1px 5px; border-radius: 4px; }

/* ---- Barre du haut */
.topbar {
  position: sticky; top: 0; z-index: 20; height: 56px; display: flex; align-items: center; gap: 12px;
  padding: 0 16px; background: var(--navy); color: #fff;
}
.brand { display: flex; align-items: center; gap: 10px; color: #fff; font-weight: 650; letter-spacing: .2px; }
.brand:hover { text-decoration: none; }
.brand-mark { display: inline-grid; place-items: center; width: 30px; height: 30px; border-radius: 6px; background: var(--primary); font-size: .8rem; font-weight: 800; color: #fff; }
.topbar-user { margin-left: auto; display: flex; align-items: center; gap: 10px; font-size: .9rem; }
.topbar-user .btn-ghost { color: #dbe4ff; border-color: rgba(255,255,255,.25); }
.topbar-user .btn-ghost:hover { background: rgba(255,255,255,.08); }
.avatar { width: 28px; height: 28px; border-radius: 50%; }
.menu-btn { display: none; background: none; border: 0; color: #fff; font-size: 1.3rem; cursor: pointer; }

/* ---- Structure */
.shell { display: flex; min-height: calc(100vh - 56px); }
.sidebar { width: 240px; flex-shrink: 0; background: var(--surface); border-right: 1px solid var(--border); padding: 12px 0; }
.sidebar a { display: flex; align-items: center; gap: 8px; padding: 9px 20px; color: var(--text); font-size: .93rem; border-left: 3px solid transparent; }
.sidebar a:hover { background: #f2f5fb; text-decoration: none; }
.sidebar a.active { background: #eaf1ff; border-left-color: var(--primary); color: var(--primary-dark); font-weight: 600; }
.sidebar .tag { margin-left: auto; }
.nav-logout { display: none !important; color: var(--danger) !important; margin-top: 12px; border-top: 1px solid var(--border); }
.nav-title { padding: 14px 20px 6px; font-size: .72rem; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); font-weight: 600; }
.content { flex: 1; padding: 24px; max-width: 1280px; min-width: 0; }
.page-head { display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 20px; }

/* ---- Cartes */
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(340px, 1fr)); gap: 16px; }
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); padding: 18px; margin-bottom: 16px; }
.cards .card { margin-bottom: 0; }
.card-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; margin-bottom: 14px; }
.server-card[data-kind="prod"] { border-top: 3px solid var(--prod); }
.server-card[data-kind="dev"] { border-top: 3px solid var(--dev); }
.server-page.server-card { border: 0; }

.metrics { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px 16px; margin: 0 0 16px; }
.metrics-row { grid-template-columns: repeat(4, 1fr); background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px 18px; box-shadow: var(--shadow); }
.metrics div { min-width: 0; }
.metrics dt { font-size: .75rem; color: var(--muted); text-transform: uppercase; letter-spacing: .05em; }
.metrics dd { margin: 2px 0 0; font-size: 1.1rem; font-weight: 600; font-variant-numeric: tabular-nums; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; }

/* ---- Étiquettes et statuts */
.tag { display: inline-block; font-size: .68rem; font-weight: 700; letter-spacing: .06em; padding: 2px 7px; border-radius: 4px; text-transform: uppercase; }
.tag-prod { background: #fde8ea; color: var(--prod); }
.tag-dev { background: #ece9fd; color: var(--dev); }
.badge { display: inline-block; font-size: .75rem; padding: 2px 8px; border-radius: 999px; font-weight: 600; }
.badge-owner { background: #ffe9b3; color: #6b4a00; }
.badge-dev { background: #dfe9ff; color: var(--primary-dark); }
.badge-ok { background: #ddf3ea; color: var(--success); }
.badge-off { background: #fde8ea; color: var(--danger); }
.status { display: inline-flex; align-items: center; gap: 6px; font-size: .88rem; font-weight: 600; white-space: nowrap; }
.dot { width: 9px; height: 9px; border-radius: 50%; background: #b5bfd1; flex-shrink: 0; }
.dot.running, .status.running .dot { background: var(--success); box-shadow: 0 0 0 3px #d4f0e4; }
.dot.stopped, .status.stopped .dot { background: var(--danger); }
.dot.busy, .status.busy .dot { background: var(--warning); }
.status.running { color: var(--success); }
.status.stopped { color: var(--danger); }
.status.busy { color: var(--warning); }

/* ---- Boutons */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; border: 1px solid transparent; border-radius: 6px;
  padding: 8px 14px; font: inherit; font-size: .9rem; font-weight: 600; cursor: pointer; background: #e9eef7; color: var(--text); line-height: 1.2; }
.btn:hover { text-decoration: none; filter: brightness(.96); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn-primary { background: var(--primary); color: #fff; }
.btn-success { background: var(--success); color: #fff; }
.btn-danger { background: var(--danger); color: #fff; }
.btn-secondary { background: #e3e9f6; color: var(--primary-dark); }
.btn-ghost { background: transparent; border-color: var(--border); color: var(--text); }
.btn-sm { padding: 5px 10px; font-size: .82rem; }
.btn-lg { padding: 12px 18px; font-size: 1rem; }
.btn-block { width: 100%; }

/* ---- Formulaires / tableaux */
input, select { font: inherit; padding: 8px 10px; border: 1px solid var(--border); border-radius: 6px; background: #fff; color: var(--text); }
input:focus, select:focus { outline: 2px solid #b9cffa; border-color: var(--primary); }
.inline-form { display: flex; gap: 8px; flex-wrap: wrap; margin: 10px 0; }
.inline-form input { flex: 1; min-width: 200px; }
.table-wrap { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; font-size: .9rem; }
.table th { text-align: left; font-size: .75rem; color: var(--muted); text-transform: uppercase; letter-spacing: .05em; padding: 8px 10px; border-bottom: 1px solid var(--border); }
.table td { padding: 10px; border-bottom: 1px solid #edf0f6; vertical-align: middle; }
.alert { padding: 10px 12px; border-radius: 6px; margin: 12px 0; font-size: .9rem; }
.alert-error { background: #fde8ea; color: #8c1d26; border: 1px solid #f6c3c8; }

/* ---- Console */
.console-card { padding: 0; overflow: hidden; }
.console-head { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 12px 16px; border-bottom: 1px solid var(--border); flex-wrap: wrap; }
.console-tools { display: flex; align-items: center; gap: 10px; }
.console-tools input[type=search] { padding: 5px 8px; font-size: .85rem; }
.console { margin: 0; height: 60vh; min-height: 320px; overflow: auto; background: #0d1426; color: #d6deee; padding: 12px 16px;
  font: 12.5px/1.5 ui-monospace, "Cascadia Code", Consolas, monospace; white-space: pre-wrap; word-break: break-word; }
.console > div { min-height: 1.5em; }
.console-input { display: flex; align-items: center; gap: 8px; padding: 10px 12px; background: #0d1426; border-top: 1px solid #1e2a45; }
.console-input .prompt { color: #61afef; font: 600 14px ui-monospace, Consolas, monospace; }
.console-input input { flex: 1; min-width: 0; background: #131c33; border: 1px solid #26355a; color: #e6ecf8; font: 13px ui-monospace, "Cascadia Code", Consolas, monospace; }
.console-input input:focus { outline: 2px solid #2b4a8c; border-color: #4b7bd8; }
.console .echo { color: #7f8aa3; font-style: italic; }
.console-card > p { padding: 8px 16px; margin: 0; }

/* ---- Connexion */
.login-page { display: grid; place-items: center; padding: 16px; background: linear-gradient(160deg, var(--navy) 0%, var(--navy-2) 100%); }
.login-card { width: 100%; max-width: 400px; background: #fff; border-radius: 12px; padding: 32px 28px; box-shadow: 0 10px 40px rgba(0,0,0,.25); }
.brand-lg { color: var(--navy); margin-bottom: 22px; font-size: 1.1rem; }
.login-card h1 { margin-bottom: 6px; }
.login-card .btn { margin: 18px 0 12px; }

/* ---- Notifications / modale */
.toast { position: fixed; right: 16px; bottom: 16px; max-width: min(420px, calc(100vw - 32px)); background: var(--navy); color: #fff; padding: 12px 16px;
  border-radius: 8px; box-shadow: 0 6px 24px rgba(0,0,0,.25); opacity: 0; transform: translateY(10px); transition: .2s; pointer-events: none; z-index: 50; }
.toast.show { opacity: 1; transform: none; }
.toast.error { background: var(--danger); }
.modal { border: 0; border-radius: 10px; padding: 22px; width: min(440px, calc(100vw - 32px)); box-shadow: 0 10px 40px rgba(0,0,0,.3); }
.modal::backdrop { background: rgba(11, 31, 77, .45); }
.modal h3 { margin: 0 0 8px; }
.modal input { width: 100%; margin-top: 6px; }
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 18px; }

/* ---- Gestionnaire de fichiers */
.sidebar a.sub { padding: 6px 20px 6px 38px; font-size: .86rem; color: var(--muted); }
.sidebar a.sub.active { color: var(--primary-dark); }
.sftp-box { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.banner { display: flex; align-items: center; justify-content: space-between; gap: 14px; padding: 12px 16px; border-radius: var(--radius); margin-bottom: 16px; font-size: .9rem; }
.banner-readonly { background: #eef3ff; border: 1px solid #c9d8fb; color: #1b326b; }
.banner-emergency { background: #fff1e0; border: 1px solid #f4c98a; color: #6b3d00; }
.files-card { position: relative; padding: 0; overflow: hidden; }
.files-toolbar { display: flex; justify-content: space-between; align-items: center; gap: 10px 16px; padding: 12px 16px; border-bottom: 1px solid var(--border); flex-wrap: wrap; }
.crumbs { display: flex; align-items: center; flex-wrap: wrap; gap: 2px 6px; font-size: .92rem; min-width: 0; }
.crumbs .sep { color: var(--muted); }
.crumbs strong { word-break: break-all; }
.files-actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.files-actions input[type=search] { padding: 5px 8px; font-size: .85rem; width: 180px; }
.files-actions label.btn { margin: 0; }
.selection-bar { display: flex; align-items: center; gap: 10px; padding: 8px 16px; background: #eaf1ff; border-bottom: 1px solid #c9d8fb; font-size: .88rem; font-weight: 600; flex-wrap: wrap; }
.files-table td { padding: 6px 10px; }
.files-table tbody tr:hover { background: #f7f9fd; }
.files-table tr.selected { background: #eef4ff; }
.files-table .col-check { width: 36px; }
.files-table .col-size { width: 100px; }
.files-table .col-date { width: 140px; }
.files-table .col-act { width: 1%; }
.fname { display: inline-flex; align-items: center; gap: 8px; color: var(--text); word-break: break-all; }
.fname:hover { color: var(--primary); }
.ficon { display: inline-flex; flex-shrink: 0; }
.ficon-dir { color: #e2a52b; }
.ficon-file { color: #8a97b1; }
.ficon-link { color: var(--dev); }
.row-actions { display: flex; gap: 4px; justify-content: flex-end; opacity: .35; transition: opacity .15s; }
tr:hover .row-actions, .row-actions:focus-within { opacity: 1; }
.btn.danger { color: var(--danger); }
.row-actions .btn svg { flex-shrink: 0; }
.row-up td { color: var(--muted); }
.drop-hint { padding: 10px 16px; border-top: 1px dashed var(--border); }
.drop-overlay { position: absolute; inset: 0; display: grid; place-items: center; background: rgba(0, 80, 215, .08); border: 2px dashed var(--primary); border-radius: var(--radius); pointer-events: none; }
.drop-overlay span { background: var(--primary); color: #fff; font-weight: 600; padding: 10px 18px; border-radius: 6px; }
.uploads { padding: 14px 16px; }
.uploads-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px; }
.upload-row { display: grid; grid-template-columns: minmax(0, 1fr) 160px minmax(0, 220px); gap: 10px; align-items: center; padding: 5px 0; border-bottom: 1px solid #edf0f6; font-size: .86rem; }
.upload-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.upload-row progress { width: 100%; }
.upload-row.done .upload-state { color: var(--success); }
.upload-row.failed .upload-state { color: var(--danger); }
.modal-editor { width: min(1200px, calc(100vw - 24px)); max-width: none; height: calc(100vh - 48px); max-height: none; padding: 0; display: none; flex-direction: column; overflow: hidden; }
.modal-editor[open] { display: flex; }
.editor-head { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 10px 14px; border-bottom: 1px solid var(--border); flex-wrap: wrap; }
.editor-title { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.editor-actions { display: flex; align-items: center; gap: 8px; }
.editor { flex: 1; width: 100%; border: 0; resize: none; padding: 12px 14px; background: #0d1426; color: #e6ecf8; font: 13px/1.55 ui-monospace, "Cascadia Code", Consolas, monospace; tab-size: 4; outline: none; white-space: pre; overflow: auto; }
.editor-foot { display: flex; justify-content: space-between; gap: 10px; padding: 6px 14px; border-top: 1px solid var(--border); flex-wrap: wrap; }
.modal label { display: block; margin-top: 10px; font-size: .9rem; }

/* ---- Mobile */
@media (max-width: 860px) {
  .menu-btn { display: block; }
  .sidebar { position: fixed; top: 56px; bottom: 0; left: 0; z-index: 15; transform: translateX(-100%); transition: transform .2s; box-shadow: 4px 0 20px rgba(0,0,0,.15); }
  .sidebar.open { transform: none; }
  .content { padding: 16px; }
  .topbar-user .who, .topbar-user .badge, .topbar-logout { display: none; }
  .nav-logout { display: flex !important; }
  .metrics-row { grid-template-columns: repeat(2, 1fr); }
  .cards { grid-template-columns: 1fr; }
  .actions .btn { flex: 1; }
  .console { height: 55vh; }
  .files-table .col-date, .files-table .col-size { display: none; }
  .files-actions { width: 100%; }
  .files-actions input[type=search] { flex: 1 1 100%; width: auto; }
  .files-actions .btn { flex: 1; }
  .row-actions { opacity: 1; flex-wrap: nowrap; }
  .row-actions .btn { padding: 6px 7px; }
  .row-actions .btn .lbl { display: none; }
  .banner { flex-direction: column; align-items: stretch; }
  .upload-row { grid-template-columns: 1fr; gap: 2px; }
  .modal-editor { width: 100vw; height: 100dvh; border-radius: 0; }
  .editor-foot span:last-child { display: none; }
}
