:root {
  --bg: #f3f5f8;
  --surface: #ffffff;
  --text: #111827;
  --muted: #667085;
  --line: #e6eaf0;
  --brand: #1664c0;
  --brand-soft: #e8f1fb;
  --ok: #027a48;
  --ok-soft: #ecfdf3;
  --warn: #b54708;
  --danger: #b42318;
  --radius: 16px;
  --shadow: 0 1px 2px rgba(16, 24, 40, .04), 0 1px 3px rgba(16, 24, 40, .06);
  --tab-h: 64px;
  --safe-b: env(safe-area-inset-bottom, 0px);
}

* { box-sizing: border-box; }
[x-cloak] { display: none !important; }

html, body {
  margin: 0;
  min-height: 100%;
  background: #dce3ec;
  color: var(--text);
  font-family: "Plus Jakarta Sans", system-ui, sans-serif;
  -webkit-font-smoothing: antialiased;
}

a { color: inherit; text-decoration: none; }
button, input, select { font: inherit; }

.app {
  min-height: 100dvh;
  max-width: 430px;
  margin: 0 auto;
  background: var(--bg);
  position: relative;
  box-shadow: 0 0 0 1px rgba(16, 24, 40, .06), 0 20px 50px rgba(16, 24, 40, .08);
}
.app.guest .main { padding-bottom: 32px; }

.app-head {
  position: sticky;
  top: 0;
  z-index: 40;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  min-height: 56px;
  padding: 10px 12px;
  background: rgba(255,255,255,.92);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--line);
}

.icon-btn {
  width: 40px;
  height: 40px;
  border: 0;
  background: #f2f4f7;
  border-radius: 12px;
  color: var(--text);
  display: grid;
  place-items: center;
  padding: 0;
}

.menu-bg {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, .28);
  z-index: 45;
}

.top-menu {
  position: absolute;
  top: 60px;
  left: 12px;
  right: 12px;
  z-index: 50;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 16px;
  box-shadow: 0 16px 40px rgba(16, 24, 40, .14);
  overflow: hidden;
}
.top-menu a {
  display: block;
  padding: 14px 16px;
  font-weight: 650;
  border-top: 1px solid var(--line);
}
.top-menu a:first-child { border-top: 0; }
.top-menu a.danger { color: var(--danger); }

.app-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.logo {
  width: 32px;
  height: 32px;
  border-radius: 9px;
  background: var(--brand);
  color: #fff;
  display: grid;
  place-items: center;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: -.02em;
}

.brand-name {
  font-size: 14px;
  font-weight: 700;
  letter-spacing: -.02em;
}

.brand-name span { color: var(--muted); font-weight: 600; }

.app-user {
  font-size: 12px;
  color: var(--muted);
  max-width: 110px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-weight: 700;
}
a.app-user:active { color: var(--brand); }

.main {
  padding: 16px 16px calc(var(--tab-h) + var(--safe-b) + 20px);
}

.page-kicker {
  margin: 0 0 2px;
  font-size: 12px;
  font-weight: 600;
  color: var(--muted);
}

.page-title {
  margin: 0 0 16px;
  font-size: 24px;
  font-weight: 750;
  letter-spacing: -.03em;
  line-height: 1.2;
}

.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.stack > * + * { margin-top: 12px; }

.pad { padding: 14px; }
.pad-lg { padding: 16px; }

.muted { color: var(--muted); }
.small { font-size: 13px; }
.tiny { font-size: 12px; color: var(--muted); }

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

.stats {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  align-items: stretch;
}

.stats .card {
  margin: 0;
  height: 100%;
}

.stat {
  padding: 14px;
  height: 108px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}

.stat .tiny {
  min-height: 16px;
}

.stat-label, .meta {
  display: flex;
  align-items: center;
  gap: 6px;
}
.meta {
  flex-wrap: wrap;
  margin: 4px 0 0;
  color: var(--muted);
}
.meta-item {
  display: inline-flex;
  align-items: center;
  gap: 4px;
}
.ico {
  flex-shrink: 0;
  display: block;
  color: currentColor;
}

.stat b {
  display: block;
  font-size: 20px;
  line-height: 1.2;
  letter-spacing: -.03em;
  white-space: nowrap;
}

.list { overflow: hidden; }
.list a, .list .item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px;
  border-top: 1px solid var(--line);
}
.list a:first-child, .list .item:first-child { border-top: 0; }

.badge {
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  padding: 3px 8px;
  font-size: 11px;
  font-weight: 700;
  background: var(--brand-soft);
  color: var(--brand);
}
.badge.warn { background: #fff6ed; color: var(--warn); }
.badge.ok { background: var(--ok-soft); color: var(--ok); }
.badge.neutral { background: #f2f4f7; color: var(--muted); }

.field, .input, select, textarea {
  width: 100%;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--text);
  border-radius: 12px;
  padding: 11px 12px;
  outline: none;
}
.field:focus, .input:focus, select:focus {
  border-color: #84b4e8;
  box-shadow: 0 0 0 3px rgba(22, 100, 192, .12);
}

.label {
  display: block;
  margin-bottom: 6px;
  font-size: 13px;
  font-weight: 600;
  color: #344054;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border: 0;
  border-radius: 12px;
  padding: 12px 16px;
  font-weight: 700;
  cursor: pointer;
  background: var(--brand);
  color: #fff;
}
.btn:disabled { opacity: .55; }
.btn-block { width: 100%; }
.btn-ghost {
  background: #fff;
  color: var(--text);
  border: 1px solid var(--line);
}
.btn-soft {
  background: var(--brand-soft);
  color: var(--brand);
}
.btn-danger {
  background: #fff;
  color: var(--danger);
  border: 1px solid #fecdca;
}

.seg {
  display: flex;
  gap: 6px;
  padding: 4px;
  background: #eef1f5;
  border-radius: 12px;
}
.seg a {
  flex: 1;
  text-align: center;
  padding: 8px 6px;
  border-radius: 9px;
  font-size: 13px;
  font-weight: 650;
  color: var(--muted);
}
.seg a.on { background: #fff; color: var(--text); box-shadow: var(--shadow); }

.flash {
  margin-bottom: 12px;
  padding: 12px 14px;
  border-radius: 12px;
  font-size: 13px;
  font-weight: 600;
}
.flash.ok { background: var(--ok-soft); color: var(--ok); }
.flash.error { background: #fef3f2; color: var(--danger); }

.qty {
  display: flex;
  align-items: center;
  gap: 8px;
}
.qty button {
  width: 32px;
  height: 32px;
  border: 1px solid var(--line);
  background: #fff;
  border-radius: 10px;
  font-size: 18px;
  line-height: 1;
}
.qty button.plus { background: var(--brand); color: #fff; border-color: var(--brand); }

.product {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 0;
  border-top: 1px solid var(--line);
}
.product:first-child { border-top: 0; padding-top: 0; }

.pick {
  width: 100%;
  text-align: left;
  border: 0;
  background: transparent;
  padding: 10px 8px;
  border-radius: 10px;
}
.pick.on { background: var(--brand-soft); }

.checkout {
  position: sticky;
  bottom: calc(var(--tab-h) + var(--safe-b) + 8px);
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 14px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 16px;
  box-shadow: 0 10px 30px rgba(16, 24, 40, .12);
}

.tabbar {
  position: fixed;
  left: 50%;
  bottom: 0;
  transform: translateX(-50%);
  width: 100%;
  max-width: 430px;
  z-index: 40;
  display: flex;
  align-items: flex-end;
  justify-content: space-around;
  padding: 6px 6px calc(8px + var(--safe-b));
  background: rgba(255,255,255,.96);
  backdrop-filter: blur(14px);
  border-top: 1px solid var(--line);
}

.tab {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  padding: 6px 2px;
  color: #98a2b3;
  font-size: 10px;
  font-weight: 700;
  background: none;
  border: 0;
}
.tab svg { width: 22px; height: 22px; }
.tab.on { color: var(--brand); }

.tab.sell {
  margin-top: -18px;
}
.tab.sell .sell-ico {
  width: 48px;
  height: 48px;
  border-radius: 16px;
  background: var(--brand);
  color: #fff;
  display: grid;
  place-items: center;
  box-shadow: 0 8px 16px rgba(22, 100, 192, .28);
}
.tab.sell.on .sell-ico,
.tab.sell .sell-ico { color: #fff; }
.tab.sell span { color: var(--brand); }

.sheet-bg {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, .35);
  z-index: 50;
}
.sheet {
  position: fixed;
  left: 50%;
  bottom: 0;
  transform: translateX(-50%);
  width: 100%;
  max-width: 430px;
  z-index: 60;
  background: #fff;
  border-radius: 20px 20px 0 0;
  padding: 10px 16px calc(20px + var(--safe-b));
  box-shadow: 0 -10px 40px rgba(16, 24, 40, .15);
}
.sheet-handle {
  width: 36px;
  height: 4px;
  border-radius: 99px;
  background: #d0d5dd;
  margin: 4px auto 14px;
}
.sheet a, .sheet .sheet-link {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 4px;
  border-top: 1px solid var(--line);
  font-weight: 650;
}
.sheet a:first-of-type { border-top: 0; }

.login-wrap { padding: 36px 20px 32px; }
.login-card { padding: 22px; }
.login-logo { width: 180px; height: auto; display: block; margin: 0 auto 8px; }

.splash {
  position: fixed;
  inset: 0;
  z-index: 200;
  display: grid;
  place-items: center;
  background: #ffffff;
  transition: opacity .45s ease;
}
.splash img {
  width: min(78vw, 300px);
  height: auto;
  animation: splashIn .7s ease;
}
.splash.hide {
  opacity: 0;
  pointer-events: none;
}
@keyframes splashIn {
  from { opacity: 0; transform: scale(.92); }
  to { opacity: 1; transform: scale(1); }
}

.brand-logo {
  width: 36px;
  height: 36px;
  object-fit: contain;
  display: block;
  background: transparent;
}

.actions {
  display: flex;
  gap: 6px;
  margin-top: 10px;
}
.actions form { flex: 1; }
.btn-sm {
  width: 100%;
  padding: 8px 6px;
  font-size: 12px;
  font-weight: 700;
  border-radius: 10px;
}
.paused { opacity: .62; }

.modal-bg {
  position: fixed;
  inset: 0;
  z-index: 80;
  background: rgba(15, 23, 42, .4);
}
.modal {
  position: fixed;
  left: 50%;
  bottom: 0;
  transform: translateX(-50%);
  width: 100%;
  max-width: 430px;
  z-index: 90;
  background: #fff;
  border-radius: 20px 20px 0 0;
  padding: 14px 16px calc(20px + var(--safe-b));
  box-shadow: 0 -12px 40px rgba(16, 24, 40, .18);
}
.modal h3 { margin: 4px 0 14px; font-size: 18px; }

.entrega-card {
  display: flex;
  align-items: flex-start;
  gap: 10px;
}
.entrega-card.on {
  outline: 2px solid var(--brand);
  outline-offset: -1px;
}
.chk {
  width: 24px;
  height: 24px;
  flex: 0 0 24px;
  margin-top: 2px;
  border: 2px solid #d0d5dd;
  border-radius: 8px;
  background: #fff;
  color: transparent;
  display: grid;
  place-items: center;
  padding: 0;
}
.chk.on {
  background: var(--brand);
  border-color: var(--brand);
  color: #fff;
}
.chk:disabled {
  opacity: .35;
}
.route-map {
  height: 260px;
  border-radius: 16px;
  overflow: hidden;
  border: 1px solid var(--line);
  margin-bottom: 12px;
  z-index: 1;
}
.pin {
  background: none;
  border: 0;
}
.pin span {
  display: grid;
  place-items: center;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: var(--brand);
  color: #fff;
  font-size: 12px;
  font-weight: 800;
  box-shadow: 0 4px 10px rgba(22, 100, 192, .35);
}

@media (min-width: 431px) {
  body { padding: 16px 0; }
  .app { min-height: calc(100dvh - 32px); border-radius: 24px; overflow: visible; }
  .tabbar, .sheet { border-radius: 0 0 24px 24px; }
}
