/* =============================================================
   AUDITORIA PAGE — Material 3 Expressive + Rich Colors
   Mobile-first. Tokens de styles.css.
   ============================================================= */

/* ── Keyframes ────────────────────────────────────────────── */
@keyframes aud-slideDown {
    from { opacity: 0; transform: translateY(-12px); }
    to   { opacity: 1; transform: translateY(0); }
}
@keyframes aud-fadeUp {
    from { opacity: 0; transform: translateY(16px) scale(0.97); }
    to   { opacity: 1; transform: translateY(0)    scale(1); }
}
@keyframes aud-cardIn {
    from { opacity: 0; transform: translateY(12px); }
    to   { opacity: 1; transform: translateY(0); }
}
@keyframes aud-statPop {
    0%   { transform: scale(1); }
    45%  { transform: scale(1.1); }
    100% { transform: scale(1); }
}
@keyframes aud-criticalPulse {
    0%, 100% { box-shadow: 0 0 0 0 rgba(220,38,38,0.35); }
    50%       { box-shadow: 0 0 0 6px rgba(220,38,38,0); }
}
@keyframes aud-tabContentIn {
    from { opacity: 0; transform: translateX(10px); }
    to   { opacity: 1; transform: translateX(0); }
}
@keyframes aud-spin {
    to { transform: rotate(360deg); }
}

/* ── Base ─────────────────────────────────────────────────── */
body {
    background: #eef2f8;
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    margin: 0; padding: 0;
    color: var(--gray800, #1e293b);
    -webkit-font-smoothing: antialiased;
}
.u-hidden { display: none !important; }

/* ── Action Bar ───────────────────────────────────────────── */
.auditoria-actions {
    position: sticky; top: 0; z-index: 200;
    display: flex; align-items: center; gap: 6px;
    padding: calc(10px + env(safe-area-inset-top, 0px)) 14px 10px;
    background: linear-gradient(135deg, #1e3a8a 0%, #1d4ed8 100%);
    box-shadow: 0 4px 20px rgba(30,58,138,0.35);
    animation: aud-slideDown 0.3s cubic-bezier(0.34,1.56,0.64,1) both;
}
.auditoria-actions .spacer { flex: 1; min-width: 0; }

/* Back button */
.auditoria-actions .back-btn {
    display: flex; align-items: center; justify-content: center;
    width: 40px; height: 40px;
    border-radius: 50%;
    background: rgba(255,255,255,0.18);
    color: #fff;
    text-decoration: none; border: none; cursor: pointer;
    flex-shrink: 0; font-size: 15px;
    transition: background 0.2s, transform 0.15s;
    -webkit-tap-highlight-color: transparent;
    backdrop-filter: blur(4px);
}
.auditoria-actions .back-btn:active {
    background: rgba(255,255,255,0.3);
    transform: scale(0.93);
}

/* Page title in action bar */
.auditoria-actions .aud-page-title {
    font-size: 15px; font-weight: 700; color: #fff;
    letter-spacing: 0.01em; flex: 1; min-width: 0;
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}

/* Buttons */
.auditoria-actions .action-btn {
    display: inline-flex; align-items: center; gap: 6px;
    padding: 0 14px; height: 36px;
    border-radius: 18px;
    font-size: 12px; font-weight: 700; font-family: inherit;
    border: none; cursor: pointer; white-space: nowrap; flex-shrink: 0;
    -webkit-tap-highlight-color: transparent;
    transition: opacity 0.15s, transform 0.12s, background 0.15s;
    letter-spacing: 0.01em;
}
.auditoria-actions .action-btn:active { opacity: 0.85; transform: scale(0.95); }

.auditoria-actions .action-btn.primary {
    background: rgba(255,255,255,0.95);
    color: #1e3a8a;
    box-shadow: 0 2px 8px rgba(0,0,0,0.2);
}
.auditoria-actions .action-btn.primary:active { background: #fff; }

.auditoria-actions .action-btn.secondary {
    background: rgba(255,255,255,0.18);
    color: #fff;
    border: 1px solid rgba(255,255,255,0.3);
    backdrop-filter: blur(4px);
}
.auditoria-actions .action-btn.secondary:active { background: rgba(255,255,255,0.28); }

.auditoria-actions .action-btn.danger {
    background: #fecaca;
    color: #991b1b;
}

@media (max-width: 420px) {
    .auditoria-actions .action-btn.secondary .action-btn-label { display: none; }
    .auditoria-actions .action-btn { padding: 0 10px; }
}

/* ── Header ───────────────────────────────────────────────── */
.auditoria-header {
    padding: 16px 16px 12px;
    background: linear-gradient(180deg, #f0f5ff 0%, #eef2f8 100%);
    border-bottom: 2px solid #dde6f7;
    animation: aud-fadeUp 0.35s 0.05s cubic-bezier(0.34,1.56,0.64,1) both;
}

/* Inventory selector */
.auditoria-inventory-selector {
    display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
    margin-bottom: 12px;
    padding: 8px 12px;
    background: rgba(255,255,255,0.8);
    border-radius: 12px;
    border: 1px solid #dde6f7;
}
.inventory-name-auditoria {
    font-size: 13px; font-weight: 700; color: #1e3a8a;
}
.btn-alterar-estoque-compact-auditoria {
    display: inline-flex; align-items: center; justify-content: center;
    width: 30px; height: 30px;
    border-radius: 50%;
    background: #dbeafe; color: #1d4ed8;
    border: none; cursor: pointer; font-size: 12px;
    -webkit-tap-highlight-color: transparent;
    transition: background 0.15s;
}
.btn-alterar-estoque-compact-auditoria:active { background: #bfdbfe; }

.auditoria-btn-multiple {
    display: inline-flex; align-items: center; gap: 5px;
    padding: 6px 12px;
    border-radius: 20px;
    font-size: 12px; font-weight: 600; font-family: inherit;
    border: 1.5px solid #93c5fd;
    background: #eff6ff; color: #1d4ed8;
    cursor: pointer; -webkit-tap-highlight-color: transparent;
    transition: background 0.15s;
}
.auditoria-btn-multiple:active { background: #dbeafe; }

/* Multi-estoque panel */
.auditoria-multi-panel {
    background: #fff;
    border-radius: 14px;
    padding: 12px; margin-bottom: 12px;
    border: 1.5px solid #93c5fd;
    box-shadow: 0 2px 8px rgba(30,58,138,0.08);
    display: none;
    animation: aud-fadeUp 0.2s ease both;
}
.auditoria-multi-panel h4 {
    font-size: 11px; font-weight: 700; color: #1d4ed8;
    margin: 0 0 8px; text-transform: uppercase; letter-spacing: 0.05em;
}
.auditoria-multi-checkboxes { display: flex; flex-direction: column; gap: 6px; }

/* Title row */
.auditoria-title {
    font-size: 18px; font-weight: 900; color: #0f172a;
    margin-bottom: 12px; line-height: 1.2;
    display: flex; align-items: center; gap: 8px;
}
.auditoria-title::before {
    content: '';
    display: inline-block;
    width: 4px; height: 20px;
    background: linear-gradient(180deg, #1d4ed8, #7c3aed);
    border-radius: 2px;
    flex-shrink: 0;
}

/* ── Stats Grid ───────────────────────────────────────────── */
.auditoria-stats-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 8px;
    margin-bottom: 8px;
}

.auditoria-stat-card {
    border-radius: 14px;
    padding: 12px 8px 10px;
    text-align: center;
    position: relative;
    overflow: hidden;
    transition: transform 0.18s cubic-bezier(0.34,1.56,0.64,1),
                box-shadow 0.18s ease;
    cursor: default;
}
.auditoria-stat-card:active { transform: scale(0.96); }

/* Staggered entrance animation */
.auditoria-stats-grid .auditoria-stat-card:nth-child(1) { animation: aud-fadeUp 0.3s 0.08s ease both; }
.auditoria-stats-grid .auditoria-stat-card:nth-child(2) { animation: aud-fadeUp 0.3s 0.12s ease both; }
.auditoria-stats-grid .auditoria-stat-card:nth-child(3) { animation: aud-fadeUp 0.3s 0.16s ease both; }
.auditoria-stats-grid .auditoria-stat-card:nth-child(4) { animation: aud-fadeUp 0.3s 0.20s ease both; }
.auditoria-stats-grid .auditoria-stat-card:nth-child(5) { animation: aud-fadeUp 0.3s 0.24s ease both; }
.auditoria-stats-grid .auditoria-stat-card:nth-child(6) { animation: aud-fadeUp 0.3s 0.28s ease both; }

/* Decorative circle in top-right corner */
.auditoria-stat-card::after {
    content: '';
    position: absolute; top: -10px; right: -10px;
    width: 44px; height: 44px;
    border-radius: 50%;
    opacity: 0.18;
}

/* Each card has its own palette */
/* Total — Blue */
.auditoria-stat-card:nth-child(1) {
    background: linear-gradient(135deg, #dbeafe 0%, #eff6ff 100%);
    border: 1px solid #93c5fd;
    box-shadow: 0 2px 8px rgba(30,58,138,0.1);
}
.auditoria-stat-card:nth-child(1) .auditoria-stat-card__value { color: #1e3a8a; }
.auditoria-stat-card:nth-child(1)::after { background: #1d4ed8; }

/* Contados — Teal */
.auditoria-stat-card:nth-child(2) {
    background: linear-gradient(135deg, #ccfbf1 0%, #f0fdf4 100%);
    border: 1px solid #5eead4;
    box-shadow: 0 2px 8px rgba(13,148,136,0.1);
}
.auditoria-stat-card:nth-child(2) .auditoria-stat-card__value { color: #0f766e; }
.auditoria-stat-card:nth-child(2)::after { background: #0d9488; }

/* Não Contados — Slate */
.auditoria-stat-card:nth-child(3) {
    background: linear-gradient(135deg, #f1f5f9 0%, #f8fafc 100%);
    border: 1px solid #cbd5e1;
    box-shadow: 0 2px 8px rgba(71,85,105,0.08);
}
.auditoria-stat-card:nth-child(3) .auditoria-stat-card__value { color: #334155; }
.auditoria-stat-card:nth-child(3)::after { background: #64748b; }

/* Corretos — Green */
.auditoria-stat-card:nth-child(4) {
    background: linear-gradient(135deg, #d1fae5 0%, #f0fdf4 100%);
    border: 1px solid #6ee7b7;
    box-shadow: 0 2px 8px rgba(5,150,105,0.1);
}
.auditoria-stat-card:nth-child(4) .auditoria-stat-card__value { color: #065f46; }
.auditoria-stat-card:nth-child(4)::after { background: #059669; }

/* Incorretos — Amber */
.auditoria-stat-card:nth-child(5) {
    background: linear-gradient(135deg, #fef3c7 0%, #fffbeb 100%);
    border: 1px solid #fcd34d;
    box-shadow: 0 2px 8px rgba(217,119,6,0.1);
}
.auditoria-stat-card:nth-child(5) .auditoria-stat-card__value { color: #92400e; }
.auditoria-stat-card:nth-child(5)::after { background: #d97706; }

/* Corrigidos — Purple */
.auditoria-stat-card:nth-child(6) {
    background: linear-gradient(135deg, #ede9fe 0%, #f5f3ff 100%);
    border: 1px solid #c4b5fd;
    box-shadow: 0 2px 8px rgba(124,58,237,0.1);
}
.auditoria-stat-card:nth-child(6) .auditoria-stat-card__value { color: #5b21b6; }
.auditoria-stat-card:nth-child(6)::after { background: #7c3aed; }

.auditoria-stat-card__value {
    font-size: 22px; font-weight: 900;
    font-family: 'JetBrains Mono', monospace;
    line-height: 1.1;
    transition: transform 0.2s cubic-bezier(0.34,1.56,0.64,1);
}
/* Trigger animation class added by JS when value changes */
.auditoria-stat-card__value.updated {
    animation: aud-statPop 0.3s cubic-bezier(0.34,1.56,0.64,1);
}
.auditoria-stat-card__label {
    font-size: 9px; font-weight: 700;
    color: currentColor; opacity: 0.65;
    margin-top: 3px;
    text-transform: uppercase; letter-spacing: 0.06em; line-height: 1.2;
}

/* Corrigidos sub-grid */
.auditoria-stat-card--corrigidos-total .auditoria-stat-card__value { color: #065f46; }
.auditoria-stat-card--corrigidos-bad   .auditoria-stat-card__value { color: #92400e; }

/* Percentual row */
.auditoria-pct-row {
    text-align: right; font-size: 11px; font-weight: 600;
    color: #92400e;
    padding-bottom: 2px;
    opacity: 0.8;
}
.auditoria-pct-row #percentualIncorretos { font-weight: 800; }

/* ── Tabs ─────────────────────────────────────────────────── */
.auditoria-tabs-wrapper {
    position: relative;
    background: #fff;
    border-bottom: 2px solid #e2e8f0;
    box-shadow: 0 2px 8px rgba(15,23,42,0.06);
    display: flex; align-items: stretch;
}

/* Scroll arrows */
.auditoria-tabs-arrow {
    flex-shrink: 0;
    width: 36px;
    border: none; background: transparent;
    color: #94a3b8;
    cursor: pointer;
    display: flex; align-items: center; justify-content: center;
    font-size: 13px;
    -webkit-tap-highlight-color: transparent;
    transition: color 0.15s, background 0.15s, opacity 0.2s;
    opacity: 0;
    pointer-events: none;
    position: relative; z-index: 2;
}
.auditoria-tabs-arrow.visible {
    opacity: 1;
    pointer-events: auto;
}
.auditoria-tabs-arrow:active { background: #f1f5f9; color: #1e3a8a; }

/* Left arrow gets a subtle right-side fade */
.auditoria-tabs-arrow--left::after {
    content: '';
    position: absolute; top: 0; right: -12px; bottom: 0; width: 12px;
    background: linear-gradient(to right, #fff, transparent);
    pointer-events: none;
}
/* Right arrow gets a subtle left-side fade */
.auditoria-tabs-arrow--right::before {
    content: '';
    position: absolute; top: 0; left: -12px; bottom: 0; width: 12px;
    background: linear-gradient(to left, #fff, transparent);
    pointer-events: none;
}

.auditoria-tabs-bar {
    flex: 1; min-width: 0;
    display: flex; gap: 2px;
    padding: 0 4px;
    overflow-x: auto; -webkit-overflow-scrolling: touch; scrollbar-width: none;
    background: transparent;
}
.auditoria-tabs-bar::-webkit-scrollbar { display: none; }

.auditoria-tab-btn {
    display: inline-flex; align-items: center; gap: 6px;
    flex-shrink: 0; padding: 12px 16px;
    font-size: 12px; font-weight: 700; font-family: inherit;
    border: none; background: transparent;
    color: #94a3b8;
    cursor: pointer; white-space: nowrap;
    -webkit-tap-highlight-color: transparent;
    transition: color 0.18s, background 0.18s;
    position: relative; bottom: -2px;
    border-bottom: 2.5px solid transparent;
    border-radius: 8px 8px 0 0;
}
.auditoria-tab-btn i {
    font-size: 13px;
    transition: transform 0.2s cubic-bezier(0.34,1.56,0.64,1);
}
.auditoria-tab-btn:hover { color: #64748b; background: #f8fafc; }
.auditoria-tab-btn:active i { transform: scale(1.3); }

/* Per-tab accent colors */
.auditoria-tab-btn[data-tab="geral"].active    { color: #1e3a8a; border-bottom-color: #1e3a8a; background: #eff6ff; }
.auditoria-tab-btn[data-tab="contados"].active { color: #0f766e; border-bottom-color: #0d9488; background: #f0fdf4; }
.auditoria-tab-btn[data-tab="errados"].active  { color: #92400e; border-bottom-color: #d97706; background: #fffbeb; }
.auditoria-tab-btn[data-tab="criticos"].active { color: #991b1b; border-bottom-color: #dc2626; background: #fff5f5; }
.auditoria-tab-btn[data-tab="corrigidos"].active { color: #5b21b6; border-bottom-color: #7c3aed; background: #f5f3ff; }

/* Inactive icon colors */
.auditoria-tab-btn[data-tab="geral"] i    { color: #93c5fd; }
.auditoria-tab-btn[data-tab="contados"] i { color: #5eead4; }
.auditoria-tab-btn[data-tab="errados"] i  { color: #fcd34d; }
.auditoria-tab-btn[data-tab="criticos"] i { color: #fca5a5; }
.auditoria-tab-btn[data-tab="corrigidos"] i { color: #c4b5fd; }

.auditoria-tab-btn.active i { color: currentColor; }

@media (max-width: 380px) {
    .auditoria-tab-btn i { display: none; }
    .auditoria-tab-btn { padding: 10px 10px; font-size: 11px; }
}

/* Tab section content — animate on show */
.auditoria-content {
    animation: aud-tabContentIn 0.22s ease both;
}

/* ── Mobile Toolbar ───────────────────────────────────────── */
.auditoria-mobile-toolbar {
    display: flex; flex-direction: column; gap: 8px;
    padding: 10px 16px 12px;
    background: #f8fafc;
    border-bottom: 1px solid #e2e8f0;
}
.auditoria-mobile-toolbar__row {
    display: flex; align-items: flex-end; gap: 8px;
}
.auditoria-mobile-toolbar__row--search {
    flex-direction: column; align-items: stretch; gap: 4px;
}
.auditoria-mobile-toolbar__label {
    font-size: 10px; font-weight: 700;
    color: #64748b;
    text-transform: uppercase; letter-spacing: 0.07em;
}
.auditoria-mobile-toolbar__input,
.auditoria-mobile-toolbar__select {
    width: 100%; padding: 10px 14px;
    border-radius: 12px;
    border: 1.5px solid #cbd5e1;
    font-size: 14px; font-family: inherit;
    background: #fff; color: #1e293b;
    box-sizing: border-box; outline: none;
    -webkit-appearance: none; appearance: none;
    transition: border-color 0.15s, box-shadow 0.15s;
}
.auditoria-mobile-toolbar__input:focus,
.auditoria-mobile-toolbar__select:focus {
    border-color: #3b82f6;
    box-shadow: 0 0 0 3px rgba(59,130,246,0.15);
}
.auditoria-mobile-toolbar__field {
    flex: 1; display: flex; flex-direction: column; gap: 4px;
}
.auditoria-mobile-toolbar__dir-btn {
    display: inline-flex; flex-direction: column;
    align-items: center; justify-content: center; gap: 2px;
    min-width: 52px; height: 44px;
    border-radius: 12px;
    border: 1.5px solid #cbd5e1;
    background: #fff; color: #475569;
    font-family: inherit; cursor: pointer;
    -webkit-tap-highlight-color: transparent;
    transition: background 0.15s, border-color 0.15s;
    align-self: flex-end;
}
.auditoria-mobile-toolbar__dir-btn:disabled { opacity: 0.35; cursor: default; }
.auditoria-mobile-toolbar__dir-btn:not(:disabled):hover { border-color: #3b82f6; color: #1e3a8a; }
.auditoria-mobile-toolbar__dir-btn:not(:disabled):active { background: #eff6ff; }
.auditoria-mobile-toolbar__dir-text { font-size: 10px; font-weight: 700; letter-spacing: 0.03em; }

/* ── Table Section ────────────────────────────────────────── */
.auditoria-section { padding: 12px 12px 80px; }

.actions-bar {
    display: flex; justify-content: flex-end;
    padding-bottom: 10px;
}
.export-btn {
    display: inline-flex; align-items: center; gap: 6px;
    padding: 7px 16px;
    border-radius: 20px;
    font-size: 12px; font-weight: 700; font-family: inherit;
    border: 1.5px solid #e2e8f0;
    background: #fff; color: #64748b;
    cursor: pointer; -webkit-tap-highlight-color: transparent;
    transition: background 0.15s, border-color 0.15s, color 0.15s, box-shadow 0.15s;
    box-shadow: 0 1px 3px rgba(15,23,42,0.06);
}
.export-btn:hover { background: #fff5f5; border-color: #fca5a5; color: #dc2626; box-shadow: 0 2px 8px rgba(220,38,38,0.12); }
.export-btn:active { transform: scale(0.97); }

/* ─── Desktop Table ─────────────────────────────────────── */
.table-container {
    overflow-x: auto; -webkit-overflow-scrolling: touch;
    border-radius: 16px;
    background: #fff;
    box-shadow: 0 2px 12px rgba(15,23,42,0.08);
    border: 1px solid #e2e8f0;
}
.auditoria-table {
    width: 100%; border-collapse: collapse;
    font-size: 13px; min-width: 480px;
}
.auditoria-table thead tr {
    background: linear-gradient(90deg, #f8fafc 0%, #f1f5f9 100%);
}
.auditoria-table thead th {
    padding: 12px 14px;
    font-size: 10px; font-weight: 800;
    text-transform: uppercase; letter-spacing: 0.08em;
    color: #64748b;
    border-bottom: 2px solid #e2e8f0;
    text-align: left;
    white-space: nowrap; cursor: pointer; user-select: none;
    transition: color 0.15s;
}
.auditoria-table thead th:hover { color: #1e3a8a; }
.auditoria-table thead th.aud-col-num { text-align: right; }

.auditoria-table tbody tr {
    border-bottom: 1px solid #f1f5f9;
    transition: background 0.14s;
    border-left: 4px solid transparent;
}
.auditoria-table tbody tr:last-child { border-bottom: none; }

/* Status-tinted hover backgrounds */
.auditoria-table tbody tr[data-status="correto"]:hover             { background: rgba(5,150,105,0.04); }
.auditoria-table tbody tr[data-status="errado"]:hover              { background: rgba(217,119,6,0.04); }
.auditoria-table tbody tr[data-status="critico"]:hover             { background: rgba(220,38,38,0.04); }
.auditoria-table tbody tr[data-status="nao-contado"]:hover         { background: #f8fafc; }
.auditoria-table tbody tr[data-status="corrigido"]:hover           { background: rgba(5,150,105,0.04); }
.auditoria-table tbody tr[data-status="corrigido-incorreto"]:hover { background: rgba(217,119,6,0.04); }
.auditoria-table tbody tr[data-status="corrigido-critico"]:hover   { background: rgba(220,38,38,0.04); }

/* Thick left border by status */
.auditoria-table tbody tr[data-status="correto"]             { border-left-color: #059669; }
.auditoria-table tbody tr[data-status="errado"]              { border-left-color: #d97706; }
.auditoria-table tbody tr[data-status="critico"]             { border-left-color: #dc2626; }
.auditoria-table tbody tr[data-status="nao-contado"]         { border-left-color: #cbd5e1; }
.auditoria-table tbody tr[data-status="corrigido"]           { border-left-color: #059669; }
.auditoria-table tbody tr[data-status="corrigido-incorreto"] { border-left-color: #d97706; }
.auditoria-table tbody tr[data-status="corrigido-critico"]   { border-left-color: #dc2626; }

.auditoria-table td {
    padding: 11px 14px;
    vertical-align: middle;
    color: #475569;
}
.auditoria-table td:first-child { font-weight: 600; color: #1e293b; }
.auditoria-table td.aud-col-num {
    text-align: right;
    font-family: 'JetBrains Mono', monospace;
    font-weight: 700; font-size: 13px;
}

/* No-data — .no-data is on the <td> itself */
.auditoria-table td.no-data {
    text-align: center; padding: 56px 16px;
    color: #94a3b8; font-size: 14px;
}
.auditoria-table td.no-data i {
    display: block; font-size: 2.5rem;
    margin-bottom: 10px; opacity: 0.5;
}

/* Sortable headers indicator */
.sortable-header { user-select: none; }
.sortable-header.sort-asc::after  { content: ' ↑'; font-size: 10px; color: #1e3a8a; }
.sortable-header.sort-desc::after { content: ' ↓'; font-size: 10px; color: #1e3a8a; }

/* ─── Mobile: table rows → cards ───────────────────────────
   ┌────────────────────────────────────────┐
   │  Nome do Produto      [STATUS BADGE]   │
   ├────────────────────────────────────────┤
   │  FÍSICO     SISTEMA       DIF.         │
   │    10          8          +2           │
   └────────────────────────────────────────┘
   ─────────────────────────────────────── */
@media (max-width: 680px) {
    .table-container {
        background: transparent; box-shadow: none;
        border-radius: 0; overflow: visible; border: none;
    }
    .auditoria-table { min-width: 0; }
    .auditoria-table thead { display: none; }

    .auditoria-table,
    .auditoria-table tbody { display: block; }
    .auditoria-table tbody { display: flex; flex-direction: column; gap: 10px; }

    /* Card */
    .auditoria-table tbody tr {
        display: block; position: relative;
        background: #fff;
        border-radius: 16px;
        padding: 13px 13px 11px;
        box-shadow: 0 2px 10px rgba(15,23,42,0.08);
        border: none;
        border-left: 4px solid #e2e8f0;
        animation: aud-cardIn 0.25s ease both;
        transition: transform 0.15s, box-shadow 0.15s;
    }
    .auditoria-table tbody tr:active {
        transform: scale(0.985);
        box-shadow: 0 1px 4px rgba(15,23,42,0.06);
    }

    /* Stagger card entries */
    .auditoria-table tbody tr:nth-child(1)  { animation-delay: 0.03s; }
    .auditoria-table tbody tr:nth-child(2)  { animation-delay: 0.06s; }
    .auditoria-table tbody tr:nth-child(3)  { animation-delay: 0.09s; }
    .auditoria-table tbody tr:nth-child(4)  { animation-delay: 0.12s; }
    .auditoria-table tbody tr:nth-child(5)  { animation-delay: 0.15s; }
    .auditoria-table tbody tr:nth-child(6)  { animation-delay: 0.18s; }
    .auditoria-table tbody tr:nth-child(7)  { animation-delay: 0.20s; }
    .auditoria-table tbody tr:nth-child(8)  { animation-delay: 0.22s; }
    .auditoria-table tbody tr:nth-child(9)  { animation-delay: 0.24s; }
    .auditoria-table tbody tr:nth-child(10) { animation-delay: 0.25s; }

    /* Status colours on mobile cards */
    .auditoria-table tbody tr[data-status="correto"]             { border-left-color: #059669; }
    .auditoria-table tbody tr[data-status="errado"]              { border-left-color: #d97706; }
    .auditoria-table tbody tr[data-status="critico"]             { border-left-color: #dc2626; }
    .auditoria-table tbody tr[data-status="nao-contado"]         { border-left-color: #cbd5e1; }
    .auditoria-table tbody tr[data-status="corrigido"]           { border-left-color: #059669; }
    .auditoria-table tbody tr[data-status="corrigido-incorreto"] { border-left-color: #d97706; }
    .auditoria-table tbody tr[data-status="corrigido-critico"]   { border-left-color: #dc2626; }

    /* Very subtle tinted bg per status */
    .auditoria-table tbody tr[data-status="correto"]             { background: linear-gradient(135deg, #f0fdf4 0%, #fff 60%); }
    .auditoria-table tbody tr[data-status="errado"]              { background: linear-gradient(135deg, #fffbeb 0%, #fff 60%); }
    .auditoria-table tbody tr[data-status="critico"]             { background: linear-gradient(135deg, #fff5f5 0%, #fff 60%); }
    .auditoria-table tbody tr[data-status="corrigido"]           { background: linear-gradient(135deg, #f0fdf4 0%, #fff 60%); }
    .auditoria-table tbody tr[data-status="corrigido-incorreto"] { background: linear-gradient(135deg, #fffbeb 0%, #fff 60%); }
    .auditoria-table tbody tr[data-status="corrigido-critico"]   { background: linear-gradient(135deg, #fff5f5 0%, #fff 60%); }

    /* Reset all cells */
    .auditoria-table td { display: block; padding: 0; border: none; }

    /* td[1] = Nome */
    .auditoria-table td:nth-child(1) {
        padding-right: 108px; padding-bottom: 10px;
        font-size: 13px; font-weight: 700; color: #0f172a;
        display: -webkit-box;
        -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
        line-height: 1.4;
    }
    .auditoria-table td:nth-child(1)::before { display: none; }

    /* td[5] = Status — absolute top-right */
    .auditoria-table td:nth-child(5) {
        position: absolute; top: 13px; right: 13px; display: block;
    }
    .auditoria-table td:nth-child(5)::before { display: none; }

    /* td[2,3,4] = Numeric — side by side */
    .auditoria-table td:nth-child(2),
    .auditoria-table td:nth-child(3),
    .auditoria-table td:nth-child(4) {
        display: inline-flex !important;
        flex-direction: column; align-items: center; justify-content: flex-start;
        width: 33.333%; padding-top: 9px;
        border-top: 1px solid #f1f5f9;
        box-sizing: border-box; vertical-align: top;
        font-family: 'JetBrains Mono', monospace;
        font-size: 15px; font-weight: 800; color: #1e293b;
        text-align: center;
    }

    /* ::before labels */
    .auditoria-table td::before {
        content: attr(data-label);
        display: block;
        font-size: 9px; font-weight: 700;
        text-transform: uppercase; letter-spacing: 0.08em;
        color: #94a3b8;
        margin-bottom: 3px; white-space: nowrap;
        font-family: 'Inter', sans-serif;
    }
    .auditoria-table td:nth-child(1)::before,
    .auditoria-table td:nth-child(5)::before { display: none; }

    /* Color the difference cell based on value sign */
    .auditoria-table td:nth-child(4) { color: #64748b; }

    /* No-data — .no-data is on the <td>, row is its <tr> parent */
    .auditoria-table tbody tr:has(td.no-data) {
        background: #fff !important;
        border-radius: 16px !important;
        box-shadow: 0 2px 10px rgba(15,23,42,0.06) !important;
        border-left: none !important;
        animation: none !important;
    }
    /* Override all nth-child card styles for the no-data cell */
    .auditoria-table td.no-data,
    .auditoria-table td.no-data:nth-child(1),
    .auditoria-table td.no-data:nth-child(2),
    .auditoria-table td.no-data:nth-child(3),
    .auditoria-table td.no-data:nth-child(4),
    .auditoria-table td.no-data:nth-child(5) {
        display: block !important; position: static !important;
        width: 100% !important; box-sizing: border-box !important;
        padding: 48px 16px !important; padding-right: 16px !important;
        text-align: center !important; font-size: 14px !important;
        color: #94a3b8 !important; background: transparent !important;
        border-top: none !important; font-weight: 400 !important;
        font-family: 'Inter', sans-serif !important;
    }
    .auditoria-table td.no-data::before { display: none !important; }
}

/* ── Status Badges ────────────────────────────────────────── */
.status-badge {
    display: inline-flex; align-items: center; gap: 4px;
    padding: 4px 10px;
    border-radius: 20px;
    font-size: 11px; font-weight: 800;
    white-space: nowrap; letter-spacing: 0.02em;
    box-shadow: 0 1px 3px rgba(15,23,42,0.1);
}
.status-correto             { background: #d1fae5; color: #065f46; border: 1px solid #6ee7b7; }
.status-errado              { background: #fef3c7; color: #92400e; border: 1px solid #fcd34d; }
.status-critico             {
    background: #fee2e2; color: #991b1b; border: 1px solid #fca5a5;
    animation: aud-criticalPulse 2s ease-in-out infinite;
}
.status-nao-contado         { background: #f1f5f9; color: #475569; border: 1px solid #cbd5e1; }
.status-corrigido           { background: #d1fae5; color: #065f46; border: 1px solid #6ee7b7; }
.status-corrigido-incorreto { background: #fef3c7; color: #92400e; border: 1px solid #fcd34d; }
.status-corrigido-critico   { background: #fee2e2; color: #991b1b; border: 1px solid #fca5a5; }

/* ── Salvar Bottom Sheet ──────────────────────────────────── */
#salvarAuditoriaSheet {
    padding: 0 20px calc(24px + env(safe-area-inset-bottom, 0px));
}
#salvarAuditoriaSheet h3 {
    font-size: 17px; font-weight: 800; color: #0f172a;
    margin: 0 0 16px;
    display: flex; align-items: center; gap: 8px;
}
#salvarAuditoriaSheet h3::before {
    content: '';
    display: inline-block; width: 4px; height: 18px;
    background: linear-gradient(180deg, #1d4ed8, #7c3aed);
    border-radius: 2px;
}
#salvarAuditoriaSheet #auditoriaNome {
    width: 100%; padding: 13px 14px;
    border: 2px solid #e2e8f0;
    border-radius: 14px;
    font-size: 15px; font-family: inherit;
    background: #f8fafc; color: #1e293b;
    box-sizing: border-box; margin-bottom: 16px; outline: none;
    transition: border-color 0.2s, box-shadow 0.2s, background 0.2s;
}
#salvarAuditoriaSheet #auditoriaNome:focus {
    border-color: #3b82f6;
    box-shadow: 0 0 0 4px rgba(59,130,246,0.15);
    background: #fff;
}
.sheet-actions { display: flex; gap: 10px; }
.sheet-actions button {
    flex: 1; padding: 14px;
    border-radius: 14px;
    font-size: 14px; font-weight: 700; font-family: inherit;
    border: none; cursor: pointer;
    -webkit-tap-highlight-color: transparent;
    transition: opacity 0.15s, transform 0.12s, box-shadow 0.15s;
}
.sheet-actions button:active { opacity: 0.85; transform: scale(0.97); }
.btn-confirm {
    background: linear-gradient(135deg, #1e3a8a, #1d4ed8);
    color: #fff;
    box-shadow: 0 4px 14px rgba(30,58,138,0.35);
}
.btn-confirm:hover { box-shadow: 0 6px 20px rgba(30,58,138,0.4); }
.btn-cancel  { background: #f1f5f9; color: #64748b; }

/* ── Progress Overlay ─────────────────────────────────────── */
.buscar-estoque-overlay {
    position: fixed; inset: 0;
    background: rgba(15,23,42,0.55);
    z-index: 9999;
    display: flex; align-items: center; justify-content: center;
    backdrop-filter: blur(4px);
    animation: aud-fadeUp 0.2s ease both;
}
.buscar-estoque-progress-card {
    background: #fff;
    border-radius: 24px;
    padding: 36px 28px; text-align: center;
    box-shadow: 0 24px 64px rgba(15,23,42,0.25);
    max-width: 280px; width: 90%;
    border: 1px solid #e2e8f0;
}
.buscar-estoque-progress-card .fas.fa-spinner {
    font-size: 2.5rem; color: #7c3aed; margin-bottom: 16px;
    display: block;
}
.buscar-estoque-progress-text {
    font-size: 14px; font-weight: 600; color: #475569;
    margin: 0; line-height: 1.5;
}

/* ── Desktop enhancements ─────────────────────────────────── */
@media (min-width: 680px) {
    .auditoria-stats-grid { grid-template-columns: repeat(6, 1fr); gap: 10px; }
    .auditoria-stat-card__value { font-size: 22px; }
    .auditoria-stat-card { padding: 14px 10px 12px; }
}
@media (min-width: 768px) {
    .auditoria-header   { padding: 18px 24px 14px; }
    .auditoria-tabs-bar { padding: 0 24px; }
    .auditoria-mobile-toolbar {
        padding: 10px 24px 12px;
        flex-direction: row; align-items: flex-end;
    }
    .auditoria-mobile-toolbar__row--search { flex: 1; }
    .auditoria-mobile-toolbar__row--controls { flex-shrink: 0; }
    .auditoria-section  { padding: 16px 24px 40px; }
    .auditoria-actions  { padding-left: 20px; padding-right: 20px; }
    .auditoria-title    { font-size: 20px; }
}
@media (min-width: 1024px) {
    .auditoria-section  { max-width: 1100px; margin: 0 auto; }
}

/* Inventory chip on auditoria uses the same .inventory-name-display style
   defined in styles.css (light-blue chip, dark text) — no override needed. */

/* ── Histórico de Auditorias (modal) ──────────────────────────────────────
   styles.css turns every .modal into a bottom-sheet on mobile. For the
   history modal we want a centered floating card instead, with each saved
   audit shown as its own card. ───────────────────────────────────────────── */
@media (max-width: 768px) {
    #auditoriasAnterioresModal {
        align-items: center;
        padding: 16px;
        overflow: hidden;
        overscroll-behavior: contain;
    }
    #auditoriasAnterioresModal .modal-content,
    #auditoriasAnterioresModal .modal-content.large-modal {
        width: 100%;
        max-width: 480px;
        max-height: 82dvh;
        border-radius: 20px;           /* full rounded = floating card */
        box-shadow: 0 24px 64px rgba(15, 23, 42, 0.3);
    }
}

/* History modal scrolls inside its list, not in the page behind it. */
#auditoriasAnterioresModal.active {
    overflow: hidden;
    overscroll-behavior: contain;
}

#auditoriasAnterioresModal .modal-content.large-modal {
    height: min(720px, calc(100dvh - 32px));
    max-height: calc(100dvh - 32px);
}

#auditoriasAnterioresModal .auditorias-list {
    flex: 1 1 auto;
    min-height: 0;
    overflow-y: auto;
    overscroll-behavior: contain;
    touch-action: pan-y;
    -webkit-overflow-scrolling: touch;
}

/* List of saved audits */
#auditoriasList,
.auditorias-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
    padding: 4px 2px;
}

/* Each saved audit = a card */
.auditoria-item {
    background: #fff;
    border: 1px solid #e2e8f0;
    border-left: 4px solid #1d4ed8;
    border-radius: 14px;
    padding: 14px 16px;
    box-shadow: 0 2px 8px rgba(15, 23, 42, 0.06);
    cursor: pointer;
    transition: transform 0.15s ease, box-shadow 0.15s ease, border-color 0.15s ease;
    -webkit-tap-highlight-color: transparent;
}
.auditoria-item:hover {
    box-shadow: 0 6px 18px rgba(15, 23, 42, 0.12);
    transform: translateY(-1px);
    border-color: #cbd5e1;
}
.auditoria-item:active { transform: scale(0.99); }

.auditoria-item h4 {
    margin: 0 0 8px;
    font-size: 15px;
    font-weight: 800;
    color: #0f172a;
    line-height: 1.3;
}
.auditoria-item p {
    margin: 4px 0;
    font-size: 12px;
    color: #64748b;
    line-height: 1.45;
}
.auditoria-item p i { color: #94a3b8; margin-right: 2px; }

/* Contagem label as a small pill */
.auditoria-item-contagem {
    display: inline-block;
}
.auditoria-item-contagem strong {
    display: inline-block;
    background: #eff6ff;
    color: #1d4ed8;
    font-size: 11px;
    font-weight: 800;
    padding: 3px 10px;
    border-radius: 20px;
    letter-spacing: 0.02em;
}

/* Finalized audits = green accent */
.auditoria-item-finalizada {
    border-left-color: #059669;
    background: linear-gradient(135deg, #f0fdf4 0%, #fff 60%);
}
.auditoria-item-finalizada .auditoria-item-contagem strong {
    background: #d1fae5;
    color: #065f46;
}

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