:root {
  --bg: #0b110d;
  --surface: #131c16;
  --surface-2: #1b2820;
  --border: #27392e;
  --text: #eef5f0;
  --muted: #93a799;
  --go-green: #2e7d32;
  --go-bright: #4caf50;
  --amber: #ffb300;
  --red: #ef5350;
  --blue: #4fc3f7;
  --radius: 14px;
}

* {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, sans-serif;
  font-size: 15px;
  line-height: 1.4;
}

.app-shell {
  min-height: 100dvh;
  max-width: 760px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  padding-top: env(safe-area-inset-top);
  padding-bottom: calc(74px + env(safe-area-inset-bottom));
}

.top-bar {
  position: sticky;
  top: 0;
  z-index: 20;
  background: rgba(11, 17, 13, 0.92);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
  padding: 12px 16px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
}

.brand-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--amber);
  box-shadow: 0 0 8px var(--amber);
}
.brand-dot.live {
  background: var(--go-bright);
  box-shadow: 0 0 8px var(--go-bright);
}
.brand-dot.err {
  background: var(--red);
  box-shadow: 0 0 8px var(--red);
}

.brand-title {
  font-weight: 700;
  font-size: 17px;
  letter-spacing: -0.2px;
}

.brand-sub {
  font-size: 12px;
  color: var(--muted);
}

.top-actions {
  display: flex;
  gap: 8px;
}

.main-content {
  padding: 14px 14px 20px;
  flex: 1;
}

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

.card, .route-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px;
  margin-bottom: 14px;
}

.card h2 {
  margin: 0 0 10px;
  font-size: 16px;
  font-weight: 700;
}
.card h3 {
  margin: 0 0 8px;
  font-size: 15px;
}

.card-header-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  margin-bottom: 8px;
}
.card-header-row h2 {
  margin: 0;
}

.route-endpoints {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.endpoint {
  flex: 1;
  min-width: 0;
}
.endpoint.right {
  text-align: right;
}
.endpoint-label {
  display: block;
  font-size: 11px;
  color: var(--muted);
  font-weight: 600;
  letter-spacing: 0.6px;
}
.endpoint-name {
  display: block;
  font-size: 17px;
  font-weight: 700;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.btn-swap {
  background: var(--surface-2);
  color: var(--go-bright);
  border: 1px solid var(--border);
  border-radius: 999px;
  width: 40px;
  height: 40px;
  font-size: 18px;
  cursor: pointer;
  flex-shrink: 0;
}

.route-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 10px;
}

.pill {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 12px;
  font-weight: 600;
  padding: 4px 9px;
  border-radius: 999px;
  background: rgba(76, 175, 80, 0.16);
  color: #a5d6a7;
  border: 1px solid rgba(76, 175, 80, 0.32);
}
.pill.muted {
  background: var(--surface-2);
  color: var(--muted);
  border-color: var(--border);
}
.pill.warn {
  background: rgba(255, 179, 0, 0.16);
  color: #ffd54f;
  border-color: rgba(255, 179, 0, 0.35);
}
.pill.danger {
  background: rgba(239, 83, 80, 0.18);
  color: #ff8a80;
  border-color: rgba(239, 83, 80, 0.4);
}
.pill.info {
  background: rgba(79, 195, 247, 0.15);
  color: #81d4fa;
  border-color: rgba(79, 195, 247, 0.3);
}

.hidden {
  display: none !important;
}

.advisories {
  background: rgba(255, 179, 0, 0.08);
  border: 1px solid rgba(255, 179, 0, 0.3);
  border-radius: var(--radius);
  margin-bottom: 12px;
  overflow: hidden;
}
.advisories-toggle {
  width: 100%;
  background: transparent;
  border: none;
  color: #ffd54f;
  padding: 10px 14px;
  font-size: 13px;
  font-weight: 600;
  display: flex;
  justify-content: space-between;
  cursor: pointer;
}
.advisories-list {
  margin: 0;
  padding: 0 14px 12px 28px;
  font-size: 13px;
  color: var(--text);
}
.advisories-list li + li {
  margin-top: 6px;
}

.departures-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.dep-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 13px 14px;
  cursor: pointer;
  transition: border-color 0.15s ease;
}
.dep-card.past {
  opacity: 0.58;
}
.dep-card:active {
  border-color: var(--go-bright);
}

.dep-main {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
}

.dep-times {
  display: flex;
  align-items: baseline;
  gap: 8px;
}
.dep-sched {
  font-size: 21px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}
.dep-sched.struck {
  text-decoration: line-through;
  color: var(--muted);
  font-size: 16px;
}
.dep-pred {
  font-size: 21px;
  font-weight: 700;
  color: var(--amber);
  font-variant-numeric: tabular-nums;
}
.dep-countdown {
  font-size: 13px;
  font-weight: 600;
  color: var(--go-bright);
}

.dep-right {
  display: flex;
  align-items: center;
  gap: 8px;
}

.plat-badge {
  min-width: 54px;
  text-align: center;
  padding: 6px 10px;
  border-radius: 10px;
  font-weight: 700;
  font-size: 14px;
  background: var(--surface-2);
  color: var(--muted);
  border: 1px solid var(--border);
}
.plat-badge.assigned {
  background: var(--go-green);
  color: #ffffff;
  border-color: var(--go-bright);
}
.plat-badge.hint {
  border-style: dashed;
  color: #a5d6a7;
}
.plat-badge.proceed {
  box-shadow: 0 0 0 2px rgba(76, 175, 80, 0.45);
  animation: pulse 1.8s infinite;
}

@keyframes pulse {
  0%, 100% { box-shadow: 0 0 0 1px rgba(76, 175, 80, 0.35); }
  50% { box-shadow: 0 0 0 5px rgba(76, 175, 80, 0.15); }
}

.dep-sub {
  margin-top: 8px;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: var(--muted);
}

.dep-detail {
  margin-top: 12px;
  padding-top: 10px;
  border-top: 1px solid var(--border);
}
.stop-row {
  display: grid;
  grid-template-columns: 1fr auto auto;
  gap: 8px;
  padding: 5px 0;
  font-size: 13px;
  border-bottom: 1px dashed rgba(39, 57, 46, 0.6);
}
.stop-row:last-child {
  border-bottom: none;
}
.stop-row.not-stopping {
  opacity: 0.4;
}

.field {
  margin-bottom: 10px;
}
.field label {
  display: block;
  font-size: 12px;
  color: var(--muted);
  margin-bottom: 4px;
  font-weight: 600;
}
.field input, .field select {
  width: 100%;
  background: var(--surface-2);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 9px 10px;
  font-size: 14px;
}

.grid-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}
.grid-3 {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}

.btn-primary, .btn-secondary, .btn-small, .btn-icon {
  border: none;
  border-radius: 10px;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.btn-primary {
  background: var(--go-green);
  color: #fff;
  padding: 10px 14px;
  width: 100%;
  font-size: 14px;
}
.btn-secondary {
  background: var(--surface-2);
  color: var(--text);
  border: 1px solid var(--border);
  padding: 10px 14px;
  width: 100%;
  font-size: 14px;
}
.btn-small {
  background: var(--go-green);
  color: #fff;
  padding: 6px 11px;
  font-size: 12px;
}
.btn-small.secondary {
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--text);
}
.btn-icon {
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 6px 10px;
  font-size: 13px;
}
.btn-row {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}
.btn-row > .btn-primary, .btn-row > .btn-secondary {
  flex: 1;
}

.input-with-btn {
  display: flex;
  gap: 6px;
}
.input-with-btn input {
  flex: 1;
}

.hint {
  font-size: 12.5px;
  color: var(--muted);
  margin: 0 0 10px;
}

.rules-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.rule-item {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px 12px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
}
.rule-form {
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid var(--border);
}
.days-picker {
  display: flex;
  gap: 6px;
}
.day-btn {
  flex: 1;
  padding: 7px 0;
  border-radius: 8px;
  background: var(--surface-2);
  color: var(--muted);
  border: 1px solid var(--border);
  font-weight: 700;
  cursor: pointer;
}
.day-btn.active {
  background: var(--go-green);
  color: #fff;
  border-color: var(--go-bright);
}

.toggles-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-bottom: 12px;
}
.toggle-item {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  background: var(--surface-2);
  padding: 8px 10px;
  border-radius: 10px;
  border: 1px solid var(--border);
}

.subcard {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 11px;
  margin-bottom: 10px;
}
.subcard-title {
  font-weight: 700;
  font-size: 13.5px;
  margin-bottom: 4px;
}

.status-box {
  margin-top: 10px;
  padding: 10px;
  border-radius: 10px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  font-size: 12px;
  white-space: pre-wrap;
  word-break: break-word;
}

.webhook-urls {
  margin-top: 10px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.copy-row {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 8px;
  font-size: 11.5px;
  word-break: break-all;
}

.kpi-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
  margin-bottom: 14px;
}
.kpi-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px;
}
.kpi-label {
  font-size: 11.5px;
  color: var(--muted);
  font-weight: 600;
}
.kpi-val {
  font-size: 22px;
  font-weight: 700;
  margin-top: 2px;
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12.5px;
}
.data-table th, .data-table td {
  text-align: left;
  padding: 7px 6px;
  border-bottom: 1px solid var(--border);
}
.data-table th {
  color: var(--muted);
  font-weight: 600;
}

.events-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-height: 420px;
  overflow-y: auto;
}
.event-row {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 9px 11px;
  font-size: 13px;
}
.event-head {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  font-weight: 700;
}
.event-meta {
  font-size: 11.5px;
  color: var(--muted);
  margin-top: 3px;
}

.stats-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 12px;
  font-size: 13.5px;
}
.stat-row {
  display: flex;
  justify-content: space-between;
  padding: 6px 0;
  border-bottom: 1px solid var(--border);
}

.checklist {
  list-style: none;
  padding: 0;
  margin: 0 0 10px;
}
.checklist li {
  padding: 6px 0;
  font-size: 13.5px;
}

.empty-state {
  text-align: center;
  padding: 28px 16px;
  color: var(--muted);
  background: var(--surface);
  border: 1px dashed var(--border);
  border-radius: var(--radius);
}

.bottom-nav {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 30;
  background: rgba(11, 17, 13, 0.95);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-top: 1px solid var(--border);
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  padding-bottom: env(safe-area-inset-bottom);
}
.nav-btn {
  background: transparent;
  border: none;
  color: var(--muted);
  padding: 8px 4px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  font-size: 11px;
  font-weight: 600;
  cursor: pointer;
}
.nav-btn.active {
  color: var(--go-bright);
}
.nav-ico {
  font-size: 18px;
}

code {
  background: var(--surface-2);
  padding: 2px 5px;
  border-radius: 5px;
  font-size: 12px;
}
