/* =============================================================================
   dashboard.gyromap.fr — Style pro (cohérent avec editor mais finition +)
   ============================================================================= */

:root {
  --bg: #0A0E27;
  --bg-2: #0D1230;
  --bg-card: #131836;
  --bg-card-2: #161B3D;
  --bg-input: #1A2048;
  --border: #2A3158;
  --border-light: #353D6B;
  --text: #E8EBF7;
  --text-muted: #8B92AB;
  --text-dim: #5C6488;
  --primary: #5B8DEF;
  --primary-hover: #6B9DFF;
  --primary-dim: #5B8DEF22;
  --success: #34C759;
  --warning: #FF9500;
  --danger: #FF3B30;
  --purple: #AF52DE;
  --radius-sm: 8px;
  --radius: 12px;
  --radius-lg: 18px;
  --shadow: 0 4px 24px rgba(0,0,0,0.35);
  --shadow-lg: 0 12px 48px rgba(0,0,0,0.5);
  --sidebar-w: 248px;
}

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

html, body {
  background:
    radial-gradient(1200px 600px at 80% -10%, #16204d33, transparent),
    radial-gradient(900px 500px at 0% 100%, #1b1740aa, transparent),
    var(--bg);
  background-attachment: fixed;
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Inter", "Helvetica Neue", Arial, sans-serif;
  min-height: 100vh;
  line-height: 1.5;
  font-size: 14.5px;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--primary); text-decoration: none; }
a:hover { color: var(--primary-hover); }

h1,h2,h3 { font-weight: 700; letter-spacing: -0.01em; }
h1 { font-size: 24px; }
h2 { font-size: 18px; }
h3 { font-size: 15px; }

.muted { color: var(--text-muted); }
.dim { color: var(--text-dim); }
.small { font-size: 12.5px; }
.mono { font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace; }

/* ===== Boutons ===== */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  background: var(--primary); color: #fff; border: 0;
  padding: 10px 18px; border-radius: var(--radius-sm);
  font-size: 14px; font-weight: 600; cursor: pointer;
  transition: all .15s ease; white-space: nowrap;
}
.btn:hover { background: var(--primary-hover); transform: translateY(-1px); }
.btn:active { transform: translateY(0); }
.btn:disabled { opacity: .5; cursor: not-allowed; transform: none; }
.btn.secondary { background: var(--bg-input); color: var(--text); border: 1px solid var(--border); }
.btn.secondary:hover { background: var(--bg-card-2); border-color: var(--border-light); }
.btn.danger { background: var(--danger); }
.btn.danger:hover { background: #ff5147; }
.btn.success { background: var(--success); }
.btn.ghost { background: transparent; color: var(--text-muted); }
.btn.ghost:hover { background: var(--bg-input); color: var(--text); }
.btn.sm { padding: 6px 12px; font-size: 13px; }
.btn.block { width: 100%; }

/* ===== Inputs ===== */
.field { margin-bottom: 16px; }
.field label {
  display: block; font-size: 12px; font-weight: 600; text-transform: uppercase;
  letter-spacing: .04em; color: var(--text-muted); margin-bottom: 6px;
}
input[type=text], input[type=email], input[type=password], input[type=number],
input[type=date], select, textarea {
  width: 100%; background: var(--bg-input); border: 1px solid var(--border);
  color: var(--text); padding: 11px 13px; border-radius: var(--radius-sm);
  font-size: 14px; font-family: inherit; transition: border-color .15s;
}
input:focus, select:focus, textarea:focus {
  outline: none; border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-dim);
}
input::placeholder { color: var(--text-dim); }
select { cursor: pointer; }

/* ===== Cards ===== */
.card {
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 20px; box-shadow: var(--shadow);
}
.card.flat { box-shadow: none; }

/* ===== Badges / pills ===== */
.pill {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 3px 10px; border-radius: 20px; font-size: 12px; font-weight: 600;
}
.pill.actif { background: #34C75922; color: var(--success); }
.pill.essai { background: #5B8DEF22; color: var(--primary); }
.pill.suspendu { background: #FF950022; color: var(--warning); }
.pill.expire { background: #FF3B3022; color: var(--danger); }
.pill.dot::before { content: "●"; font-size: 8px; }

.tag {
  display: inline-block; padding: 2px 8px; border-radius: 6px;
  font-size: 11px; font-weight: 600; background: var(--bg-input); color: var(--text-muted);
}
.tag.admin { background: #FF950022; color: var(--warning); }
.tag.operateur { background: #5B8DEF22; color: var(--primary); }

/* ===== Tables ===== */
table { width: 100%; border-collapse: collapse; }
th {
  text-align: left; font-size: 11px; text-transform: uppercase; letter-spacing: .04em;
  color: var(--text-dim); font-weight: 600; padding: 10px 12px; border-bottom: 1px solid var(--border);
}
td { padding: 12px; border-bottom: 1px solid var(--border); font-size: 14px; vertical-align: middle; }
tr:last-child td { border-bottom: 0; }
tbody tr { transition: background .12s; }
tbody tr:hover { background: var(--bg-card-2); }

/* ===== Login ===== */
.login-wrap {
  min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 24px;
}
.login-box { width: 100%; max-width: 400px; }
.login-logo { text-align: center; margin-bottom: 28px; }
.login-logo .mark { font-size: 30px; font-weight: 800; letter-spacing: -.02em; }
.login-logo .mark span { color: var(--primary); }
.login-logo .sub { color: var(--text-muted); font-size: 13px; margin-top: 4px; }
.login-tabs { display: flex; gap: 4px; background: var(--bg-input); padding: 4px; border-radius: var(--radius-sm); margin-bottom: 20px; }
.login-tabs button {
  flex: 1; background: transparent; border: 0; color: var(--text-muted);
  padding: 9px; border-radius: 6px; font-size: 13px; font-weight: 600; cursor: pointer; transition: all .15s;
}
.login-tabs button.active { background: var(--primary); color: #fff; }

/* ===== Layout app (sidebar + main) ===== */
.layout { display: flex; min-height: 100vh; }
.sidebar {
  width: var(--sidebar-w); background: var(--bg-2); border-right: 1px solid var(--border);
  display: flex; flex-direction: column; position: fixed; top: 0; bottom: 0; left: 0; z-index: 50;
}
.sidebar .brand { padding: 20px; font-size: 19px; font-weight: 800; border-bottom: 1px solid var(--border); }
.sidebar .brand span { color: var(--primary); }
.sidebar .brand .badge {
  display: inline-block; font-size: 10px; font-weight: 700; text-transform: uppercase;
  background: var(--purple); color: #fff; padding: 2px 7px; border-radius: 6px; margin-left: 6px; vertical-align: middle;
}
.sidebar nav { flex: 1; padding: 12px; display: flex; flex-direction: column; gap: 2px; overflow-y: auto; }
.sidebar nav a {
  display: flex; align-items: center; gap: 11px; padding: 10px 12px; border-radius: var(--radius-sm);
  color: var(--text-muted); font-size: 14px; font-weight: 500; transition: all .12s;
}
.sidebar nav a:hover { background: var(--bg-input); color: var(--text); }
.sidebar nav a.active { background: var(--primary-dim); color: var(--primary); font-weight: 600; }
.sidebar nav a .ico { width: 18px; text-align: center; font-size: 16px; }
.sidebar .foot { padding: 14px; border-top: 1px solid var(--border); }
.sidebar .foot .who { font-size: 13px; font-weight: 600; }
.sidebar .foot .who .org { color: var(--text-muted); font-weight: 400; font-size: 12px; display: block; margin-top: 2px; }

.main { flex: 1; margin-left: var(--sidebar-w); display: flex; flex-direction: column; }
.topbar {
  height: 60px; border-bottom: 1px solid var(--border); display: flex; align-items: center;
  justify-content: space-between; padding: 0 28px; background: var(--bg-2cc); position: sticky; top: 0; z-index: 40;
  backdrop-filter: blur(8px); background: rgba(13,18,48,0.7);
}
.content { padding: 28px; flex: 1; }
.page-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 22px; gap: 16px; flex-wrap: wrap; }

/* Impersonation banner */
.imperso-banner {
  background: linear-gradient(90deg, #AF52DE33, #5B8DEF22);
  border: 1px solid var(--purple); border-radius: var(--radius-sm);
  padding: 10px 16px; margin-bottom: 20px; display: flex; align-items: center; justify-content: space-between;
  font-size: 13px;
}

/* ===== Stat cards ===== */
.stats-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 16px; margin-bottom: 24px; }
.stat {
  background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius); padding: 18px 20px;
}
.stat .label { font-size: 12px; color: var(--text-muted); text-transform: uppercase; letter-spacing: .04em; }
.stat .value { font-size: 30px; font-weight: 800; margin-top: 6px; letter-spacing: -.02em; }
.stat .value.primary { color: var(--primary); }
.stat .value.success { color: var(--success); }

/* ===== Grille générique ===== */
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
.grid-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 16px; }

/* ===== Modal ===== */
.modal-backdrop {
  position: fixed; inset: 0; background: rgba(5,7,20,0.7); backdrop-filter: blur(4px);
  display: none; align-items: center; justify-content: center; z-index: 200; padding: 24px;
}
.modal-backdrop.open { display: flex; }
.modal {
  background: var(--bg-card); border: 1px solid var(--border-light); border-radius: var(--radius-lg);
  padding: 26px; width: 100%; max-width: 480px; box-shadow: var(--shadow-lg); max-height: 90vh; overflow-y: auto;
}
.modal h2 { margin-bottom: 18px; }
.modal .actions { display: flex; gap: 10px; justify-content: flex-end; margin-top: 22px; }

/* ===== Carte live ===== */
.live-layout { display: grid; grid-template-columns: 1fr 320px; gap: 0; height: calc(100vh - 60px); }
#liveMap { width: 100%; height: 100%; background: var(--bg-input); }
.live-side { border-left: 1px solid var(--border); background: var(--bg-2); overflow-y: auto; padding: 16px; }
.live-side h3 { margin-bottom: 12px; }
.member-row {
  display: flex; align-items: center; gap: 11px; padding: 11px; border-radius: var(--radius-sm);
  background: var(--bg-card); border: 1px solid var(--border); margin-bottom: 8px; cursor: pointer; transition: all .12s;
}
.member-row:hover { border-color: var(--border-light); }
.member-row .dot { width: 12px; height: 12px; border-radius: 50%; flex-shrink: 0; }
.member-row.stale { opacity: .5; }
.member-row .info { flex: 1; min-width: 0; }
.member-row .info .name { font-weight: 600; font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.member-row .info .meta { font-size: 12px; color: var(--text-muted); }
.member-row .age { font-size: 11px; color: var(--text-dim); }

/* Marker véhicule sur la carte */
.veh-marker {
  width: 30px; height: 30px; border-radius: 50% 50% 50% 0; transform: rotate(-45deg);
  border: 2.5px solid #fff; box-shadow: 0 2px 8px rgba(0,0,0,.5); cursor: pointer;
  display: flex; align-items: center; justify-content: center;
}
.veh-marker .label { transform: rotate(45deg); font-size: 11px; font-weight: 800; color: #fff; }

/* ===== Toast ===== */
.toast {
  position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%) translateY(80px);
  background: var(--bg-card); border: 1px solid var(--border-light); color: var(--text);
  padding: 13px 20px; border-radius: var(--radius); box-shadow: var(--shadow-lg);
  font-size: 14px; z-index: 300; opacity: 0; transition: all .25s; pointer-events: none;
}
.toast.show { transform: translateX(-50%) translateY(0); opacity: 1; }
.toast.success { border-color: var(--success); }
.toast.error { border-color: var(--danger); }

/* ===== Code équipe (gros affichage) ===== */
.team-code {
  font-family: ui-monospace, "SF Mono", Menlo, monospace; font-size: 32px; font-weight: 800;
  letter-spacing: .15em; color: var(--primary); background: var(--bg-input);
  padding: 14px 24px; border-radius: var(--radius); text-align: center; border: 1px dashed var(--border-light);
}

/* ===== Permissions checkboxes ===== */
.perm-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.perm-row {
  display: flex; align-items: center; gap: 9px; padding: 9px 11px; background: var(--bg-input);
  border-radius: var(--radius-sm); font-size: 13px; cursor: pointer; border: 1px solid transparent;
}
.perm-row:hover { border-color: var(--border); }
.perm-row input { width: auto; }

/* ===== Color swatches ===== */
.swatch { display: inline-block; width: 14px; height: 14px; border-radius: 4px; vertical-align: middle; margin-right: 6px; border: 1px solid rgba(255,255,255,.2); }

/* ===== Empty state ===== */
.empty { text-align: center; padding: 50px 20px; color: var(--text-muted); }
.empty .ico { font-size: 40px; margin-bottom: 12px; opacity: .5; }

/* ===== Responsive ===== */
@media (max-width: 900px) {
  .sidebar { transform: translateX(-100%); transition: transform .2s; }
  .sidebar.open { transform: translateX(0); }
  .main { margin-left: 0; }
  .live-layout { grid-template-columns: 1fr; }
  .live-side { display: none; }
  .grid-2 { grid-template-columns: 1fr; }
}

/* Hamburger (mobile) */
.hamburger { display: none; background: none; border: 0; color: var(--text); font-size: 22px; cursor: pointer; }
@media (max-width: 900px) { .hamburger { display: block; } }

.hidden { display: none !important; }
.spinner {
  width: 18px; height: 18px; border: 2px solid var(--border); border-top-color: var(--primary);
  border-radius: 50%; animation: spin .7s linear infinite; display: inline-block;
}
@keyframes spin { to { transform: rotate(360deg); } }
.center-load { display: flex; align-items: center; justify-content: center; gap: 10px; padding: 40px; color: var(--text-muted); }
