* {
  box-sizing: border-box;
}

html, body {
  margin: 0;
  height: 100%;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  color: #1f2430;
}

#app {
  height: 100vh;
  position: relative;
  overflow: hidden;
}

/* La carte occupe tout l'écran ; le panneau flotte par-dessus. */
#map {
  position: absolute;
  inset: 0;
}

#panel {
  position: absolute;
  top: 16px;
  left: 16px;
  bottom: 16px;
  width: 300px;
  padding: 20px;
  overflow-y: auto;
  overflow-x: hidden;
  border-radius: 16px;
  border: 1px solid rgba(255, 255, 255, 0.5);
  background: rgba(250, 251, 252, 0.6);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  box-shadow: 0 8px 30px rgba(0, 0, 0, 0.18);
  z-index: 500;
  transition: transform 0.25s ease, opacity 0.25s ease;
}

#app.panel-collapsed #panel {
  transform: translateX(calc(-100% - 32px));
  opacity: 0;
  pointer-events: none;
}

#panel-toggle {
  position: absolute;
  top: 16px;
  left: 332px;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  border: 1px solid #d7dbe3;
  background: white;
  color: #2563eb;
  font-size: 22px;
  line-height: 1;
  cursor: pointer;
  z-index: 600;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
  transition: left 0.25s ease;
}

#app.panel-collapsed #panel-toggle {
  left: 16px;
}

#panel h1 {
  font-size: 18px;
  margin: 0;
}

#user-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
  flex-wrap: wrap;
  gap: 4px;
}

#user-email {
  font-size: 11px;
  color: #5b6472;
  margin-right: 8px;
}

.link-btn {
  border: none;
  background: none;
  color: #2563eb;
  font-size: 11px;
  cursor: pointer;
  padding: 0;
}

#login-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #fafbfc;
}

.login-card {
  width: 320px;
  padding: 28px;
  background: white;
  border: 1px solid #e2e5eb;
  border-radius: 10px;
  box-shadow: 0 2px 12px rgba(0, 0, 0, 0.06);
}

.login-card h1 {
  font-size: 20px;
  margin: 0 0 8px;
}

.login-hint {
  font-size: 12px;
  color: #5b6472;
  margin: 0 0 20px;
}

.login-card label {
  display: block;
  font-size: 12px;
  color: #5b6472;
  margin-bottom: 12px;
}

.login-card input {
  display: block;
  width: 100%;
  margin-top: 4px;
  padding: 8px 10px;
  border: 1px solid #d7dbe3;
  border-radius: 6px;
  font-size: 14px;
}

.login-card button {
  width: 100%;
  padding: 10px;
  margin-top: 8px;
  background: #2563eb;
  color: white;
  border: none;
  border-radius: 6px;
  font-size: 14px;
  cursor: pointer;
}

.login-error {
  color: #dc2626;
  font-size: 12px;
  margin: 12px 0 0;
  min-height: 14px;
}

#sync-box {
  margin-bottom: 20px;
  padding-bottom: 16px;
  border-bottom: 1px solid #e2e5eb;
}

#sync-btn {
  width: 100%;
  padding: 8px 12px;
  background: #2563eb;
  color: white;
  border: none;
  border-radius: 6px;
  font-size: 14px;
  cursor: pointer;
}

#sync-btn:disabled {
  background: #93b4f0;
  cursor: not-allowed;
}

#sync-status {
  margin: 8px 0 0;
  font-size: 12px;
  color: #5b6472;
  line-height: 1.4;
}

.filter-group {
  margin-bottom: 10px;
  border-bottom: 1px solid rgba(226, 229, 235, 0.7);
  padding-bottom: 10px;
}

.filter-group summary {
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: #5b6472;
  margin: 0 0 8px;
  cursor: pointer;
  list-style: none;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.filter-group summary::-webkit-details-marker {
  display: none;
}

.filter-group summary::after {
  content: "▾";
  font-size: 10px;
  transition: transform 0.15s ease;
}

.filter-group:not([open]) summary::after {
  transform: rotate(-90deg);
}

.filter-group summary:hover {
  color: #2563eb;
}

.filter-group[open] summary {
  margin-bottom: 8px;
}

.filter-search {
  width: 100%;
  padding: 6px 8px;
  margin-bottom: 8px;
  border: 1px solid #d7dbe3;
  border-radius: 6px;
  font-size: 12px;
}

.filter-list {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  max-height: 160px;
  overflow-y: auto;
}

.filter-chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 8px;
  border-radius: 999px;
  border: 1px solid #d7dbe3;
  background: white;
  font-size: 12px;
  cursor: pointer;
  user-select: none;
}

.filter-chip.active {
  background: #2563eb;
  border-color: #2563eb;
  color: white;
}

.filter-list:empty::after {
  content: "—";
  font-size: 12px;
  color: #9aa2af;
}

#result-count {
  font-size: 12px;
  color: #5b6472;
}

.client-logo-marker {
  border-radius: 50%;
  background: white;
  border: 2px solid #2563eb;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.3);
  object-fit: contain;
}

.client-popup h3 {
  margin: 0 0 4px;
  font-size: 14px;
}

.popup-logo {
  height: 28px;
  margin-bottom: 6px;
}

.client-popup p {
  margin: 2px 0;
  font-size: 12px;
  color: #444;
}

.fab {
  position: absolute;
  bottom: 24px;
  right: 24px;
  width: 52px;
  height: 52px;
  border-radius: 50%;
  border: none;
  background: #2563eb;
  color: white;
  font-size: 22px;
  line-height: 1;
  cursor: pointer;
  z-index: 600;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.3);
}

.fab:hover {
  background: #1d4ed8;
}

.modal-overlay[hidden] {
  display: none;
}

.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(15, 20, 30, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 2000;
}

.modal-card {
  width: 520px;
  max-height: 80vh;
  overflow-y: auto;
  padding: 24px;
  background: white;
  border-radius: 14px;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.25);
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
}

.modal-header h2 {
  font-size: 16px;
  margin: 0;
}

.internal-code-form {
  display: flex;
  gap: 8px;
  margin-bottom: 8px;
}

.internal-code-form input {
  flex: 1;
  padding: 8px 10px;
  border: 1px solid #d7dbe3;
  border-radius: 6px;
  font-size: 13px;
}

.internal-code-form button {
  padding: 8px 14px;
  background: #2563eb;
  color: white;
  border: none;
  border-radius: 6px;
  font-size: 13px;
  cursor: pointer;
  white-space: nowrap;
}

.internal-codes-table {
  width: 100%;
  border-collapse: collapse;
  margin-top: 12px;
  font-size: 13px;
}

.internal-codes-table th {
  text-align: left;
  font-size: 11px;
  text-transform: uppercase;
  color: #5b6472;
  padding: 6px 8px;
  border-bottom: 1px solid #e2e5eb;
}

.internal-codes-table td {
  padding: 8px;
  border-bottom: 1px solid #f0f1f4;
}

.status-active {
  color: #16a34a;
  font-weight: 600;
}

.status-revoked {
  color: #dc2626;
  font-weight: 600;
}

.table-action-btn {
  border: none;
  background: none;
  color: #2563eb;
  cursor: pointer;
  font-size: 12px;
  margin-right: 8px;
  padding: 0;
}

.table-action-btn.danger {
  color: #dc2626;
}
