/* ============================================
   PIX PARCELADO — Design System
   Glassmorphism + Indigo/Violet Theme
   ============================================ */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700;800&display=swap');

/* ── CSS Variables ── */
:root {
    /* Primary Palette */
    --primary: #6366f1;
    --primary-light: #818cf8;
    --primary-dark: #4f46e5;
    --primary-glow: rgba(99, 102, 241, 0.4);
    --violet: #8b5cf6;
    --violet-light: #a78bfa;

    /* Accent Colors */
    --success: #10b981;
    --success-light: #34d399;
    --success-bg: rgba(16, 185, 129, 0.12);
    --warning: #f59e0b;
    --warning-light: #fbbf24;
    --warning-bg: rgba(245, 158, 11, 0.12);
    --danger: #ef4444;
    --danger-light: #f87171;
    --danger-bg: rgba(239, 68, 68, 0.12);
    --info: #3b82f6;
    --info-bg: rgba(59, 130, 246, 0.12);

    /* Dark Theme */
    --bg-deep: #06070d;
    --bg-dark: #0a0e1a;
    --surface: rgba(15, 18, 35, 0.75);
    --surface-hover: rgba(25, 30, 55, 0.85);
    --surface-light: rgba(30, 35, 60, 0.6);
    --surface-card: rgba(15, 18, 35, 0.6);

    /* Text */
    --text: #f1f5f9;
    --text-secondary: #94a3b8;
    --text-muted: #64748b;
    --text-inverse: #0f172a;

    /* Borders */
    --border: rgba(99, 102, 241, 0.15);
    --border-hover: rgba(99, 102, 241, 0.3);
    --border-light: rgba(148, 163, 184, 0.1);

    /* Effects */
    --blur: blur(20px);
    --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.3);
    --shadow-md: 0 4px 16px rgba(0, 0, 0, 0.4);
    --shadow-lg: 0 8px 32px rgba(0, 0, 0, 0.5);
    --shadow-glow: 0 0 30px rgba(99, 102, 241, 0.15);

    /* Spacing */
    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 16px;
    --radius-xl: 24px;

    /* Sidebar */
    --sidebar-width: 260px;
    --sidebar-collapsed: 70px;
    --bottom-nav-height: 64px;

    /* Transitions */
    --ease: cubic-bezier(0.4, 0, 0.2, 1);
    --transition: all 0.3s var(--ease);
}

/* ── Reset & Base ── */
*, *::before, *::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    font-size: 16px;
    zoom: 0.9;
    scroll-behavior: smooth;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    background: var(--bg-deep);
    color: var(--text);
    min-height: 100vh;
    overflow-x: hidden;
    line-height: 1.6;
}

/* ── Animated Background ── */
body::before {
    content: '';
    position: fixed;
    inset: 0;
    background: linear-gradient(-45deg, #06070d, #12103a, #1a0d3a, #0d1a2e, #06070d);
    background-size: 400% 400%;
    animation: gradientFlow 20s ease infinite;
    z-index: -2;
}

body::after {
    content: '';
    position: fixed;
    inset: 0;
    background: 
        radial-gradient(ellipse 600px 400px at 20% 20%, rgba(99, 102, 241, 0.06), transparent),
        radial-gradient(ellipse 500px 300px at 80% 80%, rgba(139, 92, 246, 0.05), transparent);
    z-index: -1;
}

@keyframes gradientFlow {
    0% { background-position: 0% 50%; }
    25% { background-position: 50% 100%; }
    50% { background-position: 100% 50%; }
    75% { background-position: 50% 0%; }
    100% { background-position: 0% 50%; }
}

/* ── Scrollbar ── */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb {
    background: rgba(99, 102, 241, 0.3);
    border-radius: 3px;
}
::-webkit-scrollbar-thumb:hover { background: rgba(99, 102, 241, 0.5); }

/* ── App Layout ── */
.app-container {
    display: flex;
    min-height: 100vh;
}

.main-content {
    flex: 1;
    margin-left: var(--sidebar-collapsed);
    padding: 2rem;
    max-width: calc(100% - var(--sidebar-collapsed));
    transition: margin-left 0.3s var(--ease), max-width 0.3s var(--ease);
}

.app-container:has(.sidebar-nav:hover) .main-content {
    margin-left: var(--sidebar-width);
    max-width: calc(100% - var(--sidebar-width));
}

/* ── Sidebar Navigation ── */
.sidebar-nav {
    position: fixed;
    top: 0;
    left: 0;
    width: var(--sidebar-collapsed);
    height: 100vh;
    background: var(--surface);
    backdrop-filter: var(--blur);
    -webkit-backdrop-filter: var(--blur);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    z-index: 100;
    overflow-x: hidden;
    overflow-y: auto;
    transition: width 0.3s var(--ease);
}

.sidebar-nav:hover {
    width: var(--sidebar-width);
}

/* Hide text when collapsed, show on hover */
.sidebar-nav span,
.sidebar-nav .brand-text,
.sidebar-nav .nav-section-label,
.sidebar-nav .nav-user-info,
.sidebar-nav .nav-badge {
    opacity: 0;
    white-space: nowrap;
    transition: opacity 0.2s var(--ease);
}

.sidebar-nav:hover span,
.sidebar-nav:hover .brand-text,
.sidebar-nav:hover .nav-section-label,
.sidebar-nav:hover .nav-user-info,
.sidebar-nav:hover .nav-badge {
    opacity: 1;
}

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

.sidebar-brand .brand-icon {
    width: 40px;
    height: 40px;
    background: linear-gradient(135deg, var(--primary), var(--violet));
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.2rem;
    box-shadow: 0 4px 12px rgba(99, 102, 241, 0.3);
}

.sidebar-brand .brand-text {
    display: flex;
    flex-direction: column;
}

.sidebar-brand .brand-name {
    font-size: 1.1rem;
    font-weight: 700;
    background: linear-gradient(135deg, var(--primary-light), var(--violet-light));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    line-height: 1.2;
}

.sidebar-brand .brand-sub {
    font-size: 0.65rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 1px;
}

.nav-section {
    padding: 1rem 0.75rem;
    flex: 1;
}

.nav-section-label {
    font-size: 0.65rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 1.5px;
    padding: 0 0.75rem;
    margin-bottom: 0.5rem;
    font-weight: 600;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.7rem 0.75rem;
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
    cursor: pointer;
    transition: var(--transition);
    font-size: 0.875rem;
    font-weight: 500;
    text-decoration: none;
    user-select: none;
    margin-bottom: 2px;
}

.nav-item:hover {
    background: var(--surface-hover);
    color: var(--text);
}

.nav-item.active {
    background: linear-gradient(135deg, rgba(99, 102, 241, 0.15), rgba(139, 92, 246, 0.1));
    color: var(--primary-light);
    box-shadow: inset 3px 0 0 var(--primary);
}

.nav-item .nav-icon {
    width: 20px;
    height: 20px;
    flex-shrink: 0;
    opacity: 0.8;
}

.nav-item.active .nav-icon { opacity: 1; }

.nav-item .nav-badge {
    margin-left: auto;
    background: var(--danger);
    color: white;
    font-size: 0.65rem;
    font-weight: 700;
    padding: 0.15rem 0.45rem;
    border-radius: 10px;
    min-width: 18px;
    text-align: center;
    animation: pulse-badge 2s ease infinite;
}

@keyframes pulse-badge {
    0%, 100% { box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.4); }
    50% { box-shadow: 0 0 0 6px rgba(239, 68, 68, 0); }
}

.nav-footer {
    padding: 1rem;
    border-top: 1px solid var(--border);
}

.nav-user {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.5rem;
}

.nav-user-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--primary), var(--violet));
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 0.85rem;
    flex-shrink: 0;
}

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

.nav-user-name {
    font-size: 0.8rem;
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.nav-user-role {
    font-size: 0.65rem;
    color: var(--text-muted);
}

.nav-logout {
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    padding: 0.4rem;
    border-radius: var(--radius-sm);
    transition: var(--transition);
    display: flex;
}

.nav-logout:hover {
    color: var(--danger);
    background: var(--danger-bg);
}

/* ── Top User Bar (fixed top-right) ── */
.top-user-bar {
    position: fixed;
    top: 0.75rem;
    right: 1rem;
    z-index: 100;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.4rem 0.6rem 0.4rem 0.5rem;
    background: var(--surface);
    backdrop-filter: var(--blur);
    -webkit-backdrop-filter: var(--blur);
    border: 1px solid var(--border);
    border-radius: 50px;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.2);
}

.top-user-info {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    cursor: pointer;
    padding: 0.15rem 0.3rem;
    border-radius: 50px;
    transition: var(--transition);
}

.top-user-info:hover {
    background: var(--surface-hover);
}

.top-user-avatar {
    width: 30px;
    height: 30px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--primary), var(--violet));
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 0.7rem;
    flex-shrink: 0;
    color: white;
}

.top-user-details {
    display: flex;
    align-items: center;
    gap: 0.4rem;
}

.top-user-name {
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--text);
    white-space: nowrap;
}

.top-user-role {
    font-size: 0.6rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    padding: 1px 6px;
    border-radius: 4px;
    background: rgba(99, 102, 241, 0.15);
    color: var(--primary-light);
    white-space: nowrap;
}

.top-logout-btn {
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    padding: 0.35rem;
    border-radius: 50%;
    transition: var(--transition);
    display: flex;
    margin-left: 0.15rem;
}

.top-logout-btn:hover {
    color: var(--danger);
    background: var(--danger-bg);
}

/* ── Page Sections ── */
.page-section {
    display: none;
    animation: fadeIn 0.3s var(--ease);
}

.page-section.active {
    display: block;
}

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

.page-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 1.5rem;
    flex-wrap: wrap;
    gap: 1rem;
    padding-top: 3rem; /* Push below top user bar */
}

.page-title {
    font-size: 1.5rem;
    font-weight: 700;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.page-title .title-icon {
    width: 28px;
    height: 28px;
    color: var(--primary-light);
}

.page-subtitle {
    font-size: 0.85rem;
    color: var(--text-secondary);
    margin-top: 0.15rem;
}

/* ── Cards ── */
.card {
    background: var(--surface);
    backdrop-filter: var(--blur);
    -webkit-backdrop-filter: var(--blur);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 1.25rem;
    transition: var(--transition);
}

.card:hover {
    border-color: var(--border-hover);
    box-shadow: var(--shadow-glow);
}

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

.card-title {
    font-size: 0.85rem;
    color: var(--text-secondary);
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* ── KPI Cards ── */
.kpi-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.kpi-card {
    background: var(--surface);
    backdrop-filter: var(--blur);
    -webkit-backdrop-filter: var(--blur);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 1.25rem;
    display: flex;
    align-items: flex-start;
    gap: 1rem;
    transition: var(--transition);
    position: relative;
    overflow: hidden;
}

.kpi-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 3px;
    background: linear-gradient(90deg, var(--kpi-color, var(--primary)), transparent);
    opacity: 0.6;
}

.kpi-card:hover {
    border-color: var(--border-hover);
    transform: translateY(-2px);
    box-shadow: var(--shadow-glow);
}

.kpi-icon {
    width: 48px;
    height: 48px;
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.kpi-icon svg {
    width: 24px;
    height: 24px;
}

.kpi-icon.blue { background: var(--info-bg); color: var(--info); }
.kpi-icon.green { background: var(--success-bg); color: var(--success); }
.kpi-icon.amber { background: var(--warning-bg); color: var(--warning); }
.kpi-icon.red { background: var(--danger-bg); color: var(--danger); }
.kpi-icon.violet { background: rgba(139, 92, 246, 0.12); color: var(--violet); }

.kpi-info { flex: 1; }

.kpi-label {
    font-size: 0.75rem;
    color: var(--text-secondary);
    font-weight: 500;
    margin-bottom: 0.25rem;
}

.kpi-value {
    font-size: 1.6rem;
    font-weight: 800;
    line-height: 1.2;
    letter-spacing: -0.5px;
}

.kpi-value.green { color: var(--success); }
.kpi-value.amber { color: var(--warning); }
.kpi-value.red { color: var(--danger); }

.kpi-sub {
    font-size: 0.7rem;
    color: var(--text-muted);
    margin-top: 0.2rem;
}

/* ── Buttons ── */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.6rem 1.2rem;
    border: 1px solid transparent;
    border-radius: var(--radius-sm);
    font-family: inherit;
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
    text-decoration: none;
    white-space: nowrap;
    user-select: none;
    line-height: 1.4;
}

.btn svg {
    width: 18px;
    height: 18px;
    flex-shrink: 0;
}

.btn-primary {
    background: linear-gradient(135deg, var(--primary), var(--violet));
    color: white;
    box-shadow: 0 4px 12px rgba(99, 102, 241, 0.3);
}

.btn-primary:hover {
    box-shadow: 0 6px 20px rgba(99, 102, 241, 0.5);
    transform: translateY(-1px);
}

.btn-success {
    background: linear-gradient(135deg, var(--success), #059669);
    color: white;
    box-shadow: 0 4px 12px rgba(16, 185, 129, 0.3);
}

.btn-success:hover {
    box-shadow: 0 6px 20px rgba(16, 185, 129, 0.5);
    transform: translateY(-1px);
}

.btn-danger {
    background: linear-gradient(135deg, var(--danger), #dc2626);
    color: white;
    box-shadow: 0 4px 12px rgba(239, 68, 68, 0.3);
}

.btn-danger:hover {
    box-shadow: 0 6px 20px rgba(239, 68, 68, 0.5);
    transform: translateY(-1px);
}

.btn-ghost {
    background: transparent;
    color: var(--text-secondary);
    border: 1px solid var(--border);
}

.btn-ghost:hover {
    background: var(--surface-hover);
    color: var(--text);
    border-color: var(--border-hover);
}

.btn-sm {
    padding: 0.35rem 0.75rem;
    font-size: 0.75rem;
}

.btn-sm svg { width: 15px; height: 15px; }

.btn-icon {
    padding: 0.5rem;
    border-radius: var(--radius-sm);
}

.btn-whatsapp {
    background: #25d366;
    color: white;
}

.btn-whatsapp:hover {
    background: #1ebe5a;
    transform: translateY(-1px);
}

.btn-pix {
    background: linear-gradient(135deg, #32bcad, #00b4a0);
    color: white;
    box-shadow: 0 4px 12px rgba(0, 180, 160, 0.3);
}

.btn-pix:hover {
    box-shadow: 0 6px 20px rgba(0, 180, 160, 0.5);
    transform: translateY(-1px);
}

.btn:disabled {
    opacity: 0.5;
    pointer-events: none;
}

/* ── Forms ── */
.form-group {
    margin-bottom: 1rem;
}

.form-label {
    display: block;
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: 0.35rem;
}

.form-input,
.form-select,
.form-textarea {
    width: 100%;
    padding: 0.65rem 0.85rem;
    background: rgba(15, 18, 35, 0.5);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text);
    font-family: inherit;
    font-size: 0.875rem;
    transition: var(--transition);
    outline: none;
}

.form-input:focus,
.form-select:focus,
.form-textarea:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.1);
}

.form-input::placeholder { color: var(--text-muted); }

.form-textarea {
    min-height: 80px;
    resize: vertical;
}

.form-select {
    cursor: pointer;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%2394a3b8' stroke-width='2'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 0.75rem center;
    padding-right: 2rem;
}

.form-select option {
    background: var(--bg-dark);
    color: var(--text);
}

.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
}

.form-row-3 {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    gap: 1rem;
}

.form-hint {
    font-size: 0.7rem;
    color: var(--text-muted);
    margin-top: 0.25rem;
}

.form-error {
    font-size: 0.7rem;
    color: var(--danger);
    margin-top: 0.25rem;
}

/* ── Modals ── */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(4px);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    padding: 1rem;
    animation: fadeIn 0.2s var(--ease);
}

.modal-overlay.active {
    display: flex;
}

.modal {
    background: var(--surface);
    backdrop-filter: var(--blur);
    -webkit-backdrop-filter: var(--blur);
    border: 1px solid var(--border);
    border-radius: var(--radius-xl);
    width: 100%;
    max-width: 560px;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: var(--shadow-lg);
    animation: modalSlide 0.3s var(--ease);
}

.modal-lg { max-width: 720px; }

@keyframes modalSlide {
    from { opacity: 0; transform: translateY(20px) scale(0.97); }
    to { opacity: 1; transform: translateY(0) scale(1); }
}

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1.25rem 1.5rem;
    border-bottom: 1px solid var(--border);
}

.modal-title {
    font-size: 1.1rem;
    font-weight: 700;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.modal-close {
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    padding: 0.35rem;
    border-radius: var(--radius-sm);
    transition: var(--transition);
    display: flex;
}

.modal-close:hover {
    background: var(--danger-bg);
    color: var(--danger);
}

.modal-body {
    padding: 1.5rem;
}

.modal-footer {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 0.75rem;
    padding: 1rem 1.5rem;
    border-top: 1px solid var(--border);
}

/* ── Tables ── */
.table-container {
    overflow-x: auto;
    border-radius: var(--radius-lg);
    border: 1px solid var(--border);
    background: var(--surface);
    backdrop-filter: var(--blur);
    -webkit-backdrop-filter: var(--blur);
}

.data-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.85rem;
}

.data-table thead th {
    background: rgba(15, 18, 35, 0.5);
    padding: 0.75rem 1rem;
    text-align: left;
    font-weight: 600;
    color: var(--text-secondary);
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    border-bottom: 1px solid var(--border);
    white-space: nowrap;
}

.data-table tbody tr {
    transition: var(--transition);
    border-bottom: 1px solid var(--border-light);
}

.data-table tbody tr:last-child { border-bottom: none; }

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

.data-table tbody td {
    padding: 0.75rem 1rem;
    vertical-align: middle;
}

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

/* ── Badges ── */
.badge {
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
    padding: 0.2rem 0.6rem;
    border-radius: 20px;
    font-size: 0.7rem;
    font-weight: 600;
    white-space: nowrap;
}

.badge-success {
    background: var(--success-bg);
    color: var(--success-light);
}

.badge-warning {
    background: var(--warning-bg);
    color: var(--warning-light);
}

.badge-danger {
    background: var(--danger-bg);
    color: var(--danger-light);
    animation: pulse-badge 2s ease infinite;
}

.badge-info {
    background: var(--info-bg);
    color: var(--info);
}

.badge-neutral {
    background: rgba(100, 116, 139, 0.12);
    color: var(--text-muted);
}

/* ── Search Bar ── */
.search-bar {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    flex-wrap: wrap;
}

.search-input-wrap {
    position: relative;
    flex: 1;
    min-width: 200px;
}

.search-input-wrap svg {
    position: absolute;
    left: 0.75rem;
    top: 50%;
    transform: translateY(-50%);
    width: 18px;
    height: 18px;
    color: var(--text-muted);
    pointer-events: none;
}

.search-input-wrap .form-input {
    padding-left: 2.5rem;
}

.filter-group {
    display: flex;
    gap: 0;
    background: rgba(15, 18, 35, 0.4);
    border-radius: var(--radius-md);
    border: 1px solid var(--border);
    overflow: hidden;
}

.filter-btn {
    padding: 0.45rem 0.85rem;
    background: transparent;
    border: none;
    border-right: 1px solid var(--border);
    border-radius: 0;
    color: var(--text-muted);
    font-size: 0.78rem;
    font-weight: 500;
    cursor: pointer;
    transition: var(--transition);
    font-family: inherit;
    white-space: nowrap;
}

.filter-btn:last-child {
    border-right: none;
}

.filter-btn:hover {
    background: var(--surface-hover);
    color: var(--text);
}

.filter-btn.active {
    background: linear-gradient(135deg, rgba(99, 102, 241, 0.2), rgba(139, 92, 246, 0.15));
    color: var(--primary-light);
    font-weight: 600;
    box-shadow: inset 0 1px 0 rgba(99, 102, 241, 0.2);
}

/* ── Empty State ── */
.empty-state {
    text-align: center;
    padding: 3rem 1rem;
    color: var(--text-muted);
}

.empty-state svg {
    width: 64px;
    height: 64px;
    margin-bottom: 1rem;
    opacity: 0.3;
}

.empty-state h3 {
    font-size: 1.1rem;
    color: var(--text-secondary);
    margin-bottom: 0.35rem;
}

.empty-state p {
    font-size: 0.85rem;
}

/* ── QR Code Modal ── */
.qr-container {
    text-align: center;
    padding: 1rem 0;
}

.qr-container img {
    max-width: 256px;
    border-radius: var(--radius-md);
    border: 2px solid var(--border);
    margin-bottom: 1rem;
}

.pix-copy-area {
    background: rgba(15, 18, 35, 0.5);
    border: 1px dashed var(--border);
    border-radius: var(--radius-sm);
    padding: 0.75rem;
    margin: 1rem 0;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.pix-copy-area code {
    flex: 1;
    word-break: break-all;
    font-size: 0.75rem;
    color: var(--text-secondary);
}

/* ── Chart Area ── */
.chart-container {
    padding: 1rem 0;
}

.chart-bar-group {
    display: flex;
    align-items: flex-end;
    gap: 2px;
    height: 120px;
    padding: 0 0.25rem;
}

.chart-bar {
    flex: 1;
    border-radius: 3px 3px 0 0;
    min-height: 4px;
    transition: var(--transition);
    position: relative;
}

.chart-bar:hover {
    opacity: 0.8;
}

.chart-bar.paid { background: var(--success); }
.chart-bar.pending { background: var(--warning); }
.chart-bar.overdue { background: var(--danger); }

.chart-legend {
    display: flex;
    justify-content: center;
    gap: 1.5rem;
    margin-top: 0.75rem;
    font-size: 0.75rem;
    color: var(--text-secondary);
}

.chart-legend-item {
    display: flex;
    align-items: center;
    gap: 0.35rem;
}

.chart-legend-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
}

.chart-legend-dot.paid { background: var(--success); }
.chart-legend-dot.pending { background: var(--warning); }
.chart-legend-dot.overdue { background: var(--danger); }

/* ── Upcoming List ── */
.upcoming-list {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.upcoming-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem;
    border-radius: var(--radius-sm);
    background: var(--surface-light);
    border: 1px solid var(--border-light);
    transition: var(--transition);
    cursor: pointer;
}

.upcoming-item:hover {
    border-color: var(--border-hover);
    background: var(--surface-hover);
}

.upcoming-date {
    display: flex;
    flex-direction: column;
    align-items: center;
    min-width: 45px;
    font-weight: 700;
    line-height: 1;
}

.upcoming-date .day {
    font-size: 1.3rem;
    color: var(--primary-light);
}

.upcoming-date .month {
    font-size: 0.6rem;
    color: var(--text-muted);
    text-transform: uppercase;
    margin-top: 2px;
}

.upcoming-info { flex: 1; }

.upcoming-name {
    font-size: 0.85rem;
    font-weight: 600;
}

.upcoming-desc {
    font-size: 0.72rem;
    color: var(--text-muted);
}

.upcoming-value {
    font-weight: 700;
    font-size: 0.9rem;
    color: var(--success);
}

/* ── Installment Preview ── */
.installment-preview {
    background: var(--surface-light);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: 1rem;
    margin-top: 1rem;
}

.installment-preview h4 {
    font-size: 0.8rem;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 0.75rem;
}

.installment-preview-list {
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
}

.installment-preview-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.5rem 0.75rem;
    background: rgba(15, 18, 35, 0.4);
    border-radius: var(--radius-sm);
    font-size: 0.8rem;
}

.installment-preview-item .ipn {
    color: var(--text-muted);
    font-weight: 600;
    min-width: 30px;
}

.installment-preview-item .ipd {
    color: var(--text-secondary);
    flex: 1;
    text-align: center;
}

.installment-preview-item .ipv {
    color: var(--success-light);
    font-weight: 700;
}

/* ── Toast ── */
.toast-container {
    position: fixed;
    top: 1.5rem;
    right: 1.5rem;
    z-index: 2000;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.toast {
    background: var(--surface);
    backdrop-filter: var(--blur);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: 0.85rem 1.25rem;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    min-width: 280px;
    max-width: 420px;
    box-shadow: var(--shadow-lg);
    animation: toastIn 0.4s var(--ease);
    font-size: 0.85rem;
}

.toast.success { border-left: 3px solid var(--success); }
.toast.error { border-left: 3px solid var(--danger); }
.toast.warning { border-left: 3px solid var(--warning); }
.toast.info { border-left: 3px solid var(--info); }

@keyframes toastIn {
    from { opacity: 0; transform: translateX(40px); }
    to { opacity: 1; transform: translateX(0); }
}

.toast-exit {
    animation: toastOut 0.3s var(--ease) forwards;
}

@keyframes toastOut {
    to { opacity: 0; transform: translateX(40px); }
}

/* ── Login Screen ── */
.login-screen {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1rem;
}

.login-card {
    background: var(--surface);
    backdrop-filter: var(--blur);
    -webkit-backdrop-filter: var(--blur);
    border: 1px solid var(--border);
    border-radius: var(--radius-xl);
    padding: 2.5rem;
    width: 100%;
    max-width: 400px;
    box-shadow: var(--shadow-lg), var(--shadow-glow);
    text-align: center;
}

.login-brand {
    display: flex;
    flex-direction: column;
    align-items: center;
    margin-bottom: 2rem;
}

.login-brand .brand-icon {
    width: 64px;
    height: 64px;
    background: linear-gradient(135deg, var(--primary), var(--violet));
    border-radius: var(--radius-lg);
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 1rem;
    box-shadow: 0 8px 24px rgba(99, 102, 241, 0.3);
    font-size: 1.8rem;
}

.login-brand h1 {
    font-size: 1.6rem;
    font-weight: 800;
    background: linear-gradient(135deg, var(--primary-light), var(--violet-light));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.login-brand p {
    font-size: 0.85rem;
    color: var(--text-muted);
    margin-top: 0.3rem;
}

.login-card .form-group { text-align: left; }

.login-card .btn-primary {
    width: 100%;
    padding: 0.75rem;
    margin-top: 0.5rem;
}

.login-divider {
    display: flex;
    align-items: center;
    gap: 1rem;
    margin: 1.5rem 0;
    font-size: 0.75rem;
    color: var(--text-muted);
}

.login-divider::before,
.login-divider::after {
    content: '';
    flex: 1;
    height: 1px;
    background: var(--border);
}

.login-link {
    color: var(--primary-light);
    cursor: pointer;
    font-size: 0.85rem;
    transition: var(--transition);
    background: none;
    border: none;
    font-family: inherit;
    text-decoration: underline;
    text-underline-offset: 2px;
}

.login-link:hover { color: var(--violet-light); }

/* ── Confirm Delete Modal ── */
.confirm-text {
    font-size: 0.9rem;
    line-height: 1.6;
    color: var(--text-secondary);
    text-align: center;
    padding: 1rem 0;
}

.confirm-text strong {
    color: var(--text);
}

/* ── Responsive ── */
@media (max-width: 768px) {
    .sidebar-nav {
        position: fixed;
        bottom: 0;
        left: 0;
        right: 0;
        top: auto;
        width: 100%;
        height: auto;
        flex-direction: row;
        border-right: none;
        border-top: 1px solid var(--border);
        overflow-y: visible;
        overflow-x: auto;
    }

    .sidebar-brand,
    .nav-section-label,
    .nav-footer { display: none; }

    .nav-section {
        display: flex;
        flex-direction: row;
        justify-content: space-around;
        padding: 0.35rem 0.5rem;
        width: 100%;
        gap: 0;
    }

    .nav-item {
        flex-direction: column;
        font-size: 0.6rem;
        padding: 0.45rem 0.5rem;
        gap: 0.2rem;
        text-align: center;
        margin-bottom: 0;
    }

    .nav-item .nav-icon {
        width: 22px;
        height: 22px;
    }

    .nav-item .nav-badge {
        position: absolute;
        top: 2px;
        right: 2px;
        margin-left: 0;
        font-size: 0.55rem;
        padding: 0.1rem 0.3rem;
    }

    .nav-item.active {
        box-shadow: inset 0 3px 0 var(--primary);
    }

    .nav-item .nav-text-hide { display: none; }

    .main-content {
        margin-left: 0;
        max-width: 100%;
        padding: 1.25rem;
        padding-bottom: calc(var(--bottom-nav-height) + 1.5rem);
    }

    .page-header {
        flex-direction: column;
        align-items: flex-start;
        padding-top: 3.5rem; /* Push below top user bar on mobile */
    }

    .kpi-grid {
        grid-template-columns: repeat(2, 1fr);
    }

    .form-row,
    .form-row-3 {
        grid-template-columns: 1fr;
    }

    .modal {
        max-height: 85vh;
        margin: auto 0.5rem;
    }

    .search-bar {
        flex-direction: column;
    }

    .filter-group {
        width: 100%;
        overflow-x: auto;
    }

    .data-table {
        font-size: 0.78rem;
    }

    .data-table thead th,
    .data-table tbody td {
        padding: 0.6rem 0.65rem;
    }
}

@media (max-width: 480px) {
    .kpi-grid {
        grid-template-columns: 1fr;
    }

    .kpi-card {
        padding: 1rem;
    }

    .kpi-value {
        font-size: 1.3rem;
    }

    .page-title {
        font-size: 1.2rem;
    }
}

/* ── Utilities ── */
.text-center { text-align: center; }
.text-right { text-align: right; }
.text-muted { color: var(--text-muted); }
.text-success { color: var(--success); }
.text-danger { color: var(--danger); }
.text-warning { color: var(--warning); }
.font-mono { font-family: 'SF Mono', 'Fira Code', monospace; }
.mt-1 { margin-top: 0.5rem; }
.mt-2 { margin-top: 1rem; }
.mb-1 { margin-bottom: 0.5rem; }
.mb-2 { margin-bottom: 1rem; }
.flex { display: flex; }
.flex-center { display: flex; align-items: center; justify-content: center; }
.gap-1 { gap: 0.5rem; }
.gap-2 { gap: 1rem; }
.hidden { display: none !important; }
.w-full { width: 100%; }

/* ── Loading Spinner ── */
.spinner {
    width: 20px;
    height: 20px;
    border: 2px solid rgba(255,255,255,0.2);
    border-top-color: white;
    border-radius: 50%;
    animation: spin 0.6s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* ── Pulse animation for overdue ── */
.overdue-pulse {
    animation: overdue-glow 2s ease infinite;
}

@keyframes overdue-glow {
    0%, 100% { background-color: var(--danger-bg); }
    50% { background-color: rgba(239, 68, 68, 0.25); }
}

/* ═══════════════════════════════════════════
   B2B DASHBOARD STYLES
   ═══════════════════════════════════════════ */

/* ── KPI Grid ── */
.b2b-kpi-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 1.25rem;
    margin-bottom: 0.5rem;
}

.b2b-kpi-card {
    position: relative;
    background: var(--surface);
    backdrop-filter: var(--blur);
    -webkit-backdrop-filter: var(--blur);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 1.5rem 1.25rem;
    display: flex;
    align-items: center;
    gap: 1rem;
    overflow: hidden;
    transition: var(--transition);
    animation: b2bKpiEnter 0.5s var(--ease) both;
}

.b2b-kpi-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 3px;
    background: linear-gradient(90deg, var(--kpi-accent, var(--primary)), transparent);
    opacity: 0.7;
}

.b2b-kpi-card:hover {
    border-color: var(--kpi-accent, var(--border-hover));
    transform: translateY(-3px);
    box-shadow: 0 8px 30px rgba(0, 0, 0, 0.3), 0 0 20px color-mix(in srgb, var(--kpi-accent, var(--primary)) 15%, transparent);
}

.b2b-kpi-glow {
    position: absolute;
    top: -50%;
    right: -30%;
    width: 200px;
    height: 200px;
    border-radius: 50%;
    pointer-events: none;
    opacity: 0.5;
    transition: opacity 0.3s ease;
}

.b2b-kpi-card:hover .b2b-kpi-glow {
    opacity: 1;
}

.b2b-kpi-icon {
    width: 52px;
    height: 52px;
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    background: color-mix(in srgb, var(--kpi-accent, var(--primary)) 12%, transparent);
    color: var(--kpi-accent, var(--primary-light));
    transition: var(--transition);
}

.b2b-kpi-card:hover .b2b-kpi-icon {
    transform: scale(1.08);
    background: color-mix(in srgb, var(--kpi-accent, var(--primary)) 20%, transparent);
}

.b2b-kpi-icon svg {
    width: 26px;
    height: 26px;
}

.b2b-kpi-content {
    display: flex;
    flex-direction: column;
    position: relative;
    z-index: 1;
}

.b2b-kpi-value {
    font-size: 1.75rem;
    font-weight: 800;
    line-height: 1.15;
    letter-spacing: -0.5px;
    color: var(--text);
}

.b2b-kpi-label {
    font-size: 0.78rem;
    color: var(--text-secondary);
    font-weight: 500;
    margin-top: 0.2rem;
    letter-spacing: 0.2px;
}

@keyframes b2bKpiEnter {
    from {
        opacity: 0;
        transform: translateY(16px) scale(0.97);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

/* ── Chart ── */
.b2b-chart-wrapper {
    display: flex;
    align-items: flex-end;
    gap: 8px;
    padding: 0 0.5rem;
    min-height: 200px;
}

.b2b-chart-col {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    animation: b2bChartSlideUp 0.6s var(--ease) both;
}

.b2b-chart-bars {
    display: flex;
    flex-direction: column;
    align-items: center;
    width: 100%;
    height: 180px;
    justify-content: flex-end;
    gap: 2px;
}

.b2b-chart-bar {
    width: 65%;
    min-height: 4px;
    border-radius: 4px 4px 2px 2px;
    transition: height 0.6s var(--ease), opacity 0.3s ease;
    cursor: pointer;
    position: relative;
}

.b2b-chart-bar:hover {
    opacity: 0.85;
    filter: brightness(1.2);
}

.b2b-chart-bar::after {
    content: attr(title);
    position: absolute;
    bottom: calc(100% + 8px);
    left: 50%;
    transform: translateX(-50%);
    background: var(--bg-dark);
    color: var(--text);
    font-size: 0.65rem;
    padding: 4px 8px;
    border-radius: 6px;
    white-space: nowrap;
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.2s ease;
    border: 1px solid var(--border);
    z-index: 10;
}

.b2b-chart-bar:hover::after {
    opacity: 1;
}

.b2b-chart-bar.paid {
    background: linear-gradient(to top, #16a34a, #22c55e);
    box-shadow: 0 0 8px rgba(34, 197, 94, 0.2);
}

.b2b-chart-bar.pending {
    background: linear-gradient(to top, #d97706, #f59e0b);
    box-shadow: 0 0 8px rgba(245, 158, 11, 0.2);
}

.b2b-chart-bar.overdue {
    background: linear-gradient(to top, #dc2626, #ef4444);
    box-shadow: 0 0 8px rgba(239, 68, 68, 0.2);
}

.b2b-chart-label {
    font-size: 0.72rem;
    color: var(--text-muted);
    margin-top: 0.5rem;
    font-weight: 500;
    text-align: center;
}

.b2b-chart-label.current {
    color: var(--primary-light);
    font-weight: 700;
    position: relative;
}

.b2b-chart-label.current::before {
    content: '●';
    font-size: 0.5rem;
    position: absolute;
    top: -6px;
    left: 50%;
    transform: translateX(-50%);
    color: var(--primary-light);
}

.b2b-chart-total {
    font-size: 0.62rem;
    color: var(--text-muted);
    margin-top: 0.15rem;
    opacity: 0.7;
    font-weight: 600;
    text-align: center;
}

.b2b-chart-legend {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 1.5rem;
    margin-top: 1.25rem;
    padding-top: 1rem;
    border-top: 1px solid var(--border);
}

.b2b-legend-item {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    font-size: 0.75rem;
    color: var(--text-secondary);
    font-weight: 500;
}

.b2b-legend-dot {
    width: 10px;
    height: 10px;
    border-radius: 3px;
    flex-shrink: 0;
}

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

/* ── B2B Dashboard Responsive ── */
@media (max-width: 1100px) {
    .b2b-kpi-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (max-width: 640px) {
    .b2b-kpi-grid {
        grid-template-columns: 1fr;
    }
    
    .b2b-kpi-card {
        padding: 1rem;
    }
    
    .b2b-kpi-value {
        font-size: 1.4rem;
    }
    
    .b2b-chart-bars {
        height: 140px;
    }
    
    .b2b-chart-bar {
        width: 80%;
    }
}
