/* [02/08] CSS do SPA do PCP — extraído do index.html (era inline, 2.423 linhas).
 * ⭐ Agora mexer em CSS não invalida os 768 KB de JS: cada um tem sua versão e seu cache.
 * ⚠️ Servido como /pcp-app.css?v=N — o bump do ?v= é o que publica (immutable por 1 ano).
 */
/* ====================== RESET & VARIABLES ====================== */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
:root, :root[data-theme="escuro"] {
  color-scheme: dark;
  /* aliases legados — pipeline e telas antigas usavam esses nomes e ficavam transparentes */
  --bg-primary: var(--bg-card);
  --bg-secondary: var(--bg-input);
  --border-color: var(--border);
  /* Noite confortável (turno noturno) — neutro, sem brilho duro */
  --bg-body: #0f1115;
  --bg-card: #171a21;
  --bg-card-hover: #1f232c;
  --bg-input: #14171d;
  --bg-sidebar: #131620;
  --bg-header: #131620;
  --border: #262b35;
  --border-light: #333944;
  --text-primary: #f4f6f9;
  --text-secondary: #aab1bd;
  --text-muted: #6f7680;
  --primary: #6f7bff;
  --primary-2: #5563f0;
  --primary-ink: #ffffff;
  --primary-soft: rgba(111,123,255,.16);
  --accent: #f5b400;
}
:root[data-theme="claro"] {
  color-scheme: light;
  /* "Cara Belo Santo" — claro, leve, fino (espelha novo2.belosanto.com.br) */
  --bg-body: #f4f6f9;
  --bg-card: #ffffff;
  --bg-card-hover: #f6f7f9;
  --bg-input: #ffffff;
  --bg-sidebar: #ffffff;
  --bg-header: #ffffff;
  --border: #e6e8ec;
  --border-light: #d4d6dc;
  --text-primary: #14161c;
  --text-secondary: #5f6470;
  --text-muted: #9a9aa6;
  --primary: #2a3aff;
  --primary-2: #202be2;
  --primary-ink: #ffffff;
  --primary-soft: #eef0ff;
  --accent: #f5b400;
}
:root {
  --color-produzido: #3b82f6;
  --color-conferido: #22c55e;
  --color-rejeitado: #ef4444;
  --color-em-carga: #f59e0b;
  --color-despachado: #8b5cf6;
  --color-entregue: #10b981;
  --color-retirado: #06b6d4;
  --color-parado: #6b7280;
  --color-blue: #3b82f6;
  --color-green: #22c55e;
  --color-red: #ef4444;
  --color-yellow: #f59e0b;
  --color-purple: #8b5cf6;
  --color-teal: #10b981;
  --color-cyan: #06b6d4;
  --color-gray: #6b7280;
  --color-orange: #f97316;
  /* Primário/acento de marca (fallback p/ temas sem override) */
  --primary: #2a3aff;
  --primary-2: #202be2;
  --primary-ink: #ffffff;
  --primary-soft: rgba(42,58,255,.10);
  --accent: #f5b400;
  --radius: 12px;
  --radius-sm: 8px;
  --radius-lg: 16px;
  /* Sombras suaves (estilo fino/premium) */
  --shadow: 0 8px 28px rgba(20,22,28,0.10);
  --shadow-sm: 0 1px 2px rgba(20,22,28,0.05), 0 4px 14px rgba(20,22,28,0.05);
  --transition: 0.2s ease;
  --header-h: 56px;
  --sidebar-w: 236px;
  --bottombar-h: 64px;
}
html, body {
  height: 100%; width: 100%;
  font-family: 'Inter', system-ui, -apple-system, sans-serif;
  font-size: 16px;
  line-height: 1.5;
  background: var(--bg-body);
  color: var(--text-primary);
  overflow: hidden;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
}
/* Permite copiar texto em conteudo relevante (codigos, dados, info) */
#content, .selectable, .copy-able,
.responsive-table, .rt-value, .metric-value, .metric-label,
td, th, p, h1, h2, h3, h4, h5, h6 {
  user-select: text;
  -webkit-user-select: text;
}
input, textarea, [contenteditable] {
  user-select: text !important;
  -webkit-user-select: text !important;
}
a { color: var(--color-blue); text-decoration: none; }
input, select, textarea, button { font-family: inherit; font-size: inherit; }
button { cursor: pointer; border: none; background: none; color: inherit; }
input, select, textarea {
  background: var(--bg-input);
  color: var(--text-primary);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px 16px;
  font-size: 16px;
  outline: none;
  width: 100%;
}
input:focus, select:focus, textarea:focus { border-color: var(--color-blue); }
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }

/* ====================== ANIMATIONS ====================== */
@keyframes fadeIn { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: translateY(0); } }
@keyframes fadeOut { from { opacity: 1; } to { opacity: 0; } }
@keyframes slideUp { from { transform: translateY(100%); } to { transform: translateY(0); } }
@keyframes slideDown { from { transform: translateY(-20px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }
@keyframes pulse { 0%,100% { opacity: 1; } 50% { opacity: 0.5; } }
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes successPop { 0% { transform: scale(0.8); opacity: 0; } 50% { transform: scale(1.05); } 100% { transform: scale(1); opacity: 1; } }
@keyframes progressStripe { 0% { background-position: 0 0; } 100% { background-position: 40px 0; } }
@keyframes shake { 0%,100% { transform: translateX(0); } 25% { transform: translateX(-8px); } 75% { transform: translateX(8px); } }
@keyframes blink { 0%,100% { opacity: 1; } 50% { opacity: 0.3; } }
@keyframes pulseGreen { 0%,100% { box-shadow: 0 0 0 0 rgba(34,197,94,0); } 50% { box-shadow: 0 0 0 12px rgba(34,197,94,0.18); } }
@keyframes pulseAlerta { 0%,100% { box-shadow: 0 0 0 0 rgba(239,68,68,0); } 50% { box-shadow: 0 0 0 8px rgba(239,68,68,0.3); } }
.fade-in { animation: fadeIn 0.3s ease; }

/* ====================== LAYOUT ====================== */
#app {
  display: flex;
  flex-direction: column;
  height: 100vh;
  height: 100dvh;
  width: 100vw;
  overflow: hidden;
}

/* ====================== HEADER ====================== */
#header {
  display: none;
  align-items: center;
  gap: 12px;
  padding: 0 16px;
  height: var(--header-h);
  min-height: var(--header-h);
  background: var(--bg-header);
  border-bottom: 1px solid var(--border);
  z-index: 200;
  flex-shrink: 0;
}
#header.visible { display: flex; }
#header .hamburger {
  display: none;
  width: 40px; height: 40px;
  align-items: center; justify-content: center;
  font-size: 24px;
  border-radius: var(--radius-sm);
}
#header .hamburger:active { background: var(--bg-card); }
#header .user-info {
  display: flex;
  align-items: center;
  gap: 10px;
  flex: 1;
  min-width: 0;
}
#header .user-avatar {
  width: 36px; height: 36px;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-weight: 700;
  font-size: 14px;
  flex-shrink: 0;
}
#header .user-name {
  font-weight: 600;
  font-size: 15px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
#header .user-badge {
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.5px;
  flex-shrink: 0;
}
#header .badge-admin { background: var(--primary); color: #fff; }
#header .badge-operador { background: var(--color-blue); color: #fff; }
#header .badge-expedidor { background: var(--color-teal); color: #fff; }
#header .machine-info {
  font-size: 13px;
  color: var(--text-secondary);
  white-space: nowrap;
}
#header .btn-sair {
  padding: 8px 16px;
  border: 1px solid var(--color-red);
  color: var(--color-red);
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 600;
  flex-shrink: 0;
  min-height: 40px;
}
#header .btn-sair:active { background: var(--color-red); color: #fff; }
/* Botão tema */
#header .btn-theme {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text-primary);
  width: 38px; height: 38px;
  border-radius: 8px;
  font-size: 18px;
  margin-right: 6px;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer;
}
#header .btn-theme:hover, #header .btn-theme:active { background: var(--bg-card); }

/* ====================== BODY WRAPPER (sidebar + content) ====================== */
#body-wrap {
  display: flex;
  flex: 1;
  overflow: hidden;
}

/* ====================== SIDEBAR (admin desktop) ====================== */
#sidebar {
  display: none;
  flex-direction: column;
  width: var(--sidebar-w);
  min-width: var(--sidebar-w);
  background: var(--bg-sidebar);
  border-right: 1px solid var(--border);
  padding: 12px 0;
  overflow-y: auto;
  z-index: 150;
}
#sidebar.visible { display: flex; }
#sidebar .sidebar-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 20px;
  font-size: 14px;
  font-weight: 500;
  color: var(--text-secondary);
  transition: var(--transition);
  border-left: 3px solid transparent;
}
#sidebar .sidebar-item:hover { background: var(--bg-card); color: var(--text-primary); }
#sidebar .sidebar-item.active {
  background: rgba(59,130,246,0.1);
  color: var(--color-blue);
  border-left-color: var(--color-blue);
  font-weight: 600;
}
#sidebar .sidebar-item .icon { font-size: 18px; width: 24px; text-align: center; }
#sidebar .sidebar-label {
  padding: 20px 20px 8px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 1px;
  color: var(--text-muted);
  text-transform: uppercase;
}

/* ====================== BOTTOM BAR (mobile nav) ====================== */
#bottombar {
  display: none;
  align-items: center;
  justify-content: space-around;
  height: var(--bottombar-h);
  min-height: var(--bottombar-h);
  background: var(--bg-header);
  border-top: 1px solid var(--border);
  z-index: 200;
  flex-shrink: 0;
}
#bottombar.visible { display: flex; }
#bottombar .tab-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  padding: 6px 12px;
  font-size: 11px;
  color: var(--text-muted);
  min-width: 60px;
  min-height: 48px;
  justify-content: center;
}
#bottombar .tab-item .icon { font-size: 20px; }
#bottombar .tab-item.active { color: var(--color-blue); }

/* ====================== MAIN CONTENT ====================== */
#content {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  -webkit-overflow-scrolling: touch;
  padding: 20px;
}
.screen { animation: fadeIn 0.25s ease; }
/* [31/07] barra das telas fundidas — mesmos tokens do pcp.css */
.fundida-barra{display:flex;gap:6px;align-items:center;flex-wrap:wrap;padding:9px 12px;
  border-bottom:1px solid var(--border);background:var(--panel);margin-bottom:10px;}
.fundida-tit{font-weight:800;font-size:14px;margin-right:8px;}
.fundida-aba{border:1px solid var(--border);background:transparent;color:var(--text-muted,var(--muted));
  padding:7px 13px;border-radius:999px;cursor:pointer;font-size:12.5px;font-weight:700;min-height:36px;}
.fundida-aba:hover{border-color:var(--text-muted,var(--muted));}
.fundida-aba.on{background:var(--color-blue,var(--primary));border-color:transparent;color:#fff;}
@media(max-width:768px){.fundida-aba{min-height:44px;flex:1 1 auto;}}
.screen-title {
  font-size: 23px;
  font-weight: 800;
  letter-spacing: -0.4px;
  color: var(--text-primary);
  line-height: 1.15;
  margin-bottom: 20px;
}

/* ====================== COMMON COMPONENTS ====================== */

/* Cards */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  transition: var(--transition);
}
.card:hover { border-color: var(--border-light); }
.card-grid {
  display: grid;
  gap: 16px;
}
.card-grid-2 { grid-template-columns: repeat(2, 1fr); }
.card-grid-3 { grid-template-columns: repeat(3, 1fr); }
.card-grid-4 { grid-template-columns: repeat(4, 1fr); }

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 12px 24px;
  border-radius: var(--radius-sm);
  font-weight: 600;
  font-size: 15px;
  min-height: 48px;
  transition: var(--transition);
  text-align: center;
  white-space: nowrap;
}
.btn:active { transform: scale(0.97); }
.btn-lg {
  min-height: 64px;
  font-size: 18px;
  font-weight: 700;
  border-radius: var(--radius);
  padding: 16px 32px;
}
.btn-xl {
  min-height: 80px;
  font-size: 20px;
  font-weight: 800;
  border-radius: var(--radius-lg);
  padding: 20px 40px;
}
.btn-block { display: flex; width: 100%; }
.btn-blue { background: var(--color-blue); color: #fff; }
.btn-blue:active { background: #2563eb; }
.btn-green { background: var(--color-green); color: #fff; }
.btn-green:active { background: #16a34a; }
.btn-red { background: var(--color-red); color: #fff; }
.btn-red:active { background: #dc2626; }
.btn-yellow { background: var(--color-yellow); color: #000; }
.btn-yellow:active { background: #d97706; }
.btn-purple { background: var(--color-purple); color: #fff; }
.btn-purple:active { background: #7c3aed; }
.btn-gray { background: var(--color-gray); color: #fff; }
.btn-gray:active { background: #4b5563; }
.btn-orange { background: var(--color-orange); color: #fff; }
.btn-orange:active { background: #ea580c; }
.btn-outline {
  background: transparent;
  border: 2px solid var(--border-light);
  color: var(--text-primary);
}
.btn-outline:active { background: var(--bg-card); }
.btn[disabled] { opacity: 0.4; pointer-events: none; }

/* Badges */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 3px 10px;
  border-radius: 4px;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.3px;
}
.badge-green { background: rgba(34,197,94,0.15); color: var(--color-green); }
.badge-red { background: rgba(239,68,68,0.15); color: var(--color-red); }
.badge-yellow { background: rgba(245,158,11,0.15); color: var(--color-yellow); }
.badge-blue { background: rgba(59,130,246,0.15); color: var(--color-blue); }
.badge-purple { background: rgba(139,92,246,0.15); color: var(--color-purple); }
.badge-gray { background: rgba(107,114,128,0.15); color: var(--color-gray); }
.badge-teal { background: rgba(16,185,129,0.15); color: var(--color-teal); }
.badge-cyan { background: rgba(6,182,212,0.15); color: var(--color-cyan); }

/* Progress bar */
.progress-bar {
  width: 100%;
  height: 12px;
  background: rgba(255,255,255,0.08);
  border-radius: 6px;
  overflow: hidden;
  position: relative;
}
.progress-bar .fill {
  height: 100%;
  border-radius: 6px;
  background: var(--color-blue);
  transition: width 0.5s ease;
  background-image: linear-gradient(45deg, rgba(255,255,255,0.1) 25%, transparent 25%, transparent 50%, rgba(255,255,255,0.1) 50%, rgba(255,255,255,0.1) 75%, transparent 75%);
  background-size: 40px 40px;
  animation: progressStripe 1s linear infinite;
}

/* Tables */
.table-wrap { overflow-x: auto; border-radius: var(--radius); border: 1px solid var(--border); }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th, td { padding: 12px 16px; text-align: left; border-bottom: 1px solid var(--border); white-space: nowrap; }
th { background: var(--bg-card); color: var(--text-secondary); font-weight: 600; font-size: 12px; text-transform: uppercase; letter-spacing: 0.5px; position: sticky; top: 0; z-index: 1; }
tr:hover td { background: rgba(255,255,255,0.02); }

/* Toast */
#toast-container {
  position: fixed;
  top: 16px;
  right: 16px;
  z-index: 10000;
  display: flex;
  flex-direction: column;
  gap: 8px;
  pointer-events: none;
}
.toast {
  padding: 14px 20px;
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-weight: 600;
  color: #fff;
  animation: slideDown 0.3s ease;
  pointer-events: auto;
  max-width: 360px;
  box-shadow: var(--shadow);
}
.toast-success { background: var(--color-green); }
.toast-error { background: var(--color-red); }
.toast-warning { background: var(--color-yellow); color: #000; }
.toast-info { background: var(--color-blue); }

/* Loading */
.loading-overlay {
  position: fixed;
  inset: 0;
  background: rgba(15,15,26,0.85);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 16px;
  z-index: 9999;
}
.spinner {
  width: 48px; height: 48px;
  border: 4px solid var(--border);
  border-top-color: var(--color-blue);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
.loading-text { font-size: 16px; color: var(--text-secondary); }

/* PIN Pad Overlay */
.pin-overlay {
  position: fixed;
  inset: 0;
  background: rgba(15,15,26,0.95);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  z-index: 5000;
  animation: fadeIn 0.2s ease;
}
.pin-title {
  font-size: 20px;
  font-weight: 700;
  margin-bottom: 8px;
}
.pin-dots {
  display: flex;
  gap: 16px;
  margin: 24px 0;
}
.pin-dot {
  width: 20px; height: 20px;
  border-radius: 50%;
  border: 2px solid var(--border-light);
  transition: var(--transition);
}
.pin-dot.filled { background: var(--color-blue); border-color: var(--color-blue); }
.pin-dot.error { background: var(--color-red); border-color: var(--color-red); animation: shake 0.3s ease; }
.pin-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
  max-width: 300px;
  width: 100%;
  padding: 0 20px;
}
.pin-key {
  height: 80px;
  border-radius: var(--radius);
  background: var(--bg-card);
  border: 1px solid var(--border);
  font-size: 28px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: var(--transition);
}
.pin-key:active { background: var(--color-blue); border-color: var(--color-blue); }
.pin-key.pin-back { font-size: 20px; color: var(--color-yellow); }
.pin-key.pin-cancel { font-size: 14px; color: var(--color-red); font-weight: 600; }

/* Fullscreen form */
.fullscreen {
  position: fixed;
  inset: 0;
  background: var(--bg-body);
  z-index: 3000;
  display: flex;
  flex-direction: column;
  animation: slideUp 0.25s ease;
  overflow-y: auto;
}
.fullscreen .fs-header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  background: var(--bg-header);
  border-bottom: 1px solid var(--border);
  min-height: var(--header-h);
  flex-shrink: 0;
}
.fullscreen .fs-header .btn-voltar {
  min-height: 44px;
  padding: 8px 16px;
  border: 1px solid var(--border-light);
  border-radius: var(--radius-sm);
  font-weight: 600;
  font-size: 14px;
}
.fullscreen .fs-header .btn-voltar:active { background: var(--bg-card); }
.fullscreen .fs-header .fs-title {
  font-size: 18px;
  font-weight: 700;
  flex: 1;
}
.fullscreen .fs-body {
  flex: 1;
  padding: 20px;
  display: flex;
  flex-direction: column;
  align-items: center;
}

/* Custom numpad */
.numpad {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  max-width: 340px;
  width: 100%;
  margin-top: 20px;
}
.numpad-key {
  height: 72px;
  border-radius: var(--radius);
  background: var(--bg-card);
  border: 1px solid var(--border);
  font-size: 26px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: var(--transition);
}
.numpad-key:active { background: var(--color-blue); transform: scale(0.95); }
.numpad-key.key-clear { color: var(--color-yellow); font-size: 18px; }
.numpad-key.key-back { color: var(--color-red); font-size: 20px; }
.numpad-display {
  font-size: 48px;
  font-weight: 800;
  text-align: center;
  padding: 20px;
  min-height: 80px;
  font-variant-numeric: tabular-nums;
}

/* Parada banner */
.parada-banner {
  background: rgba(239,68,68,0.15);
  border: 2px solid var(--color-red);
  border-radius: var(--radius);
  padding: 16px;
  display: flex;
  align-items: center;
  gap: 16px;
  margin-bottom: 16px;
  animation: blink 2s infinite;
}
.parada-banner .timer {
  font-size: 32px;
  font-weight: 800;
  color: var(--color-red);
  font-variant-numeric: tabular-nums;
}

/* KPI Cards */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
  margin-bottom: 20px;
}
.kpi-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  text-align: center;
}
.kpi-value {
  font-size: 32px;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
}
.kpi-label {
  font-size: 12px;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-top: 4px;
}

/* Alert cards */
.alert-card {
  border-radius: var(--radius-sm);
  padding: 12px 16px;
  margin-bottom: 8px;
  font-size: 14px;
  font-weight: 500;
  display: flex;
  align-items: center;
  gap: 10px;
}
.alert-critical { background: rgba(239,68,68,0.12); border-left: 4px solid var(--color-red); color: var(--color-red); }
.alert-warning { background: rgba(245,158,11,0.12); border-left: 4px solid var(--color-yellow); color: var(--color-yellow); }
.alert-info { background: rgba(59,130,246,0.12); border-left: 4px solid var(--color-blue); color: var(--color-blue); }

/* Kanban */
.kanban {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
  height: calc(100vh - 180px);
}
.kanban-col {
  display: flex;
  flex-direction: column;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}
.kanban-col-header {
  padding: 12px 16px;
  font-weight: 700;
  font-size: 14px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 8px;
}
.kanban-col-body {
  flex: 1;
  overflow-y: auto;
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.kanban-card {
  background: var(--bg-body);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px;
  font-size: 13px;
}

/* Signature canvas */
.signature-box {
  border: 2px dashed var(--border-light);
  border-radius: var(--radius);
  background: var(--bg-input);
  touch-action: none;
}

/* QR Input */
.qr-input-wrap {
  position: relative;
  margin-bottom: 20px;
}
.qr-input {
  font-size: 20px;
  padding: 16px 20px 16px 52px;
  text-align: center;
  font-weight: 600;
  letter-spacing: 1px;
}
.qr-input-icon {
  position: absolute;
  left: 16px;
  top: 50%;
  transform: translateY(-50%);
  font-size: 24px;
  color: var(--text-muted);
}

/* Result card (conferencia) */
.result-card {
  padding: 20px;
  border-radius: var(--radius);
  margin: 16px 0;
  animation: successPop 0.3s ease;
  font-size: 16px;
}
.result-ok { background: rgba(34,197,94,0.15); border: 2px solid var(--color-green); }
.result-warn { background: rgba(245,158,11,0.15); border: 2px solid var(--color-yellow); }
.result-error { background: rgba(239,68,68,0.15); border: 2px solid var(--color-red); }

/* Volume checklist */
.volume-list {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin: 12px 0;
}
.volume-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 16px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-weight: 600;
  min-width: 120px;
}
.volume-item.checked { border-color: var(--color-green); background: rgba(34,197,94,0.1); }
.volume-check { font-size: 18px; }

/* Charts (CSS only) */
.chart-bar-wrap {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  height: 200px;
  padding: 0 8px;
}
.chart-bar-col {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  height: 100%;
  justify-content: flex-end;
}
.chart-bar {
  width: 100%;
  max-width: 48px;
  border-radius: 4px 4px 0 0;
  transition: height 0.5s ease;
  min-height: 4px;
}
.chart-bar-label {
  font-size: 11px;
  color: var(--text-muted);
  text-align: center;
}
.chart-bar-value {
  font-size: 12px;
  font-weight: 700;
}

/* Tabs */
.tabs {
  display: flex;
  gap: 4px;
  margin-bottom: 20px;
  border-bottom: 1px solid var(--border);
  overflow-x: auto;
}
.tab-btn {
  padding: 10px 20px;
  font-size: 14px;
  font-weight: 600;
  color: var(--text-muted);
  border-bottom: 2px solid transparent;
  white-space: nowrap;
  min-height: 48px;
}
.tab-btn.active { color: var(--color-blue); border-bottom-color: var(--color-blue); }
.tab-btn:hover { color: var(--text-primary); }

/* Checkbox */
.chk {
  display: flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
  min-height: 48px;
}
.chk-box {
  width: 22px; height: 22px;
  border: 2px solid var(--border-light);
  border-radius: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: var(--transition);
  font-size: 14px;
}
.chk.checked .chk-box { background: var(--color-blue); border-color: var(--color-blue); }

/* Select dropdown styled */
select {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' fill='%2394a3b8' viewBox='0 0 16 16'%3E%3Cpath d='M8 12L2 6h12z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 14px center;
  padding-right: 36px;
}
/* Options do select: força fundo e texto pra evitar branco-no-branco no Windows/alguns browsers */
select option, select optgroup {
  background-color: var(--bg-card);
  color: var(--text-primary);
}
select option:checked, select option:hover {
  background-color: var(--bg-card-hover);
}
/* Datepicker e color inputs no Firefox/Chrome respeitam color-scheme */
input[type="date"], input[type="datetime-local"], input[type="time"], input[type="month"] {
  color-scheme: dark;
}

/* Mobile overlay sidebar */
.sidebar-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.6);
  z-index: 4000;
  display: none;
}
.sidebar-overlay.visible { display: block; }
.sidebar-mobile {
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  width: min(85vw, 320px);
  background: var(--bg-sidebar);
  border-right: 1px solid var(--border);
  z-index: 4001;
  transform: translateX(-100%);
  transition: transform 0.3s ease;
  padding: 0;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  display: flex;
  flex-direction: column;
  padding-top: env(safe-area-inset-top, 0px);
  padding-bottom: env(safe-area-inset-bottom, 0px);
}
.sidebar-mobile.open { transform: translateX(0); box-shadow: 4px 0 24px rgba(0,0,0,0.4); }
.sidebar-mobile .sidebar-label {
  padding: 16px 20px 8px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 1px;
  color: var(--text-muted);
  text-transform: uppercase;
  border-bottom: 1px solid var(--border);
  margin-bottom: 6px;
}
.sidebar-mobile .sidebar-item {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 14px 20px;
  font-size: 15px;
  font-weight: 500;
  color: var(--text-secondary);
  border-left: 3px solid transparent;
  background: none;
  width: 100%;
  text-align: left;
  cursor: pointer;
  min-height: 48px;
  transition: background 0.15s ease;
}
.sidebar-mobile .sidebar-item:active { background: var(--bg-card); }
.sidebar-mobile .sidebar-item.active {
  background: rgba(59,130,246,0.12);
  color: var(--color-blue);
  border-left-color: var(--color-blue);
  font-weight: 700;
}
.sidebar-mobile .sidebar-item .icon {
  font-size: 18px;
  width: 28px;
  text-align: center;
  flex-shrink: 0;
}
.sidebar-mobile-header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  background: var(--bg-header);
}
.sidebar-mobile-header .sm-avatar {
  width: 40px; height: 40px;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-weight: 800;
  font-size: 16px;
  color: #fff;
  flex-shrink: 0;
}
.sidebar-mobile-header .sm-info { flex: 1; min-width: 0; }
.sidebar-mobile-header .sm-name {
  font-weight: 700;
  font-size: 14px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.sidebar-mobile-header .sm-role {
  font-size: 11px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}
.sidebar-mobile-header .sm-close {
  background: var(--bg-card);
  border: 1px solid var(--border);
  width: 36px; height: 36px;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 18px;
  color: var(--text-secondary);
  cursor: pointer;
  flex-shrink: 0;
}
.sidebar-mobile-header .sm-close:active { background: var(--bg-card-hover); }

/* ====================== MODAL OVERLAY BASE (faltava — FIX 2026-05-13) ====================== */
/* Sem essa regra os modais novos (transferência/devolução/recebimento/pedidos-abertos) ficam invisíveis */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.7);
  z-index: 9999;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 20px;
  overflow-y: auto;
}
.modal-overlay > .modal {
  background: var(--card);
  border-radius: 12px;
  width: 100%;
  max-width: 600px;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  box-shadow: 0 8px 24px rgba(0,0,0,0.5);
  margin: auto 0;
}
.modal-title {
  padding: 16px 20px;
  font-size: 18px;
  font-weight: 700;
  border-bottom: 1px solid var(--border);
  color: var(--text);
}
.modal-body {
  padding: 16px 20px;
  overflow-y: auto;
  flex: 1;
  color: var(--text);
}
.modal-footer {
  padding: 12px 20px;
  border-top: 1px solid var(--border);
  display: flex;
  gap: 8px;
  justify-content: flex-end;
  flex-wrap: wrap;
}

/* ====================== RESPONSIVE - MOBILE FIRST (refeito 2026-05-12) ====================== */

/* Bloqueia overflow horizontal global e ajusta scroll iOS */
html, body { overflow-x: hidden; max-width: 100vw; }
#content { max-width: 100vw; }

/* MOBILE (<=767px) */
@media (max-width: 767px) {
  /* Conteudo: padding base; padding-bottom extra so se bottombar visivel */
  #content {
    padding: 12px;
    padding-bottom: calc(env(safe-area-inset-bottom, 0px) + 12px);
  }
  /* :has() detecta bottombar ativa e adiciona espaco extra */
  body:has(#bottombar.visible) #content {
    padding-bottom: calc(var(--bottombar-h) + env(safe-area-inset-bottom, 0px) + 16px);
  }
  .screen-title { font-size: 18px; margin-bottom: 12px; }

  /* Header compacto */
  #header { padding: 0 10px; gap: 8px; }
  #header .hamburger { display: flex; }
  #header .machine-info { display: none; }
  #header .user-name { font-size: 13px; }
  #header .user-badge { font-size: 10px; padding: 2px 6px; }
  #header .btn-sair { padding: 6px 12px; font-size: 12px; min-height: 36px; }

  /* Bottombar fixa no rodape + safe-area iPhone */
  #bottombar.visible {
    position: fixed;
    left: 0; right: 0; bottom: 0;
    padding-bottom: env(safe-area-inset-bottom, 0px);
    box-shadow: 0 -2px 12px rgba(0,0,0,0.4);
    z-index: 200;
  }
  #bottombar .tab-item {
    flex: 1;
    min-width: 0;
    padding: 6px 4px;
    font-size: 10px;
    text-align: center;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }
  #bottombar .tab-item .icon { font-size: 22px; }

  /* Grids: empilhar */
  .card-grid-2, .card-grid-3, .card-grid-4 { grid-template-columns: 1fr !important; gap: 12px; }
  .kpi-grid { grid-template-columns: repeat(2, 1fr) !important; gap: 10px; }
  .kanban { grid-template-columns: 1fr !important; height: auto !important; }

  /* Tabelas: fonte menor + scroll horizontal */
  .table-wrap, .table-scroll {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    font-size: 13px;
  }
  table { min-width: max-content; }
  th, td { padding: 8px 10px; white-space: nowrap; }

  /* Botoes consistentes (toque 44x44 minimo) */
  .btn { min-height: 44px; padding: 10px 16px; font-size: 14px; }
  .btn-lg { min-height: 56px; font-size: 16px; }
  .btn-sm { min-height: 36px; padding: 6px 12px; font-size: 13px; }
  .numpad-key { height: 64px; font-size: 24px; }
  .pin-key { height: 70px; font-size: 26px; }

  /* Inputs maiores e legiveis */
  input, select, textarea {
    font-size: 16px;
    min-height: 44px;
    padding: 10px 14px;
  }

  /* Modais: full-screen em mobile */
  .modal-overlay > div:not(.modal-no-fullscreen),
  .modal-content,
  .modal-card {
    width: 100% !important;
    max-width: 100% !important;
    max-height: 100vh !important;
    border-radius: 0 !important;
    margin: 0 !important;
    box-shadow: none !important;
  }

  /* Form rows: empilhar campos */
  .form-row, .row-2, .row-3, .row-4 {
    grid-template-columns: 1fr !important;
    flex-direction: column !important;
  }

  /* Utility */
  .desktop-only { display: none !important; }
  .hide-on-mobile { display: none !important; }
}

/* TABLET PORTRAIT (768-1023px) */
@media (min-width: 768px) and (max-width: 1023px) {
  .card-grid-4 { grid-template-columns: repeat(2, 1fr); }
  .card-grid-3 { grid-template-columns: repeat(2, 1fr); }
  .kpi-grid { grid-template-columns: repeat(3, 1fr); }
}

/* DESKTOP: esconde bottombar */
@media (min-width: 1024px) {
  #bottombar { display: none !important; }
  .mobile-only { display: none !important; }
}

/* Esconde sidebar abaixo de 1024 (use hamburger + drawer) */
@media (max-width: 1023px) {
  #sidebar { display: none !important; }
  /* body-wrap sem sidebar fica 100% */
  #body-wrap > #content { width: 100%; }
}

/* PRINT */
@media print {
  #header, #sidebar, #sidebar-mobile, #sidebar-overlay, #bottombar, #toast-container { display: none !important; }
  body { overflow: auto !important; }
  #content { overflow: visible !important; padding: 0 !important; }
  .card { break-inside: avoid; }
}

/* ====================== UTILITIES MOBILE-FIRST ====================== */

/* Stack vertical no mobile, horizontal desktop */
.mobile-stack { display: flex; flex-direction: column; gap: 12px; }
@media (min-width: 768px) {
  .mobile-stack { flex-direction: row; align-items: stretch; }
}

/* Card mobile-first */
.card-mobile {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px;
  width: 100%;
}
@media (min-width: 768px) {
  .card-mobile { padding: 18px; }
}

/* Botao full-width mobile, auto desktop */
.btn-mobile-full {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  min-height: 48px;
  padding: 12px 16px;
  font-size: 15px;
  font-weight: 600;
  border-radius: var(--radius-sm);
  gap: 8px;
  background: var(--color-blue);
  color: #fff;
  transition: var(--transition);
}
.btn-mobile-full:active { transform: scale(0.97); }
.btn-mobile-full.btn-mf-secondary { background: var(--bg-input); color: var(--text-primary); border: 1px solid var(--border); }
.btn-mobile-full.btn-mf-success { background: var(--color-green); }
.btn-mobile-full.btn-mf-danger { background: var(--color-red); }
.btn-mobile-full.btn-mf-warn { background: var(--color-orange); }
@media (min-width: 768px) {
  .btn-mobile-full { width: auto; min-width: 160px; }
}

/* Input padronizado mobile */
.input-mobile, input.input-mobile, select.input-mobile, textarea.input-mobile {
  font-size: 16px;
  min-height: 48px;
  padding: 12px 14px;
  border-radius: var(--radius-sm);
  background: var(--bg-input);
  color: var(--text-primary);
  border: 1px solid var(--border);
  width: 100%;
}
.input-mobile:focus { border-color: var(--color-blue); outline: none; }

/* Grid de metricas/KPIs */
.metric-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
}
@media (min-width: 768px) {
  .metric-grid { grid-template-columns: repeat(4, 1fr); gap: 14px; }
}
.metric-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px;
  text-align: center;
}
.metric-card .metric-value {
  font-size: 22px;
  font-weight: 800;
  color: var(--text-primary);
  font-variant-numeric: tabular-nums;
  line-height: 1.1;
}
.metric-card .metric-label {
  font-size: 11px;
  text-transform: uppercase;
  color: var(--text-secondary);
  letter-spacing: 0.5px;
  margin-top: 4px;
}
.metric-card.metric-blue .metric-value { color: var(--color-blue); }
.metric-card.metric-green .metric-value { color: var(--color-green); }
.metric-card.metric-red .metric-value { color: var(--color-red); }
.metric-card.metric-orange .metric-value { color: var(--color-orange); }
.metric-card.metric-purple .metric-value { color: var(--color-purple); }
@media (min-width: 768px) {
  .metric-card { padding: 18px; }
  .metric-card .metric-value { font-size: 28px; }
}

/* Tabela responsiva (mobile=cards, desktop=table) */
.responsive-table { width: 100%; display: block; }
.responsive-table .rt-row {
  display: flex;
  flex-direction: column;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px;
  margin-bottom: 8px;
  gap: 4px;
}
.responsive-table .rt-cell {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 13px;
  gap: 8px;
}
.responsive-table .rt-cell .rt-label {
  color: var(--text-secondary);
  font-weight: 500;
  font-size: 12px;
  flex-shrink: 0;
}
.responsive-table .rt-cell .rt-value {
  color: var(--text-primary);
  font-weight: 600;
  text-align: right;
  word-break: break-word;
}
.responsive-table .rt-cell.rt-main {
  font-size: 15px;
  font-weight: 700;
  padding-bottom: 6px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 4px;
}
.responsive-table .rt-cell.rt-main .rt-value { font-size: 16px; }
.responsive-table .rt-actions {
  display: flex;
  gap: 8px;
  margin-top: 8px;
  flex-wrap: wrap;
}
.responsive-table .rt-actions > * { flex: 1; min-width: 100px; }
@media (min-width: 768px) {
  .responsive-table { display: table; border-collapse: collapse; }
  .responsive-table .rt-row {
    display: table-row;
    background: transparent;
    border: none;
    border-bottom: 1px solid var(--border);
    border-radius: 0;
    padding: 0;
    margin: 0;
  }
  .responsive-table .rt-row:hover { background: var(--bg-card-hover); }
  .responsive-table .rt-cell {
    display: table-cell;
    padding: 12px 14px;
    vertical-align: middle;
    font-size: 14px;
    justify-content: flex-start;
    text-align: left;
  }
  .responsive-table .rt-cell .rt-label { display: none; }
  .responsive-table .rt-cell .rt-value { text-align: left; font-weight: 500; }
  .responsive-table .rt-cell.rt-main {
    font-size: 14px;
    font-weight: 600;
    padding-bottom: 12px;
    border-bottom: 0;
    margin-bottom: 0;
  }
  .responsive-table .rt-cell.rt-main .rt-value { font-size: 14px; }
  .responsive-table .rt-actions {
    display: table-cell;
    margin-top: 0;
    padding: 12px 14px;
    width: 1%;
    white-space: nowrap;
  }
  .responsive-table .rt-actions > * { flex: 0 0 auto; min-width: 0; }
}

/* Page header mobile (titulo + actions row) */
.page-head-mobile {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-bottom: 14px;
}
.page-head-mobile .page-title {
  font-size: 18px;
  font-weight: 700;
  line-height: 1.2;
}
.page-head-mobile .page-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}
.page-head-mobile .page-actions > * { flex: 1; min-width: 120px; }
@media (min-width: 768px) {
  .page-head-mobile {
    flex-direction: row;
    align-items: center;
    justify-content: space-between;
  }
  .page-head-mobile .page-title { font-size: 22px; }
  .page-head-mobile .page-actions > * { flex: 0 0 auto; }
}

/* Show/hide por breakpoint */
.show-mobile { display: block; }
.hide-mobile { display: none; }
@media (min-width: 768px) {
  .show-mobile { display: none !important; }
  .hide-mobile { display: block; }
}

/* Safe-area iPhone (notch) */
@supports (padding: env(safe-area-inset-top)) {
  #header.visible {
    padding-top: env(safe-area-inset-top);
    height: calc(var(--header-h) + env(safe-area-inset-top));
    min-height: calc(var(--header-h) + env(safe-area-inset-top));
  }
}

/* Scroll suave em containers */
.scroll-touch { -webkit-overflow-scrolling: touch; overflow-y: auto; }

/* Visual: bottombar drop-shadow + active highlight melhor */
#bottombar .tab-item.active {
  position: relative;
}
#bottombar .tab-item.active::before {
  content: '';
  position: absolute;
  top: 0; left: 30%; right: 30%;
  height: 3px;
  background: var(--color-blue);
  border-radius: 0 0 3px 3px;
}

/* ====================== DEFENSIVE MOBILE RULES (overrides inline styles) ====================== */
@media (max-width: 767px) {
  /* Qualquer container com max-width fixo vira fluido (cobre 300-1400) */
  [style*="max-width:300px"], [style*="max-width: 300px"],
  [style*="max-width:340px"], [style*="max-width: 340px"],
  [style*="max-width:400px"], [style*="max-width: 400px"],
  [style*="max-width:420px"], [style*="max-width: 420px"],
  [style*="max-width:440px"], [style*="max-width: 440px"],
  [style*="max-width:460px"], [style*="max-width: 460px"],
  [style*="max-width:480px"], [style*="max-width: 480px"],
  [style*="max-width:500px"], [style*="max-width: 500px"],
  [style*="max-width:520px"], [style*="max-width: 520px"],
  [style*="max-width:560px"], [style*="max-width: 560px"],
  [style*="max-width:600px"], [style*="max-width: 600px"],
  [style*="max-width:640px"], [style*="max-width: 640px"],
  [style*="max-width:680px"], [style*="max-width: 680px"],
  [style*="max-width:700px"], [style*="max-width: 700px"],
  [style*="max-width:720px"], [style*="max-width: 720px"],
  [style*="max-width:760px"], [style*="max-width: 760px"],
  [style*="max-width:780px"], [style*="max-width: 780px"],
  [style*="max-width:800px"], [style*="max-width: 800px"],
  [style*="max-width:900px"], [style*="max-width: 900px"],
  [style*="max-width:1000px"], [style*="max-width: 1000px"],
  [style*="max-width:1100px"], [style*="max-width: 1100px"],
  [style*="max-width:1200px"], [style*="max-width: 1200px"],
  [style*="max-width:1400px"], [style*="max-width: 1400px"] {
    max-width: 100% !important;
  }

  /* Grid template com tracks px (multi-coluna fixa de tabela) - vira 1fr */
  [style*="grid-template-columns:60px"],
  [style*="grid-template-columns:80px"],
  [style*="grid-template-columns:90px"],
  [style*="grid-template-columns:100px"],
  [style*="grid-template-columns: 60px"],
  [style*="grid-template-columns: 80px"],
  [style*="grid-template-columns: 90px"],
  [style*="grid-template-columns: 100px"] {
    grid-template-columns: 1fr !important;
  }

  /* grid 1fr 1fr (paired stats) - mantem 2cols mas com gap menor */
  [style*="grid-template-columns:1fr 1fr"]:not([style*="!important"]),
  [style*="grid-template-columns: 1fr 1fr"]:not([style*="!important"]) {
    gap: 8px !important;
  }

  /* Qualquer width fixo desktop vira 100% */
  [style*="width:480px"],
  [style*="width:600px"],
  [style*="width:800px"],
  [style*="width: 480px"],
  [style*="width: 600px"],
  [style*="width: 800px"] {
    width: 100% !important;
  }

  /* Grids com colunas px ou repeat fixo viram 1 coluna */
  [style*="grid-template-columns: repeat(3"],
  [style*="grid-template-columns: repeat(4"],
  [style*="grid-template-columns: repeat(5"],
  [style*="grid-template-columns: repeat(6"],
  [style*="grid-template-columns:repeat(3"],
  [style*="grid-template-columns:repeat(4"],
  [style*="grid-template-columns:repeat(5"],
  [style*="grid-template-columns:repeat(6"] {
    grid-template-columns: 1fr !important;
  }
  [style*="grid-template-columns: repeat(2"],
  [style*="grid-template-columns:repeat(2"] {
    grid-template-columns: repeat(2, 1fr) !important;
  }

  /* Grids com colunas em px (200px 1fr, 100px 200px, etc) - forca 1fr */
  [style*="grid-template-columns: 200px"],
  [style*="grid-template-columns: 240px"],
  [style*="grid-template-columns: 280px"],
  [style*="grid-template-columns: 300px"],
  [style*="grid-template-columns: 350px"],
  [style*="grid-template-columns: 400px"],
  [style*="grid-template-columns:200px"],
  [style*="grid-template-columns:240px"],
  [style*="grid-template-columns:280px"],
  [style*="grid-template-columns:300px"],
  [style*="grid-template-columns:350px"],
  [style*="grid-template-columns:400px"] {
    grid-template-columns: 1fr !important;
  }

  /* Flex rows com gap grande viram coluna em mobile (header de telas, action rows) */
  .flex-row-mobile-stack {
    flex-direction: column !important;
    align-items: stretch !important;
  }

  /* Botoes em row de acoes ganham wrap */
  [style*="display:flex"][style*="gap:"] > .btn,
  [style*="display: flex"][style*="gap:"] > .btn {
    flex: 1 1 auto;
    min-width: 0;
  }

  /* Card padding interno reduz em mobile */
  .card { padding: 12px; }

  /* Inputs com style inline tambem ganham font-size 16px */
  input[style], select[style], textarea[style] {
    font-size: 16px !important;
  }

  /* Wrap geral via classe */
  .table-wrap, .table-scroll, .scroll-x-mobile, .table-wrap-auto {
    overflow-x: auto !important;
    -webkit-overflow-scrolling: touch;
    max-width: 100%;
  }
  /* Tabelas em wrappers automaticos mantem display:table */
  .table-wrap-auto table {
    width: auto !important;
    min-width: max-content;
    border-collapse: collapse;
    white-space: nowrap;
  }
  /* Indicador visual de scroll horizontal disponivel */
  .table-wrap-auto {
    position: relative;
    border: 1px solid var(--border);
    border-radius: 6px;
    margin-bottom: 8px;
  }
  .table-wrap-auto::after {
    content: '←” arraste lateralmente';
    display: block;
    text-align: center;
    font-size: 10px;
    color: var(--text-muted);
    padding: 4px;
    background: rgba(59,130,246,0.06);
    border-top: 1px dashed var(--border);
    opacity: 0.7;
  }

  /* Forca min-width:0 em flex children pra impedir overflow horizontal */
  [style*="display:flex"] > *:not(.no-shrink),
  [style*="display: flex"] > *:not(.no-shrink) {
    min-width: 0;
  }

  /* Titulos gigantes da tela (font-size > 24 inline) reduzem */
  [style*="font-size:24px"], [style*="font-size: 24px"] { font-size: 18px !important; }
  [style*="font-size:28px"], [style*="font-size: 28px"] { font-size: 20px !important; }
  [style*="font-size:32px"], [style*="font-size: 32px"] { font-size: 22px !important; }
  [style*="font-size:36px"], [style*="font-size: 36px"] { font-size: 24px !important; }
  [style*="font-size:48px"], [style*="font-size: 48px"] { font-size: 32px !important; }

  /* Padding inline gigante (24, 30, 32, 40, 48) reduz no mobile */
  [style*="padding:24px"], [style*="padding: 24px"] { padding: 14px !important; }
  [style*="padding:30px"], [style*="padding: 30px"] { padding: 14px !important; }
  [style*="padding:32px"], [style*="padding: 32px"] { padding: 14px !important; }
  [style*="padding:40px"], [style*="padding: 40px"] { padding: 16px !important; }

  /* Inline gap grande reduz */
  [style*="gap:20px"], [style*="gap: 20px"] { gap: 10px !important; }
  [style*="gap:24px"], [style*="gap: 24px"] { gap: 12px !important; }
  [style*="gap:30px"], [style*="gap: 30px"] { gap: 12px !important; }

  /* Modais com inset:0 mas padding inline gigante */
  [style*="position:fixed"][style*="inset:0"][style*="padding:20px"],
  [style*="position: fixed"][style*="inset: 0"][style*="padding: 20px"] {
    padding: 0 !important;
  }
  /* Cards dentro de modais full-screen mobile */
  [style*="position:fixed"][style*="inset:0"] > .card,
  [style*="position: fixed"][style*="inset: 0"] > .card,
  [style*="z-index:9999"] > .card,
  [style*="z-index: 9999"] > .card {
    width: 100% !important;
    max-width: 100% !important;
    height: 100% !important;
    max-height: 100% !important;
    border-radius: 0 !important;
    overflow-y: auto !important;
  }

  /* Botoes-row "justify-content:flex-end" empilham e ficam largos */
  [style*="justify-content:flex-end"][style*="gap"],
  [style*="justify-content: flex-end"][style*="gap"] {
    justify-content: stretch !important;
    flex-wrap: wrap !important;
  }
  [style*="justify-content:flex-end"][style*="gap"] > .btn,
  [style*="justify-content: flex-end"][style*="gap"] > .btn {
    flex: 1 1 auto;
  }

  /* QR Input (conferencia/carga/retira) */
  .qr-input {
    font-size: 18px !important;
    padding: 14px 14px 14px 44px !important;
  }
  .qr-input-icon { font-size: 20px; left: 14px; }

  /* Modais com classe .modal-overlay */
  .modal-overlay { padding: 0 !important; }
  .modal-overlay > .modal,
  .modal-overlay > div:not(.toast):not([class*="toast"]) {
    max-width: 100% !important;
    width: 100% !important;
    max-height: 100vh !important;
    border-radius: 0 !important;
    min-height: 100vh !important;
    overflow-y: auto !important;
  }

  /* Tabs do motorista (e similares) */
  .tab-btn-mob { font-size: 13px !important; padding: 10px 6px !important; }

  /* Conferencia scan area */
  .conf-scan-area { padding: 14px !important; }
  .conf-scan-icon { font-size: 36px !important; }

  /* Cards de carga/pedido (border-left grosso, mantem) */
  .card { padding: 12px; border-radius: 10px; }
  .card[style*="border-left"] { padding: 12px; }

  /* Volumes list em carga */
  .volume-list { display: grid; grid-template-columns: repeat(2, 1fr); gap: 6px; }
  .volume-item { font-size: 13px; padding: 8px; }

  /* Retira pedido card */
  .retira-pedido-card { padding: 12px; }

  /* Botoes XL em pedidos abertos viram large */
  .btn-xl { font-size: 16px !important; padding: 14px !important; min-height: 52px !important; }
  .btn-block { display: flex; width: 100%; }

  /* Carga order */
  .carga-order { padding: 12px; }
  .carga-order .co-header { flex-wrap: wrap; gap: 6px; }

  /* Toast container - subir pra ficar acima da bottombar */
  #toast-container {
    bottom: calc(var(--bottombar-h) + env(safe-area-inset-bottom, 0px) + 12px) !important;
  }

  /* ============ ADMIN SCREENS ============ */

  /* Pipeline: colunas Kanban viram cards verticais empilhados */
  [style*="grid-template-columns:repeat(auto-fit,minmax(220px"],
  [style*="grid-template-columns: repeat(auto-fit, minmax(220px"] {
    grid-template-columns: 1fr !important;
  }

  /* Kanban classico */
  .kanban-col { min-height: auto !important; }
  .kanban-col-body { max-height: 360px; }
  .kanban-card { font-size: 12px; padding: 10px; }

  /* KPI grid: 2 cols em mobile */
  .kpi-grid { grid-template-columns: repeat(2, 1fr) !important; gap: 8px; }
  .kpi-card { padding: 12px 8px; }
  .kpi-value { font-size: 22px !important; }
  .kpi-label { font-size: 11px !important; }

  /* Dashboard machines */
  .dash-machine { min-height: auto !important; padding: 12px; }

  /* Tabelas admin grandes: forca scroll horizontal */
  .table-wrap {
    overflow-x: auto !important;
    -webkit-overflow-scrolling: touch;
    border-radius: var(--radius-sm);
  }
  .table-wrap table { min-width: 600px; }

  /* Filtros admin (data filters etc) */
  .filter-row, .filtros-row {
    flex-direction: column !important;
    align-items: stretch !important;
    gap: 8px !important;
  }
  .filter-row > *, .filtros-row > * { width: 100% !important; }

  /* Analytics: graficos limitados */
  canvas { max-width: 100% !important; height: auto !important; }
  .chart-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }

  /* Tabela admin OPs / etiquetas */
  .ops-table, .etiquetas-table {
    display: block;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }

  /* Badges em mobile menores */
  .badge { font-size: 10px !important; padding: 2px 6px !important; }

  /* Pulse-dot em mobile */
  .pulse-dot { width: 8px; height: 8px; }

  /* Forms admin (inputs verticais) */
  .form-grid {
    grid-template-columns: 1fr !important;
  }

  /* Reservas/Grupos/Simulacao - cards compactos */
  .reserva-card, .grupo-row, .simul-card { padding: 12px !important; }

  /* Pipeline column header compacta */
  [style*="font-weight:800;font-size:13px"],
  [style*="font-weight: 800; font-size: 13px"] {
    font-size: 12px !important;
  }

  /* Modal-overlay z-index=9999 do wizard */
  #wizard-modal {
    padding: 0 !important;
    align-items: flex-start !important;
  }
  #wizard-modal > div {
    max-width: 100% !important;
    width: 100% !important;
    margin: 0 !important;
    border-radius: 0 !important;
    min-height: 100vh !important;
  }
  #wizard-content {
    padding: 14px !important;
  }
  #wizard-content table {
    display: block;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }
}

/* ============ TABLET (768-1023): admin nav drawer + densidade media ============ */
@media (min-width: 768px) and (max-width: 1023px) {
  /* Pipeline 2 colunas */
  [style*="grid-template-columns:repeat(auto-fit,minmax(220px"],
  [style*="grid-template-columns: repeat(auto-fit, minmax(220px"] {
    grid-template-columns: repeat(2, 1fr) !important;
  }
  /* Header com hamburger pra abrir sidebar */
  #header .hamburger { display: flex !important; }
}

/* ====================== EXTRA CSS - OPERATOR BUTTONS ====================== */
.op-btn-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-top: 8px;
}
.op-action-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 96px;
  border-radius: var(--radius-lg);
  font-weight: 700;
  font-size: 16px;
  color: #fff;
  border: none;
  transition: var(--transition);
  position: relative;
  overflow: hidden;
}
.op-action-btn:active { transform: scale(0.95); }
.op-action-btn::after {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(135deg, rgba(255,255,255,0.1) 0%, transparent 50%);
  pointer-events: none;
}
.op-action-btn.btn-finalizar {
  background: var(--color-green);
  min-height: 110px;
  font-size: 18px;
  box-shadow: 0 4px 20px rgba(34,197,94,0.3);
}
.op-action-btn.btn-finalizar:active { background: #16a34a; }
.op-action-btn.btn-abastecer { background: var(--color-blue); }
.op-action-btn.btn-abastecer:active { background: #2563eb; }
.op-action-btn.btn-desperdicio { background: var(--color-orange); }
.op-action-btn.btn-desperdicio:active { background: #ea580c; }
.op-action-btn.btn-parada { background: var(--color-red); }
.op-action-btn.btn-parada:active { background: #dc2626; }
.op-action-btn.btn-retomar { background: var(--color-green); animation: pulse 2s infinite; }
.op-action-btn .btn-icon { font-size: 28px; }
.op-action-btn[disabled] { opacity: 0.35; pointer-events: none; }

/* ====================== EXTRA CSS - MACHINE CARDS ====================== */
.machine-card {
  position: relative;
  padding: 20px;
  border-radius: var(--radius-lg);
  background: var(--bg-card);
  border: 2px solid var(--border);
  text-align: center;
  min-height: 140px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  cursor: pointer;
  transition: var(--transition);
}
.machine-card:active { transform: scale(0.97); }
.machine-card.available { border-color: var(--color-green); }
.machine-card.available:hover { background: rgba(34,197,94,0.05); }
.machine-card.in-use { border-color: var(--color-yellow); opacity: 0.7; cursor: not-allowed; }
.machine-card.stopped { border-color: var(--color-red); opacity: 0.6; cursor: not-allowed; }
.machine-card .mc-icon { font-size: 36px; }
.machine-card .mc-name { font-size: 17px; font-weight: 700; }
.machine-card .mc-status {
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

/* ====================== EXTRA CSS - LOGIN GRID ====================== */
.login-container {
  max-width: 580px;
  margin: 0 auto;
  padding-top: 10vh;
}
.login-logo {
  text-align: center;
  margin-bottom: 40px;
}
.login-logo h1 {
  font-size: 42px;
  font-weight: 800;
  letter-spacing: -.5px;
  background: linear-gradient(135deg, var(--primary), var(--primary-2));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}
.login-logo p {
  font-size: 14px;
  color: var(--text-muted);
  margin-top: 4px;
}
.operator-card {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 16px 20px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  cursor: pointer;
  transition: var(--transition);
  min-height: 80px;
}
.operator-card:active { transform: scale(0.97); background: var(--bg-card-hover); }
.operator-card:hover { border-color: var(--border-light); }
.operator-card .op-avatar {
  width: 52px;
  height: 52px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 22px;
  font-weight: 800;
  flex-shrink: 0;
  color: #fff;
}
.operator-card .op-name { font-size: 17px; font-weight: 700; }
.operator-card .op-role { font-size: 12px; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.5px; }

/* ====================== EXTRA CSS - DASHBOARD MACHINE CARD ====================== */
.dash-machine {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  position: relative;
  overflow: hidden;
}
.dash-machine::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 3px;
}
.dash-machine.dm-available::before { background: var(--color-green); }
.dash-machine.dm-inuse::before { background: var(--color-yellow); }
.dash-machine.dm-stopped::before { background: var(--color-red); }
.dash-machine .dm-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 10px;
}
.dash-machine .dm-name { font-weight: 700; font-size: 15px; }
.dash-machine .dm-operator {
  font-size: 13px;
  color: var(--text-secondary);
  display: flex;
  align-items: center;
  gap: 4px;
}
.dash-machine .dm-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 13px;
  color: var(--text-muted);
  margin-top: 8px;
}

/* ====================== EXTRA CSS - FILA TABLE ROWS ====================== */
.fila-row { cursor: pointer; }
.fila-row:hover td { background: rgba(59,130,246,0.04); }
.fila-row.selected td { background: rgba(59,130,246,0.08); }
.fila-row .fila-chk {
  width: 24px; height: 24px;
  border: 2px solid var(--border-light);
  border-radius: 4px;
  display: flex; align-items: center; justify-content: center;
  transition: var(--transition);
  font-size: 14px; color: #fff;
}
.fila-row.selected .fila-chk { background: var(--color-blue); border-color: var(--color-blue); }

/* ====================== EXTRA CSS - OP DETAIL EXPAND ====================== */
.op-card-detail {
  border-top: 1px solid var(--border);
  padding: 16px;
  background: rgba(0,0,0,0.15);
  animation: fadeIn 0.2s ease;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 16px;
}
.op-detail-section h4 {
  font-size: 11px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 8px;
}
.op-detail-section p {
  font-size: 14px;
  margin-bottom: 4px;
}

/* ====================== EXTRA CSS - EXP CONFERENCIA ====================== */
.conf-scan-area {
  background: var(--bg-card);
  border: 2px dashed var(--border-light);
  border-radius: var(--radius-lg);
  padding: 24px;
  text-align: center;
  margin-bottom: 20px;
}
.conf-scan-area.scanning {
  border-color: var(--color-blue);
  background: rgba(59,130,246,0.05);
}
.conf-scan-icon { font-size: 48px; margin-bottom: 8px; opacity: 0.5; }

/* ====================== EXTRA CSS - CARGA ORDER ====================== */
.carga-order {
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 14px;
  margin-bottom: 10px;
}
.carga-order.current {
  border-color: var(--color-yellow);
  background: rgba(245,158,11,0.05);
}
.carga-order.done {
  border-color: var(--color-green);
  background: rgba(34,197,94,0.05);
  opacity: 0.8;
}
.carga-order .co-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 6px;
}
.carga-order .co-client { font-weight: 700; }
.carga-order .co-address { font-size: 13px; color: var(--text-muted); }

/* ====================== EXTRA CSS - RETIRA ====================== */
.retira-pedido-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 10px;
  cursor: pointer;
  transition: var(--transition);
}
.retira-pedido-card:active { transform: scale(0.98); }
.retira-pedido-card:hover { border-color: var(--border-light); }

/* ====================== EXTRA CSS - CONFIG FORMS ====================== */
.config-form {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  margin-top: 16px;
  animation: fadeIn 0.2s ease;
}
.config-form .form-grid {
  display: grid;
  gap: 14px;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
}
.config-form label {
  font-size: 13px;
  color: var(--text-secondary);
  display: block;
  margin-bottom: 4px;
}
.config-item {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 14px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  margin-bottom: 8px;
}
.config-item .ci-icon {
  width: 44px; height: 44px;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 18px;
  flex-shrink: 0; color: #fff;
}
.config-item .ci-info { flex: 1; min-width: 0; }
.config-item .ci-name { font-weight: 700; }
.config-item .ci-meta { font-size: 13px; color: var(--text-muted); }
.config-item .ci-actions { display: flex; gap: 8px; align-items: center; }

/* Toggle switch */
.toggle {
  width: 44px; height: 24px;
  background: var(--border-light);
  border-radius: 12px;
  position: relative;
  cursor: pointer;
  transition: var(--transition);
  flex-shrink: 0;
}
.toggle.on { background: var(--color-green); }
.toggle::after {
  content: '';
  position: absolute;
  width: 20px; height: 20px;
  background: #fff;
  border-radius: 50%;
  top: 2px; left: 2px;
  transition: var(--transition);
}
.toggle.on::after { left: 22px; }

/* ====================== EXTRA CSS - EMPTY STATE ====================== */
.empty-state {
  text-align: center;
  padding: 48px 24px;
  color: var(--text-muted);
}
.empty-state .es-icon { font-size: 56px; margin-bottom: 16px; opacity: 0.3; }
.empty-state .es-text { font-size: 16px; margin-bottom: 16px; }

/* ====================== EXTRA CSS - MODAL CONFIRM ====================== */
.confirm-overlay {
  position: fixed;
  inset: 0;
  background: rgba(15,15,26,0.85);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 8000;
  animation: fadeIn 0.15s ease;
}
.confirm-box {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 32px;
  max-width: 400px;
  width: 90%;
  text-align: center;
}
.confirm-box .cb-title { font-size: 18px; font-weight: 700; margin-bottom: 8px; }
.confirm-box .cb-text { font-size: 14px; color: var(--text-secondary); margin-bottom: 24px; }
.confirm-box .cb-actions { display: flex; gap: 12px; justify-content: center; }

/* ====================== EXTRA CSS - PULSE DOT ====================== */
.pulse-dot {
  width: 10px; height: 10px;
  border-radius: 50%;
  display: inline-block;
  animation: pulse 2s infinite;
}
.pulse-dot.green { background: var(--color-green); }
.pulse-dot.red { background: var(--color-red); }
.pulse-dot.yellow { background: var(--color-yellow); }

/* ====================== EXTRA CSS - MINI STATS ====================== */
.mini-stat {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  background: rgba(255,255,255,0.03);
  border-radius: var(--radius-sm);
  font-size: 13px;
}
.mini-stat .ms-value { font-weight: 700; font-size: 18px; font-variant-numeric: tabular-nums; }
.mini-stat .ms-label { color: var(--text-muted); }

/* ══════════════════════════════════════════════════════════════════
   REDESIGN 2026-06 — Design System "cara Belo Santo" (espelha novo2).
   Linguagem: claro/leve/fino — bordas hairline, muito respiro, sombras
   suaves, azul de marca #2a3aff, tipografia com hierarquia forte.
   Camada aditiva: refina componentes existentes sem reescrever telas.
   Theme-aware (header e tudo seguem o tema; claro = padrão).
   ══════════════════════════════════════════════════════════════════ */
:root{ --focus-ring:0 0 0 3px var(--primary-soft); }
body{ font-feature-settings:"cv02","cv03","cv04","ss01"; -webkit-font-smoothing:antialiased; }

/* Header limpo, segue o tema (branco no claro / escuro suave à noite) */
#header{ background:var(--bg-header); border-bottom:1px solid var(--border); box-shadow:none; }
/* Logo no login (SVG oficial, maior) */
.login-brand{ display:flex; justify-content:center; color:var(--text-primary); margin-bottom:2px; }
.login-brand .brand-svg{ height:46px; width:auto; }
/* Logo OFICIAL no header (SVG; wordmark herda a cor do tema) */
#header .hdr-brand{ display:flex; align-items:center; flex-shrink:0; cursor:pointer; padding-right:8px; color:var(--text-primary); }
#header .hdr-brand .brand-svg{ height:22px; width:auto; display:block; }
@media(max-width:600px){ #header .hdr-brand .brand-svg{ height:18px; } #header .user-badge{ display:none; } }
@media(max-width:420px){ #header .hdr-brand{ display:none; } }

/* Botões finos e arredondados; toque ≥44px; foco acessível */
.btn{ min-height:42px; border-radius:10px; font-weight:600; letter-spacing:.1px; transition:background .15s,box-shadow .15s,border-color .15s,transform .04s; }
.btn:focus-visible{ outline:none; box-shadow:var(--focus-ring); }
.btn:active{ transform:translateY(.5px); }
.btn-primary{ background:var(--primary); color:var(--primary-ink); box-shadow:0 1px 2px rgba(20,22,28,.12); }
.btn-primary:hover{ background:var(--primary-2); }
.btn-primary:active{ background:var(--primary-2); }
.btn-outline{ border:1px solid var(--border-light); background:transparent; color:var(--text-primary); }
.btn-outline:hover{ background:var(--bg-card-hover); border-color:var(--primary); color:var(--primary); }
.btn-pill{ border-radius:999px; }

/* Cards finos: hairline + cantos suaves + sombra leve */
.card{ border:1px solid var(--border); border-radius:14px; box-shadow:var(--shadow-sm); }

/* Sidebar refinada (segue o tema) */
#sidebar{ background:var(--bg-sidebar); border-right:1px solid var(--border); }
#sidebar .sidebar-label{ color:var(--text-muted); letter-spacing:.8px; }

/* ── Menu agrupado (colapsável via <details> nativo) ── */
#sidebar .nav-group,.sidebar-mobile .nav-group{ border:0; margin:1px 0; }
#sidebar .nav-group>summary,.sidebar-mobile .nav-group>summary{
  list-style:none; cursor:pointer; display:flex; align-items:center;
  padding:9px 12px; margin:3px 8px 1px; font-size:11px; font-weight:700; letter-spacing:.7px;
  text-transform:uppercase; color:var(--text-muted); user-select:none; border-radius:8px;
}
#sidebar .nav-group>summary:hover,.sidebar-mobile .nav-group>summary:hover{ background:var(--bg-card-hover); }
#sidebar .nav-group>summary::-webkit-details-marker,
.sidebar-mobile .nav-group>summary::-webkit-details-marker{ display:none; }
#sidebar .nav-group>summary::after,.sidebar-mobile .nav-group>summary::after{
  content:"\25BE"; margin-left:auto; font-size:9px; transition:transform .15s; opacity:.5;
}
#sidebar .nav-group:not([open])>summary::after,
.sidebar-mobile .nav-group:not([open])>summary::after{ transform:rotate(-90deg); }
#sidebar .nav-group>summary:hover,.sidebar-mobile .nav-group>summary:hover{ color:var(--text-secondary); }
#sidebar .nav-group[open]>summary{ color:var(--text-secondary); }
#sidebar .nav-group .sidebar-item,.sidebar-mobile .nav-group .sidebar-item{
  display:block; width:auto; padding:9px 12px; font-size:13.5px; line-height:1.2;
  border-radius:8px; margin:1px 8px; color:var(--text-secondary);
  white-space:nowrap; overflow:hidden; text-overflow:ellipsis; text-align:left; border:0;
}
/* Ícone em coluna de largura fixa → títulos e itens alinham na mesma coluna */
.nav-ic{ display:inline-block; width:22px; text-align:center; margin-right:8px; font-size:13px; line-height:1; vertical-align:-1px; flex-shrink:0; }
.nav-ic-grp{ font-size:14px; }
#sidebar .nav-group .sidebar-item:hover,.sidebar-mobile .nav-group .sidebar-item:hover{ background:var(--bg-card-hover); color:var(--text-primary); }
/* Item ativo: pílula suave da marca */
#sidebar .sidebar-item.active,.sidebar-mobile .sidebar-item.active{
  background:var(--primary-soft); color:var(--primary); font-weight:600; box-shadow:none;
}
/* GRUPO ABERTO = bloco tingido que "abraça" header + itens (deixa claro que o
   submenu pertence àquele menu). Só o grupo aberto recebe o destaque (dinâmico). */
#sidebar .nav-group[open],.sidebar-mobile .nav-group[open]{
  background:var(--bg-card-hover); border-radius:12px; margin:4px 8px; padding-bottom:5px;
}
#sidebar .nav-group[open]>summary,.sidebar-mobile .nav-group[open]>summary{
  color:var(--primary); margin:0 0 2px; border-radius:12px 12px 0 0;
}
#sidebar .nav-group[open]>summary::after,.sidebar-mobile .nav-group[open]>summary::after{ opacity:.9; color:var(--primary); }
/* itens do grupo aberto: trilho de conexão à esquerda (hierarquia visual) */
#sidebar .nav-group[open] .sidebar-item,.sidebar-mobile .nav-group[open] .sidebar-item{
  margin:1px 10px 1px 16px; border-left:2px solid var(--border); border-radius:0 8px 8px 0;
}
#sidebar .nav-group[open] .sidebar-item:hover,.sidebar-mobile .nav-group[open] .sidebar-item:hover{ border-left-color:var(--border-light); }
#sidebar .nav-group[open] .sidebar-item.active,.sidebar-mobile .nav-group[open] .sidebar-item.active{ border-left-color:var(--primary); }

/* ── Cabeçalho de tela (título + subtítulo + ações) ── */
.screen-head{ display:flex; justify-content:space-between; align-items:flex-start; gap:14px; flex-wrap:wrap; margin-bottom:22px; }
.screen-head .sh-text{ min-width:0; }
.screen-head h1{ font-size:23px; font-weight:800; letter-spacing:-.4px; margin:0; color:var(--text-primary); line-height:1.15; }
.screen-head .sh-sub{ font-size:13.5px; color:var(--text-secondary); margin-top:4px; line-height:1.45; }
.screen-head .sh-actions{ display:flex; gap:8px; flex-wrap:wrap; align-items:center; }
@media(max-width:600px){ .screen-head h1{ font-size:20px; } .screen-head .sh-actions{ width:100%; } .screen-head .sh-actions .btn{ flex:1; } }

/* ── Estado vazio ── */
.empty-state{ text-align:center; padding:48px 20px; color:var(--text-muted); }
.empty-state .es-icon{ font-size:44px; opacity:.45; margin-bottom:12px; }
.empty-state .es-title{ font-size:16px; font-weight:700; color:var(--text-primary); margin-bottom:5px; }
.empty-state .es-msg{ font-size:13.5px; max-width:380px; margin:0 auto 16px; line-height:1.55; }

/* ── Eyebrow/pílula (estilo novo2) — disponível p/ telas ── */
.eyebrow{ display:inline-flex; align-items:center; gap:7px; padding:5px 12px; border:1px solid var(--border); border-radius:999px; font-size:12px; color:var(--text-secondary); background:var(--bg-card); }
.eyebrow::before{ content:""; width:7px; height:7px; border-radius:50%; background:var(--primary); }

/* ══════════════════════════════════════════════════════════════════
   INCREMENTO 3 — Modos por dispositivo
   ══════════════════════════════════════════════════════════════════ */
/* ── MODO FÁBRICA (operador) — toque GRANDE, texto grande, p/ usar de relance
      na máquina (tablet/celular fixo, às vezes de luva). Auto por data-perfil. ── */
[data-perfil="operador"] #content{ font-size:16.5px; }
[data-perfil="operador"] .btn{ min-height:56px; font-size:16.5px; border-radius:12px; font-weight:700; }
[data-perfil="operador"] .btn-lg{ min-height:66px; font-size:19px; }
[data-perfil="operador"] .btn-xl{ min-height:78px; font-size:22px; }
[data-perfil="operador"] .screen-title,[data-perfil="operador"] .screen-head h1{ font-size:26px; }
[data-perfil="operador"] .screen-head .sh-sub{ font-size:15px; }
[data-perfil="operador"] input,[data-perfil="operador"] select,[data-perfil="operador"] textarea,[data-perfil="operador"] .qr-input{ min-height:54px; font-size:17px; }
[data-perfil="operador"] .card{ border-radius:16px; }
[data-perfil="operador"] .card-grid .card{ padding:20px; }
/* números/estados grandes pra leitura à distância */
[data-perfil="operador"] .kpi-card .kpi-value,[data-perfil="operador"] .metric-value{ font-size:34px; }

/* ── TABLET / COLETOR (expedidor) — toque confortável, scanner em destaque ── */
[data-perfil="expedidor"] .btn{ min-height:50px; font-size:15px; }
[data-perfil="expedidor"] .qr-input{ min-height:56px; font-size:18px; }

/* ── Refino mobile do design fino: tabela com scroll mais elegante + toque ── */
@media (max-width:767px){
  .table-wrap-auto{ border:1px solid var(--border); border-radius:12px; }
  .btn{ min-height:44px; }
  td .btn, th .btn{ min-height:38px; }
  /* respiro lateral confortável no conteúdo */
  #content .screen{ padding-left:14px; padding-right:14px; }
}
/* alvo de toque mínimo universal em links de ação dentro de listas */
.sidebar-item,.tab-item{ min-height:44px; }

/* ═══ [02/08] BARRA DE FILTROS DA FILA ═══════════════════════════════════════
 * Defeito nº1 apontado pelos três (Fable 5, Grok, Codex): no celular os botões
 * MONTAR OP / CARGA ANTECIPADA passavam POR CIMA do campo de busca.
 * ⭐ Causa: o container era display:flex SEM flex-wrap — só o pai tinha wrap.
 */
.fila-toolbar { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.fila-toolbar .btn { min-height: 44px; }
@media (max-width: 767px) {
  /* no celular a barra toma a largura toda e as duas ações ficam lado a lado, grandes */
  .fila-toolbar { width: 100%; }
  .fila-toolbar .btn {
    flex: 1 1 calc(50% - 4px);
    min-height: 48px;          /* ação primária com luva */
    font-size: 14px; line-height: 1.2;
    white-space: normal;       /* deixa o rótulo quebrar em vez de vazar do botão */
  }
}

/* ═══ [02/08] CÂMERA EM CAMPO DE ETIQUETA ═══════════════════════════════════
 * Julio: "eu fico refém apenas de leitor de QR code? não posso ir só com o celular?"
 * 13 de 21 campos não tinham câmera. O motor já existia — faltava o botão.
 */
.bip-row { display: flex; gap: 8px; align-items: center; }
.bip-row > input { flex: 1; min-width: 0; }   /* min-width:0 ou o input trava o encolhimento */
.btn.bip-cam-btn, .bip-cam-btn {
  flex: 0 0 auto;
  min-width: 48px; min-height: 48px;          /* alvo de luva — regra unânime dos três */
  font-size: 20px; line-height: 1; padding: 0 12px;
}


/* ═══ [02/08] LISTA DENSA ════════════════════════════════════════════════════
 * Consenso da mesa (Fable 5 · Grok · Codex): lista longa de itens comparáveis é
 * TABELA, não pilha de cartões. Antes: 200 etiquetas × cartão de 130px = 4 por tela.
 * ⭐ No celular NÃO vira cartão: vira LINHA DUPLA (identidade em cima, números embaixo).
 * ⭐ UMA ação primária visível por linha; consulta vai pro clique na linha.
 */
.lista-densa-wrap { overflow-x: auto; border: 1px solid var(--border); border-radius: 10px; background: var(--panel, var(--bg-card)); }
.lista-densa { width: 100%; border-collapse: collapse; font-size: 13px; }
.lista-densa thead th {
  position: sticky; top: 0; z-index: 2;
  background: var(--panel, var(--bg-card));
  text-align: left; font-size: 10.5px; letter-spacing: .04em; text-transform: uppercase;
  color: var(--text-muted); font-weight: 700;
  padding: 9px 10px; border-bottom: 1px solid var(--border); white-space: nowrap;
}
.lista-densa tbody td { padding: 7px 10px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.lista-densa tbody tr { height: 44px; }
.lista-densa tbody tr:last-child td { border-bottom: 0; }
.lista-densa tbody tr.clicavel { cursor: pointer; }
.lista-densa tbody tr.clicavel:hover { background: var(--bg-hover, rgba(127,127,127,.07)); }
.lista-densa tbody tr.apagada { opacity: .5; }
.ld-id { font-family: monospace; font-weight: 700; white-space: nowrap; }
.ld-sub { font-size: 11px; color: var(--text-muted); }
.ld-num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
/* [02/08] a ação GRUDA na direita: sem isso a tabela rolava e o botão IMPRIMIR — a única
 * ação que muda estado — ficava fora da tela. Ação primária invisível é ação que não existe. */
.ld-acao { text-align: right; white-space: nowrap; position: sticky; right: 0; background: var(--panel, var(--bg-card)); box-shadow: -6px 0 6px -6px rgba(0,0,0,.25); }
.lista-densa thead th.ld-acao { z-index: 3; }
@media (max-width: 767px) { .ld-acao { position: static; box-shadow: none; background: transparent; } }
.ld-acao .btn { min-height: 32px; padding: 5px 10px; font-size: 11px; }
/* selo de estado: a COR diz o estado, o texto diz qual — nunca só a cor */
.ld-selo { display: inline-block; padding: 2px 7px; border-radius: 6px; font-size: 10px; font-weight: 700; text-transform: uppercase; white-space: nowrap; }

@media (max-width: 767px) {
  /* linha dupla: identidade em cima, números e ação embaixo. Densidade mantida. */
  .lista-densa-wrap { overflow-x: visible; }
  .lista-densa thead { display: none; }
  .lista-densa, .lista-densa tbody, .lista-densa tr, .lista-densa td { display: block; width: auto; }
  .lista-densa tbody tr {
    height: auto; padding: 9px 11px; border-bottom: 1px solid var(--border);
    display: grid; grid-template-columns: 1fr auto; gap: 2px 8px; align-items: center;
  }
  .lista-densa tbody td { padding: 0; border: 0; }
  .lista-densa td.m-full { grid-column: 1 / -1; }
  .lista-densa td.m-none { display: none; }   /* coluna que só faz sentido no desktop */
  .ld-num { text-align: left; }
  .ld-acao { text-align: right; }
  .ld-acao .btn { min-height: 40px; padding: 8px 12px; font-size: 12px; }
}


/* ═══ [02/08] TELA DE ETIQUETAS NO CELULAR ══════════════════════════════════
 * O que empurrava a lista pra baixo da dobra: 3 botões + 5 KPIs + filtros quebrados.
 */
.etq-filtros { display: grid; grid-template-columns: 1fr 140px 140px 120px; gap: 8px; align-items: end; }
@media (max-width: 767px) {
  /* busca ocupa a linha toda; tipo e status dividem a de baixo; recarregar embaixo */
  .etq-filtros { grid-template-columns: 1fr 1fr; }
  .etq-filtros > div:first-child { grid-column: 1 / -1; }
  /* KPIs: 3 por linha e mais baixos — informação continua, altura cai pela metade */
  /* [02/08] os 5 KPIs em UMA faixa rolável: eram 2 linhas de 130px empurrando a lista
     pra fora da tela. O número continua inteiro, só deixa de ocupar meia dobra. */
  #etq-stats { flex-wrap: nowrap !important; overflow-x: auto; gap: 6px !important; }
  #etq-stats .card { min-width: 92px !important; flex: 0 0 auto !important; padding: 5px 9px !important; }
  #etq-stats .card > div:first-child { font-size: 9.5px !important; }
  #etq-stats .card > div:last-child { font-size: 17px !important; }
  /* os 3 botões do topo ficam lado a lado em vez de empilhados */
  .screen-title .btn { flex: 1 1 auto; font-size: 11px !important; padding: 7px 8px !important; }
}

/* a linha densa no celular: 3 faixas com a ação à direita ocupando as três */
@media (max-width: 767px) {
  .lista-densa tbody tr {
    grid-template-columns: 1fr auto;
    grid-template-areas: "id id" "prod acao" "qtd acao" "op acao";
    row-gap: 1px;
  }
  td.ld-c-id { grid-area: id; }
  td.ld-c-prod { grid-area: prod; font-weight: 600; }
  td.ld-c-qtd { grid-area: qtd; }
  td.ld-c-op { grid-area: op; }
  /* [02/08] os 2 botões LADO A LADO: empilhados a célula ficava 84px e ESTICAVA as 3 faixas
     do grid (84/3=28px cada) — a ação mandava na altura da linha inteira. */
  td.ld-c-acao { grid-area: acao; align-self: center; display: flex; gap: 4px; }
  /* min-width:0 ou a coluna 1 não encolhe e o grid estoura os 390px do celular */
  .lista-densa tbody td { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  /* cliente e quando saem do celular — estão a um toque, na prévia */
  td.ld-c-cli, td.ld-c-quando { display: none; }
}


/* ═══ [02/08] KANBAN EM UMA LINHA ═══════════════════════════════════════════
 * Antes: repeat(auto-fit, minmax(220px,1fr)) quebrava e "EM PRODUÇÃO"/"EM MONTAGEM" —
 * etapas FINAIS — apareciam ABAIXO das iniciais. Kanban que quebra deixa de ser fluxo.
 * ⭐ Rola pro lado em vez de quebrar: a ordem esquerda→direita É a informação.
 */
.kanban-fluxo {
  display: grid; gap: 12px;
  grid-auto-flow: column; grid-auto-columns: minmax(210px, 1fr);
  overflow-x: auto; padding-bottom: 6px;
  scroll-snap-type: x proximity;
}
.kanban-fluxo > * { scroll-snap-align: start; }
@media (max-width: 767px) { .kanban-fluxo { grid-auto-columns: minmax(180px, 82vw); } }



/* ═══ [02/08] CINTO DE SEGURANÇA MOBILE ═══════════════════════════════════════
   Julio, medindo em 390px: botão com até 114px de texto cortado e card de gráfico
   passando 198px da borda. A causa é sempre a mesma — conteúdo com largura própria
   maior que a tela, e botão que não deixa o rótulo quebrar.
   ⭐ Regra na causa: no celular o rótulo QUEBRA e nada passa da viewport.            */
@media (max-width: 767px) {
  /* nada dentro do conteúdo pode ser mais largo que a tela */
  #content, #content * { max-width: 100%; }

  /* ⭐ o rótulo quebra em vez de esticar o botão pra fora da tela.
     (mantenho min-height pra continuar clicável de dedo)                            */
  #content .btn, #content button {
    white-space: normal;
    overflow-wrap: anywhere;
    min-height: 40px;
    height: auto;
  }

  /* tabela larga é decisão, não defeito — mas tem que rolar DENTRO da caixa dela,
     nunca empurrar a página inteira de lado                                          */
  #content table { display: block; overflow-x: auto; max-width: 100%; }

  /* gráfico/canvas não tem largura própria maior que o card                          */
  #content canvas, #content svg, #content img { max-width: 100%; height: auto; }
  #content .chart-bar-wrap, #content .card { overflow-x: auto; }

  /* o badge de perfil estourava 2-5px por causa do padding + letter-spacing          */
  #content .badge { white-space: normal; word-break: break-word; }
}
