:root {
  color-scheme: light;
  --ink: #152033;
  --muted: #667085;
  --line: #dde5f0;
  --soft: #f5f7fb;
  --surface: #ffffff;
  --brand: #0f7a6c;
  --brand-strong: #09594e;
  --accent: #2563eb;
  --warn: #b45309;
  --danger: #b91c1c;
  --shadow: 0 16px 42px rgba(20, 32, 51, 0.14);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

html {
  width: 100%;
  max-width: 100%;
  overflow-x: hidden;
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

body {
  margin: 0;
  width: 100%;
  max-width: 100%;
  overflow-x: hidden;
  background: var(--soft);
  color: var(--ink);
}

body.modal-open {
  overflow: hidden;
  overscroll-behavior: none;
}

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

button {
  cursor: pointer;
  touch-action: manipulation;
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.58;
}

.app-shell {
  min-height: 100svh;
  padding: 0 0 96px;
}

.loading-state,
.empty-state,
.error-state,
.confirmation {
  display: grid;
  min-height: 100svh;
  place-items: center;
  padding: 28px;
  text-align: center;
}

.brand-mark {
  display: inline-grid;
  width: 48px;
  height: 48px;
  place-items: center;
  border-radius: 8px;
  background: var(--brand);
  color: #fff;
  font-weight: 800;
}

.store-header {
  position: sticky;
  top: 0;
  z-index: 5;
  border-bottom: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.96);
  backdrop-filter: blur(12px);
}

.header-inner,
.content {
  width: min(1120px, 100%);
  margin: 0 auto;
  padding: 14px 14px 0;
}

.header-top {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 12px;
}

.logo {
  width: 48px;
  height: 48px;
  flex: 0 0 auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  object-fit: cover;
  background: #e8eef7;
}

.logo-placeholder {
  display: grid;
  place-items: center;
  background: linear-gradient(135deg, #0f7a6c, #2563eb);
  color: #fff;
  font-weight: 800;
}

.logo-default {
  object-fit: contain;
  padding: 2px;
}

.store-title {
  min-width: 0;
  flex: 1;
}

.store-title h1 {
  margin: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 1.18rem;
  letter-spacing: 0;
}

.status-line {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 4px;
  color: var(--muted);
  font-size: 0.88rem;
}

.status-dot {
  width: 9px;
  height: 9px;
  border-radius: 99px;
  background: var(--brand);
}

.status-dot.off {
  background: var(--warn);
}

.store-status-notice {
  margin-top: 10px;
  border: 1px solid #f3d19c;
  border-radius: 8px;
  background: #fff7ed;
  color: #7c2d12;
  padding: 10px 12px;
  font-size: 0.9rem;
  font-weight: 700;
}

.whatsapp-link,
.ghost-button,
.primary-button,
.danger-button {
  display: inline-flex;
  min-height: 44px;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border-radius: 8px;
  padding: 0 14px;
  border: 1px solid var(--line);
  text-decoration: none;
  font-weight: 700;
}

.whatsapp-link {
  color: var(--brand-strong);
  background: #eaf8f4;
  border-color: #bfe7db;
}

.header-button {
  min-height: 40px;
  padding-inline: 10px;
}

.logout-button {
  color: var(--danger);
}

.primary-button {
  width: 100%;
  border-color: var(--brand);
  background: var(--brand);
  color: #fff;
}

.ghost-button {
  background: #fff;
  color: var(--ink);
}

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

.search-row {
  display: grid;
  grid-template-columns: 1fr;
  gap: 8px;
  padding: 12px 0;
}

.field,
.select,
.textarea {
  width: 100%;
  min-height: 46px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  padding: 10px 12px;
  outline: none;
}

.field:focus,
.select:focus,
.textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.12);
}

.category-strip {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding: 0 0 12px;
  scrollbar-width: thin;
}

.chip {
  min-height: 36px;
  flex: 0 0 auto;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #fff;
  color: var(--ink);
  padding: 0 12px;
  font-weight: 700;
}

.chip.active {
  border-color: var(--brand);
  background: var(--brand);
  color: #fff;
}

.content {
  padding-bottom: 24px;
}

.product-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 10px;
}

.product-card {
  display: grid;
  grid-template-columns: 84px 1fr;
  gap: 12px;
  min-height: 112px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  padding: 10px;
  box-shadow: 0 1px 0 rgba(20, 32, 51, 0.03);
}

.product-image {
  width: 84px;
  height: 84px;
  border-radius: 8px;
  object-fit: cover;
  background: #edf2f7;
}

.product-placeholder {
  display: grid;
  place-items: center;
  color: var(--muted);
  font-size: 0.75rem;
  font-weight: 800;
}

.product-info {
  min-width: 0;
}

.product-name {
  margin: 0;
  font-size: 0.98rem;
  line-height: 1.25;
}

.product-description {
  display: -webkit-box;
  margin: 4px 0 0;
  overflow: hidden;
  color: var(--muted);
  font-size: 0.84rem;
  line-height: 1.25;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
}

.product-bottom {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-top: 10px;
}

.price {
  font-weight: 800;
  color: var(--brand-strong);
}

.qty-control {
  display: inline-grid;
  grid-template-columns: 40px 36px 40px;
  align-items: center;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.qty-control button {
  width: 40px;
  height: 40px;
  border: 0;
  background: #fff;
  color: var(--ink);
  font-size: 1.15rem;
  font-weight: 800;
}

.qty-control span {
  text-align: center;
  font-weight: 800;
}

.add-button {
  min-height: 40px;
  border: 0;
  border-radius: 8px;
  background: var(--accent);
  color: #fff;
  padding: 0 12px;
  font-weight: 800;
}

.unavailable-badge {
  color: var(--warn);
  font-size: 0.82rem;
  font-weight: 800;
}

.floating-cart {
  position: fixed;
  right: 14px;
  bottom: max(14px, env(safe-area-inset-bottom));
  left: 14px;
  z-index: 10;
  display: flex;
  min-height: 58px;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  border: 0;
  border-radius: 8px;
  background: #101828;
  color: #fff;
  box-shadow: var(--shadow);
  padding: 10px 14px;
  font-weight: 800;
}

.floating-cart > span {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.cart-icon {
  width: 21px;
  height: 21px;
  flex: 0 0 auto;
}

.cart-panel {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: grid;
  align-items: end;
  background: rgba(15, 23, 42, 0.42);
  overscroll-behavior: contain;
}

.modal-panel {
  position: fixed;
  inset: 0;
  z-index: 30;
  display: grid;
  align-items: center;
  justify-items: center;
  background: rgba(15, 23, 42, 0.48);
  padding: 16px;
}

.cart-sheet {
  width: 100%;
  max-width: 100vw;
  height: 94svh;
  height: 94dvh;
  max-height: 94svh;
  max-height: 94dvh;
  overflow-x: hidden;
  overflow-y: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
  border-radius: 8px 8px 0 0;
  background: #fff;
  padding: 14px;
  box-shadow: var(--shadow);
}

.modal-card {
  width: min(620px, 100%);
  max-height: min(92svh, 760px);
  overflow-x: hidden;
  overflow-y: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
  border-radius: 8px;
  background: #fff;
  padding: 14px;
  box-shadow: var(--shadow);
}

.sheet-header,
.cart-line,
.summary-line {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.sheet-header {
  position: sticky;
  top: -14px;
  z-index: 1;
  margin: -14px -14px 12px;
  border-bottom: 1px solid var(--line);
  background: #fff;
  padding: 14px;
}

.sheet-header h2 {
  margin: 0;
  font-size: 1.05rem;
}

.cart-items {
  display: grid;
  gap: 8px;
}

.cart-line {
  align-items: flex-start;
  border-bottom: 1px solid var(--line);
  padding: 10px 0;
}

.cart-line strong {
  display: block;
  margin-bottom: 4px;
}

.summary {
  display: grid;
  gap: 8px;
  margin: 14px 0;
  border-top: 1px solid var(--line);
  padding-top: 14px;
}

.summary-line.total {
  font-size: 1.15rem;
  font-weight: 900;
}

.checkout-form {
  display: grid;
  gap: 10px;
}

.checkout-section {
  display: grid;
  gap: 10px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fff;
}

.section-title {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  color: var(--ink);
}

.section-title span {
  display: inline-grid;
  place-items: center;
  width: 28px;
  height: 28px;
  flex: 0 0 28px;
  border-radius: 50%;
  background: #eef4fb;
  color: var(--muted);
  font-weight: 900;
}

.section-title b,
.section-title small {
  display: block;
}

.section-title small {
  margin-top: 2px;
  color: var(--muted);
  font-size: .86rem;
  line-height: 1.25;
}

.payment-section {
  border-color: #10b981;
  background: linear-gradient(180deg, #ecfdf5 0%, #ffffff 100%);
  box-shadow: inset 0 0 0 1px rgba(16, 185, 129, .16);
}

.payment-title span {
  background: #0f766e;
  color: #fff;
}

.payment-select {
  min-height: 50px;
  border-color: #10b981;
  font-weight: 900;
}

.segment {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.segment button {
  min-height: 44px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  font-weight: 800;
}

.segment button.active {
  border-color: var(--brand);
  background: #eaf8f4;
  color: var(--brand-strong);
}

.customer-mode {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin: 10px 0 12px;
}

.customer-mode button {
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
  font-weight: 800;
}

.customer-mode button.active {
  border-color: var(--brand);
  background: #eaf8f4;
  color: var(--brand-strong);
}

.customer-mode.single button {
  min-height: 46px;
}

.logged-customer-card,
.delivery-confirm-box {
  display: grid;
  gap: 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8fafc;
  padding: 10px;
}

.logged-customer-card {
  grid-template-columns: 1fr auto;
  align-items: center;
}

.logged-customer-card b,
.logged-customer-card small {
  display: block;
}

.logged-customer-card small {
  color: var(--muted);
  line-height: 1.35;
}

.delivery-confirm-box {
  background: #fff7ed;
  border-color: #fed7aa;
}

.delivery-confirm-box.confirmed {
  background: #ecfdf5;
  border-color: #86efac;
}

.delivery-confirm-box p {
  margin: 0;
  color: var(--muted);
  line-height: 1.35;
}

.address-grid {
  display: grid;
  gap: 8px;
}

.register-grid {
  display: grid;
  gap: 8px;
}

.address-title {
  margin-top: 6px;
  border-top: 1px solid var(--line);
  padding-top: 12px;
  color: var(--ink);
  font-weight: 800;
}

.field.auto-filled {
  background: #eef7ff;
  color: #19324d;
}

.cep-status {
  border-radius: 8px;
  padding: 9px 10px;
  background: #eef7ff;
  color: #1d4ed8;
  font-size: 0.84rem;
  font-weight: 700;
}

.cep-status.loading {
  background: #f0f9ff;
  color: #0369a1;
}

.cep-status.done {
  background: #ecfdf3;
  color: #047857;
}

.cep-status.error {
  background: #fff7ed;
  color: #9a3412;
}

.register-grid label {
  display: grid;
  gap: 4px;
}

.register-grid label span {
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 700;
}

.identity-hint {
  margin: 0;
  border: 1px solid #c7d7fe;
  border-radius: 8px;
  background: #eef4ff;
  color: #1d4ed8;
  padding: 9px 10px;
  font-size: 0.84rem;
  font-weight: 700;
}

.full-button {
  width: 100%;
}

.small-text {
  font-size: 0.82rem;
}

.order-list {
  display: grid;
  gap: 10px;
  margin-top: 12px;
}

.order-filter-row {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding: 10px 0 0;
  scroll-snap-type: x proximity;
  overscroll-behavior-inline: contain;
}

.order-filter-row > * {
  flex: 0 0 auto;
  scroll-snap-align: start;
}

.lookup-row {
  display: grid;
  grid-template-columns: 1fr;
  gap: 8px;
}

.order-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  padding: 12px;
  min-width: 0;
  overflow-wrap: anywhere;
}

.order-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.status-pill {
  border-radius: 999px;
  background: #eaf8f4;
  color: var(--brand-strong);
  padding: 5px 9px;
  font-size: 0.82rem;
  font-weight: 800;
}

.compact {
  min-height: 180px;
}

.textarea {
  min-height: 86px;
  resize: vertical;
}

.notice {
  border: 1px solid #f3d19c;
  border-radius: 8px;
  background: #fff7ed;
  color: #7c2d12;
  padding: 10px 12px;
  font-size: 0.9rem;
}

.pickup-address {
  border: 1px solid #bfe7db;
  border-radius: 8px;
  background: #eaf8f4;
  color: var(--brand-strong);
  padding: 10px 12px;
  font-size: 0.9rem;
}

.cash-change-grid {
  display: grid;
  gap: 8px;
}

.installments-box {
  display: grid;
  gap: 6px;
}

.installments-box label {
  display: grid;
  gap: 6px;
}

.installments-box span {
  color: var(--brand-strong);
  font-size: 0.86rem;
  font-weight: 900;
}

.checkbox-row {
  display: flex;
  min-height: 44px;
  align-items: center;
  gap: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  padding: 0 12px;
  font-weight: 800;
}

.checkbox-row input {
  width: 18px;
  height: 18px;
}

.confirmation-card {
  width: min(520px, 100%);
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  padding: 18px;
  box-shadow: var(--shadow);
}

.confirmation-card h1 {
  margin: 8px 0 4px;
  font-size: 1.5rem;
}

.action-row {
  display: grid;
  gap: 8px;
  margin-top: 14px;
}

.muted {
  color: var(--muted);
}

.hide {
  display: none !important;
}

@media (max-width: 420px) {
  .modal-panel {
    align-items: stretch;
    padding: 0;
  }

  .cart-sheet,
  .modal-card {
    height: 100svh;
    height: 100dvh;
    max-height: 100svh;
    max-height: 100dvh;
    border-radius: 0;
    padding-bottom: max(14px, env(safe-area-inset-bottom));
  }

  .logged-customer-card {
    grid-template-columns: 1fr;
  }

  .modal-card {
    height: auto;
  }
}

@media (min-width: 640px) {
  .header-inner,
  .content {
    padding-inline: 20px;
  }

  .search-row {
    grid-template-columns: 1fr 220px;
  }

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

  .lookup-row {
    grid-template-columns: 1fr 1fr auto;
  }

  .cart-sheet {
    width: min(560px, calc(100% - 28px));
    margin: 0 auto;
    border-radius: 8px 8px 0 0;
  }

  .modal-card {
    width: min(620px, calc(100% - 28px));
    margin: 0 auto;
    border-radius: 8px;
  }
}

@media (min-width: 900px) {
  .app-shell {
    padding-bottom: 28px;
  }

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

  .floating-cart {
    right: 28px;
    left: auto;
    width: min(420px, calc(100% - 56px));
  }

}
