/* ==========================================================================
   PC Tracking — tema do painel (sobre Bootstrap 5.3.8 vendorizado)
   Sem fontes ou ícones externos: o painel roda em rede interna.
   Claro/escuro via data-bs-theme (ver assets/js/theme.js).
   ========================================================================== */

:root {
    --pct-brand: #4f46e5;
    --pct-brand-rgb: 79, 70, 229;
    --pct-brand-hover: #4338ca;
    --pct-brand-active: #3730a3;
    --pct-radius: 14px;
    --pct-radius-sm: 10px;

    --pct-bg: #f3f5fa;
    --pct-surface: #ffffff;
    --pct-surface-2: #f8f9fd;
    --pct-border: #e5e8f1;
    --pct-muted: #64748b;
    --pct-shadow: 0 1px 2px rgba(16, 24, 40, .04), 0 6px 20px rgba(16, 24, 40, .06);

    --pct-sidebar-bg: #0f172a;
    --pct-sidebar-fg: #94a3b8;
    --pct-sidebar-heading: #64748b;

    --bs-font-sans-serif: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, "Noto Sans", sans-serif;
    --bs-body-font-size: .92rem;
    --bs-primary: var(--pct-brand);
    --bs-primary-rgb: var(--pct-brand-rgb);
    --bs-link-color: var(--pct-brand);
    --bs-link-color-rgb: var(--pct-brand-rgb);
    --bs-link-hover-color: var(--pct-brand-hover);
    --bs-body-bg: var(--pct-bg);
    --bs-border-color: var(--pct-border);
    --bs-border-radius: var(--pct-radius-sm);
    --bs-border-radius-lg: var(--pct-radius);
}

[data-bs-theme="dark"] {
    --pct-brand: #818cf8;
    --pct-brand-rgb: 129, 140, 248;
    --pct-brand-hover: #a5b4fc;
    --pct-brand-active: #c7d2fe;

    --pct-bg: #0b1020;
    --pct-surface: #131a2b;
    --pct-surface-2: #182036;
    --pct-border: #232c44;
    --pct-muted: #94a3b8;
    --pct-shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 8px 24px rgba(0, 0, 0, .28);

    --pct-sidebar-bg: #0a0f1e;

    --bs-body-bg: var(--pct-bg);
    --bs-body-bg-rgb: 11, 16, 32;
    --bs-body-color: #dfe4f1;
    --bs-secondary-bg: var(--pct-surface-2);
    --bs-tertiary-bg: var(--pct-surface-2);
}

body {
    background: var(--pct-bg);
    -webkit-font-smoothing: antialiased;
}

.icon { flex-shrink: 0; vertical-align: -.2em; }

/* Utilitários como .d-flex usam !important e, sem isto, vencem o atributo hidden. */
[hidden] { display: none !important; }

/* --- Estrutura: barra lateral + conteúdo --------------------------------- */

.app-shell { display: flex; min-height: 100vh; }
.app-main { flex: 1 1 auto; min-width: 0; display: flex; flex-direction: column; }
.sidebar-col { flex: 0 0 auto; width: 0; }

@media (min-width: 992px) {
    .sidebar-col { width: 264px; position: sticky; top: 0; height: 100vh; display: flex; }
}

.sidebar { --bs-offcanvas-width: 280px; --bs-offcanvas-bg: transparent; --bs-offcanvas-border-width: 0; display: flex; flex-direction: column; }
.sidebar .offcanvas-body { padding: 0; display: flex; flex: 1 1 auto; }
.sidebar-inner {
    flex: 1 1 auto; display: flex; flex-direction: column;
    background: var(--pct-sidebar-bg); color: var(--pct-sidebar-fg);
    padding: 1.25rem 1rem; overflow-y: auto;
    border-right: 1px solid rgba(255, 255, 255, .04);
}

.brand { display: flex; align-items: center; gap: .75rem; color: #fff; text-decoration: none; }
.brand:hover { color: #fff; }
.brand-mark {
    width: 38px; height: 38px; border-radius: 11px; display: grid; place-items: center; color: #fff;
    background: linear-gradient(135deg, #6366f1, #8b5cf6);
    box-shadow: 0 6px 16px rgba(99, 102, 241, .4);
}
.brand-text { display: flex; flex-direction: column; font-weight: 700; letter-spacing: -.01em; line-height: 1.15; font-size: 1rem; }
.brand-text small { font-weight: 400; font-size: .7rem; color: var(--pct-sidebar-fg); letter-spacing: 0; }

.side-nav { display: flex; flex-direction: column; gap: 2px; margin-top: .5rem; }
.side-heading {
    font-size: .66rem; font-weight: 600; letter-spacing: .09em; text-transform: uppercase;
    color: var(--pct-sidebar-heading); padding: 1rem .75rem .35rem;
}
.side-link {
    display: flex; align-items: center; gap: .7rem; padding: .55rem .75rem; border-radius: var(--pct-radius-sm);
    color: var(--pct-sidebar-fg); text-decoration: none; font-weight: 500; font-size: .9rem;
    transition: background-color .15s, color .15s;
}
.side-link:hover { background: rgba(255, 255, 255, .06); color: #e2e8f0; }
.side-link.active { background: rgba(129, 140, 248, .18); color: #fff; box-shadow: inset 3px 0 0 #818cf8; }
.side-link.active .icon { color: #a5b4fc; }
.side-link:focus-visible { outline: 2px solid #818cf8; outline-offset: 1px; }
.sidebar-footer { margin-top: auto; padding: 1rem .75rem 0; font-size: .75rem; color: var(--pct-sidebar-heading); }

.badge-count {
    margin-left: auto; min-width: 1.35rem; padding: .05rem .4rem; border-radius: 999px; text-align: center;
    background: #ef4444; color: #fff; font-size: .7rem; font-weight: 700; line-height: 1.35;
}
.badge-count[hidden] { display: none; }

.topbar {
    position: sticky; top: 0; z-index: 1020; display: flex; align-items: center; gap: .75rem;
    padding: .7rem 1.5rem; min-height: 60px;
    background: var(--pct-bg);
    background: color-mix(in srgb, var(--pct-bg) 82%, transparent);
    -webkit-backdrop-filter: blur(10px); backdrop-filter: blur(10px);
    border-bottom: 1px solid var(--pct-border);
}
.topbar-title { font-weight: 650; font-size: 1.02rem; letter-spacing: -.01em; }
.btn-icon {
    width: 38px; height: 38px; padding: 0; display: inline-grid; place-items: center;
    background: transparent; border: 1px solid transparent; color: var(--bs-body-color); border-radius: var(--pct-radius-sm);
}
.btn-icon:hover { background: var(--pct-surface); border-color: var(--pct-border); }
.user-chip { display: flex; align-items: center; gap: .6rem; padding: .2rem .65rem .2rem .25rem; border-radius: 999px; background: var(--pct-surface); border: 1px solid var(--pct-border); }
.avatar {
    width: 30px; height: 30px; border-radius: 50%; display: grid; place-items: center;
    font-size: .72rem; font-weight: 700; color: #fff; background: linear-gradient(135deg, #6366f1, #a855f7);
}
.user-name { font-weight: 600; font-size: .82rem; }
.user-role { font-size: .68rem; letter-spacing: .05em; color: var(--pct-muted); }

[data-bs-theme="light"] .theme-icon-light { display: none; }
[data-bs-theme="dark"] .theme-icon-dark { display: none; }

.content-banner:has(.alert:not([hidden])) { padding: 1rem 1.5rem 0; }

/* Conteúdo das páginas: as views usam <main class="container..."> */
.app-main > main { width: 100%; max-width: 1480px; margin: 0 auto; padding: 1.5rem 1.5rem 3rem; }
.app-main > main.container,
.app-main > main.container-fluid { --bs-gutter-x: 0; }

.page-header { display: flex; flex-wrap: wrap; align-items: flex-start; justify-content: space-between; gap: 1rem; margin-bottom: 1.5rem; }
.page-header h1, main > h1.h4 { font-size: 1.45rem; font-weight: 700; letter-spacing: -.02em; margin: 0; }
main > h1.h4 { margin-bottom: 1.25rem; }
.page-sub { color: var(--pct-muted); margin: .25rem 0 0; }
.page-actions { display: flex; flex-wrap: wrap; gap: .5rem; }

/* --- Cartões, tabelas, formulários -------------------------------------- */

.card {
    --bs-card-bg: var(--pct-surface); --bs-card-border-color: var(--pct-border);
    --bs-card-border-radius: var(--pct-radius); --bs-card-inner-border-radius: calc(var(--pct-radius) - 1px);
    --bs-card-cap-bg: transparent;
    box-shadow: var(--pct-shadow);
}
.card-header { font-weight: 650; padding: .9rem 1.15rem; border-bottom: 1px solid var(--pct-border); }
.card > .table:last-child { margin-bottom: 0; }
.shadow-sm { box-shadow: var(--pct-shadow) !important; }
.bg-white { background-color: var(--pct-surface) !important; }

.table-responsive {
    background: var(--pct-surface); border: 1px solid var(--pct-border);
    border-radius: var(--pct-radius); box-shadow: var(--pct-shadow);
}
.table { --bs-table-bg: transparent; --bs-table-hover-bg: rgba(var(--pct-brand-rgb), .05); --bs-table-border-color: var(--pct-border); margin-bottom: 0; }
.table > :not(caption) > * > * { padding: .75rem .85rem; }
.table > thead.table-light {
    --bs-table-bg: var(--pct-surface-2); --bs-table-color: var(--pct-muted); --bs-table-border-color: var(--pct-border);
}
.table thead th {
    font-size: .7rem; font-weight: 650; letter-spacing: .06em; text-transform: uppercase; color: var(--pct-muted);
    white-space: nowrap; border-bottom-width: 1px;
}
.table tbody tr:last-child > * { border-bottom-width: 0; }
.table-sm > :not(caption) > * > * { padding: .55rem 1.15rem; }
.card .table th { font-weight: 500; color: var(--pct-muted); }

.form-control, .form-select {
    --bs-border-color: var(--pct-border); background-color: var(--pct-surface);
    border-radius: var(--pct-radius-sm); padding: .55rem .8rem;
}
.form-control-sm, .form-select-sm { padding: .3rem .6rem; }
.form-control:focus, .form-select:focus, .btn:focus-visible, .form-check-input:focus {
    border-color: var(--pct-brand); box-shadow: 0 0 0 .22rem rgba(var(--pct-brand-rgb), .18);
}
.form-check-input:checked { background-color: var(--pct-brand); border-color: var(--pct-brand); }
.form-label { font-weight: 550; font-size: .82rem; color: var(--bs-secondary-color); }

.input-icon { position: relative; }
.input-icon > .icon { position: absolute; left: .85rem; top: 50%; transform: translateY(-50%); color: var(--pct-muted); pointer-events: none; }
.input-icon > .form-control { padding-left: 2.4rem; }

/* --- Botões -------------------------------------------------------------- */

.btn { border-radius: var(--pct-radius-sm); font-weight: 550; padding: .5rem .95rem; }
.btn-sm { padding: .3rem .65rem; font-size: .8rem; }
.btn-primary {
    --bs-btn-bg: var(--pct-brand); --bs-btn-border-color: var(--pct-brand); --bs-btn-color: #fff;
    --bs-btn-hover-bg: var(--pct-brand-hover); --bs-btn-hover-border-color: var(--pct-brand-hover); --bs-btn-hover-color: #fff;
    --bs-btn-active-bg: var(--pct-brand-active); --bs-btn-active-border-color: var(--pct-brand-active); --bs-btn-active-color: #fff;
    --bs-btn-disabled-bg: var(--pct-brand); --bs-btn-disabled-border-color: var(--pct-brand);
    --bs-btn-focus-shadow-rgb: var(--pct-brand-rgb);
    box-shadow: 0 1px 2px rgba(var(--pct-brand-rgb), .3);
}
[data-bs-theme="dark"] .btn-primary { --bs-btn-color: #0b1020; --bs-btn-hover-color: #0b1020; --bs-btn-active-color: #0b1020; }
.btn-outline-primary {
    --bs-btn-color: var(--pct-brand); --bs-btn-border-color: rgba(var(--pct-brand-rgb), .45);
    --bs-btn-hover-bg: var(--pct-brand); --bs-btn-hover-border-color: var(--pct-brand); --bs-btn-hover-color: #fff;
    --bs-btn-active-bg: var(--pct-brand); --bs-btn-active-border-color: var(--pct-brand);
}
.btn-outline-secondary { --bs-btn-border-color: var(--pct-border); --bs-btn-color: var(--bs-body-color); --bs-btn-hover-bg: var(--pct-surface-2); --bs-btn-hover-color: var(--bs-body-color); --bs-btn-hover-border-color: var(--pct-muted); background: var(--pct-surface); }
.btn-link { color: var(--pct-brand); text-decoration: none; }

/* --- Etiquetas de situação ---------------------------------------------- */

.badge { border-radius: 999px; padding: .32em .72em; font-weight: 600; font-size: .72rem; letter-spacing: .01em; }
.badge::before {
    content: ""; display: inline-block; width: .42rem; height: .42rem; border-radius: 50%;
    background: currentColor; margin-right: .4em; vertical-align: .05em;
}
.badge.text-bg-success   { background: rgba(16, 185, 129, .14) !important; color: #047857 !important; }
.badge.text-bg-secondary { background: rgba(100, 116, 139, .16) !important; color: #475569 !important; }
.badge.text-bg-warning   { background: rgba(245, 158, 11, .17) !important; color: #b45309 !important; }
.badge.text-bg-danger    { background: rgba(239, 68, 68, .14) !important; color: #b91c1c !important; }
.badge.text-bg-info      { background: rgba(14, 165, 233, .15) !important; color: #0369a1 !important; }
.badge.text-bg-primary   { background: rgba(var(--pct-brand-rgb), .14) !important; color: var(--pct-brand-active) !important; }
[data-bs-theme="dark"] .badge.text-bg-success   { color: #34d399 !important; }
[data-bs-theme="dark"] .badge.text-bg-secondary { color: #cbd5e1 !important; }
[data-bs-theme="dark"] .badge.text-bg-warning   { color: #fbbf24 !important; }
[data-bs-theme="dark"] .badge.text-bg-danger    { color: #f87171 !important; }
[data-bs-theme="dark"] .badge.text-bg-info      { color: #38bdf8 !important; }

.alert { border-radius: var(--pct-radius-sm); border-width: 1px; }
.pagination { --bs-pagination-border-radius: var(--pct-radius-sm); --bs-pagination-color: var(--pct-brand); --bs-pagination-active-bg: var(--pct-brand); --bs-pagination-active-border-color: var(--pct-brand); --bs-pagination-bg: var(--pct-surface); --bs-pagination-border-color: var(--pct-border); --bs-pagination-hover-bg: var(--pct-surface-2); gap: 4px; flex-wrap: wrap; }
.pagination .page-link { border-radius: var(--pct-radius-sm); }
[data-bs-theme="dark"] .pagination { --bs-pagination-active-color: #0b1020; }
code { color: var(--pct-brand); }
details > summary { cursor: pointer; color: var(--pct-muted); }

/* --- Componentes do painel ---------------------------------------------- */

.stat-card {
    --tone: var(--pct-brand); --tone-soft: rgba(var(--pct-brand-rgb), .12);
    display: flex; align-items: center; gap: 1rem; height: 100%; padding: 1.15rem 1.25rem;
    background: var(--pct-surface); border: 1px solid var(--pct-border); border-radius: var(--pct-radius); box-shadow: var(--pct-shadow);
    text-decoration: none; color: inherit; transition: transform .15s, box-shadow .15s;
}
a.stat-card:hover { transform: translateY(-2px); color: inherit; box-shadow: 0 10px 28px rgba(16, 24, 40, .12); }
.stat-icon { width: 48px; height: 48px; border-radius: 13px; display: grid; place-items: center; background: var(--tone-soft); color: var(--tone); flex-shrink: 0; }
.stat-label { font-size: .74rem; font-weight: 600; letter-spacing: .05em; text-transform: uppercase; color: var(--pct-muted); }
.stat-value { font-size: 1.85rem; font-weight: 750; letter-spacing: -.03em; line-height: 1.1; font-variant-numeric: tabular-nums; }
.tone-success   { --tone: #10b981; --tone-soft: rgba(16, 185, 129, .14); }
.tone-secondary { --tone: #64748b; --tone-soft: rgba(100, 116, 139, .16); }
.tone-warning   { --tone: #f59e0b; --tone-soft: rgba(245, 158, 11, .16); }
.tone-danger    { --tone: #ef4444; --tone-soft: rgba(239, 68, 68, .14); }
.tone-info      { --tone: #0ea5e9; --tone-soft: rgba(14, 165, 233, .15); }

.split-bar { display: flex; height: 10px; border-radius: 999px; overflow: hidden; background: var(--pct-surface-2); border: 1px solid var(--pct-border); }
.split-bar > span { display: block; height: 100%; }
.legend { display: flex; flex-wrap: wrap; gap: .4rem 1.25rem; margin-top: .75rem; font-size: .82rem; color: var(--pct-muted); }
.legend i { display: inline-block; width: .6rem; height: .6rem; border-radius: 50%; margin-right: .4rem; }

.action-tile {
    display: flex; align-items: center; gap: .85rem; padding: .85rem 1rem; text-decoration: none; color: inherit;
    border: 1px solid var(--pct-border); border-radius: var(--pct-radius-sm); background: var(--pct-surface-2);
    transition: border-color .15s, background-color .15s;
}
.action-tile:hover { border-color: var(--pct-brand); color: inherit; background: rgba(var(--pct-brand-rgb), .06); }
.action-tile .icon-wrap { width: 36px; height: 36px; border-radius: 10px; display: grid; place-items: center; background: rgba(var(--pct-brand-rgb), .12); color: var(--pct-brand); }
.action-tile small { display: block; color: var(--pct-muted); }

.filter-card { padding: 1rem; margin-bottom: 1rem; }
.selection-bar {
    display: flex; flex-wrap: wrap; align-items: center; gap: .6rem; padding: .7rem 1rem; margin-bottom: 1rem;
    border: 1px dashed rgba(var(--pct-brand-rgb), .4); border-radius: var(--pct-radius-sm); background: rgba(var(--pct-brand-rgb), .05);
}
.selection-bar [data-selection-count] { color: var(--pct-muted); font-size: .85rem; }

.status-dot { display: inline-block; width: .55rem; height: .55rem; border-radius: 50%; margin-right: .45rem; background: #94a3b8; }
.status-dot.online { background: #10b981; box-shadow: 0 0 0 3px rgba(16, 185, 129, .2); }

.kv { display: grid; grid-template-columns: minmax(120px, 40%) 1fr; gap: .55rem 1rem; margin: 0; padding: 1rem 1.15rem; }
.kv dt { font-weight: 500; color: var(--pct-muted); }
.kv dd { margin: 0; word-break: break-word; }

.timeline { list-style: none; margin: 0; padding: 1rem 1.15rem 1rem 1.6rem; position: relative; }
.timeline::before { content: ""; position: absolute; left: 1.15rem; top: 1.4rem; bottom: 1.4rem; width: 2px; background: var(--pct-border); }
.timeline li { position: relative; padding: 0 0 1.1rem 1rem; }
.timeline li:last-child { padding-bottom: 0; }
.timeline li::before {
    content: ""; position: absolute; left: -.62rem; top: .32rem; width: .75rem; height: .75rem; border-radius: 50%;
    background: var(--pct-surface); border: 2px solid var(--pct-brand);
}

.empty-state { text-align: center; padding: 3rem 1rem; color: var(--pct-muted); }
.empty-state .icon { width: 40px; height: 40px; opacity: .5; margin-bottom: .75rem; }

.option-cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: .75rem; }
.option-cards label {
    display: flex; gap: .75rem; padding: .9rem 1rem; cursor: pointer; border: 1px solid var(--pct-border);
    border-radius: var(--pct-radius-sm); background: var(--pct-surface); transition: border-color .15s, box-shadow .15s;
}
.option-cards label:hover { border-color: var(--pct-muted); }
.option-cards input:checked + .option-body { color: var(--bs-body-color); }
.option-cards label:has(input:checked) { border-color: var(--pct-brand); box-shadow: 0 0 0 3px rgba(var(--pct-brand-rgb), .16); }
.option-body strong { display: block; }
.option-body small { color: var(--pct-muted); }

/* --- Login --------------------------------------------------------------- */

.auth-shell { min-height: 100vh; display: grid; grid-template-columns: 1fr; }
@media (min-width: 992px) { .auth-shell { grid-template-columns: 1.1fr 1fr; } }
.auth-aside {
    display: none; padding: 3rem; color: #e0e7ff; position: relative; overflow: hidden;
    background: radial-gradient(1200px 500px at 0% 0%, #4338ca 0%, transparent 60%), linear-gradient(160deg, #1e1b4b, #0f172a);
}
@media (min-width: 992px) { .auth-aside { display: flex; flex-direction: column; justify-content: space-between; } }
.auth-aside::after {
    content: ""; position: absolute; right: -120px; bottom: -120px; width: 380px; height: 380px; border-radius: 50%;
    background: radial-gradient(circle, rgba(129, 140, 248, .35), transparent 65%);
}
.auth-aside h2 { font-size: 2rem; font-weight: 750; letter-spacing: -.03em; color: #fff; max-width: 16ch; }
.auth-aside ul { list-style: none; padding: 0; margin: 1.5rem 0 0; display: grid; gap: .8rem; position: relative; z-index: 1; }
.auth-aside li { display: flex; gap: .7rem; align-items: center; color: #c7d2fe; }
.auth-main { display: grid; place-items: center; padding: 2rem 1.25rem; }
.auth-card { width: 100%; max-width: 400px; }
.auth-card .brand-mark { width: 44px; height: 44px; }

.error-shell { min-height: 100vh; display: grid; place-items: center; padding: 2rem; text-align: center; }
.error-code { font-size: clamp(4rem, 12vw, 7rem); font-weight: 800; letter-spacing: -.05em; line-height: 1;
    background: linear-gradient(135deg, #6366f1, #a855f7); -webkit-background-clip: text; background-clip: text; color: transparent; }

@media (max-width: 575.98px) {
    .app-main > main { padding: 1rem 1rem 2.5rem; }
    .topbar { padding: .6rem 1rem; }
    .table > :not(caption) > * > * { padding: .65rem .75rem; }
    .kv { grid-template-columns: 1fr; gap: .1rem; }
    .kv dd { margin-bottom: .6rem; }
}

@media (prefers-reduced-motion: reduce) {
    * { transition: none !important; }
}

/* --- Divergências --------------------------------------------------------- */

.rule-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: .6rem; }
.rule-chip {
    --tone: var(--pct-brand);
    display: flex; align-items: center; gap: .75rem; padding: .65rem .85rem; text-decoration: none; color: inherit;
    background: var(--pct-surface); border: 1px solid var(--pct-border); border-radius: var(--pct-radius-sm);
    transition: border-color .15s, box-shadow .15s;
}
.rule-chip:hover { color: inherit; border-color: var(--tone); }
.rule-chip.active { border-color: var(--tone); box-shadow: 0 0 0 3px color-mix(in srgb, var(--tone) 18%, transparent); }
.rule-chip.sev-high { --tone: #ef4444; }
.rule-chip.sev-medium { --tone: #f59e0b; }
.rule-chip.is-empty { opacity: .55; }
.rule-count {
    min-width: 2.1rem; height: 2.1rem; display: grid; place-items: center; flex-shrink: 0;
    border-radius: 10px; font-weight: 750; font-variant-numeric: tabular-nums;
    background: color-mix(in srgb, var(--tone) 14%, transparent); color: var(--tone);
}
.rule-name { font-size: .82rem; font-weight: 550; line-height: 1.25; }

.divergence { border-left: 4px solid var(--pct-border); overflow: hidden; }
.divergence.sev-high { border-left-color: #ef4444; }
.divergence.sev-medium { border-left-color: #f59e0b; }
.divergence-head { padding: .85rem 1.15rem; border-bottom: 1px solid var(--pct-border); }
.divergence-key { font-size: .85rem; padding: .1rem .5rem; border-radius: 6px; background: var(--pct-surface-2); }
.divergence-foot { padding: .65rem 1.15rem; border-top: 1px solid var(--pct-border); background: var(--pct-surface-2); color: var(--pct-muted); font-size: .82rem; }
.divergence .table-responsive { background: transparent; }
.divergence .table > :not(caption) > * > * { padding: .5rem .6rem; }
.divergence .table thead th { letter-spacing: .03em; }

/* --- Tokens de instalação -------------------------------------------------- */

.token-reveal { border-color: #10b981; box-shadow: 0 0 0 3px rgba(16, 185, 129, .14), var(--pct-shadow); }
.token-reveal textarea { resize: none; }

/* --- Datatable: cartão com barra de título, filtros, tabela zebrada e rodapé ------ */
/* Formato do exemplo "Order Details Table with Search Filter" (Tutorial Republic). */

:root {
    --dt-title-bg: #4b5366; --dt-title-fg: #fff;
    --dt-line: #e9e9e9; --dt-stripe: #fcfcfc; --dt-hover: #f5f5f5; --dt-field: #ddd;
}
[data-bs-theme="dark"] {
    --dt-title-bg: #2a3142;
    --dt-line: var(--pct-border); --dt-stripe: rgba(255, 255, 255, .025); --dt-hover: rgba(255, 255, 255, .06); --dt-field: var(--pct-border);
}

.table-card { background: var(--pct-surface); border-radius: 4px; box-shadow: 0 1px 1px rgba(0, 0, 0, .05), 0 1px 3px rgba(16, 24, 40, .07); overflow: hidden; margin-bottom: 1.5rem; }

/* Barra de título: nome da lista à esquerda, ações à direita. */
.dt-title {
    display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: .75rem 1rem;
    padding: 16px 25px; background: var(--dt-title-bg); color: var(--dt-title-fg);
}
.dt-title h2 { margin: 0; font-size: 1.4rem; font-weight: 600; letter-spacing: -.01em; color: inherit; }
.dt-title .dt-sub { margin-top: .15rem; font-size: .8rem; opacity: .75; }
.dt-actions { display: flex; flex-wrap: wrap; gap: .5rem; }
.dt-actions .btn { border: 0; border-radius: 3px; background: #fff; color: #333; font-size: .85rem; display: inline-flex; align-items: center; gap: .4rem; }
.dt-actions .btn:hover { background: #f2f2f2; color: #333; }
.dt-actions .btn-primary { background: var(--pct-brand); color: #fff; }
.dt-actions .btn-primary:hover { background: var(--pct-brand-hover); color: #fff; }
[data-bs-theme="dark"] .dt-actions .btn-primary { color: #0b1020; }

/* Linha de filtros: funil, filtros com rótulo, busca e botão de lupa. */
.dt-filter {
    display: flex; flex-wrap: wrap; align-items: center; justify-content: flex-end; gap: .6rem 1rem;
    margin: 0; padding: 12px 25px; border-bottom: 1px solid var(--dt-line);
}
.dt-filter-icon { display: inline-flex; color: var(--pct-muted); opacity: .7; }
.dt-group { display: flex; align-items: center; gap: .4rem; min-width: 0; }
.dt-group label { margin: 0; font-size: .85rem; font-weight: 400; color: var(--pct-muted); white-space: nowrap; }
.dt-filter .form-select, .dt-filter .form-control {
    height: 34px; padding-top: 0; padding-bottom: 0; border-radius: 3px; border-color: var(--dt-field); box-shadow: none; font-size: .875rem;
}
.dt-filter .form-select { width: auto; max-width: 12rem; }
.dt-filter .form-control { width: 14rem; min-width: 0; }
.dt-filter .btn-search {
    height: 34px; width: 40px; padding: 0; display: inline-grid; place-items: center; flex: 0 0 auto;
    background: var(--pct-brand); color: #fff; border: 0; border-radius: 3px;
}
.dt-filter .btn-search:hover { background: var(--pct-brand-hover); color: #fff; }
[data-bs-theme="dark"] .dt-filter .btn-search { color: #0b1020; }
.dt-clear { font-size: .85rem; white-space: nowrap; }

/* Tabela zebrada, cabeçalho simples e linhas de 12px 15px. */
.table-card .table-responsive { border: 0; border-radius: 0; box-shadow: none !important; background: transparent; }
.table-card .table { font-size: .875rem; --bs-table-bg: transparent; --bs-table-striped-bg: var(--dt-stripe); --bs-table-hover-bg: var(--dt-hover); --bs-table-border-color: var(--dt-line); margin: 0; }
.table-card .table > thead.table-light { --bs-table-bg: transparent; }
.table-card .table > :not(caption) > * > * { padding: 12px 12px; vertical-align: middle; border-color: var(--dt-line); }
.table-card .table > :not(caption) > * > *:first-child { padding-left: 25px; }
.table-card .table > :not(caption) > * > *:last-child { padding-right: 25px; }
.table-card .table thead th {
    font-size: .85rem; font-weight: 700; letter-spacing: 0; text-transform: none; color: var(--bs-body-color); background: transparent; white-space: nowrap;
}
.table-card .table > :not(caption) > *:first-child > * { border-bottom-width: 1px; }
.table-card .selection-bar {
    margin: 0; padding: .6rem 25px; border: 0; border-bottom: 1px solid var(--dt-line); border-radius: 0; background: var(--pct-surface-2);
}

/* Cabeçalhos ordenáveis. */
.th-sort { color: inherit; text-decoration: none; white-space: nowrap; display: inline-flex; align-items: center; gap: .3rem; }
.th-sort:hover { color: var(--pct-brand); }
.th-sort-arrow { font-size: .6rem; opacity: .35; }
.th-sort.active { color: var(--pct-brand); }
.th-sort.active .th-sort-arrow { opacity: 1; }
th[data-sort] { cursor: pointer; user-select: none; white-space: nowrap; }
th[data-sort]:hover { color: var(--pct-brand); }
th[data-sort] .th-sort-arrow { margin-left: .3rem; }
th[data-sort][aria-sort="ascending"], th[data-sort][aria-sort="descending"] { color: var(--pct-brand); }
th[data-sort][aria-sort="ascending"] .th-sort-arrow, th[data-sort][aria-sort="descending"] .th-sort-arrow { opacity: 1; }

/* Situação com bolinha colorida e ação circular (como no exemplo). */
.dt-status { white-space: nowrap; }
.dt-dot { display: inline-block; width: .6rem; height: .6rem; border-radius: 50%; margin-right: .45rem; vertical-align: middle; background: #94a3b8; }
.dt-dot.success { background: #10c469; } .dt-dot.info { background: #62c9e8; }
.dt-dot.warning { background: #ffc107; } .dt-dot.danger { background: #ff5b5b; } .dt-dot.secondary { background: #94a3b8; }
.dt-view { display: inline-flex; color: var(--pct-brand); text-decoration: none; border-radius: 50%; }
.dt-view:hover { color: var(--pct-brand-hover); background: rgba(var(--pct-brand-rgb), .1); }
.table-card .table td a.fw-semibold { color: inherit; }
.table-card .table td a.fw-semibold:hover { color: var(--pct-brand); }

/* Rodapé: "por página" e resumo à esquerda; paginação em texto à direita. */
.table-footer { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: .5rem 1rem; padding: 12px 25px 14px; border-top: 1px solid var(--dt-line); }
.table-footer[hidden] { display: none; }
.table-footer-start { display: flex; flex-wrap: wrap; align-items: center; gap: .5rem 1rem; }
.table-footer-pages { margin-left: auto; }
.table-summary { color: var(--pct-muted); font-size: .85rem; }
.table-perpage { display: flex; align-items: center; gap: .5rem; margin: 0; }
.table-perpage label { margin: 0; white-space: nowrap; }
.table-perpage .form-select { width: auto; min-width: 4.5rem; border-radius: 3px; border-color: var(--dt-field); }
.table-footer .pagination { margin: 0; gap: 0; }
.table-footer .page-link {
    border: 0; background: transparent; color: var(--pct-muted); font-size: .85rem; min-width: 30px; min-height: 30px; line-height: 30px;
    padding: 0 8px; margin: 0 2px; text-align: center; border-radius: 2px !important; box-shadow: none;
}
.table-footer .page-link:hover { color: var(--bs-body-color); background: var(--dt-hover); }
.table-footer .page-item.active .page-link { background: var(--pct-brand); color: #fff; }
[data-bs-theme="dark"] .table-footer .page-item.active .page-link { color: #0b1020; }
.table-footer .page-item.disabled .page-link { color: #c4c9d4; background: transparent; }
.table-empty-search td { text-align: center; color: var(--pct-muted); padding: 1.5rem; }

.table-compact > :not(caption) > * > * { padding: .6rem .6rem; }

/* Celular: cada linha vira um cartão "rótulo: valor" (os rótulos vêm dos cabeçalhos, via JS). */
@media (max-width: 767.98px) {
    .table-card .table-responsive { overflow-x: visible; }
    .table-card table.dt-stack { display: block; }
    .table-card table.dt-stack thead { display: none; }
    .table-card table.dt-stack tbody { display: block; }
    .table-card table.dt-stack tr { display: block; padding: .75rem 1rem; border-bottom: 1px solid var(--dt-line); }
    .table-card table.dt-stack tbody tr:nth-of-type(odd) { background: var(--dt-stripe); }
    .table-card table.dt-stack tbody tr:last-child { border-bottom: 0; }
    .table-card table.dt-stack > tbody > tr > td {
        display: flex; align-items: center; justify-content: space-between; gap: 1rem; width: 100%;
        padding: .3rem 0 !important; border: 0; text-align: right; background: transparent !important; box-shadow: none !important;
    }
    .table-card table.dt-stack > tbody > tr > td[data-label]::before {
        content: attr(data-label); flex: 0 0 38%; max-width: 38%; text-align: left; font-size: .8rem; font-weight: 600; color: var(--pct-muted);
    }
    .table-card table.dt-stack > tbody > tr > td.text-end, .table-card table.dt-stack > tbody > tr > td.text-center { flex-wrap: wrap; justify-content: flex-end; }
    .table-card table.dt-stack > tbody > tr > td .small, .table-card table.dt-stack > tbody > tr > td .text-muted { text-align: right; }
    .table-card table.dt-stack .empty-state { width: 100%; }
    .table-card table.dt-stack > tbody > tr.table-empty-search > td { justify-content: center; }
}

/* Modais */
.modal-content { border: 1px solid var(--pct-border); border-radius: var(--pct-radius); box-shadow: 0 20px 50px rgba(15, 23, 42, .25); }
.modal-header, .modal-footer { border-color: var(--pct-border); }
.modal-title { font-size: 1.05rem; font-weight: 650; }
.modal-subtitle { color: var(--pct-muted); font-size: .85rem; }

/* O padding das <select> não pode engolir o espaço da seta. */
.form-select { padding-right: 2.25rem; }
.form-select-sm { padding-right: 2rem; }

/* --- Abas e histórico de divergências ---------------------------------------- */

.tab-nav { display: flex; gap: .25rem; margin-bottom: 1.25rem; border-bottom: 1px solid var(--pct-border); overflow-x: auto; }
.tab-link {
    display: inline-flex; align-items: center; gap: .5rem; padding: .6rem 1rem; margin-bottom: -1px; white-space: nowrap;
    color: var(--pct-muted); font-weight: 550; text-decoration: none; border-bottom: 2px solid transparent;
}
.tab-link:hover { color: var(--pct-brand); }
.tab-link.active { color: var(--pct-brand); border-bottom-color: var(--pct-brand); }

.case-history { list-style: none; margin: 0; padding: 0; display: grid; gap: .75rem; }
.case-history li { padding-left: .85rem; border-left: 2px solid var(--pct-border); }
.case-note { margin-top: .25rem; white-space: pre-wrap; overflow-wrap: anywhere; }
.note-cell { min-width: 14rem; white-space: pre-wrap; overflow-wrap: anywhere; }

/* --- Celular e tablet --------------------------------------------------------- */

@media (max-width: 767.98px) {
    .page-header { margin-bottom: 1rem; }
    .page-header h1 { font-size: 1.25rem; }
    .page-actions { width: 100%; }
    .page-actions .btn { flex: 1 1 auto; }

    .dt-title { padding: 14px 16px; }
    .dt-title h2 { font-size: 1.2rem; }
    .dt-actions { width: 100%; }
    .dt-actions .btn { flex: 1 1 auto; justify-content: center; }

    /* Filtros: os seletores em duas colunas; a busca (com o botão) ocupa a linha inteira. */
    .dt-filter { justify-content: flex-start; padding: 12px 16px; }
    .dt-filter-icon, .dt-group label { display: none; }
    .dt-group { flex: 1 1 calc(50% - .5rem); }
    .dt-filter .form-select { width: 100%; max-width: none; }
    .dt-group.dt-search { flex-basis: 100%; }
    .dt-filter .form-control { flex: 1 1 auto; width: auto; }
    .table-card .selection-bar { padding: .6rem 16px; gap: .5rem; }
    .table-card .selection-bar .btn { flex: 1 1 auto; }
    .table-card .selection-bar [data-selection-count] { flex-basis: 100%; }
    .table-card .table > :not(caption) > * > * { padding: 10px 12px; }

    /* Rodapé: "por página" e resumo em cima, paginação centralizada embaixo. */
    .table-footer { flex-direction: column; align-items: stretch; padding: 12px 16px; }
    .table-footer-start { justify-content: space-between; }
    .table-footer-pages { margin-left: 0; }
    .table-footer .pagination { justify-content: center; flex-wrap: wrap; }

    .table .btn-sm { padding: .4rem .75rem; }
    .modal-footer .btn { flex: 1 1 auto; }
    .rule-grid { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); }
}

@media (max-width: 575.98px) {
    /* Só « Anterior · página atual · Próxima »: a lista de números não cabe. */
    .table-footer .page-item:not(.active):not(:first-child):not(:last-child) { display: none; }
    .modal-title { font-size: 1rem; }
    .tab-link { padding: .55rem .75rem; }
}
