:root {
  color-scheme: light;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: #12221e;
  background: #edf3f1;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-width: 320px;
}

button,
select,
input {
  font: inherit;
}

button {
  min-height: 44px;
  border-radius: 0.65rem;
  cursor: pointer;
}

button:disabled,
select:disabled,
input:disabled {
  cursor: not-allowed;
  opacity: 0.55;
}

.app-shell {
  width: min(100%, 960px);
  min-height: 100vh;
  margin: 0 auto;
  padding: 1rem;
}

.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1rem;
}

.eyebrow {
  margin: 0;
  color: #37715f;
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

h1 {
  margin: 0.15rem 0 0;
  font-size: clamp(1.5rem, 5vw, 2.25rem);
}

.status-pill {
  flex: 0 0 auto;
  border-radius: 999px;
  background: #d9e3df;
  color: #29453c;
  padding: 0.4rem 0.7rem;
  font-size: 0.85rem;
  font-weight: 600;
}

.status-pill.connected {
  background: #c7ebd6;
  color: #07592f;
}

.status-pill.error {
  background: #f6d5d2;
  color: #8d231c;
}

.controls {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.6rem;
}

.primary-button,
.secondary-button {
  border: 1px solid transparent;
  padding: 0.55rem 0.85rem;
  font-weight: 700;
}

.primary-button {
  background: #0f5d4f;
  color: #fff;
}

.secondary-button {
  border-color: #91aaa1;
  background: #fff;
  color: #173b31;
}

.refresh-control,
.favorites-control {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  font-size: 0.9rem;
}

.refresh-control select {
  min-height: 44px;
  border: 1px solid #91aaa1;
  border-radius: 0.55rem;
  background: #fff;
  padding: 0 0.4rem;
}

.favorites-control input {
  width: 1.15rem;
  height: 1.15rem;
  accent-color: #0f5d4f;
}

.message {
  min-height: 1.5rem;
  margin: 0.8rem 0;
  color: #3b514a;
  font-size: 0.92rem;
}

.message.error {
  color: #a62820;
}

.view-switcher {
  display: grid;
  grid-template-columns: 1fr 1fr;
  margin-bottom: 0.65rem;
  overflow: hidden;
  border: 1px solid #9db3aa;
  border-radius: 0.7rem;
}

.view-button {
  min-height: 40px;
  border: 0;
  border-radius: 0;
  background: #fff;
  color: #285044;
  font-weight: 700;
}

.view-button.active {
  background: #d7ece5;
  color: #073d32;
}

.view-panel {
  position: relative;
}

#map {
  height: min(63vh, 600px);
  min-height: 360px;
  overflow: hidden;
  border: 1px solid #c0d1ca;
  border-radius: 0.8rem;
  background: #dce7e2;
}

.map-legend {
  position: absolute;
  z-index: 500;
  top: 0.75rem;
  left: 3.5rem;
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem 0.7rem;
  max-width: calc(100% - 5rem);
  border-radius: 0.5rem;
  background: rgb(255 255 255 / 94%);
  padding: 0.45rem 0.6rem;
  box-shadow: 0 1px 5px rgb(0 0 0 / 15%);
  font-size: 0.75rem;
}

.legend-item {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  white-space: nowrap;
}

.history-dot {
  width: 0.65rem;
  height: 0.65rem;
  border: 2px solid #455a64;
  border-radius: 50%;
  background: #90a4ae;
}

.movement-line {
  width: 1rem;
  border-top: 3px solid #455a64;
}

.empty-state {
  position: absolute;
  right: 1rem;
  bottom: 0.2rem;
  left: 1rem;
  margin: 0;
  border-radius: 0.5rem;
  background: rgb(255 255 255 / 92%);
  padding: 0.7rem;
  text-align: center;
  font-size: 0.9rem;
  box-shadow: 0 1px 5px rgb(0 0 0 / 15%);
}

.empty-state[hidden] {
  display: none;
}

.table-scroll {
  overflow-x: auto;
  border: 1px solid #c0d1ca;
  border-radius: 0.8rem;
  background: #fff;
}

table {
  width: 100%;
  min-width: 720px;
  border-collapse: collapse;
}

th,
td {
  padding: 0.8rem;
  border-bottom: 1px solid #e0e8e4;
  text-align: left;
  vertical-align: top;
}

th {
  background: #f1f7f4;
  color: #315446;
  font-size: 0.82rem;
}

tbody tr:last-child td {
  border-bottom: 0;
}

.empty-cell {
  color: #536961;
  text-align: center;
}

.route-badge {
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  padding: 0.25rem 0.55rem;
  font-size: 0.8rem;
  font-weight: 700;
  white-space: nowrap;
}

.route-badge.direct {
  background: #d8e8f4;
  color: #164f78;
}

.route-badge.flooded {
  background: #d8efdf;
  color: #185d34;
}

.route-badge.unknown {
  background: #e8ecea;
  color: #536961;
}

.app-footer {
  display: flex;
  justify-content: center;
  gap: 0.4rem;
  padding: 1rem 0 0.5rem;
  color: #536961;
  font-size: 0.78rem;
}

.app-footer code {
  color: #315446;
}

@media (min-width: 640px) {
  .app-shell {
    padding: 1.5rem;
  }

  .view-switcher {
    width: 260px;
  }
}
