:root {
  color-scheme: light;
  --bg: #f5f7f4;
  --surface: #ffffff;
  --ink: #16211f;
  --muted: #68736f;
  --line: #dde4df;
  --green: #0f8f61;
  --green-dark: #086343;
  --amber: #d88919;
  --red: #d83b34;
  --blue: #2477b9;
  --shadow: 0 18px 60px rgba(30, 44, 39, 0.13);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--ink);
  font-family: "Inter", "Segoe UI", Arial, sans-serif;
}

button,
input,
select,
textarea {
  font: inherit;
}

button {
  cursor: pointer;
}

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

.sidebar {
  display: flex;
  flex-direction: column;
  gap: 28px;
  padding: 24px;
  background: #10231d;
  color: #eef8f3;
}

.brand,
.operator-card,
.nav-item {
  display: flex;
  align-items: center;
}

.brand {
  gap: 12px;
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  border-radius: 8px;
  background: var(--green);
  font-size: 22px;
  font-weight: 800;
}

.brand strong,
.operator-card strong {
  display: block;
}

.brand span,
.operator-card span {
  display: block;
  margin-top: 4px;
  color: #b9cbc4;
  font-size: 13px;
}

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

.nav-item {
  gap: 12px;
  width: 100%;
  min-height: 44px;
  padding: 0 12px;
  border: 1px solid transparent;
  border-radius: 8px;
  background: transparent;
  color: #d9e8e2;
  text-align: left;
}

.nav-item.active,
.nav-item:hover {
  border-color: rgba(255, 255, 255, 0.12);
  background: rgba(255, 255, 255, 0.08);
}

.icon {
  display: grid;
  place-items: center;
  width: 26px;
  height: 26px;
  border-radius: 7px;
  background: rgba(255, 255, 255, 0.11);
}

.operator-card {
  gap: 12px;
  margin-top: auto;
  padding: 14px;
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.08);
}

.status-dot {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: #44d07c;
  box-shadow: 0 0 0 6px rgba(68, 208, 124, 0.15);
}

.workspace {
  padding: 26px;
  overflow: hidden;
}

.topbar,
.panel-head,
.top-actions,
.form-row,
.order-meta,
.order-actions,
.order-title,
.worker-mini {
  display: flex;
  align-items: center;
}

.topbar {
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 22px;
}

.eyebrow {
  margin: 0 0 6px;
  color: var(--green-dark);
  font-size: 13px;
  font-weight: 700;
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  font-size: 32px;
  line-height: 1.2;
}

h2 {
  font-size: 19px;
}

.top-actions {
  gap: 10px;
}

.view-switch {
  width: fit-content;
  margin-bottom: 14px;
}

.account-chip {
  display: flex;
  align-items: center;
  gap: 9px;
  min-height: 44px;
  padding: 6px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
}

.account-chip strong,
.account-chip span {
  display: block;
}

.account-chip strong {
  font-size: 13px;
}

.account-chip span {
  margin-top: 2px;
  color: var(--muted);
  font-size: 12px;
}

.account-chip.signed-in {
  border-color: rgba(15, 143, 97, 0.32);
  background: #f4fbf8;
}

.account-avatar {
  display: grid;
  place-items: center;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: #dfeee7;
  color: var(--green-dark);
  font-size: 13px;
  font-weight: 800;
}

.primary-button,
.ghost-button,
.accept-button,
.secondary-button,
.segment,
.icon-button {
  min-height: 40px;
  border-radius: 8px;
  border: 1px solid transparent;
  padding: 0 16px;
}

.primary-button {
  background: var(--green);
  color: white;
  font-weight: 700;
}

.primary-button:hover,
.accept-button:hover {
  background: var(--green-dark);
}

.ghost-button {
  background: var(--surface);
  border-color: var(--line);
  color: var(--ink);
}

.secondary-button {
  background: #fff4f3;
  border-color: rgba(216, 59, 52, 0.18);
  color: var(--red);
  font-weight: 700;
}

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

.metric,
.panel,
.tracking-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: 0 8px 30px rgba(37, 55, 49, 0.06);
}

.metric {
  padding: 16px;
}

.metric span,
.metric small,
.panel-head p,
.order-meta,
.tracking-label {
  color: var(--muted);
}

.metric strong {
  display: block;
  margin: 8px 0 4px;
  font-size: 30px;
}

.metric.urgent {
  border-color: rgba(216, 59, 52, 0.35);
}

.main-grid {
  display: grid;
  grid-template-columns: minmax(420px, 1.1fr) minmax(360px, 0.9fr);
  gap: 14px;
}

.panel {
  min-height: 520px;
}

.panel-head {
  justify-content: space-between;
  gap: 16px;
  padding: 18px;
  border-bottom: 1px solid var(--line);
}

.panel-head.compact {
  padding-bottom: 12px;
}

.segmented {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 4px;
  padding: 4px;
  background: #eef3ef;
  border-radius: 8px;
}

.segment {
  min-height: 32px;
  padding: 0 12px;
  background: transparent;
  color: var(--muted);
}

.segment.active {
  background: white;
  color: var(--ink);
  box-shadow: 0 2px 8px rgba(20, 32, 29, 0.1);
}

.order-list {
  display: grid;
  gap: 10px;
  padding: 14px;
}

.order-card {
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.order-card.selected {
  border-color: rgba(15, 143, 97, 0.55);
  box-shadow: 0 0 0 1px rgba(15, 143, 97, 0.15);
}

.order-card.accepted {
  border-color: rgba(15, 143, 97, 0.45);
  background: #f4fbf8;
}

.order-title {
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 8px;
}

.order-title strong {
  font-size: 17px;
}

.badge {
  display: inline-flex;
  align-items: center;
  min-height: 26px;
  padding: 0 9px;
  border-radius: 999px;
  background: #eef3ef;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  white-space: nowrap;
}

.badge.high {
  background: #ffe8e5;
  color: var(--red);
}

.badge.medium {
  background: #fff1d8;
  color: #9b610b;
}

.order-description {
  margin-bottom: 12px;
  color: #35413d;
  line-height: 1.55;
}

.dispatch-strip {
  display: grid;
  gap: 6px;
  margin-bottom: 12px;
  padding: 12px;
  border: 1px solid rgba(36, 119, 185, 0.18);
  border-radius: 8px;
  background: #f3f8fc;
}

.dispatch-strip.tradie {
  border-color: rgba(15, 143, 97, 0.22);
  background: #f2fbf7;
}

.dispatch-strip strong {
  font-size: 14px;
}

.dispatch-strip small {
  color: var(--muted);
  line-height: 1.45;
}

.dispatch-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.order-meta {
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 12px;
  font-size: 13px;
}

.escrow-box {
  display: grid;
  grid-template-columns: minmax(110px, 0.7fr) minmax(160px, 1.3fr);
  gap: 10px 14px;
  margin-bottom: 12px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8faf8;
}

.escrow-box p {
  grid-column: 1 / -1;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
}

.escrow-box.held {
  border-color: rgba(36, 119, 185, 0.28);
  background: #f3f8fc;
}

.escrow-box.hold {
  border-color: rgba(216, 137, 25, 0.35);
  background: #fffaf1;
}

.escrow-box.released {
  border-color: rgba(15, 143, 97, 0.38);
  background: #f2fbf7;
}

.escrow-box.dispute {
  border-color: rgba(216, 59, 52, 0.28);
  background: #fff5f4;
}

.escrow-label {
  display: block;
  margin-bottom: 4px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.order-actions {
  justify-content: space-between;
  gap: 12px;
}

.action-stack {
  display: grid;
  gap: 8px;
  justify-items: end;
}

.worker-mini {
  gap: 8px;
  min-width: 0;
}

.avatar {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: #dfeee7;
  color: var(--green-dark);
  font-weight: 800;
}

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

.accept-button {
  background: var(--green);
  color: white;
  font-weight: 700;
  white-space: nowrap;
}

.accept-button:disabled {
  background: #cfdbd5;
  color: #61716b;
  cursor: default;
}

.secondary-button:disabled {
  background: #f6f0ef;
  color: #a9928e;
  border-color: #eadfdd;
  cursor: default;
}

.proof-strip,
.dispute-box {
  display: grid;
  gap: 8px;
  margin-bottom: 12px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.proof-strip {
  background: #f8faf8;
}

.proof-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.proof-chip {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  padding: 0 10px;
  border-radius: 999px;
  background: #eef3ef;
  color: var(--ink);
  font-size: 12px;
  font-weight: 700;
}

.dispute-box {
  background: #fff5f4;
  border-color: rgba(216, 59, 52, 0.2);
}

.dispute-box strong,
.proof-strip strong {
  font-size: 14px;
}

.dispute-box small,
.proof-strip small {
  color: var(--muted);
  line-height: 1.45;
}

.live-pill {
  display: inline-flex;
  align-items: center;
  height: 28px;
  padding: 0 10px;
  border-radius: 999px;
  background: #e8f8ef;
  color: var(--green-dark);
  font-size: 12px;
  font-weight: 800;
}

.city-map {
  position: relative;
  height: 340px;
  margin: 14px;
  overflow: hidden;
  border-radius: 8px;
  background:
    linear-gradient(90deg, rgba(36, 119, 185, 0.08) 1px, transparent 1px),
    linear-gradient(rgba(36, 119, 185, 0.08) 1px, transparent 1px),
    #eef4f1;
  background-size: 46px 46px;
}

.road {
  position: absolute;
  background: rgba(255, 255, 255, 0.85);
  box-shadow: 0 0 0 1px rgba(104, 115, 111, 0.08);
}

.road-a {
  width: 130%;
  height: 26px;
  left: -12%;
  top: 42%;
  transform: rotate(-15deg);
}

.road-b {
  width: 28px;
  height: 120%;
  left: 54%;
  top: -10%;
  transform: rotate(9deg);
}

.road-c {
  width: 120%;
  height: 20px;
  left: -10%;
  top: 70%;
  transform: rotate(8deg);
}

.zone {
  position: absolute;
  color: rgba(22, 33, 31, 0.48);
  font-size: 13px;
  font-weight: 700;
}

.zone-a {
  left: 16px;
  top: 18px;
}

.zone-b {
  right: 26px;
  top: 26px;
}

.zone-c {
  right: 32px;
  bottom: 24px;
}

.map-pin {
  position: absolute;
  left: var(--x);
  top: var(--y);
  width: 20px;
  height: 20px;
  border: 3px solid white;
  border-radius: 50%;
  transform: translate(-50%, -50%);
  box-shadow: var(--shadow);
}

.map-pin.worker {
  background: var(--green);
}

.map-pin.order {
  background: var(--blue);
}

.map-pin.emergency {
  width: 24px;
  height: 24px;
  background: var(--red);
  animation: pulse 1.5s infinite;
}

.route-line {
  position: absolute;
  left: 31%;
  top: 39%;
  width: 170px;
  height: 4px;
  border-radius: 999px;
  background: repeating-linear-gradient(90deg, var(--green), var(--green) 14px, transparent 14px, transparent 24px);
  transform: rotate(28deg);
  transform-origin: left center;
}

@keyframes pulse {
  0% {
    box-shadow: 0 0 0 0 rgba(216, 59, 52, 0.35);
  }
  70% {
    box-shadow: 0 0 0 16px rgba(216, 59, 52, 0);
  }
  100% {
    box-shadow: 0 0 0 0 rgba(216, 59, 52, 0);
  }
}

.tracking-card {
  margin: 14px;
  padding: 16px;
}

.summary-card {
  display: grid;
  gap: 14px;
  margin: 14px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8faf8;
}

.summary-card strong {
  display: block;
  margin-top: 4px;
}

.summary-list {
  display: grid;
  gap: 10px;
}

.summary-item {
  display: grid;
  gap: 4px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

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

.summary-item strong {
  margin: 0;
  font-size: 14px;
}

.summary-item span,
.summary-item small {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.45;
}

.summary-pill {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  padding: 0 8px;
  border-radius: 999px;
  background: #eef3ef;
  color: var(--ink);
  font-size: 12px;
  font-weight: 700;
}

.summary-pill.pending {
  background: #fff1d8;
  color: #9b610b;
}

.summary-pill.ready {
  background: #e8f8ef;
  color: var(--green-dark);
}

.summary-pill.locked {
  background: #eef3ef;
  color: var(--muted);
}

.is-hidden {
  display: none;
}

.tracking-card strong {
  display: block;
  margin-top: 4px;
}

.timeline {
  display: grid;
  grid-template-columns: repeat(8, 1fr);
  gap: 8px;
  margin: 16px 0 0;
  padding: 0;
  list-style: none;
}

.timeline li {
  min-height: 36px;
  padding: 8px;
  border-radius: 8px;
  background: #eef3ef;
  color: var(--muted);
  font-size: 13px;
  text-align: center;
}

.timeline li.done {
  background: #e8f8ef;
  color: var(--green-dark);
  font-weight: 800;
}

.conversation-card {
  display: grid;
  gap: 14px;
  margin: 14px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
}

.conversation-card strong {
  display: block;
  margin-top: 4px;
}

.conversation-list {
  display: grid;
  gap: 10px;
  max-height: 260px;
  overflow: auto;
  padding-right: 4px;
}

.message-item {
  display: grid;
  gap: 4px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8faf8;
}

.message-item.own {
  background: #f2fbf7;
  border-color: rgba(15, 143, 97, 0.22);
}

.message-item.system {
  background: #f5f7fb;
  border-color: rgba(36, 119, 185, 0.18);
}

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

.message-meta strong {
  margin: 0;
  font-size: 13px;
}

.message-meta span,
.message-item p,
.message-empty {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
}

.conversation-form {
  display: grid;
  gap: 12px;
}

.conversation-form textarea {
  min-height: 86px;
}

.request-dialog {
  width: min(540px, calc(100vw - 28px));
  border: 0;
  border-radius: 8px;
  padding: 0;
  box-shadow: var(--shadow);
}

.payment-dialog {
  width: min(500px, calc(100vw - 28px));
}

.payment-summary,
.secure-note {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8faf8;
}

.payment-summary {
  display: grid;
  gap: 10px;
  padding: 14px;
}

.payment-summary div {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
}

.payment-summary span,
.payment-summary p,
.secure-note {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
}

.payment-summary strong {
  text-align: right;
}

.secure-note {
  padding: 12px;
}

.request-dialog::backdrop {
  background: rgba(16, 35, 29, 0.45);
}

.request-form {
  display: grid;
  gap: 14px;
  padding: 22px;
}

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

.icon-button {
  width: 38px;
  padding: 0;
  background: #eef3ef;
  color: var(--ink);
  font-size: 24px;
  line-height: 1;
}

label {
  display: grid;
  gap: 7px;
  color: #34433e;
  font-size: 14px;
  font-weight: 700;
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 11px 12px;
  background: #fff;
  color: var(--ink);
}

textarea {
  min-height: 96px;
  resize: vertical;
}

.form-row {
  align-items: start;
  gap: 12px;
}

.form-row label {
  flex: 1;
}

.full {
  width: 100%;
}

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

  .sidebar {
    position: sticky;
    top: 0;
    z-index: 5;
    display: grid;
    grid-template-columns: 1fr auto;
    gap: 14px;
    padding: 14px;
  }

  .nav-list {
    grid-column: 1 / -1;
    grid-template-columns: repeat(4, 1fr);
  }

  .operator-card {
    display: none;
  }

  .metric-grid,
  .main-grid {
    grid-template-columns: 1fr 1fr;
  }

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

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

  .topbar,
  .panel-head,
  .order-actions {
    align-items: stretch;
    flex-direction: column;
  }

  h1 {
    font-size: 25px;
  }

  .top-actions,
  .form-row {
    flex-direction: column;
  }

  .top-actions button {
    width: 100%;
  }

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

  .nav-list {
    grid-template-columns: 1fr 1fr;
  }

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

  .nav-item span:last-child {
    display: none;
  }

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