:root {
  --blue: #15293a;
  --blue-dark: #0c1a26;
  --green: #0e9f6e;
  --green-dark: #057a55;
  --red: #f05252;
  --red-dark: #c81e1e;
  --orange: #ec6a1c;
  --orange-dark: #c8550f;
  --gray-50: #f9fafb;
  --gray-100: #f3f4f6;
  --gray-200: #e5e7eb;
  --gray-300: #d1d5db;
  --gray-400: #9ca3af;
  --gray-500: #6b7280;
  --gray-700: #374151;
  --gray-900: #111827;
  --shadow: 0 1px 3px rgba(0,0,0,0.12), 0 1px 2px rgba(0,0,0,0.08);
  --shadow-md: 0 4px 6px rgba(0,0,0,0.1), 0 2px 4px rgba(0,0,0,0.06);
  --radius: 10px;

  /* Variáveis semânticas usadas pelo menu e pelo módulo de logística */
  --bg: var(--gray-100);
  --bg-card: #fff;
  --text: var(--gray-900);
  --text-muted: var(--gray-500);
  --border: var(--gray-200);
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background: var(--gray-100);
  color: var(--gray-900);
  min-height: 100vh;
  font-size: 16px;
  -webkit-tap-highlight-color: transparent;
}

/* ── Layout ── */
#app { min-height: 100vh; display: flex; flex-direction: column; }

.page { display: none; flex: 1; flex-direction: column; }
.page.active { display: flex; }

/* ── Header ── */
.header {
  background: var(--blue);
  background-image:
    repeating-linear-gradient(115deg, transparent 0 24px, rgba(255,255,255,0.035) 24px 26px),
    repeating-linear-gradient(64deg, transparent 0 30px, rgba(255,255,255,0.025) 30px 32px);
  border-bottom: 3px solid var(--orange);
  color: #fff;
  padding: 12px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  row-gap: 8px;
  box-shadow: var(--shadow-md);
  position: sticky;
  top: 0;
  z-index: 100;
}
.header h1 { font-size: 1.1rem; font-weight: 700; }
.header .operator-name { font-size: 0.85rem; opacity: 0.9; }
.header .brand-logo { height: 30px; width: auto; flex-shrink: 0; }
.header.hdr-stacked .brand-logo { height: 34px; }

/* ── Buttons ── */
.btn {
  display: inline-flex; align-items: center; justify-content: center;
  gap: 8px;
  padding: 12px 20px;
  border: none; border-radius: var(--radius);
  font-size: 1rem; font-weight: 600;
  cursor: pointer;
  transition: filter 0.15s, transform 0.1s;
  -webkit-user-select: none; user-select: none;
}
.btn:active { transform: scale(0.97); filter: brightness(0.92); }
.btn-primary { background: var(--blue); color: #fff; }
.btn-success { background: var(--green); color: #fff; }
.btn-danger  { background: var(--red);  color: #fff; }
.btn-warning { background: var(--orange); color: #fff; }
.btn-outline { background: transparent; color: var(--blue); border: 2px solid var(--blue); }
.btn-gray    { background: var(--gray-200); color: var(--gray-700); }
.btn-sm      { padding: 8px 14px; font-size: 0.875rem; }
.btn-block   { width: 100%; }
.btn-lg      { padding: 16px 24px; font-size: 1.1rem; }

/* ── Cards ── */
.card {
  background: #fff;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 16px;
}
.card-title { font-size: 0.8rem; text-transform: uppercase; color: var(--gray-500); margin-bottom: 8px; letter-spacing: 0.05em; }

/* ── Grid ── */
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }

/* ── Operator Select ── */
#page-operator { padding: 16px; gap: 16px; }
.operator-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 12px; }
.operator-card {
  background: #fff; border-radius: var(--radius);
  padding: 20px 12px; text-align: center;
  cursor: pointer; box-shadow: var(--shadow);
  border: 3px solid transparent;
  transition: border-color 0.2s, box-shadow 0.2s;
}
.operator-card:hover, .operator-card:active { border-color: var(--blue); box-shadow: var(--shadow-md); }
.operator-card .avatar {
  width: 56px; height: 56px; border-radius: 50%;
  background: var(--blue); color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-size: 1.4rem; font-weight: 700; margin: 0 auto 10px;
}
.operator-card.has-open .avatar { background: var(--orange); }
.operator-card .op-name { font-weight: 600; font-size: 0.9rem; word-break: break-word; }
.operator-card .badge-code { font-size: 0.75rem; color: var(--gray-500); margin-top: 4px; }
.operator-card .open-badge {
  background: var(--orange); color: #fff;
  font-size: 0.65rem; font-weight: 700;
  border-radius: 99px; padding: 2px 8px; margin-top: 6px; display: inline-block;
}

/* ── Main page ── */
#page-main { gap: 0; }
.top-bar {
  background: #fff; border-bottom: 1px solid var(--gray-200);
  padding: 12px 16px; display: flex; align-items: center; justify-content: space-between;
}
.top-bar .op-info { font-size: 0.9rem; color: var(--gray-700); }
.top-bar .op-info strong { font-size: 1rem; }
.main-content { padding: 16px; flex: 1; overflow-y: auto; display: flex; flex-direction: column; gap: 16px; }

.open-entry-banner {
  background: linear-gradient(135deg, var(--orange), #f59e0b);
  color: #fff; border-radius: var(--radius);
  padding: 14px 16px; cursor: pointer;
  display: flex; align-items: center; justify-content: space-between;
}
.open-entry-banner .timer-display { font-size: 1.4rem; font-weight: 700; font-family: monospace; }

.section-title { font-size: 0.8rem; text-transform: uppercase; color: var(--gray-500); font-weight: 600; letter-spacing: 0.05em; }

/* ── Tile grid (categories & sectors) ── */
.tile-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 14px;
}
.tile-card {
  background: #fff; border: 2px solid var(--gray-200);
  border-radius: var(--radius); padding: 20px 12px 16px;
  text-align: center; cursor: pointer; box-shadow: var(--shadow);
  transition: border-color 0.15s, background 0.15s, box-shadow 0.15s;
  display: flex; flex-direction: column; align-items: center; gap: 8px;
  -webkit-user-select: none; user-select: none;
}
.tile-card:hover  { border-color: var(--blue); box-shadow: var(--shadow-md); }
.tile-card:active { transform: scale(0.97); }
.tile-card .tile-icon { font-size: 2.4rem; line-height: 1; }
.tile-card .tile-name {
  font-size: 0.9rem; font-weight: 600;
  word-break: break-word; line-height: 1.3;
}
.tile-card .tile-badge {
  font-size: 0.65rem; background: var(--gray-200); color: var(--gray-500);
  border-radius: 99px; padding: 2px 8px; font-weight: 500;
}

/* keep old names as aliases for compatibility */
.category-list { display: contents; }
.sector-list   { display: contents; }

/* ── Entry page ── */
#page-entry { padding: 16px; gap: 16px; overflow-y: auto; }
.entry-header { display: flex; align-items: center; gap: 12px; }
.entry-info-card { }
.entry-info-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px 16px; font-size: 0.9rem; }
.entry-info-grid dt { color: var(--gray-500); font-size: 0.8rem; }
.entry-info-grid dd { font-weight: 600; }

.op-input-row { display: flex; gap: 8px; }
.op-input-row input { flex: 1; }

.entry-summary-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}
.entry-summary-subtitle {
  color: var(--gray-500);
  font-size: 0.8rem;
  margin-top: -4px;
}
.entry-summary-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 10px;
}
.entry-summary-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  background: var(--gray-50);
  border: 1px solid var(--gray-200);
  border-radius: 8px;
  padding: 10px 12px;
}
.entry-summary-sector {
  font-weight: 600;
  line-height: 1.25;
}
.entry-summary-main { display: flex; flex-direction: column; gap: 3px; min-width: 130px; }
.entry-summary-own,
.entry-summary-target { color: var(--gray-500); font-size: 0.78rem; }
.entry-summary-progress { flex: 1; min-width: 150px; }
.entry-summary-progress-top {
  display: flex; justify-content: space-between; gap: 8px;
  color: var(--gray-500); font-size: 0.78rem; margin-bottom: 4px;
}
.entry-summary-progress-top strong { color: var(--green); white-space: nowrap; }
.entry-summary-target { margin-top: 3px; text-align: right; }
.entry-summary-empty {
  color: var(--gray-500);
  font-size: 0.9rem;
  text-align: center;
  padding: 12px 4px;
}

.pcp-program-modal {
  position: fixed;
  inset: 0;
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  background: rgba(0, 0, 0, 0.45);
}
.pcp-program-box {
  width: min(440px, 94vw);
  background: var(--bg-card);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 16px;
  box-shadow: 0 18px 45px rgba(0, 0, 0, 0.28);
}
.pcp-program-title {
  font-weight: 700;
  margin-bottom: 8px;
}
.pcp-program-box textarea {
  width: 100%;
  min-height: 150px;
  resize: vertical;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px;
  background: #fff;
  color: var(--text);
  font: inherit;
  line-height: 1.45;
}

.pcp-excel-th { position: relative; min-width: 125px; }
.pcp-excel-head {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  border: 0;
  background: transparent;
  color: inherit;
  font: inherit;
  font-weight: 700;
  cursor: pointer;
  padding: 0;
  text-align: left;
}
.pcp-excel-head span { font-size: 0.72rem; opacity: 0.8; }
.pcp-excel-head.active span { color: var(--orange); opacity: 1; }
.pcp-excel-menu {
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  z-index: 50;
  width: 245px;
  padding: 10px;
  border: 1px solid var(--gray-300);
  border-radius: 8px;
  background: #fff;
  color: var(--gray-900);
  box-shadow: var(--shadow-md);
  text-align: left;
}
.pcp-excel-sort,
.pcp-excel-actions {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  margin-bottom: 8px;
}
.pcp-excel-sort button {
  border: 1px solid var(--gray-300);
  background: var(--gray-50);
  border-radius: 6px;
  padding: 5px 7px;
  font-size: 0.76rem;
  cursor: pointer;
}
.pcp-excel-field {
  display: grid;
  grid-template-columns: 1fr;
  gap: 6px;
  margin-bottom: 8px;
}
.pcp-excel-field select,
.pcp-excel-field input {
  width: 100%;
  padding: 7px 8px;
  border: 1px solid var(--gray-300);
  border-radius: 6px;
  font-size: 0.8rem;
}
.pcp-excel-values {
  max-height: 150px;
  overflow: auto;
  border: 1px solid var(--gray-200);
  border-radius: 6px;
  padding: 6px;
  margin-bottom: 8px;
  background: var(--gray-50);
}
.pcp-excel-values label {
  display: block;
  font-weight: 400;
  font-size: 0.78rem;
  padding: 3px 0;
  white-space: nowrap;
}

input[type=text], input[type=number], input[type=password] {
  border: 2px solid var(--gray-200); border-radius: var(--radius);
  padding: 12px 14px; font-size: 1rem; width: 100%; min-width: 0;
  outline: none; transition: border-color 0.2s;
  background: #fff;
}
input:focus { border-color: var(--blue); }

.timer-card {
  background: linear-gradient(135deg, var(--blue), var(--blue-dark));
  color: #fff; border-radius: var(--radius);
  padding: 24px; text-align: center;
}
.timer-card .timer-label { font-size: 0.85rem; opacity: 0.85; margin-bottom: 8px; }
.timer-card .timer-value { font-size: 3rem; font-weight: 700; font-family: monospace; letter-spacing: 0.05em; }

.progress-bar-wrap { background: var(--gray-200); border-radius: 99px; height: 10px; overflow: hidden; }
.progress-bar-fill { height: 100%; border-radius: 99px; background: var(--green); transition: width 0.5s; }
.progress-bar-fill.danger { background: var(--red); }

/* ── History page ── */
#page-history { gap: 0; }
.history-content { padding: 16px; flex: 1; overflow-y: auto; }
.history-table { width: 100%; border-collapse: collapse; font-size: 0.85rem; }
.history-table th {
  background: var(--gray-100); padding: 10px 8px;
  text-align: left; font-size: 0.75rem; text-transform: uppercase;
  color: var(--gray-500); border-bottom: 2px solid var(--gray-200);
  white-space: nowrap;
}
.history-table td { padding: 10px 8px; border-bottom: 1px solid var(--gray-100); vertical-align: middle; }
.history-table tr:hover td { background: var(--gray-50); }
.status-pill {
  display: inline-block; border-radius: 99px; padding: 3px 10px;
  font-size: 0.75rem; font-weight: 600;
}
.status-pill.aberto { background: #fef3c7; color: #92400e; }
.status-pill.encerrado { background: #d1fae5; color: #065f46; }

/* ── Admin page ── */
#page-admin { gap: 0; }
.admin-tabs { display: flex; border-bottom: 2px solid var(--gray-200); background: #fff; overflow-x: auto; }
.admin-tab {
  padding: 12px 16px; font-size: 0.9rem; font-weight: 600; cursor: pointer;
  border-bottom: 3px solid transparent; margin-bottom: -2px; white-space: nowrap;
  color: var(--gray-500);
}
.admin-tab.active { border-color: var(--blue); color: var(--blue); }
.admin-tab.tab-order-btn { margin-left: auto; color: var(--gray-500); border-left: 1px solid var(--gray-200); }
.admin-content { padding: 16px; flex: 1; overflow-y: auto; }
.admin-panel { display: none; }
.admin-panel.active { display: block; }

table.data-table { width: 100%; border-collapse: collapse; font-size: 0.875rem; }
table.data-table th {
  background: var(--gray-100); padding: 10px 8px;
  text-align: left; font-size: 0.75rem; text-transform: uppercase;
  color: var(--gray-500); border-bottom: 2px solid var(--gray-200);
}
table.data-table td { padding: 10px 8px; border-bottom: 1px solid var(--gray-100); }
table.data-table tr:hover td { background: var(--gray-50); }

.form-group { display: flex; flex-direction: column; gap: 6px; margin-bottom: 14px; }
.form-group label { font-size: 0.85rem; font-weight: 600; color: var(--gray-700); }
.form-row { display: flex; gap: 8px; flex-wrap: wrap; }
.form-row .form-group { flex: 1; min-width: 140px; }
.checkbox-label { display: flex; align-items: center; gap: 8px; cursor: pointer; font-size: 0.95rem; }
.checkbox-label input[type=checkbox] { width: 18px; height: 18px; cursor: pointer; }

/* ── Numpad Modal ── */
.modal-overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,0.5);
  display: flex; align-items: flex-end; justify-content: center;
  z-index: 999; padding: 0;
}
.modal-overlay.center { align-items: center; padding: 16px; }
/* O numpad pode abrir por cima de outro modal (ex.: editar apontamento/volumes) */
#numpad-modal { z-index: 1500; }
.modal-box {
  background: #fff; border-radius: 16px 16px 0 0;
  padding: 20px; width: 100%; max-width: 420px;
}
.modal-overlay.center .modal-box { border-radius: 16px; }
.modal-title { font-size: 1.1rem; font-weight: 700; margin-bottom: 16px; text-align: center; }
.tab-order-row {
  display: flex; align-items: center; gap: 8px; padding: 10px 12px; margin-bottom: 8px;
  border: 1px solid var(--gray-200); border-radius: var(--radius); background: var(--gray-50); cursor: grab;
}
.tab-order-row:active { cursor: grabbing; }
.tab-order-grip { color: var(--gray-500); font-weight: 700; }

.numpad-display {
  background: var(--gray-100); border-radius: var(--radius);
  padding: 16px; text-align: right; font-size: 2rem;
  font-weight: 700; font-family: monospace;
  margin-bottom: 16px; min-height: 68px; word-break: break-all;
}
.numpad-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-bottom: 12px; }
.numpad-key {
  background: var(--gray-100); border: none; border-radius: var(--radius);
  padding: 18px 0; font-size: 1.3rem; font-weight: 600;
  cursor: pointer; transition: background 0.1s;
}
.numpad-key:active { background: var(--gray-300); }
.numpad-key.danger { background: #fee2e2; color: var(--red); }
.numpad-key.wide { grid-column: span 2; }

/* ── Connection overlay ── */
#connection-overlay {
  position: fixed; inset: 0; background: rgba(17,24,39,0.85);
  display: none; align-items: center; justify-content: center;
  z-index: 9999; flex-direction: column; gap: 16px; color: #fff; text-align: center; padding: 24px;
}
#connection-overlay.visible { display: flex; }
#connection-overlay .icon { font-size: 3rem; }
#connection-overlay h2 { font-size: 1.3rem; }
#connection-overlay p { font-size: 0.9rem; opacity: 0.8; }

/* ── Toast ── */
#toast-container {
  position: fixed; top: 16px; right: 16px; z-index: 1000;
  display: flex; flex-direction: column; gap: 8px;
}
.toast {
  background: var(--gray-900); color: #fff;
  padding: 12px 16px; border-radius: var(--radius);
  font-size: 0.875rem; box-shadow: var(--shadow-md);
  animation: slideIn 0.2s ease;
  max-width: 300px;
}
.toast.success { background: var(--green-dark); }
.toast.error   { background: var(--red-dark); }
.toast.warning { background: var(--orange); }
@keyframes slideIn { from { opacity:0; transform: translateX(20px); } to { opacity:1; transform: none; } }

/* ── Misc ── */
.divider { border: none; border-top: 1px solid var(--gray-200); margin: 8px 0; }
.text-sm { font-size: 0.875rem; }
.text-muted { color: var(--gray-500); }
.mt-2 { margin-top: 8px; }
.mt-4 { margin-top: 16px; }
.mb-4 { margin-bottom: 16px; }
.flex { display: flex; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-2 { gap: 8px; }
.gap-4 { gap: 16px; }
.text-center { text-align: center; }
.hidden { display: none !important; }
.w-full { width: 100%; }

.empty-state {
  text-align: center; padding: 48px 16px; color: var(--gray-400);
}
.empty-state .icon { font-size: 3rem; margin-bottom: 12px; }
.empty-state p { font-size: 0.95rem; }

@media (max-width: 480px) {
  .history-table { font-size: 0.78rem; }
  .history-table th, .history-table td { padding: 8px 4px; }
  .entry-info-grid { grid-template-columns: 1fr; }
}

/* ── Operator page header: stack on small screens ── */
@media (max-width: 560px) {
  #page-operator .header {
    flex-direction: column;
    align-items: flex-start;
    gap: 8px;
    padding: 10px 12px;
  }
  #page-operator .header h1 {
    font-size: 1rem;
  }
  #page-operator .header > .flex {
    width: 100%;
    justify-content: flex-end;
    gap: 6px;
  }
  #page-operator .header .btn-sm {
    padding: 6px 10px;
    font-size: 0.8rem;
  }
  #page-operator .header .theme-toggle {
    font-size: 1rem;
    padding: 4px;
  }
}

/* ══════════════════════════════════
   RESPONSIVO — celular / tablet / notebook / TV
   ══════════════════════════════════ */

/* ── Celular (≤ 600px) ── */
@media (max-width: 600px) {
  body { font-size: 15px; }

  .header { padding: 10px 12px; }
  .header h1 { font-size: 1rem; }
  /* botões do cabeçalho compactos — evitam empilhar sobre o conteúdo */
  .header .btn-sm { padding: 7px 10px; font-size: 0.8rem; }

  .main-content { padding: 12px; gap: 12px; }
  #page-operator, #page-entry { padding: 12px; gap: 12px; }

  /* tiles e operadores menores cabem melhor na tela estreita */
  .operator-grid,
  .tile-grid { grid-template-columns: repeat(auto-fill, minmax(108px, 1fr)); gap: 10px; }
  .tile-card { padding: 16px 8px 12px; }
  .tile-card .tile-icon { font-size: 2rem; }
  .operator-card { padding: 16px 10px; }
  .operator-card .avatar { width: 48px; height: 48px; font-size: 1.2rem; }

  .timer-card { padding: 18px; }
  .timer-card .timer-value { font-size: 2.4rem; }

  /* menu da tela inicial ocupa quase toda a largura, sem estourar */
  .hdr-menu-list { left: 8px; right: 8px; min-width: 0; }

  /* kanban da logística: colunas mais estreitas */
  .logi-col { flex-basis: 200px; min-width: 200px; }
}

/* ── Celular pequeno (≤ 380px) ── */
@media (max-width: 380px) {
  .operator-grid,
  .tile-grid { grid-template-columns: repeat(auto-fill, minmax(94px, 1fr)); }
  .tile-card .tile-icon { font-size: 1.8rem; }
  .timer-card .timer-value { font-size: 2rem; }
}

/* ── TV / telas grandes (≥ 1600px): proporções maiores p/ leitura à distância ── */
@media (min-width: 1600px) {
  body { font-size: 19px; }

  .header { padding: 16px 28px; }
  .header h1 { font-size: 1.4rem; }

  .main-content { padding: 24px; gap: 22px; }

  .operator-grid,
  .tile-grid { grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 20px; }
  .tile-card { padding: 26px 16px 20px; }
  .tile-card .tile-icon { font-size: 3rem; }
  .operator-card .avatar { width: 68px; height: 68px; font-size: 1.7rem; }

  .timer-card .timer-value { font-size: 3.6rem; }
}

/* ── TV 4K (≥ 2560px) ── */
@media (min-width: 2560px) {
  body { font-size: 22px; }

  .operator-grid,
  .tile-grid { grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 26px; }
  .tile-card .tile-icon { font-size: 3.6rem; }
  .timer-card .timer-value { font-size: 4.4rem; }
}

/* Scrollbar */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--gray-300); border-radius: 3px; }

/* ══════════════════════════════════
   DARK THEME
   ══════════════════════════════════ */
[data-theme="dark"] {
  --gray-50:  #1f2937;
  --gray-100: #111827;
  --gray-200: #374151;
  --gray-300: #4b5563;
  --gray-400: #6b7280;
  --gray-500: #9ca3af;
  --gray-700: #d1d5db;
  --gray-900: #f9fafb;

  /* Variáveis semânticas no tema escuro */
  --bg: #0f172a;
  --bg-card: #1e293b;
  --border: #334155;
}

[data-theme="dark"] body {
  background: #0f172a;
  color: #f1f5f9;
}

[data-theme="dark"] .card,
[data-theme="dark"] .tile-card {
  background: #1e293b;
  border-color: #334155;
  box-shadow: 0 1px 3px rgba(0,0,0,0.4);
}
[data-theme="dark"] .tile-card:hover { border-color: var(--blue); }

[data-theme="dark"] .header {
  background: #122334;
  border-bottom: 3px solid var(--orange);
}

[data-theme="dark"] .top-bar {
  background: #1e293b;
  border-bottom: 1px solid #334155;
}

[data-theme="dark"] input[type=text],
[data-theme="dark"] input[type=number],
[data-theme="dark"] input[type=password],
[data-theme="dark"] select {
  background: #334155 !important;
  border-color: #475569 !important;
  color: #f1f5f9;
}

[data-theme="dark"] input::placeholder { color: #64748b; }

[data-theme="dark"] .category-btn {
  background: #1e293b;
  color: #f1f5f9;
  box-shadow: 0 1px 3px rgba(0,0,0,0.3);
}
[data-theme="dark"] .category-btn:hover { background: #273549; }
[data-theme="dark"] .category-btn.active { background: var(--blue); color: #fff; }

[data-theme="dark"] .sector-btn {
  background: #334155;
  border-color: #475569;
  color: #f1f5f9;
}
[data-theme="dark"] .sector-btn:hover { background: #3d5068; border-color: var(--blue); }

[data-theme="dark"] .operator-card {
  background: #1e293b;
  box-shadow: 0 1px 3px rgba(0,0,0,0.4);
}
[data-theme="dark"] .operator-card:hover { border-color: var(--blue); }

[data-theme="dark"] .admin-tabs {
  background: #1e293b;
  border-bottom-color: #334155;
}
[data-theme="dark"] .admin-tab { color: #94a3b8; }
[data-theme="dark"] .admin-tab.active { color: #f3934f; border-color: #f3934f; }

[data-theme="dark"] table.data-table th,
[data-theme="dark"] .history-table th {
  background: #1e293b;
  color: #94a3b8;
  border-bottom-color: #334155;
}
[data-theme="dark"] table.data-table td,
[data-theme="dark"] .history-table td {
  border-bottom-color: #1e293b;
}
[data-theme="dark"] table.data-table tr:hover td,
[data-theme="dark"] .history-table tr:hover td {
  background: #273549;
}

[data-theme="dark"] .btn-gray {
  background: #334155;
  color: #e2e8f0;
}

[data-theme="dark"] .btn-outline {
  border-color: #f3934f;
  color: #f3934f;
}

[data-theme="dark"] .numpad-display {
  background: #334155;
  color: #f1f5f9;
}

[data-theme="dark"] .numpad-key {
  background: #334155;
  color: #f1f5f9;
}
[data-theme="dark"] .numpad-key:active { background: #475569; }
[data-theme="dark"] .numpad-key.danger { background: #450a0a; color: #fca5a5; }

[data-theme="dark"] .modal-box {
  background: #1e293b;
  border: 1px solid #334155;
}

[data-theme="dark"] .progress-bar-wrap { background: #334155; }

[data-theme="dark"] #connection-overlay { background: rgba(0,0,0,0.92); }

[data-theme="dark"] ::-webkit-scrollbar-thumb { background: #475569; }

/* Linha atrasada (tabelas de Prioridades etc.) — par claro/escuro legível */
.row-late { background: #fef2f2; }
[data-theme="dark"] .row-late { background: #3b1d1d; }

/* Theme toggle button */
.theme-toggle {
  background: none; border: none; cursor: pointer;
  font-size: 1.1rem; padding: 6px; border-radius: 6px;
  color: rgba(255,255,255,0.85);
  transition: background 0.15s;
}
.theme-toggle:hover { background: rgba(255,255,255,0.15); }

/* ── Requisition card (warehouse open panel) ── */
.req-card { transition: box-shadow 0.15s, border-color 0.15s; border: 2px solid var(--gray-200); }
.req-card.req-selected { border-color: var(--blue); box-shadow: 0 0 0 2px rgba(21,41,58,0.22); }
/* Requisição aberta há mais de 10 min: pisca para sinalizar prioridade */
.req-card.req-blink { animation: req-blink 1s ease-in-out infinite; border-color: #dc2626; }
@keyframes req-blink {
  0%, 100% { box-shadow: 0 0 0 2px rgba(220,38,38,0.15); background: rgba(220,38,38,0.04); }
  50% { box-shadow: 0 0 0 4px rgba(220,38,38,0.55); background: rgba(220,38,38,0.14); }
}

/* ── Print layout ── */
#print-area { display: none; }

@media print {
  body > *:not(#print-area) { display: none !important; }
  #print-area { display: block !important; }
  .slip-page { page-break-after: always; }
  .slip-page:last-child { page-break-after: auto; }

  /* Impressão é sempre em papel branco: força as variáveis do tema CLARO dentro do
     print-area, mesmo com o modo escuro ativo — senão markup compartilhado tela/impressão
     (ex.: relatórios do PCP, que copiam o HTML da tela) sairia com cores do tema escuro. */
  #print-area {
    --gray-50:  #f9fafb;
    --gray-100: #f3f4f6;
    --gray-200: #e5e7eb;
    --gray-300: #d1d5db;
    --gray-400: #9ca3af;
    --gray-500: #6b7280;
    --gray-700: #374151;
    --gray-900: #111827;
    --bg: #fff;
    --bg-card: #fff;
    --text: #111827;
    --text-muted: #6b7280;
    --border: #e5e7eb;
    color: #111;
    background: #fff;
  }
}

/* Dashed cut line between slips */
.slip-cut {
  border: none;
  border-top: 1px dashed #aaa;
  margin: 4mm 0;
}

.req-slip {
  width: 100%;
  box-sizing: border-box;
  border: 1px solid #999;
  padding: 6mm 10mm;
  font-family: Arial, sans-serif;
  color: #111;
  background: #fff;
  /* Never break a single slip across pages */
  break-inside: avoid;
  page-break-inside: avoid;
}

/* ── Crachás (impressão + plastificação) ── */
.badge-sheet {
  display: flex;
  flex-wrap: wrap;
  gap: 4mm;
  align-content: flex-start;
}
.badge-preview {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
}
.badge-card {
  width: 54mm;
  height: 86mm;
  box-sizing: border-box;
  border: 1px dashed #999;          /* guia de corte */
  border-radius: 3mm;
  overflow: hidden;
  background: #fff;
  color: #111;
  font-family: -apple-system, 'Segoe UI', Arial, sans-serif;
  display: flex;
  flex-direction: column;
  break-inside: avoid;
  page-break-inside: avoid;
  -webkit-print-color-adjust: exact;
  print-color-adjust: exact;
}
.badge-head {
  background: var(--blue);
  color: #fff;
  padding: 2mm 2.5mm;
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 2mm;
  min-height: 9mm;
  -webkit-print-color-adjust: exact;
  print-color-adjust: exact;
}
.badge-logo {
  margin-left: auto;     /* sempre no canto superior direito */
  max-height: 7mm;
  max-width: 45%;
  width: auto;
  object-fit: contain;
}
.badge-company {
  font-weight: 700;
  font-size: 3.2mm;
  letter-spacing: 0.3px;
}
.badge-body {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 3mm 3mm 2mm;
}
.badge-photo {
  width: 31mm;
  height: 37mm;
  border: 0.4mm solid var(--gray-300);
  border-radius: 1.5mm;
  margin: 1.5mm 0 2mm;
  display: flex;
  align-items: center;
  justify-content: center;
  background: repeating-linear-gradient(45deg, #fcfcfd, #fcfcfd 2mm, #f4f5f7 2mm, #f4f5f7 4mm);
}
.badge-photo span {
  color: var(--gray-400);
  font-size: 2.8mm;
  letter-spacing: 1.5px;
  font-weight: 600;
}
.badge-role {
  font-size: 2.3mm;
  letter-spacing: 2.5px;
  font-weight: 700;
  color: var(--blue);
  -webkit-print-color-adjust: exact;
  print-color-adjust: exact;
}
.badge-name {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  line-height: 1.05;
  margin: 0.8mm 0 auto;
  word-break: break-word;
}
.badge-first {
  font-size: 4.8mm;
  font-weight: 800;
  text-transform: uppercase;
  color: #000;
}
.badge-last {
  font-size: 4mm;
  font-weight: 700;
  text-transform: uppercase;
  color: #000;
  margin-top: 0.6mm;
}
.badge-name-sm .badge-first { font-size: 4mm; }
.badge-name-sm .badge-last { font-size: 3.4mm; }
.badge-barcode {
  width: 48mm;
  height: 14mm;
  margin-top: 1.5mm;
}
.badge-barcode .bc-svg { width: 100%; height: 100%; display: block; }
/* QR Code do crachá (substitui o Code39) */
.badge-qr-wrap {
  width: 18mm;
  height: 18mm;
  margin-top: 1.5mm;
}
.badge-qr { width: 100%; height: 100%; display: block; image-rendering: pixelated; }

/* Overlay do scanner de crachá (QR) */
.badge-scan-overlay {
  position: fixed; inset: 0; z-index: 4000;
  background: rgba(0,0,0,0.85);
  display: flex; align-items: center; justify-content: center;
  padding: 16px;
}
.badge-scan-overlay.hidden { display: none; }
.badge-scan-box {
  background: var(--card-bg, #fff);
  border-radius: 14px;
  padding: 16px;
  width: 100%; max-width: 380px;
}
.badge-scan-title { font-weight: 700; text-align: center; margin-bottom: 10px; }
.badge-scan-stage {
  width: 100%; aspect-ratio: 1/1;
  background: #000; border-radius: 10px; overflow: hidden;
}
.badge-scan-stage video { width: 100%; height: 100%; object-fit: cover; }
.badge-scan-hint { text-align: center; font-size: 0.85rem; color: var(--text-muted, #667); margin-top: 8px; }
.badge-code {
  font-family: 'Courier New', monospace;
  font-size: 3.8mm;
  font-weight: 700;
  letter-spacing: 3px;
  margin-top: 1mm;
  text-align: center;
  color: #000;
}
.badge-foot {
  height: 3mm;
  background: var(--blue);
  -webkit-print-color-adjust: exact;
  print-color-adjust: exact;
}

@media print {
  .badge-sheet { gap: 4mm; }
  .badge-card { border: 0.3mm dashed #bbb; }
}

/* ════════════ MÓDULO DE LOGÍSTICA ════════════ */
/* Cabeçalho empilhado: título centralizado, 🌙 à direita, ações embaixo */
.header.hdr-stacked {
  flex-direction: column;
  align-items: stretch;
  gap: 10px;
}
.hdr-title-row {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 32px;
  width: 100%;            /* ocupa a largura toda — menu (esq) e tema (dir) vão aos cantos */
}
.hdr-title-row .brand-logo { height: 32px; width: auto; }
.hdr-title-row h1 { margin: 0; text-align: center; padding: 0 46px; line-height: 1.2; }
.hdr-theme { position: absolute; right: 0; top: 50%; transform: translateY(-50%); }
.hdr-back {
  position: absolute; left: 0; top: 50%; transform: translateY(-50%);
  background: none; border: none; color: #fff; font-size: 1.5rem; cursor: pointer; padding: 4px;
}
.hdr-actions-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: center;
  align-items: center;
}
.hdr-btn { background: rgba(255,255,255,0.15); color: #fff; }
.hdr-operator { font-weight: 700; font-size: 0.95rem; color: #fff; }

/* Menu da tela inicial */
.hdr-menu-btn {
  position: absolute; left: 0; top: 50%; transform: translateY(-50%);
  background: none; border: none; color: #fff; font-size: 1.5rem; cursor: pointer; padding: 4px 8px;
}
.hdr-menu-list {
  position: fixed; top: 52px; left: 10px; z-index: 300;
  background: var(--bg-card, #fff);
  border: 1px solid var(--border, #ddd);
  border-radius: 10px;
  box-shadow: var(--shadow-md, 0 8px 24px rgba(0,0,0,0.18));
  display: flex; flex-direction: column; min-width: 230px;
  max-width: calc(100vw - 20px); overflow: hidden;
}
.hdr-menu-list button {
  background: none; border: none; text-align: left;
  padding: 14px 18px; font-size: 1rem; cursor: pointer;
  color: var(--text, #222); border-bottom: 1px solid var(--border, #eee);
}
.hdr-menu-list button:last-child { border-bottom: none; }
.hdr-menu-list button:active { background: var(--bg, #eef); }

/* Faixa/etiqueta de PRIORIDADE */
.prio-ribbon {
  display: inline-block; background: var(--red, #dc2626); color: #fff;
  font-size: 0.66rem; font-weight: 800; letter-spacing: 0.5px;
  padding: 2px 7px; border-radius: 4px; margin-right: 6px; text-transform: uppercase;
}
.logi-card.is-prio { border-left: 6px solid var(--red, #dc2626) !important; }
.exp-work-card.is-prio { border-left: 6px solid var(--red, #dc2626); }
.card.is-prio { border-left: 6px solid var(--red, #dc2626); }
.btn:disabled { opacity: 0.45; cursor: not-allowed; filter: grayscale(0.3); }

/* Cores por status */
:root {
  --st-ag_separacao: #f59e0b;
  --st-em_separacao: #3b82f6;
  --st-conferencia: #8b5cf6;
  --st-faturamento: #06b6d4;
  --st-ag_transportadora: #f97316;
  --st-expedido: #22c55e;
}

/* Chips / pills */
.logi-chip {
  display: inline-block;
  background: var(--bg-card, #eef);
  border: 1px solid var(--border, #ccd);
  border-radius: 10px;
  padding: 1px 8px;
  font-size: 0.72rem;
  margin: 1px 0;
}
.logi-pill {
  display: inline-block;
  border-radius: 10px;
  padding: 2px 9px;
  font-size: 0.72rem;
  font-weight: 700;
  color: #fff;
  background: #888;
  white-space: nowrap;
}
.logi-pill.st-ag_separacao { background: var(--st-ag_separacao); }
.logi-pill.st-em_separacao { background: var(--st-em_separacao); }
.logi-pill.st-conferencia { background: var(--st-conferencia); }
.logi-pill.st-faturamento { background: var(--st-faturamento); }
.logi-pill.st-ag_transportadora { background: var(--st-ag_transportadora); }
.logi-pill.st-expedido { background: var(--st-expedido); }

/* Kanban */
.logi-dash-toolbar { padding: 10px 12px 0; }
.logi-dash-toolbar input { width: 100%; max-width: 520px; }
.logi-kanban {
  display: flex;
  gap: 10px;
  overflow-x: auto;
  padding: 12px;
  flex: 1;
  align-items: flex-start;
}
.logi-col {
  flex: 1 0 230px;
  min-width: 230px;
  background: var(--bg-card, #f6f7f9);
  border: 1px solid var(--border, #e2e5ea);
  border-radius: 10px;
  display: flex;
  flex-direction: column;
  max-height: 100%;
}
.logi-col-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 10px;
  font-weight: 700;
  font-size: 0.82rem;
  color: #fff;
  border-radius: 10px 10px 0 0;
  background: #888;
}
.logi-col-head.st-ag_separacao { background: var(--st-ag_separacao); }
.logi-col-head.st-em_separacao { background: var(--st-em_separacao); }
.logi-col-head.st-conferencia { background: var(--st-conferencia); }
.logi-col-head.st-faturamento { background: var(--st-faturamento); }
.logi-col-head.st-ag_transportadora { background: var(--st-ag_transportadora); }
.logi-col-head.st-expedido { background: var(--st-expedido); }
/* Coleta de Produção: P9 = âmbar, P3 = azul, Conferido = verde */
.logi-col-head.st-ag_coleta_p9 { background: #f59e0b; }
.logi-col-head.st-ag_coleta_p3 { background: #2563eb; }
.logi-col-head.st-conferido { background: #22c55e; }
/* Caminhão: A Buscar = âmbar, Coletado = verde */
.logi-col-head.st-pendente { background: #f59e0b; }
.logi-col-head.st-coletado { background: #22c55e; }
.logi-count {
  background: rgba(0,0,0,0.22);
  border-radius: 9px;
  padding: 0 8px;
  font-size: 0.78rem;
}
.logi-col-today {
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--green-dark, #057a55);
  background: rgba(16,159,110,0.12);
  padding: 3px 10px;
  text-align: center;
}
.logi-col-body {
  padding: 8px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  overflow-y: auto;
}
.logi-empty { color: var(--text-muted, #999); text-align: center; padding: 8px; font-size: 0.85rem; }
.logi-card {
  background: var(--bg, #fff);
  border: 1px solid var(--border, #e2e5ea);
  border-left: 4px solid #888;
  border-radius: 8px;
  padding: 8px 10px;
  font-size: 0.82rem;
}
.logi-card.st-ag_separacao { border-left-color: var(--st-ag_separacao); }
.logi-card.st-em_separacao { border-left-color: var(--st-em_separacao); }
.logi-card.st-conferencia { border-left-color: var(--st-conferencia); }
.logi-card.st-faturamento { border-left-color: var(--st-faturamento); }
.logi-card.st-ag_transportadora { border-left-color: var(--st-ag_transportadora); }
.logi-card.st-expedido { border-left-color: var(--st-expedido); }
.logi-card.st-ag_coleta_p9 { border-left-color: #f59e0b; }
.logi-card.st-ag_coleta_p3 { border-left-color: #2563eb; }
.logi-card.st-conferido { border-left-color: #22c55e; }
.logi-card-top { display: flex; justify-content: space-between; align-items: center; }
.logi-vol { font-size: 0.7rem; color: var(--text-muted, #888); }
.logi-card-client { font-weight: 600; margin-top: 2px; }
.logi-card-meta { font-size: 0.74rem; color: var(--text-muted, #777); margin-top: 1px; }
.logi-card-prog { font-size: 0.72rem; margin-top: 4px; color: var(--blue, #2563eb); }
.logi-card-who { font-size: 0.72rem; margin-top: 3px; color: var(--text-muted, #555); }
.logi-timer { font-weight: 700; font-variant-numeric: tabular-nums; }

/* Card atrasado (>48h sem expedir) — pisca amarelo */
.logi-card.is-overdue { animation: blink-overdue 1.1s steps(1, end) infinite; }
@keyframes blink-overdue {
  0%, 49% { background: #fff7cc; border-left-color: #d97706 !important; box-shadow: 0 0 0 2px rgba(217,119,6,0.35); }
  50%, 100% { background: var(--bg, #fff); }
}

/* Card "Parado" no Dashboard */
.logi-card.is-stopped { border-left-color: var(--red, #dc2626) !important; background: rgba(220,38,38,0.06); }
.logi-card-stopped { margin: -8px -10px 6px; padding: 4px 10px; border-radius: 8px 8px 0 0; background: var(--red, #dc2626); color: #fff; }
.logi-stopped-top { font-weight: 800; font-size: 0.72rem; letter-spacing: 1px; }
.logi-stopped-reason { font-size: 0.78rem; font-weight: 600; }

/* Card "Parado" na Expedição */
.exp-stopped-card { border: 2px solid var(--red, #dc2626); background: rgba(220,38,38,0.06); text-align: center; }
.exp-stopped-title { font-weight: 800; color: var(--red, #dc2626); letter-spacing: 1px; }
.exp-stopped-reason { font-size: 1rem; font-weight: 600; margin-top: 2px; }

/* Itens da Expedição (checklist) */
.exp-item-list { display: flex; flex-direction: column; gap: 6px; }
.exp-item {
  display: grid;
  grid-template-columns: auto auto 1fr auto;
  align-items: center;
  gap: 10px;
  padding: 12px 10px;
  border: 2px solid var(--gray-200, #e2e5ea);
  border-radius: 10px;
  cursor: pointer;
}
.exp-item input[type=checkbox] { width: 22px; height: 22px; }
.exp-item-truck {
  flex-shrink: 0;
  background: var(--blue, #2563eb);
  color: #fff;
  border: none;
  border-radius: 8px;
  font-size: 1.15rem;
  line-height: 1;
  padding: 8px 10px;
  cursor: pointer;
}
.exp-item-truck:active { transform: scale(0.94); }
.exp-item.done { background: rgba(34,197,94,0.10); border-color: var(--st-expedido); }
.exp-item-qty { font-weight: 700; white-space: nowrap; }
.exp-item-main { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.exp-item-code { font-size: 0.78rem; font-weight: 700; color: var(--text-muted, #667); }
.exp-item-desc { font-size: 0.9rem; }

/* Expedição — leitura dos volumes por câmera */
.exp-scan-progress { text-align: center; font-weight: 700; margin: 8px 0; font-size: 1.05rem; }
.exp-scan-chips { display: flex; flex-wrap: wrap; gap: 6px; justify-content: center; margin-bottom: 8px; }
.exp-vol-chip { font-size: 0.85rem; padding: 4px 10px; border-radius: 999px; border: 2px solid var(--gray-200, #e2e5ea); color: var(--text-muted, #667); }
.exp-vol-chip.on { background: rgba(34,197,94,0.15); border-color: var(--st-expedido, #22c55e); color: #15803d; font-weight: 700; }
.exp-scan-stage { position: relative; width: 100%; max-width: 360px; margin: 0 auto; aspect-ratio: 1 / 1; background: #000; border-radius: 12px; overflow: hidden; }
.exp-scan-stage video { width: 100%; height: 100%; object-fit: cover; }
.exp-scan-hint { text-align: center; font-size: 0.85rem; color: var(--text-muted, #667); margin-top: 8px; }

/* QR na etiqueta de expedição */
.ship-label-qr { width: 24mm; height: 24mm; }

/* Worklist da Expedição */
.exp-worklist { display: flex; flex-direction: column; gap: 8px; margin-top: 10px; }
.exp-work-card {
  background: var(--bg, #fff);
  border: 1px solid var(--border, #e2e5ea);
  border-radius: 10px;
  padding: 12px 14px;
  cursor: pointer;
}
.exp-work-card:active { transform: scale(0.99); }

/* Cronômetro da Expedição */
.exp-timer-card { margin-bottom: 12px; }

/* Fotos da conferência */
.exp-photo-grid { display: flex; flex-wrap: wrap; gap: 8px; }
.exp-photo-thumb {
  width: 72px; height: 72px; object-fit: cover;
  border-radius: 8px; border: 1px solid var(--border, #ccd);
  display: block;
}
.exp-photo-wrap { position: relative; display: inline-block; }
.exp-photo-del {
  position: absolute; top: -6px; right: -6px;
  width: 22px; height: 22px; border-radius: 50%;
  border: none; background: var(--red, #dc2626); color: #fff;
  font-size: 13px; line-height: 22px; text-align: center; padding: 0;
  cursor: pointer; box-shadow: 0 1px 3px rgba(0,0,0,.4);
}

/* Etiquetas de remetente */
.ship-label-sheet { display: block; }
.ship-label {
  width: 100mm;
  box-sizing: border-box;
  border: 1px solid #999;
  padding: 6mm 8mm;
  margin: 0 auto 6mm;
  font-family: Arial, sans-serif;
  color: #111;
  background: #fff;
  break-inside: avoid;
  page-break-inside: avoid;
}
.ship-label-rem { border-bottom: 1px dashed #999; padding-bottom: 3mm; margin-bottom: 3mm; }
.ship-label-rem-name { font-size: 11pt; font-weight: 700; margin-top: 1mm; }
.ship-label-rem-line { font-size: 9pt; color: #333; }
.ship-label-head { font-size: 10pt; font-weight: 700; letter-spacing: 1px; color: #555; }
.ship-label-name { font-size: 15pt; font-weight: 700; margin: 2mm 0; }
.ship-label-addr { font-size: 11pt; }
.ship-label-doc { font-size: 11pt; margin-top: 1mm; }
.ship-label-row { display: flex; justify-content: space-between; align-items: center; margin-top: 4mm; }
.ship-label-row .lbl { font-size: 8pt; color: #555; text-transform: uppercase; }
.ship-label-vol { font-size: 22pt; font-weight: 800; border: 2px solid #000; padding: 2mm 5mm; border-radius: 2mm; }
.ship-label-foot { margin-top: 4mm; border-top: 1px dashed #999; padding-top: 2mm; font-size: 9pt; color: #333; }

/* Lista de vendas adicionadas na inclusão (juntar 2+ vendas) */
.logi-venda-list { display: flex; flex-direction: column; gap: 6px; }
.logi-venda-chip { display: flex; align-items: center; flex-wrap: wrap; gap: 4px; background: var(--surface-2, #f3f4f6); border: 1px solid var(--border, #e5e7eb); border-radius: 6px; padding: 6px 10px; font-size: 0.9rem; }

/* ════════════ MÓDULO PCP ════════════ */
.pcp-toolbar {
  display: flex; gap: 8px; align-items: center; flex-wrap: wrap;
  margin-bottom: 12px;
}
.pcp-toolbar input[type="text"], .pcp-toolbar input[type="date"], .pcp-toolbar input[type="month"],
.pcp-toolbar select {
  border: 2px solid var(--gray-200); border-radius: var(--radius);
  padding: 8px 10px; font-size: 0.88rem; background: var(--card-bg, #fff); color: inherit;
}
.pcp-chk { display: inline-flex; align-items: center; gap: 4px; font-size: 0.85rem; cursor: pointer; }

.pcp-table-wrap { overflow-x: auto; }
.pcp-table { min-width: 1100px; }
.pcp-table td { white-space: nowrap; }
.pcp-desc { max-width: 240px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pcp-mini { font-size: 0.72rem; }
.pcp-inp {
  border: 1px solid var(--gray-200); border-radius: 6px; padding: 4px 6px;
  font-size: 0.82rem; background: transparent; color: inherit; max-width: 150px;
}

.pcp-du { display: inline-block; min-width: 26px; text-align: center; padding: 2px 6px; border-radius: 999px; font-weight: 700; font-size: 0.8rem; }
.pcp-du-late { background: #fee2e2; color: #b91c1c; }
.pcp-du-warn { background: #fef3c7; color: #b45309; }
.pcp-du-ok { background: var(--gray-100, #f3f4f6); color: var(--gray-600, #4b5563); }
[data-theme="dark"] .pcp-du-late { background: #7f1d1d; color: #fecaca; }
[data-theme="dark"] .pcp-du-warn { background: #78350f; color: #fde68a; }
[data-theme="dark"] .pcp-du-ok { background: #374151; color: #d1d5db; }

.pcp-cap-bar { height: 10px; border-radius: 999px; background: var(--gray-100, #eef1f4); overflow: hidden; margin-top: 8px; }
.pcp-cap-fill { height: 100%; border-radius: 999px; background: #22c55e; transition: width 0.3s; }
.pcp-cap-fill.over { background: #ef4444; }

.pcp-seq-btn {
  border: none; background: none; cursor: pointer; font-size: 0.7rem; padding: 1px 3px;
  color: var(--gray-500, #6b7280);
}
.pcp-seq-btn:hover { color: var(--blue, #2563eb); }

.pcp-status { padding: 2px 10px; border-radius: 999px; font-size: 0.78rem; font-weight: 700; text-transform: capitalize; }
.pcp-st-aberto { background: #dbeafe; color: #1d4ed8; }
.pcp-st-enviado { background: #fef3c7; color: #b45309; }
.pcp-st-retornado { background: #dcfce7; color: #15803d; }
[data-theme="dark"] .pcp-st-aberto { background: #1e3a5f; color: #93c5fd; }
[data-theme="dark"] .pcp-st-enviado { background: #78350f; color: #fde68a; }
[data-theme="dark"] .pcp-st-retornado { background: #14532d; color: #86efac; }

/* PCP Cadastros */
.pcp-cad-layout { display: grid; grid-template-columns: 210px minmax(0, 1fr); gap: 14px; align-items: start; }
.pcp-cad-menu { position: sticky; top: 0; display: flex; flex-direction: column; gap: 6px; background: var(--card-bg, #fff); border: 1px solid var(--gray-200, #e5e7eb); border-radius: var(--radius, 10px); padding: 10px; }
.pcp-cad-menu button { text-align: left; border: 0; background: transparent; padding: 9px 10px; border-radius: 8px; cursor: pointer; font-weight: 700; color: var(--text, #111827); }
.pcp-cad-menu button:hover { background: var(--gray-100, #f3f4f6); }
.pcp-cad-main { display: flex; flex-direction: column; gap: 14px; min-width: 0; }
.pcp-cad-card { scroll-margin-top: 12px; }
.pcp-form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 10px 14px; }
@media (max-width: 800px) { .pcp-cad-layout { grid-template-columns: 1fr; } .pcp-cad-menu { position: static; } }

/* Impressões do PCP (folha de programação + romaneio) */
.pcp-print-sheet { font-family: Arial, sans-serif; color: #000; padding: 6mm; }
.pcp-print-head { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 4mm; border-bottom: 2px solid #000; padding-bottom: 2mm; }
.pcp-print-title { font-size: 14pt; font-weight: 800; }
.pcp-print-table { width: 100%; border-collapse: collapse; font-size: 9pt; }
.pcp-print-table th, .pcp-print-table td { border: 0.4pt solid #444; padding: 2pt 4pt; text-align: left; }
.pcp-print-table th { background: #eee; }
.pcp-print-sign { display: flex; justify-content: space-between; margin-top: 14mm; font-size: 10pt; }

/* ════════════ ROMANEIO DE ENVIO (identidade RR, paisagem) ════════════ */
/* Impresso via #print-area; @page landscape é injetado inline no printRomaneio(). */
.rr-romaneio { font-family: Arial, Helvetica, sans-serif; color: #1a1a1a; padding: 0; }

.rr-rom-band {
  display: flex; align-items: center; gap: 16px;
  border-bottom: 3px solid #15293a; padding-bottom: 8px; margin-bottom: 10px;
}
.rr-rom-logo { height: 46px; width: auto; }
.rr-rom-titlewrap { flex: 1; text-align: center; }
.rr-rom-title { font-size: 20pt; font-weight: 800; color: #15293a; letter-spacing: 1px; line-height: 1; }
.rr-rom-sub { font-size: 11pt; font-weight: 700; color: #5a6b7a; margin-top: 3px; letter-spacing: 3px; }
.rr-rom-lote {
  background: #15293a; color: #fff; border-radius: 8px; padding: 6px 16px; text-align: center; min-width: 84px;
}
.rr-rom-lote-lbl { font-size: 8pt; letter-spacing: 2px; opacity: 0.85; }
.rr-rom-lote-num { font-size: 22pt; font-weight: 800; line-height: 1; }

.rr-rom-meta {
  display: flex; flex-wrap: wrap; gap: 8px 26px; margin-bottom: 10px; padding: 6px 10px;
  background: #f0f3f6; border-radius: 6px; border: 0.5pt solid #d3dae1;
}
.rr-rom-meta > div { display: flex; flex-direction: column; }
.rr-rom-meta span { font-size: 7.5pt; text-transform: uppercase; letter-spacing: 0.5px; color: #6b7885; }
.rr-rom-meta strong { font-size: 11pt; color: #15293a; }
.rr-rom-obs { flex: 1; min-width: 200px; }

.rr-rom-table { width: 100%; border-collapse: collapse; font-size: 9.5pt; }
.rr-rom-table th {
  background: #15293a; color: #fff; padding: 5pt 6pt; text-align: left;
  font-size: 8.5pt; letter-spacing: 0.4px; border: 0.5pt solid #15293a;
}
.rr-rom-table td { padding: 4pt 6pt; border: 0.5pt solid #b9c2cc; }
.rr-rom-table tbody tr:nth-child(even) { background: #f4f7fa; }
.rr-rom-table .c-seq { width: 26px; text-align: center; color: #6b7885; }
.rr-rom-table .c-op { width: 60px; font-weight: 700; }
.rr-rom-table .c-cod { width: 74px; }
.rr-rom-table .c-cor { width: 78px; }
.rr-rom-table .c-qtd { width: 48px; text-align: right; font-weight: 700; }
.rr-rom-table .c-cx { width: 120px; }
.rr-rom-table .c-ret { width: 96px; }
.rr-rom-table td.c-ret { background: #fbfbfb; }
.rr-rom-table .rr-rom-total td {
  background: #dde4ea; font-weight: 800; color: #15293a; font-size: 10pt; border-color: #15293a;
}
.rr-rom-table .rr-rom-total td:first-child { text-align: right; letter-spacing: 1px; }

.rr-rom-sign { display: flex; justify-content: space-between; gap: 40px; margin-top: 20mm; }
.rr-rom-sign > div { flex: 1; text-align: center; font-size: 9pt; color: #5a6b7a; }
.rr-rom-sign-line { border-top: 1pt solid #333; margin-bottom: 4px; }

/* Colunas específicas da folha de PROGRAMAÇÃO (reusa .rr-rom-table) */
.rr-rom-table .c-prazo { width: 78px; }
.rr-rom-table .c-ok { width: 90px; }
.rr-rom-table td.c-ok { background: #fbfbfb; }

/* Cabeçalho de seção por dia nas folhas de programação semanal (Será Levado / PXA / Prolongador) */
.rr-rom-daygroup { page-break-inside: avoid; margin-top: 12px; }
.rr-rom-daygroup:first-child { margin-top: 0; }
.rr-rom-daysec {
  background: #15293a; color: #fff; font-weight: 800; font-size: 10pt;
  letter-spacing: 0.5px; padding: 5pt 10pt; border-radius: 5px 5px 0 0;
}
.rr-rom-daygroup .rr-rom-table { margin-top: 0; }

/* ─── Programação semanal (PXA / Será Levado) ─── */
.pcp-week-grid { display: grid; grid-template-columns: repeat(5, 1fr); gap: 10px; }
@media (max-width: 900px) { .pcp-week-grid { grid-template-columns: 1fr; } }
.pcp-week-col { background: var(--bg-card, #f6f7f9); border: 1px solid var(--border, #e2e5ea); border-radius: 10px; display: flex; flex-direction: column; min-height: 120px; }
.pcp-week-head { padding: 8px 10px; border-bottom: 2px solid var(--blue, #15293a); font-weight: 700; font-size: 0.85rem; border-radius: 10px 10px 0 0; }
.pcp-week-date { font-weight: 400; font-size: 0.72rem; color: var(--gray-500, #6b7280); margin-left: 6px; }
.pcp-week-sub { font-size: 0.74rem; font-weight: 600; color: var(--gray-500, #6b7280); margin-top: 2px; }
.pcp-week-body { padding: 8px; display: flex; flex-direction: column; gap: 6px; }
.pcp-week-card { background: var(--card-bg, #fff); border: 1px solid var(--gray-200, #e5e7eb); border-radius: 8px; padding: 7px 8px; }
.pcp-week-card-top { display: flex; align-items: center; gap: 6px; }
.pcp-week-card-top strong { flex: 1; font-size: 0.85rem; }
.pcp-week-qty { font-weight: 700; font-size: 0.9rem; }
.pcp-week-desc { font-size: 0.74rem; color: var(--gray-600, #4b5563); margin: 3px 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pcp-week-foot { display: flex; align-items: center; gap: 4px; flex-wrap: wrap; }
.pcp-week-move { display: flex; gap: 2px; flex: 1; }
.pcp-week-del { padding: 1px 6px !important; font-size: 0.7rem !important; }
.pcp-star { background: none; border: none; cursor: pointer; font-size: 1rem; color: var(--gray-400, #9ca3af); padding: 0; }
.pcp-star.on { color: #f59e0b; }
.pcp-sale-cell { display: flex; align-items: center; gap: 6px; }
.pcp-sale-dot {
  display: inline-block; width: 10px; height: 10px; min-width: 10px;
  border-radius: 50%; box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.18);
}
.pcp-sale-dot-green { background: #22c55e; }
.pcp-sale-dot-yellow { background: #facc15; }
.pcp-tipo { padding: 1px 7px; border-radius: 999px; font-size: 0.68rem; font-weight: 700; }
.pcp-tipo-redondo { background: #dbeafe; color: #1d4ed8; }
.pcp-tipo-bc { background: #fef3c7; color: #b45309; }
[data-theme="dark"] .pcp-tipo-redondo { background: #1e3a5f; color: #93c5fd; }
[data-theme="dark"] .pcp-tipo-bc { background: #78350f; color: #fde68a; }
