:root {
  --font-sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --radius-sm: 10px;
  --radius-md: 16px;
  --radius-lg: 22px;
  --shadow-card: 0 10px 30px rgba(2, 6, 23, 0.25);
  --transition: 180ms cubic-bezier(0.2, 0.8, 0.2, 1);
}

[data-theme="dark"] {
  --bg: #0b1120;
  --bg-elevated: #111a2e;
  --surface: #152038;
  --surface-2: #1c2a48;
  --border: rgba(148, 163, 184, 0.16);
  --text: #f1f5f9;
  --text-muted: #94a3b8;
  --accent: #38bdf8;
  --accent-strong: #0284c7;
  --green: #22c55e;
  --green-bg: rgba(34, 197, 94, 0.14);
  --yellow: #f59e0b;
  --yellow-bg: rgba(245, 158, 11, 0.15);
  --red: #f43f5e;
  --red-bg: rgba(244, 63, 94, 0.16);
  --info-bg: rgba(56, 189, 248, 0.14);
}

[data-theme="light"] {
  --bg: #eef2f7;
  --bg-elevated: #ffffff;
  --surface: #ffffff;
  --surface-2: #f8fafc;
  --border: rgba(15, 23, 42, 0.11);
  --text: #0f172a;
  --text-muted: #475569;
  --accent: #0284c7;
  --accent-strong: #0369a1;
  --green: #16a34a;
  --green-bg: rgba(22, 163, 74, 0.11);
  --yellow: #d97706;
  --yellow-bg: rgba(217, 119, 6, 0.12);
  --red: #dc2626;
  --red-bg: rgba(220, 38, 38, 0.11);
  --info-bg: rgba(2, 132, 199, 0.1);
  --shadow-card: 0 8px 24px rgba(15, 23, 42, 0.07);
}

*, *::before, *::after {
  box-sizing: border-box;
}

html, body {
  margin: 0;
  padding: 0;
  max-width: 100%;
  overflow-x: hidden;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-sans);
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
}

a {
  color: var(--accent);
  text-decoration: none;
}

.hidden {
  display: none !important;
}

.tabular {
  font-variant-numeric: tabular-nums;
}

.muted {
  color: var(--text-muted);
}

.small {
  font-size: 0.875rem;
}

.mb-md {
  margin-bottom: 1rem;
}

/* Topbar */
.topbar {
  position: sticky;
  top: 0;
  z-index: 30;
  background: var(--bg-elevated);
  border-bottom: 1px solid var(--border);
  backdrop-filter: blur(12px);
}

.topbar-inner {
  max-width: 1380px;
  margin: 0 auto;
  padding: 0.65rem 1rem;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
}

.brand-group {
  display: flex;
  align-items: center;
  gap: 0.7rem;
  min-width: 0;
}

.brand-icon {
  border-radius: 10px;
  flex-shrink: 0;
}

.brand-text {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.brand-title {
  font-weight: 700;
  font-size: 1.05rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.brand-title-mobile,
.mobile-topbar-tools,
.alerts-compact-bar {
  display: none;
}

.mobile-only-inline {
  display: none !important;
}

.school-header-actions {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  flex-wrap: wrap;
}

.banner-inline-btn {
  border: 1px solid rgba(56, 189, 248, 0.45);
  background: var(--surface);
  color: var(--accent);
  font: inherit;
  font-size: 0.78rem;
  font-weight: 700;
  padding: 0.2rem 0.6rem;
  border-radius: 999px;
  cursor: pointer;
  flex-shrink: 0;
}

.icon-pill {
  min-height: 34px;
  min-width: 34px;
  padding: 0 0.5rem;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text);
  font: inherit;
  font-size: 0.9rem;
  font-weight: 700;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.icon-pill.is-on {
  background: var(--green-bg);
  border-color: rgba(34, 197, 94, 0.45);
}

.live-meta {
  font-size: 0.8rem;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  gap: 0.35rem;
  flex-wrap: wrap;
}

.topbar-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.45rem;
}

.chip-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.42rem 0.72rem;
  min-height: 38px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text);
  font: inherit;
  font-size: 0.84rem;
  font-weight: 600;
  cursor: pointer;
  transition: transform var(--transition), border-color var(--transition), background var(--transition);
}

.chip-btn:hover {
  border-color: var(--accent);
}

.chip-btn.is-on {
  background: var(--green-bg);
  border-color: rgba(34, 197, 94, 0.45);
}

.chip-btn.chip-ghost {
  background: transparent;
}

/* Control Bar */
.control-bar {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}

.control-bar-inner {
  max-width: 1380px;
  margin: 0 auto;
  padding: 0.75rem 1rem;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
}

.selector-group, .direction-group {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.6rem;
}

.select-pill {
  display: flex;
  flex-direction: column;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 0.3rem 0.65rem;
  min-width: 145px;
}

.select-pill-wide {
  min-width: 220px;
}

.pill-caption {
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-muted);
  font-weight: 700;
}

.select-pill select {
  background: transparent;
  color: var(--text);
  border: none;
  font: inherit;
  font-weight: 700;
  font-size: 0.96rem;
  padding: 0.15rem 0;
  outline: none;
  cursor: pointer;
  width: 100%;
}

.select-pill select option {
  background: var(--surface);
  color: var(--text);
}

.segmented {
  display: inline-flex;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 3px;
  gap: 3px;
}

.seg-btn {
  border: none;
  background: transparent;
  color: var(--text-muted);
  font: inherit;
  font-weight: 700;
  font-size: 0.9rem;
  padding: 0.48rem 0.9rem;
  border-radius: 9px;
  cursor: pointer;
  min-height: 38px;
  transition: background var(--transition), color var(--transition);
}

.seg-btn.is-active {
  background: var(--accent-strong);
  color: #ffffff;
}

.segmented-sm .seg-btn {
  padding: 0.42rem 0.72rem;
  font-size: 0.82rem;
}

/* Main Layout */
.dashboard-main, .admin-main {
  max-width: 1380px;
  margin: 0 auto;
  padding: 1rem;
}

.dashboard-layout {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.col-left,
.col-right {
  display: contents;
}

#hero-card { order: 1; }
.alerts-card { order: 2; }
#weather-card { order: 3; }
.trips-card { order: 4; }
#school-time-card { order: 5; }

@media (min-width: 900px) {
  .dashboard-layout {
    display: grid;
    grid-template-columns: minmax(0, 1.2fr) minmax(0, 1fr);
    gap: 1.15rem;
    align-items: start;
  }

  .col-left,
  .col-right {
    display: flex;
    flex-direction: column;
    gap: 1.15rem;
    min-width: 0;
  }

  #hero-card,
  #weather-card,
  .trips-card,
  .alerts-card,
  #school-time-card {
    order: 0;
  }
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1.15rem 1.25rem;
  box-shadow: var(--shadow-card);
  min-width: 0;
}

.card-header {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.65rem;
  margin-bottom: 0.85rem;
}

.card-header h2, .card h2 {
  margin: 0;
  font-size: 1.05rem;
  font-weight: 700;
}

.card-header p {
  margin: 0.2rem 0 0;
}

/* Badges & Alerts */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  padding: 0.25rem 0.65rem;
  border-radius: 999px;
  font-size: 0.78rem;
  font-weight: 700;
  background: var(--info-bg);
  color: var(--accent);
}

.badge-subtle {
  background: var(--surface-2);
  color: var(--text-muted);
  border: 1px solid var(--border);
  white-space: nowrap;
}

.badge-ok {
  background: var(--green-bg);
  color: var(--green);
}

.badge-warn {
  background: var(--yellow-bg);
  color: var(--yellow);
}

.badge-danger {
  background: var(--red-bg);
  color: var(--red);
}

.alert {
  padding: 0.85rem 1rem;
  border-radius: var(--radius-md);
  margin-bottom: 0.85rem;
  border: 1px solid var(--border);
  font-size: 0.94rem;
}

.alert-info {
  background: var(--info-bg);
  border-color: rgba(56, 189, 248, 0.35);
}

.alert-warn {
  background: var(--yellow-bg);
  border-color: rgba(245, 158, 11, 0.45);
}

.alert-danger {
  background: var(--red-bg);
  border-color: rgba(244, 63, 94, 0.48);
}

.dwd-alerts {
  margin-bottom: 0.85rem;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

/* Hero Card */
.hero-card {
  position: relative;
  overflow: hidden;
  border-width: 2px;
  transition: border-color var(--transition), background var(--transition);
}

.hero-card.status-green {
  border-color: rgba(34, 197, 94, 0.6);
}

.hero-card.status-yellow {
  border-color: rgba(245, 158, 11, 0.7);
}

.hero-card.status-red {
  border-color: rgba(244, 63, 94, 0.85);
}

.hero-card.status-red.is-urgent {
  animation: urgentPulse 1.8s ease-in-out infinite;
}

@keyframes urgentPulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(244, 63, 94, 0.35); }
  50% { box-shadow: 0 0 0 10px rgba(244, 63, 94, 0); }
}

.hero-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.75rem;
}

.hero-title {
  margin: 0.35rem 0 0.15rem;
  font-size: 1.32rem;
  font-weight: 800;
}

.hero-subtitle {
  margin: 0;
  font-size: 0.88rem;
}

.hero-line-pill {
  flex-shrink: 0;
  min-width: 56px;
  height: 44px;
  padding: 0 0.85rem;
  border-radius: 14px;
  background: var(--accent-strong);
  color: #fff;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  font-size: 1.15rem;
}

.hero-countdown-box {
  margin: 1rem 0;
  padding: 1rem;
  border-radius: var(--radius-md);
  background: var(--surface-2);
  border: 1px solid var(--border);
}

.hero-leave-row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.hero-label {
  font-size: 0.92rem;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.hero-leave-time {
  font-size: clamp(1.9rem, 4vw, 2.7rem);
  font-weight: 900;
  line-height: 1.05;
}

.hero-countdown {
  margin-top: 0.35rem;
  font-size: clamp(1.35rem, 3.2vw, 1.95rem);
  font-weight: 800;
}

.status-green .hero-countdown { color: var(--green); }
.status-yellow .hero-countdown { color: var(--yellow); }
.status-red .hero-countdown { color: var(--red); }

.hero-hint {
  margin-top: 0.35rem;
  font-size: 0.86rem;
  color: var(--text-muted);
}

.hero-metrics {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.65rem;
}

.metric {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 0.65rem 0.75rem;
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.metric-label {
  font-size: 0.75rem;
  color: var(--text-muted);
  font-weight: 600;
}

.metric-val {
  font-size: 1.25rem;
  font-weight: 800;
  margin: 0.1rem 0;
}

.metric-sub {
  font-size: 0.78rem;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

#metric-dep-sub,
#metric-arr-sub {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.18rem 0.32rem;
  white-space: normal;
  overflow: visible;
  text-overflow: clip;
  line-height: 1.25;
}

.underground-tag {
  display: inline-flex;
  align-items: center;
  padding: 0.08rem 0.42rem;
  border-radius: 999px;
  font-size: 0.68rem;
  font-weight: 700;
  line-height: 1.25;
  background: var(--info-bg);
  color: var(--accent);
  border: 1px solid rgba(56, 189, 248, 0.28);
  white-space: nowrap;
}

/* Schulbeginn & Override */
.school-time-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.9rem;
}

.school-start-display {
  display: flex;
  flex-direction: column;
}

.school-start-display strong {
  font-size: 1.35rem;
  font-weight: 800;
}

.override-controls {
  flex: 1 1 260px;
}

.field-inline {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
}

.inline-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
  align-items: center;
}

/* Weather */
.weather-icon-lg {
  font-size: 2.1rem;
  line-height: 1;
}

.weather-main {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 1rem;
  align-items: center;
}

.weather-now {
  display: flex;
  flex-direction: column;
  padding-right: 0.85rem;
  border-right: 1px solid var(--border);
}

.weather-now-top {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
}

.weather-temp {
  font-size: 2rem;
  font-weight: 900;
  line-height: 1.05;
}

.weather-desc {
  font-weight: 700;
  margin-top: 0.2rem;
}

.weather-day {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.weather-day-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.6rem;
  font-size: 0.9rem;
}

.weather-day-row > strong {
  white-space: nowrap;
  flex-shrink: 0;
}

.tips-list {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
  margin-top: 0.85rem;
}

.tips-list:empty {
  display: none;
}

.tip-pill {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.35rem 0.7rem;
  border-radius: 999px;
  font-size: 0.82rem;
  font-weight: 600;
  background: var(--surface-2);
  border: 1px solid var(--border);
}

/* Trips List */
.trips-list {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.trip-item {
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--surface-2);
  padding: 0.9rem 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
}

.trip-item.is-ideal {
  border-width: 2px;
  border-color: var(--accent);
  background: var(--bg-elevated);
}

.trip-item.is-missed {
  opacity: 0.62;
}

.trip-item.is-cancelled {
  border-color: rgba(244, 63, 94, 0.7);
  background: var(--red-bg);
}

.trip-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
}

.trip-role-group {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.line-tag {
  display: inline-flex;
  align-items: center;
  padding: 0.18rem 0.55rem;
  border-radius: 8px;
  background: var(--accent-strong);
  color: #fff;
  font-weight: 800;
  font-size: 0.85rem;
}

.trip-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 0.55rem;
}

@media (max-width: 640px) {
  .trip-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

.trip-cell {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.trip-cell-label {
  font-size: 0.72rem;
  color: var(--text-muted);
  font-weight: 600;
}

.trip-cell-val {
  font-size: 1.05rem;
  font-weight: 800;
}

.delay-pos {
  color: var(--red);
  font-weight: 700;
  font-size: 0.82rem;
}

.delay-ok {
  color: var(--green);
  font-weight: 700;
  font-size: 0.82rem;
}

.strikethrough {
  text-decoration: line-through;
  opacity: 0.65;
  margin-right: 0.3rem;
}

/* VRR Alerts */
.vrr-alerts-list {
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
}

.vrr-alerts-list > p {
  margin: 0;
}

.vrr-alert-box {
  border-radius: var(--radius-sm);
  padding: 0.8rem 0.9rem;
  border: 1px solid rgba(245, 158, 11, 0.4);
  background: var(--yellow-bg);
}

.vrr-alert-box h3 {
  margin: 0 0 0.25rem;
  font-size: 0.95rem;
}

.vrr-alert-box p {
  margin: 0.25rem 0 0;
  font-size: 0.85rem;
  white-space: pre-line;
}

/* Forms, Buttons, Inputs */
input, select, textarea {
  font: inherit;
  color: var(--text);
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 0.55rem 0.75rem;
  min-height: 40px;
  width: 100%;
  min-width: 0;
}

.inline-actions select,
.inline-actions input {
  width: auto;
}

input:focus, select:focus {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  padding: 0.55rem 0.95rem;
  min-height: 40px;
  font: inherit;
  font-weight: 700;
  cursor: pointer;
  transition: filter var(--transition), background var(--transition);
}

.btn:hover {
  filter: brightness(1.06);
}

.btn-lg {
  min-height: 46px;
  font-size: 1rem;
  width: 100%;
}

.btn-sm {
  min-height: 34px;
  padding: 0.35rem 0.7rem;
  font-size: 0.84rem;
}

.btn-primary {
  background: var(--accent-strong);
  color: #ffffff;
}

.btn-secondary {
  background: var(--surface-2);
  border-color: var(--border);
  color: var(--text);
}

.btn-danger {
  background: var(--red-bg);
  border-color: rgba(244, 63, 94, 0.5);
  color: var(--red);
}

.btn-ghost {
  background: transparent;
  border-color: var(--border);
  color: var(--text-muted);
}

/* Auth Page */
.auth-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}

.auth-card {
  width: 100%;
  max-width: 440px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1.5rem;
  box-shadow: var(--shadow-card);
}

.admin-gate {
  margin: 2rem auto;
}

.auth-brand {
  display: flex;
  align-items: center;
  gap: 0.85rem;
  margin-bottom: 1.15rem;
}

.auth-brand h1 {
  margin: 0;
  font-size: 1.3rem;
}

.auth-brand p {
  margin: 0.1rem 0 0;
  font-size: 0.9rem;
}

.stack-form {
  display: flex;
  flex-direction: column;
  gap: 0.9rem;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
}

.field > span {
  font-size: 0.86rem;
  font-weight: 600;
  color: var(--text-muted);
}

.checkbox-row {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  cursor: pointer;
  font-size: 0.92rem;
}

.checkbox-row input[type="checkbox"] {
  width: 18px;
  height: 18px;
  min-height: 18px;
}

/* Admin Specific */
.admin-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
  margin-bottom: 1rem;
}

.tab-btn {
  padding: 0.55rem 0.95rem;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text-muted);
  font: inherit;
  font-weight: 700;
  font-size: 0.9rem;
  cursor: pointer;
  min-height: 40px;
}

.tab-btn.is-active {
  background: var(--accent-strong);
  color: #fff;
  border-color: transparent;
}

.tab-panel {
  display: none;
}

.tab-panel.is-active {
  display: block;
}

.admin-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 1rem;
  align-items: start;
}

@media (min-width: 880px) {
  .admin-grid {
    grid-template-columns: minmax(280px, 0.9fr) minmax(360px, 1.3fr);
  }
}

.admin-list {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.admin-list-item {
  width: 100%;
  text-align: left;
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text);
  border-radius: var(--radius-sm);
  padding: 0.7rem 0.85rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
}

.admin-list-item.is-selected {
  border-color: var(--accent);
  box-shadow: 0 0 0 1px var(--accent);
}

.form-row-2 {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.75rem;
}

.form-row-3 {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0.75rem;
}

@media (max-width: 640px) {
  .form-row-2, .form-row-3 {
    grid-template-columns: 1fr;
  }
}

.form-actions, .inline-between {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.6rem;
}

.autocomplete-wrap {
  position: relative;
}

.autocomplete-list {
  position: absolute;
  left: 0;
  right: 0;
  top: 100%;
  z-index: 40;
  background: var(--bg-elevated);
  border: 1px solid var(--accent);
  border-radius: var(--radius-sm);
  max-height: 240px;
  overflow-y: auto;
  box-shadow: var(--shadow-card);
}

.autocomplete-opt {
  width: 100%;
  text-align: left;
  border: none;
  border-bottom: 1px solid var(--border);
  background: transparent;
  color: var(--text);
  padding: 0.6rem 0.75rem;
  cursor: pointer;
  display: flex;
  flex-direction: column;
}

.autocomplete-opt:hover {
  background: var(--surface-2);
}

.stop-selected {
  margin-top: 0.25rem;
}

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

.table-wrap {
  overflow-x: auto;
}

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

.data-table th, .data-table td {
  padding: 0.5rem 0.45rem;
  border-bottom: 1px solid var(--border);
  text-align: left;
}

.data-table input {
  min-height: 36px;
  padding: 0.35rem 0.5rem;
  width: 100%;
}

.test-result {
  margin-top: 0.85rem;
  padding: 0.85rem;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--surface-2);
  font-size: 0.88rem;
}

.toast {
  position: fixed;
  bottom: 1.25rem;
  right: 1.25rem;
  z-index: 50;
  background: var(--accent-strong);
  color: #fff;
  padding: 0.75rem 1.1rem;
  border-radius: var(--radius-sm);
  font-weight: 700;
  box-shadow: var(--shadow-card);
}

.toast.is-error {
  background: var(--red);
}

.divider {
  border: none;
  border-top: 1px solid var(--border);
  margin: 1rem 0;
}

.skeleton-box {
  padding: 2rem;
  text-align: center;
  color: var(--text-muted);
}

@media (max-width: 899px) {
  .topbar {
    position: static;
  }
  .topbar-inner {
    padding: 0.42rem 0.75rem;
    gap: 0.45rem;
  }
  .brand-group {
    flex: 1 1 auto;
    gap: 0.5rem;
  }
  .brand-icon {
    width: 28px;
    height: 28px;
  }
  .brand-title {
    font-size: 0.94rem;
  }
  .brand-title-desktop {
    display: none;
  }
  .brand-title-mobile {
    display: inline;
  }
  .live-meta {
    font-size: 0.74rem;
  }
  .mobile-topbar-tools {
    display: flex;
    align-items: center;
    gap: 0.35rem;
    flex-shrink: 0;
  }
  .topbar-actions {
    display: none;
    width: 100%;
    padding-top: 0.45rem;
    border-top: 1px solid var(--border);
  }
  body.mobile-menu-open .topbar-actions {
    display: flex;
  }

  .control-bar-inner {
    padding: 0.4rem 0.75rem;
    flex-direction: row;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.4rem;
  }
  .selector-group,
  .direction-group {
    display: contents;
  }
  .select-pill-user,
  #day-toggle-wrap {
    display: none;
  }
  body.mobile-menu-open .select-pill-user,
  body.mobile-menu-open #day-toggle-wrap {
    display: flex;
    flex: 1 1 100%;
  }
  .select-pill-fav {
    flex: 1 1 120px;
    min-width: 0;
    padding: 0.08rem 0.5rem;
    min-height: 36px;
    justify-content: center;
    order: 2;
  }
  .select-pill-fav .pill-caption {
    display: none;
  }
  .select-pill-fav select {
    font-size: 0.85rem;
    padding: 0.15rem 0;
  }
  .direction-group > .segmented:first-child {
    order: 1;
  }
  .segmented {
    padding: 2px;
  }
  .segmented .seg-btn {
    padding: 0.34rem 0.62rem;
    min-height: 32px;
    font-size: 0.83rem;
  }

  .dashboard-main {
    padding: 0.55rem 0.75rem 1rem;
  }
  .dashboard-layout {
    gap: 0.6rem;
  }
  .alert {
    padding: 0.42rem 0.7rem;
    margin-bottom: 0.55rem;
    font-size: 0.8rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
    border-radius: 12px;
  }

  .card {
    padding: 0.78rem 0.88rem;
    border-radius: 16px;
  }
  .hero-badge {
    font-size: 0.72rem;
  }
  .hero-title {
    font-size: 1.06rem;
    margin: 0.18rem 0 0.08rem;
  }
  .hero-subtitle {
    font-size: 0.79rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }
  .hero-line-pill {
    min-width: 44px;
    height: 34px;
    font-size: 0.96rem;
    border-radius: 10px;
  }
  .hero-countdown-box {
    margin: 0.5rem 0;
    padding: 0.55rem 0.72rem;
    border-radius: 12px;
  }
  .hero-label {
    font-size: 0.72rem;
  }
  .hero-leave-time {
    font-size: 1.55rem;
  }
  .hero-countdown {
    font-size: 1.12rem;
    margin-top: 0.12rem;
  }
  .hero-hint {
    font-size: 0.76rem;
    margin-top: 0.18rem;
  }
  .hero-metrics {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 0.38rem;
  }
  .metric {
    padding: 0.42rem 0.48rem;
  }
  .metric-label {
    font-size: 0.66rem;
  }
  .metric-val {
    font-size: 0.94rem;
  }
  .metric-sub {
    font-size: 0.69rem;
  }
  .underground-tag {
    font-size: 0.64rem;
    padding: 0.05rem 0.34rem;
  }

  .alerts-card.is-clear {
    padding: 0.48rem 0.8rem;
  }
  .alerts-card.is-clear .card-header,
  .alerts-card.is-clear #vrr-alerts-list {
    display: none;
  }
  .alerts-card.is-clear .alerts-compact-bar {
    display: flex;
    align-items: center;
    gap: 0.45rem;
    font-size: 0.83rem;
    font-weight: 700;
    color: var(--green);
  }

  #weather-card .card-header {
    margin-bottom: 0.4rem;
  }
  #weather-card .weather-icon-lg {
    font-size: 1.6rem;
  }
  #weather-card .weather-main {
    display: flex;
    flex-direction: column;
    align-items: stretch;
    gap: 0.5rem;
  }
  #weather-card .weather-now {
    padding: 0 0 0.45rem 0;
    border-right: none;
    border-bottom: 1px solid var(--border);
    gap: 0.15rem;
  }
  #weather-card .weather-now-top {
    flex-direction: row;
    align-items: baseline;
    gap: 0.55rem;
    flex-wrap: nowrap;
  }
  #weather-card .weather-temp {
    font-size: 1.45rem;
    white-space: nowrap;
    flex-shrink: 0;
  }
  #weather-card .weather-desc {
    font-size: 0.9rem;
    margin-top: 0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }
  #weather-card #weather-apparent {
    font-size: 0.78rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }
  #weather-card .weather-day {
    gap: 0.28rem;
  }
  #weather-card .weather-day-row {
    font-size: 0.82rem;
    gap: 0.45rem;
  }
  #weather-card .weather-day-row > span,
  #weather-card .weather-day-row > strong {
    white-space: nowrap;
  }
  #weather-card .tips-list {
    margin-top: 0.5rem;
  }
  #weather-card .tip-pill {
    font-size: 0.76rem;
    padding: 0.26rem 0.58rem;
  }

  .mobile-only-inline {
    display: inline-flex !important;
    align-items: center;
  }
  #school-time-card .card-header {
    margin-bottom: 0;
    align-items: center;
  }
  #school-time-card.is-expanded .card-header {
    margin-bottom: 0.65rem;
  }
  #school-time-card .school-time-row {
    display: none;
  }
  #school-time-card.is-expanded .school-time-row {
    display: flex;
  }
}
