*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg:        #0f1117;
  --bg2:       #1a1d27;
  --bg3:       #22263a;
  --border:    #2e3250;
  --accent:    #4ade80;
  --accent2:   #3b82f6;
  --warn:      #f59e0b;
  --danger:    #ef4444;
  --text:      #e2e8f0;
  --text-muted:#8892a4;
  --radius:    10px;
}

body {
  font-family: 'Segoe UI', system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  font-size: 14px;
}

/* ── Header ── */
header {
  background: var(--bg2);
  border-bottom: 1px solid var(--border);
  padding: 0 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 60px;
  position: sticky;
  top: 0;
  z-index: 100;
}

.logo {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 700;
  font-size: 18px;
  letter-spacing: -0.3px;
}

.logo-icon { font-size: 22px; }

.server-status {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: var(--text-muted);
}

.dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--danger);
  transition: background 0.3s;
}
.dot.ok { background: var(--accent); box-shadow: 0 0 8px var(--accent); }

/* ── Navigation ── */
nav {
  background: var(--bg2);
  border-bottom: 1px solid var(--border);
  display: flex;
  padding: 0 24px;
  gap: 4px;
}

.tab-btn {
  background: none;
  border: none;
  color: var(--text-muted);
  padding: 14px 18px;
  cursor: pointer;
  font-size: 14px;
  font-weight: 500;
  border-bottom: 2px solid transparent;
  transition: color 0.2s, border-color 0.2s;
}
.tab-btn:hover { color: var(--text); }
.tab-btn.active { color: var(--accent); border-bottom-color: var(--accent); }

/* ── Layout ── */
main { padding: 24px; max-width: 1400px; margin: 0 auto; }

.tab-panel { display: none; }
.tab-panel.active { display: block; }

/* ── Stat cards ── */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}

.stat-card {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
}

.stat-card .label {
  font-size: 12px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 8px;
}

.stat-card .value {
  font-size: 28px;
  font-weight: 700;
  line-height: 1;
}

.stat-card .value.green  { color: var(--accent); }
.stat-card .value.blue   { color: var(--accent2); }
.stat-card .value.yellow { color: var(--warn); }

/* ── Cards / panels ── */
.card {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-bottom: 20px;
  overflow: hidden;
}

.card-header {
  padding: 14px 20px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-weight: 600;
  font-size: 14px;
}

.card-body { padding: 0; }

/* ── Tables ── */
table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

th {
  background: var(--bg3);
  color: var(--text-muted);
  font-weight: 600;
  text-transform: uppercase;
  font-size: 11px;
  letter-spacing: 0.4px;
  padding: 10px 16px;
  text-align: left;
  border-bottom: 1px solid var(--border);
}

td {
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}

tr:last-child td { border-bottom: none; }
tr:hover td { background: var(--bg3); }

.empty-row td {
  text-align: center;
  color: var(--text-muted);
  padding: 32px;
}

/* ── Badges ── */
.badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 600;
}
.badge-green  { background: #14532d; color: #4ade80; }
.badge-blue   { background: #1e3a5f; color: #60a5fa; }
.badge-yellow { background: #451a03; color: #fbbf24; }
.badge-red    { background: #450a0a; color: #f87171; }
.badge-gray   { background: #1e293b; color: #94a3b8; }

/* ── Bornes connectées ── */
.bornes-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 12px;
  padding: 16px;
}

.borne-card {
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 16px;
  display: flex;
  align-items: center;
  gap: 12px;
}

.borne-icon { font-size: 28px; }
.borne-name { font-weight: 600; font-size: 14px; }
.borne-sub  { font-size: 12px; color: var(--text-muted); margin-top: 2px; }

/* ── Forms ── */
.form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 12px;
  padding: 16px;
}

.form-group { display: flex; flex-direction: column; gap: 6px; }

label { font-size: 12px; color: var(--text-muted); font-weight: 500; }

input, select {
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text);
  padding: 8px 12px;
  font-size: 13px;
  outline: none;
  transition: border-color 0.2s;
}
input:focus, select:focus { border-color: var(--accent2); }

.form-actions {
  padding: 0 16px 16px;
  display: flex;
  gap: 8px;
}

/* ── Buttons ── */
.btn {
  padding: 8px 16px;
  border-radius: 6px;
  border: none;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: opacity 0.2s, transform 0.1s;
}
.btn:active { transform: scale(0.97); }

.btn-primary { background: var(--accent2); color: #fff; }
.btn-success { background: #166534; color: var(--accent); }
.btn-danger  { background: #7f1d1d; color: #fca5a5; border: 1px solid #ef4444; }
.btn-ghost   { background: var(--bg3); color: var(--text-muted); border: 1px solid var(--border); }
.btn:disabled { opacity: 0.4; cursor: not-allowed; }

/* ── Pagination ── */
.pagination {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 14px;
  border-top: 1px solid var(--border);
  font-size: 13px;
  color: var(--text-muted);
}

/* ── Filtres ── */
.filters {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
  align-items: flex-end;
}

.filters .form-group { min-width: 140px; }

/* ── Toast ── */
#toast-container {
  position: fixed;
  bottom: 24px;
  right: 24px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  z-index: 9999;
}

.toast {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 12px 16px;
  font-size: 13px;
  max-width: 320px;
  animation: slideIn 0.2s ease;
  box-shadow: 0 4px 20px rgba(0,0,0,0.4);
}
.toast.success { border-left: 3px solid var(--accent); }
.toast.error   { border-left: 3px solid var(--danger); }

@keyframes slideIn {
  from { transform: translateX(20px); opacity: 0; }
  to   { transform: translateX(0);    opacity: 1; }
}

/* ── Refresh indicator ── */
.refresh-info {
  font-size: 12px;
  color: var(--text-muted);
}

/* ── Bouton suppression définitive ── */
.btn-delete   { background: #450a0a; color: #f87171; border: 1px solid #b91c1c; }
.btn-warning  { background: #451a03; color: #fbbf24; border: 1px solid #f59e0b; }

/* ── Modale modification employé ── */
#modal-fond {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.65);
  z-index: 200;
}

#modal-modifier {
  display: none;
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  z-index: 201;
  width: calc(100% - 32px);
  max-width: 520px;
  max-height: 90vh;
  overflow-y: auto;
}

.modal-entete {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 20px;
  border-bottom: 1px solid var(--border);
  font-weight: 600;
  font-size: 14px;
}

/* ── Boutons d'action dans le tableau des bornes ── */
.actions-cell { white-space: nowrap; }

/* Boutons compacts pour Redémarrer / Renommer / Ampérage */
.btn-borne-action {
  padding: 4px 8px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--bg3);
  color: var(--text);
  font-size: 12px;
  cursor: pointer;
  margin-right: 4px;
  transition: background .15s, border-color .15s;
}
.btn-borne-action:hover  { background: var(--border); }
.btn-borne-action:active { opacity: .75; }
.btn-reset   { color: var(--warn); border-color: var(--warn); }
.btn-rename  { color: var(--accent2); border-color: var(--accent2); }
.btn-amperage { color: var(--accent);  border-color: var(--accent); }

/* Menu contextuel — survol des options */
#ctx-menu button:hover {
  background: var(--bg3);
}

/* ── Cartes organisations (superadmin) ── */
.orgs-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 12px;
  padding: 16px;
}

.org-card {
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  cursor: pointer;
  transition: border-color .15s, transform .1s;
  user-select: none;
}
.org-card:hover { border-color: var(--accent2); transform: translateY(-1px); }
.org-card.actif { border-color: var(--accent);  background: rgba(74,222,128,.05); }

.org-card-nom   { font-weight: 700; font-size: 14px; margin-bottom: 10px; }
.org-card-stats { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 8px; }
.org-card-total { font-size: 12px; color: var(--text-muted); }

/* ── Responsive ── */
@media (max-width: 640px) {
  main { padding: 12px; }
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
  th, td { padding: 8px 10px; }
}
