:root {
  --red: #d71920;
  --red-dark: #a90f18;
  --ink: #17202c;
  --muted: #6b7686;
  --line: #e6ebf1;
  --soft: #f4f7fb;
  --panel: #ffffff;
  --nav: #101824;
  --nav-2: #172233;
  --blue: #1f7ae0;
  --green: #16a06a;
  --orange: #f08a24;
  --shadow: 0 16px 38px rgba(23, 32, 44, 0.09);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  color: var(--ink);
  background: linear-gradient(135deg, #f7f9fc 0%, #eef3f9 100%);
}

button {
  font: inherit;
  border: 0;
  cursor: pointer;
}

.app-shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 288px minmax(0, 1fr);
}

.sidebar {
  background: linear-gradient(180deg, var(--nav) 0%, #0c111a 100%);
  color: white;
  padding: 24px 18px;
  display: flex;
  flex-direction: column;
  gap: 24px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 58px;
}

.brand img {
  width: 74px;
  height: 34px;
  object-fit: contain;
  object-position: center;
  border-radius: 6px;
}

.brand strong,
.brand span {
  display: block;
}

.brand strong {
  font-size: 20px;
  letter-spacing: .2px;
}

.brand span,
.module-list p,
.system-health span,
.system-health small {
  color: #aab5c5;
  font-size: 12px;
}

.nav,
.module-list {
  display: grid;
  gap: 8px;
}

.nav-item,
.module-item {
  color: #dbe3ee;
  background: transparent;
  border-radius: 8px;
  padding: 10px 12px;
  display: flex;
  align-items: center;
  gap: 10px;
  text-align: left;
  transition: .2s ease;
}

.nav-item:hover,
.module-item:hover,
.nav-item.active,
.module-item.active {
  background: rgba(255, 255, 255, .09);
  color: white;
}

.module-item.active {
  box-shadow: inset 3px 0 0 var(--red);
}

.nav-icon {
  width: 30px;
  height: 30px;
  border-radius: 8px;
  display: grid;
  place-items: center;
  background: rgba(215, 25, 32, .18);
  color: #ffb3b7;
  font-size: 11px;
  font-weight: 800;
}

.module-list p {
  margin: 4px 12px;
  text-transform: uppercase;
  letter-spacing: .08em;
}

.system-health {
  margin-top: auto;
  border: 1px solid rgba(255, 255, 255, .12);
  background: rgba(255, 255, 255, .06);
  border-radius: 8px;
  padding: 16px;
}

.system-health strong {
  display: block;
  font-size: 34px;
  margin: 6px 0 2px;
}

.workspace {
  min-width: 0;
  padding: 24px;
}

.topbar {
  display: flex;
  justify-content: space-between;
  gap: 18px;
  align-items: center;
  margin-bottom: 20px;
}

.eyebrow {
  margin: 0 0 6px;
  color: var(--red);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: .08em;
  text-transform: uppercase;
}

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

h1 {
  margin-bottom: 0;
  font-size: clamp(26px, 4vw, 40px);
  letter-spacing: 0;
}

h2 {
  margin-bottom: 4px;
  font-size: 18px;
}

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

.top-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.primary-button,
.ghost-button {
  min-height: 40px;
  border-radius: 8px;
  padding: 0 16px;
  font-weight: 750;
}

.primary-button {
  color: white;
  background: linear-gradient(180deg, #e02730, var(--red-dark));
  box-shadow: 0 10px 22px rgba(215, 25, 32, .24);
}

.ghost-button {
  background: white;
  color: var(--ink);
  border: 1px solid var(--line);
}

.view { display: none; }
.view.active { display: block; }

.kpi-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(150px, 1fr));
  gap: 14px;
  margin-bottom: 14px;
}

.kpi-card,
.panel {
  background: var(--panel);
  border: 1px solid rgba(214, 222, 232, .9);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.kpi-card {
  padding: 16px;
  min-height: 116px;
  position: relative;
  overflow: hidden;
}

.kpi-card::after {
  content: "";
  position: absolute;
  right: -32px;
  top: -32px;
  width: 92px;
  height: 92px;
  border-radius: 50%;
  background: rgba(215, 25, 32, .08);
}

.kpi-card span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.kpi-card strong {
  display: block;
  margin: 10px 0 8px;
  font-size: 30px;
}

.trend {
  color: var(--green);
  font-size: 12px;
  font-weight: 800;
}

.operator-grid {
  display: grid;
  grid-template-columns: minmax(420px, 1.45fr) minmax(330px, .9fr);
  gap: 14px;
}

.panel {
  padding: 16px;
  min-width: 0;
}

.map-panel { min-height: 536px; }

.panel-head {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: flex-start;
  margin-bottom: 14px;
}

.panel-head p,
.panel-head span,
.muted {
  color: var(--muted);
  font-size: 12px;
}

.compact {
  align-items: center;
}

.segmented {
  display: flex;
  background: var(--soft);
  border-radius: 8px;
  padding: 4px;
  gap: 2px;
}

.segmented button {
  border-radius: 6px;
  min-height: 30px;
  padding: 0 10px;
  background: transparent;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.segmented button.active {
  color: var(--red);
  background: white;
  box-shadow: 0 4px 12px rgba(23, 32, 44, .07);
}

.malaysia-map {
  position: relative;
  min-height: 432px;
  border-radius: 8px;
  overflow: hidden;
  border: 1px solid var(--line);
}

.malaysia-map svg {
  width: 100%;
  height: 432px;
  display: block;
}

.land {
  fill: #dfe9ef;
  stroke: white;
  stroke-width: 3;
}

.east { fill: #d7e7e2; }

.route {
  fill: none;
  stroke-width: 5;
  stroke-linecap: round;
  stroke-dasharray: 9 9;
}

.route.red { stroke: var(--red); }
.route.blue { stroke: var(--blue); }
.route.green { stroke: var(--green); }

.pin circle { fill: var(--red); stroke: white; stroke-width: 4; }
.pin text {
  font-size: 18px;
  fill: var(--ink);
  font-weight: 800;
}

.airport rect {
  fill: #121a26;
}

.airport text {
  fill: white;
  font-size: 14px;
  font-weight: 800;
}

.car rect { fill: #17202c; }
.car circle { fill: white; }

.map-card {
  position: absolute;
  width: 158px;
  background: rgba(255, 255, 255, .92);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  box-shadow: 0 12px 24px rgba(23, 32, 44, .1);
}

.map-card strong,
.map-card span {
  display: block;
}

.map-card span {
  color: var(--muted);
  font-size: 12px;
  margin-top: 4px;
}

.map-card.demand { left: 22px; bottom: 22px; }
.map-card.eta { right: 22px; top: 22px; }

.module-copy {
  color: var(--muted);
  font-size: 14px;
  line-height: 1.55;
}

.mini-metrics {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
  margin: 18px 0;
}

.mini-metric {
  padding: 12px;
  border-radius: 8px;
  background: var(--soft);
}

.mini-metric strong {
  display: block;
  font-size: 22px;
  margin-bottom: 4px;
}

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

.workflow {
  display: grid;
  gap: 10px;
}

.workflow-step {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--red);
  box-shadow: 0 0 0 5px rgba(215, 25, 32, .12);
}

.chart-panel,
.table-panel {
  min-height: 250px;
}

.bar-chart {
  display: grid;
  gap: 13px;
  padding-top: 8px;
}

.bar-row {
  display: grid;
  grid-template-columns: 110px 1fr 54px;
  align-items: center;
  gap: 10px;
  font-size: 13px;
  font-weight: 750;
}

.bar-track {
  height: 12px;
  border-radius: 999px;
  background: #edf2f7;
  overflow: hidden;
}

.bar-fill {
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--red), #ff8a8f);
}

.table {
  display: grid;
  gap: 8px;
}

.table-row {
  display: grid;
  grid-template-columns: 1fr 82px 92px;
  gap: 8px;
  align-items: center;
  padding: 10px 0;
  border-bottom: 1px solid var(--line);
  font-size: 13px;
}

.tag {
  justify-self: start;
  border-radius: 999px;
  padding: 5px 9px;
  font-size: 11px;
  font-weight: 800;
}

.tag.red { color: var(--red-dark); background: #fde9eb; }
.tag.orange { color: #9a520c; background: #fff1df; }
.tag.green { color: #087548; background: #e7f7ef; }

.phone-stage {
  min-height: calc(100vh - 128px);
  display: none;
  grid-template-columns: minmax(260px, 420px) minmax(320px, 430px);
  gap: 44px;
  align-items: center;
  justify-content: center;
}

.phone-stage.active { display: grid; }

.phone-info h2 {
  font-size: clamp(30px, 5vw, 54px);
  line-height: 1.02;
  margin-bottom: 16px;
}

.phone-info p {
  color: var(--muted);
  font-size: 16px;
  line-height: 1.65;
}

.scenario-list {
  display: grid;
  gap: 10px;
  margin-top: 28px;
}

.scenario {
  min-height: 46px;
  border-radius: 8px;
  background: white;
  border: 1px solid var(--line);
  text-align: left;
  padding: 0 14px;
  font-weight: 800;
  color: var(--ink);
}

.scenario.active {
  color: var(--red);
  border-color: rgba(215, 25, 32, .3);
  box-shadow: 0 10px 24px rgba(215, 25, 32, .12);
}

.phone {
  width: min(100%, 390px);
  min-height: 760px;
  border-radius: 34px;
  background: #111820;
  padding: 12px;
  box-shadow: 0 28px 60px rgba(23, 32, 44, .28);
  position: relative;
  justify-self: center;
}

.passenger-phone {
  background: #151a22;
}

.driver-phone {
  background: #0e141d;
}

.phone::before {
  content: "";
  position: absolute;
  top: 10px;
  left: 50%;
  transform: translateX(-50%);
  width: 108px;
  height: 25px;
  background: #0b0d11;
  border-radius: 0 0 16px 16px;
  z-index: 3;
}

.phone-status {
  color: var(--ink);
  background: white;
  border-radius: 26px 26px 0 0;
  padding: 18px 18px 10px;
  display: flex;
  justify-content: space-between;
  font-size: 12px;
  font-weight: 850;
}

.phone-status.dark {
  background: #151c27;
  color: white;
}

.phone-map {
  height: 280px;
  background: white;
  position: relative;
  overflow: hidden;
}

.phone-map svg,
.driver-map svg {
  width: 100%;
  height: 100%;
  display: block;
}

.phone-map path,
.driver-map path {
  fill: none;
  stroke: #cfd8e3;
  stroke-width: 4;
  stroke-linecap: round;
}

.active-route {
  stroke: var(--red) !important;
  stroke-width: 6 !important;
}

.phone-map circle,
.driver-map circle {
  fill: var(--red);
  stroke: white;
  stroke-width: 4;
}

.sos {
  position: absolute;
  right: 18px;
  top: 18px;
  width: 52px;
  height: 52px;
  border-radius: 50%;
  color: white;
  background: var(--red);
  font-weight: 900;
  box-shadow: 0 10px 24px rgba(215, 25, 32, .3);
}

.sheet {
  background: white;
  border-radius: 0 0 26px 26px;
  padding: 22px 18px;
  min-height: 442px;
}

.sheet .muted {
  margin-bottom: 4px;
}

.fare-options {
  display: grid;
  gap: 10px;
  margin: 18px 0;
}

.fare-card {
  display: grid;
  grid-template-columns: 42px 1fr auto;
  align-items: center;
  gap: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
}

.fare-card.active {
  border-color: rgba(215, 25, 32, .38);
  background: #fff6f6;
}

.fare-icon {
  width: 42px;
  height: 42px;
  border-radius: 8px;
  background: #111820;
  color: white;
  display: grid;
  place-items: center;
  font-weight: 900;
}

.fare-card span,
.fare-card small {
  display: block;
}

.fare-card small {
  color: var(--muted);
  margin-top: 3px;
}

.fare-price {
  font-weight: 900;
}

.book-button,
.accept-button {
  width: 100%;
  min-height: 52px;
  border-radius: 8px;
  color: white;
  background: var(--red);
  font-weight: 900;
}

.driver-header {
  background: #151c27;
  color: white;
  padding: 16px 18px 18px;
  display: flex;
  justify-content: space-between;
  align-items: end;
}

.driver-header span {
  color: #aab5c5;
  font-size: 12px;
}

.offer-card,
.driver-map,
.compliance {
  background: white;
  margin: 12px;
  border-radius: 12px;
}

.offer-card {
  padding: 18px;
}

.offer-top {
  display: flex;
  justify-content: space-between;
  color: var(--red);
  font-size: 12px;
  font-weight: 850;
  margin-bottom: 12px;
}

.offer-card h3 {
  font-size: 22px;
  line-height: 1.15;
}

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

.offer-grid div,
.driver-stats div {
  background: var(--soft);
  border-radius: 8px;
  padding: 12px;
}

.offer-grid span,
.driver-stats span {
  display: block;
  color: var(--muted);
  font-size: 11px;
  margin-top: 3px;
}

.accept-button {
  margin-top: 16px;
  transition: .2s ease;
}

.accept-button.accepted {
  background: var(--green);
}

.driver-map {
  height: 200px;
  overflow: hidden;
}

.compliance {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  padding: 14px;
}

.compliance span {
  flex: 1;
  min-width: 92px;
  text-align: center;
  padding: 9px;
  border-radius: 999px;
  color: #087548;
  background: #e7f7ef;
  font-size: 12px;
  font-weight: 850;
}

@media (max-width: 1100px) {
  .app-shell {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: sticky;
    top: 0;
    z-index: 10;
    padding: 12px;
    display: grid;
    grid-template-columns: 1fr;
  }

  .brand,
  .module-list,
  .system-health {
    display: none;
  }

  .nav {
    grid-template-columns: repeat(3, 1fr);
  }

  .nav-item {
    justify-content: center;
  }

  .operator-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 760px) {
  .workspace {
    padding: 16px;
  }

  .topbar {
    align-items: flex-start;
    flex-direction: column;
  }

  .kpi-grid {
    grid-template-columns: repeat(2, 1fr);
  }

  .phone-stage.active {
    grid-template-columns: 1fr;
  }

  .phone {
    min-height: 704px;
  }

  .phone-info h2 {
    font-size: 34px;
  }

  .bar-row,
  .table-row {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 520px) {
  .nav-item span:last-child {
    display: none;
  }

  .kpi-grid {
    grid-template-columns: 1fr;
  }

  .panel-head {
    flex-direction: column;
  }

  .malaysia-map,
  .malaysia-map svg {
    min-height: 330px;
    height: 330px;
  }
}
