:root {
  --navy: #242f3a;
  --navy-light: #34455a;
  --brand-blue: #68b4e5;
  --brand-blue-dark: #4a93c9;
  --status-ok: #5a9c1f;
  --status-ok-dot: #6fb52c;
  --amber: #f0a63a;
  --red: #e0533d;
  --grey-bg: #f4f6f4;
  --card-bg: #ffffff;
  --text-main: #242f3a;
  --text-muted: #66727c;
  --radius: 14px;
  --font-display: 'Inter', 'Inter Fallback', system-ui, sans-serif;
  --font-body: 'Inter', 'Inter Fallback', system-ui, sans-serif;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: var(--font-body);
  background: var(--grey-bg);
  color: var(--text-main);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.topbar {
  background: var(--navy);
  color: white;
  padding: 14px 24px;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 16px;
  row-gap: 8px;
}

.topbar .brand-logo {
  height: 40px;
  width: auto;
  display: block;
}

.topbar h1 {
  font-family: var(--font-display);
  font-size: 1.05rem;
  margin: 0;
  letter-spacing: 0.2px;
  border-left: 1px solid rgba(255,255,255,0.25);
  padding-left: 16px;
}

/* Le nouveau logo Véligo Location est nettement plus large que l'ancien
   (bande logo + "Un service Île-de-France mobilités") : sur petit écran,
   on le réduit et on laisse les liens de navigation passer sur leur propre
   ligne plutôt que de forcer un défilement horizontal. */
@media (max-width: 480px) {
  .topbar {
    padding: 10px 16px;
    gap: 8px;
  }
  .topbar .brand-logo {
    height: 26px;
  }
  .topbar h1 {
    font-size: 0.82rem;
    padding-left: 10px;
    white-space: nowrap;
  }
  .admin-link:first-of-type {
    margin-left: 0;
  }
  .admin-link {
    margin-left: 0;
    margin-right: 14px;
    font-size: 0.72rem;
  }
}

main {
  flex: 1;
  display: flex;
  justify-content: center;
  padding: 32px 16px 60px;
}

.panel {
  width: 100%;
  max-width: 440px;
}

.panel h2 {
  font-family: var(--font-display);
  font-size: 1.5rem;
  margin: 0 0 6px;
}

.panel p.sub {
  color: var(--text-muted);
  margin: 0 0 24px;
  font-size: 0.95rem;
}

.search-card {
  background: var(--card-bg);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: 0 2px 10px rgba(22, 35, 46, 0.06);
}

label {
  display: block;
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-bottom: 8px;
}

.input-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

input#bikeId {
  flex: 1;
  padding: 14px 16px;
  border-radius: 10px;
  border: 1.5px solid #dde2de;
  font-size: 1.05rem;
  font-family: var(--font-display);
  letter-spacing: 0.03em;
  outline: none;
  transition: border-color 0.15s;
}

input#bikeId:focus {
  border-color: var(--brand-blue-dark);
}

button#searchBtn {
  background: var(--navy);
  color: white;
  border: none;
  border-radius: 10px;
  padding: 0 20px;
  font-family: var(--font-display);
  font-size: 0.95rem;
  cursor: pointer;
  transition: background 0.15s;
}

button#searchBtn:hover { background: var(--navy-light); }
button#searchBtn:disabled { opacity: 0.6; cursor: default; }

.hint {
  margin-top: 10px;
  font-size: 0.8rem;
  color: var(--text-muted);
}

#result {
  margin-top: 22px;
}

.status-card {
  border-radius: var(--radius);
  padding: 22px;
  display: flex;
  align-items: center;
  gap: 16px;
  animation: rise 0.25s ease;
}

@keyframes rise {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}

.status-dot {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  flex-shrink: 0;
}

.status-text .id {
  font-family: var(--font-display);
  font-size: 0.82rem;
  color: var(--text-muted);
  letter-spacing: 0.04em;
}

.status-text .label {
  font-family: var(--font-display);
  font-size: 1.25rem;
  font-weight: 600;
}

.category-message {
  font-size: 0.85rem;
  color: var(--text-main);
  opacity: 0.75;
  margin-top: 4px;
  white-space: pre-line;
}

.status-ok    { background: #d4edad; }
.status-warn  { background: #fbdca6; }
.status-bad   { background: #f5c2b8; }
.status-ok .status-dot   { background: var(--status-ok-dot); }
.status-warn .status-dot { background: var(--amber); }
.status-bad .status-dot  { background: var(--red); }

.error-card {
  border-radius: var(--radius);
  padding: 18px 22px;
  background: #fbe6e2;
  color: #8a2f1f;
  font-size: 0.95rem;
}

.spinner {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--text-muted);
  font-size: 0.9rem;
  padding: 10px 2px;
}

.spinner .ring {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  border: 3px solid #dde2de;
  border-top-color: var(--navy);
  animation: spin 0.7s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

footer {
  text-align: center;
  color: var(--text-muted);
  font-size: 0.78rem;
  padding: 18px;
}

footer.branded {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
}

footer.branded img {
  height: 22px;
  width: auto;
  opacity: 0.85;
}

@media (min-width: 640px) {
  main { padding-top: 64px; }
  .panel h2 { font-size: 1.75rem; }
}

/* --- Version ordinateur : utilise mieux la largeur disponible.
   La page publique reste raisonnablement centrée (simple recherche),
   l'admin et l'espace Forces de l'ordre s'élargissent davantage (tableaux,
   listes de demandes). --- */
@media (min-width: 900px) {
  .panel { max-width: 620px; }
  body.page-admin .panel,
  body.page-police .panel { max-width: 900px; }

  .topbar { padding: 16px 40px; }
  main { padding-left: 24px; padding-right: 24px; }

  /* Sur grand écran, les infos de recherche + résultat peuvent se répartir
     côte à côte plutôt que de s'empiler indéfiniment en une seule colonne
     étroite tirée en longueur. */
  body.page-admin .search-card,
  body.page-police .search-card {
    padding: 24px;
  }

  .history-table th, .history-table td { padding: 10px 12px; }

  #requestsBox {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(340px, 1fr));
    gap: 14px;
    align-items: start;
  }
  #requestsBox .request-card { margin-bottom: 0; }
  #requestsBox > .hint { grid-column: 1 / -1; }
}

/* --- Ajouts pour la version Excel / interface admin --- */

.update-banner {
  margin-bottom: 18px;
  font-size: 0.82rem;
  color: var(--text-muted);
  background: #eef1ee;
  border-radius: 10px;
  padding: 10px 14px;
}

.update-banner a {
  color: var(--brand-blue-dark);
  font-weight: 600;
  text-decoration: underline;
}

.admin-link {
  margin-left: 18px;
  font-size: 0.78rem;
  color: #ffffff;
  text-decoration: none;
  opacity: 1;
}
.admin-link:first-of-type { margin-left: auto; }
.admin-link:hover { opacity: 1; }

.field {
  margin-bottom: 16px;
}

input[type="password"], input[type="file"] {
  width: 100%;
  padding: 12px 14px;
  border-radius: 10px;
  border: 1.5px solid #dde2de;
  font-size: 1rem;
  font-family: var(--font-body);
  background: white;
}

button.primary {
  width: 100%;
  background: var(--navy);
  color: white;
  border: none;
  border-radius: 10px;
  padding: 13px;
  font-family: var(--font-display);
  font-size: 0.95rem;
  cursor: pointer;
}
button.primary:hover { background: var(--navy-light); }
button.primary:disabled { opacity: 0.6; cursor: default; }

.info-box {
  background: var(--card-bg);
  border-radius: var(--radius);
  padding: 18px 20px;
  box-shadow: 0 2px 10px rgba(22, 35, 46, 0.06);
  margin-bottom: 20px;
  font-size: 0.9rem;
  color: var(--text-muted);
}
.info-box strong { color: var(--text-main); }

.success-card {
  border-radius: var(--radius);
  padding: 16px 20px;
  background: #eef9dc;
  color: #3c5a12;
  font-size: 0.9rem;
}

/* --- Onglets admin --- */

.tabs {
  display: flex;
  gap: 4px;
  background: #e6e9e5;
  border-radius: 10px;
  padding: 4px;
  margin-bottom: 24px;
}

.tab-btn {
  flex: 1;
  border: none;
  background: transparent;
  padding: 10px 8px;
  border-radius: 8px;
  font-family: var(--font-display);
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-muted);
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.tab-btn.active {
  background: var(--card-bg);
  color: var(--text-main);
  box-shadow: 0 1px 4px rgba(22, 35, 46, 0.1);
}

#unreadBadge {
  display: inline-block;
  background: var(--red);
  color: white;
  font-size: 0.68rem;
  font-weight: 700;
  border-radius: 999px;
  padding: 1px 6px;
  margin-left: 5px;
}

.message-item {
  padding: 14px;
  border-radius: 10px;
  margin-bottom: 10px;
  border: 1px solid #e6e9e5;
  white-space: pre-line;
  font-size: 0.9rem;
}
.message-item.unread { border-color: var(--brand-blue-dark); background: #f4f9fd; }
.message-item .message-meta {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-bottom: 6px;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}
.message-item.type-accepted .message-meta { color: var(--status-ok-dot); }
.message-item.type-rejected .message-meta { color: var(--red); }

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

/* --- Historique des imports --- */

.history-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.85rem;
  table-layout: fixed;
}

.history-table th,
.history-table td {
  overflow-wrap: anywhere;
}

.history-table th {
  text-align: left;
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-muted);
  padding: 0 8px 8px;
  border-bottom: 1px solid #e6e9e5;
}

.history-table td {
  padding: 10px 8px;
  border-bottom: 1px solid #f0f2ef;
}

.history-table tr:last-child td { border-bottom: none; }

.history-table .count {
  font-family: var(--font-display);
  font-weight: 600;
}

/* --- Options "en location" --- */

.rental-buttons {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

button.secondary {
  width: 100%;
  background: var(--card-bg);
  color: var(--text-main);
  border: 1.5px solid #dde2de;
  border-radius: 10px;
  padding: 12px;
  font-family: var(--font-display);
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
}
button.secondary:hover {
  border-color: var(--brand-blue-dark);
  background: #f4f9fd;
}

.checkbox-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 0;
}
.checkbox-row input[type="checkbox"] {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
}
.checkbox-row label {
  font-size: 0.9rem;
  font-weight: 400;
  color: var(--text-main);
  text-transform: none;
  letter-spacing: normal;
  margin: 0;
  cursor: pointer;
}

/* --- Liste des comptes Police --- */

.police-account-row {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: center;
  padding: 12px 4px;
  border-bottom: 1px solid #f0f2ef;
  gap: 10px;
}
.police-account-row:last-child { border-bottom: none; }

.police-account-info {
  min-width: 0;
  overflow-wrap: anywhere;
}

.police-account-info .name {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 0.92rem;
}
.police-account-info .id {
  font-size: 0.78rem;
  color: var(--text-muted);
}

.police-account-actions {
  display: flex;
  gap: 6px;
  flex-shrink: 0;
}

.icon-btn {
  border: 1.5px solid #dde2de;
  background: white;
  border-radius: 8px;
  padding: 6px 10px;
  font-size: 0.78rem;
  cursor: pointer;
  font-family: var(--font-body);
}
.icon-btn:hover { border-color: var(--brand-blue-dark); }
.icon-btn.danger:hover { border-color: var(--red); color: #8a2f1f; }

#requestsBadge {
  display: inline-block;
  background: var(--red);
  color: white;
  font-size: 0.68rem;
  font-weight: 700;
  border-radius: 999px;
  padding: 1px 6px;
  margin-left: 5px;
}

.request-card {
  border: 1px solid #e6e9e5;
  border-radius: 10px;
  padding: 14px;
  margin-bottom: 12px;
}
.request-card .request-meta {
  font-size: 0.78rem;
  color: var(--text-muted);
  margin-bottom: 6px;
}
.request-card .request-info {
  font-size: 0.9rem;
  margin-bottom: 10px;
}
.request-card .request-actions {
  display: flex;
  gap: 8px;
}
.request-card .request-actions button {
  flex: 1;
}
.btn-accept {
  background: var(--status-ok-dot);
  color: white;
  border: none;
  border-radius: 10px;
  padding: 10px;
  font-family: var(--font-display);
  font-weight: 600;
  cursor: pointer;
}
.btn-reject {
  background: white;
  color: var(--red);
  border: 1.5px solid var(--red);
  border-radius: 10px;
  padding: 10px;
  font-family: var(--font-display);
  font-weight: 600;
  cursor: pointer;
}

