/* ===== Material Design 3 color tokens (blue theme) ===== */
:root {
  --md-primary: #1a73e8;
  --md-primary-container: #d3e3fd;
  --md-on-primary: #ffffff;
  --md-on-primary-container: #0b57d0;
  --md-secondary-container: #d3e3fd;
  --md-on-secondary-container: #0b57d0;
  --md-surface: #ffffff;
  --md-surface-container: #f1f4f9;
  --md-surface-container-high: #e6eaf0;
  --md-on-surface: #1a1c1e;
  --md-on-surface-variant: #44474e;
  --md-outline: #74777f;
  --md-outline-variant: #c4c7cf;
  --md-error: #ba1a1a;
  --md-error-container: #ffdad6;
  --md-on-error-container: #410002;
  --md-bg: #f7f9fc;

  /* Elevation shadows (Material) */
  --elev-1: 0 1px 2px rgba(0, 0, 0, 0.3), 0 1px 3px 1px rgba(0, 0, 0, 0.15);
  --elev-2: 0 1px 2px rgba(0, 0, 0, 0.3), 0 2px 6px 2px rgba(0, 0, 0, 0.15);
  --elev-3: 0 1px 3px rgba(0, 0, 0, 0.3), 0 4px 8px 3px rgba(0, 0, 0, 0.15);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  font-family: "Roboto", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--md-on-surface);
  background: var(--md-bg);
  -webkit-font-smoothing: antialiased;
}

.screen {
  height: 100dvh;
  display: flex;
  flex-direction: column;
}

.hidden { display: none !important; }

/* ===== Login ===== */
#login-screen {
  align-items: center;
  justify-content: center;
  padding: 24px;
  padding-top: calc(24px + env(safe-area-inset-top));
  padding-bottom: calc(24px + env(safe-area-inset-bottom));
}

.login-card {
  width: 100%;
  max-width: 360px;
  background: var(--md-surface);
  border-radius: 28px;
  padding: 32px 24px;
  box-shadow: var(--elev-2);
  text-align: center;
}

.login-logo {
  width: 72px;
  height: 72px;
  margin: 0 auto 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 2.4rem;
  background: var(--md-primary-container);
  border-radius: 50%;
}

.login-card h1 {
  margin: 0 0 4px;
  font-size: 1.75rem;
  font-weight: 500;
  letter-spacing: 0;
}

.login-card .subtitle {
  margin: 0 0 24px;
  color: var(--md-on-surface-variant);
  font-size: 0.95rem;
}

#login-form { display: flex; flex-direction: column; gap: 20px; }

/* Material outlined text field */
.text-field {
  position: relative;
}
.text-field input {
  width: 100%;
  padding: 16px 14px;
  font-size: 1.2rem;
  font-family: inherit;
  text-align: center;
  letter-spacing: 0.5em;
  color: var(--md-on-surface);
  background: transparent;
  border: 1px solid var(--md-outline);
  border-radius: 8px;
  outline: none;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
.text-field label {
  position: absolute;
  top: 50%;
  left: 14px;
  transform: translateY(-50%);
  padding: 0 4px;
  font-size: 1rem;
  color: var(--md-on-surface-variant);
  background: var(--md-surface);
  pointer-events: none;
  transition: all 0.15s ease;
}
.text-field input:focus {
  border: 2px solid var(--md-primary);
  padding: 15px 13px;
}
.text-field input:focus + label,
.text-field input:not(:placeholder-shown) + label {
  top: 0;
  transform: translateY(-50%);
  font-size: 0.75rem;
  color: var(--md-primary);
}

/* ===== Material buttons ===== */
.mdc-button {
  position: relative;
  overflow: hidden;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 0 24px;
  height: 48px;
  font-family: inherit;
  font-size: 0.95rem;
  font-weight: 500;
  letter-spacing: 0.02em;
  text-transform: uppercase;
  border: none;
  border-radius: 24px;
  cursor: pointer;
  transition: box-shadow 0.2s ease, background 0.2s ease, transform 0.05s ease;
  -webkit-tap-highlight-color: transparent;
}
.mdc-button:active { transform: scale(0.98); }

/* Filled */
.mdc-button--filled {
  background: var(--md-primary);
  color: var(--md-on-primary);
  box-shadow: var(--elev-1);
}
.mdc-button--filled:hover { box-shadow: var(--elev-2); background: #0b57d0; }

/* Tonal */
.mdc-button--tonal {
  background: var(--md-secondary-container);
  color: var(--md-on-secondary-container);
}
.mdc-button--tonal:hover { background: #b9cdf8; }

/* Text */
.mdc-button--text {
  background: transparent;
  color: var(--md-primary);
  box-shadow: none;
}
.mdc-button--text:hover { background: var(--md-primary-container); }

/* Danger text button */
.mdc-button--danger {
  color: var(--md-error);
}
.mdc-button--danger:hover { background: var(--md-error-container); }

.error { color: var(--md-error); margin-top: 12px; font-size: 0.9rem; }

/* ===== Main screen (Google Maps Material layout) ===== */
#main-screen {
  position: relative;
  overflow: hidden;
}

/* Full-bleed map */
#map {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  z-index: 1;
}

/* Floating top card (search-bar style) */
.top-card {
  position: absolute;
  top: calc(12px + env(safe-area-inset-top));
  left: 16px;
  right: 16px;
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 4px 4px 4px 20px;
  background: var(--md-surface);
  border-radius: 28px;
  box-shadow: var(--elev-2);
}
.top-card__title {
  font-size: 1.15rem;
  font-weight: 500;
  letter-spacing: 0;
  color: var(--md-on-surface);
}
.top-card .mdc-button--text { height: 40px; }

/* Move Leaflet zoom controls below the floating header */
.leaflet-control-zoom {
  margin-top: calc(76px + env(safe-area-inset-top)) !important;
}

/* Bottom sheet */
.bottom-sheet {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 1000;
  padding: 8px 16px calc(16px + env(safe-area-inset-bottom));
  background: var(--md-surface);
  border-radius: 28px 28px 0 0;
  box-shadow: var(--elev-3);
}
.bottom-sheet__handle {
  width: 36px;
  height: 4px;
  margin: 0 auto 8px;
  border-radius: 2px;
  background: var(--md-outline-variant);
}

.status {
  margin: 0 0 12px;
  text-align: center;
  font-size: 0.95rem;
  font-weight: 500;
  color: var(--md-on-surface-variant);
}
.status.error { color: var(--md-error); }

.controls {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.controls .mdc-button { width: 100%; }

/* ===== Ripple ===== */
.ripple {
  position: absolute;
  border-radius: 50%;
  transform: scale(0);
  animation: ripple-anim 0.6s linear;
  background: currentColor;
  opacity: 0.25;
  pointer-events: none;
}
@keyframes ripple-anim {
  to { transform: scale(2.5); opacity: 0; }
}

