:root {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: #111827;
  background: #f3f4f6;
  color-scheme: light;
}
* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
button, input, select, textarea { font: inherit; }
button, select, textarea, input { -webkit-tap-highlight-color: transparent; }
a { color: inherit; }
.hidden { display: none !important; }
.muted { color: #6b7280; }

/* Auth */
.auth-page { min-height: 100vh; display: grid; place-items: center; padding: 24px; background: #e5e7eb; }
.auth-card { width: min(100%, 420px); background: #fff; border-radius: 24px; padding: 28px; box-shadow: 0 18px 50px rgba(17,24,39,.12); }
.auth-card h1 { margin: 12px 0 6px; font-size: 28px; }
.auth-card p { margin: 0 0 20px; }
.brand-mark { width: 50px; height: 50px; display: grid; place-items: center; border-radius: 16px; background: #111827; color: #fff; font-weight: 900; font-size: 24px; }
.stack-form, .admin-form { display: grid; gap: 14px; }
label { display: grid; gap: 7px; font-weight: 600; font-size: 14px; }
input, select, textarea { width: 100%; border: 1px solid #d1d5db; border-radius: 12px; background: #f9fafb; padding: 12px; color: #111827; outline: none; }
input:focus, select:focus, textarea:focus { border-color: #6b7280; box-shadow: 0 0 0 3px rgba(107,114,128,.12); }
.alert { padding: 11px 12px; border-radius: 12px; margin: 14px 0; font-size: 14px; }
.alert.error { background: #fee2e2; color: #991b1b; }
.hint.standalone { margin: -4px 0 0; }
.primary-button, .secondary-button, .save-button, .danger-button { border: 0; border-radius: 12px; padding: 11px 14px; font-weight: 700; cursor: pointer; }
.primary-button, .save-button { background: #111827; color: #fff; }
.secondary-button { background: #e5e7eb; color: #111827; }
.danger-button { background: #fee2e2; color: #991b1b; }
button:disabled { opacity: .55; }

/* Map */
.map-page, .map-page #map { width: 100%; height: 100%; margin: 0; }
.map-page { overflow: hidden; }
#map { position: fixed; inset: 0; }
.topbar { position: fixed; z-index: 10; top: calc(env(safe-area-inset-top) + 12px); left: 12px; right: 12px; min-height: 54px; display: flex; align-items: center; justify-content: space-between; padding: 9px 10px 9px 16px; background: rgba(255,255,255,.94); backdrop-filter: blur(16px); border-radius: 18px; box-shadow: 0 8px 28px rgba(17,24,39,.18); }
.topbar strong { display: block; font-size: 18px; line-height: 1.1; }
.topbar span { display: block; font-size: 12px; color: #6b7280; margin-top: 3px; }
.topbar-actions { display: flex; gap: 8px; }
.icon-button, .round-button { border: 0; background: #fff; color: #111827; box-shadow: 0 5px 18px rgba(17,24,39,.2); text-decoration: none; display: grid; place-items: center; cursor: pointer; }
.icon-button { width: 38px; height: 38px; border-radius: 12px; font-size: 20px; }
.map-controls { position: fixed; z-index: 10; right: 16px; bottom: calc(env(safe-area-inset-bottom) + 18px); display: grid; gap: 10px; }
.round-button { width: 52px; height: 52px; border-radius: 50%; font-size: 26px; }
.round-button.primary { background: #111827; color: white; font-size: 32px; }
.toast { position: fixed; z-index: 60; left: 50%; bottom: calc(env(safe-area-inset-bottom) + 90px); transform: translate(-50%, 12px); background: rgba(17,24,39,.94); color: white; padding: 10px 14px; border-radius: 12px; opacity: 0; pointer-events: none; transition: .2s; font-size: 14px; max-width: calc(100% - 32px); text-align: center; }
.toast.visible { opacity: 1; transform: translate(-50%, 0); }
.backdrop { position: fixed; z-index: 20; inset: 0; background: rgba(17,24,39,.32); }
.sheet { position: fixed; z-index: 30; left: 0; right: 0; bottom: 0; max-height: 82vh; overflow-y: auto; background: #fff; border-radius: 24px 24px 0 0; padding: 6px 18px calc(env(safe-area-inset-bottom) + 18px); box-shadow: 0 -10px 35px rgba(17,24,39,.18); }
.grabber { width: 42px; height: 5px; border-radius: 99px; background: #d1d5db; margin: 4px auto 10px; }
.sheet-header { display: flex; justify-content: space-between; align-items: center; gap: 16px; }
.sheet-header h1 { margin: 4px 0 14px; font-size: 22px; }
.text-button { border: 0; background: transparent; color: #4b5563; padding: 8px 0; cursor: pointer; }
#observationForm { display: grid; gap: 14px; }
textarea { resize: vertical; }
.position-card { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px; border-radius: 14px; background: #f3f4f6; }
.position-card div { min-width: 0; }
.position-card strong, .position-card span { display: block; }
.position-card strong { font-size: 14px; overflow: hidden; text-overflow: ellipsis; }
.position-card #accuracyText { color: #6b7280; font-size: 12px; margin-top: 3px; }
.eyebrow { text-transform: uppercase; letter-spacing: .08em; font-size: 10px !important; color: #6b7280; margin-bottom: 4px; }
.hint { margin: -7px 2px 0; color: #6b7280; font-size: 12px; line-height: 1.35; }
.photo-picker input { display: none; }
.photo-picker .secondary-button { text-align: center; }
.photo-preview { width: 100%; max-height: 220px; object-fit: cover; border-radius: 14px; background: #f3f4f6; }
.checkbox-row { display: flex; align-items: center; font-weight: 500; color: #4b5563; }
.checkbox-row input { width: auto; }
.actions { display: flex; gap: 10px; padding-top: 2px; }
.save-button { flex: 1; }
.marker-dot { width: 22px; height: 22px; border-radius: 50%; border: 3px solid #fff; background: #111827; box-shadow: 0 2px 7px rgba(0,0,0,.35); cursor: pointer; }
.marker-dot.condition-use { background: #6b7280; }
.marker-dot.condition-degrade { background: #374151; }
.marker-dot.condition-absent { background: #000; }
.marker-dot.condition-inconnu { background: #9ca3af; }
.edit-marker { width: 28px; height: 28px; border-radius: 50%; border: 4px solid white; background: #2563eb; box-shadow: 0 3px 10px rgba(0,0,0,.35); }
.maplibregl-popup-content { border-radius: 12px; padding: 12px; font-family: inherit; }
.popup-title { font-weight: 800; margin-bottom: 5px; }
.popup-meta { font-size: 12px; color: #6b7280; margin-bottom: 6px; }
.popup-photo { width: 180px; max-height: 130px; object-fit: cover; border-radius: 8px; display: block; margin: 8px 0; }
.popup-button { width: 100%; border: 0; background: #111827; color: #fff; border-radius: 8px; padding: 8px 10px; font-weight: 700; }
.drawer { position: fixed; z-index: 50; top: 0; right: 0; bottom: 0; width: min(340px, 88vw); padding: calc(env(safe-area-inset-top) + 18px) 18px calc(env(safe-area-inset-bottom) + 18px); background: #fff; box-shadow: -12px 0 34px rgba(17,24,39,.2); display: flex; flex-direction: column; gap: 8px; }
.drawer-head { display: flex; justify-content: space-between; align-items: flex-start; margin-bottom: 12px; }
.drawer-head strong, .drawer-head span { display: block; }
.drawer-head span { color: #6b7280; font-size: 12px; margin-top: 3px; }
.drawer a, .drawer-button { border: 0; background: #f3f4f6; text-decoration: none; border-radius: 12px; padding: 13px 14px; text-align: left; font-weight: 650; color: #111827; }
.drawer-button { cursor: pointer; }
.drawer small { color: #9ca3af; margin-top: auto; }

/* Admin */
.admin-page { min-height: 100vh; background: #f3f4f6; }
.page-header { max-width: 980px; margin: 0 auto; padding: 28px 20px 10px; display: flex; justify-content: space-between; align-items: flex-end; gap: 20px; }
.page-header h1 { margin: 8px 0 0; }
.page-header > div:last-child { text-align: right; }
.page-header > div:last-child span { display: block; color: #6b7280; font-size: 12px; margin-top: 3px; }
.back-link { color: #6b7280; text-decoration: none; }
.admin-shell { max-width: 980px; margin: 0 auto; padding: 12px 20px 40px; display: grid; gap: 18px; }
.panel { background: #fff; border-radius: 20px; padding: 20px; box-shadow: 0 8px 28px rgba(17,24,39,.07); }
.panel h2 { margin: 0 0 6px; }
.panel h3 { margin: 10px 0 0; }
.user-list { display: grid; gap: 8px; margin: 18px 0; }
.user-row { display: flex; justify-content: space-between; gap: 16px; align-items: center; padding: 12px; border-radius: 14px; background: #f9fafb; }
.user-row strong, .user-row span { display: block; }
.user-row span { color: #6b7280; font-size: 12px; margin-top: 3px; }
.inline-actions { display: flex; gap: 8px; flex-wrap: wrap; justify-content: flex-end; }
.admin-form { grid-template-columns: 1fr 1fr 180px auto; align-items: end; }
.admin-form h3 { grid-column: 1 / -1; }
.backup-actions { display: grid; gap: 12px; margin-top: 16px; }
.link-button { text-decoration: none; display: inline-flex; justify-content: center; align-items: center; width: fit-content; }
.restore-form { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.restore-form input { max-width: 460px; }
.status-grid { display: grid; gap: 10px; margin: 16px 0 0; }
.status-grid div { display: flex; justify-content: space-between; gap: 20px; padding: 10px 0; border-top: 1px solid #e5e7eb; }
.status-grid dt { color: #6b7280; }
.status-grid dd { margin: 0; text-align: right; font-weight: 650; }

@media (min-width: 700px) {
  .sheet { left: auto; right: 18px; bottom: 18px; width: 430px; border-radius: 24px; max-height: calc(100vh - 36px); padding-bottom: 18px; }
  #sheetBackdrop { display: none; }
  .map-controls { bottom: 18px; }
}
@media (max-width: 760px) {
  .admin-form { grid-template-columns: 1fr; }
  .user-row { align-items: flex-start; flex-direction: column; }
  .inline-actions { justify-content: flex-start; }
  .page-header { align-items: flex-start; }
}
