:root {
  --bg: #f6f7f8;
  --panel: #ffffff;
  --ink: #17211b;
  --muted: #68736c;
  --line: #dfe5e1;
  --accent: #0f7b55;
  --accent-strong: #075f41;
  --warn: #b7791f;
  --danger: #b42318;
  --ok: #18875f;
  --soft: #eef7f2;
  --shadow: 0 12px 30px rgba(20, 33, 26, 0.08);
  color-scheme: light;
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--ink);
  display: grid;
  grid-template-columns: 280px minmax(0, 1fr);
}

body.is-loading {
  cursor: wait;
}

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

button {
  border: 0;
  border-radius: 6px;
  background: var(--accent);
  color: #fff;
  min-height: 38px;
  padding: 0 14px;
  cursor: pointer;
}

button:hover {
  background: var(--accent-strong);
}

button.button-loading {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

button.button-loading::before {
  content: "";
  width: 14px;
  height: 14px;
  border: 2px solid rgba(255, 255, 255, 0.48);
  border-top-color: #fff;
  border-radius: 999px;
  animation: loading-spin 0.82s linear infinite;
}

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

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

.sidebar {
  background: #14231b;
  color: #f8faf8;
  padding: 20px 14px;
  display: flex;
  flex-direction: column;
  gap: 20px;
  min-height: 100vh;
  position: sticky;
  top: 0;
}

.brand {
  display: flex;
  gap: 12px;
  align-items: center;
  padding: 4px 6px 16px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.12);
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  border-radius: 8px;
  background: #e7f7ef;
  color: #0d5139;
  font-weight: 800;
}

.brand span,
.sidebar-footer,
.eyebrow,
.meta,
.muted {
  color: var(--muted);
  font-size: 13px;
}

.brand span {
  display: block;
  color: rgba(255, 255, 255, 0.65);
}

nav {
  display: grid;
  gap: 5px;
}

.nav-button {
  background: transparent;
  color: rgba(255, 255, 255, 0.8);
  text-align: left;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 10px 12px;
}

.nav-button:hover,
.nav-button.active {
  background: rgba(255, 255, 255, 0.1);
  color: #fff;
}

.nav-count {
  min-width: 26px;
  text-align: center;
  padding: 2px 6px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.12);
  font-size: 12px;
}

.sidebar-footer {
  margin-top: auto;
  display: grid;
  gap: 10px;
  color: rgba(255, 255, 255, 0.7);
}

.workspace {
  min-width: 0;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  padding: 24px 28px;
  border-bottom: 1px solid var(--line);
  background: rgba(246, 247, 248, 0.92);
  position: sticky;
  top: 0;
  z-index: 5;
  backdrop-filter: blur(12px);
}

.topbar h1,
.dialog-head h2 {
  margin: 0;
  letter-spacing: 0;
}

.eyebrow {
  margin: 0 0 4px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-weight: 700;
}

.topbar-actions {
  display: grid;
  grid-template-columns: minmax(240px, 360px) auto;
  gap: 10px;
  align-items: center;
}

.view {
  padding: 24px 28px 42px;
  display: grid;
  gap: 18px;
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(160px, 1fr));
  gap: 14px;
}

.stat,
.panel,
.record-card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.stat {
  padding: 16px;
}

.stat strong {
  display: block;
  margin-top: 6px;
  font-size: 28px;
  letter-spacing: 0;
}

.panel {
  overflow: hidden;
}

.panel-head,
.record-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 15px 16px;
  border-bottom: 1px solid var(--line);
}

.panel-head h2,
.record-head h3 {
  margin: 0;
  font-size: 17px;
  letter-spacing: 0;
}

.panel-actions,
.row-actions {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
}

.compact-select {
  width: auto;
  min-width: 142px;
}

.table-wrap {
  overflow: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
  min-width: 760px;
}

.orders-table {
  min-width: 980px;
}

th,
td {
  text-align: left;
  padding: 12px 14px;
  border-bottom: 1px solid var(--line);
  vertical-align: top;
  font-size: 14px;
}

th {
  color: var(--muted);
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  background: #fbfcfb;
}

tr:last-child td {
  border-bottom: 0;
}

.orders-table tbody tr:hover {
  background: #fbfcfb;
}

.order-cell {
  display: grid;
  gap: 3px;
}

.text-link {
  display: inline;
  width: fit-content;
  min-height: 0;
  padding: 0;
  border: 0;
  border-radius: 0;
  background: transparent;
  color: var(--accent);
  font-weight: 800;
  text-align: left;
}

.text-link:hover {
  background: transparent;
  color: var(--accent-strong);
  text-decoration: underline;
}

.order-cell strong {
  font-size: 14px;
}

.order-cell span,
.mini-meta {
  color: var(--muted);
  font-size: 12px;
}

.status-stack {
  display: grid;
  justify-items: start;
  gap: 5px;
}

.badge {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  border-radius: 999px;
  padding: 2px 9px;
  background: #eef1ef;
  color: #3a463f;
  font-size: 12px;
  font-weight: 700;
  white-space: nowrap;
}

.badge.ok {
  background: #e9f8f1;
  color: var(--ok);
}

.badge.warn {
  background: #fff7e6;
  color: var(--warn);
}

.badge.danger {
  background: #fff0ed;
  color: var(--danger);
}

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

.ghost-button:hover {
  background: var(--soft);
  color: var(--accent-strong);
}

.danger-button {
  background: var(--danger);
}

.danger-button:hover {
  background: #8f1d14;
}

.icon-button {
  width: 36px;
  padding: 0;
  background: transparent;
  color: var(--muted);
  border: 1px solid var(--line);
}

.split {
  display: grid;
  grid-template-columns: minmax(0, 1.35fr) minmax(320px, 0.65fr);
  gap: 18px;
}

.records-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(220px, 1fr));
  gap: 14px;
  padding: 16px;
}

.record-card {
  box-shadow: none;
}

.record-card .body {
  padding: 14px;
  display: grid;
  gap: 8px;
}

.record-card p {
  margin: 0;
}

.progress-list {
  display: grid;
  gap: 12px;
  padding: 16px;
}

.progress-row {
  display: grid;
  grid-template-columns: 150px 1fr auto;
  gap: 12px;
  align-items: center;
}

.bar {
  height: 10px;
  border-radius: 999px;
  background: #e7ece8;
  overflow: hidden;
}

.bar span {
  display: block;
  height: 100%;
  background: var(--accent);
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.field.full {
  grid-column: 1 / -1;
}

.field label {
  display: block;
  margin-bottom: 6px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

dialog {
  width: min(820px, calc(100vw - 32px));
  border: 0;
  border-radius: 10px;
  box-shadow: 0 24px 70px rgba(0, 0, 0, 0.24);
  padding: 0;
}

dialog::backdrop {
  background: rgba(12, 20, 16, 0.55);
}

.loading-overlay {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: grid;
  place-items: center;
  padding: 24px;
  background: rgba(12, 20, 16, 0.48);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.16s ease;
  backdrop-filter: blur(5px);
}

.loading-overlay.active {
  opacity: 1;
  pointer-events: all;
}

.loading-card {
  width: min(320px, 100%);
  display: grid;
  justify-items: center;
  gap: 10px;
  padding: 24px;
  border: 1px solid rgba(255, 255, 255, 0.54);
  border-radius: 10px;
  background: #ffffff;
  box-shadow: 0 24px 70px rgba(0, 0, 0, 0.24);
  text-align: center;
}

.loading-card strong {
  font-size: 17px;
}

.loading-card span {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
}

.loading-spinner {
  width: 58px;
  height: 58px;
  fill: none;
  stroke-linecap: round;
}

.loading-track {
  stroke: #dfe5e1;
  stroke-width: 7;
}

.loading-arc {
  stroke: var(--accent);
  stroke-width: 7;
  animation: loading-spin 0.82s linear infinite;
  transform-origin: center;
}

@keyframes loading-spin {
  to {
    transform: rotate(360deg);
  }
}

#editorForm {
  padding: 18px;
  display: grid;
  gap: 18px;
}

.dialog-head,
menu {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin: 0;
  padding: 0;
}

.empty {
  padding: 32px;
  color: var(--muted);
  text-align: center;
}

.details-body {
  display: grid;
  gap: 16px;
}

.details-body h3 {
  margin: 4px 0 0;
  font-size: 16px;
}

.detail-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.detail-grid p {
  margin: 0;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fbfcfb;
  min-width: 0;
}

.detail-grid strong {
  display: block;
  overflow-wrap: anywhere;
}

.identity-title,
.identity-id,
.contact-stack span {
  display: block;
}

.identity-title {
  color: var(--ink);
  font-size: 15px;
}

.identity-id {
  margin-top: 2px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
}

.contact-stack {
  display: grid;
  gap: 3px;
}

.timeline {
  display: grid;
  gap: 8px;
  margin: 0;
  padding-left: 22px;
}

.timeline li {
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fbfcfb;
}

.timeline li.done {
  border-color: #caeadb;
  background: #f4fbf7;
}

.timeline span {
  display: block;
  color: var(--muted);
  font-size: 13px;
}

.chat-phone {
  display: grid;
  gap: 10px;
  max-width: 640px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: #f2f4f3;
}

.chat-message {
  width: min(82%, 440px);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 10px 12px;
  background: #fff;
  box-shadow: 0 4px 12px rgba(20, 33, 26, 0.05);
}

.chat-message.customer {
  justify-self: start;
  border-bottom-left-radius: 4px;
}

.chat-message.rider {
  justify-self: end;
  border-color: #cfe9dc;
  border-bottom-right-radius: 4px;
  background: #eaf8f1;
}

.chat-message.restaurant,
.chat-message.system {
  justify-self: center;
  width: min(92%, 520px);
  background: #fff8e9;
}

.chat-bubble-head {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  color: var(--muted);
  font-size: 13px;
}

.chat-message p {
  margin: 6px 0 0;
  overflow-wrap: anywhere;
}

@media (max-width: 1080px) {
  body {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: static;
    min-height: auto;
  }

  nav {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .stats-grid,
  .records-grid,
  .split {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 720px) {
  .topbar {
    align-items: stretch;
    flex-direction: column;
  }

  .topbar-actions,
  .form-grid,
  .detail-grid,
  .progress-row {
    grid-template-columns: 1fr;
  }

  .view,
  .topbar {
    padding-left: 16px;
    padding-right: 16px;
  }
}
