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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    background: #f0f2f5;
    color: #1a1a2e;
    min-height: 100vh;
}

header {
    background: #1a1a2e;
    color: #fff;
    padding: 16px 32px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    box-shadow: 0 2px 8px rgba(0,0,0,0.2);
}

header h1 { font-size: 18px; font-weight: 600; letter-spacing: 0.5px; }
header span { font-size: 12px; color: #8892a4; margin-left: 8px; }

.header-actions { display: flex; align-items: center; gap: 12px; }

.btn-refresh {
    background: #2563eb;
    color: #fff;
    border: none;
    padding: 8px 16px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 13px;
    font-weight: 500;
    transition: background 0.2s;
}
.btn-refresh:hover { background: #1d4ed8; }

.btn-collapse {
    background: transparent;
    color: #6b7280;
    border: 1px solid #d1d5db;
    padding: 8px 16px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 13px;
    font-weight: 500;
    transition: all 0.2s;
}
.btn-collapse:hover { background: #f3f4f6; color: #374151; border-color: #9ca3af; }

.last-update { font-size: 12px; color: #8892a4; }

.btn-logout {
    color: #8892a4;
    font-size: 13px;
    text-decoration: none;
    padding: 8px 12px;
    border-radius: 6px;
    transition: color 0.2s, background 0.2s;
}
.btn-logout:hover { color: #fff; background: rgba(255,255,255,0.1); }

main { padding: 24px 32px; max-width: 1400px; margin: 0 auto; }

.stats {
    display: grid;
    grid-template-columns: repeat(6, 1fr);
    gap: 12px;
    margin-bottom: 24px;
}

.stat-card {
    background: #fff;
    border-radius: 10px;
    padding: 16px 20px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.08);
    border-left: 4px solid #e5e7eb;
    cursor: pointer;
    transition: transform 0.15s, box-shadow 0.15s;
}
.stat-card:hover { transform: translateY(-2px); box-shadow: 0 4px 12px rgba(0,0,0,0.1); }
.stat-card.active { box-shadow: 0 0 0 2px #2563eb; }

.stat-card.total    { border-color: #6366f1; }
.stat-card.concluido { border-color: #22c55e; }
.stat-card.divergente { border-color: #f59e0b; }
.stat-card.falhou   { border-color: #ef4444; }
.stat-card.pendente { border-color: #3b82f6; }
.stat-card.ignorado { border-color: #9ca3af; }

.stat-label { font-size: 11px; text-transform: uppercase; letter-spacing: 0.8px; color: #6b7280; font-weight: 600; }
.stat-value { font-size: 28px; font-weight: 700; margin-top: 4px; }

.stat-card.total    .stat-value { color: #6366f1; }
.stat-card.concluido .stat-value { color: #22c55e; }
.stat-card.divergente .stat-value { color: #f59e0b; }
.stat-card.falhou   .stat-value { color: #ef4444; }
.stat-card.pendente .stat-value { color: #3b82f6; }
.stat-card.ignorado .stat-value { color: #9ca3af; }

.toolbar {
    background: #fff;
    border-radius: 10px;
    padding: 14px 20px;
    margin-bottom: 16px;
    display: flex;
    gap: 12px;
    align-items: center;
    box-shadow: 0 1px 3px rgba(0,0,0,0.08);
}

.toolbar { flex-wrap: wrap; }

.input-busca {
    flex: 1;
    min-width: 180px;
    border: 1px solid #e5e7eb;
    border-radius: 6px;
    padding: 8px 12px;
    font-size: 13px;
    outline: none;
    transition: border-color 0.2s;
}
.input-busca:focus { border-color: #2563eb; }

.filtro-input-sm {
    width: 72px;
    border: 1px solid #e5e7eb;
    border-radius: 6px;
    padding: 8px 10px;
    font-size: 13px;
    outline: none;
    transition: border-color 0.2s;
}
.filtro-input-sm:focus { border-color: #2563eb; }

.filtro-select {
    border: 1px solid #e5e7eb;
    border-radius: 6px;
    padding: 8px 10px;
    font-size: 13px;
    outline: none;
    background: #fff;
    color: #374151;
    cursor: pointer;
    transition: border-color 0.2s;
}
.filtro-select:focus { border-color: #2563eb; }

.filtro-input-date {
    width: 135px;
    border: 1px solid #e5e7eb;
    border-radius: 6px;
    padding: 8px 10px;
    font-size: 13px;
    outline: none;
    transition: border-color 0.2s;
}
.filtro-input-date:focus { border-color: #2563eb; }

.toolbar-sep {
    width: 1px;
    height: 24px;
    background: #e5e7eb;
    flex-shrink: 0;
}

.btn-limpar {
    background: transparent;
    color: #9ca3af;
    border: 1px solid #e5e7eb;
    width: 32px;
    height: 34px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 14px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: all 0.15s;
}
.btn-limpar:hover { background: #fee2e2; color: #dc2626; border-color: #fca5a5; }

.toolbar-label { font-size: 13px; color: #6b7280; white-space: nowrap; }

#thFechar { width: 140px; min-width: 140px; }

.table-wrap {
    background: #fff;
    border-radius: 10px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.08);
    overflow: hidden;
}

table { width: 100%; border-collapse: collapse; font-size: 13px; }

thead tr { background: #f8fafc; }
thead th {
    padding: 12px 16px;
    text-align: left;
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.6px;
    color: #6b7280;
    border-bottom: 1px solid #e5e7eb;
    white-space: nowrap;
}

tbody tr {
    border-bottom: 1px solid #f3f4f6;
    transition: background 0.1s;
    cursor: pointer;
}
tbody tr:hover { background: #f8fafc; }
tbody tr:last-child { border-bottom: none; }

tbody tr.expanded { background: #f0f7ff; }

td { padding: 12px 16px; vertical-align: top; }

.td-id { color: #9ca3af; font-size: 12px; width: 50px; }
.td-bill { font-weight: 600; color: #1a1a2e; }
.td-secondary { color: #6b7280; }

.badge {
    display: inline-block;
    padding: 3px 10px;
    border-radius: 20px;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}
.badge-concluido  { background: #dcfce7; color: #16a34a; }
.badge-divergente { background: #fef9c3; color: #d97706; }
.badge-falhou     { background: #fee2e2; color: #dc2626; }
.badge-pendente   { background: #dbeafe; color: #2563eb; }
.badge-ignorado   { background: #f3f4f6; color: #6b7280; }

.divergencias-row td {
    background: #f8fafc;
    padding: 0;
    cursor: default;
    border-top: none;
}
.divergencias-inner {
    padding: 16px 24px 16px 48px;
    border-top: 3px solid #f59e0b;
}
.divergencias-label {
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.8px;
    color: #92400e;
    margin-bottom: 10px;
}
.divergencias-inner .div-table {
    width: auto;
    min-width: 560px;
    border-radius: 8px;
    overflow: hidden;
    border: 1px solid #e5e7eb;
    box-shadow: 0 1px 4px rgba(0,0,0,0.06);
}
.divergencias-inner .div-table thead th {
    background: #1a1a2e;
    color: #e2e8f0;
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 0.6px;
    padding: 9px 16px;
    text-transform: uppercase;
    border-bottom: none;
}
.divergencias-inner .div-table tbody tr { cursor: default; }
.divergencias-inner .div-table tbody tr:nth-child(odd)  { background: #fff; }
.divergencias-inner .div-table tbody tr:nth-child(even) { background: #f8fafc; }
.divergencias-inner .div-table tbody tr:hover { background: #f0f7ff; }
.divergencias-inner .div-table td {
    padding: 9px 16px;
    font-size: 13px;
    color: #1a1a2e;
    border-bottom: 1px solid #f3f4f6;
}
.divergencias-inner .div-table tbody tr:last-child td { border-bottom: none; }
.div-campo { font-weight: 500; color: #374151; }
.div-nf    { color: #16a34a; font-weight: 600; }
.div-titulo { color: #dc2626; font-weight: 600; }

.motivo-falha {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    background: #fff;
    border: 1px solid #fecaca;
    border-left: 4px solid #ef4444;
    padding: 12px 16px;
    border-radius: 6px;
    font-size: 13px;
    color: #7f1d1d;
    box-shadow: 0 1px 3px rgba(239,68,68,0.08);
}
.motivo-falha strong { color: #dc2626; display: block; margin-bottom: 2px; font-size: 11px; text-transform: uppercase; letter-spacing: 0.5px; }

.tudo-ok {
    display: flex;
    align-items: center;
    gap: 12px;
    background: #fff;
    border: 1px solid #bbf7d0;
    border-left: 4px solid #22c55e;
    padding: 14px 20px;
    border-radius: 8px;
    box-shadow: 0 1px 3px rgba(34,197,94,0.08);
    max-width: 520px;
}
.tudo-ok-icon {
    font-size: 22px;
    line-height: 1;
}
.tudo-ok-text strong {
    display: block;
    font-size: 13px;
    font-weight: 700;
    color: #15803d;
    margin-bottom: 2px;
}
.tudo-ok-text span {
    font-size: 12px;
    color: #4b5563;
}

.empty {
    text-align: center;
    padding: 60px 20px;
    color: #9ca3af;
    font-size: 14px;
}

.count-label {
    font-size: 12px;
    color: #9ca3af;
    padding: 12px 16px;
    border-top: 1px solid #f3f4f6;
}

.paginacao {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 12px 16px;
    border-top: 1px solid #f3f4f6;
}

.pag-info {
    font-size: 12px;
    color: #6b7280;
    margin-right: 8px;
}

.pag-btn {
    background: #fff;
    border: 1px solid #e5e7eb;
    color: #374151;
    width: 32px;
    height: 32px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 13px;
    font-weight: 500;
    transition: all 0.15s;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}
.pag-btn:hover:not(:disabled) { background: #f3f4f6; border-color: #9ca3af; }
.pag-btn:disabled { opacity: 0.35; cursor: default; }
.pag-btn.active { background: #1a1a2e; color: #fff; border-color: #1a1a2e; }

.pag-ellipsis {
    font-size: 13px;
    color: #9ca3af;
    padding: 0 4px;
}

/* ── Nav tabs ── */
.nav-tabs { display: flex; gap: 4px; }
.nav-tab {
    color: #8892a4;
    font-size: 13px;
    font-weight: 500;
    text-decoration: none;
    padding: 7px 16px;
    border-radius: 6px;
    transition: all 0.2s;
}
.nav-tab:hover { color: #fff; background: rgba(255,255,255,0.1); }
.nav-tab.active { color: #fff; background: rgba(255,255,255,0.18); }

/* ── Analytics ── */
.analytics-periodo-label { font-size: 13px; color: #6b7280; }

.analytics-kpis {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 12px;
    margin-bottom: 20px;
}

.analytics-grid-2 {
    display: grid;
    grid-template-columns: 3fr 2fr;
    gap: 16px;
    margin-bottom: 16px;
}

.analytics-card {
    background: #fff;
    border-radius: 10px;
    padding: 20px 24px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.08);
    margin-bottom: 16px;
}

.analytics-card-title {
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.6px;
    color: #6b7280;
    margin-bottom: 16px;
}

.chart-wrap { position: relative; height: 280px; }
.chart-wrap-lg { height: 200px; }

.kpi-card {
    background: #fff;
    border-radius: 10px;
    padding: 18px 20px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.08);
    border-left: 4px solid var(--kpi-color, #6366f1);
}

.kpi-label {
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.8px;
    color: #6b7280;
    margin-bottom: 4px;
}

.kpi-value {
    font-size: 26px;
    font-weight: 700;
    color: var(--kpi-color, #6366f1);
    line-height: 1.2;
}

.kpi-sub { font-size: 12px; color: #9ca3af; margin-top: 3px; }

.periodo-tabs {
    display: flex;
    gap: 4px;
    background: #f3f4f6;
    padding: 4px;
    border-radius: 8px;
}

.periodo-btn {
    background: transparent;
    border: none;
    padding: 6px 14px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 13px;
    font-weight: 500;
    color: #6b7280;
    transition: all 0.15s;
}

.periodo-btn:hover { color: #374151; }
.periodo-btn.active { background: #fff; color: #1a1a2e; box-shadow: 0 1px 3px rgba(0,0,0,0.1); }

/* ── Responsáveis ── */
.user-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(380px, 1fr));
    gap: 16px;
}

.user-card {
    background: #fff;
    border-radius: 12px;
    padding: 20px 24px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.08);
    transition: box-shadow 0.2s;
}
.user-card:hover { box-shadow: 0 4px 16px rgba(0,0,0,0.1); }

.user-card-header {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 16px;
}

.user-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: #1a1a2e;
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 15px;
    font-weight: 700;
    flex-shrink: 0;
}

.user-info { flex: 1; min-width: 0; }

.user-email {
    font-size: 13px;
    font-weight: 600;
    color: #1a1a2e;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.taxa-badge {
    display: inline-block;
    font-size: 11px;
    font-weight: 600;
    padding: 2px 8px;
    border-radius: 20px;
    margin-top: 4px;
}
.taxa-ok  { background: #dcfce7; color: #16a34a; }
.taxa-avg { background: #fef9c3; color: #d97706; }
.taxa-bad { background: #fee2e2; color: #dc2626; }

.btn-ver-titulos {
    font-size: 12px;
    color: #6b7280;
    text-decoration: none;
    padding: 6px 10px;
    border-radius: 6px;
    border: 1px solid #e5e7eb;
    white-space: nowrap;
    flex-shrink: 0;
    transition: all 0.15s;
}
.btn-ver-titulos:hover { background: #1a1a2e; color: #fff; border-color: #1a1a2e; }

.user-stats {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 8px;
    margin-bottom: 16px;
}

.user-stat {
    text-align: center;
    padding: 10px 4px;
    border-radius: 8px;
    background: #f8fafc;
}
.user-stat-val {
    display: block;
    font-size: 20px;
    font-weight: 700;
    color: #1a1a2e;
    line-height: 1.2;
}
.user-stat-lbl {
    display: block;
    font-size: 10px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: #9ca3af;
    font-weight: 600;
    margin-top: 2px;
}
.user-stat.conformes   .user-stat-val { color: #22c55e; }
.user-stat.divergentes .user-stat-val { color: #f59e0b; }
.user-stat.falhas      .user-stat-val { color: #ef4444; }
.user-stat.isentos     .user-stat-val { color: #9ca3af; }

.div-breakdown { border-top: 1px solid #f3f4f6; padding-top: 14px; }

.div-breakdown-title {
    font-size: 10px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.6px;
    color: #9ca3af;
    margin-bottom: 10px;
}

.div-row {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 8px;
}

.div-campo-nome {
    font-size: 12px;
    color: #374151;
    width: 148px;
    flex-shrink: 0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.div-bar-wrap {
    flex: 1;
    height: 6px;
    background: #f3f4f6;
    border-radius: 3px;
    overflow: hidden;
}

.div-bar {
    height: 100%;
    background: #f59e0b;
    border-radius: 3px;
}

.div-pct {
    font-size: 11px;
    color: #9ca3af;
    width: 52px;
    text-align: right;
    flex-shrink: 0;
}

.user-sem-div {
    font-size: 12px;
    color: #22c55e;
    font-weight: 500;
}


/* ── Login ── */
.login-body {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    background: #f0f2f5;
}

.login-wrap {
    width: 100%;
    max-width: 380px;
    padding: 24px;
}

.login-card {
    background: #fff;
    border-radius: 12px;
    padding: 40px 36px;
    box-shadow: 0 4px 24px rgba(0,0,0,0.10);
}

.login-title {
    font-size: 22px;
    font-weight: 700;
    color: #1a1a2e;
    margin-bottom: 4px;
}

.login-sub {
    font-size: 13px;
    color: #6b7280;
    margin-bottom: 28px;
}

.login-field {
    margin-bottom: 16px;
}

.login-field label {
    display: block;
    font-size: 11px;
    font-weight: 700;
    color: #374151;
    margin-bottom: 6px;
    text-transform: uppercase;
    letter-spacing: 0.6px;
}

.login-field input {
    width: 100%;
    border: 1px solid #e5e7eb;
    border-radius: 6px;
    padding: 10px 12px;
    font-size: 14px;
    outline: none;
    transition: border-color 0.2s;
}

.login-field input:focus { border-color: #2563eb; }

.login-erro {
    background: #fee2e2;
    color: #dc2626;
    border-radius: 6px;
    padding: 10px 14px;
    font-size: 13px;
    margin-bottom: 14px;
}

.btn-login {
    width: 100%;
    background: #1a1a2e;
    color: #fff;
    border: none;
    padding: 11px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 600;
    transition: background 0.2s;
    margin-top: 4px;
}
.btn-login:hover { background: #2563eb; }
