* { margin: 0; padding: 0; box-sizing: border-box; }
html, body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: #0a0e1a;
  color: #e5e7eb;
  min-height: 100vh;
  line-height: 1.5;
}
body {
  background: radial-gradient(ellipse at top, #1a2138 0%, #0a0e1a 60%);
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

.topbar {
  padding: 16px 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid #1f2937;
}
.brand {
  display: flex; align-items: center; gap: 10px;
  font-size: 14px; letter-spacing: 0.04em;
}
.brand .dot {
  width: 8px; height: 8px; border-radius: 50%;
  background: #10b981;
  box-shadow: 0 0 10px #10b981;
}
.brand strong { color: #fff; }
.muted { color: #9ca3af; }
.small { font-size: 12px; }

.container {
  flex: 1;
  padding: 32px 24px;
  max-width: 1200px;
  margin: 0 auto;
  width: 100%;
}
.footer {
  padding: 16px;
  text-align: center;
  font-size: 11px;
  color: #4b5563;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.card {
  background: #111827;
  border: 1px solid #1f2937;
  border-radius: 14px;
  padding: 28px 32px;
  margin-bottom: 20px;
}
.login-card {
  max-width: 420px;
  margin: 60px auto;
}

h1 {
  font-size: 24px;
  margin-bottom: 8px;
  color: #fff;
}
h2 {
  font-size: 13px;
  letter-spacing: 0.15em;
  text-transform: uppercase;
  color: #7dd3fc;
  margin: 0 0 16px;
  font-weight: 600;
}
p { margin-bottom: 12px; }
code { font-family: 'SF Mono', Menlo, monospace; background: #1f2937; padding: 2px 6px; border-radius: 4px; font-size: 13px; }

.form {
  display: flex;
  flex-direction: column;
  gap: 16px;
  margin-top: 16px;
}
.form label {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.form label > span {
  font-size: 11px;
  letter-spacing: 0.15em;
  text-transform: uppercase;
  color: #9ca3af;
}
.form input[type="text"], .form input[type="password"] {
  width: 100%;
  padding: 12px 14px;
  background: #0f172a;
  border: 1px solid #1f2937;
  border-radius: 8px;
  color: #fff;
  font-size: 15px;
  font-family: inherit;
  outline: none;
}
.form input:focus { border-color: #0ea5e9; }

.btn-primary, .btn-ghost {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 12px 20px;
  border-radius: 10px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  border: none;
  font-family: inherit;
  transition: background 0.15s, transform 0.1s;
  text-decoration: none;
}
.btn-primary { background: #0ea5e9; color: #fff; }
.btn-primary:hover { background: #0284c7; }
.btn-primary:active { transform: scale(0.97); }
.btn-primary:disabled { background: #1f2937; color: #6b7280; cursor: not-allowed; }
.btn-ghost { background: transparent; color: #d1d5db; border: 1px solid #374151; }
.btn-ghost:hover { background: #1f2937; }
.btn-ghost.small { padding: 6px 12px; font-size: 12px; }

.error {
  color: #fca5a5;
  background: #3a0f10;
  padding: 10px 14px;
  border-radius: 8px;
  border: 1px solid #7f1d1d;
  font-size: 13px;
}

.drop-zone {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  padding: 40px;
  background: #0f172a;
  border: 2px dashed #374151;
  border-radius: 12px;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
}
.drop-zone:hover { border-color: #0ea5e9; background: #0c1624; }
.drop-zone input { display: none; }
.drop-icon { font-size: 36px; }
.file-label {
  font-size: 15px;
  color: #e5e7eb;
  font-weight: 500;
}
.drop-hint {
  font-size: 12px;
  color: #6b7280;
}

/* ── Loader overlay ─────────────────────────────────────────────────────── */
.loader-overlay {
  position: fixed;
  inset: 0;
  background: rgba(5, 8, 16, 0.85);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease;
}
.loader-overlay.is-visible { opacity: 1; pointer-events: auto; }
.loader-box {
  background: #111827;
  border: 1px solid #1f2937;
  border-radius: 16px;
  padding: 36px 44px;
  max-width: 460px;
  width: calc(100% - 32px);
  text-align: center;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.6);
}
.loader-spinner {
  width: 56px;
  height: 56px;
  margin: 0 auto 20px;
  border-radius: 50%;
  border: 4px solid #1f2937;
  border-top-color: #0ea5e9;
  animation: spin 0.9s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.loader-title {
  font-size: 18px;
  color: #fff;
  margin-bottom: 6px;
  letter-spacing: 0;
  text-transform: none;
}
.loader-sub {
  color: #9ca3af;
  font-size: 13px;
  margin-bottom: 20px;
}
.loader-steps {
  list-style: none;
  text-align: left;
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin: 0;
  padding: 16px 0 0;
  border-top: 1px solid #1f2937;
}
.loader-steps .step {
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 13px;
  color: #6b7280;
  transition: color 0.2s;
}
.loader-steps .step .dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: #374151;
  flex-shrink: 0;
  transition: background 0.2s, box-shadow 0.2s;
}
.loader-steps .step.is-active { color: #e5e7eb; }
.loader-steps .step.is-active .dot {
  background: #0ea5e9;
  box-shadow: 0 0 10px #0ea5e9;
}

/* ── Result page ────────────────────────────────────────────────────────── */
.permit { display: block; }

.permit-header {
  padding: 28px 32px 24px;
}
.permit-head-main {
  display: flex;
  align-items: center;
  gap: 24px;
  flex-wrap: wrap;
}
.permit-title { flex: 1; min-width: 200px; }
.permit-brand {
  font-size: 22px;
  font-weight: 600;
  color: #fff;
}
.permit-brand .muted { font-weight: 400; }
.permit-sub {
  font-size: 13px;
  margin-top: 4px;
}

.plate-wrap {
  display: flex;
  align-items: stretch;
  border-radius: 8px;
  overflow: hidden;
  box-shadow: 0 2px 8px rgba(0,0,0,0.3);
  border: 1px solid #1f2937;
}
.plate-ch {
  background: #0b3a7a;
  color: #fff;
  padding: 10px 10px 6px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.1em;
  display: flex;
  align-items: center;
}
.plate {
  font-family: 'SF Mono', Menlo, monospace;
  background: #fff;
  color: #000;
  padding: 10px 16px;
  letter-spacing: 0.12em;
  font-size: 22px;
  font-weight: 700;
  display: flex;
  align-items: center;
}

.badges { display: flex; gap: 6px; flex-wrap: wrap; }
.badge {
  background: #1f2937;
  color: #d1d5db;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  font-weight: 600;
  border: 1px solid #374151;
}
.badge-high { background: #0b3a2e; color: #6ee7b7; border-color: #065f46; }
.badge-medium { background: #3a2a0f; color: #fcd34d; border-color: #7f5f1d; }
.badge-low { background: #3a0f10; color: #fca5a5; border-color: #7f1d1d; }
.badge-warn { background: #3a2a0f; color: #fcd34d; border-color: #7f5f1d; }

.notes {
  background: #0f172a;
  border: 1px solid #1f2937;
  border-radius: 8px;
  padding: 12px 14px;
  color: #d1d5db;
  font-size: 13px;
  margin: 20px 0 0;
}

/* Grille auto-fit : label au-dessus, valeur dessous, chaque champ prend la place qu'il faut */
.kv {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 4px 20px;
  margin: 0;
}
.kv > div {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 10px 0;
  border-bottom: 1px solid #1f2937;
  min-width: 0;
}
.kv > div.kv-wide { grid-column: 1 / -1; }
.kv > div > span {
  color: #9ca3af;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-weight: 500;
}
.kv > div > strong {
  color: #fff;
  font-weight: 500;
  font-size: 15px;
  word-break: break-word;
  overflow-wrap: anywhere;
}
.kv > div > strong .muted {
  font-size: 13px;
  font-weight: 400;
}

.mono { font-family: 'SF Mono', Menlo, monospace; font-size: 14px; }

.actions {
  margin-top: 4px;
  margin-bottom: 16px;
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.json-details {
  background: #111827;
  border: 1px solid #1f2937;
  border-radius: 14px;
  padding: 0;
  margin-bottom: 20px;
}
.json-details > summary {
  padding: 16px 24px;
  cursor: pointer;
  font-size: 13px;
  font-weight: 600;
  color: #9ca3af;
  letter-spacing: 0.05em;
  list-style: none;
  user-select: none;
  display: flex;
  align-items: center;
  gap: 10px;
}
.json-details > summary::-webkit-details-marker { display: none; }
.json-details > summary::before {
  content: '▸';
  color: #6b7280;
  transition: transform 0.15s;
  display: inline-block;
}
.json-details[open] > summary::before { transform: rotate(90deg); }
.json-details > summary:hover { color: #e5e7eb; }

.code {
  background: #0f172a;
  border-top: 1px solid #1f2937;
  border-bottom-left-radius: 14px;
  border-bottom-right-radius: 14px;
  padding: 20px 24px;
  color: #d1d5db;
  font-family: 'SF Mono', Menlo, monospace;
  font-size: 12px;
  overflow-x: auto;
  white-space: pre-wrap;
  word-break: break-word;
  max-height: 600px;
  overflow-y: auto;
  margin: 0;
}
