:root {
  --brand: #d84315;
  --brand-dark: #a52d0f;
  --ink: #1f2328;
  --muted: #6b7280;
  --bg: #f5f6f8;
  --card: #ffffff;
  --border: #e5e7eb;
  --ok: #1b8a5a;
  --warn: #b45309;
  --danger: #b91c1c;
}
* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: -apple-system, Segoe UI, Roboto, Helvetica, Arial, sans-serif;
  background: var(--bg);
  color: var(--ink);
}
header.topbar {
  background: var(--brand);
  color: white;
  padding: 14px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
header.topbar h1 { font-size: 17px; margin: 0; font-weight: 600; }
header.topbar .who { font-size: 13px; opacity: .9; }
nav.tabs {
  display: flex;
  gap: 4px;
  background: var(--brand-dark);
  padding: 0 16px;
  overflow-x: auto;
}
nav.tabs button {
  background: transparent;
  border: none;
  color: rgba(255,255,255,.75);
  padding: 10px 14px;
  font-size: 13px;
  cursor: pointer;
  border-bottom: 3px solid transparent;
  white-space: nowrap;
}
nav.tabs button.active { color: white; border-bottom-color: white; font-weight: 600; }
main { padding: 18px; max-width: 1200px; margin: 0 auto; }
.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 16px;
  margin-bottom: 16px;
}
.grid { display: grid; gap: 12px; }
.grid.cols-2 { grid-template-columns: 1fr 1fr; }
.grid.cols-3 { grid-template-columns: repeat(3, 1fr); }
.grid.cols-4 { grid-template-columns: repeat(4, 1fr); }
@media (max-width: 720px) {
  .grid.cols-2, .grid.cols-3, .grid.cols-4 { grid-template-columns: 1fr; }
}
label { display: block; font-size: 12px; color: var(--muted); margin-bottom: 4px; }
input, select, textarea {
  width: 100%;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 14px;
  font-family: inherit;
}
.field { margin-bottom: 10px; }
button.btn {
  background: var(--brand);
  color: white;
  border: none;
  padding: 9px 16px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 14px;
  font-weight: 600;
}
button.btn:hover { background: var(--brand-dark); }
button.btn.secondary { background: white; color: var(--brand); border: 1px solid var(--brand); }
button.btn.small { padding: 5px 10px; font-size: 12px; }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th, td { text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--border); }
th { color: var(--muted); font-weight: 600; font-size: 12px; text-transform: uppercase; }
.kpi { text-align: center; }
.kpi .value { font-size: 26px; font-weight: 700; color: var(--brand); }
.kpi .label { font-size: 12px; color: var(--muted); margin-top: 4px; }
.badge { display: inline-block; padding: 2px 8px; border-radius: 20px; font-size: 11px; font-weight: 600; }
.badge.submitted { background: #fef3c7; color: var(--warn); }
.badge.accepted, .badge.picking, .badge.packing, .badge.ready_for_dispatch { background: #dbeafe; color: #1d4ed8; }
.badge.dispatched { background: #e0e7ff; color: #4338ca; }
.badge.delivered { background: #dcfce7; color: var(--ok); }
.badge.cancelled { background: #fee2e2; color: var(--danger); }
.section-title { font-size: 15px; font-weight: 600; margin: 0 0 12px; }
.muted { color: var(--muted); font-size: 13px; }
.login-wrap { display: flex; align-items: center; justify-content: center; min-height: 90vh; }
.login-box { width: 340px; }
.error-msg { color: var(--danger); font-size: 13px; margin-top: 8px; }
.line-item { display: grid; grid-template-columns: 2fr 0.8fr 0.8fr 1fr 1fr auto; gap: 8px; align-items: end; margin-bottom: 8px; }
.map-search-row { display: flex; gap: 8px; margin-bottom: 8px; }
.map-search-row input { flex: 1; }
#retailerMap { height: 320px; border-radius: 8px; border: 1px solid var(--border); margin-bottom: 8px; }
.map-search-results { max-height: 160px; overflow-y: auto; border: 1px solid var(--border); border-radius: 6px; margin-bottom: 8px; }
.map-search-results div { padding: 8px 10px; font-size: 13px; cursor: pointer; border-bottom: 1px solid var(--border); }
.map-search-results div:last-child { border-bottom: none; }
.map-search-results div:hover { background: var(--bg); }
.chart-box { position: relative; margin-bottom: 14px; }
.chart-box canvas { max-width: 100%; }
.total-row { text-align: right; font-size: 16px; font-weight: 700; margin-top: 10px; }
