:root {
  color-scheme: light;
  --bg: #f4f5f1;
  --panel: #ffffff;
  --ink: #20201d;
  --muted: #6a6d66;
  --line: #dfe2da;
  --red: #d9232e;
  --red-dark: #a91720;
  --gold: #f2b705;
  --green: #16825d;
  --blue: #246bba;
  --shadow: 0 14px 38px rgba(32, 32, 29, 0.08);
}

* {
  box-sizing: border-box;
}

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

body.order-page {
  background: #211f1c;
}

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

.customer-shell {
  width: min(920px, calc(100% - 28px));
  margin: 0 auto;
  min-height: 100vh;
  display: grid;
  grid-template-columns: 0.85fr 1fr;
  align-items: center;
  gap: 24px;
  padding: 28px 0;
}

.customer-hero {
  color: #fffaf1;
  display: grid;
  gap: 18px;
}

.customer-brand {
  align-items: center;
}

.customer-brand p {
  color: #d9d1c4;
}

.customer-hero h2 {
  margin: 0;
  font-size: 44px;
  line-height: 1.05;
}

.customer-hero > p {
  margin: 0;
  color: #d9d1c4;
  font-size: 18px;
  line-height: 1.45;
}

.customer-panel {
  background: var(--panel);
  border-radius: 8px;
  padding: 20px;
  box-shadow: var(--shadow);
}

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

.public-order-form label {
  display: grid;
  gap: 7px;
  font-size: 13px;
  font-weight: 800;
}

.customer-result {
  margin-top: 14px;
  display: none;
  border-radius: 8px;
  padding: 13px;
  line-height: 1.45;
}

.customer-result.success,
.customer-result.error {
  display: grid;
  gap: 5px;
}

.customer-result.success {
  background: #eaf8f1;
  border: 1px solid #b8e5ce;
  color: #0d5f42;
}

.customer-result.error {
  background: #fff0f0;
  border: 1px solid #ffd2d2;
  color: var(--red-dark);
}

button {
  border: 0;
  cursor: pointer;
}

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

.sidebar {
  background: #211f1c;
  color: #fffaf1;
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 28px;
}

.brand-block {
  display: flex;
  align-items: center;
  gap: 14px;
}

.brand-mark {
  width: 54px;
  height: 54px;
  border-radius: 8px;
  background: var(--red);
  color: white;
  display: grid;
  place-items: center;
  font-weight: 900;
  letter-spacing: 0;
  border: 3px solid var(--gold);
}

.brand-block h1,
.brand-block p,
.topbar h2,
.panel-heading h3 {
  margin: 0;
}

.brand-block h1 {
  font-size: 22px;
  line-height: 1;
}

.brand-block p,
.side-panel span,
.metric-card span,
.label,
td {
  color: var(--muted);
}

.sidebar .brand-block p,
.sidebar .side-panel span {
  color: #cfc7b8;
}

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

.nav-item {
  min-height: 44px;
  border-radius: 8px;
  background: transparent;
  color: #fffaf1;
  text-align: left;
  padding: 0 14px;
}

.nav-item.active,
.nav-item:hover {
  background: rgba(255, 255, 255, 0.11);
}

.side-panel {
  margin-top: auto;
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 8px;
  padding: 16px;
  display: grid;
  gap: 8px;
}

.main-area {
  padding: 26px;
  overflow: hidden;
}

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

.eyebrow,
.label {
  margin: 0 0 5px;
  text-transform: uppercase;
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0;
}

.eyebrow {
  color: var(--red-dark);
}

.topbar h2 {
  font-size: 34px;
  line-height: 1.08;
}

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

.primary,
.secondary,
.small-btn {
  min-height: 40px;
  border-radius: 8px;
  padding: 0 14px;
  font-weight: 800;
}

.primary {
  background: var(--red);
  color: white;
}

.secondary,
.small-btn {
  background: #eceee7;
  color: var(--ink);
  border: 1px solid var(--line);
}

.small-btn {
  min-height: 32px;
  font-size: 13px;
}

.small-btn.danger {
  background: #fff0f0;
  color: var(--red-dark);
  border-color: #ffd2d2;
}

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

.metric-card,
.workspace-panel,
.order-card,
.agent-card,
.rider-card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.metric-card {
  padding: 16px;
  display: grid;
  gap: 6px;
}

.metric-card strong {
  font-size: 34px;
}

.metric-card.alert strong {
  color: var(--red-dark);
}

.view {
  display: none;
}

.view.active {
  display: block;
}

.split-layout,
.dispatcher-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 18px;
  align-items: start;
}

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

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

.full-width {
  margin-top: 18px;
}

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

.panel-heading h3 {
  font-size: 20px;
}

.status-pill {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  border-radius: 999px;
  padding: 0 10px;
  font-size: 12px;
  font-weight: 800;
  white-space: nowrap;
  color: #fff;
  background: var(--blue);
}

.status-pill.green { background: var(--green); }
.status-pill.gold { background: #806005; }
.status-pill.red { background: var(--red-dark); }
.status-pill.gray { background: #62645f; }

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

.order-form label,
.test-chat-form label {
  display: grid;
  gap: 7px;
  font-size: 13px;
  font-weight: 800;
}

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

.chat-window {
  margin-top: 14px;
  display: grid;
  gap: 8px;
  max-height: 320px;
  overflow: auto;
}

.chat-message {
  border-radius: 8px;
  padding: 10px 12px;
  font-size: 13px;
  line-height: 1.45;
  white-space: pre-line;
}

.chat-message.customer {
  background: #eceee7;
  margin-left: 28px;
}

.chat-message.bot {
  background: #fff7db;
  border: 1px solid #f2df9e;
  margin-right: 28px;
}

.wide {
  grid-column: 1 / -1;
}

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

.order-list,
.board,
.rider-grid {
  display: grid;
  gap: 12px;
}

.board,
.rider-grid {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

.order-card,
.agent-card,
.rider-card {
  padding: 14px;
  box-shadow: none;
}

.order-card header,
.agent-card header,
.rider-card header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 10px;
  margin-bottom: 10px;
}

.order-card h4,
.agent-card h4,
.rider-card h4 {
  margin: 0 0 4px;
  font-size: 16px;
}

.order-card p,
.agent-card p,
.rider-card p {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
}

.card-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 12px;
}

.table-wrap {
  overflow-x: auto;
}

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

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

th {
  color: var(--ink);
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0;
}

.table-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
}

.toast {
  position: fixed;
  right: 20px;
  bottom: 20px;
  background: #211f1c;
  color: #fffaf1;
  padding: 13px 16px;
  border-radius: 8px;
  box-shadow: var(--shadow);
  opacity: 0;
  transform: translateY(12px);
  pointer-events: none;
  transition: 180ms ease;
  max-width: min(360px, calc(100vw - 40px));
}

.toast.show {
  opacity: 1;
  transform: translateY(0);
}

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

  .sidebar {
    position: static;
    padding: 18px;
  }

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

  .side-panel {
    display: none;
  }

  .split-layout,
  .dispatcher-grid,
  .board,
  .rider-grid,
  .metrics-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 700px) {
  .main-area {
    padding: 16px;
  }

  .topbar,
  .panel-heading {
    align-items: stretch;
    flex-direction: column;
  }

  .topbar h2 {
    font-size: 28px;
  }

  .nav-list,
  .split-layout,
  .dispatcher-grid,
  .board,
  .rider-grid,
  .metrics-grid,
  .order-form,
  .public-order-form,
  .customer-shell {
    grid-template-columns: 1fr;
  }

  .customer-shell {
    align-items: start;
    padding-top: 22px;
  }

  .customer-hero h2 {
    font-size: 34px;
  }

  .top-actions,
  .card-actions,
  .table-actions {
    justify-content: stretch;
  }

  .top-actions button,
  .card-actions button,
  .table-actions button {
    flex: 1 1 auto;
  }
}
