/* SINAI DATA - Main Stylesheet v4 */
@import url('https://fonts.googleapis.com/css2?family=Nunito:wght@400;500;600;700;800&display=swap');

:root {
    --primary:       #1C64B0;
    --primary-dark:  #16365C;
    --primary-light: #2A8DD6;
    --primary-pale:  #E8F0FE;
    --bg-body:       #F0F2F5;
    --bg-card:       #FFFFFF;
    --text-main:     #1F2937;
    --text-muted:    #6B7280;
    --success:       #10B981;
    --danger:        #EF4444;
    --warning:       #F59E0B;
    --card-shadow:   0 2px 8px rgba(22,54,92,0.08);
    --card-radius:   6px;
    --border-color:  #E5E7EB;
    --filter-bg:     #E8F0FE;
    --filter-border: #C9D6EA;
    --header-h:      60px;
    --sidebar-w:            220px;
    --sidebar-collapsed-w:  64px;
    --transition:    0.22s ease;
}

*, *::before, *::after { box-sizing: border-box; }

body {
    background: var(--bg-body);
    font-family: 'Nunito', system-ui, sans-serif;
    color: var(--text-main);
    margin: 0; overflow-x: hidden;
}

/* ── Header Logo ─────────────────────────────────────────── */
.header-logo-link {
    display: flex; align-items: center; flex-shrink: 0; text-decoration: none;
}
.header-logo-wrap {
    background: #fff; border-radius: 8px; padding: 6px 12px;
    display: flex; align-items: center;
}
.header-logo-img {
    height: 40px; width: auto; display: block;
}
.header-logo-fallback {
    font-weight: 800; font-size: 0.95rem; color: var(--primary-dark);
    white-space: nowrap; align-items: center;
}

/* ── Header ──────────────────────────────────────────────── */
.app-header {
    position: sticky; top: 0; z-index: 1050;
    background: #FFFFFF;
    border-bottom: 1px solid #E5E7EB;
    box-shadow: 0 1px 4px rgba(0,0,0,0.06);
    height: var(--header-h);
    display: flex; align-items: center;
    padding: 0 1.5rem; gap: 1rem;
}
.header-search {
    flex: 1; max-width: 360px; margin: 0 auto; position: relative;
}
.header-search input {
    width: 100%; background: #F3F4F6;
    border: 1px solid #E5E7EB; border-radius: 24px;
    padding: 0.4rem 1rem 0.4rem 2.4rem; color: var(--text-main);
    font-size: 0.875rem; outline: none; font-family: inherit;
    transition: background var(--transition), border-color var(--transition);
}
.header-search input::placeholder { color: var(--text-muted); }
.header-search input:focus { background: #fff; border-color: var(--primary); box-shadow: 0 0 0 2px rgba(28,100,176,.1); }
.header-search .search-icon {
    position: absolute; left: 0.85rem; top: 50%; transform: translateY(-50%);
    color: var(--text-muted); font-size: 0.85rem; pointer-events: none;
}
.header-actions {
    display: flex; align-items: center; gap: 0.375rem; margin-left: auto; flex-shrink: 0;
}
.header-icon-btn {
    background: none; border: 1px solid var(--border-color); color: var(--text-muted);
    width: 36px; height: 36px; border-radius: 8px;
    display: flex; align-items: center; justify-content: center;
    cursor: pointer; position: relative; font-size: 1rem;
    transition: background var(--transition), color var(--transition), border-color var(--transition);
}
.header-icon-btn:hover { background: var(--primary-pale); color: var(--primary); border-color: var(--primary); }
.header-icon-btn .notif-badge {
    position: absolute; top: 5px; right: 5px; width: 7px; height: 7px;
    background: var(--warning); border-radius: 50%; border: 1.5px solid #fff;
}
.erp-status {
    display: flex; align-items: center; gap: 0.35rem;
    background: #F3F4F6; border-radius: 20px; padding: 0.25rem 0.65rem;
}
.erp-status small { color: var(--text-muted); font-size: 0.73rem; }
.status-dot { width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; }
.status-online  { background: #4ade80; box-shadow: 0 0 0 2px rgba(74,222,128,0.3); }
.status-offline { background: #f87171; box-shadow: 0 0 0 2px rgba(248,113,113,0.3); }
.status-unknown { background: #D1D5DB; }
.user-btn {
    display: flex; align-items: center; gap: 0.45rem;
    background: none; border: 1px solid var(--border-color);
    border-radius: 24px; padding: 0.25rem 0.7rem 0.25rem 0.3rem;
    color: var(--text-main); font-size: 0.83rem; cursor: pointer; font-family: inherit;
    transition: background var(--transition);
}
.user-btn:hover { background: var(--primary-pale); }
.user-btn::after { display: none; }
.user-avatar {
    width: 28px; height: 28px; background: var(--primary);
    color: #fff;
    border-radius: 50%; display: flex; align-items: center; justify-content: center;
    font-weight: 700; font-size: 0.78rem; flex-shrink: 0;
}

/* ── Sidebar ─────────────────────────────────────────────── */
.sidebar {
    position: fixed; left: 0; top: 0;
    width: var(--sidebar-w); height: 100vh;
    background: #0F2F57; z-index: 1100;
    display: flex; flex-direction: column;
    transition: transform 0.28s ease, width 0.28s ease;
    overflow: hidden;
}
.sidebar-header {
    padding: 0 1rem; height: var(--header-h);
    display: flex; align-items: center; justify-content: space-between;
    border-bottom: 1px solid rgba(255,255,255,0.08); flex-shrink: 0;
}
.sidebar-brand { display: flex; align-items: center; text-decoration: none; min-width: 0; }
.sidebar-logo-img { height: 36px; width: auto; }
.sidebar-logo-fallback { font-weight: 800; font-size: 0.9rem; color: #fff; display: none; }
.sidebar-close-btn {
    background: none; border: none; color: rgba(255,255,255,0.55);
    font-size: 1.2rem; cursor: pointer; padding: 0.25rem; line-height: 1;
    border-radius: 4px; transition: color 0.15s, background 0.15s;
}
.sidebar-close-btn:hover { color: #fff; background: rgba(255,255,255,0.1); }
.sidebar-section-title {
    padding: 1.1rem 1rem 0.35rem;
    font-size: 0.6rem; font-weight: 700;
    text-transform: uppercase; letter-spacing: 0.1em;
    color: rgba(255,255,255,0.35);
}
.sidebar-nav {
    flex: 1; overflow-y: auto; overflow-x: hidden; padding: 0.4rem 0 1.5rem;
    scrollbar-width: thin; scrollbar-color: rgba(255,255,255,0.15) transparent;
}
.sidebar-link {
    display: flex; align-items: center; gap: 0.65rem;
    padding: 0.58rem 1rem;
    color: rgba(255,255,255,0.65); text-decoration: none;
    font-size: 0.85rem; font-weight: 500;
    border-left: 3px solid transparent;
    transition: background 0.14s, color 0.14s, border-color 0.14s;
    white-space: nowrap; overflow: hidden;
}
.sidebar-link:hover { background: rgba(255,255,255,0.07); color: rgba(255,255,255,0.92); }
.sidebar-link.active {
    background: rgba(42,141,214,0.18); color: #fff;
    border-left-color: #2A8DD6; font-weight: 600;
}
.sidebar-link i { font-size: 1rem; flex-shrink: 0; width: 20px; text-align: center; }
.sidebar-link-text { flex: 1; }
.sidebar-sub-arrow {
    font-size: 0.65rem; flex-shrink: 0;
    transition: transform 0.22s;
}
.sidebar-submenu-wrap.open .sidebar-sub-arrow { transform: rotate(90deg); }
.sidebar-submenu {
    list-style: none; padding: 0; margin: 0;
    background: rgba(0,0,0,0.18);
    max-height: 0; overflow: hidden;
    transition: max-height 0.28s ease;
}
.sidebar-submenu-wrap.open .sidebar-submenu { max-height: 300px; }
.sidebar-submenu li a {
    display: flex; align-items: center; gap: 0.5rem;
    padding: 0.48rem 1rem 0.48rem 2.85rem;
    color: rgba(255,255,255,0.6); text-decoration: none; font-size: 0.82rem;
    border-left: 3px solid transparent;
    transition: background 0.14s, color 0.14s;
}
.sidebar-submenu li a:hover { background: rgba(255,255,255,0.06); color: rgba(255,255,255,0.9); }
.sidebar-submenu li a.active { color: #fff; border-left-color: #2A8DD6; background: rgba(42,141,214,0.15); }

/* ── Ícones customizados (img) no menu lateral ───────────── */
.sidebar-icon-img {
    width: 18px; height: 18px;
    object-fit: contain; flex-shrink: 0;
    filter: brightness(0) invert(1);
    opacity: 0.65;
    transition: opacity 0.14s;
}
.sidebar-link:hover .sidebar-icon-img { opacity: 0.92; }
.sidebar-link.active .sidebar-icon-img { opacity: 1; }
.sidebar-icon-img-sub { width: 16px; height: 16px; }
.sidebar-submenu li a .sidebar-icon-img { opacity: 0.6; }
.sidebar-submenu li a:hover .sidebar-icon-img,
.sidebar-submenu li a.active .sidebar-icon-img { opacity: 1; }

/* Ícone no banner (fundo azul escuro → branco) */
.banner-icon-img {
    width: 24px; height: 24px;
    object-fit: contain; vertical-align: middle;
    filter: brightness(0) invert(1);
    margin-right: 0.45rem; margin-bottom: 3px;
}

/* Ícone no cabeçalho do card (fundo branco → cor original) */
.card-icon-img {
    width: 15px; height: 15px;
    object-fit: contain; vertical-align: middle;
    margin-right: 0.2rem; margin-bottom: 2px;
}

/* ── Main Wrapper ────────────────────────────────────────── */
.main-wrapper {
    margin-left: var(--sidebar-w);
    min-height: 100vh;
    display: flex; flex-direction: column;
    transition: margin-left 0.28s ease;
}

/* ── Sidebar Toggle (hamburger in header) ────────────────── */
.sidebar-toggle {
    background: none; border: 1px solid var(--border-color); border-radius: 8px;
    width: 36px; height: 36px;
    display: flex; align-items: center; justify-content: center;
    cursor: pointer; color: var(--text-muted); font-size: 1.1rem; flex-shrink: 0;
    transition: background 0.15s, color 0.15s, border-color 0.15s;
}
.sidebar-toggle:hover { background: var(--primary-pale); color: var(--primary); border-color: var(--primary); }

/* ── Overlay (mobile) ────────────────────────────────────── */
.sidebar-overlay {
    display: none; position: fixed; inset: 0;
    background: rgba(0,0,0,0.45); z-index: 1090;
}
.sidebar-overlay.active { display: block; }

/* ── Sidebar collapsed (desktop hamburger toggle) ── */
@media (min-width: 992px) {
    body.sidebar-collapsed .sidebar {
        width: var(--sidebar-collapsed-w);
    }
    body.sidebar-collapsed .sidebar .sidebar-section-title,
    body.sidebar-collapsed .sidebar .sidebar-link-text,
    body.sidebar-collapsed .sidebar .sidebar-sub-arrow,
    body.sidebar-collapsed .sidebar .sidebar-submenu { display: none; }
    body.sidebar-collapsed .sidebar .sidebar-link { justify-content: center; padding: 0.58rem 0; }
    body.sidebar-collapsed .sidebar .sidebar-link i { width: auto; }
    body.sidebar-collapsed .sidebar .sidebar-link .sidebar-icon-img { width: auto; }
    body.sidebar-collapsed .main-wrapper { margin-left: var(--sidebar-collapsed-w); }
}

/* ── Flash container ─────────────────────────────────────── */
.flash-container { padding: 0 1.5rem; }

/* ── Page Wrapper ────────────────────────────────────────── */
.page-wrapper { flex: 1; }

/* ── Page Banner ─────────────────────────────────────────── */
.page-banner {
    background: linear-gradient(to right, #0F3A68, #2A8DD6);
    padding: 1.25rem 1.5rem 4rem; color: #fff;
}
.banner-title { font-size: 1.5rem; font-weight: 800; color: #fff; margin: 0; }
.banner-subtitle { font-size: 0.82rem; color: rgba(255,255,255,0.72); margin: 0.15rem 0 0; }
.banner-breadcrumb .breadcrumb-item { font-size: 0.79rem; }
.banner-breadcrumb .breadcrumb-item a { color: rgba(255,255,255,0.72); text-decoration: none; }
.banner-breadcrumb .breadcrumb-item a:hover { color: #fff; }
.banner-breadcrumb .breadcrumb-item.active { color: rgba(255,255,255,0.9); }
.banner-breadcrumb .breadcrumb-item + .breadcrumb-item::before { color: rgba(255,255,255,0.45); }

/* ── Page Body (overlaps banner) ─────────────────────────── */
.page-body { padding: 0 1.5rem 2.5rem; margin-top: -2.75rem; }

/* ── Cards ───────────────────────────────────────────────── */
.card {
    background: var(--bg-card); border: none;
    border-radius: var(--card-radius); box-shadow: var(--card-shadow);
    transition: box-shadow var(--transition), transform var(--transition);
}
.card:hover { box-shadow: 0 4px 18px rgba(22,54,92,0.13); }
.card-header {
    background: transparent; border-bottom: 1px solid var(--border-color);
    padding: 0.85rem 1.25rem;
    border-radius: var(--card-radius) var(--card-radius) 0 0;
}
.card-title { font-weight: 600; color: var(--text-main); font-size: 0.88rem; margin: 0; }
.card-footer {
    background: transparent; border-top: 1px solid var(--border-color); padding: 0.65rem 1.25rem;
}

/* ── KPI Cards ───────────────────────────────────────────── */
.kpi-card .card-body { padding: 1.2rem; }
.kpi-label {
    font-size: 0.75rem; font-weight: 600; text-transform: uppercase;
    letter-spacing: 0.06em; color: var(--text-muted); margin-bottom: 0.4rem;
}
.kpi-value {
    font-size: 1.9rem; font-weight: 800; color: var(--text-main);
    line-height: 1.1; font-variant-numeric: tabular-nums; margin-bottom: 0.2rem;
}
.kpi-variation {
    font-size: 0.78rem; font-weight: 600;
    display: inline-flex; align-items: center; gap: 0.15rem;
}
.kpi-variation.positive { color: var(--success); }
.kpi-variation.negative { color: var(--danger); }
.kpi-variation.neutral  { color: var(--text-muted); }
.kpi-sub { font-size: 0.72rem; color: var(--text-muted); margin: 0.2rem 0 0.65rem; }
.kpi-progress { display: flex; align-items: center; gap: 0.45rem; }
.kpi-progress .progress {
    flex: 1; height: 4px; background: var(--primary-pale); border-radius: 4px; overflow: hidden;
}
.kpi-progress .progress-bar {
    background: var(--primary); border-radius: 4px;
    transition: width 0.9s cubic-bezier(0.4,0,0.2,1);
}
.kpi-progress-pct { font-size: 0.7rem; font-weight: 700; color: var(--primary); min-width: 28px; text-align: right; }
.kpi-card-link { text-decoration: none; color: inherit; display: block; }
.kpi-card-link:hover .card { transform: translateY(-2px); box-shadow: 0 6px 22px rgba(22,54,92,0.16); }

/* ── Mini Cards ──────────────────────────────────────────── */
.mini-card .card-body {
    display: flex; align-items: center; gap: 0.875rem; padding: 1.1rem;
}
.mini-card-info { flex: 1; min-width: 0; }
.mini-card-label {
    font-size: 0.72rem; font-weight: 600; text-transform: uppercase;
    letter-spacing: 0.06em; color: var(--text-muted); margin-bottom: 0.2rem;
}
.mini-card-value {
    font-size: 1.65rem; font-weight: 800; color: var(--text-main);
    line-height: 1; font-variant-numeric: tabular-nums;
}
.mini-card-sub { font-size: 0.72rem; color: var(--text-muted); margin-top: 0.15rem; }
.mini-card-chart { width: 64px; height: 64px; flex-shrink: 0; position: relative; }

/* ── Metrics Indicators ──────────────────────────────────── */
.metric-indicators {
    display: flex; gap: 1.75rem; margin-bottom: 0.75rem; flex-wrap: wrap;
}
.metric-indicator .ind-label {
    font-size: 0.7rem; text-transform: uppercase; letter-spacing: 0.05em;
    color: var(--text-muted); display: block; margin-bottom: 0.1rem;
}
.metric-indicator .ind-pct { font-size: 1.25rem; font-weight: 800; }
.ind-pct.blue  { color: var(--primary); }
.ind-pct.green { color: var(--success); }
.ind-pct.amber { color: var(--warning); }

/* ── Week Summary ────────────────────────────────────────── */
.week-summary-stats { display: flex; gap: 2.5rem; margin-bottom: 0.75rem; flex-wrap: wrap; }
.week-stat .ws-value {
    font-size: 1.5rem; font-weight: 800; color: var(--text-main);
    font-variant-numeric: tabular-nums; line-height: 1.1;
}
.week-stat .ws-label { font-size: 0.73rem; color: var(--text-muted); margin-top: 0.1rem; }

/* ── Tables ──────────────────────────────────────────────── */
.table { color: var(--text-main); font-size: 0.875rem; }
.table thead th {
    font-size: 0.71rem; font-weight: 700; text-transform: uppercase;
    letter-spacing: 0.07em; color: var(--text-muted);
    border-bottom: 1px solid var(--border-color);
    padding: 0.7rem 1rem; background: transparent;
}
.table tbody tr { border-bottom: 1px solid #F3F4F6; transition: background var(--transition); }
.table tbody tr:hover { background: #EFF6FF; }
.table tbody td { padding: 0.65rem 1rem; vertical-align: middle; }
.badge-type { font-size: 0.68rem; font-weight: 600; padding: 0.18rem 0.55rem; border-radius: 20px; display: inline-block; }
.badge-pa  { background: #EFF6FF; color: var(--primary); }
.badge-int { background: #F0FDF4; color: var(--success); }
.badge-cir { background: #FFFBEB; color: var(--warning); }
.badge-amb { background: #FEF2F2; color: var(--danger); }

/* ── Report pages (compat) ───────────────────────────────── */
.metric-label {
    font-size: 0.75rem; font-weight: 600; text-transform: uppercase;
    letter-spacing: 0.06em; color: var(--text-muted); margin-bottom: 0.25rem;
}
.metric-value {
    font-size: 1.9rem; font-weight: 800; color: var(--text-main);
    line-height: 1.1; font-variant-numeric: tabular-nums; margin-bottom: 0;
}
.metric-value.loading { color: #D1D5DB; animation: pulse 1.5s ease-in-out infinite; }

/* ── Footer ──────────────────────────────────────────────── */
.app-footer {
    background: var(--primary-dark); color: rgba(255,255,255,0.55);
    text-align: center; padding: 0.9rem; font-size: 0.78rem; margin-top: auto;
}

/* ── Back to Top ─────────────────────────────────────────── */
.btn-back-top {
    position: fixed; bottom: 1.5rem; right: 1.5rem;
    width: 40px; height: 40px; background: var(--primary); color: #fff;
    border: none; border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    cursor: pointer; opacity: 0; transform: translateY(10px);
    transition: opacity 0.3s, transform 0.3s; z-index: 9999;
    box-shadow: 0 4px 14px rgba(28,100,176,0.4); font-size: 1rem;
}
.btn-back-top.visible { opacity: 1; transform: translateY(0); }
.btn-back-top:hover { background: #154F8C; }

/* ── Animations ──────────────────────────────────────────── */
.spin-icon { animation: spin 1s linear infinite; display: inline-block; }
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes pulse { 0%,100%{opacity:1} 50%{opacity:0.4} }

.chart-empty { display: none; }
.chart-empty.show { display: block; }

/* ── Responsive (global) ─────────────────────────────────── */
@media (max-width: 991px) {
    .header-search { display: none; }
    .page-banner { padding-bottom: 3rem; }
    .page-body { margin-top: -2rem; }
    /* Sidebar collapses to icon-only */
    .sidebar { width: var(--sidebar-collapsed-w); }
    .sidebar-section-title { display: none; }
    .sidebar-link-text { display: none; }
    .sidebar-link { justify-content: center; padding: 0.58rem 0; }
    .sidebar-link i { width: auto; }
    .sidebar-sub-arrow { display: none; }
    .sidebar-submenu { display: none; }
    .main-wrapper { margin-left: var(--sidebar-collapsed-w); }
}
@media (max-width: 767px) {
    /* Sidebar hides off-screen */
    .sidebar {
        transform: translateX(-100%);
        width: var(--sidebar-w);
    }
    .sidebar.open {
        transform: translateX(0);
        width: var(--sidebar-w);
    }
    .sidebar.open .sidebar-section-title { display: block; }
    .sidebar.open .sidebar-link-text { display: block; }
    .sidebar.open .sidebar-link { justify-content: flex-start; padding: 0.58rem 1rem; }
    .sidebar.open .sidebar-link i { width: 20px; }
    .sidebar.open .sidebar-sub-arrow { display: inline-block; }
    .sidebar.open .sidebar-submenu-wrap.open .sidebar-submenu { display: block; }
    .main-wrapper { margin-left: 0; }
    .kpi-value, .mini-card-value { font-size: 1.55rem; }
    .banner-title { font-size: 1.2rem; }
    .page-body { padding: 0 1rem 2rem; }
    .app-header { padding: 0 1rem; }
    .week-summary-stats { gap: 1.25rem; }
}
@media (max-width: 575.98px) {
    .header-logo-img { height: 32px; }
}
@media print {
    .app-header, .sidebar, .sidebar-overlay, .app-footer, .btn-back-top,
    #filter-form, .btn, nav[aria-label="breadcrumb"],
    #pagination, .banner-actions { display: none !important; }
    .main-wrapper { margin-left: 0 !important; }
    .page-body { margin-top: 0 !important; }
    .page-banner { padding-bottom: 1rem !important; background: none !important; color: #000 !important; }
    .banner-title { color: #000 !important; }
    .card { break-inside: avoid; box-shadow: none !important; }
}

/* ══════════════════════════════════════════════════════════════
   Dashboard v2 — Barra de Filtros + Cards + Skeleton + Semana
   ══════════════════════════════════════════════════════════════ */

/* ── Barra de Filtros ────────────────────────────────────────── */
.filter-bar {
    position: sticky;
    top: var(--header-h);
    z-index: 900;
    background: var(--bg-card);
    border-bottom: 1px solid var(--border-color);
    box-shadow: 0 2px 10px rgba(22,54,92,0.08);
    padding: 0.6rem 1.5rem;
    margin: 0 -1.5rem 1.5rem;
}

.filter-mobile-header {
    justify-content: space-between;
    align-items: center;
    padding-bottom: 0;
}
.btn-filter-toggle {
    background: none; border: 1px solid var(--border-color); border-radius: 6px;
    padding: 0.2rem 0.5rem; color: var(--text-muted); cursor: pointer;
    transition: background var(--transition);
}
.btn-filter-toggle:hover { background: var(--primary-pale); border-color: var(--primary); color: var(--primary); }

.filter-body {
    display: flex; align-items: flex-end; gap: 1rem; flex-wrap: wrap;
    padding-top: 0.35rem;
}
.filter-body.collapsed { display: none; }

.filter-group { display: flex; flex-direction: column; gap: 0.25rem; }
.filter-label {
    font-size: 0.69rem; font-weight: 700; text-transform: uppercase;
    letter-spacing: 0.07em; color: var(--text-muted);
}
.filter-dates { display: flex; align-items: center; gap: 0.4rem; }
.filter-date-sep { font-size: 0.8rem; color: var(--text-muted); flex-shrink: 0; }

.filter-input {
    padding: 0.32rem 0.55rem; border: 1px solid var(--filter-border);
    border-radius: 6px; font-size: 0.83rem; font-family: inherit;
    color: var(--text-main); background: var(--filter-bg); outline: none;
    transition: border-color 0.15s; min-width: 130px;
}
.filter-input:focus { border-color: var(--primary); box-shadow: 0 0 0 2px rgba(28,100,176,.12); }

.filter-shortcuts { display: flex; gap: 0.3rem; flex-wrap: wrap; }
.filter-shortcut {
    padding: 0.28rem 0.65rem; border: 1px solid var(--border-color);
    border-radius: 20px; font-size: 0.78rem; font-family: inherit;
    background: var(--bg-card); color: var(--text-muted); cursor: pointer;
    transition: all 0.15s; white-space: nowrap;
}
.filter-shortcut:hover { background: var(--primary-pale); border-color: var(--primary); color: var(--primary); }
.filter-shortcut--active,
.filter-shortcut.active {
    background: var(--primary); border-color: var(--primary); color: #fff; font-weight: 600;
}

.filter-select {
    padding: 0.32rem 0.55rem; border: 1px solid var(--filter-border);
    border-radius: 6px; font-size: 0.83rem; font-family: inherit;
    color: var(--text-main); background: var(--filter-bg); outline: none;
    min-width: 155px; transition: border-color 0.15s;
}
.filter-select:focus { border-color: var(--primary); box-shadow: 0 0 0 2px rgba(28,100,176,.12); }
.filter-select-multi { min-width: 175px; max-width: 210px; }

.filter-actions { display: flex; gap: 0.45rem; align-items: flex-end; }
.btn-filter-apply {
    padding: 0.35rem 1rem; background: var(--primary); color: #fff;
    border: none; border-radius: 6px; font-size: 0.83rem; font-family: inherit;
    font-weight: 600; cursor: pointer; transition: background 0.15s;
    display: inline-flex; align-items: center;
}
.btn-filter-apply:hover { background: #154F8C; }
.btn-filter-apply:active { background: var(--primary-dark); }

.btn-filter-clear {
    padding: 0.35rem 0.75rem; background: none; color: var(--text-muted);
    border: 1px solid var(--border-color); border-radius: 6px;
    font-size: 0.83rem; font-family: inherit; cursor: pointer;
    display: inline-flex; align-items: center; transition: all 0.15s;
}
.btn-filter-clear:hover { border-color: var(--danger); color: var(--danger); }

/* ── Dash Cards v2 ───────────────────────────────────────────── */
.dash-card .card-body { padding: 1rem 1.1rem 0.6rem; }

.chart-wrapper {
    position: relative;
    height: 210px;
}

.no-data {
    display: flex; flex-direction: column; align-items: center;
    justify-content: center; gap: 0.5rem; padding: 2.75rem 1rem;
    color: var(--text-muted); font-size: 0.83rem; text-align: center;
}
.no-data i { font-size: 2rem; opacity: 0.35; }

/* ── Card Total Strip ────────────────────────────────────────── */
.card-total-strip {
    display: flex; flex-direction: column; gap: 0.45rem;
    padding: 0.65rem 1.1rem; border-top: 1px solid var(--border-color);
    background: #F7F9FC;
    border-radius: 0 0 var(--card-radius) var(--card-radius);
    min-height: 60px;
}
.strip-row {
    display: flex; align-items: center; justify-content: space-between;
    min-height: 28px;
}
.strip-total {
    font-size: 1.85rem; font-weight: 800; color: var(--primary-dark);
    font-variant-numeric: tabular-nums; line-height: 1;
}
.strip-total-label { font-size: 0.7rem; color: var(--text-muted); margin-top: 0.1rem; }

.strip-variation {
    display: inline-flex; align-items: center; gap: 0.2rem;
    font-size: 0.8rem; font-weight: 700; padding: 0.22rem 0.55rem;
    border-radius: 20px; white-space: nowrap;
}
.strip-variation.positive { background: #DCFCE7; color: var(--success); }
.strip-variation.negative { background: #FEF2F2; color: var(--danger); }
.strip-variation.neutral  { background: #F3F4F6; color: var(--text-muted); }
.strip-variation small    { opacity: 0.7; }

/* Censo strip (legado, mantido para compatibilidade) */
.censo-stats { display: flex; gap: 1.4rem; flex-wrap: wrap; align-items: flex-start; }
.censo-stat  { display: flex; flex-direction: column; }
.censo-stat-val { font-size: 1.45rem; font-weight: 800; color: var(--primary-dark); line-height: 1; font-variant-numeric: tabular-nums; }
.censo-stat-lbl { font-size: 0.68rem; color: var(--text-muted); }
.censo-taxa     { font-size: 1.45rem; font-weight: 800; font-variant-numeric: tabular-nums; }

/* ── Censo KPI header (card dashboard) ─────────────────────── */
.censo-kpi-strip {
    display: flex;
    gap: 1.8rem;
    flex-wrap: wrap;
    align-items: flex-end;
    padding: 0.75rem 0.25rem 0.75rem;
    border-bottom: 1px solid var(--border-color);
}
.censo-kpi-item {
    display: flex;
    flex-direction: column;
    gap: 0.15rem;
}
.censo-kpi-val {
    font-size: 1.55rem;
    font-weight: 800;
    line-height: 1;
    font-variant-numeric: tabular-nums;
    color: var(--text-main);
}
.censo-kpi-main .censo-kpi-val { font-size: 2.1rem; }
.censo-kpi-lbl {
    font-size: 0.66rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.04em;
    font-weight: 500;
}
.censo-kpi-sep {
    width: 1px;
    height: 2.5rem;
    background: var(--border-color);
    align-self: center;
    flex-shrink: 0;
}
.censo-subchart-title {
    font-size: 0.78rem;
    font-weight: 600;
    color: var(--text-main);
}

/* ── Skeleton Loading ────────────────────────────────────────── */
@keyframes shimmer {
    0%   { background-position: -600px 0; }
    100% { background-position:  600px 0; }
}
.skeleton-base {
    background: linear-gradient(90deg,#E5E7EB 25%,#F3F4F6 50%,#E5E7EB 75%);
    background-size: 1200px 100%;
    animation: shimmer 1.5s ease-in-out infinite;
}
.skeleton-line {
    height: 11px; border-radius: 6px; margin-bottom: 0.45rem;
    background: linear-gradient(90deg,#E5E7EB 25%,#F3F4F6 50%,#E5E7EB 75%);
    background-size: 1200px 100%;
    animation: shimmer 1.5s ease-in-out infinite;
}
.skeleton-chart {
    height: 190px; border-radius: 8px;
    background: linear-gradient(90deg,#E5E7EB 25%,#F3F4F6 50%,#E5E7EB 75%);
    background-size: 1200px 100%;
    animation: shimmer 1.5s ease-in-out infinite;
}
.skeleton-strip {
    background: #F3F4F6 !important;
    padding: 0.8rem 1.1rem;
    display: flex; align-items: center; gap: 1rem;
}
.w-20 { width: 20%; } .w-30 { width: 30%; }
.w-40 { width: 40%; } .w-50 { width: 50%; }
.w-60 { width: 60%; }

/* ── Week Summary ────────────────────────────────────────────── */
.week-stats-row {
    display: flex; gap: 2rem; flex-wrap: wrap; align-items: flex-end;
    padding-bottom: 1rem; border-bottom: 1px solid var(--border-color); margin-bottom: 1.2rem;
}
.week-stat-item { display: flex; flex-direction: column; }
.week-stat-val {
    font-size: 1.6rem; font-weight: 800; color: var(--text-main);
    font-variant-numeric: tabular-nums; line-height: 1.1;
}
.week-stat-lbl { font-size: 0.72rem; color: var(--text-muted); margin-top: 0.08rem; }

.month-comparison { border-top: 1px solid var(--border-color); padding-top: 1.2rem; }
.month-stat-item { display: flex; flex-direction: column; margin-bottom: 0.65rem; }
.month-stat-val {
    font-size: 1.6rem; font-weight: 800; color: var(--text-main);
    font-variant-numeric: tabular-nums; line-height: 1;
}
.month-stat-lbl { font-size: 0.72rem; color: var(--text-muted); }

/* ── btn-xs ──────────────────────────────────────────────────── */
.btn-xs { padding: 0.15rem 0.4rem; font-size: 0.75rem; line-height: 1.4; }

/* ── Responsive (dashboard) ──────────────────────────────────── */
@media (max-width: 767px) {
    .filter-bar  { padding: 0.5rem 1rem; margin: 0 -1rem 1rem; }
    .filter-body { padding-top: 0.6rem; gap: 0.7rem; }
    .filter-group-convenio { display: none; }
    .week-stats-row  { gap: 1.25rem; }
    .week-stat-val   { font-size: 1.3rem; }
    .month-stat-val  { font-size: 1.3rem; }
    .strip-total     { font-size: 1.55rem; }
    .card-total-strip { min-height: unset; }
}
@media print {
    .filter-bar { display: none !important; }
}

/* ════════════════════════════════════════════════════════════
   Gráficos com Legenda HTML + Gráfico Anual
   ════════════════════════════════════════════════════════════ */

/* ── Chart Canvas Wrap ───────────────────────────────────────── */
.chart-with-legend { display: block; }
.chart-canvas-wrap {
    position: relative;
    height: 200px;
    width: 100%;
}

/* ── Bar Chart Mini-Cards (replaces chips) ───────────────────── */
.strip-chips, .chart-chips {
    padding: 0;
}

.bar-chip {
    display: inline-flex;
    align-items: center;
    gap: 0.28rem;
    background: #EEF2FB;
    border: 1px solid #D1DCF0;
    border-radius: 20px;
    padding: 0.15rem 0.5rem 0.15rem 0.32rem;
    cursor: pointer;
    user-select: none;
    transition: opacity 0.15s, background 0.12s;
    max-width: 100%;
    text-decoration: none;
}
.bar-chip:hover { background: #DDE7F5; }
.bar-chip-hidden { opacity: 0.35; }

.bar-chip-swatch {
    width: 9px; height: 9px; border-radius: 2px; flex-shrink: 0;
}
.bar-chip-name {
    font-size: 0.72rem; font-weight: 600; color: var(--text-main);
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 130px;
}
.bar-chip-qty { font-size: 0.70rem; color: var(--text-muted); white-space: nowrap; }
.bar-chip-pct { font-size: 0.64rem; margin-left: 0.18rem; color: var(--text-muted); opacity: 0.8; }
.bar-chip-pct::before { content: '('; }
.bar-chip-pct::after  { content: ')'; }
.bar-chip-more {
    background: #E8F0FE; border-color: #B8CCF0;
    color: var(--primary); font-size: 0.70rem; font-weight: 600;
}
.bar-chip-more:hover { background: #D4E3FB; }

.mini-cards-total-strip {
    display: flex; align-items: center; justify-content: space-between;
    padding: 0.65rem 1.1rem 0.55rem;
    background: #F7F9FC;
    border-top: 1px solid var(--border-color);
}
.mini-cards-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
    gap: 12px;
    padding: 0.6rem 1.1rem 0.85rem;
    background: #F7F9FC;
    border-radius: 0 0 var(--card-radius) var(--card-radius);
}
.bar-mini-card {
    background: var(--bg-card); border: 1px solid #E3E8EF;
    border-radius: 8px; box-shadow: 0 1px 4px rgba(0,0,0,0.06);
    display: flex; flex-direction: column; align-items: center;
    justify-content: center; text-align: center;
    padding: 0.7rem 0.45rem 0.6rem;
    aspect-ratio: 1 / 1;
    cursor: pointer; user-select: none;
    transition: transform 0.15s, box-shadow 0.15s, opacity 0.15s;
    position: relative; overflow: hidden;
}
.bar-mini-card::before {
    content: ''; position: absolute; top: 0; left: 0; right: 0;
    height: 4px; background: var(--card-accent-color, var(--primary));
    border-radius: 8px 8px 0 0;
}
.bar-mini-card:hover { transform: translateY(-2px); box-shadow: 0 4px 14px rgba(0,0,0,0.13); }
.bar-mini-card.bar-chip-hidden { opacity: 0.38; }
.bar-mini-card-swatch { width: 10px; height: 10px; border-radius: 2px; margin-bottom: 0.3rem; flex-shrink: 0; }
.bar-mini-card-name {
    font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.04em;
    color: #6B7280; margin-bottom: 0.25rem;
    overflow: hidden; display: -webkit-box;
    -webkit-line-clamp: 2; -webkit-box-orient: vertical;
    line-height: 1.3; max-height: 2.7em; word-break: break-word;
    width: 100%;
}
.bar-mini-card-qty { font-size: 24px; font-weight: 800; line-height: 1; font-variant-numeric: tabular-nums; margin-bottom: 0.18rem; }
.bar-mini-card-pct { font-size: 11px; color: #6B7280; }
.bar-mini-card-more {
    background: #E8F0FE; border-color: #C5D5F0;
    color: var(--primary); font-size: 0.78rem; font-weight: 600;
}
.bar-mini-card-more:hover { background: #D4E3FB; }

/* ── Annual Line Chart ────────────────────────────────────── */
.annual-chart-wrap {
    position: relative;
    height: 280px;
}
.annual-toggle-bar {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    flex-wrap: wrap;
}
.annual-loading {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 160px;
    color: var(--text-muted);
    font-size: 0.85rem;
    gap: 0.5rem;
}

/* ── Annual Summary Table ────────────────────────────────── */
.var-pos { color: var(--success); font-weight: 600; }
.var-neg { color: var(--danger); font-weight: 600; }
.var-neu { color: var(--text-muted); }

/* ── Flatpickr overrides ─────────────────────────────────── */
.flatpickr-calendar { font-family: 'Nunito', system-ui, sans-serif !important; font-size: 0.85rem; }
.flatpickr-input    { cursor: pointer; }

/* ── Relatório Detalhado (accordion mês → médico) ────────── */
.doctor-row { transition: background var(--transition); cursor: pointer; }
.doctor-row:hover { background: var(--primary-pale); }
.doctor-chevron { transition: transform 0.22s; }
.doctor-chevron.rotated { transform: rotate(180deg); }
#accordion-meses .accordion-button {
    font-size: 0.88rem; padding: 0.75rem 1.25rem;
    background: #F9FAFB;
}
#accordion-meses .accordion-button:not(.collapsed) {
    background: var(--primary-pale); color: var(--primary-dark);
    box-shadow: none;
}
#accordion-meses .accordion-button::after { flex-shrink: 0; }
#accordion-meses .accordion-body { padding: 0; }
#accordion-meses .badge { font-size: 0.72rem; font-weight: 600; }
.bg-primary-subtle { background: var(--primary-pale) !important; }
.text-primary { color: var(--primary) !important; }
.medico-nome { min-width: 0; }
.medico-nome-trunc {
    display: inline-block; max-width: 260px;
    overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
    vertical-align: bottom; cursor: default;
}

/* ── KPI Today Cards (home dashboard) ───────────────────── */
.kpi-today-grid {
    display: grid;
    grid-template-columns: repeat(6, 1fr);
    gap: 0.85rem;
}
.kpi-today-card-link { text-decoration: none; color: inherit; display: block; }
.kpi-today-card-link:hover .kpi-today-card { transform: translateY(-3px); box-shadow: 0 6px 22px rgba(0,0,0,0.13); }
.kpi-today-card {
    background: var(--bg-card); border: 1px solid var(--border-color);
    border-radius: var(--card-radius); box-shadow: var(--card-shadow);
    padding: 1.1rem 0.9rem 0.85rem;
    display: flex; flex-direction: column; gap: 0.22rem;
    position: relative; overflow: hidden;
    transition: transform 0.2s, box-shadow 0.2s; height: 100%;
}
.kpi-today-card::after {
    content: ''; position: absolute; bottom: 0; left: 0; right: 0;
    height: 3px; background: var(--kpi-color, var(--primary)); border-radius: 0 0 var(--card-radius) var(--card-radius);
}
.kpi-today-icon { font-size: 1.3rem; color: var(--kpi-color, var(--primary)); margin-bottom: 0.1rem; }
.kpi-today-label { font-size: 0.68rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.07em; color: var(--text-muted); }
.kpi-today-value { font-size: 1.95rem; font-weight: 800; color: var(--kpi-color, var(--primary)); line-height: 1; font-variant-numeric: tabular-nums; }
.kpi-today-sub { font-size: 0.71rem; color: var(--text-muted); }
.kpi-today-card.kpi-skeleton { min-height: 110px; }
.kpi-today-card.kpi-card-error {
    display: flex; flex-direction: column; align-items: flex-start; justify-content: center;
    min-height: 110px;
}
.kpi-card-error-msg {
    font-size: 0.72rem; color: var(--text-muted); margin: 0.35rem 0 0.5rem;
}
.kpi-retry-btn {
    font-size: 0.68rem; font-weight: 600; padding: 0.22rem 0.65rem;
    border: 1px solid var(--kpi-color, var(--primary)); border-radius: 4px;
    background: transparent; color: var(--kpi-color, var(--primary));
    cursor: pointer; transition: background 0.15s, color 0.15s;
}
.kpi-retry-btn:hover {
    background: var(--kpi-color, var(--primary)); color: #fff;
}

/* ── Comparison + Annual chart wrappers ──────────────────── */
.comp-mensal-chart-wrap { position: relative; height: 260px; }
.annual-home-chart-wrap { position: relative; height: 240px; }

/* ── KPI Today Grid responsive ───────────────────────────── */
@media (max-width: 1199px) {
    .kpi-today-grid { grid-template-columns: repeat(3, 1fr); }
}
@media (max-width: 767px) {
    .kpi-today-grid { grid-template-columns: repeat(2, 1fr); }
    .mini-cards-grid { grid-template-columns: repeat(3, 1fr); }
}

/* ════════════════════════════════════════════════════════════
   Marca (logo) + responsividade geral
   ════════════════════════════════════════════════════════════ */

/* ── Logo na barra lateral ───────────────────────────────── */
.sidebar-brand { gap: 0.6rem; }
.sidebar-logo-img {
    width: 36px; height: 36px; border-radius: 8px; flex-shrink: 0;
    box-shadow: 0 0 0 1px rgba(255,255,255,0.12);
}
.sidebar-brand-text {
    color: #fff; font-weight: 800; font-size: 0.95rem; line-height: 1.1;
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.sidebar-brand-text small {
    display: block; font-weight: 500; font-size: 0.68rem; color: rgba(255,255,255,0.6);
}
.sidebar-close-btn { display: none; }

/* Sidebar no modo só ícones: centraliza a logo e esconde o texto */
@media (min-width: 992px) {
    body.sidebar-collapsed .sidebar-header { justify-content: center; padding: 0; }
    body.sidebar-collapsed .sidebar-brand-text { display: none; }
}

/* ── Logo no cabeçalho (só celular, quando o menu fica escondido) ── */
.header-mobile-brand {
    display: none; align-items: center; gap: 0.5rem;
    text-decoration: none; min-width: 0;
}
.header-mobile-brand img { width: 32px; height: 32px; border-radius: 7px; flex-shrink: 0; }
.header-mobile-brand span {
    font-weight: 800; font-size: 0.95rem; color: var(--primary-dark);
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}

/* ── Tablet e celular (até 991px) ─────────────────────────── */
@media (max-width: 991px) {
    /* Sidebar fechada = só ícones (tablet) ou escondida (celular) */
    .sidebar:not(.open) .sidebar-header { justify-content: center; padding: 0; }
    .sidebar:not(.open) .sidebar-brand-text { display: none; }

    /* Menu aberto pelo botão: largura total, sobre o conteúdo */
    .sidebar.open { width: var(--sidebar-w); box-shadow: 4px 0 24px rgba(0,0,0,0.3); }
    .sidebar.open .sidebar-close-btn { display: inline-block; }
    .sidebar.open .sidebar-section-title { display: block; }
    .sidebar.open .sidebar-link-text { display: block; }
    .sidebar.open .sidebar-link { justify-content: flex-start; padding: 0.58rem 1rem; }
    .sidebar.open .sidebar-link i { width: 20px; }
    .sidebar.open .sidebar-sub-arrow { display: inline-block; }
    .sidebar.open .sidebar-submenu { display: block; }

    .card-header.d-flex { flex-wrap: wrap; gap: 0.5rem; }
}

/* ── Celular (até 767px) ──────────────────────────────────── */
@media (max-width: 767px) {
    .header-mobile-brand { display: flex; }
    .app-header { gap: 0.6rem; }
    .flash-container { padding: 0 1rem; }

    /* Título e breadcrumb empilhados à esquerda */
    .page-banner { padding: 1rem 1rem 3rem; }
    .page-banner .flex-column.align-items-end { align-items: flex-start !important; }

    /* Tabelas sem .table-responsive passam a rolar na horizontal */
    .page-body .table:not(.table-responsive .table) {
        display: block; max-width: 100%; overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }

    /* Filtro de convênio volta a aparecer no celular */
    .filter-group-convenio { display: flex; }

    /* 16px evita o zoom automático do iPhone ao tocar no campo */
    .filter-input, .filter-select, .form-control, .form-select { font-size: 16px; }
}

/* ── Celular pequeno (até 575px) ──────────────────────────── */
@media (max-width: 575.98px) {
    .filter-body { flex-direction: column; align-items: stretch; }
    .filter-group { width: 100%; }
    .filter-input, .filter-select, .filter-select-multi {
        min-width: 0 !important; width: 100%; max-width: none;
    }
    .filter-dates .filter-input { flex: 1; }
    .filter-actions { width: 100%; }
    .filter-actions > * { flex: 1; justify-content: center; }
    .mini-cards-grid { grid-template-columns: repeat(2, 1fr); }
    .card-header input[type="text"] { max-width: none !important; width: 100% !important; }
    .btn-back-top { bottom: 1rem; right: 1rem; }
}

/* ── Telas muito estreitas (até 400px) ────────────────────── */
@media (max-width: 400px) {
    #btn-fullscreen, .header-icon-btn[title="Notificações"] { display: none; }
    .kpi-value, .mini-card-value { font-size: 1.35rem; }
}
@media (max-width: 359.98px) {
    .header-mobile-brand span { display: none; }
}
