/* XK Lane — estilos compartidos (landing, vía, admin). Ligero a propósito. */
:root {
  --bg: #0f1419;
  --panel: #1a2129;
  --panel-2: #232c36;
  --text: #eef2f6;
  --muted: #9aa7b4;
  --accent: #2f9e5b;
  --accent-2: #3fbf73;
  --danger: #d7263d;
  --warn: #f4a20c;
  --blue: #2b7de9;
  --border: #2e3946;
  --radius: 12px;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--bg);
  color: var(--text);
  font: 16px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
a { color: var(--accent-2); }
h1, h2, h3 { line-height: 1.2; margin: 0 0 .5em; }

button, .btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .4em;
  min-height: 44px; padding: .55em 1.1em;
  border: 1px solid var(--border); border-radius: 10px;
  background: var(--panel-2); color: var(--text);
  font: inherit; font-weight: 600; cursor: pointer; text-decoration: none;
}
button:hover, .btn:hover { border-color: var(--muted); }
button:disabled { opacity: .5; cursor: default; }
.btn-primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-2); }
.btn-danger { background: transparent; border-color: var(--danger); color: #ff8a97; }
.btn-small { min-height: 34px; padding: .3em .7em; font-size: .9em; }

input[type=text], input[type=password], textarea {
  width: 100%; padding: .6em .75em; border-radius: 8px;
  border: 1px solid var(--border); background: var(--bg); color: var(--text); font: inherit;
}
textarea { min-height: 70px; resize: vertical; }
label { display: block; font-size: .9em; color: var(--muted); margin: .7em 0 .25em; }
.check { display: flex; align-items: center; gap: .5em; color: var(--text); }

.muted { color: var(--muted); }
.hidden { display: none !important; }

/* ---------- Landing ---------- */
.page { max-width: 640px; margin: 0 auto; padding: 24px 16px 48px; }
.brand { display: flex; align-items: center; gap: .6em; margin-bottom: 1em; }
.brand img { width: 44px; height: 44px; border-radius: 10px; }
.card { background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px; margin: 14px 0; }
.lane-list { list-style: none; margin: 0; padding: 0; }
.lane-list li { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 10px 0; border-top: 1px solid var(--border); }
.lane-list li:first-child { border-top: 0; }
.lane-list .near { color: var(--accent-2); font-weight: 600; }

/* ---------- Vista de vía ---------- */
.via { display: flex; flex-direction: column; height: 100%; height: 100dvh; }
.via-header {
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  padding: 8px 12px; background: var(--panel); border-bottom: 1px solid var(--border);
}
.via-header h1 { font-size: 1.05em; margin: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.status-pill { font-size: .8em; padding: .2em .65em; border-radius: 999px; background: var(--panel-2); color: var(--muted); white-space: nowrap; }
.status-pill.on { background: rgba(47,158,91,.18); color: var(--accent-2); }
.status-pill.off { background: rgba(215,38,61,.15); color: #ff8a97; }
#map { flex: 1; min-height: 0; background: #ccd; }
.via-footer { padding: 10px 12px calc(10px + env(safe-area-inset-bottom)); background: var(--panel); border-top: 1px solid var(--border); }
.via-footer .row { display: flex; gap: 8px; align-items: center; justify-content: space-between; }
.via-footer p { margin: 0; font-size: .92em; }

.alert-overlay {
  position: fixed; left: 10px; right: 10px; top: 58px; z-index: 1000;
  background: var(--danger); color: #fff; border-radius: var(--radius);
  padding: 16px 18px; font-size: 1.25em; font-weight: 700; line-height: 1.3;
  box-shadow: 0 10px 30px rgba(0,0,0,.45);
  animation: pulse 1.2s ease-in-out infinite;
}
@keyframes pulse { 50% { box-shadow: 0 0 0 8px rgba(215,38,61,.35), 0 10px 30px rgba(0,0,0,.45); } }
@media (prefers-reduced-motion: reduce) { .alert-overlay { animation: none; } }

.gate {
  position: fixed; inset: 0; z-index: 1100; display: flex; align-items: center; justify-content: center;
  background: rgba(15,20,25,.92); padding: 16px;
}
.gate .card { max-width: 420px; width: 100%; text-align: center; }

/* Marcadores */
.veh { width: 22px; height: 22px; border-radius: 50%; border: 3px solid #fff; box-shadow: 0 1px 6px rgba(0,0,0,.5); }
.veh.me { background: #1fb75a; width: 26px; height: 26px; }
.veh.other { background: var(--danger); }
.pin { padding: 2px 6px; border-radius: 6px; font: 700 12px/1.3 system-ui, sans-serif; color: #fff; white-space: nowrap; box-shadow: 0 1px 4px rgba(0,0,0,.4); }
.pin.entry { background: var(--accent); }
.pin.exit { background: #6b4fd8; }
.pin.siding { background: var(--blue); }
.vertex { width: 12px; height: 12px; border-radius: 50%; background: var(--warn); border: 2px solid #fff; }

/* ---------- Admin ---------- */
.admin { display: grid; grid-template-columns: 360px 1fr; height: 100vh; height: 100dvh; }
.admin aside { overflow-y: auto; padding: 16px; background: var(--panel); border-right: 1px solid var(--border); }
.admin #map { height: 100%; }
.admin table { width: 100%; border-collapse: collapse; font-size: .9em; }
.admin th, .admin td { text-align: left; padding: 6px 4px; border-top: 1px solid var(--border); vertical-align: top; }
.admin-head { display: flex; justify-content: space-between; align-items: center; }
.admin-head h1 { margin: 0; }
.actions { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 4px; }
.actions.center { justify-content: center; }
.modes { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; margin: .6em 0; }
.modes button.on { background: var(--blue); border-color: var(--blue); color: #fff; }
.siding-list { list-style: none; padding: 0; margin: .3em 0; }
.siding-list li { display: flex; justify-content: space-between; align-items: center; padding: 4px 0; }
.msg { margin: .6em 0; padding: .5em .7em; border-radius: 8px; background: var(--panel-2); }
.msg.err { background: rgba(215,38,61,.18); color: #ffb3bc; }
.msg.ok { background: rgba(47,158,91,.18); color: #9fe3b9; }
.login { max-width: 360px; margin: 12vh auto; padding: 0 16px; }
.modal { position: fixed; inset: 0; z-index: 2000; background: rgba(0,0,0,.7); display: flex; align-items: center; justify-content: center; padding: 16px; }
.modal .card { max-width: 420px; width: 100%; text-align: center; }
.modal img { width: 100%; max-width: 320px; background: #fff; border-radius: 8px; }

@media (max-width: 800px) {
  .admin { grid-template-columns: 1fr; grid-template-rows: auto 55vh; height: auto; }
  .admin aside { border-right: 0; border-bottom: 1px solid var(--border); }
}
