/* ---------- Theme Tokens ---------- */

:root {
    /* Gomes e Sá brand */
    --brand-primary: #007A75;
    --brand-primary-soft: rgba(0, 122, 117, 0.12);
    --brand-accent: #00A39C;
    --brand-gradient: linear-gradient(135deg, #007A75 0%, #00A39C 100%);

    /* Semantic state colors (theme-agnostic) */
    --success: #10b981;
    --warning: #f59e0b;
    --danger: #ef4444;
    --info: #3b82f6;

    --sidebar-width: 260px;
    --radius-md: 0.75rem;
    --radius-lg: 1.25rem;

    /* Default (light) surface tokens — overridden by [data-theme="dark"] */
    --bg-main: #f8fafc;
    --bg-card: #ffffff;
    --bg-sidebar: #ffffff;
    --bg-elevated: #f1f5f9;
    --text-main: #0f172a;
    --text-muted: #64748b;
    --text-subtle: #94a3b8;
    --border: #e2e8f0;
    --border-strong: #cbd5e1;
    --shadow-card: 0 1px 3px rgba(15, 23, 42, 0.04), 0 2px 12px rgba(15, 23, 42, 0.04);
    --shadow-hover: 0 10px 25px -5px rgba(15, 23, 42, 0.12);
    --input-bg: #ffffff;
    --overlay: rgba(15, 23, 42, 0.04);
}

[data-theme="dark"] {
    --bg-main: #0f1419;
    --bg-card: #151b2d;
    --bg-sidebar: #111827;
    --bg-elevated: #1e2536;
    --text-main: #f8fafc;
    --text-muted: #94a3b8;
    --text-subtle: #64748b;
    --border: rgba(255, 255, 255, 0.08);
    --border-strong: rgba(255, 255, 255, 0.16);
    --shadow-card: 0 1px 3px rgba(0, 0, 0, 0.2), 0 2px 12px rgba(0, 0, 0, 0.2);
    --shadow-hover: 0 10px 25px -5px rgba(0, 0, 0, 0.5);
    --input-bg: #0b0f1a;
    --overlay: rgba(255, 255, 255, 0.04);
}

/* ---------- Base ---------- */

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

html, body {
    background-color: var(--bg-main);
    color: var(--text-main);
    font-family: 'Montserrat', 'Inter', sans-serif;
    min-height: 100vh;
    transition: background-color 0.2s ease, color 0.2s ease;
}

body {
    display: flex;
    overflow-x: hidden;
}

button {
    font-family: inherit;
}

/* ---------- Animations ---------- */
@keyframes fadeInUp {
    from { opacity: 0; transform: translateY(15px); }
    to { opacity: 1; transform: translateY(0); }
}

.kpi-card, .chart-card {
    animation: fadeInUp 0.5s cubic-bezier(0.16, 1, 0.3, 1) backwards;
}

.kpi-grid > div:nth-child(1) { animation-delay: 0.05s; }
.kpi-grid > div:nth-child(2) { animation-delay: 0.10s; }
.kpi-grid > div:nth-child(3) { animation-delay: 0.15s; }
.kpi-grid > div:nth-child(4) { animation-delay: 0.20s; }
.kpi-grid > div:nth-child(5) { animation-delay: 0.25s; }
.kpi-grid > div:nth-child(6) { animation-delay: 0.30s; }

.charts-grid > div:nth-child(1) { animation-delay: 0.15s; }
.charts-grid > div:nth-child(2) { animation-delay: 0.25s; }
.charts-grid > div:nth-child(3) { animation-delay: 0.35s; }
.charts-grid > div:nth-child(4) { animation-delay: 0.45s; }
.charts-grid > div:nth-child(5) { animation-delay: 0.55s; }
.charts-grid > div:nth-child(6) { animation-delay: 0.65s; }

/* ---------- Glassmorphism Base ---------- */
.sidebar, .filters-bar, .kpi-card, .chart-card, .users-card, .modal {
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
}

[data-theme="dark"] .sidebar,
[data-theme="dark"] .filters-bar,
[data-theme="dark"] .kpi-card,
[data-theme="dark"] .chart-card,
[data-theme="dark"] .users-card,
[data-theme="dark"] .modal {
    background: rgba(21, 27, 45, 0.7);
    border: 1px solid rgba(255, 255, 255, 0.08);
}

[data-theme="light"] .sidebar,
[data-theme="light"] .filters-bar,
[data-theme="light"] .kpi-card,
[data-theme="light"] .chart-card,
[data-theme="light"] .users-card,
[data-theme="light"] .modal {
    background: rgba(255, 255, 255, 0.85);
    border: 1px solid rgba(226, 232, 240, 0.8);
}

/* ---------- Sidebar ---------- */

.sidebar {
    width: var(--sidebar-width);
    background-color: var(--bg-sidebar);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    position: fixed;
    height: 100vh;
    z-index: 100;
}

.sidebar-header {
    padding: 1.75rem 1.5rem;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    border-bottom: 1px solid var(--border);
}

.sidebar-logo {
    width: 42px;
    height: 42px;
    border-radius: 0.6rem;
    overflow: hidden;
    box-shadow: 0 4px 12px rgba(0, 122, 117, 0.25);
    flex-shrink: 0;
}

.sidebar-logo img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.sidebar-brand {
    font-weight: 700;
    font-size: 1.05rem;
    color: var(--text-main);
    letter-spacing: -0.01em;
}

.nav-links {
    list-style: none;
    padding: 1rem 0.75rem;
    margin: 0;
    flex: 1;
}

.nav-item {
    margin-bottom: 0.25rem;
}

.nav-link {
    display: flex;
    align-items: center;
    gap: 0.85rem;
    padding: 0.7rem 0.95rem;
    color: var(--text-muted);
    text-decoration: none;
    border-radius: var(--radius-md);
    transition: all 0.15s ease;
    font-size: 0.875rem;
    font-weight: 500;
}

.nav-link:hover {
    background: var(--overlay);
    color: var(--text-main);
}

.nav-link.active {
    background: var(--brand-primary-soft);
    color: var(--brand-primary);
    font-weight: 600;
}

.nav-icon {
    font-size: 1rem;
    width: 18px;
    text-align: center;
}

/* Nav groups (collapsible submenu) */
.nav-group > .nav-group-toggle {
    display: flex;
    align-items: center;
    gap: 0.85rem;
    width: 100%;
    padding: 0.7rem 0.95rem;
    background: transparent;
    border: none;
    color: var(--text-main);
    cursor: pointer;
    font-weight: 600;
    font-size: 0.875rem;
    font-family: inherit;
    border-radius: var(--radius-md);
    text-align: left;
    transition: background 0.15s ease, color 0.15s ease;
}
.nav-group > .nav-group-toggle:hover { background: var(--overlay); }

.nav-group-label { flex: 1; }

.nav-chevron {
    font-size: 0.7rem;
    color: var(--text-muted);
    transition: transform 0.2s ease;
}
.nav-group:not(.open) .nav-chevron { transform: rotate(-90deg); }

.nav-sublinks {
    list-style: none;
    padding: 0.25rem 0 0.25rem 0.5rem;
    margin: 0;
    border-left: 2px solid var(--border);
    margin-left: 1.15rem;
    overflow: hidden;
    max-height: 500px;
    transition: max-height 0.25s ease, opacity 0.2s ease;
}
.nav-group:not(.open) .nav-sublinks {
    max-height: 0;
    opacity: 0;
    padding-top: 0;
    padding-bottom: 0;
}

.nav-sublinks li { margin: 0.1rem 0; }
.nav-sublinks .nav-link {
    padding: 0.55rem 0.75rem;
    font-size: 0.83rem;
}

/* Footer nav link (for Usuários button placed in the footer) */
.footer-link {
    padding: 0.6rem 0.75rem;
    font-size: 0.85rem;
    color: var(--text-muted);
}
.footer-link:hover { background: var(--overlay); color: var(--text-main); }
.footer-link.active { background: var(--brand-primary-soft); color: var(--brand-primary); font-weight: 600; }

.sidebar-footer {
    padding: 1rem;
    border-top: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.sidebar-footer button {
    background: transparent;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 0.6rem;
    font-size: 0.85rem;
    padding: 0.6rem 0.75rem;
    border-radius: var(--radius-md);
    transition: all 0.15s ease;
    text-align: left;
}

.sidebar-footer button:hover {
    background: var(--overlay);
    color: var(--text-main);
}

/* ---------- Main layout ---------- */

.main-content {
    margin-left: var(--sidebar-width);
    flex: 1;
    padding: 2rem;
    max-width: 1600px;
    width: calc(100% - var(--sidebar-width));
}

.header-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.75rem;
    gap: 1rem;
    flex-wrap: wrap;
}

.page-title h1 {
    font-size: 1.55rem;
    font-weight: 700;
    letter-spacing: -0.02em;
}

.page-title p {
    color: var(--text-muted);
    font-size: 0.875rem;
    margin-top: 0.15rem;
}

.user-profile {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.user-profile .avatar {
    width: 40px;
    height: 40px;
    background: var(--brand-gradient);
    color: white;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    font-size: 0.875rem;
}

.user-profile .meta {
    text-align: right;
    line-height: 1.2;
}

.user-profile .meta .name {
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--text-main);
}

.user-profile .meta .role {
    font-size: 0.72rem;
    color: var(--text-muted);
}

.theme-toggle {
    background: var(--bg-card);
    border: 1px solid var(--border);
    color: var(--text-muted);
    width: 38px;
    height: 38px;
    border-radius: 50%;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.15s ease;
}

.theme-toggle:hover {
    color: var(--brand-primary);
    border-color: var(--brand-primary);
}

/* ---------- Filters ---------- */

.filters-bar {
    display: flex;
    gap: 1rem;
    background: var(--bg-card);
    padding: 0.85rem 1.25rem;
    border-radius: var(--radius-lg);
    border: 1px solid var(--border);
    margin-bottom: 1.75rem;
    align-items: center;
    flex-wrap: wrap;
    box-shadow: var(--shadow-card);
}

.filter-shortcuts {
    display: flex;
    gap: 0.4rem;
    border-right: 1px solid var(--border);
    padding-right: 1rem;
}

.btn-shortcut {
    background: transparent;
    border: 1px solid var(--border);
    color: var(--text-muted);
    padding: 0.4rem 0.8rem;
    border-radius: 0.5rem;
    font-size: 0.75rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.15s ease;
}

.btn-shortcut:hover {
    color: var(--text-main);
    border-color: var(--border-strong);
}

.btn-shortcut.active {
    background: var(--brand-primary);
    color: white;
    border-color: var(--brand-primary);
}

.date-picker-wrapper {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    color: var(--text-muted);
    font-size: 0.875rem;
}

input[type="date"] {
    background: var(--input-bg);
    border: 1px solid var(--border);
    color: var(--text-main);
    padding: 0.4rem 0.6rem;
    border-radius: 0.5rem;
    font-size: 0.8rem;
    font-family: inherit;
}

input[type="date"]::-webkit-calendar-picker-indicator {
    filter: invert(var(--calendar-icon-invert, 0));
    cursor: pointer;
}

[data-theme="dark"] {
    --calendar-icon-invert: 1;
}

.btn-primary {
    background: var(--brand-primary);
    color: white;
    border: 1px solid var(--brand-primary);
    padding: 0.4rem 0.9rem;
    border-radius: 0.5rem;
    font-size: 0.75rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.15s ease;
}

.btn-primary:hover {
    background: var(--brand-accent);
    border-color: var(--brand-accent);
}

.btn-primary:active, .btn-shortcut:active {
    transform: scale(0.96);
}

/* ---------- KPI Cards ---------- */

.kpi-grid {
    display: grid;
    grid-template-columns: repeat(6, minmax(0, 1fr));
    gap: 0.85rem;
    margin-bottom: 1.5rem;
}

.kpi-card {
    padding: 1rem 1rem 0.15rem;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-card);
    transition: transform 0.25s cubic-bezier(0.16, 1, 0.3, 1), box-shadow 0.25s ease;
    overflow: hidden;
    position: relative;
    min-width: 0;
}

.kpi-card:hover {
    transform: translateY(-3px);
    box-shadow: var(--shadow-hover);
}

.kpi-label {
    color: var(--text-muted);
    font-size: 0.68rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    font-weight: 600;
    margin-bottom: 0.35rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.kpi-value {
    font-size: 1.4rem;
    font-weight: 700;
    letter-spacing: -0.02em;
    color: var(--text-main);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.kpi-trend {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    font-size: 0.72rem;
    font-weight: 600;
    margin-top: 0.35rem;
    padding: 0.15rem 0.45rem;
    border-radius: 0.35rem;
}

.kpi-trend.up    { color: var(--success); background: rgba(16, 185, 129, 0.10); }
.kpi-trend.down  { color: var(--danger);  background: rgba(239, 68, 68, 0.10); }
.kpi-trend.flat  { color: var(--text-muted); background: var(--overlay); }

.kpi-trend i { font-size: 0.7rem; }

.kpi-trend-label {
    display: block;
    font-size: 0.65rem;
    font-weight: 500;
    color: var(--text-subtle);
    margin-top: 0.2rem;
}

.kpi-sparkline {
    margin: 0.35rem -1rem -0.15rem;
    height: 50px;
}

.kpi-card .skeleton {
    height: 1.65rem;
    border-radius: 0.35rem;
    background: var(--overlay);
    animation: pulse 1.4s infinite ease-in-out;
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

/* ---------- Charts ---------- */

.charts-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 1.25rem;
}

.chart-card {
    padding: 1.35rem;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-card);
}

.chart-card.full-width {
    grid-column: span 2;
}

.chart-header {
    margin-bottom: 1rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 0.5rem;
}

.chart-title {
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--text-main);
}

.chart-subtitle {
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-top: 0.1rem;
}

/* Data tables inside chart cards */
.data-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.82rem;
}

.data-table th,
.data-table td {
    text-align: left;
    padding: 0.6rem 0.5rem;
    border-bottom: 1px solid var(--border);
}

.data-table th {
    color: var(--text-muted);
    font-weight: 600;
    font-size: 0.72rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.data-table tbody tr:hover {
    background: var(--overlay);
}

.data-table td.num {
    text-align: right;
    font-variant-numeric: tabular-nums;
}

.data-table td.trend-up   { color: var(--success); font-weight: 600; }
.data-table td.trend-down { color: var(--danger);  font-weight: 600; }

/* ---------- Chips ---------- */

.chip {
    display: inline-block;
    padding: 2px 10px;
    border-radius: 999px;
    font-size: 0.75rem;
    font-weight: 700;
    line-height: 1.4;
    white-space: nowrap;
}
.chip-ok     { background: rgba(16, 185, 129, 0.15); color: #10b981; }
.chip-warn   { background: rgba(245, 158, 11, 0.15); color: #f59e0b; }
.chip-amber  { background: rgba(249, 115, 22, 0.18); color: #f97316; }
.chip-danger { background: rgba(239, 68, 68, 0.18);  color: #ef4444; }
.chip-muted  { background: rgba(100, 116, 139, 0.18); color: #64748b; }

/* ---------- Loading / empty states ---------- */

.loading, .empty-state {
    color: var(--text-muted);
    font-size: 0.875rem;
    padding: 1rem;
    text-align: center;
}

/* ---------- Users page ---------- */

.nav-admin-only {
    display: none;
}

body[data-role="admin"] .nav-admin-only {
    display: block;
}

.users-toolbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.25rem;
    gap: 1rem;
    flex-wrap: wrap;
}

.users-toolbar h2 {
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--text-main);
}

.users-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 0.5rem;
    box-shadow: var(--shadow-card);
    overflow-x: auto;
}

.users-card table {
    width: 100%;
}

.users-card .data-table td,
.users-card .data-table th {
    padding: 0.75rem 0.85rem;
}

.badge {
    display: inline-block;
    padding: 0.15rem 0.55rem;
    font-size: 0.7rem;
    font-weight: 600;
    border-radius: 999px;
    letter-spacing: 0.02em;
}

.badge-admin { background: var(--brand-primary-soft); color: var(--brand-primary); }
.badge-user  { background: var(--overlay); color: var(--text-muted); }

.pages-chips {
    display: inline-flex;
    gap: 0.35rem;
    flex-wrap: wrap;
}

.pages-chip {
    font-size: 0.68rem;
    padding: 0.1rem 0.5rem;
    border-radius: 999px;
    background: var(--overlay);
    color: var(--text-muted);
}

.row-actions {
    display: inline-flex;
    gap: 0.35rem;
}

.icon-btn {
    background: transparent;
    border: 1px solid var(--border);
    color: var(--text-muted);
    width: 30px;
    height: 30px;
    border-radius: 0.5rem;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: all 0.15s ease;
}

.icon-btn:hover { color: var(--text-main); border-color: var(--border-strong); }
.icon-btn.danger:hover { color: var(--danger); border-color: var(--danger); }

/* ---------- Modal ---------- */

.modal-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, 0.55);
    backdrop-filter: blur(4px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    padding: 1rem;
    animation: fadeIn 0.15s ease-out;
}

.modal {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    width: 100%;
    max-width: 480px;
    padding: 1.75rem;
    box-shadow: var(--shadow-hover);
}

.modal h2 {
    font-size: 1.15rem;
    font-weight: 700;
    margin-bottom: 0.35rem;
    color: var(--text-main);
}

.modal p.modal-subtitle {
    color: var(--text-muted);
    font-size: 0.85rem;
    margin-bottom: 1.25rem;
}

.modal .form-field {
    margin-bottom: 0.9rem;
}

.modal .form-field label {
    display: block;
    color: var(--text-main);
    font-size: 0.78rem;
    font-weight: 600;
    margin-bottom: 0.35rem;
}

.modal input[type="text"],
.modal input[type="password"],
.modal select {
    width: 100%;
    padding: 0.6rem 0.75rem;
    background: var(--input-bg);
    border: 1px solid var(--border);
    border-radius: 0.5rem;
    color: var(--text-main);
    font-size: 0.875rem;
    font-family: inherit;
}

.modal input:focus, .modal select:focus {
    outline: none;
    border-color: var(--brand-primary);
    box-shadow: 0 0 0 3px var(--brand-primary-soft);
}

.modal .radio-group {
    display: flex;
    gap: 0.5rem;
}

.modal .radio-group label {
    flex: 1;
    padding: 0.55rem;
    border: 1px solid var(--border);
    border-radius: 0.5rem;
    text-align: center;
    cursor: pointer;
    font-size: 0.8rem;
    font-weight: 500;
    transition: all 0.15s ease;
}

.modal .radio-group input[type="radio"] { display: none; }
.modal .radio-group input[type="radio"]:checked + span {
    color: var(--brand-primary);
}

.modal .radio-group label:has(input:checked) {
    border-color: var(--brand-primary);
    background: var(--brand-primary-soft);
    color: var(--brand-primary);
}

.modal .pages-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 0.5rem;
}

.modal .page-checkbox {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.55rem 0.75rem;
    border: 1px solid var(--border);
    border-radius: 0.5rem;
    cursor: pointer;
    font-size: 0.82rem;
    transition: all 0.15s ease;
    user-select: none;
}

.modal .page-checkbox:has(input:checked) {
    border-color: var(--brand-primary);
    background: var(--brand-primary-soft);
    color: var(--brand-primary);
}

.modal .page-checkbox input { accent-color: var(--brand-primary); }

.modal-actions {
    display: flex;
    gap: 0.6rem;
    justify-content: flex-end;
    margin-top: 1.25rem;
}

.btn-secondary {
    background: transparent;
    border: 1px solid var(--border);
    color: var(--text-main);
    padding: 0.55rem 1rem;
    border-radius: 0.5rem;
    font-size: 0.85rem;
    font-weight: 500;
    cursor: pointer;
    font-family: inherit;
}

.btn-secondary:hover { border-color: var(--border-strong); }

.modal .btn-primary {
    padding: 0.55rem 1rem;
    font-size: 0.85rem;
}

.modal .error-text {
    color: var(--danger);
    font-size: 0.8rem;
    margin-top: 0.75rem;
    min-height: 1em;
}

/* ---------- Animations ---------- */

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

.animate-fade-in {
    animation: fadeIn 0.35s ease-out forwards;
}

/* ---------- Filter controls ---------- */

.filter-select {
    background: var(--input-bg);
    border: 1px solid var(--border);
    color: var(--text-main);
    padding: 0.4rem 0.6rem;
    border-radius: 0.5rem;
    font-size: 0.8rem;
    font-family: inherit;
    min-width: 140px;
    cursor: pointer;
}

.filter-select:focus, .filter-input:focus {
    outline: none;
    border-color: var(--brand-primary);
}

.filter-input {
    background: var(--input-bg);
    border: 1px solid var(--border);
    color: var(--text-main);
    padding: 0.4rem 0.6rem;
    border-radius: 0.5rem;
    font-size: 0.8rem;
    font-family: inherit;
    min-width: 180px;
}

.filter-group {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    color: var(--text-muted);
    font-size: 0.8rem;
}

/* ---------- Responsive ---------- */
/* KPI grid stays 6-cols at every breakpoint — we shrink typography / padding instead */

@media (max-width: 1400px) {
    .kpi-card  { padding: 0.85rem 0.85rem 0.15rem; }
    .kpi-value { font-size: 1.2rem; }
    .kpi-label { font-size: 0.62rem; letter-spacing: 0.03em; }
    .kpi-grid  { gap: 0.6rem; }
}

@media (max-width: 1100px) {
    .charts-grid {
        grid-template-columns: 1fr;
    }
    .chart-card.full-width {
        grid-column: span 1;
    }
    .kpi-card  { padding: 0.7rem 0.7rem 0.15rem; }
    .kpi-value { font-size: 1rem; }
    .kpi-label { font-size: 0.58rem; }
    .kpi-trend { font-size: 0.66rem; padding: 0.12rem 0.35rem; }
    .kpi-trend-label { font-size: 0.58rem; }
    .kpi-sparkline { height: 38px; margin: 0.25rem -0.7rem -0.15rem; }
    .kpi-grid  { gap: 0.4rem; }
}

@media (max-width: 768px) {
    .sidebar {
        width: 70px;
    }
    .sidebar-brand, .nav-link span, .sidebar-footer button span {
        display: none;
    }
    .main-content {
        margin-left: 70px;
        width: calc(100% - 70px);
        padding: 1rem;
    }
    .kpi-card  { padding: 0.55rem 0.5rem 0.1rem; }
    .kpi-value { font-size: 0.82rem; }
    .kpi-label { font-size: 0.52rem; }
    .kpi-trend { display: none; }
    .kpi-trend-label { display: none; }
    .kpi-sparkline { height: 28px; margin: 0.2rem -0.5rem -0.1rem; }
}


/* ---------- Custom Funnel Chart ---------- */

.custom-funnel-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 1rem 0;
    font-family: inherit;
    position: relative;
}

.funnel-stage {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.8rem 1.5rem;
    margin-bottom: 0px;
    border-radius: 8px;
    color: white;
    font-weight: 600;
    font-size: 0.9rem;
    transition: all 0.3s ease;
    cursor: default;
    box-shadow: 0 4px 6px rgba(0,0,0,0.1);
    position: relative;
}

/* Base styles for the line connecting stages */
.funnel-stage:not(:last-child)::after {
    content: '';
    position: absolute;
    bottom: -15px; /* The gap */
    left: 50%;
    transform: translateX(-50%);
    width: 2px;
    height: 15px;
    background-color: var(--border-strong);
    opacity: 0.4;
}

.funnel-stage-wrapper {
    margin-bottom: 15px;
    width: 100%;
    display: flex;
    justify-content: center;
}

.funnel-stage-wrapper:last-child {
    margin-bottom: 0;
}

.funnel-stage:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 12px rgba(0,0,0,0.15);
}

.funnel-label {
    letter-spacing: 0.02em;
}

.funnel-value {
    font-weight: 700;
    font-variant-numeric: tabular-nums;
}

.funnel-val-pct {
    font-size: 0.75rem;
    opacity: 0.85;
    margin-left: 6px;
    font-weight: 500;
}

