:root {
  --surface: #ffffff;
  --surface-soft: #f7f7f8;
  --ink: #111111;
  --muted: #666a73;
  --line: #d7d9df;
  --accent: #e4002b;
  --accent-dark: #a6001f;
  --good: #0f766e;
  --warn: #b45309;
  --bad: #b42318;
  --blue: #002fa7;
  --font: "Helvetica Neue", Arial, sans-serif;
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  background: var(--surface-soft);
  color: var(--ink);
  font-family: var(--font);
}

button,
input,
select {
  font: inherit;
}

button {
  cursor: pointer;
}

.app-shell {
  min-height: 100vh;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: grid;
  grid-template-columns: 1fr auto auto;
  gap: 24px;
  align-items: center;
  min-height: 72px;
  padding: 0 28px;
  background: rgba(255, 255, 255, 0.94);
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(14px);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  color: inherit;
  text-decoration: none;
}

.brand.compact {
  margin-bottom: 28px;
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  background: var(--accent);
  color: white;
  font-weight: 800;
  letter-spacing: 0;
}

.brand small,
.label,
.metric span,
.coverage-list span,
.summary-strip span,
.review-fields span,
.workflow-step span,
.sidebar-note span {
  display: block;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.4;
}

.nav-tabs {
  display: inline-grid;
  grid-template-columns: 1fr 1fr;
  border: 1px solid var(--line);
  background: white;
}

.nav-tab {
  border: 0;
  border-right: 1px solid var(--line);
  background: white;
  padding: 10px 18px;
  color: var(--ink);
  font-weight: 700;
}

.nav-tab:last-child {
  border-right: 0;
}

.nav-tab.is-active {
  background: var(--ink);
  color: white;
}

.deploy-chip,
.status-tag,
.live-pill {
  border: 1px solid var(--line);
  background: white;
  padding: 8px 10px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.view {
  display: none;
}

.view.is-active {
  display: block;
}

.view-grid {
  display: grid;
  min-height: calc(100vh - 72px);
}

.mobile-grid {
  grid-template-columns: minmax(260px, 0.72fr) minmax(360px, 0.88fr) minmax(260px, 0.68fr);
}

.side-panel {
  padding: 36px 28px;
  background: white;
  border-right: 1px solid var(--line);
}

.right-panel {
  border-right: 0;
  border-left: 1px solid var(--line);
}

.folio {
  margin: 0 0 14px;
  color: var(--accent);
  font-size: 54px;
  font-weight: 800;
  line-height: 0.9;
  letter-spacing: 0;
}

h1,
h2,
h3,
p {
  margin-top: 0;
}

h1 {
  max-width: 640px;
  margin-bottom: 18px;
  font-size: clamp(34px, 5vw, 76px);
  line-height: 0.92;
  letter-spacing: 0;
}

h2 {
  margin-bottom: 12px;
  font-size: 24px;
}

h3 {
  margin-bottom: 8px;
  font-size: 15px;
}

.lead {
  color: var(--muted);
  font-size: 17px;
  line-height: 1.55;
}

.workflow-list,
.coverage-list {
  display: grid;
  gap: 1px;
  margin-top: 28px;
  border: 1px solid var(--line);
  background: var(--line);
}

.workflow-step {
  display: block;
  width: 100%;
  border: 0;
  background: white;
  padding: 16px;
  text-align: left;
}

.workflow-step.is-active {
  box-shadow: inset 5px 0 0 var(--accent);
}

.workflow-step strong,
.coverage-list strong {
  display: block;
  margin-top: 4px;
  font-size: 14px;
}

.system-card {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
  margin-top: 20px;
  border: 1px solid var(--line);
  background: var(--surface-soft);
  padding: 16px;
}

.text-button {
  border: 0;
  background: transparent;
  color: var(--blue);
  font-weight: 700;
  text-decoration: underline;
}

.phone-stage {
  display: grid;
  place-items: center;
  padding: 34px;
  background:
    linear-gradient(to right, var(--line) 1px, transparent 1px),
    linear-gradient(to bottom, var(--line) 1px, transparent 1px),
    var(--surface-soft);
  background-size: 64px 64px;
}

.phone {
  width: min(390px, 100%);
  height: min(820px, calc(100vh - 118px));
  overflow: auto;
  background: white;
  border: 12px solid #111;
  border-radius: 34px;
  box-shadow: 0 18px 48px rgba(17, 17, 17, 0.18);
}

.phone-status,
.phone-header,
.mobile-actions,
.metrics-grid,
.phone-section {
  margin: 0 14px;
}

.phone-status {
  display: flex;
  justify-content: space-between;
  padding: 10px 4px 8px;
  font-size: 12px;
  font-weight: 700;
}

.phone-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 0 12px;
}

.phone-header p {
  margin-bottom: 2px;
  color: var(--muted);
  font-size: 12px;
}

.phone-header h2 {
  margin: 0;
  font-size: 28px;
}

.live-pill {
  color: white;
  background: var(--good);
  border-color: var(--good);
}

.camera-feed {
  position: relative;
  height: 310px;
  margin: 0 14px 12px;
  overflow: hidden;
  background: #20242b;
}

.road-scene {
  position: absolute;
  inset: 0;
  background:
    linear-gradient(76deg, transparent 0 24%, rgba(255, 255, 255, 0.16) 24% 25%, transparent 25% 48%, rgba(255, 255, 255, 0.18) 48% 49%, transparent 49% 72%, rgba(255, 255, 255, 0.16) 72% 73%, transparent 73%),
    linear-gradient(180deg, #343a43, #161a20);
}

.road-lane {
  position: absolute;
  bottom: 0;
  border: 2px solid;
}

.bus-lane {
  left: 0;
  width: 32%;
  height: 68%;
  background: rgba(0, 47, 167, 0.28);
  border-color: var(--blue);
}

.main-lane {
  left: 25%;
  width: 46%;
  height: 76%;
  background: rgba(255, 255, 255, 0.08);
  border-color: rgba(255, 255, 255, 0.7);
}

.emergency-lane {
  right: 0;
  width: 30%;
  height: 72%;
  background: rgba(228, 0, 43, 0.26);
  border-color: var(--accent);
}

.vehicle {
  position: absolute;
  width: 36px;
  height: 70px;
  background: white;
  border: 3px solid #111;
}

.vehicle::before,
.vehicle::after {
  content: "";
  position: absolute;
  left: 7px;
  right: 7px;
  height: 8px;
  background: #111;
}

.vehicle::before {
  top: 10px;
}

.vehicle::after {
  bottom: 10px;
}

.vehicle-a {
  left: 64px;
  bottom: 88px;
  animation: nudge 2.4s infinite alternate ease-in-out;
}

.vehicle-b {
  right: 86px;
  bottom: 126px;
}

.track-box {
  position: absolute;
  border: 2px solid var(--accent);
}

.track-box span {
  display: inline-block;
  transform: translateY(-100%);
  background: var(--accent);
  color: white;
  padding: 3px 5px;
  font-size: 11px;
  font-weight: 800;
}

.track-a {
  left: 54px;
  bottom: 80px;
  width: 58px;
  height: 88px;
}

.track-b {
  right: 76px;
  bottom: 118px;
  width: 58px;
  height: 88px;
  border-color: white;
}

.track-b span {
  background: white;
  color: #111;
}

.region-name {
  position: absolute;
  color: white;
  font-size: 11px;
  font-weight: 800;
}

.bus-name {
  left: 8px;
  bottom: 12px;
}

.main-name {
  left: 42%;
  bottom: 12px;
}

.emergency-name {
  right: 8px;
  bottom: 12px;
}

.camera-overlay {
  position: absolute;
  left: 12px;
  right: 12px;
  top: 12px;
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
  color: white;
}

.camera-overlay span,
.camera-overlay strong {
  background: rgba(17, 17, 17, 0.76);
  padding: 7px 8px;
  font-size: 12px;
}

.mobile-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-bottom: 12px;
}

.primary-action,
.secondary-action,
.outline-action,
.danger-action {
  border: 1px solid var(--ink);
  padding: 11px 12px;
  font-weight: 800;
}

.primary-action {
  background: var(--accent);
  border-color: var(--accent);
  color: white;
}

.secondary-action,
.outline-action {
  background: white;
  color: var(--ink);
}

.danger-action {
  background: white;
  border-color: var(--bad);
  color: var(--bad);
}

.full {
  width: 100%;
}

.metrics-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-bottom: 12px;
}

.metric,
.phone-section,
.coverage-list > div,
.events-table-panel,
.review-panel,
.summary-strip > div,
.review-fields > div,
.audit-log {
  border: 1px solid var(--line);
  background: white;
}

.metric {
  padding: 10px;
}

.metric strong,
.summary-strip strong {
  display: block;
  margin-top: 3px;
  font-size: 20px;
  font-variant-numeric: tabular-nums;
}

.phone-section {
  margin-bottom: 12px;
  padding: 12px;
}

.section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.event-card {
  border-left: 5px solid var(--accent);
  padding-left: 10px;
}

.event-card p {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 13px;
}

.upload-steps {
  display: grid;
  grid-template-columns: 1fr;
  gap: 6px;
  margin-bottom: 10px;
}

.upload-steps span {
  border: 1px solid var(--line);
  padding: 8px;
  color: var(--muted);
  font-size: 12px;
}

.upload-steps .done {
  border-color: var(--good);
  color: var(--good);
}

.result-message {
  margin: 8px 0 0;
  color: var(--muted);
  font-size: 12px;
}

.coverage-list > div {
  padding: 14px;
}

.outline-action {
  width: 100%;
  margin-top: 20px;
}

.admin-layout {
  display: grid;
  grid-template-columns: 280px 1fr;
  min-height: calc(100vh - 72px);
}

.admin-sidebar {
  padding: 28px;
  background: white;
  border-right: 1px solid var(--line);
}

.sidebar-item {
  display: block;
  width: 100%;
  border: 0;
  border-bottom: 1px solid var(--line);
  background: white;
  padding: 14px 0;
  text-align: left;
  font-weight: 800;
}

.sidebar-item.is-active {
  color: var(--accent);
}

.sidebar-note {
  margin-top: 28px;
  border: 1px solid var(--line);
  background: var(--surface-soft);
  padding: 14px;
}

.admin-main {
  padding: 30px;
}

.admin-header {
  display: flex;
  justify-content: space-between;
  gap: 24px;
  align-items: flex-start;
}

.admin-header h1 {
  margin-bottom: 0;
  font-size: clamp(36px, 5vw, 68px);
}

.admin-actions {
  display: flex;
  gap: 10px;
}

.admin-actions input,
.admin-actions select {
  min-height: 42px;
  border: 1px solid var(--line);
  background: white;
  padding: 0 12px;
}

.summary-strip {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 1px;
  margin: 28px 0;
  background: var(--line);
  border: 1px solid var(--line);
}

.summary-strip > div {
  padding: 16px;
}

.admin-content {
  display: grid;
  grid-template-columns: minmax(520px, 1.15fr) minmax(360px, 0.85fr);
  gap: 18px;
  align-items: start;
}

.events-table-panel,
.review-panel {
  padding: 16px;
}

.events-table {
  display: grid;
  gap: 1px;
  margin-top: 14px;
  background: var(--line);
  border: 1px solid var(--line);
}

.event-row {
  display: grid;
  grid-template-columns: 1fr 1fr 0.8fr 0.7fr;
  gap: 12px;
  align-items: center;
  min-height: 62px;
  border: 0;
  background: white;
  padding: 12px;
  text-align: left;
}

.event-row.is-selected {
  box-shadow: inset 5px 0 0 var(--accent);
}

.event-row span {
  color: var(--muted);
  font-size: 12px;
}

.event-row strong {
  display: block;
  margin-top: 3px;
}

.status {
  display: inline-block;
  width: max-content;
  border: 1px solid var(--line);
  padding: 5px 7px;
  font-size: 12px;
  font-weight: 800;
}

.status.pending {
  color: var(--warn);
  border-color: var(--warn);
}

.status.confirmed {
  color: var(--good);
  border-color: var(--good);
}

.status.rejected {
  color: var(--bad);
  border-color: var(--bad);
}

.evidence-preview {
  margin-top: 14px;
  border: 1px solid var(--line);
  background: #20242b;
}

.evidence-road {
  position: relative;
  height: 230px;
  overflow: hidden;
  background:
    linear-gradient(82deg, transparent 0 31%, rgba(255,255,255,0.2) 31% 32%, transparent 32% 64%, rgba(255,255,255,0.2) 64% 65%, transparent 65%),
    linear-gradient(#393f49, #171a20);
}

.evidence-region {
  position: absolute;
  left: 0;
  bottom: 0;
  width: 38%;
  height: 70%;
  background: rgba(0, 47, 167, 0.28);
  border: 2px solid var(--blue);
}

.evidence-car {
  position: absolute;
  left: 26%;
  bottom: 74px;
  width: 50px;
  height: 90px;
  background: white;
  border: 3px solid #111;
}

.evidence-box {
  position: absolute;
  left: 23%;
  bottom: 62px;
  border: 2px solid var(--accent);
  color: white;
  background: var(--accent);
  padding: 4px 6px;
  font-size: 12px;
  font-weight: 800;
}

.review-fields {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1px;
  margin-top: 14px;
  background: var(--line);
  border: 1px solid var(--line);
}

.review-fields > div {
  padding: 12px;
}

.review-fields strong {
  display: block;
  margin-top: 4px;
  font-size: 15px;
}

.review-actions {
  display: grid;
  grid-template-columns: 1fr;
  gap: 8px;
  margin-top: 14px;
}

.audit-log {
  margin-top: 14px;
  padding: 12px;
}

.audit-entry {
  border-top: 1px solid var(--line);
  padding: 10px 0;
  color: var(--muted);
  font-size: 13px;
}

.audit-entry:first-of-type {
  border-top: 0;
}

@keyframes nudge {
  from {
    transform: translateY(0);
  }
  to {
    transform: translateY(-18px);
  }
}

@media (max-width: 1080px) {
  .topbar {
    grid-template-columns: 1fr;
    gap: 12px;
    padding: 16px;
  }

  .mobile-grid,
  .admin-layout,
  .admin-content,
  .summary-strip {
    grid-template-columns: 1fr;
  }

  .side-panel,
  .right-panel,
  .admin-sidebar {
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .phone {
    height: auto;
    max-height: none;
  }

  .admin-header,
  .admin-actions {
    flex-direction: column;
    align-items: stretch;
  }

  .event-row {
    grid-template-columns: 1fr;
  }
}
