* { margin: 0; padding: 0; box-sizing: border-box; }
html, body { height: 100%; }
body {
  font-family: "Outfit", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  color: #333; background: #e9f4f9; display: flex; flex-direction: column;
}
header.top {
  background: linear-gradient(135deg, #3cb4e5 0%, #0083c1 100%);
  color: #fff; padding: 0.6rem 1rem; display: flex; align-items: center; gap: 1rem;
  flex-wrap: wrap; box-shadow: 0 2px 10px rgba(0,0,0,.15); z-index: 1000;
}
header.top h1 { font-size: 1.25rem; font-weight: 700; flex: 1; }
header.top a { color: #fff; text-decoration: none; font-weight: 600; font-size: .9rem;
  background: rgba(255,255,255,.18); padding: .35rem .8rem; border-radius: 5px; }
header.top a:hover { background: rgba(255,255,255,.3); }
main { flex: 1; display: flex; min-height: 0; }
#panel { width: 400px; max-width: 45vw; background: #fff; display: flex; flex-direction: column;
  border-right: 1px solid #d5e3ea; min-height: 0; }
#map { flex: 1; min-width: 0; }
.tabs { display: flex; border-bottom: 1px solid #d5e3ea; }
.tabs button { flex: 1; padding: .7rem .4rem; border: 0; background: #f4f9fb; cursor: pointer;
  font: inherit; font-weight: 600; color: #557; border-bottom: 3px solid transparent; }
.tabs button.active { background: #fff; color: #0083c1; border-bottom-color: #0083c1; }
.tab { display: none; padding: 1rem; overflow: auto; flex: 1; min-height: 0; }
.tab.active { display: block; }
.row { display: flex; gap: .5rem; align-items: center; margin-bottom: .8rem; flex-wrap: wrap; }
label.small { font-size: .85rem; color: #557; }
input[type=date], input[type=search], select {
  font: inherit; padding: .4rem .5rem; border: 1px solid #b9cbd4; border-radius: 5px; background: #fff; }
input[type=search] { width: 100%; }
.badge { display: inline-block; min-width: 2rem; text-align: center; padding: .1rem .5rem;
  border-radius: 4px; color: #fff; font-weight: 700; font-size: .85rem; }
.line-card { border: 1px solid #d5e3ea; border-radius: 8px; padding: .7rem .8rem; margin-bottom: .7rem;
  border-left-width: 6px; }
.line-card h3 { font-size: 1rem; display: flex; gap: .5rem; align-items: center; }
.line-card p { font-size: .85rem; color: #557; margin-top: .3rem; }
.line-card label { display: flex; gap: .5rem; align-items: flex-start; cursor: pointer; }
.stop-item { padding: .5rem .3rem; border-bottom: 1px solid #eef3f6; cursor: pointer; font-size: .92rem; }
.stop-item:hover { background: #eef7fb; }
.stop-item .badge { font-size: .7rem; min-width: 1.6rem; padding: 0 .3rem; margin-right: .15rem; }
.muted { color: #667; font-size: .85rem; }
.tt-wrap { overflow: auto; border: 1px solid #d5e3ea; border-radius: 6px; margin-bottom: 1.2rem; max-height: 60vh; }
table.tt { border-collapse: collapse; font-size: .82rem; white-space: nowrap; }
table.tt th, table.tt td { padding: .25rem .5rem; border-bottom: 1px solid #eef3f6; text-align: center; }
table.tt th:first-child, table.tt td:first-child { position: sticky; left: 0; background: #fff;
  text-align: left; white-space: normal; min-width: 11rem; max-width: 14rem; z-index: 1; }
table.tt thead th { position: sticky; top: 0; background: #f4f9fb; z-index: 2; }
table.tt thead th:first-child { z-index: 3; }
table.tt td.next, table.tt th.next { background: #fff7d6; }
h4.pattern { font-size: .95rem; margin: .8rem 0 .4rem; color: #0083c1; }
.popup h3 { font-size: 1rem; margin-bottom: .3rem; }
.popup ul { list-style: none; margin-top: .4rem; }
.popup li { display: flex; gap: .5rem; align-items: center; font-size: .85rem; padding: .1rem 0; }
.popup li time { font-weight: 700; min-width: 3rem; }
.bus { color: #fff; font-weight: 700; font-size: 11px; border-radius: 12px; border: 2px solid #fff;
  box-shadow: 0 1px 4px rgba(0,0,0,.5); text-align: center; line-height: 20px; width: 34px; height: 24px; }
.legend-note { font-size: .78rem; color: #667; margin-top: 1rem; }
#status { padding: .6rem 1rem; color: #a33; }
@media (max-width: 800px) {
  main { flex-direction: column-reverse; }
  #panel { width: 100%; max-width: none; height: 48vh; border-right: 0; border-top: 1px solid #d5e3ea; }
  #map { height: 52vh; flex: none; }
}
.arrow { background: none; border: 0; }
.arrow svg { display: block; filter: drop-shadow(0 0 1px rgba(0,0,0,.5)); }
#map.no-arrows .arrow { display: none; }
.btn-geo { font: inherit; font-weight: 600; padding: .45rem .8rem; border: 0; border-radius: 5px;
  background: #1a73e8; color: #fff; cursor: pointer; }
.btn-geo:hover { background: #1558b0; }
.stop-item.nearest { background: #e3f0ff; border-left: 4px solid #1a73e8; font-weight: 600; }
.stop-item.nearest:focus { outline: 2px solid #1a73e8; }
.near-tag { display: block; font-size: .78rem; font-weight: 600; color: #1a73e8; margin-top: .15rem; }
