/* PetriAudit — Cleanroom (claro + escuro, viewer flush à esquerda) */
:root {
  --bg: #F8FAFC;
  --surface: #FFFFFF;
  --surface-2: #F1F5F9;
  --border: #E2E8F0;
  --border-strong: #CBD5E1;
  --ink: #0F172A;
  --muted: #64748B;
  --faint: #94A3B8;
  --accent: #0F766E;
  --accent-ink: #0B5E57;
  --accent-bg: #ECFDF5;
  --success: #15803D;
  --success-bg: #F0FDF4;
  --success-border: #BBF7D0;
  --danger: #B91C1C;
  --danger-bg: #FEF2F2;
  --danger-border: #FECACA;
  --warning: #B45309;
  --warning-bg: #FFFBEB;
  --warning-border: #FDE68A;
  --viewer-bg: #0B1220;
  --radius: 10px;
  --radius-sm: 7px;
  --shadow-sm: 0 1px 2px rgba(15, 23, 42, 0.06);
  --font-sans: 'Inter', system-ui, -apple-system, sans-serif;
  --font-mono: 'Fira Code', 'JetBrains Mono', ui-monospace, monospace;
  color-scheme: light;
}

[data-theme="dark"] {
  --bg: #0B1120;
  --surface: #151E33;
  --surface-2: #0F172A;
  --border: #2B3A55;
  --border-strong: #475569;
  --ink: #F1F5F9;
  --muted: #94A3B8;
  --faint: #64748B;
  --accent: #2DD4BF;
  --accent-ink: #5EEAD4;
  --accent-bg: rgba(45, 212, 191, 0.12);
  --success: #34D399;
  --success-bg: rgba(52, 211, 153, 0.1);
  --success-border: #065F46;
  --danger: #F87171;
  --danger-bg: rgba(248, 113, 113, 0.1);
  --danger-border: #7F1D1D;
  --warning: #FBBF24;
  --warning-bg: rgba(251, 191, 36, 0.1);
  --warning-border: #92400E;
  --shadow-sm: none;
  color-scheme: dark;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: var(--font-sans);
  background: var(--bg);
  color: var(--ink);
  font-size: 14px;
  line-height: 1.5;
  height: 100vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
}

:focus-visible {
  outline: 2px solid rgba(15, 118, 110, 0.55);
  outline-offset: 2px;
}

/* HEADER 56px */
/* HEADER 56px */
.app-header {
  height: 56px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 16px;
  gap: 12px;
  flex-shrink: 0;
  position: relative;
  z-index: 100;
}
.header-left { display: flex; align-items: center; gap: 12px; min-width: 0; flex-shrink: 0; }
.logo { display: flex; align-items: center; gap: 10px; flex-shrink: 0; }
.logo-icon {
  width: 28px; height: 28px; border-radius: 8px;
  background: var(--accent); color: #fff;
  display: grid; place-items: center;
  font-size: 14px; font-weight: 700; flex-shrink: 0;
}
.logo-text h1 { font-size: 15px; font-weight: 700; letter-spacing: -0.01em; color: var(--ink); white-space: nowrap; }
.logo-text .subtext { font-size: 11px; color: var(--muted); display: block; font-weight: 500; white-space: nowrap; }
.reviewer-selector-box { display: flex; align-items: center; gap: 8px; flex-shrink: 0; }
.reviewer-selector-box label { font-size: 11.5px; font-weight: 600; color: var(--muted); white-space: nowrap; }

/* PROGRESSO */
.header-center { flex: 1 1 auto; max-width: 440px; min-width: 0; display: flex; flex-direction: column; gap: 4px; overflow: hidden; margin: 0 4px; }
.progress-bar-container { display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.progress-labels { display: flex; justify-content: space-between; font-size: 11px; font-weight: 600; color: var(--muted); font-variant-numeric: tabular-nums; white-space: nowrap; gap: 6px; }
.progress-labels span:last-child { color: var(--ink); }
.progress-track { height: 6px; background: var(--surface-2); border: 1px solid var(--border); border-radius: 999px; overflow: hidden; }
.progress-fill { height: 100%; background: var(--accent); transition: width 0.3s ease; border-radius: 999px; }
.stats-badges { display: flex; gap: 5px; overflow-x: auto; scrollbar-width: none; min-width: 0; }
.stats-badges::-webkit-scrollbar { display: none; }
.badge { font-size: 10.5px; font-weight: 600; padding: 2px 8px; border-radius: 999px; white-space: nowrap; border: 1px solid var(--border); background: var(--surface-2); color: var(--muted); font-variant-numeric: tabular-nums; flex-shrink: 0; }
.badge-approved { background: var(--success-bg); border-color: var(--success-border); color: var(--success); }
.badge-mismatch { background: var(--danger-bg); border-color: var(--danger-border); color: var(--danger); }
.badge-doubt { background: var(--warning-bg); border-color: var(--warning-border); color: var(--warning); }
.badge-conflict { background: var(--danger-bg); border-color: var(--danger); color: var(--danger); }
.badge-pending { background: var(--surface-2); color: var(--muted); }

.header-right { display: flex; align-items: center; gap: 8px; flex-shrink: 0; }
.jump-box { display: flex; align-items: center; gap: 6px; }
.jump-box input { width: 88px; }

/* TABS */
.header-tabs { display: flex; background: var(--surface-2); padding: 2px; border-radius: 8px; border: 1px solid var(--border); gap: 2px; flex-shrink: 0; }
.header-tab-btn { background: transparent; border: 1px solid transparent; color: var(--muted); padding: 6px 11px; font-size: 12px; font-weight: 600; border-radius: 6px; cursor: pointer; transition: all 0.15s ease; font-family: var(--font-sans); white-space: nowrap; flex-shrink: 0; }
.header-tab-btn:hover { color: var(--ink); }
.header-tab-btn.active { background: var(--surface); color: var(--ink); box-shadow: var(--shadow-sm); border-color: var(--border); }

/* MAIN — viewer colado à esquerda, sem branco sob a logo */
.main-container {
  display: grid;
  grid-template-columns: minmax(0, 1.55fr) minmax(370px, 1fr);
  gap: 0;
  padding: 0;
  max-width: none;
  width: 100%;
  margin: 0;
  flex: 1;
  height: calc(100vh - 56px);
  overflow: hidden;
  min-height: 0;
}

/* VIEWER — único bloco escuro, flush esquerda/topo */
.image-viewer-section {
  display: flex; flex-direction: column;
  background: var(--viewer-bg);
  border: 0;
  border-right: 1px solid var(--border);
  border-radius: 0;
  overflow: hidden;
  min-height: 0;
}
.image-toolbar {
  min-height: 48px;
  background: transparent;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  display: flex; align-items: center; justify-content: space-between;
  padding: 8px 14px; gap: 10px; z-index: 10;
}
.toolbar-left { display: flex; align-items: center; gap: 8px; min-width: 0; }
.photo-badge { font-family: var(--font-mono); font-size: 12px; color: #E2E8F0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.photo-records-badge { font-size: 11px; font-weight: 600; background: rgba(255,255,255,0.08); color: #CBD5E1; padding: 2px 9px; border-radius: 999px; white-space: nowrap; border: 1px solid rgba(255,255,255,0.1); }
.toolbar-right { display: flex; gap: 6px; flex-shrink: 0; }
.tool-btn { background: rgba(255,255,255,0.06); border: 1px solid rgba(255,255,255,0.1); color: #E2E8F0; padding: 5px 10px; border-radius: 6px; font-size: 12px; cursor: pointer; transition: background 0.15s; font-family: var(--font-sans); font-weight: 600; }
.tool-btn:hover { background: rgba(255,255,255,0.12); }
.image-viewport { flex: 1; position: relative; overflow: hidden; display: flex; align-items: center; justify-content: center; cursor: grab; background: radial-gradient(circle at 50% 40%, #16213A 0, var(--viewer-bg) 65%); min-height: 0; touch-action: none; }
.image-viewport:active { cursor: grabbing; }
.image-canvas { position: absolute; transform-origin: center center; user-select: none; }
.image-canvas img { max-width: none; display: block; box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5); pointer-events: none; border-radius: 4px; }
.zoom-hint { position: absolute; bottom: 12px; left: 12px; color: #64748B; font-size: 11.5px; padding: 4px 8px; pointer-events: none; }
.zoom-hint kbd, kbd { font-family: var(--font-mono); font-size: 10px; background: var(--surface-2); border: 1px solid var(--border); border-bottom-width: 2px; border-radius: 4px; padding: 1px 5px; color: var(--muted); }
.image-viewer-section kbd { background: rgba(255,255,255,0.08); border-color: rgba(255,255,255,0.12); color: #94A3B8; }

/* PAINEL */
.audit-panel-section { display: flex; flex-direction: column; gap: 12px; overflow-y: auto; min-height: 0; padding: 16px 20px 20px 20px; background: var(--bg); }
/* Nenhum card do painel pode ser achatado: só o histórico absorve espaço livre */
.audit-panel-section > .card,
.audit-panel-section > .nav-bar,
.audit-panel-section > .alert { flex-shrink: 0; }
.nav-bar { display: flex; align-items: center; justify-content: space-between; background: var(--surface); padding: 8px; border-radius: var(--radius); border: 1px solid var(--border); box-shadow: var(--shadow-sm); gap: 10px; }
.record-position { text-align: center; min-width: 0; }
.record-position strong { display: block; font-size: 13px; color: var(--ink); white-space: nowrap; }
.record-position span { font-size: 11.5px; color: var(--muted); font-family: var(--font-mono); }
.alert { padding: 10px 14px; border-radius: var(--radius); font-size: 12.5px; line-height: 1.45; }
.alert-warning { background: var(--danger-bg); border: 1px solid var(--danger-border); color: var(--danger); }

/* CARDS */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 0; display: flex; flex-direction: column; box-shadow: var(--shadow-sm); overflow: hidden; }
.card-header { display: flex; align-items: center; justify-content: space-between; padding: 12px 16px; border-bottom: 1px solid var(--border); }
.card-header h3, .card-header h4 { font-size: 13px; font-weight: 700; color: var(--ink); }
.tag { font-size: 10.5px; font-weight: 700; padding: 3px 9px; border-radius: 6px; letter-spacing: 0.04em; border: 1px solid var(--border); background: var(--surface-2); color: var(--muted); }
.tag-pending { background: var(--surface-2); color: var(--muted); }
.tag-approved { background: var(--success-bg); border-color: var(--success-border); color: var(--success); }
.tag-mismatch { background: var(--danger-bg); border-color: var(--danger-border); color: var(--danger); }
.tag-doubt { background: var(--warning-bg); border-color: var(--warning-border); color: var(--warning); }
.tag-conflict { background: var(--danger-bg); border-color: var(--danger); color: var(--danger); }

/* RESOLUÇÃO DE DIVERGÊNCIA */
.resolution-card { border-color: var(--warning-border); }
.resolution-info { padding: 14px 16px; font-size: 12.5px; display: flex; flex-direction: column; gap: 6px; min-height: 48px; }
.resolution-info:empty { display: none; }
.resolution-result { display: flex; flex-direction: column; gap: 4px; }
.resolution-result strong { font-size: 13px; }
.resolution-result .resolution-comment { color: var(--muted); font-style: italic; }
.resolution-result .resolution-meta { font-size: 11px; color: var(--faint); font-family: var(--font-mono); }
#resolutionForm { padding: 0 16px 16px; display: flex; flex-direction: column; gap: 10px; }
.resolve-options { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 8px; }
.resolve-option.selected { border-color: var(--accent); background: var(--accent-bg); color: var(--accent-ink); }
.resolution-actions { display: flex; gap: 8px; flex-wrap: wrap; }

/* CAMPOS DA IA (linhas empilhadas — sem tabela, sem truncamento) */
.fields-list { display: flex; flex-direction: column; }
.field-row { display: grid; grid-template-columns: 150px minmax(0, 1fr) auto; gap: 12px; align-items: center; padding: 13px 16px; border-bottom: 1px solid var(--border); }
.field-row:last-child { border-bottom: 0; }
.field-row.row-corrected { background: var(--success-bg); }
.field-name { color: var(--muted); font-weight: 500; font-size: 12.5px; }
.field-values { display: flex; flex-wrap: wrap; align-items: baseline; gap: 2px 8px; min-width: 0; }
.ai-value { font-family: var(--font-mono); font-weight: 500; color: var(--ink); font-size: 13px; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
.corrected-value { font-family: var(--font-mono); color: var(--muted); font-size: 12.5px; overflow-wrap: anywhere; }
.corrected-value em { font-family: var(--font-sans); font-style: normal; color: var(--faint); font-size: 12px; }
.ai-strikethrough { text-decoration: line-through; color: var(--faint); margin-right: 8px; font-weight: 400; }
.badge-corr-tag { display: inline-block; color: var(--success); font-weight: 600; font-size: 13px; }
.corr-author { color: var(--faint); font-size: 11px; margin-left: 6px; font-family: var(--font-sans); }
.tag-resolved { background: var(--success-bg); border-color: var(--success-border); color: var(--success); }
.btn-edit-field { background: transparent; border: 1px solid var(--border); color: var(--muted); padding: 5px 10px; border-radius: 6px; font-size: 11.5px; font-weight: 600; cursor: pointer; transition: all 0.15s; font-family: var(--font-sans); white-space: nowrap; }
.btn-edit-field:hover { border-color: var(--border-strong); color: var(--ink); background: var(--surface-2); }

.same-photo-records { margin: 12px 16px 16px; background: var(--surface-2); padding: 10px 12px; border-radius: 8px; border: 1px solid var(--border); display: flex; flex-direction: column; gap: 8px; }
.same-photo-title { font-size: 11.5px; color: var(--muted); font-weight: 600; }
.same-photo-tags { display: flex; gap: 6px; flex-wrap: wrap; }
.same-photo-btn { background: var(--surface); border: 1px solid var(--border); color: var(--accent-ink); font-size: 12px; padding: 4px 10px; border-radius: 6px; cursor: pointer; font-family: var(--font-mono); font-weight: 500; }
.same-photo-btn:hover { border-color: var(--accent); background: var(--accent-bg); }

/* HISTÓRICO */
.history-card { padding: 0; flex: 1 0 auto; min-height: 240px; display: flex; flex-direction: column; }
.history-card .card-header { border-bottom: 1px solid var(--border); flex-shrink: 0; }
.history-list { display: flex; flex-direction: column; padding: 8px; gap: 6px; flex: 1 1 auto; min-height: 140px; max-height: 360px; overflow-y: auto; scrollbar-width: thin; }
.history-item { background: var(--surface); padding: 8px 12px; border-radius: 8px; border: 1px solid var(--border); border-left-width: 3px; font-size: 12.5px; display: flex; justify-content: space-between; align-items: flex-start; gap: 10px; }
.history-item.status-APPROVED { border-left-color: var(--success); }
.history-item.status-MISMATCH { border-left-color: var(--danger); }
.history-item.status-DOUBT { border-left-color: var(--warning); }
.history-main { display: flex; flex-direction: column; gap: 2px; min-width: 0; flex: 1; }
.history-main span { overflow-wrap: anywhere; }
.history-comment { color: var(--muted); font-style: italic; }
.history-meta { font-size: 11px; color: var(--faint); font-family: var(--font-mono); white-space: nowrap; flex-shrink: 0; }
.empty-state { font-size: 12px; color: var(--faint); padding: 12px 16px; }

/* DECISÃO */
.action-card { border: 1px solid var(--border); background: var(--surface); padding: 0; }
.action-card .card-header { border-bottom: 1px solid var(--border); }
.save-indicator { font-size: 11.5px; color: var(--success); font-weight: 600; opacity: 0; transition: opacity 0.3s ease; }
.save-indicator.visible { opacity: 1; }
.comment-box { display: flex; flex-direction: column; gap: 6px; padding: 14px 16px 0; }
.comment-box label { font-size: 12px; color: var(--muted); font-weight: 600; }
.comment-box textarea { background: var(--surface); border: 1px solid var(--border); border-radius: 8px; color: var(--ink); padding: 10px 12px; font-family: var(--font-sans); font-size: 13px; resize: vertical; min-height: 88px; }
.comment-box textarea:focus { outline: 2px solid rgba(15, 118, 110, 0.25); border-color: var(--accent); }
.audit-buttons-grid { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 8px; padding: 12px 16px 16px; }
.btn-action { display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 13px 6px; border-radius: 8px; gap: 4px; cursor: pointer; transition: all 0.15s; background: var(--surface); border: 1px solid var(--border); }
.btn-action:hover { border-color: var(--border-strong); transform: translateY(-1px); box-shadow: var(--shadow-sm); }
.btn-action:active { transform: translateY(0); }
.btn-icon { display: none; }
.btn-title { font-size: 13px; font-weight: 700; }
.shortcut-badge { font-size: 10px; color: var(--faint); font-family: var(--font-mono); }
#btnApprove { border-color: var(--success-border); background: var(--success-bg); }
#btnApprove .btn-title { color: var(--success); }
#btnDoubt .btn-title { color: var(--warning); }
#btnMismatch .btn-title { color: var(--danger); }

/* GENÉRICOS */
.btn { font-family: var(--font-sans); font-size: 12.5px; font-weight: 600; padding: 7px 13px; border-radius: 8px; cursor: pointer; display: inline-flex; align-items: center; justify-content: center; gap: 6px; transition: all 0.15s; border: 1px solid var(--border); background: var(--surface); color: var(--ink); white-space: nowrap; }
.btn-sm { font-size: 12px; padding: 6px 10px; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn-primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn-primary:hover:not(:disabled) { background: var(--accent-ink); border-color: var(--accent-ink); }
.btn-secondary:hover { background: var(--surface-2); }
.btn-outline:hover { background: var(--surface-2); }
.styled-select, .styled-input { background: var(--surface); border: 1px solid var(--border); color: var(--ink); padding: 7px 10px; border-radius: 8px; font-family: var(--font-sans); font-size: 12.5px; font-weight: 500; }
.styled-select:focus, .styled-input:focus { outline: 2px solid rgba(15, 118, 110, 0.25); border-color: var(--accent); }

/* DRAWER */
.drawer { position: fixed; top: 56px; right: -420px; width: 400px; max-width: 92vw; height: calc(100vh - 56px); background: var(--surface); border-left: 1px solid var(--border); box-shadow: -12px 0 32px rgba(15, 23, 42, 0.12); display: flex; flex-direction: column; transition: right 0.25s ease; z-index: 100; }
.drawer.open { right: 0; }
.drawer-header { padding: 14px 16px; display: flex; align-items: center; justify-content: space-between; border-bottom: 1px solid var(--border); }
.drawer-header h3 { font-size: 14px; }
.btn-close { background: transparent; border: 1px solid var(--border); border-radius: 6px; color: var(--muted); font-size: 13px; cursor: pointer; padding: 4px 9px; }
.btn-close:hover { color: var(--ink); background: var(--surface-2); }
.drawer-filters { padding: 12px 16px; display: flex; flex-direction: column; gap: 8px; border-bottom: 1px solid var(--border); background: var(--bg); }
.drawer-list { flex: 1; overflow-y: auto; padding: 8px; display: flex; flex-direction: column; gap: 6px; }
.drawer-item { padding: 9px 12px; background: var(--surface); border-radius: 8px; border: 1px solid var(--border); display: flex; align-items: center; justify-content: space-between; cursor: pointer; font-size: 12.5px; transition: all 0.15s; gap: 8px; }
.drawer-item:hover, .drawer-item.active { border-color: var(--accent); background: var(--accent-bg); }

/* MODAL */
.modal { position: fixed; inset: 0; background: rgba(15, 23, 42, 0.45); display: flex; align-items: center; justify-content: center; z-index: 200; padding: 20px; }
.modal-content { background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: 20px; width: 100%; max-width: 420px; display: flex; flex-direction: column; gap: 14px; box-shadow: 0 24px 64px rgba(15, 23, 42, 0.25); }
.modal-content h3 { font-size: 15px; }
.modal-orig { font-size: 12.5px; color: var(--muted); background: var(--surface-2); border: 1px solid var(--border); border-radius: 7px; padding: 8px 12px; font-family: var(--font-mono); }
.modal-input-group { display: flex; flex-direction: column; gap: 6px; }
.modal-input-group label { font-size: 12px; font-weight: 600; color: var(--muted); }
.modal-input-group input { width: 100%; }
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; }

/* TOAST */
.toast { position: fixed; bottom: 20px; right: 20px; background: var(--ink); color: #fff; padding: 10px 16px; border-radius: 9px; font-size: 13px; font-weight: 600; box-shadow: 0 12px 32px rgba(15, 23, 42, 0.25); transform: translateY(12px); opacity: 0; transition: all 0.25s ease; z-index: 300; pointer-events: none; max-width: min(420px, 90vw); }
.toast.show { transform: translateY(0); opacity: 1; }
.toast.error { background: var(--danger); }

/* LOADING */
.image-loading, .image-error { position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%); display: flex; flex-direction: column; align-items: center; gap: 10px; color: #CBD5E1; font-size: 13px; background: rgba(11, 18, 32, 0.9); padding: 18px 26px; border-radius: 10px; border: 1px solid rgba(255,255,255,0.1); z-index: 10; }
.spinner { width: 28px; height: 28px; border: 3px solid rgba(15, 118, 110, 0.2); border-top-color: var(--accent); border-radius: 50%; animation: spin 0.8s linear infinite; }
.image-viewport .spinner { border-color: rgba(255,255,255,0.15); border-top-color: #fff; }
@keyframes spin { to { transform: rotate(360deg); } }

/* SPREADSHEET */
.spreadsheet-view { display: flex; flex-direction: column; height: calc(100vh - 56px); background: var(--bg); padding: 20px; gap: 12px; overflow: hidden; max-width: 1440px; width: 100%; margin: 0 auto; }
.spreadsheet-toolbar { display: flex; align-items: center; justify-content: space-between; gap: 12px; background: var(--surface); padding: 10px 14px; border-radius: var(--radius); border: 1px solid var(--border); box-shadow: var(--shadow-sm); flex-wrap: wrap; }
.toolbar-search { flex: 1; min-width: 200px; max-width: 380px; }
.toolbar-search input { width: 100%; }
.toolbar-filters { display: flex; align-items: center; gap: 8px; }
.spreadsheet-pagination { display: flex; align-items: center; gap: 8px; }
.sheet-page-info { font-size: 12px; color: var(--muted); font-weight: 500; font-variant-numeric: tabular-nums; }
.spreadsheet-table-wrapper { flex: 1; overflow: auto; background: var(--surface); border-radius: var(--radius); border: 1px solid var(--border); box-shadow: var(--shadow-sm); }
.spreadsheet-table { width: 100%; border-collapse: collapse; font-size: 12.5px; text-align: left; }
.spreadsheet-table th { position: sticky; top: 0; background: var(--surface-2); color: var(--muted); padding: 9px 12px; border-bottom: 1px solid var(--border); font-size: 10.5px; text-transform: uppercase; letter-spacing: 0.06em; font-weight: 700; z-index: 5; white-space: nowrap; }
.spreadsheet-table td { padding: 9px 12px; border-bottom: 1px solid var(--border); vertical-align: middle; font-variant-numeric: tabular-nums; }
.spreadsheet-table tr:hover td { background: var(--surface-2); }
.spreadsheet-table tr.has-correction td { background: var(--success-bg); }
.sheet-badge { font-size: 11px; font-weight: 700; padding: 2px 9px; border-radius: 999px; border: 1px solid var(--border); white-space: nowrap; }
.sheet-cell-corr { color: var(--success); font-weight: 600; }
.sheet-cell-orig-struck { text-decoration: line-through; color: var(--faint); margin-right: 6px; font-weight: 400; }

/* Quebras Responsivas para Evitar Sobreposição no Header */
@media (max-width: 1420px) {
  .header-center .stats-badges {
    display: none !important;
  }
  .header-center {
    max-width: 220px;
  }
}

@media (max-width: 1140px) {
  .header-center {
    display: none !important;
  }
}

@media (max-width: 960px) {
  .main-container { grid-template-columns: 1fr; overflow-y: auto; height: auto; min-height: calc(100vh - 56px); }
  .image-viewer-section { min-height: 380px; border-right: 0; border-bottom: 1px solid var(--border); }
  .audit-panel-section { overflow: visible; }
  .spreadsheet-view { height: auto; min-height: calc(100vh - 56px); }
}

/* Mobile & PWA: layout ergonômico touch-first, alvos de toque maiores, 2x2 nos botões */
@media (max-width: 768px) {
  body { overflow-x: hidden; height: auto; display: block; }
  
  /* Header em 2 linhas limpas no celular */
  .app-header {
    height: auto;
    min-height: 52px;
    flex-wrap: wrap;
    padding: 8px 12px;
    row-gap: 8px;
    column-gap: 8px;
  }

  .header-left {
    order: 1;
    flex: 1 1 auto;
    justify-content: flex-start;
    gap: 8px;
    min-width: 0;
  }

  .logo-text h1 { font-size: 14px; }
  .logo-text .subtext { display: none; }

  .reviewer-auth-box {
    padding: 2px 7px;
    gap: 5px;
    font-size: 11px;
  }
  .auth-name {
    max-width: 80px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }
  .auth-role { display: none; }

  .header-right {
    order: 2;
    flex: 0 0 auto;
    gap: 6px;
  }
  .header-right .jump-box { display: none; }
  .header-right #btnOpenExportModal { display: none; }

  /* Abas em scroll horizontal suave no topo do celular */
  .header-tabs {
    order: 3;
    flex: 1 1 100%;
    width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    display: flex;
    padding: 2px;
    gap: 4px;
    scrollbar-width: none;
  }
  .header-tabs::-webkit-scrollbar { display: none; }
  .header-tab-btn {
    flex: 0 0 auto;
    padding: 6px 13px;
    font-size: 12px;
    white-space: nowrap;
  }

  .header-center { display: none !important; }

  /* Auditoria no celular */
  .main-container {
    display: flex;
    flex-direction: column;
    height: auto;
    overflow: visible;
    width: 100%;
  }

  .image-viewer-section {
    height: 42vh;
    min-height: 250px;
    max-height: 380px;
    border-right: 0;
    border-bottom: 2px solid var(--border);
    position: sticky;
    top: 0;
    z-index: 20;
  }

  .image-toolbar {
    padding: 4px 8px;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    flex-wrap: nowrap;
  }
  .image-toolbar::-webkit-scrollbar { display: none; }
  .tool-btn {
    padding: 6px 10px;
    font-size: 12px;
    white-space: nowrap;
    flex-shrink: 0;
  }

  .audit-panel-section {
    display: flex;
    flex-direction: column;
    padding: 12px 10px;
    gap: 12px;
    overflow: visible;
    height: auto;
  }

  /* Ordem ergonômica móvel: Navegação -> Dados -> Ações -> Histórico */
  .nav-bar { order: 1; flex-wrap: wrap; margin-bottom: 0; }
  .record-position { order: -1; flex: 1 1 100%; margin-bottom: 4px; }
  .data-card { order: 2; }
  .action-card { order: 3; }
  .history-card { order: 4; }
  .same-photo-records { order: 5; }

  .field-row { grid-template-columns: minmax(0, 1fr) auto; row-gap: 4px; }
  .field-name { grid-column: 1 / -1; }

  /* BOTÕES DE AUDITORIA: GRADE 2x2 NO CELULAR (Conferem, Dúvida, Não confere, Não se aplica) */
  .audit-buttons-grid,
  .audit-buttons-grid-4 {
    display: grid !important;
    grid-template-columns: repeat(2, 1fr) !important;
    gap: 10px !important;
    padding: 12px 10px !important;
  }

  .btn-action {
    flex-direction: column !important;
    align-items: center !important;
    justify-content: center !important;
    min-height: 54px !important;
    padding: 10px 6px !important;
    border-radius: 10px !important;
    text-align: center !important;
  }

  .btn-action .btn-title {
    font-size: 13.5px !important;
    font-weight: 700 !important;
    line-height: 1.2 !important;
  }

  .btn-action .shortcut-badge {
    display: none !important;
  }

  /* Botão "Não se aplica" com destaque visual claro no celular */
  .btn-action-na {
    background: #F0F9FF !important;
    border-color: #0284C7 !important;
    color: #0369A1 !important;
  }

  .resolve-options { grid-template-columns: 1fr; }
  .drawer { top: 0; height: 100vh; width: 100vw; max-width: 100vw; }
  .spreadsheet-view { padding: 10px; height: auto; min-height: calc(100vh - 56px); }
  .spreadsheet-toolbar { flex-direction: column; align-items: stretch; }
  .toolbar-search { max-width: none; }
  .modal { padding: 12px; align-items: flex-end; }
  .modal-content { max-width: none; }
  .toast { left: 12px; right: 12px; bottom: 12px; max-width: none; }
  .zoom-hint { display: none; }
}

/* Ajustes finos do tema escuro */
[data-theme="dark"] .comment-box textarea,
[data-theme="dark"] .styled-select,
[data-theme="dark"] .styled-input { background: var(--surface-2); }
[data-theme="dark"] .modal-orig { background: var(--surface-2); }
[data-theme="dark"] .image-viewer-section { border-right-color: #1E293B; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; transition-duration: 0.01ms !important; }
}

/* ============================================================ */
/* NOVAS FUNCIONALIDADES (NOT APPLICABLE, MARCAÇÃO, STATS, EXPORT) */
/* ============================================================ */

/* Badges e Botões "Não se aplica" */
.badge-na {
  background: #E0F2FE;
  color: #0369A1;
  border-color: #BAE6FD;
}
[data-theme="dark"] .badge-na {
  background: rgba(3, 105, 161, 0.2);
  color: #38BDF8;
  border-color: #0369A1;
}

/* 4 colunas no Desktop (sem !important para permitir 2x2 no mobile) */
.audit-buttons-grid-4 {
  grid-template-columns: repeat(4, 1fr);
}

.btn-action-na {
  border-color: #BAE6FD;
  color: #0369A1;
}
.btn-action-na:hover {
  background: #F0F9FF;
  border-color: #0284C7;
}
.btn-action-na.active {
  background: #0284C7;
  color: #fff;
  border-color: #0284C7;
}

/* Botão de Instalação PWA */
.btn-pwa-install {
  background: var(--accent) !important;
  color: #fff !important;
  border-color: var(--accent-ink) !important;
  font-weight: 700 !important;
  font-size: 11px !important;
  display: inline-flex;
  align-items: center;
  gap: 3px;
  animation: pulse-pwa 2.5s infinite;
}

@keyframes pulse-pwa {
  0% { transform: scale(1); }
  50% { transform: scale(1.05); }
  100% { transform: scale(1); }
}

/* Botão de destaque na Toolbar */
.btn-highlight {
  background: var(--accent) !important;
  color: #fff !important;
  font-weight: 600 !important;
}
.btn-highlight.active {
  background: #E11D48 !important;
  color: #fff !important;
  animation: pulse-border 1.5s infinite;
}
@keyframes pulse-border {
  0% { box-shadow: 0 0 0 0 rgba(225, 29, 72, 0.7); }
  70% { box-shadow: 0 0 0 8px rgba(225, 29, 72, 0); }
  100% { box-shadow: 0 0 0 0 rgba(225, 29, 72, 0); }
}

/* Overlay de Anotação de Placas na Imagem */
.annotation-overlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
}
.marking-active {
  cursor: crosshair !important;
}
.marking-active .annotation-overlay {
  pointer-events: auto;
}

.plate-marker {
  position: absolute;
  border: 3px dashed #10B981;
  border-radius: 50%;
  transform: translate(-50%, -50%);
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: auto;
  cursor: pointer;
  background: rgba(16, 185, 129, 0.15);
  box-shadow: 0 0 12px rgba(16, 185, 129, 0.4);
  transition: transform 0.15s ease, background 0.15s ease;
}
.plate-marker:hover {
  transform: translate(-50%, -50%) scale(1.04);
  background: rgba(16, 185, 129, 0.28);
}
.plate-marker.current-plate {
  border: 3px solid #F59E0B;
  background: rgba(245, 158, 11, 0.2);
  box-shadow: 0 0 16px rgba(245, 158, 11, 0.6);
  z-index: 8;
}
.plate-marker.other-plate {
  border: 2px dashed #0284C7;
  background: rgba(2, 132, 199, 0.12);
  opacity: 0.85;
}
.plate-marker-badge {
  background: rgba(15, 23, 42, 0.85);
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  padding: 3px 8px;
  border-radius: 6px;
  pointer-events: none;
  white-space: nowrap;
  letter-spacing: 0.02em;
  box-shadow: 0 2px 5px rgba(0,0,0,0.3);
  transform-origin: center center;
  transition: transform 0.15s ease;
  display: inline-block;
}

/* ============================================================ */
/* ABA DE ESTATÍSTICAS */
/* ============================================================ */
.stats-view {
  flex: 1;
  overflow-y: auto;
  background: var(--bg);
  padding: 24px;
}
.stats-container {
  max-width: 1300px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: 20px;
}
.stats-header-bar h2 {
  font-size: 20px;
  font-weight: 700;
  color: var(--ink);
}
.stats-subtitle {
  font-size: 13px;
  color: var(--muted);
}
.stats-cards-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 14px;
}
.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  box-shadow: var(--shadow-sm);
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.stat-card-title {
  font-size: 12px;
  font-weight: 600;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.stat-card-value {
  font-size: 28px;
  font-weight: 800;
  color: var(--ink);
  font-variant-numeric: tabular-nums;
  line-height: 1.1;
}
.stat-card-sub {
  font-size: 11.5px;
  color: var(--muted);
  font-weight: 500;
}
.stat-card-approved { border-left: 4px solid var(--success); }
.stat-card-na { border-left: 4px solid #0284C7; }
.stat-card-doubt { border-left: 4px solid var(--warning); }
.stat-card-mismatch { border-left: 4px solid var(--danger); }
.stat-card-pending { border-left: 4px solid var(--muted); }

.stats-tables-grid {
  display: grid;
  grid-template-columns: 3fr 2fr;
  gap: 16px;
}
@media (max-width: 900px) {
  .stats-tables-grid { grid-template-columns: 1fr; }
}
.styled-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}
.styled-table th {
  background: var(--surface-2);
  color: var(--muted);
  padding: 10px 14px;
  text-align: left;
  font-size: 11px;
  text-transform: uppercase;
  font-weight: 700;
  border-bottom: 1px solid var(--border);
}
.styled-table td {
  padding: 10px 14px;
  border-bottom: 1px solid var(--border);
  font-variant-numeric: tabular-nums;
}
.styled-table tr:hover td {
  background: var(--surface-2);
}

/* ============================================================ */
/* MODAL DE EXPORTAÇÃO E DOWNLOAD */
/* ============================================================ */
.export-modal-content {
  max-width: 580px;
  width: 100%;
}
.modal-subtitle {
  font-size: 12.5px;
  color: var(--muted);
  margin-bottom: 16px;
}
.modal-filter-group {
  margin-bottom: 14px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.modal-filter-group label {
  font-size: 12px;
  font-weight: 600;
  color: var(--ink);
}
.export-options-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
  margin-top: 18px;
}
.export-option-card {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 10px;
}
.export-option-card h4 {
  font-size: 14px;
  font-weight: 700;
  color: var(--ink);
}
.export-option-card p {
  font-size: 11.5px;
  color: var(--muted);
  line-height: 1.4;
  flex: 1;
}
.export-status-message {
  margin-top: 14px;
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  font-size: 12.5px;
  background: var(--surface-2);
  border: 1px solid var(--border);
}

/* ============================================================ */
/* BANNER DE TRATAMENTO ATIVO & AÇÕES RÁPIDAS */
/* ============================================================ */
.treatment-filter-banner {
  background: linear-gradient(135deg, #1E293B, #0F172A);
  border: 1px solid #3B82F6;
  border-radius: var(--radius);
  padding: 8px 14px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
  box-shadow: 0 4px 12px rgba(59, 130, 246, 0.15);
  animation: fadeIn 0.2s ease-out;
}
.treatment-filter-info {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12.5px;
  color: #F1F5F9;
}
.treatment-filter-info strong {
  color: #60A5FA;
  font-weight: 700;
}
.treatment-filter-count {
  font-size: 11.5px;
  color: #94A3B8;
  font-family: var(--font-mono);
  background: rgba(255, 255, 255, 0.08);
  padding: 1px 7px;
  border-radius: 999px;
}
.treatment-filter-actions {
  display: flex;
  align-items: center;
  gap: 6px;
}
.treatment-row-clickable {
  transition: background 0.12s ease;
}
.treatment-row-clickable:hover td {
  background: rgba(59, 130, 246, 0.08) !important;
}
.treatment-actions-cell {
  display: flex;
  gap: 6px;
  justify-content: center;
}
.btn-action-audit-trat {
  font-size: 11.5px;
  padding: 3px 10px;
  background: #3B82F6;
  color: #fff;
  border-radius: 5px;
  border: none;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s ease;
}
.btn-action-audit-trat:hover {
  background: #2563EB;
}
.btn-action-view-sheet {
  font-size: 11.5px;
  padding: 3px 10px;
  background: var(--surface-2);
  color: var(--ink);
  border-radius: 5px;
  border: 1px solid var(--border);
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s ease;
}
.btn-action-view-sheet:hover {
  background: var(--border);
}

/* Modal: Pré-seleção e chips rápidos de tratamento */
.modal-treatment-presets {
  background: rgba(59, 130, 246, 0.05);
  border: 1px solid rgba(59, 130, 246, 0.2);
  border-radius: 8px;
  padding: 10px 12px;
  margin-bottom: 14px;
}
.modal-treatment-presets .preset-label {
  display: block;
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--ink);
  margin-bottom: 5px;
}
.quick-chips-label {
  font-size: 0.72rem;
  color: var(--muted);
  margin-top: 6px;
  margin-bottom: 4px;
}
.quick-chips-container {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
}
.treatment-chip {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 2px 9px;
  font-size: 0.75rem;
  font-weight: 500;
  color: var(--ink);
  cursor: pointer;
  transition: all 0.15s ease;
  user-select: none;
}
.treatment-chip:hover {
  background: #3B82F6;
  border-color: #3B82F6;
  color: #fff;
  transform: translateY(-1px);
}
.treatment-chip:active {
  transform: translateY(0);
}

/* Modal e Botões: Adicionar Placa */
.same-photo-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 0.5rem;
}
.btn-add-plate-inline {
  font-size: 0.72rem;
  padding: 0.2rem 0.6rem;
  border-radius: 4px;
}
.add-plate-modal-content {
  max-width: 520px;
}
.modal-header-flex {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 0.25rem;
}
.form-row-2col {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.75rem;
  margin-bottom: 0.75rem;
}

/* ============================================================
   ABA GALERIA VISUAL
   ============================================================ */
.gallery-view {
  display: flex;
  flex-direction: column;
  height: calc(100vh - 65px);
  overflow: hidden;
  background: var(--bg);
}

.gallery-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.75rem 1.25rem;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
  z-index: 10;
}

.gallery-modes {
  display: flex;
  gap: 0.35rem;
  background: var(--surface-2);
  padding: 3px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
}

.btn-mode {
  background: transparent;
  border: none;
  color: var(--muted);
  font-size: 0.8rem;
  font-weight: 600;
  padding: 0.35rem 0.75rem;
  border-radius: 5px;
  cursor: pointer;
  transition: all 0.15s ease;
}

.btn-mode:hover {
  color: var(--ink);
}

.btn-mode.active {
  background: var(--surface);
  color: var(--accent-ink);
  box-shadow: 0 1px 2px rgba(0,0,0,0.08);
}

.gallery-filters {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.gallery-summary {
  font-size: 0.82rem;
  color: var(--muted);
  font-weight: 500;
}

.gallery-container {
  flex: 1;
  overflow-y: auto;
  padding: 1.25rem;
}

.gallery-loading {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 4rem;
  color: var(--muted);
  gap: 1rem;
}

/* Botão Voltar ao Feed na Barra de Auditoria */
.btn-back-feed {
  background: var(--surface-2);
  color: var(--accent);
  border: 1px solid var(--accent);
  font-weight: 600;
  font-size: 0.78rem;
  padding: 0.25rem 0.65rem;
  border-radius: var(--radius-sm);
  display: inline-flex;
  align-items: center;
  gap: 4px;
  cursor: pointer;
  transition: all 0.15s ease;
}
.btn-back-feed:hover {
  background: var(--accent);
  color: #ffffff;
}

/* Controle de Colunas do Feed (3 ou 4 colunas) */
.gallery-cols-toggle {
  display: flex;
  align-items: center;
  gap: 3px;
  background: var(--surface-2);
  padding: 3px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
}
.gallery-cols-toggle .btn-mode {
  padding: 0.25rem 0.55rem;
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--muted);
  background: transparent;
  border: none;
  border-radius: 4px;
  cursor: pointer;
  transition: all 0.15s ease;
}
.gallery-cols-toggle .btn-mode:hover {
  color: var(--ink);
}
.gallery-cols-toggle .btn-mode.active {
  background: var(--surface);
  color: var(--accent);
  box-shadow: var(--shadow-sm);
}

/* Grade de Fotos Estilo Celular (3 ou 4 colunas) */
.gallery-feed-grid {
  display: grid;
  gap: 8px;
  width: 100%;
}
.gallery-feed-grid.cols-3 {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}
.gallery-feed-grid.cols-4 {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}
@media (max-width: 960px) {
  .gallery-feed-grid.cols-4,
  .gallery-feed-grid.cols-3 {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}
@media (max-width: 580px) {
  .gallery-feed-grid.cols-4,
  .gallery-feed-grid.cols-3 {
    grid-template-columns: 1fr;
  }
}

/* Miniatura Quadrada Estilo Feed de Celular */
.gallery-feed-item {
  position: relative;
  aspect-ratio: 1 / 1;
  border-radius: 8px;
  overflow: hidden;
  background: var(--viewer-bg);
  cursor: pointer;
  border: 1px solid var(--border);
  box-shadow: 0 1px 3px rgba(0,0,0,0.06);
  transition: transform 0.18s ease, box-shadow 0.18s ease, border-color 0.18s ease;
  user-select: none;
}
.gallery-feed-item:hover {
  transform: translateY(-2px) scale(1.015);
  box-shadow: 0 8px 24px rgba(0,0,0,0.18);
  border-color: var(--accent);
  z-index: 2;
}
.gallery-feed-thumb {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  transition: transform 0.25s ease;
}
.gallery-feed-item:hover .gallery-feed-thumb {
  transform: scale(1.05);
}

.feed-item-top {
  position: absolute;
  top: 6px;
  right: 6px;
  display: flex;
  align-items: center;
  gap: 4px;
  pointer-events: none;
  z-index: 3;
}
.feed-status-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  border: 1.5px solid #ffffff;
  box-shadow: 0 1px 4px rgba(0,0,0,0.4);
}
.feed-status-dot.dot-approved { background: #10b981; }
.feed-status-dot.dot-mismatch { background: #ef4444; }
.feed-status-dot.dot-doubt { background: #f59e0b; }
.feed-status-dot.dot-not_applicable { background: #94a3b8; }
.feed-status-dot.dot-conflict { background: #a855f7; }
.feed-status-dot.dot-pending { background: #64748b; }

.feed-item-bottom {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  padding: 22px 8px 6px;
  background: linear-gradient(to top, rgba(15, 23, 42, 0.85) 0%, rgba(15, 23, 42, 0.35) 60%, rgba(0,0,0,0) 100%);
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  color: #ffffff;
  pointer-events: none;
  z-index: 3;
}
.feed-item-badge {
  background: rgba(15, 23, 42, 0.75);
  backdrop-filter: blur(4px);
  font-size: 0.72rem;
  font-weight: 600;
  padding: 2px 7px;
  border-radius: 10px;
  border: 1px solid rgba(255,255,255,0.25);
  display: flex;
  align-items: center;
  gap: 3px;
  color: #f8fafc;
}
.feed-item-info {
  font-size: 0.7rem;
  color: #f1f5f9;
  text-shadow: 0 1px 2px rgba(0,0,0,0.8);
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 65%;
}

/* Modal Lightbox de Foto Expandida */
.gallery-expand-modal {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.82);
  backdrop-filter: blur(8px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 9999;
  padding: 1rem;
}
.gallery-expand-content {
  width: min(94vw, 1050px);
  max-height: 94vh;
  display: flex;
  flex-direction: column;
  background: var(--surface);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: 0 25px 50px -12px rgba(0,0,0,0.5);
  border: 1px solid var(--border);
  animation: modalScaleIn 0.2s ease-out;
}
@keyframes modalScaleIn {
  from { opacity: 0; transform: scale(0.96); }
  to { opacity: 1; transform: scale(1); }
}
.gallery-expand-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.75rem 1.25rem;
  border-bottom: 1px solid var(--border);
  background: var(--surface-2);
}
.gallery-expand-title-wrap {
  display: flex;
  align-items: baseline;
  gap: 0.75rem;
  min-width: 0;
}
.gallery-expand-title {
  font-size: 0.95rem;
  font-weight: 700;
  font-family: var(--font-mono);
  color: var(--ink);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.gallery-expand-counter {
  font-size: 0.78rem;
  color: var(--muted);
  white-space: nowrap;
}
.gallery-expand-header-actions {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  flex-shrink: 0;
}
.gallery-expand-media {
  background: #070b14;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 350px;
  max-height: 52vh;
  overflow: hidden;
  position: relative;
}
.gallery-expand-img {
  max-width: 100%;
  max-height: 52vh;
  object-fit: contain;
  display: block;
}
.gallery-expand-details {
  padding: 0.85rem 1.25rem;
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
  background: var(--surface);
  overflow-y: auto;
  max-height: 40vh;
}
.gallery-expand-meta-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 0.5rem;
}
.expand-meta-info {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--ink);
}
.expand-status-badges {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  flex-wrap: wrap;
}
.gallery-expand-plates-box {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 0.6rem 0.8rem;
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}
.expand-plates-label {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.74rem;
  font-weight: 600;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.03em;
}
.selected-plate-info {
  color: var(--accent);
  text-transform: none;
  font-weight: 700;
  font-size: 0.8rem;
}
.gallery-expand-pills {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  max-height: 120px;
  overflow-y: auto;
}
.expand-plate-pill {
  font-size: 0.78rem;
  font-family: var(--font-mono);
  padding: 4px 9px;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--ink);
  cursor: pointer;
  transition: all 0.15s ease;
  user-select: none;
}
.expand-plate-pill:hover {
  border-color: var(--accent);
  transform: translateY(-1px);
}
.expand-plate-pill.selected {
  border-color: var(--accent);
  background: var(--accent-bg);
  color: var(--accent-ink);
  font-weight: 700;
  box-shadow: 0 0 0 2px rgba(15, 118, 110, 0.25);
}
.expand-plate-pill.pill-approved { border-color: var(--success-border); }
.expand-plate-pill.pill-mismatch { border-color: var(--danger-border); }
.expand-plate-pill.pill-doubt { border-color: var(--warning-border); }
.expand-plate-pill.pill-not_applicable { border-color: var(--border); }
.expand-plate-pill.pill-conflict { border-color: rgba(168, 85, 247, 0.4); }

.gallery-expand-footer-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 0.75rem;
  margin-top: 0.25rem;
}
.btn-expand-audit {
  font-weight: 600;
  padding: 0.5rem 1.25rem;
  font-size: 0.9rem;
}

/* Agrupamento por Data ou por Placa */
.gallery-group {
  margin-bottom: 1.5rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
}

.gallery-group-header {
  padding: 0.85rem 1.25rem;
  background: var(--surface-2);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  cursor: pointer;
  user-select: none;
}

.gallery-group-header:hover {
  background: var(--border);
}

.gallery-group-title {
  font-size: 0.92rem;
  font-weight: 700;
  color: var(--ink);
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.gallery-group-count {
  font-size: 0.8rem;
  color: var(--muted);
  font-weight: 500;
}

.gallery-group-body {
  padding: 1.25rem;
}

/* ==========================================================================
   AUTENTICAÇÃO & CONTROLE DE ACESSO (GEELTEC)
   ========================================================================== */

.reviewer-auth-box {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  padding: 4px 10px;
  border-radius: var(--radius-sm);
  font-size: 12px;
}

.auth-avatar {
  font-size: 15px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.auth-details {
  display: flex;
  flex-direction: column;
  line-height: 1.15;
}

.auth-name {
  font-weight: 700;
  color: var(--ink);
  font-size: 12px;
}

.auth-role {
  font-size: 10px;
  color: var(--muted);
}

.auth-actions {
  display: flex;
  align-items: center;
  gap: 4px;
  margin-left: 4px;
}

.btn-xs {
  font-size: 11px;
  padding: 2px 7px;
  border-radius: 4px;
  cursor: pointer;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--ink);
  transition: all 0.15s ease;
}

.btn-xs:hover {
  background: var(--surface-2);
  border-color: var(--border-strong);
}

.btn-outline-danger {
  color: var(--danger);
  border-color: var(--danger-border);
}

.btn-outline-danger:hover {
  background: var(--danger-bg);
  border-color: var(--danger);
}

/* Modais de Autenticação */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(11, 18, 32, 0.88);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 9999;
  padding: 16px;
}

.modal-backdrop > .modal {
  position: relative;
  inset: auto;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  box-shadow: 0 25px 60px -15px rgba(0, 0, 0, 0.5);
  max-width: 440px;
  width: 100%;
  padding: 28px;
  z-index: 1;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.modal-backdrop > .modal.modal-lg {
  max-width: 680px;
}

.auth-header {
  text-align: center;
}

.auth-brand-badge {
  display: inline-block;
  background: var(--accent-bg);
  color: var(--accent);
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  padding: 3px 10px;
  border-radius: 999px;
  border: 1px solid var(--accent);
  margin-bottom: 8px;
}

.auth-header h2 {
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--ink);
  margin-bottom: 4px;
}

.auth-subtitle {
  font-size: 0.82rem;
  color: var(--muted);
  line-height: 1.4;
}

.auth-tabs {
  display: flex;
  background: var(--surface-2);
  padding: 3px;
  border-radius: 8px;
  border: 1px solid var(--border);
  gap: 4px;
}

.auth-tab-btn {
  flex: 1;
  background: transparent;
  border: none;
  padding: 8px 12px;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--muted);
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.15s ease;
}

.auth-tab-btn:hover {
  color: var(--ink);
}

.auth-tab-btn.active {
  background: var(--surface);
  color: var(--ink);
  box-shadow: var(--shadow-sm);
  font-weight: 700;
}

.auth-form-panel {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.auth-invite-notice {
  background: var(--accent-bg);
  border: 1px solid var(--accent);
  color: var(--accent-ink);
  padding: 10px 12px;
  border-radius: 8px;
  font-size: 0.8rem;
  line-height: 1.4;
}

.auth-input {
  width: 100%;
  box-sizing: border-box;
}

.invite-code-input {
  font-family: var(--font-mono);
  letter-spacing: 0.12em;
  font-size: 1.05rem;
  text-align: center;
  border-color: var(--accent) !important;
}

.auth-submit-btn {
  padding: 11px 16px;
  font-size: 0.92rem;
  font-weight: 700;
  margin-top: 6px;
}

.auth-error-msg {
  background: var(--danger-bg);
  color: var(--danger);
  border: 1px solid var(--danger-border);
  padding: 8px 12px;
  border-radius: 6px;
  font-size: 0.82rem;
  font-weight: 600;
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.modal-header h3 {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--ink);
}

.btn-close {
  background: transparent;
  border: none;
  font-size: 1.4rem;
  color: var(--muted);
  cursor: pointer;
  line-height: 1;
}

.btn-close:hover {
  color: var(--ink);
}

.invite-badge-active {
  background: var(--success-bg);
  color: var(--success);
  border: 1px solid var(--success-border);
  padding: 2px 7px;
  border-radius: 999px;
  font-size: 10.5px;
  font-weight: 600;
}

.invite-badge-depleted {
  background: var(--danger-bg);
  color: var(--danger);
  border: 1px solid var(--danger-border);
  padding: 2px 7px;
  border-radius: 999px;
  font-size: 10.5px;
  font-weight: 600;
}



