:root {
  --ink: #14212e; --muted: #5d6b7a; --line: #dfe5ea; --bg: #f4f6f8; --card: #fff;
  --brand: #14324a; --accent: #0f7b6c; --accent-2: #e8f4f1;
  --sim: #b45309; --sim-bg: #fff4e0; --real: #1d4ed8; --real-bg: #e6eeff;
  --danger: #b42318; --danger-bg: #fdecea; --ok: #067647; --ok-bg: #e7f6ee;
  --radius: 14px; --tabs-h: 64px;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--ink); }
body { padding-bottom: calc(var(--tabs-h) + env(safe-area-inset-bottom)); font-size: 16px; line-height: 1.45; }
a { color: var(--accent); }
h1 { font-size: 1.35rem; margin: .2rem 0 .6rem; }
h2 { font-size: 1.1rem; margin: 1.2rem 0 .5rem; }
h3 { font-size: 1rem; margin: 0 0 .3rem; }
p { margin: .3rem 0 .6rem; }
small, .muted { color: var(--muted); }

.demo-ribbon { background: var(--sim); color: #fff; font-size: .75rem; text-align: center; padding: 3px 8px; letter-spacing: .02em; }
.topbar { position: sticky; top: 0; z-index: 1000; display: flex; align-items: center; justify-content: space-between; gap: .5rem;
  background: var(--brand); color: #fff; padding: .6rem 1rem; }
.brand { color: #fff; text-decoration: none; font-weight: 700; font-size: 1rem; }
.tag { background: #fff3; border-radius: 6px; padding: 1px 6px; font-size: .7rem; margin-left: 4px; }
.who { background: #ffffff1f; color: #fff; border: 1px solid #ffffff40; border-radius: 999px; padding: .35rem .8rem; font: inherit; font-size: .85rem;
  max-width: 55vw; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; cursor: pointer; }

main { max-width: 860px; margin: 0 auto; padding: 1rem; outline: none; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 1rem; margin: 0 0 .8rem; }
.card.tight { padding: .75rem .9rem; }
.grid { display: grid; gap: .8rem; margin-bottom: .8rem; }
.grid > .card { margin: 0; }
@media (min-width: 720px) { .grid.two { grid-template-columns: 1fr 1fr; } .grid.three { grid-template-columns: repeat(3, 1fr); } }
.row { display: flex; gap: .5rem; align-items: center; flex-wrap: wrap; }
.spread { justify-content: space-between; }
.stack > * + * { margin-top: .5rem; }

.tabs { position: fixed; bottom: 0; left: 0; right: 0; z-index: 1000; display: flex; background: #fff; border-top: 1px solid var(--line);
  padding-bottom: env(safe-area-inset-bottom); height: calc(var(--tabs-h) + env(safe-area-inset-bottom)); }
.tabs a { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; text-decoration: none; color: var(--muted);
  font-size: .72rem; gap: 2px; min-width: 0; }
.tabs a .ico { font-size: 1.25rem; line-height: 1; }
.tabs a.on { color: var(--accent); font-weight: 600; }

button, .btn { font: inherit; border-radius: 10px; border: 1px solid var(--line); background: #fff; color: var(--ink); padding: .6rem .95rem;
  cursor: pointer; min-height: 44px; text-decoration: none; display: inline-flex; align-items: center; justify-content: center; gap: .35rem; }
button.primary, .btn.primary { background: var(--accent); color: #fff; border-color: var(--accent); font-weight: 600; }
button.danger { color: var(--danger); border-color: #f3c1bc; }
button.ghost { background: transparent; }
button:disabled { opacity: .5; cursor: not-allowed; }
button.big { width: 100%; font-size: 1.05rem; min-height: 54px; }

label { display: block; font-size: .85rem; font-weight: 600; margin: .6rem 0 .2rem; }
input, select, textarea { width: 100%; font: inherit; border: 1px solid #c9d2da; border-radius: 10px; padding: .55rem .7rem; background: #fff; min-height: 44px; }
textarea { min-height: 80px; resize: vertical; }
.checks { display: flex; flex-wrap: wrap; gap: .4rem; }
.checks label { display: inline-flex; align-items: center; gap: .35rem; font-weight: 500; border: 1px solid var(--line); border-radius: 999px;
  padding: .3rem .7rem; margin: 0; background: #fff; cursor: pointer; }
.checks input { width: auto; min-height: 0; }
.err { color: var(--danger); font-size: .8rem; margin-top: .2rem; }
.field-error input, .field-error select, .field-error textarea { border-color: var(--danger); background: var(--danger-bg); }
.alert { border-radius: 10px; padding: .6rem .8rem; margin: .5rem 0; font-size: .9rem; }
.alert.error { background: var(--danger-bg); color: var(--danger); }
.alert.ok { background: var(--ok-bg); color: var(--ok); }
.alert.info { background: var(--accent-2); color: #0b5a4f; }

.pill { display: inline-block; border-radius: 999px; padding: 2px 9px; font-size: .74rem; font-weight: 600; background: #eef1f4; color: var(--muted); }
.pill.sim { background: var(--sim-bg); color: var(--sim); }
.pill.real { background: var(--real-bg); color: var(--real); }
.pill.ok { background: var(--ok-bg); color: var(--ok); }
.pill.warn { background: var(--sim-bg); color: var(--sim); }
.pill.bad { background: var(--danger-bg); color: var(--danger); }
.sim-box { border: 2px dashed #f2b968; background: var(--sim-bg); border-radius: var(--radius); padding: .8rem 1rem; margin: .8rem 0; }
.sim-box h3::before { content: "SIMULADO · "; color: var(--sim); }
.basis { font-size: .78rem; color: var(--muted); border-left: 3px solid var(--line); padding-left: .5rem; margin: .4rem 0; }

.list-item { display: flex; gap: .8rem; align-items: flex-start; }
.thumb { width: 96px; height: 60px; object-fit: cover; border-radius: 8px; flex: none; background: #ddd; }
.gallery { display: flex; gap: .4rem; overflow-x: auto; }
.gallery img { height: 120px; border-radius: 10px; }
.photo-pick { display: flex; gap: .5rem; flex-wrap: wrap; }
.photo-pick label { padding: 0; border: 3px solid transparent; border-radius: 10px; overflow: hidden; margin: 0; cursor: pointer; }
.photo-pick input { display: none; }
.photo-pick img { width: 110px; display: block; }
.photo-pick label:has(input:checked) { border-color: var(--accent); }
.kv { display: grid; grid-template-columns: auto 1fr; gap: .2rem .8rem; font-size: .9rem; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; }
.empty { text-align: center; color: var(--muted); padding: 1.5rem 1rem; border: 1px dashed var(--line); border-radius: var(--radius); background: #fff; }

.roles { display: grid; gap: .6rem; }
@media (min-width: 720px) { .roles { grid-template-columns: 1fr 1fr; } }
.role-card { text-align: left; display: block; width: 100%; padding: .9rem 1rem; border-radius: var(--radius); }
.role-card strong { display: block; }
.role-card small { display: block; }

#map { height: 52vh; min-height: 300px; border-radius: var(--radius); border: 1px solid var(--line); z-index: 0; }
.map-legend { display: flex; flex-wrap: wrap; gap: .4rem .9rem; font-size: .8rem; margin: .4rem 0; }
.dot { display: inline-block; width: 12px; height: 12px; border-radius: 50%; vertical-align: -1px; margin-right: 4px; }
.bus-marker { background: var(--sim); color: #fff; border: 2px solid #fff; border-radius: 10px; font-size: 11px; font-weight: 800; text-align: center;
  line-height: 26px; box-shadow: 0 2px 6px #0005; }
.me-marker { background: var(--real); border: 3px solid #fff; border-radius: 50%; box-shadow: 0 0 0 6px #1d4ed833; }
.stop-marker { background: #fff; border: 3px solid var(--brand); border-radius: 50%; }
.stop-marker.done { border-color: #9aa5b1; background: #e5e9ed; }
.demand-badge { background: #7c3aed; color: #fff; border-radius: 999px; font-size: 11px; font-weight: 700; text-align: center; line-height: 20px; border: 2px solid #fff; }
.nextstop { background: var(--brand); color: #fff; border-radius: var(--radius); padding: .8rem 1rem; display: flex; justify-content: space-between; align-items: center; gap: .6rem; }
.nextstop .eta { font-size: 1.6rem; font-weight: 800; }
.nextstop small { color: #cfe0ee; }
.meter { height: 12px; border-radius: 999px; background: #e7ebef; overflow: hidden; }
.meter > span { display: block; height: 100%; background: linear-gradient(90deg, #f2b968, var(--sim)); }
.drive-lock { background: #111827; color: #f9fafb; border-radius: var(--radius); padding: .8rem 1rem; font-size: .9rem; }
.stats { display: grid; grid-template-columns: repeat(2, 1fr); gap: .6rem; }
@media (min-width: 720px) { .stats { grid-template-columns: repeat(4, 1fr); } }
.stat { background: #fff; border: 1px solid var(--line); border-radius: 12px; padding: .7rem; }
.stat b { display: block; font-size: 1.35rem; }
.bars { display: flex; align-items: flex-end; gap: 6px; height: 90px; padding-top: 6px; }
.bars div { flex: 1; background: var(--accent); border-radius: 6px 6px 0 0; min-height: 2px; position: relative; }
.bars div span { position: absolute; bottom: -18px; left: 0; right: 0; text-align: center; font-size: .68rem; color: var(--muted); }
table { width: 100%; border-collapse: collapse; font-size: .88rem; }
th, td { text-align: left; padding: .35rem .3rem; border-bottom: 1px solid var(--line); }
.toast { position: fixed; left: 50%; bottom: calc(var(--tabs-h) + 14px); transform: translateX(-50%); background: #111827; color: #fff; padding: .6rem 1rem;
  border-radius: 10px; font-size: .9rem; opacity: 0; pointer-events: none; transition: opacity .2s; z-index: 2000; max-width: 90vw; }
.toast.show { opacity: 1; }
.toast.error { background: var(--danger); }
dialog { border: none; border-radius: var(--radius); padding: 1rem; max-width: 420px; width: 92vw; }
dialog::backdrop { background: #0006; }
.timeline { list-style: none; padding: 0; margin: 0; font-size: .82rem; max-height: 220px; overflow: auto; }
.timeline li { padding: .25rem 0; border-bottom: 1px dashed var(--line); }
@media (min-width: 720px) { .tabs { justify-content: center; } .tabs a { flex: 0 0 130px; } }
