:root {
  --bg-0: #050505;
  --bg-1: #0b0b0b;
  --bg-2: #121212;
  --panel: #101010cc;
  --panel-solid: #131313;
  --border: #2a2a2a99;
  --border-soft: #242424;
  --accent: #ffe100;
  --accent-2: #ffc400;
  --accent-3: #00ffa3;
  --warn: #ff8c00;
  --danger: #ff3b4e;
  --idle: #b39cff;
  --neutral: #c9c9c9;
  --text-0: #f7f7f2;
  --text-1: #b9b9b0;
  --text-2: #7a7a72;
  --radius: 16px;
  --shadow-glow:
    0 0 0 1px var(--border-soft), 0 10px 30px -10px rgba(0, 0, 0, 0.7);
}

* {
  box-sizing: border-box;
}
html,
body {
  margin: 0;
  padding: 0;
}
body {
  font-family:
    "Inter",
    system-ui,
    -apple-system,
    Segoe UI,
    Roboto,
    sans-serif;
  background:
    radial-gradient(
      1200px 600px at 85% -10%,
      rgba(255, 225, 0, 0.07),
      transparent
    ),
    radial-gradient(
      900px 500px at -10% 110%,
      rgba(255, 140, 0, 0.05),
      transparent
    ),
    var(--bg-0);
  color: var(--text-0);
  min-height: 100vh;
  overflow-x: hidden;
}

::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}
::-webkit-scrollbar-track {
  background: transparent;
}
::-webkit-scrollbar-thumb {
  background: #2a2a2a;
  border-radius: 8px;
}
::-webkit-scrollbar-thumb:hover {
  background: #3a3a3a;
}

a {
  color: inherit;
  text-decoration: none;
}

.app-shell {
  display: grid;
  grid-template-columns: 76px 1fr;
  min-height: 100vh;
}

/* ========================= SIDEBAR ========================= */
.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  background: linear-gradient(180deg, #0d0d0d, #050505);
  border-right: 1px solid var(--border-soft);
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 18px 0;
  z-index: 50;
  transition: width 0.25s ease;
  width: 76px;
  overflow: hidden;
}
.sidebar:hover {
  width: 220px;
  align-items: stretch;
}
.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 18px 18px 22px;
  width: 100%;
  margin-bottom: 6px;
  white-space: nowrap;
}
.brand-icon {
  width: 38px;
  height: 38px;
  border-radius: 11px;
  flex: 0 0 38px;
  background: var(--accent);
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 0 22px #ffe10055;
  overflow: hidden;
  padding: 0;
}
.brand-icon img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
.brand-text {
  font-family: "Orbitron", sans-serif;
  font-weight: 700;
  font-size: 15px;
  letter-spacing: 0.5px;
  opacity: 0;
  transition: opacity 0.2s;
  color: var(--text-0);
}
.sidebar:hover .brand-text {
  opacity: 1;
}
.nav-group {
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin-top: 8px;
}
.nav-label {
  font-size: 10px;
  letter-spacing: 1.5px;
  color: var(--text-2);
  padding: 14px 22px 6px;
  text-transform: uppercase;
  opacity: 0;
  transition: opacity 0.2s;
  white-space: nowrap;
}
.sidebar:hover .nav-label {
  opacity: 1;
}
.nav-item {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 11px 22px;
  margin: 0 10px;
  border-radius: 10px;
  color: var(--text-1);
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  white-space: nowrap;
  position: relative;
}
.nav-item i {
  width: 20px;
  text-align: center;
  font-size: 16px;
  flex: 0 0 20px;
}
.nav-item:hover {
  background: #1a1a1a;
  color: var(--text-0);
}
.nav-item.active {
  background: linear-gradient(90deg, #2a2400, #1a1600);
  color: var(--accent);
}
.nav-item.active::before {
  content: "";
  position: absolute;
  left: -10px;
  top: 8px;
  bottom: 8px;
  width: 3px;
  border-radius: 4px;
  background: var(--accent);
  box-shadow: 0 0 10px var(--accent);
}
.nav-item .badge-dot {
  margin-left: auto;
  background: var(--danger);
  color: #fff;
  font-size: 10px;
  padding: 1px 6px;
  border-radius: 20px;
  font-weight: 700;
  opacity: 0;
  transition: opacity 0.2s;
}
.sidebar:hover .nav-item .badge-dot {
  opacity: 1;
}
.sidebar-bottom {
  margin-top: auto;
  width: 100%;
  padding: 0 10px;
}

/* ========================= MAIN ========================= */
.main {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 40;
  display: flex;
  align-items: center;
  gap: 18px;
  padding: 14px 26px;
  background: #0b0b0bcc;
  backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--border-soft);
}
.page-title {
  display: flex;
  flex-direction: column;
  gap: 2px;
  margin-right: auto;
}
.page-title h1 {
  font-family: "Orbitron", sans-serif;
  font-size: 19px;
  margin: 0;
  letter-spacing: 0.5px;
  display: flex;
  align-items: center;
  gap: 10px;
}
.live-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 11px;
  font-weight: 700;
  color: var(--accent-3);
  background: #00251b66;
  border: 1px solid #00ffa355;
  padding: 3px 10px;
  border-radius: 20px;
  letter-spacing: 0.5px;
}
.live-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--accent-3);
  box-shadow: 0 0 8px var(--accent-3);
  animation: pulse 1.4s infinite;
}
@keyframes pulse {
  0%,
  100% {
    opacity: 1;
    transform: scale(1);
  }
  50% {
    opacity: 0.4;
    transform: scale(1.3);
  }
}
.page-title .subtitle {
  color: var(--text-2);
  font-size: 12.5px;
}

.search-box {
  display: flex;
  align-items: center;
  gap: 8px;
  background: #131313;
  border: 1px solid var(--border-soft);
  border-radius: 10px;
  padding: 9px 14px;
  min-width: 230px;
  color: var(--text-2);
}
.search-box input {
  background: transparent;
  border: none;
  outline: none;
  color: var(--text-0);
  font-size: 13px;
  width: 100%;
}
.topbar-icon-btn {
  width: 38px;
  height: 38px;
  border-radius: 10px;
  background: #131313;
  border: 1px solid var(--border-soft);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-1);
  cursor: pointer;
  position: relative;
  font-size: 14px;
  flex: 0 0 auto;
}
.topbar-icon-btn:hover {
  color: var(--accent);
  border-color: #4a4210;
}
.topbar-icon-btn .dot {
  position: absolute;
  top: -3px;
  right: -3px;
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--danger);
  border: 2px solid #0b0b0b;
}
.clock-box {
  text-align: right;
  font-family: "Orbitron", sans-serif;
  line-height: 1.1;
}
.clock-box .time {
  font-size: 16px;
  color: var(--accent);
  font-weight: 700;
}
.clock-box .date {
  font-size: 10px;
  color: var(--text-2);
  letter-spacing: 0.5px;
}
.profile {
  display: flex;
  align-items: center;
  gap: 10px;
  padding-left: 14px;
  border-left: 1px solid var(--border-soft);
}
.avatar {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 13px;
  color: #161200;
}
.profile .who {
  font-size: 12.5px;
  line-height: 1.2;
}
.profile .who small {
  display: block;
  color: var(--text-2);
  font-size: 10.5px;
}

.content {
  padding: 22px 26px 40px;
  display: flex;
  flex-direction: column;
  gap: 22px;
}

/* ===================== STAT CARDS ===================== */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 16px;
}
.stat-card {
  background: linear-gradient(160deg, #141414, #0a0a0a);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius);
  padding: 16px 18px;
  position: relative;
  overflow: hidden;
  box-shadow: var(--shadow-glow);
}
.stat-card::after {
  content: "";
  position: absolute;
  right: -30px;
  top: -30px;
  width: 110px;
  height: 110px;
  border-radius: 50%;
  background: var(--stat-color, var(--accent));
  opacity: 0.12;
  filter: blur(4px);
}
.stat-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 10px;
}
.stat-icon {
  width: 34px;
  height: 34px;
  border-radius: 9px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: color-mix(
    in srgb,
    var(--stat-color, var(--accent)) 18%,
    transparent
  );
  color: var(--stat-color, var(--accent));
  font-size: 14px;
}
.stat-trend {
  font-size: 11px;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 3px;
}
.trend-up {
  color: var(--accent-3);
}
.trend-down {
  color: var(--danger);
}
.stat-value {
  font-family: "Orbitron", sans-serif;
  font-size: 26px;
  font-weight: 700;
  letter-spacing: 0.5px;
}
.stat-label {
  color: var(--text-2);
  font-size: 12px;
  margin-top: 4px;
}

/* ===================== PANELS ===================== */
.panel {
  background: var(--panel);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius);
  box-shadow: var(--shadow-glow);
  backdrop-filter: blur(6px);
  display: flex;
  flex-direction: column;
  min-width: 0;
}
.panel-head {
  display: flex;
  align-items: center;
  justify-content: between;
  gap: 10px;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border-soft);
}
.panel-head h3 {
  margin: 0;
  font-size: 14.5px;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 8px;
}
.panel-head h3 i {
  color: var(--accent);
}
.panel-head .meta {
  margin-left: auto;
  font-size: 11.5px;
  color: var(--text-2);
}
.panel-body {
  padding: 18px 20px;
  flex: 1;
}

.tab-btn {
  font-size: 11.5px;
  padding: 5px 12px;
  border-radius: 20px;
  border: 1px solid var(--border-soft);
  color: var(--text-2);
  cursor: pointer;
  background: transparent;
}
.tab-btn.active {
  background: #241f00;
  color: var(--accent);
  border-color: #4a4210;
}
.tab-row {
  display: flex;
  gap: 6px;
  margin-left: auto;
}

/* ===================== MAIN GRID LAYOUT ===================== */
.grid-main {
  display: grid;
  grid-template-columns: 2.1fr 1fr;
  gap: 20px;
  align-items: start;
}
.grid-sub {
  display: grid;
  grid-template-columns: 1.3fr 1fr;
  gap: 20px;
  align-items: start;
}
.grid-charts3 {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 20px;
}

#map {
  height: 460px;
  width: 100%;
  border-radius: 0 0 var(--radius) var(--radius);
  filter: saturate(0.35) brightness(0.75) contrast(1.15);
}
.map-legend {
  display: flex;
  gap: 14px;
  flex-wrap: wrap;
  padding: 12px 20px;
  border-top: 1px solid var(--border-soft);
  font-size: 12px;
  color: var(--text-1);
}
.map-legend span {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.legend-dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  display: inline-block;
}

/* Bus list */
.bus-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
  max-height: 460px;
  overflow-y: auto;
  padding-right: 4px;
}
.bus-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 11px 12px;
  border-radius: 12px;
  background: #131313;
  border: 1px solid var(--border-soft);
  cursor: pointer;
  transition: 0.15s;
}
.bus-row:hover {
  border-color: #4a4210;
  background: #1a1a1a;
}
.bus-avatar {
  width: 38px;
  height: 38px;
  border-radius: 10px;
  flex: 0 0 38px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 15px;
  color: #161200;
  font-weight: 700;
}
.bus-info {
  flex: 1;
  min-width: 0;
}
.bus-info .top-line {
  display: flex;
  justify-content: space-between;
  font-size: 13px;
  font-weight: 600;
}
.bus-info .sub-line {
  font-size: 11.5px;
  color: var(--text-2);
  display: flex;
  gap: 8px;
  margin-top: 2px;
}
.status-chip {
  font-size: 10px;
  padding: 2px 8px;
  border-radius: 20px;
  font-weight: 700;
  letter-spacing: 0.3px;
  text-transform: uppercase;
}
.status-onroute {
  background: #1a2e00;
  color: var(--accent-3);
}
.status-delayed {
  background: #3a2600;
  color: var(--warn);
}
.status-idle {
  background: #241f3a;
  color: var(--idle);
}
.status-alert {
  background: #3a0d12;
  color: var(--danger);
}

.occupancy-bar {
  height: 5px;
  border-radius: 4px;
  background: #242424;
  margin-top: 6px;
  overflow: hidden;
}
.occupancy-fill {
  height: 100%;
  border-radius: 4px;
}

/* Alerts feed */
.alert-item {
  display: flex;
  gap: 12px;
  padding: 12px 0;
  border-bottom: 1px dashed var(--border-soft);
}
.alert-item:last-child {
  border-bottom: none;
}
.alert-ic {
  width: 32px;
  height: 32px;
  border-radius: 9px;
  flex: 0 0 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
}
.alert-txt {
  font-size: 13px;
}
.alert-txt b {
  font-weight: 600;
}
.alert-time {
  font-size: 11px;
  color: var(--text-2);
  margin-top: 2px;
}

/* KPI mini rings */
.kpi-mini-row {
  display: flex;
  justify-content: space-around;
  text-align: center;
  gap: 10px;
}
.kpi-mini {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
}
.ring-wrap {
  position: relative;
  width: 90px;
  height: 90px;
}
.ring-wrap canvas {
  position: absolute;
  inset: 0;
}
.ring-val {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: "Orbitron", sans-serif;
  font-weight: 700;
  font-size: 15px;
}
.kpi-mini-label {
  font-size: 11.5px;
  color: var(--text-2);
}

table.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12.5px;
}
table.data-table th {
  text-align: left;
  color: var(--text-2);
  font-weight: 600;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.4px;
  padding: 8px 10px;
  border-bottom: 1px solid var(--border-soft);
}
table.data-table td {
  padding: 10px 10px;
  border-bottom: 1px solid #24242488;
  color: var(--text-1);
}
table.data-table tr:hover td {
  background: #151515;
}
table.data-table td.strong {
  color: var(--text-0);
  font-weight: 600;
}

.progress-track {
  width: 100%;
  height: 6px;
  border-radius: 4px;
  background: #242424;
  overflow: hidden;
}
.progress-fill {
  height: 100%;
  border-radius: 4px;
}

.chip {
  font-size: 10.5px;
  padding: 2px 8px;
  border-radius: 6px;
  font-weight: 600;
}

footer.app-footer {
  text-align: center;
  color: var(--text-2);
  font-size: 12px;
  padding: 18px 0 6px;
}

@media (max-width: 1300px) {
  .stats-grid {
    grid-template-columns: repeat(3, 1fr);
  }
  .grid-main {
    grid-template-columns: 1fr;
  }
  .grid-sub {
    grid-template-columns: 1fr;
  }
  .grid-charts3 {
    grid-template-columns: 1fr;
  }
}
@media (max-width: 720px) {
  .stats-grid {
    grid-template-columns: repeat(2, 1fr);
  }
  .search-box {
    display: none;
  }
  .clock-box {
    display: none;
  }
}
