
:root {
  --navy: #193e70;
  --navy-light: #eaf1fa;
  --green: #168653;
  --green-light: #e7f5ec;
  --gold: #e5aa27;
  --paper: #f3f6f8;
  --white: #ffffff;
  --ink: #243749;
  --muted: #74818e;
  --line: #e3e9ef;
  --red: #bd4545;
  --radius: 17px;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: Arial, Helvetica, sans-serif;
  -webkit-font-smoothing: antialiased;
}

button {
  font: inherit;
  cursor: pointer;
}

button:focus-visible {
  outline: 3px solid var(--gold);
  outline-offset: 3px;
}

.header {
  background: linear-gradient(135deg, #173b70, #316b9d);
  color: white;
  padding: 25px 18px 28px;
  border-radius: 0 0 30px 0;
}

.header-inner,
.container {
  width: min(100%, 850px);
  margin: auto;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 14px;
  font-weight: 900;
  letter-spacing: .5px;
}

.brand-icon {
  width: 39px;
  height: 39px;
  display: grid;
  place-items: center;
  border-radius: 13px;
  background: #ffffff20;
  font-size: 22px;
}

.header h1 {
  font-size: clamp(25px, 5vw, 38px);
  line-height: 1.15;
  margin: 24px 0 8px;
}

.header-description {
  color: #e0eaf5;
  font-size: 14px;
  line-height: 1.6;
}

.love-note {
  margin-top: 17px;
  padding: 14px;
  background: #ffffff18;
  border: 1px solid #ffffff38;
  border-radius: 15px;
  font-size: 13px;
  line-height: 1.8;
}

.container {
  padding: 22px 14px 40px;
}

.top-controls {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
}

.route-tabs {
  display: flex;
  gap: 8px;
}

.route-tab {
  border: 1px solid var(--line);
  background: white;
  color: var(--navy);
  padding: 13px 28px;
  border-radius: 13px;
  font-size: 20px;
  font-weight: 900;
}

.route-tab.active {
  background: var(--navy);
  color: white;
  border-color: var(--navy);
}

.refresh-button {
  min-height: 48px;
  padding: 13px 18px;
  border: 0;
  border-radius: 13px;
  background: var(--green);
  color: white;
  font-size: 13px;
  font-weight: 900;
}

.refresh-button:disabled {
  opacity: .6;
  cursor: wait;
}

.boarding-panel {
  margin-top: 17px;
  padding: 15px;
  background: white;
  border: 1px solid var(--line);
  border-radius: var(--radius);
}

.boarding-title {
  margin-bottom: 11px;
  font-size: 14px;
  font-weight: 900;
}

.boarding-options {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 9px;
}

.boarding-button {
  min-height: 46px;
  padding: 12px 7px;
  border: 1px solid var(--line);
  border-radius: 11px;
  background: #f7f9fb;
  color: var(--navy);
  font-size: 12px;
  font-weight: 900;
}

.boarding-button.active {
  background: var(--navy);
  border-color: var(--navy);
  color: white;
}

.connection-status {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  margin: 17px 2px;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.5;
}

.status-dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: #abb6bf;
  flex-shrink: 0;
}

.status-dot.online {
  background: #239b5d;
}

.status-dot.offline {
  background: var(--red);
}

.status-dot.waiting {
  background: var(--gold);
}

.summary-heading {
  margin: 0 0 12px;
  font-size: 18px;
}

.summary-section {
  margin-bottom: 23px;
}

.bus-summary {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 11px;
}

.summary-card {
  min-width: 0;
  padding: 15px;
  background: white;
  border: 1px solid var(--line);
  border-radius: 15px;
}

.summary-card.stale {
  background: #fffbf0;
  border-color: #e8cf91;
}

.summary-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.summary-route {
  color: var(--navy);
  font-size: 16px;
  font-weight: 900;
}

.summary-door {
  padding: 6px 8px;
  border-radius: 8px;
  background: #f0f3f6;
  color: var(--muted);
  font-size: 11px;
}

.summary-label {
  display: block;
  color: var(--muted);
  font-size: 10px;
  margin: 12px 0 5px;
}

.summary-value {
  font-size: 13px;
  font-weight: 800;
  line-height: 1.5;
  overflow-wrap: anywhere;
}

.summary-time {
  margin-top: 11px;
  color: var(--muted);
  font-size: 10px;
  line-height: 1.6;
}

.age-badge {
  display: inline-block;
  margin-top: 8px;
  padding: 6px 8px;
  border-radius: 7px;
  background: var(--green-light);
  color: #19643f;
  font-size: 10px;
  font-weight: 900;
}

.age-badge.stale {
  background: #fff0d3;
  color: #805814;
}

.directions-wrapper {
  display: grid;
  gap: 16px;
}

.direction-panel {
  background: white;
  border: 1px solid var(--line);
  border-radius: 18px;
  overflow: hidden;
  box-shadow: 0 5px 20px #193b7008;
}

.direction-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  padding: 16px;
  background: #f8fafc;
  border-bottom: 1px solid var(--line);
}

.direction-header h3 {
  margin: 0;
  font-size: 15px;
  line-height: 1.5;
}

.direction-count {
  flex-shrink: 0;
  padding: 7px 9px;
  background: var(--navy-light);
  border-radius: 8px;
  color: var(--navy);
  font-size: 10px;
  font-weight: 900;
}

.stop-list {
  padding: 10px 13px 16px;
}

.stop-row {
  position: relative;
  display: flex;
  align-items: flex-start;
  gap: 12px;
  min-height: 59px;
  padding: 12px 6px;
  border-radius: 12px;
}

.stop-row:not(:last-child)::before {
  content: "";
  position: absolute;
  left: 17px;
  top: 37px;
  bottom: -13px;
  border-left: 2px dotted #bac6be;
  z-index: 0;
}

.stop-point {
  position: relative;
  z-index: 1;
  flex-shrink: 0;
  width: 24px;
  height: 24px;
  border: 2px solid #aab5ad;
  border-radius: 50%;
  background: white;
}

.stop-row.favorite {
  background: #fff9e9;
}

.stop-row.favorite .stop-point {
  border-color: var(--gold);
  background: #fff0be;
}

.stop-content {
  flex: 1;
  min-width: 0;
}

.stop-name {
  font-size: 13px;
  font-weight: 800;
  line-height: 1.5;
  overflow-wrap: anywhere;
}

.stop-code {
  margin-top: 4px;
  color: var(--muted);
  font-size: 10px;
}

.favorite-label {
  color: #946719;
  font-size: 9px;
  font-weight: 900;
  margin-left: 4px;
}

.bus-between {
  position: relative;
  margin: 0 0 10px 36px;
  padding: 12px;
  background: var(--green-light);
  border: 1px solid #c6e4d1;
  border-radius: 13px;
}

.bus-between::before {
  content: "";
  position: absolute;
  left: -23px;
  top: -1px;
  bottom: -11px;
  border-left: 2px dashed #9cc9ab;
}

.bus-between-header {
  display: flex;
  align-items: center;
  gap: 9px;
}

.bus-icon {
  flex-shrink: 0;
  font-size: 25px;
}

.bus-title {
  min-width: 0;
  flex: 1;
}

.bus-title strong {
  display: block;
  color: #17633e;
  font-size: 12px;
  line-height: 1.45;
}

.bus-title small {
  display: block;
  margin-top: 3px;
  color: #62816d;
  font-size: 10px;
  line-height: 1.45;
}

.bus-badge {
  flex-shrink: 0;
  padding: 7px;
  border-radius: 7px;
  background: white;
  color: #17633e;
  font-size: 9px;
  text-align: center;
  font-weight: 900;
}

.bus-badge.stale {
  background: #fff0d3;
  color: #805814;
}

.progress-track {
  height: 6px;
  background: #cbe2d1;
  border-radius: 99px;
  margin-top: 12px;
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  background: var(--green);
  border-radius: 99px;
}

.segment-caption {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  margin-top: 6px;
  color: #5c7e68;
  font-size: 9px;
  line-height: 1.4;
}

.bus-details {
  margin-top: 9px;
  padding-top: 8px;
  border-top: 1px solid #cfe7d6;
  color: #547360;
  font-size: 10px;
  line-height: 1.7;
}

.bus-at-stop {
  margin: 0 0 10px 36px;
  padding: 11px;
  background: #eff7f0;
  border: 1px solid #c6e4d1;
  border-radius: 12px;
}

.bus-at-stop strong {
  font-size: 12px;
  color: #17633e;
}

.bus-at-stop small {
  display: block;
  font-size: 10px;
  color: #64806e;
  margin-top: 5px;
}

.no-data {
  padding: 22px 14px;
  text-align: center;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.7;
}

.info-box {
  margin-top: 17px;
  padding: 14px;
  border: 1px solid #eddfbe;
  border-radius: 14px;
  background: #fff8e8;
  color: #6d541f;
  font-size: 11px;
  line-height: 1.8;
}

.info-box.error {
  background: #fff0ef;
  color: #923d38;
  border-color: #efcfcd;
}

.info-box strong {
  display: block;
  margin-bottom: 4px;
  font-size: 12px;
}

footer {
  padding: 24px 8px 5px;
  text-align: center;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.8;
}

@media(max-width: 560px) {
  .header {
    padding: 20px 14px 23px;
  }

  .header h1 {
    font-size: 25px;
  }

  .container {
    padding: 15px 10px 30px;
  }

  .top-controls {
    align-items: stretch;
  }

  .route-tabs {
    width: 100%;
  }

  .route-tab {
    flex: 1;
  }

  .refresh-button {
    width: 100%;
  }

  .bus-summary {
    grid-template-columns: 1fr;
  }

  .direction-header {
    align-items: flex-start;
  }

  .stop-list {
    padding-left: 8px;
    padding-right: 8px;
  }

  .bus-between,
  .bus-at-stop {
    margin-left: 31px;
  }
}
