/* =========================================================
   1. VARIABLES & BASE
   ========================================================= */
:root {
  --bg: #0b1018;
  --panel: #111a27;
  --panel2: #172334;
  --line: #26364a;
  --text: #e8eef7;
  --muted: #91a1b6;
  --blue: #3478d4;
  --green: #35bd7a;
  --orange: #e8a343;
  --purple: #a78bfa;
  --red: #e36b6b;
}

* { box-sizing: border-box; }

[hidden] { display: none !important; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 14px/1.45 Inter, "Segoe UI", Arial, sans-serif;
}

.muted   { color: var(--muted); }
.c-green { color: var(--green); }
.c-blue  { color: #8fc4ff; }
.mono    { font: 700 12px ui-monospace, monospace; color: #b8d7ff; }

/* =========================================================
   2. EN-TÊTE
   ========================================================= */
header {
  position: sticky;
  top: 0;
  z-index: 5;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 18px 24px;
  background: #0e1724;
  border-bottom: 1px solid var(--line);
}

.brand { display: flex; align-items: center; gap: 13px; }

.logo {
  width: 42px;
  height: 42px;
  display: grid;
  place-items: center;
  border: 1px solid #3a5c83;
  border-radius: 10px;
  color: #80b6ff;
  font-weight: 900;
  font-size: 20px;
}

.eyebrow { color: #7f9ab9; font-size: 10px; letter-spacing: 2px; font-weight: 800; }
.brand h1 { margin: 1px 0 0; font-size: 20px; letter-spacing: 1px; }

.headright { text-align: right; }
.live  { color: #55d994; font-size: 11px; font-weight: 800; letter-spacing: 1px; }
.clock { font: 600 18px ui-monospace, monospace; }

/* =========================================================
   3. MISE EN PAGE & PANNEAUX
   ========================================================= */
main {
  max-width: 1500px;
  margin: auto;
  padding: 22px;
  display: grid;
  gap: 18px;
}

.stats {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
}

.stat,
.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 12px;
}

.stat { padding: 15px 17px; }
.stat small  { color: var(--muted); font-weight: 700; letter-spacing: 1px; font-size: 10px; }
.stat strong { display: block; margin-top: 5px; font-size: 27px; }

.panel { padding: 17px; }

.section-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin-bottom: 14px;
}
.section-head h2 { margin: 0; font-size: 14px; letter-spacing: 1px; }
.section-head p  { margin: 4px 0 0; color: var(--muted); font-size: 12px; }

.footer {
  display: flex;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
  padding: 0 3px;
  color: var(--muted);
  font-size: 11px;
}

.empty {
  padding: 20px;
  text-align: center;
  color: var(--muted);
  font-size: 12px;
  border: 1px dashed var(--line);
  border-radius: 8px;
}

/* =========================================================
   4. BOUTONS & FILTRES
   ========================================================= */
button, input, select, textarea { font: inherit; }

button {
  cursor: pointer;
  padding: 9px 12px;
  background: var(--panel2);
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: 7px;
  font-weight: 700;
  font-size: 12px;
}
button:hover { filter: brightness(1.15); }

button.primary { background: var(--blue); border-color: var(--blue); color: #fff; }
button.danger  { background: #321e27; border-color: #713c46; color: #ffaaaa; }
button.small   { padding: 6px 8px; font-size: 11px; }

.filters { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 10px; }
.filters button.active { background: #203b5b; border-color: #477db8; color: #b9d9ff; }

/* =========================================================
   5. TABLEAU DES EFFECTIFS
   ========================================================= */
.tablewrap { overflow-x: auto; }

table { width: 100%; min-width: 700px; border-collapse: collapse; }

th {
  padding: 10px;
  text-align: left;
  color: var(--muted);
  font-size: 10px;
  letter-spacing: 1px;
  border-bottom: 1px solid var(--line);
}

td { padding: 11px 10px; font-size: 13px; border-bottom: 1px solid #202d3d; }
tr:last-child td { border-bottom: 0; }

.status-select { max-width: 145px; padding: 7px; }

/* Badges de statut */
.badge {
  display: inline-flex;
  padding: 4px 7px;
  border-radius: 5px;
  font-size: 10px;
  font-weight: 800;
  letter-spacing: .4px;
  white-space: nowrap;
}
.b-inter    { background: #173d30; color: #61dfa0; }
.b-pause    { background: #45351e; color: #ffc36b; }
.b-attente  { background: #1d3551; color: #8fc4ff; }
.b-balisage { background: #352b50; color: #c6aaff; }
.b-service    { background: #123a3d; color: #5fe0e6; }
.b-hs         { background: #2a303a; color: #a9b4c4; }
.b-run        { background: #4a2540; color: #ff9ad5; }
.b-indispo    { background: #4a2228; color: #ff8f8f; }
.b-encours  { background: #1d3551; color: #8fc4ff; }
.b-terminee { background: #173d30; color: #61dfa0; }

/* =========================================================
   6. CARTES D'APPELS
   ========================================================= */
.callgrid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.callcard {
  min-width: 0;
  padding: 13px;
  background: #0e1724;
  border: 1px solid var(--line);
  border-radius: 10px;
}

.calltop   { display: flex; justify-content: space-between; align-items: flex-start; gap: 10px; }
.calltitle { font-weight: 800; }
.callmeta  { margin-top: 4px; font-size: 11px; color: var(--muted); }
.callinfo  { margin: 10px 0; font-size: 12px; color: #b4c1d0; }
.unitline  { padding-top: 9px; font-size: 11px; color: #b9c9dc; border-top: 1px solid var(--line); }

.callactions { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 11px; }
.call-select { width: auto; max-width: 140px; padding: 7px; }

/* =========================================================
   7. FORMULAIRES & MODALES
   ========================================================= */
.formgrid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.field { display: grid; gap: 5px; color: #aab8c9; font-size: 11px; font-weight: 700; }
.field.full { grid-column: 1 / -1; }

input, select, textarea {
  width: 100%;
  padding: 10px;
  background: #0c1420;
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: 7px;
  outline: none;
}
input:focus, select:focus, textarea:focus { border-color: #5793d7; }
textarea { min-height: 65px; resize: vertical; }

.checks { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 5px; }
.check {
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 7px 9px;
  color: var(--text);
  font-size: 12px;
  border: 1px solid var(--line);
  border-radius: 7px;
}
.check input { width: auto; }

.modal {
  position: fixed;
  inset: 0;
  z-index: 10;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 18px;
  background: #03070dcc;
}
.modal.show { display: flex; }

.dialog {
  width: min(620px, 100%);
  max-height: 90vh;
  overflow: auto;
  padding: 20px;
  background: var(--panel);
  border: 1px solid #354a63;
  border-radius: 14px;
  box-shadow: 0 20px 80px #0009;
}
.dialog h3 { margin: 0 0 16px; font-size: 16px; }

.actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 16px; }

/* =========================================================
   8. NOTIFICATION (TOAST)
   ========================================================= */
.toast {
  position: fixed;
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 20;
  display: none;
  padding: 10px 16px;
  background: #203b5b;
  color: #eaf4ff;
  border: 1px solid #477db8;
  border-radius: 8px;
}

/* =========================================================
   9. RESPONSIVE
   ========================================================= */
@media (max-width: 800px) {
  header { padding: 13px; }
  main   { padding: 13px; }
  .stats { grid-template-columns: repeat(2, 1fr); }
  .callgrid, .formgrid { grid-template-columns: 1fr; }
  .field.full { grid-column: auto; }
}
