:root {
  --ink: #172033;
  --muted: #657189;
  --surface: #ffffff;
  --surface-soft: #f6f8fb;
  --line: #dfe5ee;
  --brand: #1769e0;
  --brand-dark: #0d47a1;
  --green: #0b9f6e;
  --amber: #b86a00;
  --red: #c63737;
  --shadow: 0 14px 36px rgba(24, 39, 75, 0.1);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  min-height: 100%;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--ink);
  background: #eef3f9;
}

body { min-height: 100vh; }

a { color: inherit; }

.topbar {
  min-height: 72px;
  padding: 12px 22px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  background: rgba(255,255,255,.96);
  border-bottom: 1px solid var(--line);
  position: relative;
  z-index: 1000;
}

.brand { display: flex; align-items: center; gap: 12px; }
.brand-mark {
  width: 40px;
  height: 40px;
  border-radius: 13px;
  display: grid;
  place-items: center;
  color: white;
  background: linear-gradient(145deg, #2779ea, #0d47a1);
  box-shadow: 0 8px 18px rgba(23,105,224,.28);
}
.brand h1 { margin: 0; font-size: 18px; line-height: 1.2; }
.brand p { margin: 3px 0 0; color: var(--muted); font-size: 12px; }

.nav { display: flex; flex-wrap: wrap; gap: 8px; }
.button, button {
  appearance: none;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface);
  color: var(--ink);
  padding: 9px 13px;
  font: inherit;
  font-size: 13px;
  font-weight: 700;
  text-decoration: none;
  cursor: pointer;
  transition: transform .15s ease, border-color .15s ease, background .15s ease;
}
.button:hover, button:hover { transform: translateY(-1px); border-color: #aeb9ca; }
.button.primary, button.primary { background: var(--brand); color: white; border-color: var(--brand); }
.button.danger, button.danger { background: #fff3f3; color: var(--red); border-color: #f0b8b8; }

.page { padding: 18px; }
.live-layout {
  display: grid;
  grid-template-columns: minmax(280px, 350px) 1fr;
  gap: 16px;
  height: calc(100vh - 108px);
}
.sidebar { min-width: 0; overflow: auto; }

.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 16px;
  margin-bottom: 12px;
  box-shadow: var(--shadow);
}
.card h2 { font-size: 15px; margin: 0 0 12px; }
.card p { color: var(--muted); }

.status-row { display: flex; align-items: center; gap: 10px; }
.status-dot {
  width: 11px;
  height: 11px;
  border-radius: 50%;
  background: var(--amber);
  box-shadow: 0 0 0 5px rgba(184,106,0,.12);
}
.status-dot.online { background: var(--green); box-shadow: 0 0 0 5px rgba(11,159,110,.12); }
.status-dot.offline { background: var(--red); box-shadow: 0 0 0 5px rgba(198,55,55,.12); }
.status-title { font-weight: 800; }
.status-detail { margin-top: 3px; color: var(--muted); font-size: 12px; }

.metrics { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.metric { background: var(--surface-soft); border: 1px solid var(--line); border-radius: 12px; padding: 12px; }
.metric.wide { grid-column: 1 / -1; }
.metric-label { color: var(--muted); font-size: 11px; text-transform: uppercase; letter-spacing: .06em; }
.metric-value { font-size: 17px; font-weight: 800; margin-top: 5px; overflow-wrap: anywhere; }

.map-card { min-height: 450px; overflow: hidden; padding: 0; margin: 0; }
.map { height: 100%; min-height: 450px; background: #dce5ef; }
.bus-marker {
  width: 24px;
  height: 24px;
  border: 4px solid white;
  border-radius: 50% 50% 50% 0;
  background: #e53935;
  transform: rotate(-45deg);
  box-shadow: 0 4px 14px rgba(0,0,0,.34);
}
.bus-marker::after {
  content: "";
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: white;
  position: absolute;
  top: 5px;
  left: 5px;
}

.notice { padding: 11px 13px; border-radius: 11px; font-size: 13px; display: none; margin-bottom: 12px; }
.notice.show { display: block; }
.notice.error { background: #fff0f0; color: #972525; border: 1px solid #f0b8b8; }
.notice.info { background: #edf5ff; color: #174d8e; border: 1px solid #bdd6f6; }

.content { width: min(1180px, 100%); margin: 0 auto; }
.page-title { display: flex; justify-content: space-between; align-items: end; gap: 20px; margin: 4px 0 18px; }
.page-title h2 { margin: 0; font-size: 26px; }
.page-title p { margin: 5px 0 0; color: var(--muted); }

.filters {
  display: grid;
  grid-template-columns: repeat(2, minmax(190px, 1fr)) auto;
  gap: 12px;
  align-items: end;
}
label { display: grid; gap: 6px; color: var(--muted); font-size: 12px; font-weight: 700; }
input {
  width: 100%;
  padding: 10px 11px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: white;
  color: var(--ink);
  font: inherit;
}

.summary-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; margin: 14px 0; }
.summary { background: white; border: 1px solid var(--line); border-radius: 14px; padding: 14px; }
.summary span { display: block; color: var(--muted); font-size: 11px; text-transform: uppercase; }
.summary strong { display: block; margin-top: 6px; font-size: 20px; }

.history-map { height: 62vh; min-height: 480px; border-radius: 16px; overflow: hidden; border: 1px solid var(--line); box-shadow: var(--shadow); }
.charts { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; margin-top: 14px; }
.chart-card { min-height: 310px; background: white; border: 1px solid var(--line); border-radius: 15px; padding: 15px; }
.chart-card h3 { margin: 0 0 12px; font-size: 14px; }
.chart-wrap { position: relative; height: 245px; }
.danger-zone { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.muted { color: var(--muted); }

@media (max-width: 850px) {
  .topbar { align-items: flex-start; flex-direction: column; }
  .page { padding: 12px; }
  .live-layout { display: flex; flex-direction: column; height: auto; }
  .sidebar { overflow: visible; }
  .map-card, .map { min-height: 60vh; }
  .filters { grid-template-columns: 1fr; }
  .summary-grid, .charts { grid-template-columns: 1fr 1fr; }
}

@media (max-width: 520px) {
  .summary-grid, .charts { grid-template-columns: 1fr; }
  .metrics { grid-template-columns: 1fr; }
  .metric.wide { grid-column: auto; }
}
