:root {
  --bg: #f4f6fa;
  --surface: #ffffff;
  --surface-alt: #f8fafc;
  --sidebar-bg: #0c1018;
  --sidebar-hover: rgba(255, 255, 255, 0.08);
  --sidebar-text: #d1d5db;
  --primary: #0066e6;
  --primary-dark: #004bb5;
  --primary-soft: #eef6ff;
  --accent: #ff6b00;
  --accent-dark: #e05a00;
  --accent-soft: #fff4eb;
  --success: #059669;
  --success-soft: #ecfdf5;
  --warning: #ea580c;
  --warning-soft: #fff7ed;
  --danger: #dc2626;
  --danger-soft: #fef2f2;
  --info: #0066e6;
  --info-soft: #eef6ff;
  --text: #111827;
  --text-muted: #64748b;
  --border: #e5e9f0;
  --radius: 12px;
  --shadow: 0 1px 2px rgba(15, 23, 42, 0.04), 0 4px 12px rgba(15, 23, 42, 0.03);
  --shadow-hover: 0 6px 20px rgba(0, 102, 230, 0.08), 0 2px 6px rgba(15, 23, 42, 0.04);
  --shadow-lg: 0 20px 44px rgba(12, 16, 24, 0.22), 0 4px 12px rgba(12, 16, 24, 0.08);
}

* { box-sizing: border-box; -webkit-tap-highlight-color: rgba(0, 102, 230, 0.14); }
html, body {
  margin: 0;
  padding: 0;
  font-family: 'Inter', 'Segoe UI', system-ui, -apple-system, BlinkMacSystemFont, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.5;
  overflow-x: hidden;
  -webkit-text-size-adjust: 100%;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}
button, a, input, select, textarea { touch-action: manipulation; }
svg { max-width: 100%; }
img { max-width: 100%; }
.table-wrap, .nav-scroll, .modal-body, .pdv-items-scroll, .tabs, .quick-actions-bar {
  -webkit-overflow-scrolling: touch;
}
body.drawer-open { overflow: hidden; }
.sidebar-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(11, 15, 23, 0.58);
  backdrop-filter: blur(2px);
  -webkit-backdrop-filter: blur(2px);
  z-index: 48;
  transition: opacity 0.2s ease;
}
.sidebar-close-btn {
  display: none;
  position: absolute;
  top: 10px;
  right: 10px;
  width: 34px;
  height: 34px;
  border-radius: 9px;
  border: 1px solid rgba(255, 255, 255, 0.14);
  background: rgba(255, 255, 255, 0.08);
  color: #e2e8f0;
  font-size: 20px;
  line-height: 1;
  cursor: pointer;
  align-items: center;
  justify-content: center;
  z-index: 5;
}
.sidebar-close-btn:hover { background: rgba(255, 107, 0, 0.85); color: #fff; }

code {
  background: #f1f5f9;
  color: #1e293b;
  padding: 2px 6px;
  border-radius: 5px;
  font-size: 12px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

a { color: var(--primary); }

/* Custom Scrollbars */
::-webkit-scrollbar { width: 7px; height: 7px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #cbd5e1; border-radius: 999px; }
::-webkit-scrollbar-thumb:hover { background: #94a3b8; }

.num { font-variant-numeric: tabular-nums; }
.hidden { display: none !important; }
.text-right { text-align: right; }
.text-center { text-align: center; }
.text-muted { color: var(--text-muted); }
.text-primary { color: var(--primary); }
.text-success { color: var(--success); }
.text-danger { color: var(--danger); }
.text-warning { color: var(--warning); }
.fw-600 { font-weight: 600; }
.fw-700 { font-weight: 700; }
.mt-1 { margin-top: 6px; }
.mt-2 { margin-top: 12px; }
.mt-3 { margin-top: 18px; }
.mb-1 { margin-bottom: 6px; }
.mb-2 { margin-bottom: 12px; }
.mb-3 { margin-bottom: 18px; }
.flex { display: flex; }
.flex-between { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.flex-gap { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }

/* Layout */
.erp-layout { display: flex; min-height: 100vh; }

.sidebar {
  width: 268px;
  background: linear-gradient(180deg, #0b0f17 0%, #111827 56%, #0a1b38 100%);
  color: var(--sidebar-text);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  position: sticky;
  top: 0;
  height: 100vh;
  z-index: 40;
  border-right: 1px solid rgba(255, 255, 255, 0.07);
  box-shadow: 4px 0 24px rgba(11, 15, 23, 0.18);
}

.brand {
  padding: 16px 18px 14px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  background: radial-gradient(circle at 50% 0%, rgba(0, 102, 230, 0.16), transparent 72%);
  position: relative;
}

.brand::after {
  content: '';
  position: absolute;
  left: 18px;
  right: 18px;
  bottom: 0;
  height: 2px;
  border-radius: 999px;
  background: linear-gradient(90deg, transparent 0%, rgba(255, 107, 0, 0.65) 35%, rgba(0, 102, 230, 0.75) 65%, transparent 100%);
}

.brand-logo-link {
  display: flex;
  align-items: center;
  justify-content: center;
  text-decoration: none;
  padding: 2px 4px;
  transition: transform 0.18s ease, filter 0.18s ease;
}

.brand-logo-link:hover {
  transform: scale(1.02);
  filter: drop-shadow(0 6px 16px rgba(0, 102, 230, 0.35));
}

.brand-logo-img {
  display: block;
  width: 100%;
  max-width: 176px;
  max-height: 112px;
  height: auto;
  object-fit: contain;
  filter: drop-shadow(0 4px 12px rgba(0, 0, 0, 0.35));
}

/* Barra de Pesquisa Global do Menu (acima de PRINCIPAL) */
.sidebar-search-wrap {
  padding: 12px 12px 6px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
  background: rgba(15, 23, 42, 0.45);
}

.sidebar-search-box {
  position: relative;
  display: flex;
  align-items: center;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(148, 163, 184, 0.22);
  border-radius: 10px;
  padding: 0 8px 0 10px;
  transition: border-color 0.16s ease, background 0.16s ease, box-shadow 0.16s ease;
}

.sidebar-search-box:focus-within {
  background: rgba(255, 255, 255, 0.1);
  border-color: #3b82f6;
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.24);
}

.sidebar-search-icon {
  font-size: 13px;
  opacity: 0.72;
  margin-right: 7px;
  flex-shrink: 0;
  pointer-events: none;
}

.sidebar-search-input {
  width: 100%;
  min-width: 0;
  background: transparent;
  border: none;
  outline: none;
  color: #f8fafc;
  font-size: 13px;
  font-family: inherit;
  padding: 8.5px 0;
}

.sidebar-search-input::placeholder {
  color: #94a3b8;
  font-weight: 400;
}

.sidebar-search-kbd {
  font-size: 10px;
  font-weight: 700;
  color: #94a3b8;
  background: rgba(15, 23, 42, 0.7);
  border: 1px solid rgba(148, 163, 184, 0.25);
  border-radius: 5px;
  padding: 2px 5px;
  letter-spacing: 0.02em;
  flex-shrink: 0;
  pointer-events: none;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

.sidebar-search-clear {
  background: rgba(148, 163, 184, 0.2);
  color: #e2e8f0;
  border: none;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  font-size: 14px;
  line-height: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  flex-shrink: 0;
  transition: background 0.14s ease, color 0.14s ease;
}

.sidebar-search-clear:hover {
  background: rgba(239, 68, 68, 0.85);
  color: #fff;
}

.sidebar-search-results {
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.sidebar-search-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 6px 10px 6px;
  font-size: 10.5px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: #94a3b8;
}

.search-res-item {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  text-align: left;
  padding: 8.5px 10px;
  border-radius: 9px;
  border: 1px solid transparent;
  background: transparent;
  color: var(--sidebar-text);
  cursor: pointer;
  font-family: inherit;
  transition: background 0.14s ease, border-color 0.14s ease, color 0.14s ease;
}

.search-res-item:hover,
.search-res-item.selected {
  background: rgba(59, 130, 246, 0.22);
  border-color: rgba(59, 130, 246, 0.42);
  color: #ffffff;
}

.search-res-body {
  min-width: 0;
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 1px;
}

.search-res-title {
  font-size: 13px;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.search-res-sub {
  font-size: 11px;
  color: #94a3b8;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.search-res-item.selected .search-res-sub,
.search-res-item:hover .search-res-sub {
  color: #bfdbfe;
}

.search-res-mark {
  background: rgba(56, 189, 248, 0.32);
  color: #ffffff;
  border-radius: 3px;
  padding: 0 2px;
}

.search-res-empty {
  padding: 20px 12px;
  text-align: center;
  color: #94a3b8;
  font-size: 12.5px;
  background: rgba(255, 255, 255, 0.03);
  border: 1px dashed rgba(148, 163, 184, 0.22);
  border-radius: 10px;
  margin-top: 6px;
}

.search-res-empty-btn {
  margin-top: 10px;
  background: rgba(59, 130, 246, 0.22);
  color: #93c5fd;
  border: 1px solid rgba(59, 130, 246, 0.4);
  border-radius: 7px;
  padding: 5px 12px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  font-family: inherit;
}

.search-res-empty-btn:hover {
  background: #2563eb;
  color: #fff;
}

.nav-scroll {
  flex: 1;
  overflow-y: auto;
  padding: 10px 10px 20px;
}
.nav-scroll::-webkit-scrollbar-thumb { background: rgba(148, 163, 184, 0.25); }
.nav-scroll::-webkit-scrollbar-thumb:hover { background: rgba(148, 163, 184, 0.45); }

.nav-group-label {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: #64748b;
  padding: 14px 12px 5px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8.5px 12px;
  border-radius: 9px;
  color: var(--sidebar-text);
  text-decoration: none;
  font-size: 13.5px;
  font-weight: 500;
  margin-bottom: 2px;
  transition: background 0.16s ease, color 0.16s ease, transform 0.14s ease, box-shadow 0.16s ease;
  position: relative;
}

.nav-item:hover {
  background: var(--sidebar-hover);
  color: #ffffff;
  transform: translateX(2px);
}

.nav-item.active {
  background: linear-gradient(90deg, #0066e6 0%, #004bb5 100%);
  color: #ffffff;
  font-weight: 600;
  box-shadow: 0 4px 14px rgba(0, 102, 230, 0.38);
  border-left: 3px solid var(--accent);
}

.nav-item.nav-highlight:not(.active) {
  background: rgba(255, 107, 0, 0.15);
  color: #fdba74;
  border: 1px solid rgba(255, 107, 0, 0.36);
}
.nav-item.nav-highlight:not(.active):hover {
  background: linear-gradient(90deg, #ff6b00 0%, #ea580c 100%);
  color: #fff;
  border-color: transparent;
}

.nav-icon { width: 20px; text-align: center; font-size: 14.5px; flex-shrink: 0; }

.sidebar-footer {
  padding: 12px 12px 14px;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
  background: rgba(0, 0, 0, 0.15);
}

.btn-b2b-link {
  display: block;
  text-align: center;
  padding: 9.5px 12px;
  border-radius: 9px;
  background: linear-gradient(135deg, rgba(255, 107, 0, 0.2), rgba(234, 88, 12, 0.24));
  color: #fed7aa;
  border: 1px solid rgba(255, 107, 0, 0.42);
  text-decoration: none;
  font-weight: 600;
  font-size: 13px;
  transition: all 0.16s ease;
}
.btn-b2b-link:hover {
  background: linear-gradient(135deg, #ff6b00, #ea580c);
  color: #fff;
  box-shadow: 0 6px 16px rgba(255, 107, 0, 0.35);
}

.main-wrap { flex: 1; min-width: 0; display: flex; flex-direction: column; }

.topbar {
  height: 62px;
  background: rgba(255, 255, 255, 0.92);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border);
  padding: 0 26px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 30;
}

.topbar-left { display: flex; align-items: center; gap: 12px; }
.page-title {
  margin: 0;
  font-size: 18.5px;
  font-weight: 800;
  color: var(--text);
  letter-spacing: -0.02em;
}
.topbar-right { display: flex; align-items: center; gap: 10px; }

.env-pill {
  font-size: 12px;
  font-weight: 700;
  padding: 5px 12px;
  border-radius: 999px;
  background: var(--warning-soft);
  color: #b45309;
  border: 1px solid #fcd34d;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.env-pill::before {
  content: '';
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #f59e0b;
}

.mobile-menu-btn { display: none; }

.content-area { padding: 22px 26px 40px; flex: 1; max-width: 1680px; width: 100%; margin: 0 auto; }

/* Cards & Grids */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 20px;
  transition: box-shadow 0.2s ease;
}

.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 16px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--border);
  flex-wrap: wrap;
}

.card-title { margin: 0; font-size: 16px; font-weight: 750; color: var(--text); letter-spacing: -0.01em; }

.kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(215px, 1fr));
  gap: 14px;
  margin-bottom: 18px;
}

.kpi-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 18px;
  box-shadow: var(--shadow);
  transition: transform 0.18s ease, box-shadow 0.18s ease, border-color 0.18s ease;
  position: relative;
  overflow: hidden;
}
.kpi-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-hover);
  border-color: #cbd5e1;
}
.kpi-label { font-size: 11.5px; font-weight: 700; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.04em; }
.kpi-value { font-size: 25px; font-weight: 800; margin-top: 6px; font-variant-numeric: tabular-nums; letter-spacing: -0.02em; line-height: 1.2; }
.kpi-sub { font-size: 12px; color: var(--text-muted); margin-top: 5px; }

.grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px; }
.grid-4 { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; }

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 8.5px 15px;
  border-radius: 8px;
  font-size: 13.5px;
  font-weight: 600;
  border: 1px solid transparent;
  cursor: pointer;
  text-decoration: none;
  transition: all 0.15s ease;
  font-family: inherit;
  line-height: 1.25;
}
.btn:active:not(:disabled) { transform: scale(0.98); }
.btn:disabled { opacity: 0.52; cursor: not-allowed; }
.btn-sm { padding: 5.5px 11px; font-size: 12.5px; border-radius: 7px; }
.btn-lg { padding: 11px 20px; font-size: 15px; }
.btn-primary { background: linear-gradient(180deg, #0073ff 0%, #0058cc 100%); color: #fff; box-shadow: 0 1px 2px rgba(0, 102, 230, 0.28); }
.btn-primary:hover:not(:disabled) { background: linear-gradient(180deg, #0066e6 0%, #004bb5 100%); box-shadow: 0 4px 12px rgba(0, 102, 230, 0.32); }
.btn-accent { background: linear-gradient(180deg, #ff7b1a 0%, #ff6b00 100%); color: #fff; box-shadow: 0 2px 6px rgba(255, 107, 0, 0.28); }
.btn-accent:hover:not(:disabled) { background: linear-gradient(180deg, #ff6b00 0%, #e05a00 100%); box-shadow: 0 5px 14px rgba(255, 107, 0, 0.34); }
.btn-success { background: linear-gradient(180deg, #10b981 0%, #059669 100%); color: #fff; box-shadow: 0 1px 2px rgba(5, 150, 105, 0.25); }
.btn-success:hover:not(:disabled) { background: linear-gradient(180deg, #059669 0%, #047857 100%); box-shadow: 0 4px 12px rgba(5, 150, 105, 0.28); }
.btn-warning { background: linear-gradient(180deg, #f59e0b 0%, #d97706 100%); color: #fff; }
.btn-warning:hover:not(:disabled) { background: linear-gradient(180deg, #d97706 0%, #b45309 100%); }
.btn-danger { background: linear-gradient(180deg, #ef4444 0%, #dc2626 100%); color: #fff; }
.btn-danger:hover:not(:disabled) { background: linear-gradient(180deg, #dc2626 0%, #b91c1c 100%); }
.btn-outline { background: #fff; border-color: #d7dfe9; color: var(--text); }
.btn-outline:hover:not(:disabled) { background: var(--surface-alt); border-color: #94a3b8; }
.btn-soft { background: var(--primary-soft); color: var(--primary-dark); border-color: #dbeafe; }
.btn-soft:hover:not(:disabled) { background: #dbeafe; }
.btn-icon { background: #fff; border: 1px solid var(--border); border-radius: 8px; padding: 6px 10px; cursor: pointer; font-size: 16px; transition: background 0.15s; }
.btn-icon:hover { background: var(--surface-alt); }

/* Topbar Utilities, Alertas, Ações Rápidas, Spinner & Modal de Confirmação */
.topbar-alerts-wrap { position: relative; }
.tenant-switcher-pill,
.user-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5.5px 11px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 700;
  font-family: inherit;
  cursor: pointer;
  transition: all 0.15s ease;
  max-width: 240px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.tenant-switcher-pill {
  background: var(--primary-soft);
  color: var(--primary-dark);
  border: 1px solid #bfdbfe;
}
.tenant-switcher-pill:hover {
  background: #dbeafe;
  border-color: #60a5fa;
}
.user-pill {
  background: var(--surface-alt);
  color: var(--text);
  border: 1px solid var(--border);
}
.user-pill:hover {
  background: #e2e8f0;
  border-color: #94a3b8;
}
.perm-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(235px, 1fr));
  gap: 12px;
  margin-top: 8px;
}
.perm-group-card {
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px 12px;
  background: var(--surface-alt);
}
.perm-group-title {
  font-size: 11.5px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--primary-dark);
  margin-bottom: 8px;
  padding-bottom: 5px;
  border-bottom: 1px solid var(--border);
}
.perm-check-row {
  display: flex;
  align-items: center;
  gap: 7px;
  font-size: 12.5px;
  padding: 3px 0;
  cursor: pointer;
}
.form-section-title {
  grid-column: 1 / -1;
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--primary-dark);
  padding: 8px 0 4px;
  margin-top: 4px;
  border-bottom: 1px solid var(--border);
}
.topbar-util-btn { position: relative; font-size: 15px; padding: 6px 9px; line-height: 1; }
.alerts-badge {
  position: absolute;
  top: -5px;
  right: -5px;
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  border-radius: 999px;
  background: var(--danger);
  color: #fff;
  font-size: 10.5px;
  font-weight: 800;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 2px 6px rgba(220, 38, 38, 0.45);
}
.alerts-popover {
  position: absolute;
  top: calc(100% + 10px);
  right: 0;
  width: 340px;
  max-width: 92vw;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: var(--shadow-lg);
  z-index: 90;
  overflow: hidden;
}
.alerts-popover-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 14px;
  background: var(--surface-alt);
  border-bottom: 1px solid var(--border);
  font-weight: 700;
  font-size: 13px;
}
.alerts-popover-list { max-height: 360px; overflow-y: auto; padding: 6px; display: flex; flex-direction: column; gap: 4px; }
.alerts-popover-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 10px;
  border-radius: 8px;
  text-decoration: none;
  color: var(--text);
  transition: background 0.14s ease;
  border: 1px solid transparent;
}
.alerts-popover-item:hover { background: var(--primary-soft); border-color: #dbeafe; }

.quick-actions-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 16px;
  padding: 11px 14px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}
.quick-actions-label {
  font-size: 11.5px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  margin-right: 4px;
}
.kpi-clickable { cursor: pointer; }
.kpi-clickable:hover { border-color: var(--primary); }

.spinner-inline {
  display: inline-block;
  width: 12px;
  height: 12px;
  border: 2px solid currentColor;
  border-right-color: transparent;
  border-radius: 50%;
  animation: nex-spin 0.65s linear infinite;
}
@keyframes nex-spin { to { transform: rotate(360deg); } }

.nex-confirm-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.58);
  backdrop-filter: blur(2px);
  display: grid;
  place-items: center;
  z-index: 200;
  padding: 16px;
}
.nex-confirm-dialog {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 13px;
  box-shadow: var(--shadow-lg);
  width: 430px;
  max-width: 100%;
  overflow: hidden;
}
.nex-confirm-header {
  padding: 14px 18px;
  border-bottom: 1px solid var(--border);
  font-size: 15px;
  background: var(--surface-alt);
}
.nex-confirm-body {
  padding: 16px 18px;
  color: #334155;
  font-size: 13.5px;
  line-height: 1.55;
  white-space: pre-line;
}
.nex-confirm-footer {
  padding: 12px 18px;
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  background: var(--surface-alt);
}

/* ==========================================================================
   Página Completa de Login / Troca de Usuário (Estilo Site NEXSISTEMAS ERP)
   ========================================================================== */
.nex-login-page {
  position: fixed;
  inset: 0;
  z-index: 160;
  display: grid;
  grid-template-columns: minmax(0, 1.08fr) minmax(0, 1fr);
  background: var(--bg);
  overflow-y: auto;
  animation: nexLoginFade 0.2s ease-out;
}
@keyframes nexLoginFade {
  from { opacity: 0; transform: scale(0.99); }
  to { opacity: 1; transform: scale(1); }
}

.nex-login-hero {
  position: relative;
  background:
    radial-gradient(circle at 14% 18%, rgba(0, 102, 230, 0.34), transparent 46%),
    radial-gradient(circle at 88% 82%, rgba(255, 107, 0, 0.26), transparent 48%),
    linear-gradient(155deg, #0b0f17 0%, #111827 52%, #0a1f44 100%);
  color: #e2e8f0;
  padding: 40px 52px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  overflow: hidden;
  border-right: 1px solid rgba(255, 255, 255, 0.08);
}

.nex-login-hero-brand {
  display: inline-flex;
  align-items: center;
  padding: 4px 0;
}
.nex-login-hero-logo-img {
  display: block;
  height: 112px;
  width: auto;
  max-width: 260px;
  object-fit: contain;
  filter: drop-shadow(0 10px 24px rgba(0, 0, 0, 0.42));
}
.nex-login-card-logo {
  display: flex;
  justify-content: center;
  margin-bottom: 18px;
}
.nex-login-card-logo img {
  height: 78px;
  width: auto;
  max-width: 210px;
  object-fit: contain;
}
.nex-login-hero-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: #fdba74;
  background: rgba(255, 107, 0, 0.16);
  border: 1px solid rgba(255, 107, 0, 0.38);
  padding: 4px 11px;
  border-radius: 999px;
  margin-bottom: 18px;
}
.nex-login-hero-title {
  margin: 0 0 14px;
  font-size: 32px;
  line-height: 1.2;
  font-weight: 800;
  color: #ffffff;
  letter-spacing: -0.025em;
  max-width: 520px;
}
.nex-login-hero-desc {
  margin: 0 0 28px;
  font-size: 14.5px;
  line-height: 1.65;
  color: #cbd5e1;
  max-width: 490px;
}
.nex-login-features {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  max-width: 520px;
}
.nex-login-feature-card {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 12px;
  padding: 13px 14px;
  backdrop-filter: blur(8px);
}
.nex-login-feature-title {
  font-size: 13px;
  font-weight: 700;
  color: #ffffff;
  margin-bottom: 3px;
}
.nex-login-feature-sub {
  font-size: 11.5px;
  color: #94a3b8;
  line-height: 1.4;
}
.nex-login-hero-footer {
  font-size: 12px;
  color: #64748b;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding-top: 20px;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
}

.nex-login-panel {
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  padding: 36px 28px;
  position: relative;
  background:
    radial-gradient(circle at 90% 10%, rgba(37, 99, 235, 0.06), transparent 40%),
    var(--bg);
}
.nex-login-back-top {
  position: absolute;
  top: 22px;
  right: 26px;
}
.nex-login-card {
  width: 100%;
  max-width: 430px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 18px;
  box-shadow: 0 20px 50px rgba(15, 23, 42, 0.1), 0 4px 14px rgba(15, 23, 42, 0.05);
  padding: 34px 32px 30px;
}
.nex-login-card-title {
  margin: 0 0 6px;
  font-size: 23px;
  font-weight: 800;
  color: var(--text);
  letter-spacing: -0.02em;
}
.nex-login-card-sub {
  margin: 0 0 24px;
  font-size: 13.5px;
  color: var(--text-muted);
}
.nex-login-field {
  margin-bottom: 16px;
}
.nex-login-field label {
  display: block;
  font-size: 12.5px;
  font-weight: 700;
  color: #334155;
  margin-bottom: 6px;
}
.nex-input-wrap {
  position: relative;
  display: flex;
  align-items: center;
}
.nex-input-icon {
  position: absolute;
  left: 12px;
  font-size: 14px;
  opacity: 0.65;
  pointer-events: none;
}
.nex-input-wrap .form-control {
  width: 100%;
  padding: 11px 12px 11px 38px;
  font-size: 14px;
  border-radius: 10px;
  border: 1px solid #cbd5e1;
  background: #ffffff;
  transition: border-color 0.16s ease, box-shadow 0.16s ease;
}
.nex-input-wrap .form-control:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3.5px rgba(37, 99, 235, 0.16);
}
.nex-input-pwd .form-control {
  padding-right: 42px;
}
.nex-pwd-toggle {
  position: absolute;
  right: 8px;
  background: transparent;
  border: none;
  cursor: pointer;
  font-size: 15px;
  padding: 5px 6px;
  border-radius: 6px;
  color: var(--text-muted);
}
.nex-pwd-toggle:hover {
  background: var(--surface-alt);
  color: var(--text);
}
.nex-login-submit {
  width: 100%;
  padding: 12px 18px;
  font-size: 14.5px;
  font-weight: 700;
  border-radius: 10px;
  margin-top: 6px;
}
.nex-login-actions-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-top: 14px;
  padding-top: 14px;
  border-top: 1px solid var(--border);
}
.nex-login-link {
  background: transparent;
  border: none;
  color: var(--primary);
  font-weight: 600;
  font-size: 12.5px;
  cursor: pointer;
  padding: 2px 0;
  font-family: inherit;
}
.nex-login-link:hover {
  color: var(--primary-dark);
  text-decoration: underline;
}

@media (max-width: 920px) {
  .nex-login-page {
    grid-template-columns: 1fr;
  }
  .nex-login-hero {
    padding: 28px 24px;
  }
  .nex-login-hero-title {
    font-size: 24px;
  }
  .nex-login-features {
    display: none;
  }
  .nex-login-panel {
    padding: 26px 18px 40px;
  }
  .nex-login-back-top {
    position: static;
    align-self: flex-end;
    margin-bottom: 12px;
  }
}

/* Forms */
.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(195px, 1fr)); gap: 13px; }
.form-group { display: flex; flex-direction: column; gap: 5px; }
.form-group.col-2 { grid-column: span 2; }
.form-group.col-3 { grid-column: span 3; }
.form-label { font-size: 12px; font-weight: 600; color: #334155; }
.form-control {
  width: 100%;
  padding: 8.5px 11px;
  border: 1px solid #cbd5e1;
  border-radius: 8px;
  font-size: 13.5px;
  font-family: inherit;
  background: #fff;
  color: var(--text);
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
.form-control:hover:not(:disabled) { border-color: #94a3b8; }
.form-control:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3.5px rgba(37, 99, 235, 0.14); }
.form-control:disabled, .form-control[readonly] { background: #f8fafc; color: #64748b; }

/* Tables */
.table-wrap { overflow-x: auto; border-radius: 9px; border: 1px solid var(--border); }
table.data-table { width: 100%; border-collapse: collapse; font-size: 13px; background: #fff; }
table.data-table th {
  text-align: left;
  padding: 11px 12px;
  background: #f8fafd;
  color: #475569;
  font-weight: 700;
  font-size: 11.5px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
  position: sticky;
  top: 0;
  z-index: 1;
}
table.data-table td {
  padding: 10.5px 12px;
  border-bottom: 1px solid #f1f5f9;
  vertical-align: middle;
}
table.data-table tbody tr:last-child td { border-bottom: none; }
table.data-table tbody tr { transition: background 0.12s ease; }
table.data-table tbody tr:hover td { background: #f8faff; }

/* Badges */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 9px;
  border-radius: 999px;
  font-size: 11.5px;
  font-weight: 650;
  white-space: nowrap;
}
.badge-success { background: var(--success-soft); color: #047857; border: 1px solid #a7f3d0; }
.badge-warning { background: var(--warning-soft); color: #b45309; border: 1px solid #fde68a; }
.badge-danger { background: var(--danger-soft); color: #b91c1c; border: 1px solid #fecaca; }
.badge-info { background: var(--info-soft); color: #0369a1; border: 1px solid #bae6fd; }
.badge-neutral { background: #f1f5f9; color: #475569; border: 1px solid #e2e8f0; }
.badge-primary { background: var(--primary-soft); color: var(--primary-dark); border: 1px solid #bfdbfe; }

/* Tabs */
.tabs {
  display: flex;
  gap: 6px;
  background: #ffffff;
  border: 1px solid var(--border);
  border-radius: 11px;
  padding: 5px;
  margin-bottom: 16px;
  flex-wrap: wrap;
  box-shadow: var(--shadow);
}
.tab-btn {
  padding: 8px 14px;
  border: none;
  border-radius: 8px;
  background: transparent;
  font-family: inherit;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-muted);
  cursor: pointer;
  transition: all 0.15s ease;
}
.tab-btn:hover:not(.active) { background: var(--surface-alt); color: var(--text); }
.tab-btn.active {
  background: var(--primary);
  color: #ffffff;
  box-shadow: 0 2px 8px rgba(37, 99, 235, 0.28);
}

/* PDV Clássico Layout — 100% ajustado em uma única tela sem rolagem externa no desktop */
@media (min-width: 1025px) {
  body.route-pdv-active {
    overflow: hidden;
  }
  body.route-pdv-active .erp-layout,
  body.route-pdv-active .main-wrap {
    height: 100vh;
    height: 100dvh;
    min-height: 0;
    overflow: hidden;
  }
  body.route-pdv-active .topbar {
    height: 50px;
    flex-shrink: 0;
    padding: 0 18px;
  }
  #app-view.pdv-view-active {
    flex: 1;
    min-height: 0;
    height: calc(100vh - 50px);
    height: calc(100dvh - 50px);
    padding: 8px 12px !important;
    overflow: hidden;
    display: flex;
    flex-direction: column;
  }
}

@media (min-width: 1025px) and (max-width: 1440px) {
  body.route-pdv-active .sidebar {
    width: 224px;
  }
  body.route-pdv-active .brand {
    padding: 10px 14px;
  }
  body.route-pdv-active .brand-logo-img {
    max-width: 148px;
    max-height: 76px;
  }
  .pdv-main-grid {
    grid-template-columns: minmax(0, 1fr) 340px;
    gap: 8px;
  }
}

@media (min-width: 1025px) and (max-height: 760px) {
  body.route-pdv-active .topbar {
    height: 46px;
  }
  #app-view.pdv-view-active {
    height: calc(100vh - 46px);
    height: calc(100dvh - 46px);
    padding: 6px 10px !important;
  }
  .pdv-classic-wrap,
  .pdv-left-col,
  .pdv-right-col {
    gap: 5px;
  }
  .pdv-top-bar {
    padding: 4px 10px;
    gap: 6px;
  }
  .pdv-top-metrics {
    gap: 10px;
  }
  .pdv-top-val {
    font-size: 12px;
  }
  .pdv-top-actions .btn-sm {
    padding: 3px 6px;
    font-size: 11px;
  }
  .pdv-scan-card {
    padding: 5px 9px;
  }
  .pdv-scan-input {
    padding: 6px 38px 6px 10px;
    font-size: 13.5px;
  }
  .pdv-person-card {
    padding: 4.5px 8px;
    gap: 7px;
  }
  .pdv-person-badge {
    width: 30px;
    height: 30px;
  }
  .pdv-person-name {
    font-size: 12px;
  }
  .pdv-total-card {
    padding: 7px 12px;
  }
  .pdv-total-amount {
    font-size: 26px;
  }
  .pdv-panel-card {
    padding: 6px 8px;
  }
  .pdv-section-title {
    margin-bottom: 4px;
    font-size: 10px;
  }
  .pdv-pay-list {
    gap: 4px;
  }
  .pdv-pay-btn {
    padding: 4.5px 6px;
    font-size: 11px;
  }
  .pdv-actions-footer {
    gap: 4px;
  }
  .pdv-key-btn {
    padding: 4.5px 5px;
  }
  .pdv-finish-btn {
    padding: 9px 12px;
    font-size: 13.5px;
  }
  .pdv-bottom-bar {
    padding: 4px 8px;
  }
}

.pdv-classic-wrap {
  display: flex;
  flex-direction: column;
  gap: 7px;
  flex: 1;
  min-height: 0;
  height: 100%;
  overflow: hidden;
}

.pdv-top-bar {
  background: #ffffff;
  border: 1px solid #d5dfec;
  border-radius: 10px;
  padding: 6px 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
  flex-shrink: 0;
  box-shadow: var(--shadow);
}
.pdv-top-metrics {
  display: flex;
  align-items: center;
  gap: 14px;
  flex-wrap: wrap;
}
.pdv-top-actions {
  display: flex;
  align-items: center;
  gap: 5px;
  flex-wrap: wrap;
}
.pdv-top-actions .btn-sm {
  padding: 4px 7px;
  font-size: 11.5px;
}

.pdv-top-metric { display: flex; flex-direction: column; gap: 1px; }
.pdv-top-label { font-size: 9.5px; color: #64748b; font-weight: 700; text-transform: uppercase; letter-spacing: 0.03em; }
.pdv-top-val { font-size: 13px; font-weight: 800; color: #0c234b; display: flex; align-items: center; gap: 5px; line-height: 1.15; }
.pdv-status-dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; }
.pdv-status-dot.open { background: #16a34a; box-shadow: 0 0 0 2px rgba(22, 163, 74, 0.22); }
.pdv-status-dot.closed { background: #dc2626; box-shadow: 0 0 0 2px rgba(220, 38, 38, 0.22); }

.pdv-main-grid {
  flex: 1;
  min-height: 0;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 365px;
  gap: 10px;
  align-items: stretch;
  overflow: hidden;
}

.pdv-left-col {
  display: flex;
  flex-direction: column;
  gap: 7px;
  min-width: 0;
  min-height: 0;
  height: 100%;
  overflow: hidden;
}

.pdv-scan-card {
  background: #ffffff;
  border: 1px solid #d5dfec;
  border-radius: 10px;
  padding: 7px 11px;
  position: relative;
  flex-shrink: 0;
  box-shadow: var(--shadow);
}

.pdv-scan-label {
  font-size: 10.5px;
  font-weight: 700;
  color: #334155;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  margin-bottom: 4px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.pdv-scan-input-wrap {
  position: relative;
  display: flex;
  align-items: center;
}

.pdv-scan-input {
  width: 100%;
  padding: 7.5px 42px 7.5px 11px;
  border: 2px solid #0066e6;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 600;
  color: #0c234b;
  background: #fff;
  font-family: inherit;
  transition: box-shadow 0.15s ease;
}
.pdv-scan-input:focus { outline: none; box-shadow: 0 0 0 3px rgba(0, 102, 230, 0.16); }

.pdv-barcode-icon {
  position: absolute;
  right: 10px;
  pointer-events: none;
  color: #0c234b;
  display: flex;
  align-items: center;
}

.pdv-autocomplete {
  position: absolute;
  left: 11px;
  right: 11px;
  top: calc(100% - 4px);
  background: #ffffff;
  border: 1px solid #0066e6;
  border-radius: 10px;
  box-shadow: var(--shadow-lg);
  z-index: 60;
  max-height: 240px;
  overflow-y: auto;
}
.pdv-ac-item {
  padding: 8px 11px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  cursor: pointer;
  border-bottom: 1px solid #f1f5f9;
}
.pdv-ac-item:hover { background: #eff6ff; }

.pdv-people-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  flex-shrink: 0;
}

.pdv-person-card {
  background: #ffffff;
  border: 1px solid #d5dfec;
  border-radius: 10px;
  padding: 6px 10px;
  display: flex;
  align-items: center;
  gap: 9px;
  cursor: pointer;
  box-shadow: var(--shadow);
  transition: border-color 0.15s, transform 0.15s, box-shadow 0.15s;
}
.pdv-person-card:hover { border-color: #0066e6; transform: translateY(-1px); box-shadow: var(--shadow-hover); }

.pdv-person-badge {
  width: 34px;
  height: 34px;
  border-radius: 8px;
  color: #fff;
  display: grid;
  place-items: center;
  flex-shrink: 0;
}
.pdv-person-badge.blue { background: linear-gradient(135deg, #0073ff, #004bb5); }
.pdv-person-badge.coral { background: linear-gradient(135deg, #ff7b1a, #ff6b00); }

.pdv-person-meta { min-width: 0; flex: 1; }
.pdv-person-tag { font-size: 9.5px; font-weight: 700; color: #64748b; text-transform: uppercase; letter-spacing: 0.03em; display: flex; align-items: center; gap: 4px; }
.pdv-person-name { font-size: 13px; font-weight: 800; color: #0c234b; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; line-height: 1.2; }
.pdv-person-sub { font-size: 10.5px; color: #475569; font-variant-numeric: tabular-nums; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.pdv-items-card {
  background: #ffffff;
  border: 1px solid #d5dfec;
  border-radius: 10px;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
  box-shadow: var(--shadow);
}

.pdv-items-scroll {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
}

table.pdv-items-table { width: 100%; border-collapse: collapse; font-size: 12.5px; }
table.pdv-items-table thead th {
  background: linear-gradient(90deg, #0b0f17 0%, #0a1f44 100%);
  color: #ffffff;
  padding: 8px 12px;
  font-size: 11.5px;
  font-weight: 700;
  text-align: left;
  position: sticky;
  top: 0;
  z-index: 2;
}
table.pdv-items-table tbody td {
  padding: 7px 12px;
  border-bottom: 1px solid #f1f5f9;
  color: #1e293b;
}
table.pdv-items-table tbody tr { cursor: pointer; transition: background 0.12s; }
table.pdv-items-table tbody tr:hover td { background: #f8faff; }
table.pdv-items-table tbody tr.selected td { background: #eff6ff; font-weight: 600; }

.pdv-bottom-bar {
  background: #ffffff;
  border: 1px solid #d5dfec;
  border-radius: 10px;
  padding: 6px 10px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  flex-wrap: wrap;
  flex-shrink: 0;
  box-shadow: var(--shadow);
}

.pdv-stat-pill {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  border: 1px solid #d5dfec;
  background: #f8fafd;
  border-radius: 7px;
  padding: 4px 8px;
  font-size: 12px;
  color: #475569;
}
.pdv-stat-pill strong { color: #0c234b; font-size: 13px; font-variant-numeric: tabular-nums; }

.btn-coral-outline {
  background: #fff;
  color: #e85a3c;
  border: 1.5px solid #e85a3c;
}
.btn-coral-outline:hover { background: #fff5f2; }

.btn-navy-outline {
  background: #fff;
  color: #0c234b;
  border: 1.5px solid #94a3b8;
}
.btn-navy-outline:hover { background: #f1f5f9; }

.pdv-right-col {
  display: flex;
  flex-direction: column;
  gap: 7px;
  min-width: 0;
  min-height: 0;
  height: 100%;
  overflow: hidden;
}

.pdv-total-card {
  background: linear-gradient(135deg, #0b0f17 0%, #0a1f44 100%);
  color: #ffffff;
  border-radius: 11px;
  padding: 9px 14px;
  border-bottom: 3px solid #ff6b00;
  box-shadow: 0 6px 18px rgba(11, 15, 23, 0.2);
  flex-shrink: 0;
}
.pdv-total-title { font-size: 10px; font-weight: 700; letter-spacing: 0.07em; color: #93c5fd; text-transform: uppercase; }
.pdv-total-amount { font-size: 30px; font-weight: 900; text-align: right; line-height: 1.06; margin-top: 2px; font-variant-numeric: tabular-nums; letter-spacing: -0.5px; }

.pdv-panel-card {
  background: #ffffff;
  border: 1px solid #d5dfec;
  border-radius: 10px;
  padding: 8px 10px;
  box-shadow: var(--shadow);
}
.pdv-pay-panel {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  overflow-y: auto;
}
.pdv-section-title { font-size: 10.5px; font-weight: 800; color: #334155; text-transform: uppercase; letter-spacing: 0.04em; margin-bottom: 6px; }

/* Grade de 2 colunas para Formas de Pagamento — todas visíveis sem rolar! */
.pdv-pay-list {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 5px;
}
.pdv-pay-btn {
  display: flex;
  align-items: center;
  gap: 5px;
  width: 100%;
  padding: 5.5px 7px;
  border-radius: 7px;
  border: 1.5px solid #d5dfec;
  background: #ffffff;
  color: #1e293b;
  font-size: 11.5px;
  font-weight: 700;
  cursor: pointer;
  font-family: inherit;
  text-align: left;
  min-width: 0;
  transition: all 0.14s ease;
}
.pdv-pay-btn > span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.pdv-pay-btn:hover { border-color: #0066e6; background: #eff6ff; }
.pdv-pay-btn.active {
  background: linear-gradient(135deg, #0066e6 0%, #004bb5 100%);
  border-color: #0066e6;
  color: #ffffff;
  box-shadow: 0 3px 10px rgba(0, 102, 230, 0.28);
}

.pdv-kbd {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 1px 4px;
  min-width: 20px;
  height: 17px;
  border-radius: 4px;
  font-size: 9.5px;
  font-weight: 800;
  font-family: ui-monospace, 'Cascadia Mono', Consolas, monospace;
  background: #e2e8f0;
  color: #0f172a;
  border: 1px solid #cbd5e1;
  box-shadow: 0 1px 0 rgba(15, 23, 42, 0.12);
  line-height: 1;
  letter-spacing: 0.01em;
  flex-shrink: 0;
}
.pdv-pay-btn.active .pdv-kbd,
.btn-primary .pdv-kbd,
.btn-success .pdv-kbd,
.btn-danger .pdv-kbd,
.pdv-key-btn .pdv-kbd,
.pdv-finish-btn .pdv-kbd {
  background: rgba(255, 255, 255, 0.22);
  color: #ffffff;
  border-color: rgba(255, 255, 255, 0.4);
  box-shadow: none;
}
.pdv-row-item.pdv-just-bumped {
  animation: pdvRowFlash 0.65s ease;
}
@keyframes pdvRowFlash {
  0% { background: #dcfce7; }
  100% { background: transparent; }
}

.pdv-actions-footer {
  display: flex;
  flex-direction: column;
  gap: 6px;
  flex-shrink: 0;
}
.pdv-shortcuts-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 6px;
}

.pdv-key-btn {
  border: none;
  border-radius: 8px;
  padding: 6px 6px;
  color: #ffffff;
  cursor: pointer;
  font-family: inherit;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1px;
  transition: filter 0.15s, transform 0.12s, box-shadow 0.15s;
}
.pdv-key-btn:hover:not(:disabled) { filter: brightness(1.08); transform: translateY(-1px); box-shadow: 0 4px 10px rgba(15, 23, 42, 0.16); }
.pdv-key-btn:disabled { opacity: 0.5; cursor: not-allowed; }
.pdv-key-btn.blue { background: linear-gradient(135deg, #0066e6, #004bb5); }
.pdv-key-btn.coral { background: linear-gradient(135deg, #ff7b1a, #ff6b00); }
.pdv-key-code { font-size: 11px; font-weight: 800; line-height: 1.1; opacity: 0.92; }
.pdv-key-label { font-size: 11.5px; font-weight: 700; }

.pdv-finish-btn {
  width: 100%;
  border: none;
  border-radius: 10px;
  padding: 11px 14px;
  background: linear-gradient(135deg, #10b981, #059669);
  color: #ffffff;
  font-size: 14.5px;
  font-weight: 800;
  cursor: pointer;
  font-family: inherit;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  box-shadow: 0 6px 16px rgba(5, 150, 105, 0.28);
  transition: filter 0.15s, transform 0.12s;
}
.pdv-finish-btn:hover:not(:disabled) { filter: brightness(1.06); transform: translateY(-1px); }
.pdv-finish-btn:disabled { opacity: 0.5; cursor: not-allowed; }

/* Modal */
@keyframes modalFadeIn {
  from { opacity: 0; transform: translateY(10px) scale(0.985); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.56);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 10px 14px;
  z-index: 100;
}
.modal-dialog {
  background: #fff;
  border-radius: 14px;
  width: 100%;
  max-width: min(860px, 95vw);
  max-height: 96dvh;
  display: flex;
  flex-direction: column;
  box-shadow: var(--shadow-lg);
  border: 1px solid rgba(255, 255, 255, 0.4);
  animation: modalFadeIn 0.18s ease-out;
  overflow: hidden;
}
.modal-dialog.modal-lg { max-width: min(1060px, 96vw); }
.modal-dialog.modal-xl { max-width: min(1260px, 97vw); }
.modal-header {
  padding: 11px 18px;
  border-bottom: 1px solid var(--border);
  background: #fbfcfe;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-shrink: 0;
}
.modal-header h3 { margin: 0; font-size: 15.5px; font-weight: 800; letter-spacing: -0.01em; }
.modal-close {
  background: #f1f5f9;
  border: none;
  width: 28px;
  height: 28px;
  border-radius: 8px;
  font-size: 19px;
  cursor: pointer;
  color: var(--text-muted);
  display: grid;
  place-items: center;
  line-height: 1;
  transition: background 0.15s, color 0.15s;
}
.modal-close:hover { background: #e2e8f0; color: var(--text); }
.modal-body {
  padding: 12px 18px;
  overflow-y: auto;
  flex: 1;
}
/* Compactação inteligente dentro de TODOS os modais do ERP para caber sem barra de rolagem */
.modal-body .tabs {
  margin-bottom: 10px !important;
  gap: 6px;
}
.modal-body .tab-btn {
  padding: 6px 12px;
  font-size: 12.5px;
}
.modal-body .form-grid {
  grid-template-columns: repeat(auto-fit, minmax(185px, 1fr));
  gap: 8px 11px;
}
.modal-dialog.modal-xl .modal-body .form-grid {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}
.modal-dialog.modal-lg .modal-body .form-grid {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}
.modal-body .form-group {
  gap: 3px;
}
.modal-body .form-group.col-3,
.modal-body .form-section-title {
  grid-column: 1 / -1;
}
.modal-body .form-section-title {
  margin: 4px 0 0;
  padding-bottom: 4px;
  font-size: 12px;
}
.modal-body .form-label,
.modal-body .form-group > label {
  font-size: 11.5px;
  line-height: 1.2;
}
.modal-body .form-control,
.modal-body input[type="text"],
.modal-body input[type="number"],
.modal-body input[type="date"],
.modal-body input[type="email"],
.modal-body input[type="password"],
.modal-body input[type="search"],
.modal-body select {
  padding: 6px 9px;
  font-size: 12.5px;
  border-radius: 7px;
}
.modal-body .alert {
  padding: 8px 11px;
  margin-bottom: 8px;
  font-size: 12px;
}
.modal-footer {
  padding: 10px 18px;
  border-top: 1px solid var(--border);
  background: #fbfcfe;
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  flex-shrink: 0;
}

/* Toast */
@keyframes toastSlideIn {
  from { opacity: 0; transform: translateX(18px); }
  to { opacity: 1; transform: translateX(0); }
}
.toast-container { position: fixed; bottom: 22px; right: 22px; z-index: 200; display: flex; flex-direction: column; gap: 8px; }
.toast {
  background: #0f172a;
  color: #fff;
  padding: 12px 16px;
  border-radius: 10px;
  font-size: 13.5px;
  font-weight: 500;
  box-shadow: var(--shadow-lg);
  border-left: 4px solid var(--primary);
  max-width: 400px;
  animation: toastSlideIn 0.2s ease-out;
}
.toast.toast-success { border-left-color: #10b981; }
.toast.toast-error { border-left-color: #ef4444; }
.toast.toast-warning { border-left-color: #f59e0b; }

/* Alert Box */
.alert { padding: 12px 15px; border-radius: 9px; font-size: 13px; border: 1px solid; line-height: 1.45; }
.alert-info { background: var(--info-soft); border-color: #bae6fd; color: #0369a1; }
.alert-success { background: var(--success-soft); border-color: #a7f3d0; color: #065f46; }
.alert-warning { background: var(--warning-soft); border-color: #fde68a; color: #92400e; }

/* Dropzone */
.dropzone {
  border: 2px dashed #94a3b8;
  border-radius: 11px;
  padding: 26px;
  text-align: center;
  background: var(--surface-alt);
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
}
.dropzone:hover, .dropzone.dragover { border-color: var(--primary); background: var(--primary-soft); }

/* Print Styles */
.print-only { display: none; }
@media print {
  .erp-layout, .modal-backdrop, .toast-container, .nex-login-page { display: none !important; }
  .print-only { display: block !important; }
  body { background: #fff; }
}

/* ==========================================================================
   Responsividade Completa — Desktop, Tablet, Android e iOS (Safe-Area Ready)
   ========================================================================== */

.bi-builder-grid {
  display: grid;
  grid-template-columns: 360px minmax(0, 1fr);
  gap: 16px;
  align-items: start;
}

/* Desktop Compacto & Tablet Paisagem (<= 1220px) */
@media (max-width: 1220px) {
  .topbar { padding: 0 18px; }
  .topbar-desktop-only { display: none !important; }
  .content-area { padding: 18px 18px 34px; }
  .pdv-main-grid { grid-template-columns: minmax(0, 1fr) 288px; }
  .grid-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

/* Tablet Retrato & Drawer Lateral (<= 1024px) */
@media (max-width: 1024px) {
  .sidebar {
    position: fixed;
    left: 0;
    top: 0;
    width: min(290px, 85vw);
    height: 100vh;
    height: 100dvh;
    z-index: 55;
    transform: translateX(-105%);
    transition: transform 0.24s cubic-bezier(0.22, 1, 0.36, 1);
    padding-top: env(safe-area-inset-top);
    padding-bottom: env(safe-area-inset-bottom);
  }
  .sidebar.open { transform: translateX(0); }
  .sidebar-close-btn { display: inline-flex; }
  .mobile-menu-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 40px;
    min-height: 40px;
    padding: 0;
  }

  .topbar {
    height: auto;
    min-height: 58px;
    padding: calc(8px + env(safe-area-inset-top)) 14px 8px;
    gap: 10px;
  }
  .topbar-left { min-width: 0; flex: 1; gap: 10px; }
  .page-title {
    font-size: 16px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }
  .topbar-right { gap: 7px; flex-shrink: 0; }
  .tenant-switcher-pill { max-width: 190px; }

  .content-area { padding: 16px 14px calc(30px + env(safe-area-inset-bottom)); }
  .pdv-classic-wrap,
  .pdv-main-grid,
  .pdv-left-col,
  .pdv-right-col {
    height: auto;
    overflow: visible;
  }
  .pdv-pay-panel { overflow: visible; }
  .pdv-main-grid, .grid-2, .grid-3, .bi-builder-grid { grid-template-columns: 1fr; }
  .kpi-grid { grid-template-columns: repeat(2, minmax(0, 1fr)) !important; gap: 11px; }
  .pdv-items-card { min-height: 240px; }
  .pdv-items-scroll { max-height: 300px; }
}

/* Smartphones Android & iOS (<= 680px) */
@media (max-width: 680px) {
  /* Evita zoom automático do Safari iOS ao focar campos */
  input, select, textarea, .form-control, .sidebar-search-input, .pdv-scan-input {
    font-size: 16px !important;
  }

  .topbar {
    padding: calc(7px + env(safe-area-inset-top)) 10px 7px;
    gap: 6px;
  }
  .page-title { font-size: 15px; }
  .tenant-switcher-pill {
    max-width: 126px;
    padding: 6px 9px;
    font-size: 11.5px;
  }
  .user-pill {
    padding: 6px 9px;
    font-size: 11.5px;
    max-width: 104px;
  }
  .topbar-util-btn { min-width: 38px; min-height: 38px; }

  /* Popover de alertas centralizado sem cortar nas bordas */
  .alerts-popover {
    position: fixed;
    top: calc(62px + env(safe-area-inset-top));
    left: 10px;
    right: 10px;
    width: auto;
    max-width: none;
  }

  .content-area { padding: 12px 10px calc(28px + env(safe-area-inset-bottom)); }

  /* Cards & Cabeçalhos adaptativos */
  .card { padding: 14px 12px; border-radius: 11px; }
  .card-header {
    flex-direction: column;
    align-items: stretch;
    gap: 10px;
    margin-bottom: 12px;
    padding-bottom: 10px;
  }
  .card-title { font-size: 15px; }
  .card-header .flex-gap { width: 100%; }
  .card-header .form-control,
  .card-header select,
  .card-header input[type="search"],
  .card-header input[type="date"] {
    width: 100% !important;
    min-width: 0 !important;
    flex: 1 1 135px;
  }

  /* Barra de Ações Rápidas & Abas em rolagem horizontal nativa */
  .quick-actions-bar {
    flex-wrap: nowrap;
    overflow-x: auto;
    scrollbar-width: none;
    padding: 9px 10px;
    gap: 7px;
  }
  .quick-actions-bar::-webkit-scrollbar { display: none; }
  .quick-actions-bar > * { flex-shrink: 0; white-space: nowrap; }

  .tabs {
    flex-wrap: nowrap;
    overflow-x: auto;
    scrollbar-width: none;
    padding: 5px;
    gap: 5px;
  }
  .tabs::-webkit-scrollbar { display: none; }
  .tab-btn {
    flex-shrink: 0;
    white-space: nowrap;
    padding: 9px 13px;
    min-height: 38px;
    font-size: 12.5px;
  }

  /* KPIs & Grids */
  .kpi-grid { grid-template-columns: repeat(2, minmax(0, 1fr)) !important; gap: 9px; margin-bottom: 14px; }
  .kpi-card { padding: 12px 13px; }
  .kpi-label { font-size: 10.5px; }
  .kpi-value { font-size: 19px !important; }
  .kpi-sub { font-size: 11px; }

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

  /* Formulários em coluna única limpa (anula col-2 / col-3) */
  .form-grid { grid-template-columns: 1fr !important; gap: 11px; }
  .form-group.col-2, .form-group.col-3 { grid-column: span 1 !important; }
  .perm-grid { grid-template-columns: 1fr; }

  /* Botões touch-friendly */
  .btn { min-height: 40px; padding: 8px 13px; }
  .btn-sm { min-height: 34px; padding: 5px 10px; }
  .nav-item { min-height: 42px; padding: 9px 12px; }

  /* Tabelas com rolagem horizontal fluida e célula legível */
  .table-wrap {
    margin: 0 -2px;
    border-radius: 8px;
  }
  table.data-table { font-size: 12.5px; }
  table.data-table th, table.data-table td { padding: 9px 9px; }

  /* PDV Mobile Touch */
  .pdv-top-bar {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
    padding: 11px 12px;
  }
  .pdv-people-row { grid-template-columns: 1fr; gap: 9px; }
  .pdv-total-amount { font-size: 30px; }
  .pdv-pay-list {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 7px;
  }
  .pdv-pay-btn { min-height: 42px; padding: 8px 9px; font-size: 12px; gap: 6px; }
  .pdv-shortcuts-grid { gap: 7px; }
  .pdv-key-btn { min-height: 54px; padding: 10px 6px; }
  .pdv-bottom-bar { flex-direction: column; align-items: stretch; gap: 8px; }
  .pdv-bottom-bar .flex-gap { width: 100%; }
  .pdv-bottom-bar select { width: 100% !important; }

  /* Modais estilo Bottom-Sheet / App Nativo no smartphone */
  .modal-backdrop {
    padding: 0;
    align-items: flex-end;
  }
  .modal-dialog,
  .modal-dialog.modal-lg,
  .modal-dialog.modal-xl {
    max-width: 100%;
    width: 100%;
    max-height: 93dvh;
    border-radius: 18px 18px 0 0;
    border: none;
  }
  .modal-header { padding: 14px 16px; }
  .modal-header h3 { font-size: 15.5px; }
  .modal-close { width: 36px; height: 36px; }
  .modal-body { padding: 14px 15px; }
  .modal-footer {
    padding: 12px 15px calc(12px + env(safe-area-inset-bottom));
    flex-wrap: wrap;
    gap: 8px;
  }
  .modal-footer .btn { flex: 1 1 auto; }

  .nex-confirm-backdrop { padding: 14px; }
  .nex-confirm-dialog { width: 100%; }

  /* Tela de Login Mobile — Logo + Formulário visíveis de imediato sem rolagem */
  .nex-login-page {
    grid-template-columns: 1fr;
    grid-template-rows: auto 1fr;
    min-height: 100dvh;
  }
  .nex-login-hero {
    padding: calc(18px + env(safe-area-inset-top)) 18px 16px;
    border-right: none;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
    align-items: center;
    text-align: center;
  }
  .nex-login-hero-logo-img { height: 74px; }
  .nex-login-hero-title,
  .nex-login-hero-desc,
  .nex-login-features,
  .nex-login-hero-footer,
  .nex-login-hero-badge {
    display: none;
  }
  .nex-login-panel {
    padding: 18px 14px calc(26px + env(safe-area-inset-bottom));
    justify-content: flex-start;
  }
  .nex-login-card {
    padding: 22px 18px 20px;
    border-radius: 15px;
  }
  .nex-login-card-logo { display: none; }
  .nex-login-card-title { font-size: 20px; }
  .nex-login-submit { min-height: 46px; font-size: 15px; }

  /* Toasts no rodapé com safe-area */
  .toast-container {
    left: 10px;
    right: 10px;
    bottom: calc(12px + env(safe-area-inset-bottom));
  }
  .toast { max-width: none; width: 100%; }
}

/* Smartphones muito estreitos (<= 390px — iPhone SE / Android compacto) */
@media (max-width: 390px) {
  .kpi-grid { grid-template-columns: 1fr !important; }
  .pdv-top-bar { grid-template-columns: 1fr; }
  .pdv-pay-list { grid-template-columns: 1fr; }
  .tenant-switcher-pill { max-width: 96px; }
  #topbar-user-label { display: none; }
}
