@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&display=swap');

:root {
    --cni-blue: #164194;
    --cni-blue-medium: #008BD2;
    --cni-green: #52AE32;
    --cni-orange: #E84910;
    --cni-teal: #6CC2BA;
    --cni-yellow: #FDAD23;
    --bg-page: #f5f7fa;
    --bg-card: #ffffff;
    --bg-panel: #f5f7fa;
    --text-dark: #1a1a2e;
    --text-body: #444;
    --text-secondary: #666;
    --text-muted: #999;
    --border-light: #e2e6ec;
    --border-medium: #d0d5dd;
    --radius: 8px;
}

*, *::before, *::after { margin: 0; padding: 0; box-sizing: border-box; }

body {
    font-family: 'Inter', 'Segoe UI', system-ui, sans-serif;
    background: var(--bg-page);
    color: var(--text-body);
    min-height: 100vh;
    -webkit-font-smoothing: antialiased;
}

.header {
    background: var(--cni-blue);
    padding: 18px 40px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.header-title-row {
    display: flex;
    align-items: center;
    gap: 16px;
}

.header-badge {
    color: white;
    padding: 7px 14px;
    border: 1.5px solid rgba(255, 255, 255, 0.4);
    border-radius: 6px;
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 2px;
    flex-shrink: 0;
}

.header h1 {
    font-size: 18px;
    font-weight: 600;
    color: white;
}

.header p {
    font-size: 12px;
    color: rgba(255, 255, 255, 0.7);
    margin-top: 2px;
}

.header-update {
    font-size: 11px;
    color: rgba(255, 255, 255, 0.85);
    background: rgba(255, 255, 255, 0.12);
    padding: 6px 14px;
    border-radius: 14px;
}

.cards {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 14px;
    padding: 20px 40px 14px;
}

.card {
    background: var(--bg-card);
    border-radius: var(--radius);
    padding: 18px 20px;
    border-left: 3px solid var(--cni-orange);
    border-top: none;
    border-right: none;
    border-bottom: none;
    transition: transform 0.15s;
}

.card:hover { transform: translateY(-1px); }

.card:nth-child(1) { border-left-color: var(--cni-green); }
.card:nth-child(2) { border-left-color: var(--cni-blue-medium); }
.card:nth-child(3) { border-left-color: var(--cni-yellow); }
.card:nth-child(4) { border-left-color: var(--cni-teal); }

.card .label {
    font-size: 10px;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    font-weight: 500;
}

.card .value {
    font-size: 26px;
    font-weight: 700;
    margin-top: 6px;
    color: var(--cni-blue);
}

.card .sub {
    font-size: 11px;
    color: var(--text-muted);
    margin-top: 3px;
}

.filter-bar {
    position: sticky;
    top: 0;
    z-index: 100;
    background: rgba(255, 255, 255, 0.97);
    backdrop-filter: blur(8px);
    border-top: 1px solid var(--border-light);
    border-bottom: 1px solid var(--border-light);
    padding: 12px 40px;
}

.filter-bar-inner {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.filters {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    align-items: flex-end;
}

.filter-group {
    display: flex;
    flex-direction: column;
    gap: 3px;
}

.filter-group label {
    font-size: 9px;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.6px;
    font-weight: 600;
}

.filter-group select {
    background: white;
    color: var(--text-body);
    border: 1px solid var(--border-medium);
    border-radius: 6px;
    padding: 7px 28px 7px 10px;
    font-size: 12px;
    font-family: inherit;
    min-width: 130px;
    cursor: pointer;
    transition: border-color 0.15s;
    appearance: none;
    -webkit-appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6'%3E%3Cpath d='M0 0l5 6 5-6z' fill='%23999'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 10px center;
}

.filter-group select:focus {
    outline: none;
    border-color: var(--cni-blue-medium);
}

.filter-group select.active-filter {
    border-color: var(--cni-blue-medium);
    color: var(--cni-blue);
    font-weight: 500;
}

.btn-limpar {
    background: transparent;
    color: var(--cni-blue-medium);
    border: none;
    padding: 7px 12px;
    font-size: 11px;
    font-family: inherit;
    cursor: pointer;
    font-weight: 600;
}

.btn-limpar:hover { text-decoration: underline; }

.filter-chips {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
    min-height: 0;
}

.filter-chips:empty { display: none; }

.chip {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background: #e6f1fb;
    color: var(--cni-blue);
    border-radius: 14px;
    padding: 3px 10px 3px 12px;
    font-size: 11px;
    font-weight: 500;
}

.chip-x {
    cursor: pointer;
    color: var(--cni-blue-medium);
    font-size: 13px;
    line-height: 1;
    opacity: 0.7;
    transition: opacity 0.1s;
}

.chip-x:hover { opacity: 1; }

.tabs-wrapper {
    background: white;
    padding: 0 40px;
    border-bottom: 2px solid var(--border-light);
}

.tabs {
    display: flex;
    gap: 0;
    overflow-x: auto;
    scrollbar-width: none;
}

.tabs::-webkit-scrollbar { display: none; }

.tab {
    padding: 12px 16px;
    cursor: pointer;
    font-size: 12px;
    font-weight: 500;
    color: var(--text-muted);
    border-bottom: 2px solid transparent;
    margin-bottom: -2px;
    transition: color 0.15s;
    white-space: nowrap;
}

.tab:hover { color: var(--text-body); }

.tab.active {
    color: var(--cni-blue);
    border-bottom-color: var(--cni-yellow);
}

.sections { padding: 20px 40px 40px; }
.section { display: none; }
.section.active { display: block; }

.chart-container {
    background: var(--bg-panel);
    border-radius: var(--radius);
    padding: 24px;
    margin-bottom: 16px;
    border: 1px solid var(--border-light);
}

.chart-header {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    margin-bottom: 16px;
}

.chart-header h3 {
    font-size: 14px;
    font-weight: 600;
    color: var(--cni-blue);
}

.chart-sub {
    font-size: 11px;
    color: var(--text-muted);
}

.chart-wrapper {
    position: relative;
    height: 400px;
    background: white;
    border-radius: 6px;
    padding: 12px;
}

.chart-wrapper.tall { height: 520px; }

.grid-2 {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
}

.table-container { overflow-x: auto; }

table {
    width: 100%;
    border-collapse: collapse;
    font-size: 12px;
}

th {
    text-align: left;
    padding: 10px 14px;
    background: white;
    color: var(--text-secondary);
    font-weight: 600;
    text-transform: uppercase;
    font-size: 10px;
    letter-spacing: 0.5px;
    border-bottom: 2px solid var(--border-light);
}

td {
    padding: 9px 14px;
    border-bottom: 1px solid var(--border-light);
    color: var(--text-body);
}

tr:hover { background: #f8fafc; }

.badge {
    display: inline-block;
    padding: 2px 10px;
    border-radius: 12px;
    font-size: 11px;
    font-weight: 600;
}

.badge-green { background: #eaf5e6; color: #3d7a35; }
.badge-red { background: #fceaea; color: #b5403a; }
.badge-yellow { background: #fdf3e0; color: #a07820; }

#infoQualidade {
    padding: 20px;
    font-size: 13px;
    line-height: 1.9;
    color: var(--text-body);
}

.footer {
    display: flex;
    justify-content: space-between;
    padding: 16px 40px;
    font-size: 11px;
    color: var(--text-muted);
    border-top: 1px solid var(--border-light);
    background: white;
}

@media (max-width: 900px) {
    .cards { grid-template-columns: repeat(2, 1fr); }
    .grid-2 { grid-template-columns: 1fr; }
    .cards, .sections, .filter-bar, .tabs-wrapper { padding-left: 16px; padding-right: 16px; }
    .header { padding: 16px; }
    .filter-group select { min-width: 110px; }
    .footer { flex-direction: column; gap: 4px; text-align: center; padding: 12px 16px; }
}

@media (max-width: 600px) {
    .cards { grid-template-columns: 1fr; }
    .header-title-row { flex-direction: column; align-items: flex-start; gap: 8px; }
    .header-right { display: none; }
}