/* ============================================
   SpeedBox Coleta — Design System v0.6
   ============================================ */

/* --- Design Tokens --- */
:root {
  /* Cores primárias */
  --bg: #f3f6fa;
  --card: #ffffff;
  --text: #17202a;
  --muted: #667085;
  --line: #d7dee8;
  --primary: #0b84ff;
  --primary-dark: #0064c9;
  --primary-light: #b7dbff;

  /* Cores semânticas */
  --success: #138a5b;
  --success-bg: #e8f7ef;
  --warning: #a86400;
  --warning-bg: #fff7e6;
  --warning-border: #ffd38a;
  --danger: #c62828;
  --danger-bg: #fdecec;
  --danger-border: #f3c1c1;
  --info: #005bbb;
  --info-bg: #edf4ff;

  /* Superfícies */
  --surface: #fbfcfe;
  --surface-hover: #fafcff;
  --surface-alt: #f8fafc;
  --surface-input: #f2f4f7;
  --surface-secondary: #eef2f7;

  /* Sidebar */
  --sidebar: #0f172a;
  --sidebar-soft: #1e293b;
  --sidebar-text: #dbe7f3;
  --sidebar-muted: #cbd5e1;
  --sidebar-border: rgba(255, 255, 255, .12);
  --sidebar-hover: rgba(255, 255, 255, .08);

  /* Sombras */
  --shadow: 0 14px 35px rgba(31, 41, 51, 0.08);
  --shadow-soft: 0 10px 24px rgba(31, 41, 51, .06);
  --shadow-modal: 0 20px 70px rgba(0, 0, 0, .25);
  --shadow-login: 0 30px 80px rgba(0, 0, 0, .3);
  --shadow-toast: 0 8px 24px rgba(0, 0, 0, .15);

  /* Tipografia */
  --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --font-mono: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, 'Liberation Mono', monospace;

  /* Bordas */
  --radius-sm: 7px;
  --radius: 9px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --radius-xl: 18px;
  --radius-full: 999px;

  /* Transições */
  --transition-fast: 0.15s ease;
  --transition: 0.2s ease;
  --transition-slow: 0.3s ease;

  /* Label colors */
  --label-color: #344054;
  --input-border: #b8c2cf;
  --table-border: #edf0f3;
  --table-header-color: #475467;
}

/* --- Reset & Base --- */
* { box-sizing: border-box; }
body {
  margin: 0;
  min-height: 100vh;
  font-family: var(--font-sans);
  background: var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}
.hidden { display: none !important; }

.icon-btn.manual-read-confirmed {
  background: var(--success);
  color: #fff;
  border-color: var(--success);
}

.icon-btn.manual-read-confirmed:hover:not(:disabled) {
  background: #0f734b;
  color: #fff;
}

button.bulk-manual-read-btn.secondary {
  background: var(--warning-bg);
  color: #8a5a00;
  border: 1px solid var(--warning-border);
}

button.bulk-manual-read-btn.secondary:hover:not(:disabled) {
  background: #f3deb2;
  color: #734a00;
}

button.bulk-manual-read-btn.secondary:disabled {
  opacity: .55;
  cursor: not-allowed;
}

.bulk-manual-read-modal {
  max-width: 560px;
}

.bulk-manual-read-modal textarea {
  min-height: 120px;
  resize: vertical;
}

/* --- Login --- */
.login-screen {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: linear-gradient(135deg, #0f172a, #164a7a);
}
.login-card {
  width: min(420px, 100%);
  background: #fff;
  border-radius: 20px;
  padding: 32px;
  box-shadow: var(--shadow-login);
}
.login-card h1 { margin: 0 0 8px; font-size: 26px; font-weight: 800; letter-spacing: -0.3px; }
.login-card p { color: var(--muted); margin: 0 0 20px; font-size: 14px; line-height: 1.5; }

/* --- App Shell --- */
.app-shell { height: 100vh; display: flex; overflow: hidden; }
.environment-banner {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 1200;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 38px;
  padding: 8px 16px;
  background: #b42318;
  color: #fff;
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.02em;
  text-align: center;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.12);
}
body.environment-development .login-screen.with-environment-banner {
  padding-top: 38px;
}
body.environment-development .app-shell {
  padding-top: 38px;
  height: 100vh;
}

/* --- Sidebar --- */
.sidebar {
  background: var(--sidebar);
  color: #fff;
  padding: 18px;
  display: flex;
  flex-direction: column;
  height: 100%;
  width: 260px;
  flex-shrink: 0;
  overflow-y: auto;
  overflow-x: hidden;
  transition: width 0.3s cubic-bezier(0.4, 0, 0.2, 1), padding 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}
.brand-block {
  display: flex;
  align-items: center;
  gap: 12px;
  padding-bottom: 18px;
  border-bottom: 1px solid var(--sidebar-border);
  position: relative;
}
.brand-block strong { display: block; font-size: 15px; font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.brand-block small { display: block; color: var(--sidebar-muted); margin-top: 3px; }
.app-meta-line {
  display: flex !important;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}
.environment-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 22px;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 800;
  line-height: 1;
  border: 1px solid transparent;
}
.environment-badge-production {
  background: rgba(16, 185, 129, 0.16);
  color: #d1fae5;
  border-color: rgba(16, 185, 129, 0.32);
}
.environment-badge-development {
  background: rgba(249, 115, 22, 0.18);
  color: #ffedd5;
  border-color: rgba(249, 115, 22, 0.34);
}
.brand-text {
  min-width: 0;
  transition: opacity 0.2s ease, max-width 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  opacity: 1;
  max-width: 200px;
}
.brand-mark {
  width: 42px;
  height: 42px;
  flex: 0 0 42px;
  border-radius: var(--radius-md);
  background: var(--primary);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 900;
  border: 0;
  color: #fff;
  cursor: default;
  padding: 0;
  position: relative;
  overflow: hidden;
}
.sidebar-toggle {
  margin-left: auto;
  width: 34px;
  height: 34px;
  padding: 0;
  border-radius: 10px;
  background: var(--sidebar-hover);
  color: #fff;
  border: 1px solid var(--sidebar-border);
  transition: background var(--transition-fast);
}
.sidebar-toggle:hover { background: rgba(255, 255, 255, .15); }

.side-nav { display: grid; gap: 4px; margin-top: 18px; }
.side-nav button {
  width: 100%;
  justify-content: flex-start;
  background: transparent;
  color: var(--sidebar-text);
  border: 1px solid transparent;
  display: flex;
  align-items: center;
  gap: 10px;
  border-radius: var(--radius);
  position: relative;
  transition: background var(--transition-fast), color var(--transition-fast);
}
.side-nav button:hover { background: var(--sidebar-hover); }
.side-nav button.active { background: var(--primary); color: white; }
.nav-icon {
  width: 20px;
  height: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.nav-icon svg { width: 20px; height: 20px; stroke-width: 1.8; }
.nav-label {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 14px;
  transition: opacity 0.2s ease, max-width 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  opacity: 1;
  max-width: 200px;
}

.sidebar-footer {
  margin-top: auto;
  border-top: 1px solid var(--sidebar-border);
  padding-top: 14px;
}
.user-box {
  font-size: 13px;
  color: var(--sidebar-text);
  margin-bottom: 10px;
  line-height: 1.35;
  transition: opacity 0.2s ease, max-height 0.3s cubic-bezier(0.4, 0, 0.2, 1), margin-bottom 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  opacity: 1;
  max-height: 100px;
  overflow: hidden;
}

#btnLogout {
  transition: opacity 0.2s ease, max-height 0.3s cubic-bezier(0.4, 0, 0.2, 1), padding 0.3s cubic-bezier(0.4, 0, 0.2, 1), margin 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  opacity: 1;
  max-height: 40px;
  overflow: hidden;
}

#btnThemeToggle span {
  transition: opacity 0.2s ease, max-width 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  opacity: 1;
  max-width: 120px;
  overflow: hidden;
  white-space: nowrap;
}

/* Sidebar collapsed */
body.sidebar-collapsed .sidebar {
  width: 78px;
  padding-left: 12px;
  padding-right: 12px;
}
body.sidebar-collapsed .brand-text {
  opacity: 0;
  max-width: 0;
  pointer-events: none;
}
body.sidebar-collapsed .nav-label {
  opacity: 0;
  max-width: 0;
  pointer-events: none;
}
body.sidebar-collapsed .user-box {
  opacity: 0;
  max-height: 0;
  margin-bottom: 0;
  pointer-events: none;
}
body.sidebar-collapsed #btnLogout {
  opacity: 0;
  max-height: 0;
  padding: 0;
  border: 0;
  margin: 0;
  pointer-events: none;
}
body.sidebar-collapsed #btnThemeToggle {
  padding: 8px 0;
  justify-content: center;
}
body.sidebar-collapsed #btnThemeToggle span {
  opacity: 0;
  max-width: 0;
  pointer-events: none;
}
body.sidebar-collapsed .brand-block { justify-content: center; flex-wrap: wrap; gap: 6px; padding-bottom: 18px; }
body.sidebar-collapsed .brand-mark { cursor: pointer; }
body.sidebar-collapsed .sidebar-toggle { display: none; margin-left: 0; }
body.sidebar-collapsed .side-nav button { justify-content: center; padding: 10px 0; }

/* Brand Mark hover animation when collapsed */
.brand-logo-text, .brand-expand-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 100%;
  position: absolute;
  top: 0;
  left: 0;
  transition: opacity 0.25s ease, transform 0.25s ease;
}
.brand-expand-icon {
  opacity: 0;
  transform: scale(0.6);
}
body.sidebar-collapsed .brand-mark:hover .brand-logo-text {
  opacity: 0;
  transform: scale(0.6);
}
body.sidebar-collapsed .brand-mark:hover .brand-expand-icon {
  opacity: 1;
  transform: scale(1);
}

/* --- Workspace --- */
.workspace { flex: 1; min-width: 0; min-height: 0; height: 100%; overflow-y: auto; display: flex; flex-direction: column; }
.page-header {
  padding: 22px 28px;
  background: #fff;
  border-bottom: 1px solid var(--line);
}
.page-header h1 { margin: 0 0 6px; font-size: 24px; font-weight: 700; letter-spacing: -0.3px; }
.page-header p { margin: 0; color: var(--muted); font-size: 14px; }
main { padding: 20px 28px 32px; flex: 1; display: flex; flex-direction: column; min-height: 0; }

/* --- Tabs --- */
.tab-panel { display: none; animation: fadeIn var(--transition) ease; }
.tab-panel.active { display: block; }
#tab-importacoes.active {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
}
#tab-importacoes #consultaPostalPreviewBody {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
}
#tab-importacoes #consultaPostalPreviewBody .empty-state {
  flex: 1;
  min-height: clamp(280px, calc(100vh - 340px), 640px);
  margin-bottom: 0;
}
@keyframes fadeIn { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: translateY(0); } }

/* --- Grid & Cards --- */
.grid { display: grid; gap: 16px; }
.grid.two { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  padding: 16px;
  box-shadow: var(--shadow);
  margin-bottom: 16px;
}
.card h2 { margin: 0 0 8px; font-size: 18px; font-weight: 700; }
.readable { max-width: 950px; line-height: 1.6; }

/* --- Step Cards (details/summary) --- */
.step-card { padding: 0; }
.step-card summary {
  list-style: none;
  cursor: pointer;
  padding: 16px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 1px solid var(--line);
  background: var(--surface);
  transition: background var(--transition-fast);
  border-top-left-radius: var(--radius-lg);
  border-top-right-radius: var(--radius-lg);
}
.step-card:not([open]) summary {
  border-bottom-left-radius: var(--radius-lg);
  border-bottom-right-radius: var(--radius-lg);
  border-bottom: none;
}
.step-card summary::-webkit-details-marker { display: none; }
.step-card summary span { font-weight: 800; font-size: 16px; }
.step-card summary small { color: var(--muted); }
.step-card summary:hover { background: var(--surface-hover); }
.step-card[open] { padding-bottom: 16px; }
.step-card[open] > *:not(summary) { margin-left: 16px; margin-right: 16px; }
.disabled-block { opacity: 0.45; pointer-events: none; }

/* --- Forms --- */
label { display: block; font-size: 13px; font-weight: 700; color: var(--label-color); margin: 10px 0 5px; }
input, select, textarea {
  width: 100%;
  padding: 10px 11px;
  border: 1px solid var(--input-border);
  border-radius: var(--radius);
  font-size: 15px;
  font-family: var(--font-sans);
  background: white;
  color: var(--text);
  transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
}
textarea { resize: vertical; }
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(11, 132, 255, 0.12);
}
input[readonly], input:disabled, textarea:disabled, select:disabled {
  background: var(--surface-input);
  color: var(--muted);
}
.checkline { display: flex; align-items: center; gap: 8px; font-weight: 500; }
.checkline input { width: auto; }
.field-label { display: flex; align-items: baseline; gap: 6px; }
.hint { margin-top: 8px; font-size: 13px; color: var(--muted); }
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.postmaxi-mode-block {
  margin: 0 0 16px;
  width: 100%;
  max-width: 520px;
}

.postmaxi-mode-btn {
  width: 100%;
  display: grid;
  grid-template-columns: 42px minmax(0, 1fr) auto;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  background: #fff;
  color: var(--text);
  text-align: left;
  box-shadow: none;
  cursor: pointer;
  transition: border-color var(--transition-fast), background var(--transition-fast), box-shadow var(--transition-fast);
}

.postmaxi-mode-btn:hover {
  border-color: var(--primary-light);
  background: var(--surface-hover);
}

.postmaxi-mode-btn.active {
  border-color: var(--primary);
  background: var(--info-bg);
  box-shadow: 0 0 0 3px rgba(11, 132, 255, 0.08);
}

.postmaxi-mode-btn:disabled {
  opacity: 0.65;
  cursor: not-allowed;
}

.postmaxi-mode-icon {
  width: 42px;
  height: 42px;
  border-radius: var(--radius-md);
  background: var(--surface-secondary);
  color: var(--primary);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  font-weight: 800;
  flex: 0 0 auto;
}

.postmaxi-mode-btn.active .postmaxi-mode-icon {
  background: var(--primary);
  color: #fff;
}

.postmaxi-mode-copy {
  min-width: 0;
}

.postmaxi-mode-copy strong {
  display: block;
  font-size: 14px;
  line-height: 1.3;
  color: var(--text);
}

.postmaxi-mode-copy small {
  display: block;
  margin-top: 3px;
  font-size: 12px;
  line-height: 1.35;
  color: var(--muted);
  font-weight: 500;
}

.postmaxi-mode-state {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 62px;
  padding: 5px 9px;
  border-radius: var(--radius-full);
  background: var(--surface-secondary);
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.postmaxi-mode-btn.active .postmaxi-mode-state {
  background: var(--primary);
  color: #fff;
}

.selected-customer-info {
  min-height: 18px;
  margin: 8px 0 0;
  font-size: 13px;
  color: var(--muted);
}

.post-confirm-modal {
  max-width: 100%;
}

.post-confirm-modal-header {
  margin-bottom: 16px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--line);
}

.post-confirm-modal-header h2 {
  margin: 0;
  font-size: 1.55rem;
  letter-spacing: -0.02em;
}

.post-confirm-modal-header p {
  margin: 6px 0 0;
  font-size: 13px;
}

.post-confirm-summary-card {
  margin-bottom: 16px;
  padding: 14px 16px;
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  background: linear-gradient(180deg, #f3f7fc 0%, var(--surface-secondary) 100%);
  display: grid;
  gap: 10px;
  font-size: 13px;
}

.post-confirm-summary-row {
  display: grid;
  grid-template-columns: 104px minmax(0, 1fr);
  gap: 10px;
  align-items: center;
}

.post-confirm-summary-row strong {
  color: var(--label-color);
}

.post-confirm-summary-row span {
  min-width: 0;
}

.post-confirm-toggle-block {
  margin: 0 0 16px;
}

.post-confirm-toggle-btn {
  width: 100%;
  display: grid;
  grid-template-columns: 42px minmax(0, 1fr) auto;
  align-items: center;
  gap: 12px;
  padding: 14px 15px;
  border: 1px solid var(--warning-border);
  border-radius: var(--radius-md);
  background: linear-gradient(180deg, #fff9ef 0%, var(--warning-bg) 100%);
  color: var(--text);
  text-align: left;
  box-shadow: none;
  cursor: pointer;
  transition: border-color var(--transition-fast), background var(--transition-fast), box-shadow var(--transition-fast), transform var(--transition-fast);
}

.post-confirm-toggle-btn:hover {
  border-color: #f0bc57;
  box-shadow: 0 6px 18px rgba(168, 100, 0, 0.08);
  transform: translateY(-1px);
}

.post-confirm-toggle-btn.active {
  border-color: #d59624;
  background: linear-gradient(180deg, #fff2d5 0%, #ffe7b3 100%);
  box-shadow: 0 0 0 3px rgba(213, 150, 36, 0.12);
}

.post-confirm-toggle-icon {
  width: 42px;
  height: 42px;
  border-radius: var(--radius-md);
  background: rgba(168, 100, 0, 0.12);
  color: var(--warning);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  font-weight: 800;
  flex: 0 0 auto;
}

.post-confirm-toggle-btn.active .post-confirm-toggle-icon {
  background: var(--warning);
  color: #fff;
}

.post-confirm-toggle-copy {
  min-width: 0;
}

.post-confirm-toggle-copy strong {
  display: block;
  font-size: 14px;
  line-height: 1.3;
  color: var(--text);
}

.post-confirm-toggle-copy small {
  display: block;
  margin-top: 4px;
  font-size: 12px;
  line-height: 1.4;
  color: var(--muted);
  font-weight: 500;
}

.post-confirm-toggle-state {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 62px;
  padding: 5px 9px;
  border-radius: var(--radius-full);
  background: rgba(168, 100, 0, 0.08);
  color: var(--warning);
  font-size: 12px;
  font-weight: 800;
}

.post-confirm-toggle-btn.active .post-confirm-toggle-state {
  background: var(--warning);
  color: #fff;
}

.customer-search-launch-wrap {
  margin: 0 0 16px;
  display: flex;
  justify-content: flex-start;
  align-items: center;
}

.customer-search-launch {
  width: auto;
  min-width: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  white-space: nowrap;
}

.customer-search-launch svg {
  width: 16px;
  height: 16px;
}

.icon-search-btn svg {
  width: 18px;
  height: 18px;
}

.icon-search-btn {
  width: 42px;
  min-width: 42px;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.customer-search-modal {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.customer-search-modal-bar {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 42px;
  gap: 8px;
}

.customer-search-modal-results {
  display: flex;
  flex-direction: column;
  gap: 10px;
  min-height: 80px;
}

.customer-search-result-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface-secondary);
}

.customer-search-result-main {
  min-width: 0;
}

.customer-search-result-main strong,
.customer-search-result-main small {
  display: block;
}

.customer-search-result-main small {
  margin-top: 4px;
  color: var(--muted);
  line-height: 1.4;
}

.customer-update-modal {
  max-width: 640px;
}

.customer-change-list {
  display: grid;
  gap: 12px;
  margin: 16px 0 20px;
}

.customer-change-row {
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  padding: 12px;
  background: var(--surface-secondary);
}

.customer-change-row > strong {
  display: block;
  margin-bottom: 8px;
  color: var(--text);
}

.customer-change-values {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.customer-change-before,
.customer-change-after {
  border-radius: var(--radius);
  padding: 10px;
}

.customer-change-before {
  background: rgba(239, 68, 68, 0.12);
  color: var(--danger);
}

.customer-change-after {
  background: rgba(11, 132, 255, 0.12);
  color: var(--primary);
}

.customer-change-before span,
.customer-change-after span {
  display: block;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  margin-bottom: 4px;
}

.customer-change-before p,
.customer-change-after p {
  margin: 0;
  color: inherit;
  font-weight: 700;
}

@media (max-width: 640px) {
  .environment-banner {
    min-height: 44px;
    padding: 10px 12px;
    font-size: 11px;
    line-height: 1.35;
  }
  body.environment-development .login-screen.with-environment-banner {
    padding-top: 44px;
  }
  body.environment-development .app-shell {
    padding-top: 44px;
    height: 100vh;
  }
  .customer-change-values {
    grid-template-columns: 1fr;
  }

  .postmaxi-mode-block {
    width: 100%;
    max-width: none;
  }

  .postmaxi-mode-btn {
    width: 100%;
    grid-template-columns: 36px minmax(0, 1fr);
  }

  .postmaxi-mode-state {
    grid-column: 2;
    justify-self: flex-start;
  }

  .postmaxi-mode-icon {
    width: 36px;
    height: 36px;
  }

  .consulta-postal-summary-grid {
    grid-template-columns: 1fr 1fr;
  }
}
.warnings { margin-top: 10px; color: var(--warning); font-size: 13px; }
.warnings div {
  background: var(--warning-bg);
  border: 1px solid var(--warning-border);
  padding: 8px;
  border-radius: 8px;
  margin-top: 5px;
}
.tracking-precheck-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}
.tracking-precheck-copy {
  min-width: 0;
  display: grid;
  gap: 3px;
}
.tracking-precheck-copy strong {
  font-size: 13px;
}
.tracking-precheck-copy small {
  font-size: 12px;
  color: inherit;
}
.tracking-precheck-item-block {
  background: var(--danger-bg) !important;
  border-color: var(--danger-border) !important;
  color: var(--danger);
}
.tracking-precheck-item-warn {
  background: var(--warning-bg) !important;
  border-color: var(--warning-border) !important;
  color: var(--warning);
}
.tracking-precheck-item-positive {
  background: var(--success-bg) !important;
  border-color: rgba(19, 138, 91, 0.28) !important;
  color: var(--success);
}
.tracking-precheck-item-pass {
  background: var(--info-bg) !important;
  border-color: var(--primary-light) !important;
  color: var(--info);
}
.tracking-precheck-action {
  flex: 0 0 auto;
  padding: 7px 10px;
  font-size: 12px;
  font-weight: 700;
  background: rgba(255,255,255,0.82);
  color: inherit;
  border: 1px solid currentColor;
}
.tracking-precheck-modal {
  width: 100%;
}
.tracking-precheck-modal .modal-dialog-body {
  max-height: calc(90vh - 150px);
  overflow: auto;
}
.tracking-precheck-modal .table-wrap {
  max-height: calc(90vh - 290px);
  overflow: auto;
}
.tracking-precheck-modal table {
  min-width: 100%;
}
.tracking-precheck-modal th,
.tracking-precheck-modal td {
  white-space: normal;
  vertical-align: top;
}
.locked-note { color: var(--muted); font-size: 11px; font-weight: 500; }

/* --- Buttons --- */
button, .link-button {
  border: 0;
  padding: 10px 12px;
  border-radius: var(--radius);
  font-size: 14px;
  font-family: var(--font-sans);
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  transition: background var(--transition-fast), transform var(--transition-fast), box-shadow var(--transition-fast);
}
button:hover:not(:disabled) { transform: translateY(-1px); }
button:active:not(:disabled) { transform: translateY(0); }
button:disabled { cursor: not-allowed; opacity: 0.55; }
.primary { background: var(--primary); color: white; }
.primary:hover:not(:disabled) { background: var(--primary-dark); box-shadow: 0 4px 12px rgba(11, 132, 255, 0.3); }
.secondary { background: var(--surface-secondary); color: #111827; border: 1px solid #cdd5df; }
.secondary:hover:not(:disabled) { background: #e5eaf0; }
.danger { color: var(--danger); }
.full { width: 100%; margin-top: 12px; }
.big { font-size: 16px; padding: 13px 18px; font-weight: 700; }
.small-btn { padding: 6px 8px; font-size: 12px; border-radius: var(--radius-sm); }
.icon-btn {
  width: 31px;
  height: 31px;
  padding: 0;
  border-radius: 8px;
  background: var(--surface-secondary);
  border: 1px solid #d5dde8;
  color: #111827;
}
.icon-btn:hover:not(:disabled) { background: #dde3eb; }
.icon-btn.micro { width: 22px; height: 22px; font-size: 11px; margin-left: 4px; }
.icon-btn.danger { color: var(--danger); background: #fff2f2; border-color: var(--danger-border); }
.icon-btn.danger:hover:not(:disabled) { background: var(--danger-bg); }

/* --- Loading Spinner --- */
.spinner {
  width: 16px;
  height: 16px;
  border: 2px solid rgba(255, 255, 255, .3);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
  display: inline-block;
}
.secondary .spinner {
  border-color: rgba(0, 0, 0, .15);
  border-top-color: #333;
}
@keyframes spin { to { transform: rotate(360deg); } }
.spin { animation: spin 1s linear infinite; }
.btn-loading { pointer-events: none; opacity: 0.8; }

/* --- Layouts --- */
.action-row { display: flex; flex-wrap: wrap; gap: 8px; margin: 12px 0; }
.dual-actions { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-top: 14px; }
.section-row { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; flex-wrap: wrap; }
.imports-mode-switcher { display: flex; flex-wrap: wrap; gap: 8px; }
.filters { display: flex; gap: 8px; min-width: min(620px, 100%); }
.filters input { min-width: 260px; }
.compact-filter { min-width: min(720px, 100%); }
.objects-toolbar { display: flex; justify-content: flex-start; }
.collection-status-bar {
  margin-top: 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  padding: 12px;
  background: var(--surface);
}

.consulta-postal-actions {
  align-items: flex-end;
  justify-content: flex-start;
}

.consulta-postal-summary-grid {
  grid-template-columns: repeat(4, minmax(0, 1fr));
  margin-bottom: 16px;
}

.consulta-postal-filter-card {
  width: 100%;
  text-align: left;
  padding: 14px 16px;
  border: 1px solid var(--line);
}

.consulta-postal-filter-card.active {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(11, 132, 255, 0.08);
}

.consulta-postal-stat.ok {
  border-color: rgba(19, 138, 91, 0.2);
  background: var(--success-bg);
}

.consulta-postal-stat.warn {
  border-color: rgba(168, 100, 0, 0.18);
  background: var(--warning-bg);
}

.consulta-postal-stat.danger {
  border-color: rgba(198, 40, 40, 0.18);
  background: var(--danger-bg);
}

.consulta-postal-group h3 {
  margin-bottom: 4px;
}

.consulta-postal-steps {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 12px;
  margin-bottom: 14px;
  font-size: 12.5px;
  color: var(--muted);
}

.consulta-postal-steps span {
  padding: 6px 10px;
  border-radius: var(--radius-full);
  background: var(--surface-secondary);
  border: 1px solid var(--line);
}

.consulta-postal-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 10px;
  flex-wrap: wrap;
}

.consulta-postal-toolbar-summary {
  min-width: 220px;
}

.consulta-postal-toolbar-search {
  flex: 1 1 320px;
  min-width: min(320px, 100%);
}

.consulta-postal-toolbar-search input {
  width: 100%;
}

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

.consulta-postal-item {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 12px;
  background: var(--surface);
}

.consulta-postal-item strong,
.consulta-postal-item small {
  display: block;
}

.consulta-postal-item small {
  margin-top: 4px;
  color: var(--muted);
  line-height: 1.4;
}

.consulta-postal-item ul {
  margin: 8px 0 0 18px;
  color: var(--muted);
}

.consulta-postal-table-wrap {
  margin-top: 0;
}

.consulta-postal-table {
  min-width: 1500px;
  font-size: 13px;
}

.consulta-postal-table th,
.consulta-postal-table td {
  white-space: nowrap;
  vertical-align: top;
}

.consulta-postal-table th .muted {
  display: block;
  margin-top: 2px;
  font-size: 11px;
  font-weight: 500;
}

.consulta-postal-table td:last-child {
  white-space: normal;
  min-width: 260px;
}

.consulta-postal-table td:nth-child(4),
.consulta-postal-table td:nth-child(11) {
  white-space: normal;
  min-width: 180px;
}

.consulta-postal-table input[type="checkbox"] {
  width: 16px;
  height: 16px;
}

.consulta-postal-link-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border-radius: 8px;
  color: var(--primary);
  background: var(--surface-secondary);
  border: 1px solid var(--line);
}

.consulta-postal-link-icon svg {
  width: 15px;
  height: 15px;
}

.consulta-postal-link-icon:hover {
  background: var(--info-bg);
}

.tracking-monitor-shell {
  max-width: none;
}

.tracking-monitor-top {
  display: grid;
  grid-template-columns: minmax(0, 1.05fr) minmax(0, 1.05fr) minmax(340px, 1.35fr);
  gap: 16px;
  align-items: stretch;
  margin-top: 12px;
}

.tracking-monitor-panel {
  margin: 0;
  padding: 18px;
  border-radius: var(--radius-md);
  border: 1px dashed var(--line);
  background: var(--surface-secondary);
  min-width: 0;
}

.tracking-monitor-panel h3 {
  margin-top: 0;
}

.tracking-monitor-meta-list {
  display: grid;
  gap: 8px;
}

.tracking-monitor-meta-list p {
  margin: 0;
}

.tracking-monitor-cards-row {
  margin-bottom: 0;
}

.tracking-monitor-config-wrap {
  display: grid;
  grid-template-columns: minmax(300px, 0.95fr) minmax(0, 2fr);
  gap: 16px;
  align-items: start;
  margin-top: 16px;
}

.tracking-monitor-form-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px 14px;
}

.tracking-monitor-form-grid label {
  display: grid;
  gap: 6px;
  min-width: 0;
}

.tracking-monitor-form-grid label span {
  font-size: 12px;
  font-weight: 700;
  color: var(--label-color);
}

.tracking-monitor-form-grid input[type="number"] {
  width: 100%;
}

.tracking-monitor-actions {
  justify-content: flex-start;
}

@media (max-width: 900px) {
  .consulta-postal-toolbar {
    align-items: stretch;
  }

  .consulta-postal-toolbar-search,
  .consulta-postal-toolbar-summary {
    min-width: 100%;
  }

  .tracking-monitor-top,
  .tracking-monitor-config-wrap {
    grid-template-columns: 1fr;
  }

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

@media (max-width: 580px) {
  .tracking-monitor-form-grid {
    grid-template-columns: 1fr;
  }
}

/* --- Tables --- */
.table-wrap {
  overflow-x: auto;
  overflow-y: hidden;
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  margin-top: 14px;
  background: #fff;
}
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th, td { padding: 9px 10px; border-bottom: 1px solid var(--table-border); text-align: left; vertical-align: middle; }
th {
  background: var(--surface-alt);
  color: var(--table-header-color);
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .03em;
}
tr:hover td { background: var(--surface-hover); }
.attendance-row { cursor: pointer; transition: background var(--transition-fast); }
.attendance-row:hover td { background: var(--info-bg); }
.attendance-row.expanded td { background: #f0f7ff; }
.nested-table th { font-size: 11px; }
.row-actions { white-space: nowrap; }

/* --- Badges --- */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 8px;
  border-radius: var(--radius-full);
  font-size: 12px;
  font-weight: 600;
  background: var(--surface-secondary);
  color: var(--label-color);
  white-space: nowrap;
}
.badge.ok { background: var(--success-bg); color: var(--success); }
.badge.warn { background: var(--warning-bg); color: var(--warning); }
.badge.info { background: var(--info-bg); color: var(--info); }
.badge.danger { background: var(--danger-bg); color: var(--danger); }

.object-status-summary {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}

.object-status-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 28px;
  padding: 4px 8px;
  border-radius: var(--radius-full);
  font-size: 12px;
  font-weight: 700;
  border: 1px solid transparent;
  white-space: nowrap;
}

.object-status-badge.summary-item {
  min-width: 52px;
  justify-content: center;
  min-height: 36px;
  padding: 6px 10px;
}

.object-status-badge.icon-only {
  justify-content: center;
  min-width: 32px;
  min-height: 32px;
  padding: 5px 7px;
}

.object-status-icon {
  width: 18px;
  height: 18px;
  flex: 0 0 18px;
}

.object-status-count {
  min-width: 10px;
  text-align: right;
}

.object-status-badge.is-muted {
  background: var(--surface-secondary);
  color: var(--muted);
  border-color: var(--line);
}

.status-recebido {
  background: var(--info-bg);
  color: var(--info);
  border-color: #c7dbff;
}

.status-expedido {
  background: #eef1ff;
  color: #4f46e5;
  border-color: #d6d3ff;
}

.status-postado {
  background: var(--success-bg);
  color: var(--success);
  border-color: #bfe6d1;
}

.status-retornado {
  background: #fff1e7;
  color: #c86a18;
  border-color: #ffd2ae;
}

.status-aguardando-cliente {
  background: var(--warning-bg);
  color: var(--warning);
  border-color: var(--warning-border);
}

.status-pronto-reenvio {
  background: #e9f8fb;
  color: #0c7f9a;
  border-color: #bfe7ef;
}

.status-retirado {
  background: #e8f7ef;
  color: #0f6a47;
  border-color: #bfe6d1;
}

.status-encerrado {
  background: var(--danger-bg);
  color: var(--danger);
  border-color: var(--danger-border);
}

.status-cancelado {
  background: var(--danger-bg);
  color: var(--danger);
  border-color: var(--danger-border);
}

.status-indefinido {
  background: #f5f7fa;
  color: #667085;
  border-color: #d7dee8;
}

.chip-status-icon {
  width: 14px;
  height: 14px;
  flex: 0 0 14px;
}

.attendance-main-datetime {
  white-space: nowrap;
}

.attendance-main-customer {
  min-width: 0;
}

.attendance-customer-name {
  display: inline-block;
  max-width: 100%;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  vertical-align: middle;
}

.attendance-table th:nth-child(1),
.attendance-table td:nth-child(1) {
  width: 108px;
}

.attendance-table th:nth-child(2),
.attendance-table td:nth-child(2) {
  width: 172px;
}

.attendance-table th:nth-child(4),
.attendance-table td:nth-child(4) {
  width: 72px;
}

.attendance-table th:nth-child(5),
.attendance-table td:nth-child(5) {
  width: 420px;
}

.attendance-table th:nth-child(6),
.attendance-table td:nth-child(6) {
  width: 220px;
}

/* --- Customer Suggestions --- */
.suggestions { position: relative; margin-top: 4px; }
.suggestion-item {
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  margin-top: 4px;
  cursor: pointer;
  transition: background var(--transition-fast);
}
.suggestion-item:hover { background: var(--info-bg); }

/* --- Conference --- */
.conference-card { border: 1px solid var(--line); border-radius: 14px; margin-top: 12px; overflow: hidden; }
.conference-head {
  display: grid;
  grid-template-columns: 1.2fr 1fr .8fr .8fr;
  gap: 8px;
  padding: 12px;
  background: var(--surface);
  border-bottom: 1px solid var(--line);
}
.conference-body { padding: 12px; display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 10px; }
.conference-actions { grid-column: 1 / -1; display: flex; justify-content: flex-end; gap: 8px; }
.conference-table th, .conference-table td { white-space: nowrap; }
.conference-table .table-input { min-width: 160px; }
.compact-conference { font-size: 13px; }
.compact-conference th { padding: 8px 7px; }
.compact-conference td { padding: 7px; }
.compact-conference small { color: var(--muted); font-size: 11px; }
.compact-conference .table-select { min-width: 112px; }
.compact-conference .small-code-input { width: 150px; min-width: 150px; margin-top: 4px; }
.compact-conference .conf-note { min-width: 170px; }

/* --- Modal --- */
.modal {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.55);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  z-index: 1000;
  animation: fadeIn var(--transition) ease;
}
.modal.hidden { display: none; }
.modal-content {
  width: min(980px, 96vw);
  max-height: 90vh;
  overflow: auto;
  background: white;
  border-radius: var(--radius-xl);
  padding: 18px;
  box-shadow: var(--shadow-modal);
  position: relative;
}
.modal-close {
  position: absolute;
  right: 12px;
  top: 12px;
  background: var(--surface-input);
  border-radius: var(--radius-full);
  width: 34px;
  height: 34px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  font-size: 24px;
  line-height: 1;
  transition: background var(--transition-fast);
}
.modal-close:hover { background: #e5e7eb; }
.muted { color: var(--muted); }
code { background: var(--surface-secondary); border-radius: 5px; padding: 2px 5px; font-family: var(--font-mono); font-size: 13px; }
.message-box { width: 100%; min-height: 190px; font-family: var(--font-sans); }

/* --- Settings --- */
.settings-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 14px 0;
  border-bottom: 1px solid var(--line);
  padding-bottom: 10px;
}
.settings-tab {
  background: var(--bg);
  border: 1px solid var(--line);
  color: var(--label-color);
  transition: background var(--transition-fast), color var(--transition-fast);
}
.settings-tab:hover:not(.active) { background: #e5eaf0; }
.settings-tab.active { background: var(--primary); color: #fff; border-color: var(--primary); }
.settings-panel { display: none; }
.settings-panel.active { display: block; }
.settings-actions { border-top: 1px solid var(--line); padding-top: 12px; margin-top: 16px; justify-content: flex-end; }
.local-printer-card {
  border: 1px dashed var(--line);
  border-radius: 14px;
  padding: 12px;
  background: var(--surface);
  margin-top: 12px;
}
.local-printer-card h3 { margin: 0 0 4px; font-size: 16px; }
.table-input, .table-select { min-width: 130px; padding: 6px 8px; font-size: 13px; }
.variables-box {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  padding: 10px;
  margin: 8px 0 12px;
}
.zpl-editor { font-family: var(--font-mono); font-size: 13px; line-height: 1.35; }
.message-template-card {
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 12px;
  background: var(--surface);
  margin-top: 12px;
}
[data-dst-row] input { min-width: 120px; padding: 7px 8px; font-size: 13px; }

/* --- Expedition --- */
.expedition-stats { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; margin: 12px 0 16px; }
.stat-card {
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  padding: 16px;
  background: #fff;
  min-height: 110px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  box-shadow: var(--shadow-soft);
  transition: transform var(--transition-fast), box-shadow var(--transition-fast);
}
.stat-card:hover { transform: translateY(-2px); box-shadow: var(--shadow); }
.stat-card small {
  color: var(--muted);
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: .04em;
  font-size: 12px;
}
.stat-card strong { font-size: 42px; line-height: 1.05; margin-top: 6px; }
.stat-available strong { color: var(--primary); }
.stat-read strong { color: var(--success); }
.stat-pending strong { color: var(--warning); }
.stat-issues strong { color: var(--danger); }
.expedition-layout-grid {
  display: grid;
  grid-template-columns: 1.2fr 1fr;
  gap: 20px;
  align-items: start;
}
.expedition-layout-grid > .card:first-child {
  display: flex;
  flex-direction: column;
  min-height: 0;
}
#expeditionHistory table, #retorno-history table {
  font-size: 13px;
  width: 100%;
}
#expeditionHistory td, #expeditionHistory th, #retorno-history td, #retorno-history th {
  padding: 8px 6px;
}
@media (max-width: 980px) {
  .expedition-layout-grid {
    grid-template-columns: 1fr;
  }
}
.expedition-scan-panel {
  display: flex;
  flex-direction: column;
  gap: 16px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background: var(--surface);
}
.scan-box input { font-size: 18px; padding: 10px 12px; border-radius: var(--radius); font-weight: 600; }
.scan-box label { font-size: 15px; }
.expedition-sticky-action-bar {
  position: sticky;
  bottom: 12px;
  z-index: 25;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-top: 16px;
  padding: 14px 18px;
  background: rgba(255, 255, 255, 0.96);
  border: 1px solid var(--line);
  border-radius: 16px;
  box-shadow: 0 -8px 24px rgba(15, 23, 42, 0.08);
  backdrop-filter: blur(8px);
}
body.dark-mode .expedition-sticky-action-bar {
  background: rgba(31, 41, 55, 0.96);
  box-shadow: 0 -8px 24px rgba(0, 0, 0, 0.4);
}
@media (max-width: 768px) {
  .expedition-sticky-action-bar {
    flex-direction: column;
    align-items: stretch;
    gap: 12px;
  }
}

/* --- Labels (print) --- */
.label-60x40 {
  width: 60mm;
  height: 40mm;
  padding: 2mm;
  font-family: Arial, Helvetica, sans-serif;
  background: white;
  color: black;
  overflow: hidden;
  page-break-after: always;
  break-after: page;
  position: relative;
}
.label-top { display: grid; grid-template-columns: 18mm 1fr; gap: 2mm; align-items: start; height: 21mm; }
.label-qr svg { width: 18mm; height: 18mm; display: block; }
.label-info .brand { font-weight: 900; font-size: 13pt; line-height: 1; margin-bottom: 1.5mm; letter-spacing: .5px; }
.label-line { font-size: 8.3pt; line-height: 1.22; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.label-line strong { font-weight: 900; }
.label-barcode { height: 11.5mm; display: flex; align-items: center; margin-top: .6mm; }
.label-barcode svg { width: 100%; height: 100%; }
.label-bottom { font-size: 8.2pt; font-weight: 900; display: flex; justify-content: space-between; margin-top: .8mm; white-space: nowrap; }

/* --- Toast Notifications --- */
.toast-container {
  position: fixed;
  top: 16px;
  right: 16px;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 8px;
  pointer-events: none;
}
.toast {
  padding: 12px 20px;
  border-radius: var(--radius);
  font-size: 14px;
  font-weight: 600;
  font-family: var(--font-sans);
  color: white;
  opacity: 0;
  transform: translateX(40px);
  transition: opacity var(--transition-slow), transform var(--transition-slow);
  pointer-events: auto;
  max-width: 400px;
  line-height: 1.4;
}
.toast.visible { opacity: 1; transform: translateX(0); }
.toast-success { background: var(--success); box-shadow: var(--shadow-toast); }
.toast-error { background: var(--danger); box-shadow: var(--shadow-toast); }
.toast-warning { background: var(--warning); box-shadow: var(--shadow-toast); }
.toast-info { background: var(--primary); box-shadow: var(--shadow-toast); }

/* --- Responsive --- */
@media (max-width: 980px) {
  .app-shell { flex-direction: column; height: auto; overflow: visible; }
  .sidebar { width: 100% !important; padding: 18px !important; position: static; min-height: auto; height: auto; overflow-y: visible; }
  body.sidebar-collapsed .sidebar { width: 100% !important; padding: 18px !important; }
  body.sidebar-collapsed .brand-text,
  body.sidebar-collapsed .nav-label,
  body.sidebar-collapsed .user-box,
  body.sidebar-collapsed #btnLogout,
  body.sidebar-collapsed #btnThemeToggle span {
    display: block !important;
    opacity: 1 !important;
    max-width: none !important;
    max-height: none !important;
    pointer-events: auto !important;
  }
  .workspace { height: auto; overflow-y: visible; }
  .side-nav { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .grid.two { grid-template-columns: 1fr; }
  .filters { flex-direction: column; }
  .dual-actions { flex-direction: column; align-items: stretch; }
  .conference-head, .conference-body { grid-template-columns: 1fr; }
  .conference-actions { grid-column: 1; }
  body.sidebar-collapsed .app-shell { flex-direction: column; }
  .settings-tabs { overflow-x: auto; flex-wrap: nowrap; }
  .expedition-stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .expedition-scan-panel { display: flex; flex-direction: column; }
  .scan-box input { font-size: 18px; padding: 8px 10px; }
}

/* --- Phase 2: UX Operacional --- */

/* Modal Dialog Custom (Confirm/Prompt) */
.modal-dialog-header {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 14px;
}
.modal-dialog-icon {
  width: 24px;
  height: 24px;
  flex-shrink: 0;
}
.modal-dialog-icon.warning {
  color: var(--warning);
}
.modal-dialog-icon.info {
  color: var(--primary);
}
.modal-dialog-header h3 {
  margin: 0;
  font-size: 18px;
  font-weight: 700;
  color: var(--text);
}
.modal-dialog-body {
  margin-bottom: 20px;
  font-size: 14.5px;
  line-height: 1.5;
  color: var(--muted);
}
.modal-dialog-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
}

/* Filter Chips */
.filter-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 10px;
  margin-bottom: 10px;
  width: 100%;
}
.chip {
  background: var(--surface-secondary);
  border: 1px solid var(--line);
  color: var(--label-color);
  padding: 6px 12px;
  border-radius: var(--radius-full);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: background var(--transition-fast), border-color var(--transition-fast), color var(--transition-fast), transform var(--transition-fast);
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.chip:hover {
  background: #e2e8f0;
  border-color: var(--input-border);
  transform: translateY(-1px);
}
.chip:active {
  transform: translateY(0);
}
.chip.active {
  background: var(--primary);
  border-color: var(--primary);
  color: white;
}
.chip .badge-count {
  background: rgba(0, 0, 0, 0.07);
  border-radius: var(--radius-full);
  padding: 1px 6px;
  font-size: 11px;
  font-weight: 700;
}
.chip.active .badge-count {
  background: rgba(255, 255, 255, 0.22);
  color: white;
}

/* Row status highlights in conference table */
tr.row-status-recebido td:first-child { box-shadow: inset 4px 0 0 0 var(--primary); }
tr.row-status-enviado_para_postagem td:first-child { box-shadow: inset 4px 0 0 0 #005bbb; }
tr.row-status-postado td:first-child { box-shadow: inset 4px 0 0 0 var(--success); }
tr.row-status-retornado td:first-child { box-shadow: inset 4px 0 0 0 var(--danger); }
tr.row-status-aguardando_cliente td:first-child { box-shadow: inset 4px 0 0 0 var(--warning); }
tr.row-status-retirado td:first-child { box-shadow: inset 4px 0 0 0 var(--muted); }
tr.row-status-encerrado td:first-child,
tr.row-status-cancelado_encerrado td:first-child { box-shadow: inset 4px 0 0 0 var(--danger); }

tr.row-status-recebido td { background-color: transparent; }
tr.row-status-enviado_para_postagem td { background-color: rgba(0, 91, 187, 0.01); }
tr.row-status-postado td { background-color: rgba(19, 138, 91, 0.01); }
tr.row-status-retornado td { background-color: rgba(198, 40, 40, 0.03); }
tr.row-status-aguardando_cliente td { background-color: rgba(168, 100, 0, 0.02); }
tr.row-status-retirado td { background-color: rgba(102, 112, 133, 0.02); opacity: 0.85; }
tr.row-status-encerrado td,
tr.row-status-cancelado_encerrado td { background-color: rgba(198, 40, 40, 0.03); text-decoration: line-through; opacity: 0.72; }

/* Dirty dot for unsaved indicator */
.dirty-dot {
  position: absolute;
  top: -2px;
  right: -2px;
  width: 8px;
  height: 8px;
  background-color: var(--warning);
  border-radius: 50%;
  border: 1px solid white;
  animation: pulse-dot 1.5s infinite;
}
@keyframes pulse-dot {
  0% { transform: scale(0.95); box-shadow: 0 0 0 0 rgba(245, 158, 11, 0.7); }
  70% { transform: scale(1); box-shadow: 0 0 0 4px rgba(245, 158, 11, 0); }
  100% { transform: scale(0.95); box-shadow: 0 0 0 0 rgba(245, 158, 11, 0); }
}
.icon-btn[data-conf-save] {
  position: relative;
}

/* Empty States */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 36px 20px;
  text-align: center;
  background: var(--card);
  border: 2px dashed var(--line);
  border-radius: var(--radius-lg);
  margin: 14px 0;
  width: 100%;
}
.empty-state-icon {
  width: 46px;
  height: 46px;
  border-radius: var(--radius-full);
  background: var(--surface-secondary);
  color: var(--muted);
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 12px;
  transition: transform var(--transition);
}
.empty-state:hover .empty-state-icon {
  transform: scale(1.06);
}
.empty-state-icon i {
  width: 22px;
  height: 22px;
}
.empty-state-title {
  margin: 0 0 6px 0;
  font-size: 15px;
  font-weight: 700;
  color: var(--text);
}
.empty-state-desc {
  margin: 0;
  font-size: 13px;
  color: var(--muted);
  max-width: 340px;
  line-height: 1.45;
}

/* Sidebar Badges */
.badges-wrapper {
  display: flex;
  gap: 4px;
  margin-left: auto;
  align-items: center;
}
.sidebar-badge {
  color: white;
  font-size: 10px;
  font-weight: 700;
  padding: 2px 6px;
  border-radius: var(--radius-full);
  min-width: 18px;
  height: 16px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
}
.badge-danger {
  background-color: var(--danger);
}
.badge-warning {
  background-color: #f97316; /* Beautiful orange HSL */
}

/* Mini badges overlaying lucide icon in collapsed sidebar */
.mini-badge {
  position: absolute;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  border: 1px solid var(--sidebar);
}
.mini-badge.badge-danger {
  top: -2px;
  right: -2px;
  background-color: var(--danger);
}
.mini-badge.badge-warning {
  bottom: -2px;
  right: -2px;
  background-color: #f97316;
}

body:not(.sidebar-collapsed) .mini-badge {
  display: none !important;
}
body.sidebar-collapsed .badges-wrapper {
  display: none !important;
}

/* Visual Flash Animations for Scan Input */
@keyframes flash-success {
  0% { background-color: var(--success-bg); border-color: var(--success); box-shadow: 0 0 0 3px rgba(19, 138, 91, 0.2); }
  100% { background-color: ''; border-color: ''; box-shadow: ''; }
}
@keyframes flash-error {
  0% { background-color: var(--danger-bg); border-color: var(--danger); box-shadow: 0 0 0 3px rgba(198, 40, 40, 0.2); }
  100% { background-color: ''; border-color: ''; box-shadow: ''; }
}
@keyframes flash-warning {
  0% { background-color: var(--warning-bg); border-color: var(--warning); box-shadow: 0 0 0 3px rgba(168, 100, 0, 0.2); }
  100% { background-color: ''; border-color: ''; box-shadow: ''; }
}
.flash-success {
  animation: flash-success 0.84s ease-out;
}
.flash-error {
  animation: flash-error 0.84s ease-out;
}
.flash-warning {
  animation: flash-warning 0.84s ease-out;
}

body::after {
  content: '';
  position: fixed;
  inset: 0;
  pointer-events: none;
  opacity: 0;
  z-index: 3000;
}

@keyframes screen-flash-success {
  0% { opacity: 0.42; background: rgba(19, 138, 91, 0.72); }
  100% { opacity: 0; background: rgba(19, 138, 91, 0); }
}

@keyframes screen-flash-warning {
  0% { opacity: 0.4; background: rgba(255, 211, 138, 0.78); }
  100% { opacity: 0; background: rgba(255, 211, 138, 0); }
}

@keyframes screen-flash-error {
  0% { opacity: 0.44; background: rgba(198, 40, 40, 0.72); }
  100% { opacity: 0; background: rgba(198, 40, 40, 0); }
}

body.screen-flash-success::after {
  animation: screen-flash-success 1.32s ease-out;
}

body.screen-flash-warning::after {
  animation: screen-flash-warning 1.32s ease-out;
}

body.screen-flash-error::after {
  animation: screen-flash-error 1.32s ease-out;
}

/* Row Highlight for newly added item in Expedition */
@keyframes highlight-success-row {
  0% { background-color: var(--success-bg); }
  100% { background-color: transparent; }
}

@keyframes highlight-warning-row {
  0% { background-color: var(--warning-bg); }
  100% { background-color: transparent; }
}

@keyframes highlight-error-row {
  0% { background-color: var(--danger-bg); }
  100% { background-color: transparent; }
}

.row-highlight-success td {
  animation: highlight-success-row 0.84s ease-out;
}

.row-highlight-warning td {
  animation: highlight-warning-row 0.84s ease-out;
}

.row-highlight-error td {
  animation: highlight-error-row 0.84s ease-out;
}

/* --- Print --- */
@media print {
  body { background: white; }
  .sidebar, .page-header, .no-print, .modal-close, .login-screen, .toast-container { display: none !important; }
  main { padding: 0; }
  .card { border: 0; box-shadow: none; }
  @page { size: 60mm 40mm; margin: 0; }
}

/* --- Pagination Styles --- */
.pagination {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 16px;
  margin-top: 20px;
  padding-top: 14px;
  border-top: 1px solid var(--line);
  font-family: var(--font-sans);
}

.pagination-info {
  font-size: 13.5px;
  color: var(--muted);
}

.pagination-info strong {
  color: var(--text);
  font-weight: 600;
}

.small-btn {
  padding: 6px 12px;
  font-size: 13px;
  height: auto;
  min-height: auto;
  border-radius: var(--radius);
}

/* --- Dark Mode --- */
body.dark-mode {
  --bg: #090d16;
  --card: #111827;
  --text: #f3f4f6;
  --muted: #9ca3af;
  --line: #374151;
  --primary: #3b82f6;
  --primary-dark: #2563eb;
  --primary-light: #1e3a8a;

  /* Cores semânticas */
  --success: #10b981;
  --success-bg: rgba(16, 185, 129, 0.15);
  --warning: #f59e0b;
  --warning-bg: rgba(245, 158, 11, 0.15);
  --warning-border: #d97706;
  --danger: #ef4444;
  --danger-bg: rgba(239, 68, 68, 0.15);
  --danger-border: #b91c1c;
  --info: #3b82f6;
  --info-bg: rgba(59, 130, 246, 0.15);

  /* Superfícies */
  --surface: #1f2937;
  --surface-hover: #374151;
  --surface-alt: #1f2937;
  --surface-input: #111827;
  --surface-secondary: #374151;

  /* Label colors */
  --label-color: #d1d5db;
  --input-border: #4b5563;
  --table-border: #374151;
  --table-header-color: #9ca3af;
  
  /* Sidebar */
  --sidebar: #070a13;
  --sidebar-soft: #111827;
  --sidebar-text: #e5e7eb;
  --sidebar-muted: #9ca3af;
}

body.dark-mode input, 
body.dark-mode select, 
body.dark-mode textarea {
  background-color: var(--surface-input);
  color: var(--text);
  border-color: var(--input-border);
}

body.dark-mode .page-header, 
body.dark-mode .suggestion-item {
  background-color: var(--card);
}

body.dark-mode .suggestion-item:hover {
  background-color: var(--surface-hover);
}

body.dark-mode .modal-content {
  background-color: var(--card);
  border: 1px solid var(--line);
}

/* --- Dashboard Grid --- */
.dashboard-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
  margin-bottom: 20px;
}

@media (max-width: 980px) {
  .dashboard-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (max-width: 580px) {
  .dashboard-grid {
    grid-template-columns: 1fr;
  }
}

.progress-bar.bar-ok { background-color: var(--success); }
.progress-bar.bar-warn { background-color: var(--warning); }
.progress-bar.bar-danger { background-color: var(--danger); }
.progress-bar.bar-info { background-color: var(--primary); }

/* --- Conference Cards View --- */
.conference-cards-container {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 16px;
  margin-top: 16px;
}

.conference-card-item {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  padding: 16px;
  box-shadow: var(--shadow-soft);
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 10px;
  transition: transform var(--transition);
}

.conference-card-item:hover {
  transform: translateY(-2px);
}

.conference-card-item.status-recebido { border-left: 5px solid var(--primary); }
.conference-card-item.status-enviado_para_postagem { border-left: 5px solid #005bbb; }
.conference-card-item.status-postado { border-left: 5px solid var(--success); }
.conference-card-item.status-retornado { border-left: 5px solid var(--danger); }
.conference-card-item.status-aguardando_cliente { border-left: 5px solid var(--warning); }
.conference-card-item.status-retirado { border-left: 5px solid var(--muted); }
.conference-card-item.status-encerrado,
.conference-card-item.status-cancelado_encerrado { border-left: 5px solid var(--danger); opacity: 0.8; }

.conference-card-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  border-bottom: 1px solid var(--table-border);
  padding-bottom: 8px;
}

.conference-card-body {
  display: grid;
  gap: 8px;
}

.conference-card-field {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.conference-card-field label {
  font-size: 11.5px;
  font-weight: 700;
  color: var(--muted);
  text-transform: uppercase;
}

.conference-card-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  border-top: 1px solid var(--table-border);
  padding-top: 10px;
  margin-top: 6px;
}

/* --- Help Layout --- */
.help-layout {
  display: grid;
  grid-template-columns: 240px 1fr;
  gap: 24px;
  min-height: 500px;
  background: var(--card);
  border-radius: var(--radius-md);
  border: 1px solid var(--line);
  overflow: hidden;
}

.help-sidebar-menu {
  background: var(--bg-body);
  border-right: 1px solid var(--line);
  padding: 16px 8px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.help-menu-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  border: none;
  background: none;
  color: var(--text-muted);
  font-family: inherit;
  font-size: 14px;
  font-weight: 500;
  text-align: left;
  border-radius: var(--radius);
  cursor: pointer;
  transition: all 0.2s ease;
  width: 100%;
}

.help-menu-item svg {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
}

.help-menu-item:hover {
  background: var(--sidebar-hover);
  color: var(--text-main);
}

.help-menu-item.active {
  background: var(--primary);
  color: #fff;
}

.help-content-panel {
  padding: 24px;
}

.help-panel {
  display: none;
}

.help-panel.active {
  display: block;
  animation: fadeIn var(--transition-fast) ease;
}

.help-panel h2 {
  margin-top: 0;
  margin-bottom: 12px;
  font-size: 22px;
  color: var(--text-main);
}

.help-panel p {
  line-height: 1.6;
  color: var(--text-muted);
  margin-bottom: 16px;
}

.help-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 16px;
  margin-top: 20px;
}

.help-card-info {
  background: var(--bg-body);
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  padding: 16px;
}

.help-card-info h3 {
  margin-top: 0;
  margin-bottom: 8px;
  font-size: 16px;
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--text-main);
}

.help-card-info h3 svg {
  width: 18px;
  height: 18px;
  color: var(--primary);
}

.help-card-info p {
  font-size: 13px;
  margin: 0;
  line-height: 1.4;
}

.help-list {
  padding-left: 20px;
  margin-bottom: 16px;
}

.help-list li {
  margin-bottom: 10px;
  line-height: 1.5;
  color: var(--text-muted);
}

/* Status Box */
.status-box {
  background: var(--bg-body);
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  padding: 20px;
  margin: 20px 0;
}

.status-box h3 {
  margin-top: 0;
  margin-bottom: 12px;
}

.status-indicator {
  display: flex;
  align-items: center;
  gap: 12px;
}

.indicator-badge {
  padding: 4px 10px;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 600;
  background: var(--line);
  color: var(--text-muted);
  display: inline-block;
}

.indicator-badge.signed {
  background: #10b981;
  color: #fff;
}

.indicator-badge.unsigned {
  background: #f59e0b;
  color: #fff;
}

.indicator-badge.success {
  background: var(--success-bg);
  color: var(--success);
  border: 1px solid rgba(16, 185, 129, 0.2);
}

.indicator-badge.danger {
  background: var(--danger-bg);
  color: var(--danger);
  border: 1px solid rgba(239, 68, 68, 0.2);
}

.indicator-badge.warning {
  background: var(--warning-bg);
  color: var(--warning);
  border: 1px solid rgba(245, 158, 11, 0.2);
}

.indicator-badge.default {
  background: var(--line);
  color: var(--text-muted);
  border: 1px solid rgba(100, 116, 139, 0.2);
}

/* Proportional input sizing utilities */
.input-xs { max-width: 90px; }
.input-sm { max-width: 150px; }
.input-md { max-width: 260px; }
.input-full { width: 100%; }

/* Settings field row for inline label+input */
.settings-field-row {
  display: flex;
  align-items: center;
  gap: 10px;
}
.settings-field-row label {
  white-space: nowrap;
  min-width: max-content;
}

.indicator-desc {
  font-size: 14px;
  color: var(--text-main);
}

/* Keyboard shortcuts grid */
.keyboard-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 12px;
  margin-top: 16px;
}

.key-card {
  display: flex;
  align-items: center;
  gap: 12px;
  background: var(--bg-body);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 10px 14px;
}

.key-card kbd {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 4px;
  box-shadow: 0 1px 0 rgba(0,0,0,0.2);
  padding: 2px 6px;
  font-family: monospace;
  font-size: 12px;
  font-weight: bold;
  color: var(--text-main);
}

.key-card span {
  font-size: 13px;
  color: var(--text-muted);
}

/* Version timeline */
.version-timeline {
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.version-release {
  border-left: 2px solid var(--line);
  padding-left: 16px;
}

.version-release h3 {
  margin-top: 0;
  margin-bottom: 8px;
  font-size: 16px;
  color: var(--text-main);
}

.version-release .release-date {
  font-weight: normal;
  font-size: 12px;
  color: var(--text-muted);
  margin-left: 6px;
}

.version-release ul {
  margin: 0;
  padding-left: 18px;
}

.version-release li {
  font-size: 13px;
  color: var(--text-muted);
  line-height: 1.5;
  margin-bottom: 6px;
}

@media (max-width: 768px) {
  .help-layout {
    grid-template-columns: 1fr;
  }
  .help-sidebar-menu {
    border-right: none;
    border-bottom: 1px solid var(--line);
    flex-direction: row;
    overflow-x: auto;
    padding: 8px;
  }
  .help-menu-item {
    white-space: nowrap;
    width: auto;
  }
}

/* --- Attendance Sticky Action Bar --- */
.attendance-sticky-action-bar {
  position: sticky;
  bottom: 12px;
  z-index: 30;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-top: 16px;
  padding: 14px 18px;
  background: rgba(255, 255, 255, 0.96);
  border: 1px solid var(--line);
  border-radius: 16px;
  box-shadow: 0 -8px 24px rgba(15, 23, 42, 0.08);
  backdrop-filter: blur(8px);
  transition: all 0.2s ease-in-out;
}
body.dark-mode .attendance-sticky-action-bar {
  background: rgba(31, 41, 55, 0.96);
  box-shadow: 0 -8px 24px rgba(0, 0, 0, 0.4);
}
.sticky-bar-left {
  display: flex;
  align-items: center;
  gap: 16px;
}
.sticky-bar-right {
  display: flex;
  align-items: center;
  gap: 12px;
}
.sticky-bar-summary {
  font-size: 14px;
  color: var(--text);
  font-weight: 500;
}
.sticky-bar-summary strong {
  color: var(--primary);
}
.attendance-sticky-action-bar button {
  min-width: 140px;
  margin: 0;
}
@media (max-width: 768px) {
  .attendance-sticky-action-bar {
    flex-direction: column-reverse;
    align-items: stretch;
    gap: 12px;
  }
  .sticky-bar-left {
    flex-direction: column-reverse;
    align-items: stretch;
    gap: 10px;
  }
  .sticky-bar-right {
    flex-direction: column;
    align-items: stretch;
    gap: 8px;
  }
  .attendance-sticky-action-bar button {
    width: 100%;
  }
}

/* --- Withdrawal Page --- */
.withdrawal-stats {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
  margin: 12px 0 16px;
}
tr.row-danger {
  background-color: rgba(239, 68, 68, 0.08) !important;
}
tr.row-danger:hover {
  background-color: rgba(239, 68, 68, 0.12) !important;
}
.text-success {
  color: var(--success) !important;
}
.text-danger {
  color: var(--danger) !important;
}

@media (max-width: 768px) {
  .withdrawal-stats {
    grid-template-columns: 1fr;
  }
}

/* --- Treatment Modal Layout --- */
.treatment-layout-grid {
  display: grid;
  grid-template-columns: 1fr 1.5fr;
  gap: 24px;
  align-items: start;
}
@media (max-width: 820px) {
  .treatment-layout-grid {
    grid-template-columns: 1fr;
    gap: 16px;
  }
}

/* --- Conference Stats --- */
.conference-stats {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 12px;
  margin: 12px 0 16px;
}
@media (max-width: 980px) {
  .conference-stats {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}
@media (max-width: 580px) {
  .conference-stats {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

/* --- Copy Chip --- */
.copy-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: var(--surface-secondary);
  border: 1px solid var(--line);
  color: var(--label-color);
  padding: 6px 12px;
  border-radius: var(--radius-full);
  font-size: 13px;
  font-weight: 600;
  font-family: var(--font-sans);
  cursor: pointer;
  text-decoration: none;
  transition: background var(--transition-fast), border-color var(--transition-fast), color var(--transition-fast), transform var(--transition-fast);
  vertical-align: middle;
  line-height: 1.4;
  outline: none;
}

.copy-chip:hover {
  background: #e2e8f0;
  border-color: var(--input-border);
  transform: translateY(-1px);
  color: var(--label-color);
}

.copy-chip:active {
  transform: scale(0.96) translateY(0);
}

/* --- Custom Tooltip --- */
#custom-tooltip {
  position: absolute;
  z-index: 10000;
  background: var(--text);
  color: var(--surface);
  padding: 6px 10px;
  font-size: 11px;
  font-weight: 500;
  border-radius: 4px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
  pointer-events: none;
  opacity: 0;
  transform: translateY(4px);
  transition: opacity 100ms ease, transform 100ms ease;
  white-space: nowrap;
  display: none;
}

#custom-tooltip.visible {
  display: block;
  opacity: 1;
  transform: translateY(0);
}

/* --- Stable Treatment Modal Panels --- */
.treatment-modal-wrapper .treatment-panel {
  min-height: 430px;
  display: flex;
  flex-direction: column;
  padding-right: 4px;
}
.treatment-modal-wrapper .treatment-panel > .dual-actions {
  margin-top: auto;
}
.treatment-modal-wrapper .contacts-column {
  min-height: 480px;
  max-height: 480px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
}
.modal-choice-group {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}
.modal-choice-card {
  width: 100%;
  min-height: 92px;
  display: flex;
  align-items: center;
  gap: 10px;
  text-align: left;
  border: 1px solid var(--line);
  background: var(--surface-secondary);
  color: var(--text);
  border-radius: var(--radius);
  padding: 12px;
  cursor: pointer;
  transition: border-color var(--transition), box-shadow var(--transition), background var(--transition);
}
.modal-choice-card:hover {
  box-shadow: var(--shadow-soft);
}
.modal-choice-card.is-active {
  background: var(--surface);
}
.modal-choice-card.tone-primary.is-active {
  border-color: var(--primary);
}
.modal-choice-card.tone-success.is-active {
  border-color: var(--success);
}
.modal-choice-icon {
  width: 38px;
  height: 38px;
  border-radius: 12px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: rgba(255,255,255,.8);
  flex-shrink: 0;
}
.modal-choice-card.tone-primary .modal-choice-icon {
  color: var(--primary);
}
.modal-choice-card.tone-success .modal-choice-icon {
  color: var(--success);
}
.modal-choice-copy {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 0;
  flex: 1;
}
.modal-choice-copy strong {
  font-size: 13px;
}
.modal-choice-copy small {
  color: var(--muted);
  line-height: 1.35;
}
.modal-choice-state {
  font-size: 11px;
  font-weight: 700;
  color: var(--muted);
}
.modal-choice-card.is-active .modal-choice-state {
  color: var(--text);
}

/* --- Proportional Address Grids (v0.6.6.1) --- */
.address-grid {
  display: grid;
  gap: 16px;
  grid-template-columns: 140px 1fr 120px 140px;
}
.address-grid-row2 {
  display: grid;
  gap: 16px;
  grid-template-columns: 1.5fr 1fr 1fr 80px;
}
.address-grid-row3 {
  display: grid;
  gap: 16px;
  grid-template-columns: 1fr;
}

@media (max-width: 768px) {
  .address-grid, .address-grid-row2 {
    grid-template-columns: 1fr !important;
  }
}

@media (max-width: 700px) {
  .modal-choice-group {
    grid-template-columns: 1fr;
  }
}

/* --- Compact Alerts Layout (v0.6.6.5) --- */
.alerts-compact-card {
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--surface);
  overflow: hidden;
  max-width: 920px;
  margin-top: 15px;
}

.alerts-compact-header,
.alerts-compact-row {
  display: grid;
  grid-template-columns: 130px 1fr 88px 80px;
  align-items: center;
  gap: 12px;
}

.alerts-compact-header {
  padding: 10px 14px;
  font-size: 12px;
  font-weight: 700;
  color: var(--text-muted);
  background: var(--bg-hover);
  border-bottom: 1px solid var(--border);
  text-transform: uppercase;
  letter-spacing: 0.02em;
}

.alerts-compact-row {
  padding: 10px 14px;
  border-bottom: 1px solid var(--border);
}

.alerts-compact-row:last-child {
  border-bottom: none;
}

.alerts-compact-row label {
  margin: 0;
  font-weight: 600;
  color: var(--text);
}

.input-compact-number {
  width: 72px;
  max-width: 72px;
  text-align: center;
}

.indicator-badge.neutral {
  background: var(--line);
  color: var(--text-muted);
  border: 1px solid rgba(100, 116, 139, 0.2);
}

@media (max-width: 760px) {
  .alerts-compact-header {
    display: none;
  }

  .alerts-compact-row {
    grid-template-columns: 1fr 72px 60px;
    gap: 8px;
  }

  .alerts-compact-row > div:first-child {
    grid-column: 1 / -1;
  }
}

/* Variable badges for settings (v0.6.6.8) */
.var-badge {
  background: var(--bg-hover);
  border: 1px solid var(--border);
  color: var(--primary);
  padding: 2px 6px;
  border-radius: 4px;
  font-family: monospace;
  font-size: 0.85em;
  cursor: pointer;
  display: inline-block;
  margin: 2px;
  transition: all 0.2s ease;
  user-select: none;
}
.var-badge:hover {
  background: var(--primary-bg);
  border-color: var(--primary);
  color: var(--primary);
  transform: translateY(-1px);
}
.var-badge:active {
  transform: translateY(0);
}

/* Variables Tabs Layout (v0.6.6.10) */
.vars-container {
  margin-bottom: 12px;
  font-size: 0.85em;
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 10px;
  background: var(--bg-hover);
}

.vars-tabs-row {
  display: flex;
  gap: 6px;
  margin-bottom: 10px;
  border-bottom: 1px solid var(--border);
  padding-bottom: 6px;
  flex-wrap: wrap;
}

.vars-tab {
  padding: 4px 8px;
  font-size: 0.85em;
  border-radius: 4px;
  border: 1px solid var(--border);
  background: var(--surface);
  cursor: pointer;
  color: var(--text-muted);
  font-weight: 600;
  transition: all 0.2s ease;
}

.vars-tab:hover {
  background: var(--bg-hover);
  color: var(--text);
}

.vars-tab.active {
  background: var(--primary);
  color: #fff;
  border-color: var(--primary);
}

body.dark-mode .vars-tab.active {
  color: var(--bg);
}

.vars-content-group {
  display: none;
}

.vars-content-group.active {
  display: block;
}

/* Receipt Preview Centering & Styling (v0.6.6.10) */
.receipt-preview-wrap {
  display: flex;
  flex-direction: column;
  align-items: center;
  margin: 15px 0;
}

.receipt-preview-title {
  text-align: center;
  width: 100%;
}

.receipt-preview {
  font-family: "Courier New", Courier, monospace;
  white-space: pre-wrap;
  overflow-x: hidden;
  line-height: 1.25;
  font-size: 11px;
  background: #fffde7;
  color: #222;
  padding: 12px;
  border: 1px solid #d4d4d4;
  border-radius: 4px;
  width: var(--receipt-preview-width, 48ch);
  min-width: var(--receipt-preview-width, 48ch);
  max-width: var(--receipt-preview-width, 48ch);
  box-sizing: content-box;
}

body.dark-mode .receipt-preview {
  background: #fffde7; /* Mantém fundo amarelado fiel mesmo em dark mode */
  color: #222;
  border: 1px solid #b5b5b5;
}

/* ===================== Manifest A4 Page & Grid ===================== */
.manifest-page {
  box-sizing: border-box;
  background: #fff;
  color: #111;
  font-family: monospace;
  font-size: 10px;
  line-height: 1.25;
  display: flex;
  flex-direction: column;
  margin-bottom: 20px;
  page-break-after: always;
  break-after: page;
}

/* Para a visualização no editor de configurações */
.print-model-preview-col .manifest-page {
  width: 100%;
  min-height: 297mm; /* Mantém proporção de folha A4 no preview */
  padding: 15px 20px;
  border: 1px solid var(--border);
  box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}

/* Para a geração real da impressão */
body:not(.print-model-preview-col) .manifest-page {
  width: 210mm;
  min-height: 297mm;
  padding: 15mm 10mm;
}

.manifest-header {
  flex: 0 0 auto;
  white-space: pre-wrap;
  margin: 0;
  font-family: monospace;
  font-size: 10px;
  line-height: 1.25;
}

.manifest-body {
  flex: 1 1 auto;
  margin: 6px 0;
}

.manifest-bottom {
  margin-top: auto;
  flex: 0 0 auto;
  display: flex;
  flex-direction: column;
}

.manifest-signature {
  flex: 0 0 auto;
  white-space: pre-wrap;
  margin: 0;
  font-family: monospace;
  font-size: 10px;
  line-height: 1.25;
}

.manifest-footer {
  flex: 0 0 auto;
  white-space: pre-wrap;
  margin: 0;
  font-family: monospace;
  font-size: 10px;
  line-height: 1.25;
}

.manifest-items-grid {
  width: 100%;
  border-collapse: collapse;
  table-layout: fixed;
}

.manifest-items-grid td {
  vertical-align: top;
  padding: 1.5px 6px 1.5px 0;
  white-space: nowrap;
  overflow: hidden;
}

.manifest-cols-1 td { width: 100%; }
.manifest-cols-2 td { width: 50%; }
.manifest-cols-3 td { width: 33.3333%; }
.manifest-cols-4 td { width: 25%; }

/* Grid Item estruturado */
.manifest-item {
  display: grid;
  column-gap: 4px;
  align-items: baseline;
  min-width: 0;
  white-space: nowrap;
  font-size: inherit !important;
}

.manifest-item-number {
  text-align: center;
  font-family: monospace;
  font-variant-numeric: tabular-nums;
  font-size: inherit !important;
}

.manifest-item-object {
  font-family: monospace;
  font-variant-numeric: tabular-nums;
  font-size: inherit !important;
}

.manifest-item-code {
  font-family: monospace;
  font-variant-numeric: tabular-nums;
  overflow: hidden;
  text-overflow: ellipsis;
  font-size: inherit !important;
}

.manifest-item-text {
  font-size: inherit !important;
}

/* Densidades */
.manifest-density-normal .manifest-items-grid td {
  padding-top: 3px;
  padding-bottom: 3px;
  font-size: 10px;
}

.manifest-density-compact .manifest-items-grid td {
  padding-top: 2px;
  padding-bottom: 2px;
  font-size: 9px;
}

.manifest-density-max .manifest-items-grid td {
  padding-top: 1px;
  padding-bottom: 1px;
  font-size: 8px;
}

.manifest-density-max .manifest-item {
  font-size: 8px;
  column-gap: 3px;
}

@media print {
  .manifest-page {
    box-shadow: none !important;
    border: none !important;
    margin: 0 !important;
  }
}

.consulta-postal-code-summary,
.postmaxi-sale-details {
  min-width: 0;
}

.consulta-postal-code-summary {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.consulta-postal-code-summary small {
  color: var(--muted-color);
}

.postmaxi-sale-details summary {
  cursor: pointer;
  font-weight: 600;
}

.postmaxi-sale-items {
  display: block;
  margin-top: 8px;
  min-width: 100%;
}

.postmaxi-sale-items-table {
  width: 100%;
}

.postmaxi-sale-items-table td {
  background: color-mix(in srgb, var(--surface) 96%, var(--color-primary) 4%);
}
