:root {
  --bg: #f7f5ef;
  --paper: #fffdf8;
  --ink: #1f2a2e;
  --accent: #176b53;
  --accent-2: #f2a900;
  --danger: #b42318;
  --muted: #5b676b;
  --line: #d9d4c7;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: "Manrope", sans-serif;
  background: radial-gradient(circle at top right, #f5d58d 0%, var(--bg) 45%), var(--bg);
  color: var(--ink);
}

.container {
  width: min(1100px, 92vw);
  margin: 0 auto;
}

.site-header,
.admin-header {
  border-bottom: 1px solid var(--line);
  background: rgba(255, 253, 248, 0.9);
  backdrop-filter: blur(6px);
}

.brand {
  display: inline-flex;
  flex-direction: column;
  align-items: stretch;
  font-weight: 800;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--accent);
  text-decoration: none;
  line-height: 1;
}

.brand__title {
  display: block;
}

.brand__sub {
  display: block;
  width: 100%;
  margin-top: 2px;
  font-size: 0.52em;
  font-weight: 700;
  letter-spacing: 0.15em;
  text-transform: lowercase;
  color: var(--muted);
  text-align: justify;
  text-align-last: justify;
}

.site-nav-links {
  gap: 8px;
}

.site-nav-links .nav-link {
  text-decoration: none;
  color: var(--ink);
  font-weight: 600;
  border-radius: 8px;
  padding: 8px 10px;
}

.site-nav-links .nav-link:hover,
.site-nav-links .nav-link:focus {
  background: rgba(23, 107, 83, 0.08);
}

.site-nav-links .panel-link {
  color: var(--accent);
}

.hero {
  padding: 56px 0 28px;
}

.hero-grid {
  display: grid;
  grid-template-columns: 1.2fr .8fr;
  gap: 24px;
}

h1 {
  font-size: clamp(2rem, 4vw, 3rem);
  margin-bottom: 12px;
}

.eyebrow {
  color: var(--accent);
  text-transform: uppercase;
  letter-spacing: .08em;
  font-weight: 700;
}

.lead {
  color: var(--muted);
  line-height: 1.65;
}

.hero-actions {
  display: flex;
  gap: 12px;
  margin-top: 20px;
}

.home-bus-panel {
  display: flex;
  flex-direction: column;
  gap: 14px;
  align-self: start;
}

.home-bus-panel__head {
  background: rgba(255, 253, 248, 0.72);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 18px;
  backdrop-filter: blur(6px);
}

.home-bus-panel__head h2 {
  margin: 0 0 8px;
  font-size: clamp(1.35rem, 2vw, 1.75rem);
}

.home-bus-panel__eyebrow {
  margin: 0 0 6px;
  color: var(--accent);
  text-transform: uppercase;
  letter-spacing: .08em;
  font-size: .76rem;
  font-weight: 800;
}

.home-bus-panel__text {
  margin: 0 0 14px;
  color: var(--muted);
  line-height: 1.6;
}

.card,
.content-block,
.table-wrap {
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 20px;
}

.card-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 16px;
}

.metric {
  font-size: 2rem;
  margin: 0;
  color: var(--accent);
}

.content-block {
  margin: 24px auto;
}

.narrow {
  max-width: 760px;
}

.center-box {
  margin: 40px auto;
}

.form-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.alert {
  margin-top: 16px;
}

.error-text {
  color: var(--danger);
  display: inline-block;
  margin-top: 4px;
}

.status-badge {
  display: inline-block;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: .75rem;
  font-weight: 700;
  letter-spacing: .03em;
}

.status-badge.ok {
  background: #e7f8ef;
  color: #176b53;
}

.status-badge.fail {
  background: #fdecec;
  color: #b42318;
}

.table-wrap {
  overflow: auto;
}

.map-embed {
  width: 100%;
  aspect-ratio: 16 / 9;
  border: 1px solid var(--line);
  border-radius: 12px;
  overflow: hidden;
  background: #fff;
  display: block;
}

.map-embed iframe,
.map-embed img {
  width: 100%;
  height: 100%;
  border: 0;
  object-fit: cover;
  display: block;
}

.route-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
  gap: 1rem;
}

.bus-hour-head {
  width: 78px;
  min-width: 78px;
  max-width: 78px;
  background: #0f4c81;
  color: #fff;
}

.bus-hour-cell {
  width: 78px;
  min-width: 78px;
  max-width: 78px;
  white-space: nowrap;
  background: #e8f3ff;
  color: #0f4c81;
  font-weight: 700;
}

.bus-minute-pill {
  display: inline-block;
  padding: 0.12rem 0.45rem;
  margin: 0 0.25rem 0.25rem 0;
  border-radius: 999px;
  background: #f1f5f9;
  color: #0f4c81;
  font-weight: 700;
  font-size: 0.88rem;
}

.next-bus-card {
  padding: 1rem 1.1rem;
}

.next-bus-card__title {
  font-size: 0.78rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: #64748b;
  margin-bottom: 0.8rem;
}

.next-bus-direction {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.5rem 0.75rem;
  margin-bottom: 0.6rem;
}

.next-bus-direction:last-child {
  margin-bottom: 0;
}

.next-bus-direction__label {
  font-size: 0.88rem;
  font-weight: 600;
  color: #1e3a5f;
  min-width: 0;
  flex-shrink: 0;
}

.next-bus-badges {
  display: flex;
  gap: 0.4rem;
  flex-wrap: wrap;
}

.next-bus-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  padding: 0.28rem 0.65rem;
  border-radius: 999px;
  background: #e8f3ff;
  border: 1.5px solid #b8d8f8;
  font-size: 0.88rem;
  line-height: 1.2;
}

.next-bus-badge--tomorrow {
  background: #fef9ec;
  border-color: #f5d87a;
}

.next-bus-badge--empty {
  background: #f1f5f9;
  border-color: #e2e8f0;
  opacity: 0.6;
}

.next-bus-badge__code {
  font-weight: 700;
  color: #0f4c81;
  font-size: 0.82rem;
}

.next-bus-badge--tomorrow .next-bus-badge__code {
  color: #92600a;
}

.next-bus-badge__time {
  font-weight: 700;
  color: #0f4c81;
  font-size: 0.95rem;
}

.next-bus-badge--tomorrow .next-bus-badge__time {
  color: #92600a;
}

.next-bus-badge--empty .next-bus-badge__time {
  color: #94a3b8;
  font-weight: 400;
}

.next-bus-badge__time small {
  font-size: 0.72rem;
  font-weight: 400;
  margin-left: 0.1rem;
  opacity: 0.8;
}

.next-bus-badge__mins {
  font-size: 0.75rem;
  font-weight: 600;
  color: #2563a8;
  background: #d0e8ff;
  border-radius: 999px;
  padding: 0.05rem 0.42rem;
  margin-left: 0.1rem;
  white-space: nowrap;
}

.next-bus-badge--tomorrow .next-bus-badge__mins {
  color: #7a4f08;
  background: #fde9a2;
}

.log-header-row {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 16px;
  margin-bottom: 16px;
}

.log-viewer {
  background: #111827;
  color: #e5eef7;
  padding: 16px;
  border-radius: 12px;
  overflow: auto;
  min-height: 320px;
  white-space: pre-wrap;
  font-family: "Courier New", monospace;
  line-height: 1.5;
}

.table-wrap table {
  width: 100%;
  border-collapse: collapse;
}

.table-wrap th,
.table-wrap td {
  text-align: left;
  border-bottom: 1px solid var(--line);
  padding: 10px;
}

.data-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  margin-bottom: 8px;
}

.data-meta__tag {
  display: inline-flex;
  align-items: stretch;
  border-radius: 999px;
  overflow: hidden;
  font-size: .78rem;
  font-weight: 600;
  border: 1px solid var(--line);
  line-height: 1;
}

.data-meta__label {
  background: var(--line);
  color: var(--muted);
  padding: 4px 9px;
  display: flex;
  align-items: center;
}

.data-meta__value {
  background: var(--paper);
  color: var(--ink);
  padding: 4px 10px;
  display: flex;
  align-items: center;
}

.site-footer {
  margin-top: 28px;
  padding: 18px 0;
  border-top: 1px solid var(--line);
  color: var(--muted);
  text-align: center;
}

@media (max-width: 900px) {
  .navbar-collapse {
    margin-top: 10px;
  }

  .site-nav-links {
    gap: 6px;
  }

  .site-nav-links .nav-link {
    border: 1px solid var(--line);
    background: var(--paper);
  }

  .hero-grid,
  .card-grid {
    grid-template-columns: 1fr;
  }

  .hero {
    padding-top: 36px;
  }

  .hero-actions {
    flex-wrap: wrap;
  }

  .home-bus-panel {
    margin-top: 8px;
  }

  .content-block,
  .card,
  .table-wrap {
    padding: 16px;
  }

  .log-header-row {
    flex-direction: column;
  }

  .hero-actions .btn {
    width: 100%;
    text-align: center;
  }

  .card .btn {
    width: auto;
  }
}

@media (max-width: 640px) {
  .container {
    width: min(1100px, 94vw);
  }

  .site-nav-links {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
  }

  .site-nav-links .nav-link {
    text-align: center;
    font-size: .92rem;
  }
}
