/* ReFix — reprend les jetons de la suite (Com, Manager) pour que l'app ne
   depayse pas quand on y arrive depuis Manager. */
:root {
  --bg: #0f1115;
  --panel: #171a21;
  --panel-2: #1e222b;
  --line: #2a2f3a;
  --text: #e8ebf0;
  --muted: #9aa3b2;
  --accent: #6c8cff;
  --ok: #3ecf8e;
  --warn: #f5a524;
  --ko: #f2555a;
  --radius: 10px;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

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

/* --- barre laterale --- */
.sidebar {
  width: 260px; flex: 0 0 260px;
  background: var(--panel); border-right: 1px solid var(--line);
  padding: 20px 16px; display: flex; flex-direction: column; gap: 22px;
}
.brand { display: flex; align-items: center; gap: 12px; }
.brand-icon {
  width: 38px; height: 38px; border-radius: 10px;
  background: linear-gradient(135deg, var(--accent), #a06cff);
  display: grid; place-items: center; font-weight: 700; color: #0b0d12;
}
.brand strong { display: block; }
.brand span { color: var(--muted); font-size: 12px; }

.side-block { display: flex; flex-direction: column; gap: 10px; }
.project-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 4px; }
.project-list button {
  width: 100%; text-align: left; background: none; border: 0; color: var(--muted);
  padding: 8px 10px; border-radius: 8px; font: inherit; cursor: pointer;
}
.project-list button:hover { background: var(--panel-2); color: var(--text); }
.project-list button.active { background: var(--panel-2); color: var(--text); font-weight: 600; }
.project-list small { display: block; color: var(--muted); font-size: 11px; font-weight: 400; }

.sidebar-foot {
  margin-top: auto; padding-top: 16px; border-top: 1px solid var(--line);
  display: flex; flex-direction: column; gap: 8px;
}
.meta-status { font-size: 12px; color: var(--muted); line-height: 1.6; }

/* --- zone principale --- */
.main { flex: 1; padding: 24px 28px 60px; min-width: 0; }
.topbar {
  display: flex; align-items: flex-start; justify-content: space-between;
  gap: 20px; flex-wrap: wrap; margin-bottom: 18px;
}
.topbar h1 { margin: 0 0 4px; font-size: 22px; outline: none; }
.topbar h1:focus { border-bottom: 1px dashed var(--accent); }
.topbar-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.muted { color: var(--muted); margin: 0; }
.empty { color: var(--muted); padding: 32px 0; text-align: center; }
.welcome { max-width: 620px; padding-top: 40px; }
.welcome h1 { font-size: 26px; margin: 0 0 10px; }

/* --- boutons --- */
.btn {
  background: var(--panel-2); color: var(--text);
  border: 1px solid var(--line); border-radius: 8px;
  padding: 8px 14px; font: inherit; cursor: pointer;
}
.btn:hover:not(:disabled) { border-color: var(--accent); }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn-primary { background: var(--accent); border-color: var(--accent); color: #0b0d12; font-weight: 600; }
.btn-ghost { background: none; }
.btn-small { padding: 5px 10px; font-size: 13px; }
.btn-block { width: 100%; }
.btn-danger { border-color: var(--ko); color: var(--ko); }

/* --- messages --- */
.flash { padding: 10px 14px; border-radius: 8px; margin-bottom: 16px; border: 1px solid var(--line); background: var(--panel); }
.flash-ok { border-color: var(--ok); }
.flash-error { border-color: var(--ko); }
.flash-warn { border-color: var(--warn); }

/* --- etapes --- */
.steps { display: flex; gap: 6px; margin-bottom: 20px; flex-wrap: wrap; }
.step {
  background: var(--panel); border: 1px solid var(--line); color: var(--muted);
  padding: 9px 16px; border-radius: 999px; font: inherit; cursor: pointer;
}
.step span { margin-right: 4px; }
.step:hover { color: var(--text); }
.step.active { background: var(--panel-2); color: var(--text); border-color: var(--accent); font-weight: 600; }

/* --- cartes --- */
.card {
  background: var(--panel); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 18px; margin-bottom: 16px;
}
.card h2 { margin: 0 0 6px; font-size: 16px; }
.grid-2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); gap: 16px; }

/* --- formulaires --- */
label { display: flex; flex-direction: column; gap: 4px; font-size: 13px; color: var(--muted); }
input, select, textarea {
  background: var(--panel-2); color: var(--text);
  border: 1px solid var(--line); border-radius: 8px;
  padding: 8px 10px; font: inherit; width: 100%;
}
input:focus, select:focus { outline: none; border-color: var(--accent); }
.form { display: flex; flex-direction: column; gap: 12px; margin-top: 12px; }
.row-fields { display: grid; grid-template-columns: repeat(auto-fit, minmax(90px, 1fr)); gap: 10px; }

.results {
  list-style: none; margin: 0; padding: 0; max-height: 220px; overflow-y: auto;
  border: 1px solid var(--line); border-radius: 8px; background: var(--panel-2);
}
.results li { padding: 8px 10px; cursor: pointer; font-size: 13px; border-bottom: 1px solid var(--line); }
.results li:last-child { border-bottom: 0; }
.results li:hover, .results li.sel { background: var(--accent); color: #0b0d12; }

/* --- depot de fichier --- */
.dropzone {
  border: 2px dashed var(--line); border-radius: var(--radius);
  padding: 28px; text-align: center; color: var(--muted); margin-top: 12px;
}
.dropzone.over { border-color: var(--accent); background: var(--panel-2); }
.dropzone-small { padding: 16px; }
.info-block {
  margin-top: 12px; padding: 12px; border-radius: 8px;
  background: var(--panel-2); font-size: 13px; line-height: 1.7;
}
.info-block dt { color: var(--muted); float: left; clear: left; width: 150px; }
.info-block dd { margin: 0 0 2px 160px; }

/* --- tableaux --- */
.table { width: 100%; border-collapse: collapse; margin-bottom: 16px; }
.table th, .table td {
  text-align: left; padding: 9px 10px; border-bottom: 1px solid var(--line); font-size: 14px;
}
.table th { color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: .04em; }
.table tbody tr:hover { background: var(--panel); }
.table td select { min-width: 200px; }

/* --- plan de feu --- */
.plan-wrap { display: grid; grid-template-columns: 260px 1fr; gap: 16px; margin-top: 14px; }
.palette { display: flex; flex-direction: column; gap: 8px; }
.palette-list {
  list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px;
  max-height: 420px; overflow-y: auto;
}
.palette-list li {
  background: var(--panel-2); border: 1px solid var(--line); border-radius: 8px;
  padding: 8px 10px; font-size: 12px; cursor: grab; line-height: 1.4;
}
.palette-list li:active { cursor: grabbing; }
.palette-list li:hover { border-color: var(--accent); }

.plan {
  position: relative; min-height: 440px; border-radius: var(--radius);
  border: 1px solid var(--line); background:
    linear-gradient(var(--panel) 1px, transparent 1px) 0 0 / 100% 40px,
    linear-gradient(90deg, var(--panel) 1px, transparent 1px) 0 0 / 40px 100%,
    var(--bg);
  overflow: auto;
}
.unit {
  position: absolute; width: 78px; min-height: 62px;
  background: var(--panel-2); border: 1px solid var(--line); border-radius: 8px;
  padding: 6px; font-size: 11px; line-height: 1.3; cursor: grab;
  display: flex; flex-direction: column; gap: 2px; user-select: none;
}
.unit:active { cursor: grabbing; }
.unit.over { border-color: var(--accent); box-shadow: 0 0 0 2px rgba(108,140,255,.35); }
.unit.replaced { border-color: var(--ok); }
.unit .addr { color: var(--muted); }
.unit .new { color: var(--ok); font-weight: 600; }

/* --- correspondances --- */
.map-group { margin-bottom: 22px; }
.map-head {
  display: flex; align-items: baseline; gap: 12px; flex-wrap: wrap;
  padding-left: 12px; border-left: 4px solid var(--accent); margin-bottom: 10px;
}
.map-head h3 { margin: 0; font-size: 16px; }
.badge {
  font-size: 11px; padding: 2px 8px; border-radius: 999px;
  background: var(--panel-2); color: var(--muted); border: 1px solid var(--line);
}
.badge-auto { color: var(--ok); border-color: var(--ok); }
.badge-confirm { color: var(--warn); border-color: var(--warn); }
.badge-drop { color: var(--ko); border-color: var(--ko); }
.badge-new { color: var(--accent); border-color: var(--accent); }
.reason { color: var(--muted); font-size: 12px; }

/* --- ecran d'acces --- */
.login-shell { min-height: 100vh; display: grid; place-items: center; padding: 20px; }
.login-card {
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 28px; max-width: 420px; text-align: center;
}
.login-card h1 { margin: 0 0 10px; }

@media (max-width: 900px) {
  .app-shell { flex-direction: column; }
  .sidebar { width: auto; flex: none; }
  .plan-wrap { grid-template-columns: 1fr; }
}
