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

html, body {
  margin: 0;
  padding: 0;
}

html {
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: #0b0d10;
  color: #e5e7eb;
}

body {
  background: #0b0d10;
  color: #e5e7eb;
}

/* Typography & utility */
.mono {
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
  font-variant-numeric: tabular-nums;
}

.strong {
  font-weight: 600;
}

.text-right {
  text-align: right;
}

/* Header */
.header {
  position: sticky;
  top: 0;
  z-index: 40;
  border-bottom: 1px solid #1f2933;
  background: rgba(12, 15, 20, 0.94);
  backdrop-filter: blur(10px);
}

.header-inner {
  max-width: 64rem;
  margin: 0 auto;
  padding: 0.5rem 0.7rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.brand-box {
  width: 2.2rem;
  height: 2.2rem;
  border-radius: 0.6rem;
  background: #000;
  color: #facc15;
  display: grid;
  place-items: center;
  font-weight: 700;
  user-select: none;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  margin-left: auto;
  flex-shrink: 0;
}

.font-buttons {
  display: flex;
  align-items: center;
  gap: 0.25rem;
}

/* Buttons */
.btn-ghost,
.btn-outline {
  font-size: 0.75rem;
  padding: 0.2rem 0.45rem;
  border-radius: 0.5rem;
  border: 1px solid #4b5563;
  background: transparent;
  color: #e5e7eb;
  cursor: pointer;
}

.btn-outline {
  font-size: 0.8rem;
  padding: 0.25rem 0.6rem;
}

.btn-outline:hover {
  background: #111827;
}

/* Controls */
.header-controls {
  max-width: 64rem;
  margin: 0 auto;
  padding: 0 0.7rem 0.5rem;
}

.controls-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.35rem;
}

/* Search */
.search-box {
  flex: 1;
  min-width: 220px;
  display: flex;
  align-items: center;
  gap: 0.3rem;
  border-radius: 0.65rem;
  border: 1px solid #4b5563;
  background: #020617;
  padding: 0.25rem 0.55rem;
}

.search-icon {
  font-size: 0.8rem;
  opacity: 0.7;
}

.search-input {
  flex: 1;
  border: none;
  outline: none;
  background: transparent;
  color: #e5e7eb;
  font-size: 0.9rem;
  padding: 0.15rem 0;
}

.search-input::placeholder {
  color: #9ca3af;
}

/* Selects */
.control-select {
  border-radius: 0.65rem;
  border: 1px solid #4b5563;
  background: #020617;
  color: #e5e7eb;
  font-size: 0.8rem;
  padding: 0.3rem 0.55rem;
}

.control-label {
  font-size: 0.7rem;
  color: #9ca3af;
  margin-left: auto;
}

/* Status counts */
.status-counts {
  margin-top: 0.25rem;
  font-size: 0.82rem;
  color: #9ca3af;
}

/* Status legend */
.status-legend {
  margin-top: 0.2rem;
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem 0.7rem;
  font-size: 0.75rem;
  color: #9ca3af;
}

.legend-item {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
}

.legend-swatch {
  width: 0.75rem;
  height: 0.75rem;
  border-radius: 999px;
  border: 1px solid #020617;
}

.legend-swatch--notworking {
  background: #dc2626;
}

/* Table header */
.table-header-wrap {
  position: sticky;
  z-index: 30;
  top: 0; /* overridden by JS */
}

.table-header {
  background: rgba(15, 23, 42, 0.9);
  border-bottom: 1px solid #1f2937;
  color: #9ca3af;
  font-size: 0.7rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

/* Table / rows */
.main {
  max-width: 64rem;
  margin: 0 auto;
  padding: 0.6rem 0.7rem 0.9rem;
}

.card {
  background: #020617;
  border-radius: 0.9rem;
  border: 1px solid #1f2937;
  overflow: hidden;
}

/* Shared grid columns: Callsign | Status | Reg | Taxi Plate */
.table-row,
.row {
  display: grid;
  grid-template-columns:
    80px                     /* Callsign */
    minmax(150px, 1.7fr)     /* Status */
    minmax(120px, 1.2fr)     /* Reg Plate */
    minmax(120px, 1.1fr);    /* Taxi Plate */
  column-gap: 0.5rem;
  align-items: center;
}

.row {
  padding: 0.45rem 0.75rem;
  border-bottom: 1px solid #111827;
  position: relative;
}

.row:last-child {
  border-bottom: none;
}

/* Row backgrounds for highlight modes */
.row-bg-online {
  background: rgba(22, 163, 74, 0.09);
}

.row-bg-offline {
  background: rgba(220, 38, 38, 0.09);
}

.row-bg-neutral {
  background: rgba(15, 23, 42, 0.5);
}

.row-border-online {
  border-left: 4px solid #16a34a;
}

.row-border-offline {
  border-left: 4px solid #dc2626;
}

.row-border-neutral {
  border-left: 4px solid #4b5563;
}

/* Flash animation when status changes */
@keyframes rowFlash {
  0% { background-color: transparent; }
  40% { background-color: rgba(250, 204, 21, 0.25); }
  100% { background-color: transparent; }
}

.row-flash {
  animation: rowFlash 0.6s ease-out;
}

/* Cells */
.cell {
  min-width: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  font-size: 0.85rem;
}

/* Pills */
.pill-muted {
  display: inline-block;
  padding: 0.1rem 0.4rem;
  border-radius: 0.6rem;
  border: 1px solid #4b5563;
  background: #020617;
  font-size: 0.82rem;
}

.pill-reg {
  display: inline-block;
  padding: 0.1rem 0.4rem;
  border-radius: 0.6rem;
  border: 1px solid #eab308;
  background: #eab308;
  color: #000;
  font-size: 0.9rem;
}

/* Driver status text */
.driver-status-text {
  font-size: 0.76rem;
  color: #e5e7eb;
}

/* Status panel */
.cell-status {
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  align-items: flex-end;
  gap: 0.1rem;
}

.status-main {
  line-height: 1.2;
}

.status-updated {
  font-size: 0.7rem;
  color: #9ca3af;
}

/* Skeleton */
.skeleton {
  border-top: 1px solid #111827;
}

.skeleton-row {
  height: 2.6rem;
  background: linear-gradient(90deg, #0f172a 0%, #111827 50%, #0f172a 100%);
  background-size: 200% 100%;
  animation: skeletonPulse 1.2s ease-in-out infinite;
}

@keyframes skeletonPulse {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

/* Empty state / error */
.empty-state,
.error-text {
  padding: 1rem;
  font-size: 0.85rem;
}

.empty-state {
  color: #9ca3af;
}

.error-text {
  color: #fecaca;
}

/* ===== Mobile tweaks ===== */
@media (max-width: 640px) {
  .header-inner {
    padding: 0.5rem 0.55rem;
    gap: 0.4rem;
  }

  .header-controls {
    padding: 0 0.55rem 0.45rem;
  }

  .main {
    padding: 0.5rem 0.55rem 0.75rem;
  }

  .controls-row {
    gap: 0.3rem;
  }

  .control-select {
    font-size: 0.78rem;
    padding: 0.25rem 0.45rem;
  }

  .search-box {
    min-width: 180px;
    padding: 0.2rem 0.45rem;
  }

  .search-input {
    font-size: 0.82rem;
  }

  .status-counts {
    font-size: 0.8rem;
  }

  .status-legend {
    font-size: 0.76rem;
    gap: 0.25rem 0.55rem;
  }

  .table-row,
  .row {
    grid-template-columns:
      70px                     /* Callsign */
      minmax(130px, 1.6fr)     /* Status */
      minmax(90px, 1.1fr)      /* Reg */
      minmax(90px, 1fr);       /* Taxi plate */
    column-gap: 0.35rem;
  }

  .row {
    padding: 0.4rem 0.55rem;
  }

  .cell {
    font-size: 0.82rem;
  }

  .pill-muted,
  .pill-reg {
    font-size: 0.78rem;
    padding: 0.06rem 0.32rem;
  }

  .driver-status-text {
    font-size: 0.72rem;
  }

  .cell-status {
    align-items: flex-start;
    justify-content: flex-start;
  }

  .status-updated {
    font-size: 0.72rem;
  }
}
