/* ===== ATremix - Modern Mobile-First Design ===== */
:root {
  --bg: #0f172a;
  --bg-card: #1e293b;
  --bg-elevated: #334155;
  --bg-hover: #475569;
  --text: #f1f5f9;
  --text-muted: #94a3b8;
  --primary: #3b82f6;
  --primary-hover: #2563eb;
  --success: #10b981;
  --warning: #f59e0b;
  --danger: #ef4444;
  --border: #334155;
  --radius: 12px;
  --radius-sm: 8px;
  --shadow: 0 4px 20px rgba(0,0,0,0.35);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --topbar-h: 56px;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
}

html, body {
  height: 100%;
  height: 100dvh;
  font-family: 'Inter', system-ui, -apple-system, sans-serif;
  background: var(--bg);
  color: var(--text);
  overflow: hidden;
  font-size: 15px;
  line-height: 1.45;
}

/* ===== Splash ===== */
.splash {
  position: fixed;
  inset: 0;
  background: var(--bg);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 9999;
}
.splash-content { text-align: center; }
.logo-big {
  font-size: 2.4rem;
  font-weight: 800;
  letter-spacing: -1px;
  margin-bottom: 2rem;
}
.logo-big span, .logo span, .logo-sm span { color: var(--primary); }
.splash-loader {
  width: 40px;
  height: 40px;
  border: 3px solid var(--border);
  border-top-color: var(--primary);
  border-radius: 50%;
  margin: 0 auto 1rem;
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.splash-status { color: var(--text-muted); font-size: 0.9rem; }

/* ===== Utilities ===== */
.hidden { display: none !important; }

/* App shell: força altura e scroll só no conteúdo */
#app {
  display: flex;
  flex-direction: column;
  height: 100%;
  height: 100dvh;
  overflow: hidden;
  position: relative;
}
#app:not(.hidden) {
  display: flex;
}

.screen { min-height: 100%; }

/* ===== Login ===== */
#login-screen {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100%;
  padding: 1.5rem;
  background: linear-gradient(160deg, #0f172a 0%, #1e293b 50%, #0f172a 100%);
}
.login-card {
  width: 100%;
  max-width: 380px;
  background: var(--bg-card);
  border-radius: 20px;
  padding: 2rem 1.5rem;
  box-shadow: var(--shadow);
  border: 1px solid var(--border);
}
.logo {
  font-size: 1.8rem;
  font-weight: 800;
  text-align: center;
  margin-bottom: 0.25rem;
}
.login-subtitle {
  text-align: center;
  color: var(--text-muted);
  margin-bottom: 1.75rem;
  font-size: 0.9rem;
}
.form-group {
  margin-bottom: 1rem;
}
.form-group label {
  display: block;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-muted);
  margin-bottom: 0.35rem;
  text-transform: uppercase;
  letter-spacing: 0.4px;
}
.form-group input,
input[type="text"],
input[type="password"],
input[type="number"],
input[type="date"],
input[type="time"],
select,
textarea {
  width: 100%;
  padding: 0.75rem 1rem;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-size: 1rem;
  outline: none;
  transition: border-color 0.2s;
}
input:focus, select:focus, textarea:focus {
  border-color: var(--primary);
}
.error-msg {
  background: rgba(239,68,68,0.15);
  color: var(--danger);
  padding: 0.75rem;
  border-radius: var(--radius-sm);
  margin-top: 1rem;
  font-size: 0.9rem;
  text-align: center;
}
.demo-accounts {
  margin-top: 1.5rem;
  padding-top: 1.25rem;
  border-top: 1px solid var(--border);
  text-align: center;
}
.demo-accounts p {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-bottom: 0.6rem;
}
.btn-demo {
  display: block;
  width: 100%;
  background: transparent;
  border: 1px dashed var(--border);
  color: var(--text-muted);
  padding: 0.5rem;
  border-radius: var(--radius-sm);
  margin-bottom: 0.4rem;
  font-size: 0.8rem;
  cursor: pointer;
}
.btn-demo:active { background: var(--bg-elevated); }
.sync-status-bar {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  margin-top: 1.25rem;
  font-size: 0.8rem;
  color: var(--text-muted);
}
.dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--warning);
}
.dot.online { background: var(--success); }
.dot.offline { background: var(--text-muted); }

/* ===== Buttons ===== */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  padding: 0.7rem 1.2rem;
  border: none;
  border-radius: var(--radius-sm);
  font-weight: 600;
  font-size: 0.95rem;
  cursor: pointer;
  transition: all 0.15s;
  font-family: inherit;
}
.btn-primary {
  background: var(--primary);
  color: white;
}
.btn-primary:active { background: var(--primary-hover); }
.btn-outline {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text);
}
.btn-outline:active { background: var(--bg-elevated); }
.btn-ghost {
  background: transparent;
  color: var(--text-muted);
}
.btn-danger {
  background: var(--danger);
  color: white;
}
.btn-success {
  background: var(--success);
  color: white;
}
.btn-block { width: 100%; }
.btn-sm { padding: 0.45rem 0.85rem; font-size: 0.85rem; }
.btn:disabled { opacity: 0.5; pointer-events: none; }
.icon-btn {
  background: transparent;
  border: none;
  color: var(--text);
  width: 40px;
  height: 40px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}
.icon-btn:active { background: var(--bg-elevated); }

/* ===== Topbar ===== */
.topbar {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: var(--topbar-h);
  background: var(--bg-card);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 0.5rem 0 0.25rem;
  z-index: 100;
}
.topbar-left, .topbar-right {
  display: flex;
  align-items: center;
  gap: 0.25rem;
}
.store-info {
  display: flex;
  flex-direction: column;
  line-height: 1.2;
}
.store-info span {
  font-weight: 600;
  font-size: 0.95rem;
}
.store-info small {
  color: var(--text-muted);
  font-size: 0.75rem;
}
.sync-indicator {
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
}
.sync-indicator.online { color: var(--success); }
.sync-indicator.offline { color: var(--text-muted); }
.sync-indicator.syncing { color: var(--primary); animation: pulse 1s infinite; }
@keyframes pulse { 50% { opacity: 0.5; } }

/* ===== Sidebar ===== */
.sidebar {
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  width: 280px;
  max-width: 85vw;
  background: var(--bg-card);
  z-index: 200;
  transform: translateX(-100%);
  transition: transform 0.25s ease;
  display: flex;
  flex-direction: column;
  border-right: 1px solid var(--border);
}
.sidebar.open { transform: translateX(0); }
.sidebar-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.55);
  z-index: 150;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s;
}
.sidebar-overlay.open {
  opacity: 1;
  pointer-events: auto;
}
.sidebar-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1rem;
  border-bottom: 1px solid var(--border);
}
.logo-sm { font-size: 1.3rem; font-weight: 800; }
.sidebar-nav {
  flex: 1;
  overflow-y: auto;
  padding: 0.75rem 0;
}
.nav-item {
  display: flex;
  align-items: center;
  gap: 0.85rem;
  padding: 0.85rem 1.25rem;
  color: var(--text-muted);
  text-decoration: none;
  font-weight: 500;
  transition: all 0.15s;
}
.nav-item .material-icons-round { font-size: 1.35rem; }
.nav-item:active, .nav-item.active {
  background: rgba(59,130,246,0.12);
  color: var(--primary);
}
.sidebar-footer {
  padding: 1rem;
  border-top: 1px solid var(--border);
}
.sync-info {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  font-size: 0.8rem;
  color: var(--text-muted);
}

/* ===== Main Content ===== */
#main-content {
  flex: 1 1 auto;
  min-height: 0;
  margin-top: var(--topbar-h);
  overflow-y: scroll;
  overflow-x: hidden;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior-y: contain;
  touch-action: pan-y;
  padding-bottom: calc(6rem + var(--safe-bottom));
}
.page {
  display: none;
  padding: 1rem;
  padding-bottom: 3rem;
}
.page.active {
  display: block;
}
.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1rem;
}
.page-header h1 {
  font-size: 1.35rem;
  font-weight: 700;
}

/* ===== PDV Layout ===== */
.pdv-layout {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  height: calc(100vh - var(--topbar-h) - 1.5rem);
}
.pdv-left {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 0;
}
.pdv-right {
  background: var(--bg-card);
  border-radius: var(--radius);
  border: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  max-height: 48%;
  min-height: 220px;
}
.search-bar {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.35rem 0.75rem;
  margin-bottom: 0.75rem;
}
.search-bar input {
  flex: 1;
  border: none;
  background: transparent;
  padding: 0.5rem 0;
  font-size: 1rem;
}
.search-bar .material-icons-round { color: var(--text-muted); }
.product-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.55rem;
  overflow-y: auto;
  flex: 1;
  padding-bottom: 0.5rem;
  align-content: start;
}
@media (min-width: 480px) {
  .product-grid { grid-template-columns: repeat(auto-fill, minmax(148px, 1fr)); }
}
.product-card {
  /* estilos principais vêm inline no JS — aqui só reforço */
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}
.product-card:active { transform: scale(0.98); }

/* Cart */
.cart-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.75rem 1rem;
  border-bottom: 1px solid var(--border);
}
.cart-header h2 { font-size: 1rem; font-weight: 700; }
.cart-items {
  flex: 1;
  overflow-y: auto;
  padding: 0.5rem;
}
.empty-cart {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 100%;
  color: var(--text-muted);
  gap: 0.35rem;
}
.empty-cart .material-icons-round { font-size: 2.5rem; opacity: 0.4; }
.cart-item {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.6rem;
  border-radius: var(--radius-sm);
  background: var(--bg);
  margin-bottom: 0.4rem;
}
.cart-item .info { flex: 1; min-width: 0; }
.cart-item .name {
  font-weight: 600;
  font-size: 0.9rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.cart-item .unit-price {
  font-size: 0.8rem;
  color: var(--text-muted);
}
.cart-item .qty-controls {
  display: flex;
  align-items: center;
  gap: 0.35rem;
}
.cart-item .qty-btn {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  border: 1px solid var(--border);
  background: var(--bg-elevated);
  color: var(--text);
  font-size: 1rem;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}
.cart-item .qty {
  min-width: 24px;
  text-align: center;
  font-weight: 600;
}
.cart-item .subtotal {
  font-weight: 700;
  color: var(--success);
  min-width: 70px;
  text-align: right;
}
.cart-footer {
  border-top: 1px solid var(--border);
  padding: 0.75rem;
}
.cart-total {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.75rem;
  font-size: 1.1rem;
}
.cart-total strong {
  font-size: 1.4rem;
  color: var(--success);
}
.payment-methods {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 0.4rem;
}
.pay-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.2rem;
  padding: 0.6rem 0.25rem;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-size: 0.7rem;
  font-weight: 600;
  cursor: pointer;
}
.pay-btn .material-icons-round { font-size: 1.3rem; }
.pay-btn:active {
  background: var(--primary);
  border-color: var(--primary);
  color: white;
}

/* ===== Cards & Lists ===== */
.list-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: visible;
  margin-bottom: 1.5rem;
}
.list-item {
  display: flex;
  align-items: flex-start;
  gap: 0.75rem;
  padding: 0.9rem 1rem;
  border-bottom: 1px solid var(--border);
}
.list-item:last-child { border-bottom: none; }
.list-item .info { flex: 1; min-width: 0; }
.list-item .title {
  font-weight: 600;
  white-space: normal;
  word-break: break-word;
}
.list-item .actions {
  flex-shrink: 0;
  align-self: center;
}
.list-item .subtitle {
  font-size: 0.8rem;
  color: var(--text-muted);
}
.list-item .value {
  font-weight: 700;
  color: var(--success);
  white-space: nowrap;
}
.list-item .actions {
  display: flex;
  gap: 0.25rem;
}
.section-title {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin: 1.25rem 0 0.6rem;
}

/* ===== Caixa ===== */
.caixa-status-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem;
  text-align: center;
}
.caixa-status-card.open { border-color: var(--success); }
.caixa-status-card.closed { border-color: var(--text-muted); }
.caixa-status-card .status-label {
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-bottom: 0.35rem;
}
.caixa-status-card .status-value {
  font-size: 1.5rem;
  font-weight: 800;
}
.caixa-status-card.open .status-value { color: var(--success); }
.caixa-status-card .meta {
  margin-top: 0.75rem;
  font-size: 0.85rem;
  color: var(--text-muted);
}
.caixa-actions {
  display: flex;
  gap: 0.6rem;
  margin-top: 1rem;
}
.caixa-actions .btn { flex: 1; }

/* ===== Reports ===== */
.filters-row {
  display: flex;
  gap: 0.5rem;
  margin-bottom: 1rem;
  flex-wrap: wrap;
}
.filters-row input[type="date"] { flex: 1; min-width: 120px; }
.report-cards {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 0.6rem;
  margin-bottom: 1rem;
}
.report-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem;
  text-align: center;
}
.report-card .label {
  font-size: 0.75rem;
  color: var(--text-muted);
  text-transform: uppercase;
  margin-bottom: 0.25rem;
}
.report-card .value {
  font-size: 1.25rem;
  font-weight: 800;
}
.report-actions {
  display: flex;
  gap: 0.6rem;
  margin-top: 1rem;
}
.report-actions .btn { flex: 1; }

/* ===== Admin ===== */
.admin-tabs {
  display: flex;
  gap: 0.35rem;
  margin-bottom: 1rem;
  overflow-x: auto;
}
.admin-tabs .tab {
  padding: 0.55rem 1rem;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 999px;
  color: var(--text-muted);
  font-weight: 600;
  font-size: 0.85rem;
  white-space: nowrap;
  cursor: pointer;
}
.admin-tabs .tab.active {
  background: var(--primary);
  border-color: var(--primary);
  color: white;
}
.admin-panel { margin-top: 0.5rem; }
.hint {
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-bottom: 0.85rem;
}

/* ===== Config ===== */
.config-list {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}
.config-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1rem;
  border-bottom: 1px solid var(--border);
}
.config-item:last-child { border-bottom: none; }
.config-item.version {
  justify-content: center;
  color: var(--text-muted);
  font-size: 0.8rem;
}

/* Switch */
.switch {
  position: relative;
  width: 48px;
  height: 28px;
}
.switch input { opacity: 0; width: 0; height: 0; }
.slider {
  position: absolute;
  inset: 0;
  background: var(--bg-elevated);
  border-radius: 28px;
  cursor: pointer;
  transition: 0.2s;
}
.slider:before {
  content: "";
  position: absolute;
  width: 22px;
  height: 22px;
  left: 3px;
  bottom: 3px;
  background: white;
  border-radius: 50%;
  transition: 0.2s;
}
.switch input:checked + .slider { background: var(--primary); }
.switch input:checked + .slider:before { transform: translateX(20px); }

/* ===== Modal ===== */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.65);
  z-index: 3000;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  padding: 0;
  overflow-x: hidden;
}
.modal {
  background: var(--bg-card);
  width: 100%;
  max-width: 520px;
  max-height: 92vh;
  max-height: 92dvh;
  border-radius: 20px 20px 0 0;
  display: flex;
  flex-direction: column;
  animation: slideUp 0.25s ease;
  box-sizing: border-box;
  overflow: hidden;
  margin: 0 auto;
}
@keyframes slideUp {
  from { transform: translateY(100%); }
  to { transform: translateY(0); }
}
.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  padding: 1rem 1rem;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.modal-header h3 {
  font-size: 1.05rem;
  font-weight: 700;
  line-height: 1.3;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  flex: 1;
  min-width: 0;
}
.modal-body {
  padding: 1rem;
  overflow-y: auto;
  overflow-x: hidden;
  flex: 1;
  min-height: 0;
  -webkit-overflow-scrolling: touch;
}
.modal-footer {
  padding: 0.75rem 1rem;
  border-top: 1px solid var(--border);
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  padding-bottom: calc(0.75rem + var(--safe-bottom));
  flex-shrink: 0;
}
.modal-footer .btn {
  flex: 1 1 auto;
  min-width: calc(50% - 0.5rem);
  white-space: normal;
  line-height: 1.25;
  padding: 0.7rem 0.5rem;
  font-size: 0.88rem;
}
.modal-footer.footer-stack .btn,
.modal-footer.footer-many .btn {
  flex: 1 1 100%;
  min-width: 100%;
  width: 100%;
}

/* Opções empilhadas (fechamento de caixa etc.) */
.close-opt-list { display: flex; flex-direction: column; gap: 0.55rem; }
.close-opt {
  display: block;
  width: 100%;
  text-align: left;
  padding: 0.85rem 1rem;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: var(--bg-elevated, #334155);
  color: var(--text);
  cursor: pointer;
  font: inherit;
}
.close-opt:active { opacity: 0.9; transform: scale(0.99); }
.close-opt strong { display: block; font-size: 0.95rem; margin-bottom: 0.25rem; }
.close-opt span { display: block; font-size: 0.8rem; color: var(--text-muted); line-height: 1.35; }
.close-opt.primary {
  border-color: var(--primary);
  background: rgba(59, 130, 246, 0.18);
}
.close-opt.primary strong { color: #93c5fd; }

/* ===== Toast ===== */
.toast {
  position: fixed;
  bottom: calc(1.5rem + var(--safe-bottom));
  left: 50%;
  transform: translateX(-50%);
  background: var(--bg-elevated);
  color: var(--text);
  padding: 0.85rem 1.5rem;
  border-radius: 999px;
  font-weight: 600;
  font-size: 0.9rem;
  z-index: 500;
  box-shadow: var(--shadow);
  animation: fadeIn 0.25s;
  max-width: 90%;
  text-align: center;
}
.toast.success { background: var(--success); color: #fff; }
.toast.error { background: var(--danger); color: #fff; }
@keyframes fadeIn {
  from { opacity: 0; transform: translateX(-50%) translateY(10px); }
  to { opacity: 1; transform: translateX(-50%) translateY(0); }
}

/* ===== Receipt ===== */
.receipt-template {
  display: none;
  width: 280px;
  padding: 1rem;
  background: white;
  color: #000;
  font-family: 'Courier New', monospace;
  font-size: 12px;
}
.receipt-template.printing {
  display: block !important;
}
.receipt-preview {
  background: #fff;
  color: #111;
  border-radius: 12px;
  padding: 1rem;
  max-height: 60vh;
  overflow-y: auto;
}
.rcpt { font-family: 'Courier New', monospace; font-size: 13px; line-height: 1.4; color: #111; }
.rcpt-center { text-align: center; }
.rcpt-store { font-weight: 800; font-size: 16px; margin-bottom: 2px; }
.rcpt-title { font-weight: 700; font-size: 13px; letter-spacing: 0.5px; }
.rcpt-muted { color: #444; font-size: 11px; }
.rcpt-sep { border-top: 1px dashed #999; margin: 8px 0; }
.rcpt-item { margin-bottom: 8px; }
.rcpt-item-name { font-weight: 700; }
.rcpt-item-line { font-size: 12px; }
.rcpt-item-desc { font-size: 11px; color: #c62828; }
.rcpt-row { display: flex; justify-content: space-between; gap: 0.5rem; margin: 2px 0; }
.rcpt-discount { color: #c62828; }
.rcpt-total { font-weight: 800; font-size: 15px; margin-top: 4px; }

@media print {
  body * { visibility: hidden !important; }
  #receipt-template,
  #receipt-template * {
    visibility: visible !important;
  }
  #receipt-template {
    display: block !important;
    position: absolute !important;
    left: 0 !important;
    top: 0 !important;
    width: 80mm !important;
    background: #fff !important;
    color: #000 !important;
    z-index: 99999 !important;
  }
  .modal-overlay, .toast, .topbar, #sidebar, #main-content { display: none !important; }
}

/* ===== Responsive - Tablet+ ===== */
@media (min-width: 768px) {
  .pdv-layout {
    flex-direction: row;
    height: calc(100vh - var(--topbar-h) - 2rem);
  }
  .pdv-left { flex: 1.4; }
  .pdv-right {
    flex: 1;
    max-height: none;
    min-height: auto;
  }
  .modal {
    border-radius: 16px;
    margin: auto;
    max-height: 85vh;
  }
  .modal-overlay {
    align-items: center;
    padding: 1rem;
  }
  .product-grid {
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    align-items: start;
  }
}

/* Admin-only visibility controlled by JS */
.admin-only { display: none; }
body.role-admin .admin-only { display: flex; }
body.role-admin .admin-only.btn,
body.role-admin .admin-only.btn-sm { display: inline-flex; }
body.role-admin a.admin-only { display: flex; }

.admin-only-block { display: none !important; }
body.role-admin .admin-only-block { display: flex !important; }

.store-chip {
  display: inline-block;
  font-size: 0.7rem;
  padding: 0.15rem 0.45rem;
  border-radius: 999px;
  background: var(--bg-elevated);
  color: var(--text-muted);
  margin: 0.1rem 0.15rem 0 0;
}
.store-chip.on { background: rgba(16,185,129,0.2); color: var(--success); }
.store-chip.off { opacity: 0.5; }

.check-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.4rem 0;
  font-size: 0.9rem;
}
.check-row input { width: auto; }


/* Produtos / listas longas: garantir scroll completo */
#page-produtos .list-card,
#page-relatorios .list-card,
#page-admin .list-card,
#page-lojas .list-card,
#page-caixa .list-card {
  overflow: visible;
  margin-bottom: 3rem;
}
#page-produtos {
  padding-bottom: 4rem;
}


/* Cargos: botões admin-only só para admin */
body:not(.role-admin) .admin-only { display: none !important; }
body.role-admin .admin-only { display: flex; }


/* Teclado mobile — todos os modais */
.modal-overlay.modal-keyboard {
  /* evita cortar título no mobile */
  align-items: flex-start !important;
  justify-content: center;
  padding: 0.35rem 0.5rem 40vh 0.5rem;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}
.modal-overlay.modal-keyboard .modal {
  max-height: none;
  border-radius: 16px;
  margin: 0 auto;
  width: 100%;
  max-width: 480px;
}
.modal-overlay.modal-keyboard .modal-body {
  max-height: none;
  overflow: visible;
}
.modal-overlay.modal-keyboard input,
.modal-overlay.modal-keyboard select,
.modal-overlay.modal-keyboard textarea {
  font-size: 16px !important; /* evita zoom iOS */
}
.money-modal-body { padding-bottom: 0.25rem; }
.money-total-display {
  font-size: 1.5rem;
  font-weight: 800;
  color: var(--success);
  padding: 0.5rem 0;
}
.money-input-lg {
  font-size: 1.6rem !important;
  font-weight: 700 !important;
  text-align: center;
  letter-spacing: 0.5px;
  padding: 0.85rem 1rem !important;
}
.money-quick-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  margin: 0.5rem 0 0.75rem;
}
.money-quick-row .btn { flex: 1 1 auto; min-width: 4.5rem; }
.money-change-display {
  font-size: 1.35rem;
  font-weight: 700;
  color: var(--text-muted);
  padding: 0.5rem 0;
}
.money-change-display.has-change {
  color: var(--warning, #f59e0b);
}

/* Painel / períodos */
.period-btn.active, .report-period.active {
  background: var(--primary);
  color: #fff;
  border-color: var(--primary);
}
#painel-stores .list-item {
  border-bottom: 1px solid var(--border);
  padding: 0.85rem 0.5rem;
}

/* Scanner de código de barras — câmera / USB / remota */
#scan-overlay {
  position: fixed;
  inset: 0;
  z-index: 10000;
  display: flex;
  align-items: flex-end;
  justify-content: center;
}
.scan-overlay-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0,0,0,0.72);
}
.scan-overlay-panel {
  position: relative;
  width: 100%;
  max-width: 480px;
  max-height: 92vh;
  overflow-y: auto;
  background: var(--bg-card, #1a1d24);
  border-radius: 16px 16px 0 0;
  padding: 1rem 1rem 1.25rem;
  box-shadow: 0 -8px 32px rgba(0,0,0,0.4);
}
.scan-overlay-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 0.75rem;
}
.scan-overlay-header h3 {
  margin: 0;
  font-size: 1.05rem;
  font-weight: 700;
}
.scan-video-wrap {
  position: relative;
  border-radius: 12px;
  overflow: hidden;
  background: #000;
  aspect-ratio: 4/3;
}
.scan-video-wrap video {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
.scan-frame {
  pointer-events: none;
  position: absolute;
  left: 12%;
  right: 12%;
  top: 28%;
  bottom: 28%;
  border: 2px solid rgba(0, 200, 120, 0.85);
  border-radius: 8px;
  box-shadow: 0 0 0 9999px rgba(0,0,0,0.35);
}
.scan-status {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  margin: 0;
  padding: 0.45rem 0.6rem;
  background: rgba(0,0,0,0.65);
  color: #fff;
  font-size: 0.85rem;
  text-align: center;
}
.scan-overlay-actions {
  display: flex;
  gap: 0.5rem;
  margin-top: 0.85rem;
}
.scan-overlay-actions .btn { flex: 1; }
#scan-camera-select {
  width: 100%;
  padding: 0.65rem 0.75rem;
  border-radius: 10px;
  border: 1px solid var(--border, #333);
  background: var(--bg-input, #12151a);
  color: var(--text, #eee);
  font-size: 1rem;
}

.pdv-customer-bar {
  padding: 0.65rem 0.75rem;
  background: var(--bg-card, #1a1d24);
  border-bottom: 1px solid var(--border, #333);
}
.pdv-customer-bar label { display: block; margin-bottom: 0.25rem; color: var(--text-muted); }


/* ===== Área do Cliente ===== */
#customer-portal {
  min-height: 100dvh;
  background: var(--bg, #0f1115);
  color: var(--text, #e8eaed);
}
#customer-portal .topbar {
  position: sticky;
  top: 0;
  z-index: 20;
}
.cust-main {
  padding: 1rem 1rem 3rem;
  max-width: 520px;
  margin: 0 auto;
}
.cust-dash { animation: fadeIn 0.25s ease; }
.cust-summary-cards {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.65rem;
  margin-bottom: 1.25rem;
}
.cust-summary-card {
  background: var(--bg-card, #1a1d24);
  border: 1px solid var(--border, #2a2f3a);
  border-radius: 14px;
  padding: 0.9rem 0.75rem;
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
  min-height: 88px;
}
.cust-summary-ok { border-color: rgba(46, 204, 113, 0.35); }
.cust-summary-wait { border-color: rgba(241, 196, 15, 0.25); }
.cust-summary-label {
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-muted, #9aa0a6);
  font-weight: 600;
}
.cust-summary-value {
  font-size: 1.35rem;
  font-weight: 800;
  line-height: 1.2;
}
.cust-summary-ok .cust-summary-value { color: #2ecc71; }
.cust-summary-hint {
  font-size: 0.7rem;
  color: var(--text-muted, #9aa0a6);
}
.cust-section-title {
  margin: 0.5rem 0 0.55rem;
  font-size: 1rem;
  font-weight: 700;
}
.cust-list {
  display: flex;
  flex-direction: column;
  gap: 0.55rem;
  margin-bottom: 1.25rem;
}
.cust-cb-item, .cust-sale-item {
  background: var(--bg-card, #1a1d24);
  border: 1px solid var(--border, #2a2f3a);
  border-radius: 12px;
  padding: 0.85rem 0.9rem;
}
.cust-cb-top, .cust-sale-top {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 0.5rem;
  margin-bottom: 0.35rem;
}
.cust-cb-amount {
  font-weight: 800;
  font-size: 1.05rem;
  margin-right: 0.4rem;
}
.cust-cb-saldo, .cust-sale-total {
  font-weight: 700;
  color: #2ecc71;
  white-space: nowrap;
  font-size: 0.9rem;
}
.cust-cb-meta {
  font-size: 0.78rem;
  color: var(--text-muted, #9aa0a6);
  line-height: 1.35;
}
.cust-cb-note {
  font-size: 0.75rem;
  color: var(--text-muted, #9aa0a6);
  margin-top: 0.3rem;
  line-height: 1.35;
}
.cust-badge {
  display: inline-block;
  font-size: 0.65rem;
  font-weight: 700;
  text-transform: uppercase;
  padding: 0.15rem 0.45rem;
  border-radius: 999px;
  vertical-align: middle;
}
.cust-badge-ok { background: rgba(46,204,113,0.15); color: #2ecc71; }
.cust-badge-wait { background: rgba(241,196,15,0.15); color: #f1c40f; }
.cust-badge-used, .cust-badge-exp { background: rgba(149,165,166,0.15); color: #95a5a6; }
.cust-empty {
  text-align: center;
  padding: 1.25rem 1rem;
  color: var(--text-muted, #9aa0a6);
  background: var(--bg-card, #1a1d24);
  border: 1px dashed var(--border, #2a2f3a);
  border-radius: 12px;
  font-size: 0.9rem;
}
@keyframes fadeIn {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: none; }
}

.store-info { cursor: pointer; }
.store-info:active { opacity: 0.85; }
#current-store-name {
  cursor: default !important;
  text-decoration: none !important;
  pointer-events: none;
}
.store-pick-item { align-items: flex-start !important; }
.store-pick-active {
  border-color: var(--primary, #3b82f6) !important;
  box-shadow: 0 0 0 1px rgba(59,130,246,0.35);
}
.store-chip.on {
  background: rgba(46,204,113,0.2);
  color: #2ecc71;
  font-size: 0.7rem;
  padding: 0.1rem 0.4rem;
  border-radius: 999px;
  font-weight: 700;
}

.cust-rules {
  background: var(--bg-card, #1a1d24);
  border: 1px solid var(--border, #2a2f3a);
  border-radius: 12px;
  padding: 0.75rem 0.9rem;
  margin-bottom: 1rem;
  font-size: 0.8rem;
  line-height: 1.45;
  color: var(--text-muted, #9aa0a6);
}
.cust-rules strong { color: var(--text, #e8eaed); font-size: 0.85rem; }

/* Produto por peso no modal */
#modal-body .check-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.55rem 0.65rem;
  background: var(--bg-card, #1a1d24);
  border: 1px solid var(--border, #2a2f3a);
  border-radius: 10px;
  margin: 0.4rem 0;
  cursor: pointer;
}
#modal-body .check-row input { width: auto; accent-color: var(--primary, #3b82f6); }

.mix-status-box {
  margin-top: 0.75rem;
  padding: 0.75rem 0.9rem;
  background: var(--bg-card, #1a1d24);
  border: 1px solid var(--border, #2a2f3a);
  border-radius: 12px;
  font-size: 0.9rem;
  line-height: 1.5;
}
.mix-status-box strong { font-weight: 800; }

.pdv-payment-progress {
  margin: 0.5rem 0 0.65rem;
  padding: 0.65rem 0.75rem;
  background: rgba(59, 130, 246, 0.08);
  border: 1px solid var(--border, #2a2f3a);
  border-radius: 12px;
  font-size: 0.85rem;
}
.pdv-payment-progress .pp-row {
  display: flex;
  justify-content: space-between;
  gap: 0.5rem;
  padding: 0.2rem 0;
}
.pdv-payment-progress .pp-rest {
  margin-top: 0.4rem;
  padding-top: 0.4rem;
  border-top: 1px dashed var(--border, #2a2f3a);
  font-weight: 700;
}
.pdv-payment-progress .pp-rest.ok { color: #2ecc71; }
.pdv-payment-progress .pp-rest.pend { color: #f1c40f; }


/* Badge notificações chat/tickets */
.nav-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 1.15rem;
  height: 1.15rem;
  padding: 0 0.3rem;
  margin-left: 0.35rem;
  border-radius: 999px;
  background: #ef4444;
  color: #fff;
  font-size: 0.7rem;
  font-weight: 700;
  line-height: 1;
}
.nav-badge.hidden { display: none !important; }
.nav-item { position: relative; }
