:root {
  color-scheme: light;
  --orange: #f97316;
  --red: #ef4444;
  --ink: #172033;
  --muted: #667085;
  --line: #d8dee8;
  --surface: #ffffff;
  --soft: #f6f8fb;
  --green: #12805c;
  --blue: #2563eb;
  --shadow: 0 18px 50px rgba(23, 32, 51, 0.1);
  --chip: #f2f4f7;
  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;
  display: block;
  background: var(--soft);
  color: var(--ink);
}

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

button {
  border: 0;
  cursor: pointer;
  border-radius: 8px;
  background: var(--orange);
  color: #fff;
  font-weight: 800;
  min-height: 40px;
  padding: 0 14px;
}

button.secondary {
  background: #edf0f4;
  color: var(--ink);
}

button:disabled {
  cursor: wait;
  opacity: 0.65;
}

.sidebar {
  min-height: 100vh;
  background: #fff;
  border-right: 1px solid var(--line);
  padding: 18px;
  position: fixed;
  top: 0;
  left: 0;
  width: 260px;
  z-index: 40;
  transform: translateX(-100%);
  transition: transform 180ms ease;
  box-shadow: var(--shadow);
}

.sidebar.open {
  transform: translateX(0);
}

.drawer-backdrop {
  position: fixed;
  inset: 0;
  z-index: 35;
  background: rgba(15, 23, 42, 0.28);
}

.brand-logo {
  width: 104px;
  height: auto;
  display: block;
  margin: 0 auto 18px;
  border-radius: 20px;
  box-shadow: var(--shadow);
}

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

.nav-tabs button {
  background: transparent;
  color: var(--ink);
  text-align: left;
  border: 1px solid transparent;
}

.nav-tabs button.active,
.nav-tabs button:hover {
  background: #fff3eb;
  border-color: #fed7aa;
  color: #c2410c;
}

.status-tile {
  margin-top: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px 12px;
  display: grid;
  gap: 4px;
}

.status-tile span,
.eyebrow,
.section-title p,
label,
small {
  color: var(--muted);
}

.app-shell {
  padding: 20px 28px 40px;
  min-width: 0;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 25;
  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: 12px;
  margin-bottom: 20px;
  padding: 10px 0 14px;
  background: rgba(246, 248, 251, 0.94);
  backdrop-filter: blur(12px);
}

.topbar h1 {
  margin: 0;
  font-size: 34px;
  line-height: 1;
}

.brand-lockup {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 176px;
}

.menu-button {
  width: 42px;
  min-height: 42px;
  padding: 0;
  background: #fff;
  color: var(--ink);
  border: 1px solid transparent;
  border-radius: 999px;
  font-size: 24px;
}

.menu-button:hover {
  border-color: var(--line);
  background: #f8fafc;
}

.delivery-mode {
  display: inline-flex;
  align-items: center;
  padding: 3px;
  border-radius: 999px;
  background: #edf0f4;
  white-space: nowrap;
}

.delivery-mode button,
.address-chip,
.auth-actions button,
.cart-button {
  min-height: 38px;
  border-radius: 999px;
}

.delivery-mode button {
  background: transparent;
  color: var(--ink);
  padding: 0 16px;
}

.delivery-mode button.active {
  background: #fff;
  box-shadow: 0 4px 14px rgba(23, 32, 51, 0.12);
}

.address-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  max-width: 260px;
  background: transparent;
  color: var(--ink);
}

.address-chip strong {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.top-search {
  flex: 1 1 280px;
  max-width: 620px;
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 8px;
  min-height: 44px;
  padding: 0 14px;
  border-radius: 999px;
  background: #fff;
  border: 1px solid var(--line);
}

.top-search span {
  color: var(--muted);
  font-weight: 900;
}

.top-search input {
  border: 0;
  padding: 0;
  background: transparent;
}

.top-search input:focus {
  outline: 0;
}

.top-search button {
  display: none;
}

.eyebrow {
  margin: 0 0 4px;
  text-transform: uppercase;
  letter-spacing: 0;
  font-size: 12px;
  font-weight: 900;
}

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

#refreshBtn {
  width: 42px;
  padding: 0;
  background: var(--ink);
}

.auth-actions {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  white-space: nowrap;
}

.auth-actions .secondary {
  background: #fff;
}

.cart-button {
  position: relative;
  width: 48px;
  padding: 0;
  background: #fff;
  color: var(--ink);
  border: 1px solid var(--line);
}

.cart-button span {
  position: absolute;
  top: -7px;
  right: -4px;
  min-width: 20px;
  min-height: 20px;
  display: grid;
  place-items: center;
  border-radius: 999px;
  background: var(--green);
  color: #fff;
  font-size: 12px;
  font-weight: 900;
}

.metrics,
.admin-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(150px, 1fr));
  gap: 12px;
  margin-bottom: 20px;
}

.metrics:empty {
  display: none;
}

.notice {
  min-height: 0;
  margin-bottom: 14px;
  padding: 0;
  color: var(--muted);
}

.notice:not(:empty) {
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  padding: 12px 14px;
  font-weight: 800;
}

.notice.success {
  border-color: #bbf7d0;
  color: var(--green);
  background: #f0fdf4;
}

.notice.error {
  border-color: #fecaca;
  color: #b91c1c;
  background: #fef2f2;
}

.button-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.divider {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 10px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.divider::before,
.divider::after {
  content: "";
  height: 1px;
  background: var(--line);
}

.google-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
}

.google-btn span {
  width: 24px;
  height: 24px;
  display: inline-grid;
  place-items: center;
  border-radius: 999px;
  background: #fff;
  color: #4285f4;
  font-weight: 900;
}

.google-button-mount {
  min-height: 44px;
  display: grid;
}

.google-button-mount > div {
  width: 100% !important;
}

.business-select-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
  pointer-events: none;
}

.business-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(168px, 1fr));
  gap: 12px;
}

.business-card {
  min-height: 172px;
  display: grid;
  grid-template-rows: auto 1fr;
  justify-items: center;
  align-content: start;
  gap: 10px;
  padding: 14px;
  text-align: center;
  background: #fff;
  color: var(--ink);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.business-card:hover,
.business-card.active {
  border-color: #fb923c;
  background: #fff7ed;
  box-shadow: 0 8px 24px rgba(249, 115, 22, 0.14);
}

.business-logo {
  width: 78px;
  height: 78px;
  display: grid;
  place-items: center;
  overflow: hidden;
  border-radius: 999px;
  background: #ffedd5;
}

.business-logo img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.business-logo-fallback {
  color: #c2410c;
  font-size: 1.65rem;
  font-weight: 900;
}

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

.business-card-copy {
  display: grid;
  gap: 4px;
  min-width: 0;
}

.business-card-copy strong,
.business-card-copy small {
  overflow-wrap: anywhere;
}

.business-card-copy small {
  color: var(--muted);
  line-height: 1.25;
}

.menu-picker,
.cart-box,
.location-box {
  display: grid;
  gap: 10px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8fafc;
}

.location-box small {
  color: var(--muted);
}

.menu-title,
.cart-head,
.cart-line,
.cart-totals {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.menu-title {
  align-items: start;
}

.menu-title small,
.cart-line small {
  display: block;
  color: var(--muted);
  margin-top: 2px;
}

.menu-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 12px;
}

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

.branch-card {
  min-height: 52px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 10px 12px;
  text-align: left;
  background: #fff;
  color: var(--ink);
  border: 1px solid var(--line);
}

.branch-card.active,
.branch-card:hover {
  border-color: #fb923c;
  background: #fff7ed;
}

.branch-card small {
  white-space: nowrap;
}

.menu-item {
  min-height: 86px;
  display: grid;
  align-content: center;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 12px;
  padding: 14px;
  text-align: left;
  background: #fff;
  color: var(--ink);
  border: 1px solid var(--line);
}

.menu-item strong {
  color: var(--ink);
}

.menu-item:hover {
  border-color: #fed7aa;
  background: #fff7ed;
}

.cart-line {
  padding: 10px 0;
  border-top: 1px solid var(--line);
}

.quantity-stepper {
  display: grid;
  grid-template-columns: 34px 28px 34px;
  align-items: center;
  gap: 6px;
  text-align: center;
  font-weight: 900;
}

.quantity-stepper button {
  min-height: 34px;
  padding: 0;
}

.cart-totals {
  flex-wrap: wrap;
  justify-content: flex-start;
  padding-top: 10px;
  border-top: 1px solid var(--line);
  color: var(--muted);
}

.cart-totals strong {
  color: var(--ink);
}

.helper-text {
  margin: -4px 0 12px;
  color: var(--muted);
  line-height: 1.45;
}

.metric,
.panel,
.order-card,
.admin-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: 0 10px 28px rgba(23, 32, 51, 0.05);
}

.metric,
.admin-card {
  padding: 14px;
}

.metric span,
.admin-card span {
  display: block;
  color: var(--muted);
  font-size: 13px;
}

.metric strong,
.admin-card strong {
  display: block;
  margin-top: 6px;
  font-size: 24px;
}

.view {
  display: none;
}

.view.active {
  display: block;
}

.section-title {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 16px;
  margin: 18px 0 12px;
}

.section-title h2 {
  margin: 0;
  font-size: 24px;
}

.section-title p {
  margin: 0;
  max-width: 620px;
}

.category-strip {
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: minmax(104px, 130px);
  gap: 12px;
  overflow-x: auto;
  padding: 6px 2px 18px;
  margin-bottom: 4px;
}

.category-chip {
  min-height: 126px;
  display: grid;
  place-items: center;
  gap: 8px;
  padding: 10px 8px;
  background: #fff;
  color: var(--ink);
  border: 1px solid var(--line);
  box-shadow: 0 8px 20px rgba(23, 32, 51, 0.05);
}

.category-chip:hover,
.category-chip.active {
  border-color: #fed7aa;
  background: #fff7ed;
}

.food-icon {
  width: 78px;
  height: 78px;
  display: block;
  border-radius: 999px;
  background-image: url("./assets/food-icons.png");
  background-repeat: no-repeat;
  background-size: 390px 260px;
}

.icon-pizza { background-position: 0 0; }
.icon-torta { background-position: -78px 0; }
.icon-tacos { background-position: -156px 0; }
.icon-hamburguesa { background-position: -234px 0; }
.icon-hotdog { background-position: -312px 0; }
.icon-malteada { background-position: 0 -130px; }
.icon-soda { background-position: -78px -130px; }
.icon-jugo { background-position: -156px -130px; }

.content-grid {
  display: grid;
  grid-template-columns: minmax(280px, 0.9fr) minmax(360px, 1.1fr);
  gap: 14px;
  align-items: start;
}

.panel {
  padding: 18px;
}

.panel h3 {
  margin: 0 0 14px;
  font-size: 17px;
}

form {
  display: grid;
  gap: 12px;
}

label {
  display: grid;
  gap: 6px;
  font-weight: 700;
  font-size: 13px;
}

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

select + input,
input + select {
  margin-top: 2px;
}

.orders-list,
#driverOrders {
  display: grid;
  gap: 12px;
  margin-top: 14px;
}

.order-card {
  padding: 16px;
  display: grid;
  gap: 10px;
}

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

.order-head h4 {
  margin: 0;
}

.pill {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  padding: 0 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 900;
}

.pill.success {
  color: var(--green);
  background: #ddfbea;
}

.pill.neutral {
  color: var(--blue);
  background: #dbeafe;
}

.pill.warn {
  color: #b45309;
  background: #fef3c7;
}

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

.cost-row span {
  color: var(--muted);
}

.map-board {
  height: 220px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #eef6ff;
  position: relative;
  overflow: hidden;
}

.map-board .leaflet-container,
.map-board.leaflet-container {
  width: 100%;
  height: 100%;
  font: inherit;
}

.driver-card {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 12px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.driver-card img {
  width: 54px;
  height: 54px;
  border-radius: 8px;
  object-fit: cover;
}

.driver-card .vehicle-photo {
  width: 90px;
  height: 56px;
  margin-top: 8px;
}

.price-list {
  display: grid;
  gap: 12px;
  margin-top: 14px;
}

.scanner-video {
  display: none;
  width: 100%;
  aspect-ratio: 4 / 3;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #0f172a;
  object-fit: cover;
}

.scanner-video.active {
  display: block;
}

.check-row {
  display: flex;
  grid-template-columns: auto 1fr;
  align-items: center;
  gap: 10px;
}

.check-row input {
  width: auto;
}

pre {
  max-height: 260px;
  overflow: auto;
  white-space: pre-wrap;
}

.wallet {
  display: grid;
  gap: 10px;
  padding: 16px;
  border-radius: 8px;
  background: #f8fafc;
  border: 1px solid var(--line);
}

.wallet strong {
  font-size: 30px;
}

.document-list {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 12px;
}

.mobile-bottom-nav {
  display: none;
}

@media (max-width: 860px) {
  :root {
    --soft: #ffffff;
  }

  body {
    display: block;
    background: #fff;
    padding-bottom: 82px;
  }

  .sidebar {
    width: min(82vw, 300px);
  }

  .brand-logo {
    margin-left: auto;
  }

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

  .app-shell {
    padding: 14px 14px 92px;
  }

  .topbar {
    display: grid;
    grid-template-columns: 1fr auto;
    align-items: center;
    gap: 10px;
    margin-bottom: 12px;
    padding: 10px 0 12px;
    background: #fff;
    border-bottom: 0;
    box-shadow: none;
  }

  .brand-lockup,
  .menu-button {
    display: none;
  }

  .eyebrow,
  .topbar h1,
  .delivery-mode,
  .auth-actions {
    display: none;
  }

  .address-chip {
    order: 1;
    width: auto;
    max-width: none;
    justify-self: start;
    min-height: 34px;
    padding: 0;
    font-size: 24px;
    font-weight: 900;
    background: transparent;
  }

  .address-chip span {
    font-size: 24px;
  }

  .address-chip strong {
    max-width: 260px;
  }

  .cart-button {
    order: 2;
    justify-self: end;
    width: 46px;
    min-height: 46px;
    border: 0;
    background: #fff3eb;
    color: var(--orange);
    font-size: 24px;
  }

  .top-search {
    order: 3;
    grid-column: 1 / -1;
    width: 100%;
    max-width: none;
    min-height: 58px;
    padding: 0 8px 0 16px;
    border: 0;
    border-radius: 18px;
    background: #f0f1f3;
    font-size: 17px;
  }

  .top-search span {
    font-size: 26px;
    color: #8b929d;
  }

  .top-search button {
    display: inline-grid;
    place-items: center;
    min-height: 46px;
    padding: 0 18px;
    border-radius: 14px;
    background: var(--orange);
  }

  .notice:not(:empty) {
    min-height: auto;
    border-radius: 14px;
  }

  .section-title {
    display: none;
  }

  .metrics,
  .admin-grid,
  .content-grid {
    grid-template-columns: 1fr;
  }

  .category-strip {
    grid-auto-columns: 82px;
    gap: 12px;
    padding: 8px 0 22px;
    margin: 0 -2px;
  }

  .category-chip {
    min-height: 104px;
    padding: 4px 0;
    border: 0;
    box-shadow: none;
    background: transparent;
    font-size: 13px;
    line-height: 1.1;
  }

  .category-chip:hover,
  .category-chip.active {
    background: transparent;
    border-color: transparent;
    color: var(--orange);
  }

  .food-icon {
    width: 62px;
    height: 62px;
    background-size: 310px 207px;
    box-shadow: 0 10px 22px rgba(23, 32, 51, 0.06);
  }

  .icon-pizza { background-position: 0 0; }
  .icon-torta { background-position: -62px 0; }
  .icon-tacos { background-position: -124px 0; }
  .icon-hamburguesa { background-position: -186px 0; }
  .icon-hotdog { background-position: -248px 0; }
  .icon-malteada { background-position: 0 -104px; }
  .icon-soda { background-position: -62px -104px; }
  .icon-jugo { background-position: -124px -104px; }

  #view-client > .content-grid:first-of-type {
    display: flex;
    flex-direction: column;
  }

  #orderForm {
    order: 1;
  }

  #clientAuthForm {
    order: 2;
  }

  #view-client > .content-grid:nth-of-type(2) {
    margin-top: 14px;
  }

  .panel {
    padding: 0;
    border: 0;
    border-radius: 0;
    box-shadow: none;
    background: transparent;
  }

  .panel h3 {
    margin: 0 0 14px;
    font-size: 22px;
  }

  #clientAuthForm,
  #profileForm {
    padding: 16px;
    border: 1px solid var(--line);
    border-radius: 18px;
    background: #fff;
  }

  #orderForm > label:first-of-type {
    display: none;
  }

  #orderForm label:nth-of-type(2) {
    margin-bottom: 8px;
  }

  #businessSearch {
    min-height: 48px;
    border-radius: 14px;
    background: #f6f7f9;
  }

  .business-grid {
    display: grid;
    grid-auto-flow: column;
    grid-auto-columns: minmax(118px, 132px);
    grid-template-columns: none;
    overflow-x: auto;
    gap: 14px;
    padding: 2px 0 18px;
  }

  .business-card {
    min-height: 138px;
    padding: 10px 8px;
    border: 0;
    box-shadow: none;
    background: transparent;
  }

  .business-card:hover,
  .business-card.active {
    background: transparent;
    border-color: transparent;
    box-shadow: none;
    color: var(--orange);
  }

  .business-logo {
    width: 72px;
    height: 72px;
    background: #fff2df;
    box-shadow: 0 12px 24px rgba(23, 32, 51, 0.08);
  }

  .business-card-copy strong {
    font-size: 14px;
    line-height: 1.12;
  }

  .business-card-copy small {
    font-size: 12px;
  }

  .menu-picker,
  .cart-box,
  .location-box {
    border-radius: 18px;
    background: #fff;
  }

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

  .menu-item {
    min-height: 74px;
    border-radius: 16px;
    box-shadow: 0 8px 20px rgba(23, 32, 51, 0.05);
  }

  .menu-item::after {
    content: "+";
    width: 42px;
    height: 42px;
    display: grid;
    place-items: center;
    grid-column: 2;
    grid-row: 1 / span 2;
    border-radius: 999px;
    background: var(--orange);
    color: #fff;
    font-size: 28px;
    font-weight: 900;
  }

  .cart-box {
    margin-top: 12px;
  }

  .cart-head strong {
    font-size: 22px;
  }

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

  .cart-totals strong {
    grid-column: 1 / -1;
    font-size: 20px;
  }

  textarea,
  input,
  select {
    min-height: 46px;
    border-radius: 14px;
  }

  #orderLocationBtn,
  #orderForm > button[type="submit"] {
    min-height: 52px;
    border-radius: 16px;
    font-size: 17px;
  }

  .orders-list {
    margin-top: 16px;
  }

  .order-card {
    border-radius: 18px;
    box-shadow: 0 10px 28px rgba(23, 32, 51, 0.06);
  }

  .mobile-bottom-nav {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 30;
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 2px;
    padding: 8px 10px max(8px, env(safe-area-inset-bottom));
    background: rgba(255, 255, 255, 0.96);
    border-top: 1px solid #eceff3;
    box-shadow: 0 -8px 28px rgba(23, 32, 51, 0.08);
    backdrop-filter: blur(12px);
  }

  .mobile-bottom-nav button {
    min-height: 52px;
    display: grid;
    place-items: center;
    gap: 2px;
    padding: 0;
    border-radius: 14px;
    background: transparent;
    color: var(--ink);
    font-size: 11px;
    font-weight: 800;
  }

  .mobile-bottom-nav button span {
    font-size: 22px;
    line-height: 1;
  }

  .mobile-bottom-nav button.active {
    color: var(--orange);
    background: #fff7ed;
  }
}
