:root {
  --bg: #0f172a;
  --bg-soft: #1e293b;
  --surface: #ffffff;
  --text: #0f172a;
  --muted: #64748b;
  --border: #e2e8f0;
  --primary: #2563eb;
  --primary-dark: #1d4ed8;
  --green: #16a34a;
  --blue: #2563eb;
  --danger: #dc2626;
  --radius: 12px;
  --shadow: 0 1px 3px rgba(15, 23, 42, .08), 0 8px 24px rgba(15, 23, 42, .06);
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

* { box-sizing: border-box; }

html, body { height: 100%; }

body {
  margin: 0;
  font-family: var(--font);
  color: var(--text);
  background: #f1f5f9;
  line-height: 1.5;
}

body.body--center {
  display: grid;
  place-items: center;
  min-height: 100vh;
  background: linear-gradient(135deg, #1e293b, #0f172a);
}

a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }

.muted { color: var(--muted); font-size: .9rem; }

/* Topbar */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: .75rem 1.5rem;
  background: var(--bg);
  color: #fff;
}
.topbar__left { display: flex; align-items: center; gap: .75rem; }
.topbar__logo { height: 30px; width: auto; object-fit: contain; display: block; }
.topbar__logo--r3 { height: 26px; }
.brand { color: #fff; font-weight: 600; display: flex; align-items: center; gap: .5rem; }
.brand:hover { text-decoration: none; }
.topnav { display: flex; align-items: center; gap: 1rem; }
.topnav a { color: #cbd5e1; font-size: .95rem; }
.topnav a:hover, .topnav a.is-active { color: #fff; text-decoration: none; }
.topnav__user { color: #94a3b8; font-size: .85rem; }

.main { padding: 1.5rem; }

.page { max-width: 1200px; margin: 0 auto; }
.page__head { display: flex; align-items: flex-end; justify-content: space-between; gap: 1rem; margin-bottom: 1rem; flex-wrap: wrap; }
.page__head h1 { margin: 0 0 .25rem; font-size: 1.5rem; }

/* Mapa */
.map-wrap {
  display: grid;
  grid-template-columns: 1fr 340px;
  gap: 1rem;
  align-items: stretch;
}
#mapa, #mapa-seleccion {
  height: 70vh;
  min-height: 420px;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  background: var(--surface);
}
@media (max-width: 860px) {
  .map-wrap { grid-template-columns: 1fr; }
  #mapa { height: 55vh; }
}

.legend { display: flex; gap: 1rem; font-size: .85rem; color: var(--muted); }
.legend__item { display: flex; align-items: center; gap: .4rem; }
.dot { width: 12px; height: 12px; border-radius: 50%; display: inline-block; }
.dot--green { background: var(--green); }
.dot--blue { background: var(--blue); }

/* Marcadores Leaflet personalizados */
.marker-pin {
  border-radius: 50%;
  border: 3px solid #fff;
  box-shadow: 0 0 0 1px rgba(0,0,0,.25), 0 2px 6px rgba(0,0,0,.3);
}
.marker-pin--green { background: var(--green); }
.marker-pin--blue { background: var(--blue); }

/* Ficha de parada */
.parada-card {
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 1.25rem;
  overflow: auto;
}
.parada-card--empty { display: grid; place-items: center; text-align: center; }
.parada-card__head { display: flex; align-items: flex-start; justify-content: space-between; gap: .5rem; }
.parada-card__head h2 { font-size: 1.05rem; margin: 0 0 .5rem; }
.parada-card__msg {
  background: #eff6ff; border-left: 3px solid var(--blue);
  padding: .5rem .75rem; border-radius: 6px; font-style: italic; color: #1e3a8a;
}
.parada-card__grid { display: grid; grid-template-columns: 1fr 1fr; gap: .5rem 1rem; margin: 1rem 0; }
.parada-card__grid dt { font-size: .7rem; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); }
.parada-card__grid dd { margin: 0; font-weight: 600; font-size: .95rem; }
.parada-card__actions { margin-top: .5rem; }

.badge { font-size: .7rem; padding: .2rem .5rem; border-radius: 999px; font-weight: 600; white-space: nowrap; }
.badge--green { background: #dcfce7; color: #166534; }
.badge--blue { background: #dbeafe; color: #1e40af; }

/* Botones */
.btn {
  display: inline-block; cursor: pointer; border: 1px solid transparent;
  border-radius: 8px; padding: .55rem 1rem; font-size: .9rem; font-weight: 600;
  font-family: inherit; transition: background .15s, border-color .15s;
}
.btn:hover { text-decoration: none; }
.btn--sm { padding: .35rem .7rem; font-size: .8rem; }
.btn--block { width: 100%; }
.btn--primary { background: var(--primary); color: #fff; }
.btn--primary:hover { background: var(--primary-dark); }
.btn--ghost { background: transparent; border-color: var(--border); color: var(--text); }
.btn--ghost:hover { background: #f8fafc; }

/* Alertas */
.alert { padding: .75rem 1rem; border-radius: 8px; margin: 0 0 1rem; font-size: .9rem; }
.alert--ok { background: #dcfce7; color: #166534; }
.alert--error { background: #fee2e2; color: #991b1b; }

/* Formulario de mensajes */
.field { display: flex; flex-direction: column; gap: .35rem; }
.field > span { font-size: .8rem; font-weight: 600; color: var(--muted); }
.field input, .field textarea {
  font-family: inherit; font-size: .95rem; padding: .6rem .75rem;
  border: 1px solid var(--border); border-radius: 8px; background: #fff; color: var(--text);
}
.field input:focus, .field textarea:focus { outline: 2px solid var(--primary); outline-offset: 0; border-color: var(--primary); }
.field--narrow { max-width: 180px; }

.form-mensajes { background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow); padding: 1.25rem; }
.form-mensajes__top { display: flex; gap: 1rem; flex-wrap: wrap; margin-bottom: 1rem; }
.form-mensajes__top .field:first-child { flex: 1; min-width: 280px; }
.form-mensajes__grid { display: grid; grid-template-columns: 320px 1fr; gap: 1rem; }
@media (max-width: 820px) { .form-mensajes__grid { grid-template-columns: 1fr; } }
.form-mensajes__actions { display: flex; align-items: center; justify-content: space-between; gap: 1rem; margin-top: 1rem; flex-wrap: wrap; }

.seleccion { border: 1px solid var(--border); border-radius: 8px; display: flex; flex-direction: column; max-height: 60vh; }
.seleccion__head { display: flex; align-items: center; justify-content: space-between; padding: .6rem .75rem; border-bottom: 1px solid var(--border); }
.seleccion__lista { overflow: auto; padding: .25rem .5rem; }
.check { display: flex; align-items: center; gap: .5rem; padding: .35rem .25rem; font-size: .9rem; border-radius: 6px; cursor: pointer; }
.check:hover { background: #f8fafc; }
.mapa-seleccion { height: 60vh; min-height: 360px; border-radius: 8px; box-shadow: var(--shadow); }

/* Login */
.login { width: min(380px, 92vw); }
.login__card { background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow); padding: 2rem; display: flex; flex-direction: column; gap: 1rem; }
.login__title { margin: 0; font-size: 1.4rem; }
.login__card .muted { margin-top: -.5rem; }
