/* =============================================
   CLÍNICA AGNP - Sistema de Gestão v2.0
   CSS Principal
   ============================================= */

:root {
    /* Colors - Dark Mode (default) */
    --bg-body: #0f1117;
    --bg-sidebar: #161b27;
    --bg-card: #1e2330;
    --bg-card-hover: #252b3b;
    --bg-input: #252b3b;
    --bg-table-header: #1a1f2e;
    --bg-table-row: #1e2330;
    --bg-table-alt: #222840;
    --bg-table-hover: #2a3050;

    --text-primary: #e8ecf4;
    --text-secondary: #8b95ad;
    --text-muted: #5a6378;
    --text-accent: #7c6af5;
    --text-reciept: #e5e4e2;

    --border-color: #2e3548;
    --border-focus: #7c6af5;

    --agnes-color: #3b82f6;
    --agnes-light: rgba(59, 130, 246, 0.15);
    --agnes-bg: #1e3a5f;

    --neisy-color: #a855f7;
    --neisy-light: rgba(168, 85, 247, 0.15);
    --neisy-bg: #3b1a5c;

    --total-color: #10b981;
    --total-light: rgba(16, 185, 129, 0.15);

    --success: #10b981;
    --warning: #f59e0b;
    --danger: #ef4444;
    --info: #3b82f6;

    --shadow-sm: 0 2px 8px rgba(0,0,0,0.3);
    --shadow-md: 0 4px 20px rgba(0,0,0,0.4);
    --shadow-lg: 0 8px 40px rgba(0,0,0,0.5);

    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 16px;

    --sidebar-width: 240px;
    --topbar-height: 64px;

    --transition: all 0.2s ease;
}

.light-mode {
    --bg-body: #f1f4f9;
    --bg-sidebar: #ffffff;
    --bg-card: #ffffff;
    --bg-card-hover: #f8faff;
    --bg-input: #f1f4f9;
    --bg-table-header: #f8faff;
    --bg-table-row: #ffffff;
    --bg-table-alt: #f8faff;
    --bg-table-hover: #eef2ff;

    --text-primary: #1a1f36;
    --text-secondary: #4a5568;
    --text-muted: #8896a5;
    --text-accent: #6c5ce7;
    --text-reciept: #1a1a2e;

    --border-color: #e2e8f0;
    --border-focus: #6c5ce7;

    --agnes-light: rgba(59, 130, 246, 0.1);
    --agnes-bg: #dbeafe;
    --neisy-light: rgba(168, 85, 247, 0.1);
    --neisy-bg: #ede9fe;
    --total-light: rgba(16, 185, 129, 0.1);

    --shadow-sm: 0 2px 8px rgba(0,0,0,0.06);
    --shadow-md: 0 4px 20px rgba(0,0,0,0.08);
    --shadow-lg: 0 8px 40px rgba(0,0,0,0.12);
}

/* =============================================
   RESET & BASE
   ============================================= */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html { scroll-behavior: smooth; }

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    background: var(--bg-body);
    color: var(--text-primary);
    display: flex;
    min-height: 100vh;
    transition: background 0.3s ease, color 0.3s ease;
    overflow-x: hidden;
}

/* =============================================
   SIDEBAR
   ============================================= */
.sidebar {
    width: var(--sidebar-width);
    background: var(--bg-sidebar);
    border-right: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0; left: 0; bottom: 0;
    z-index: 1000;
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1), background 0.3s;
    overflow-y: auto;
    overflow-x: hidden;
}

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

.brand-logo {
    width: 44px; height: 44px;
    background: linear-gradient(135deg, var(--agnes-color), var(--neisy-color));
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.25rem;
    color: white;
    flex-shrink: 0;
    box-shadow: 0 4px 12px rgba(124, 106, 245, 0.4);
}

.brand-text h1 {
    font-size: 1.05rem;
    font-weight: 700;
    color: var(--text-primary);
    line-height: 1.2;
}

.brand-text p {
    font-size: 0.72rem;
    color: var(--text-secondary);
    line-height: 1.2;
}

.sidebar-nav {
    padding: 1rem 0.75rem;
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.7rem 0.9rem;
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
    text-decoration: none;
    font-size: 0.88rem;
    font-weight: 500;
    transition: var(--transition);
    position: relative;
}

.nav-item i {
    width: 18px;
    text-align: center;
    font-size: 0.95rem;
    flex-shrink: 0;
}

.nav-item span { flex: 1; }

.nav-badge {
    font-size: 0.65rem;
    background: var(--bg-card);
    color: var(--text-accent);
    padding: 0.15rem 0.45rem;
    border-radius: 20px;
    font-weight: 600;
    border: 1px solid var(--border-color);
}

.nav-item:hover {
    background: var(--bg-card);
    color: var(--text-primary);
}

.nav-item.active {
    background: linear-gradient(135deg, rgba(124, 106, 245, 0.15), rgba(168, 85, 247, 0.1));
    color: var(--text-accent);
    border: 1px solid rgba(124, 106, 245, 0.2);
}

.nav-item.active i { color: var(--text-accent); }

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

.theme-toggle {
    width: 100%;
    display: flex;
    align-items: center;
    gap: 0.6rem;
    padding: 0.6rem 0.9rem;
    background: var(--bg-input);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
    font-size: 0.82rem;
    cursor: pointer;
    transition: var(--transition);
}

.theme-toggle:hover { color: var(--text-primary); background: var(--bg-card-hover); }

.version {
    font-size: 0.7rem;
    color: var(--text-muted);
    text-align: center;
    margin-top: 0.5rem;
}

/* =============================================
   MAIN CONTENT
   ============================================= */
.main-content {
    margin-left: var(--sidebar-width);
    flex: 1;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    transition: margin-left 0.3s ease;
}

/* =============================================
   TOPBAR
   ============================================= */
.topbar {
    height: var(--topbar-height);
    background: var(--bg-card);
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 0 1.5rem;
    position: sticky;
    top: 0;
    z-index: 100;
    transition: background 0.3s;
}

.menu-toggle {
    display: none;
    background: none;
    border: none;
    color: var(--text-primary);
    font-size: 1.1rem;
    cursor: pointer;
    padding: 0.4rem;
    border-radius: var(--radius-sm);
    transition: var(--transition);
}

.menu-toggle:hover { background: var(--bg-input); }

.topbar-title {
    font-size: 1rem;
    font-weight: 600;
    color: var(--text-primary);
    flex: 1;
}

.topbar-date {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.82rem;
    color: var(--text-secondary);
}

/* =============================================
   PAGES
   ============================================= */
.page {
    display: none;
    padding: 1.75rem 1.5rem;
    flex: 1;
    animation: fadeIn 0.25s ease;
}

.page.active { display: block; }

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

.page-header {
    margin-bottom: 1.75rem;
}

.page-header h2 {
    font-size: 1.6rem;
    font-weight: 800;
    color: var(--text-primary);
    line-height: 1.2;
}

.page-header p {
    font-size: 0.9rem;
    color: var(--text-secondary);
    margin-top: 0.25rem;
}

.text-accent { color: var(--text-accent); }

/* =============================================
   KPI CARDS
   ============================================= */
.kpi-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.kpi-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: 1.25rem 1.5rem;
    display: flex;
    align-items: center;
    gap: 1rem;
    transition: var(--transition);
    position: relative;
    overflow: hidden;
}

.kpi-card::before {
    content: '';
    position: absolute;
    top: 0; left: 0; right: 0;
    height: 3px;
}

.kpi-card:hover {
    background: var(--bg-card-hover);
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

.kpi-agnes::before { background: linear-gradient(90deg, var(--agnes-color), #60a5fa); }
.kpi-neisy::before { background: linear-gradient(90deg, var(--neisy-color), #c084fc); }
.kpi-total::before { background: linear-gradient(90deg, var(--total-color), #34d399); }
.kpi-clientes::before { background: linear-gradient(90deg, var(--warning), #fbbf24); }

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

.kpi-agnes .kpi-icon { background: var(--agnes-light); color: var(--agnes-color); }
.kpi-neisy .kpi-icon { background: var(--neisy-light); color: var(--neisy-color); }
.kpi-total .kpi-icon { background: var(--total-light); color: var(--total-color); }
.kpi-clientes .kpi-icon { background: rgba(245, 158, 11, 0.15); color: var(--warning); }

.kpi-info { display: flex; flex-direction: column; gap: 0.15rem; }
.kpi-label { font-size: 0.78rem; color: var(--text-secondary); font-weight: 500; }
.kpi-value { font-size: 1.35rem; font-weight: 800; color: var(--text-primary); }
.kpi-sub { font-size: 0.72rem; color: var(--text-muted); }

/* =============================================
   CHARTS
   ============================================= */
.charts-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.chart-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: 1.25rem;
}

.chart-card-header {
    margin-bottom: 1rem;
}

.chart-card-header h3 {
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--text-secondary);
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.chart-container { position: relative; }

/* =============================================
   SECTION CARDS
   ============================================= */
.section-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: 1.25rem;
    transition: background 0.3s;
}

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

.section-card-header h3 {
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--text-primary);
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.section-card-header h3 i { color: var(--text-accent); }

/* =============================================
   TABLES
   ============================================= */
.table-wrapper {
    overflow-x: auto;
    border-radius: var(--radius-sm);
}

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

.data-table thead tr {
    background: var(--bg-table-header);
}

.data-table th {
    padding: 0.7rem 0.9rem;
    text-align: left;
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.03em;
    border-bottom: 1px solid var(--border-color);
    white-space: nowrap;
}

.data-table td {
    padding: 0.7rem 0.9rem;
    border-bottom: 1px solid var(--border-color);
    color: var(--text-primary);
    vertical-align: middle;
}

.data-table tbody tr:nth-child(even) { background: var(--bg-table-alt); }
.data-table tbody tr:hover { background: var(--bg-table-hover); }

.empty-row {
    text-align: center;
    color: var(--text-muted);
    padding: 2.5rem !important;
    font-size: 0.9rem;
}

.empty-row i { margin-right: 0.5rem; font-size: 1.1rem; }

/* TYPE BADGES */
.badge {
    padding: 0.25rem 0.6rem;
    border-radius: 20px;
    font-size: 0.72rem;
    font-weight: 600;
    white-space: nowrap;
}

.badge-maquina { background: var(--agnes-light); color: var(--agnes-color); }
.badge-atendimento { background: var(--neisy-light); color: var(--neisy-color); }

/* =============================================
   FORMS
   ============================================= */
.form-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
}

.form-group { display: flex; flex-direction: column; gap: 0.4rem; }
.form-group.full-width { grid-column: 1 / -1; }

.form-group label {
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--text-secondary);
    display: flex;
    align-items: center;
    gap: 0.4rem;
}

.form-group label i { color: var(--text-accent); font-size: 0.85rem; }

.form-group input,
.form-group textarea,
.form-group select {
    background: var(--bg-input);
    border: 1.5px solid var(--border-color);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-family: inherit;
    font-size: 0.88rem;
    padding: 0.65rem 0.9rem;
    outline: none;
    transition: var(--transition);
    width: 100%;
}

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

.form-group input:focus,
.form-group textarea:focus,
.form-group select:focus {
    border-color: var(--border-focus);
    background: var(--bg-card-hover);
    box-shadow: 0 0 0 3px rgba(124, 106, 245, 0.1);
}

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

.form-group 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 12 12'%3E%3Cpath fill='%238b95ad' d='M6 8L1 3h10z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 0.9rem center;
    padding-right: 2.5rem;
}

.form-actions {
    grid-column: 1 / -1;
    display: flex;
    justify-content: flex-end;
    gap: 0.75rem;
    padding-top: 0.5rem;
    border-top: 1px solid var(--border-color);
    margin-top: 0.5rem;
}

/* Calculated Display */
.calc-display {
    background: var(--bg-input);
    border: 1.5px solid var(--border-color);
    border-radius: var(--radius-sm);
    color: var(--total-color);
    font-size: 0.95rem;
    font-weight: 700;
    padding: 0.65rem 0.9rem;
}

/* =============================================
   BUTTONS
   ============================================= */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.6rem 1.2rem;
    border-radius: var(--radius-sm);
    font-family: inherit;
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    border: none;
    transition: var(--transition);
    text-decoration: none;
    white-space: nowrap;
}

.btn:active { transform: scale(0.97); }

.btn-primary {
    background: linear-gradient(135deg, #6c5ce7, #a855f7);
    color: white;
    box-shadow: 0 4px 12px rgba(108, 92, 231, 0.35);
}

.btn-primary:hover {
    background: linear-gradient(135deg, #5b4cce, #9741e0);
    box-shadow: 0 4px 16px rgba(108, 92, 231, 0.5);
    transform: translateY(-1px);
}

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

.btn-success:hover {
    background: linear-gradient(135deg, #047857, #059669);
    transform: translateY(-1px);
}

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

.btn-ghost:hover { background: var(--bg-card-hover); color: var(--text-primary); }

.btn-outline {
    background: transparent;
    color: var(--text-accent);
    border: 1.5px solid var(--text-accent);
}

.btn-outline:hover { background: rgba(124, 106, 245, 0.1); }

.btn-danger { background: var(--danger); color: white; }
.btn-danger:hover { background: #dc2626; }

.btn-sm { padding: 0.4rem 0.8rem; font-size: 0.78rem; }

/* ACTION BUTTONS in table */
.action-btns { display: flex; gap: 0.4rem; flex-wrap: wrap; }

.btn-icon {
    width: 30px; height: 30px;
    display: flex; align-items: center; justify-content: center;
    border-radius: var(--radius-sm);
    border: none; cursor: pointer;
    font-size: 0.8rem;
    transition: var(--transition);
}

.btn-icon-edit { background: var(--agnes-light); color: var(--agnes-color); }
.btn-icon-edit:hover { background: var(--agnes-color); color: white; }

.btn-icon-delete { background: rgba(239, 68, 68, 0.1); color: var(--danger); }
.btn-icon-delete:hover { background: var(--danger); color: white; }

.btn-icon-pdf-a { background: var(--agnes-light); color: var(--agnes-color); }
.btn-icon-pdf-a:hover { background: var(--agnes-color); color: white; }

.btn-icon-pdf-n { background: var(--neisy-light); color: var(--neisy-color); }
.btn-icon-pdf-n:hover { background: var(--neisy-color); color: white; }

/* =============================================
   RATEIO CARDS
   ============================================= */
.rateio-card {
    background: var(--bg-body);
    border: 1.5px solid var(--border-color);
    border-radius: var(--radius-md);
    overflow: hidden;
}

.rateio-header {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    padding: 0.75rem 1rem;
    background: linear-gradient(135deg, rgba(124, 106, 245, 0.1), rgba(168, 85, 247, 0.1));
    border-bottom: 1px solid var(--border-color);
    font-size: 0.82rem;
    font-weight: 600;
    color: var(--text-accent);
}

.rateio-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0;
}

.rateio-item {
    padding: 1rem;
    text-align: center;
    transition: var(--transition);
}

.rateio-item:first-child { border-right: 1px solid var(--border-color); }

.rateio-agnes { background: rgba(59, 130, 246, 0.06); }
.rateio-neisy { background: rgba(168, 85, 247, 0.06); }

.rateio-label {
    font-size: 0.78rem;
    color: var(--text-secondary);
    margin-bottom: 0.4rem;
    font-weight: 500;
}

.rateio-value {
    font-size: 1.3rem;
    font-weight: 800;
}

.rateio-agnes .rateio-value { color: var(--agnes-color); }
.rateio-neisy .rateio-value { color: var(--neisy-color); }

/* Rateio Atendimento */
.rateio-table { padding: 0.5rem 0; }

.rateio-row {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr 1fr;
    padding: 0.6rem 1rem;
    font-size: 0.82rem;
    border-bottom: 1px solid var(--border-color);
    align-items: center;
}

.rateio-row:last-child { border-bottom: none; }

.header-row {
    font-size: 0.72rem;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

.agnes-row { background: rgba(59, 130, 246, 0.05); color: var(--agnes-color); }
.neisy-row { background: rgba(168, 85, 247, 0.05); color: var(--neisy-color); }

.rateio-total { font-weight: 700; }

.rateio-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.75rem 1rem;
    background: rgba(16, 185, 129, 0.08);
    border-top: 1px solid var(--border-color);
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-secondary);
}

.rateio-grand-total { font-size: 1.1rem; color: var(--total-color); font-weight: 800; }

/* =============================================
   INFO STEPS
   ============================================= */
.info-steps { display: flex; flex-direction: column; gap: 0.75rem; }

.info-step {
    display: flex;
    align-items: flex-start;
    gap: 0.75rem;
}

.step-num {
    width: 28px; height: 28px;
    background: linear-gradient(135deg, var(--agnes-color), var(--neisy-color));
    color: white;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.72rem;
    font-weight: 700;
    flex-shrink: 0;
}

.step-text {
    font-size: 0.82rem;
    color: var(--text-secondary);
    line-height: 1.5;
}

.step-text strong { color: var(--text-primary); }
.step-text small { color: var(--text-muted); }

.divider {
    height: 1px;
    background: var(--border-color);
    margin: 1rem 0;
}

.formula-box {
    background: var(--bg-body);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    padding: 1rem;
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
}

.formula-title {
    font-size: 0.78rem;
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: 0.25rem;
}

.formula-box code {
    font-family: 'Courier New', monospace;
    font-size: 0.82rem;
    color: var(--total-color);
    background: rgba(16, 185, 129, 0.08);
    padding: 0.25rem 0.5rem;
    border-radius: 4px;
}

/* Mini Stats */
.mini-stats {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.75rem;
}

.mini-stat {
    background: var(--bg-body);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    padding: 0.75rem;
    text-align: center;
    transition: var(--transition);
}

.mini-stat:hover { border-color: var(--border-focus); }

.agnes-stat { border-color: rgba(59, 130, 246, 0.3); }
.neisy-stat { border-color: rgba(168, 85, 247, 0.3); }

.mini-stat-label {
    display: block;
    font-size: 0.72rem;
    color: var(--text-muted);
    font-weight: 500;
    margin-bottom: 0.3rem;
}

.mini-stat-value {
    display: block;
    font-size: 1rem;
    font-weight: 700;
    color: var(--text-primary);
}

.agnes-stat .mini-stat-value { color: var(--agnes-color); }
.neisy-stat .mini-stat-value { color: var(--neisy-color); }

/* =============================================
   TWO COLUMN LAYOUT
   ============================================= */
.two-col-layout {
    display: grid;
    grid-template-columns: 1.2fr 0.8fr;
    gap: 1.5rem;
    align-items: start;
}

.info-side { position: sticky; top: calc(var(--topbar-height) + 1.5rem); }

/* =============================================
   SEARCH BOX
   ============================================= */
.search-box {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    background: var(--bg-input);
    border: 1.5px solid var(--border-color);
    border-radius: var(--radius-sm);
    padding: 0.4rem 0.75rem;
    transition: var(--transition);
}

.search-box:focus-within {
    border-color: var(--border-focus);
    box-shadow: 0 0 0 3px rgba(124, 106, 245, 0.1);
}

.search-box i { color: var(--text-muted); font-size: 0.82rem; }

.search-box input {
    background: none;
    border: none;
    outline: none;
    color: var(--text-primary);
    font-family: inherit;
    font-size: 0.82rem;
    width: 160px;
}

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

/* =============================================
   CLIENT SEARCH DROPDOWN
   ============================================= */
.client-search-wrapper { position: relative; }

.client-dropdown {
    position: absolute;
    top: calc(100% + 4px);
    left: 0; right: 0;
    background: var(--bg-card);
    border: 1.5px solid var(--border-focus);
    border-radius: var(--radius-sm);
    box-shadow: var(--shadow-lg);
    z-index: 200;
    display: none;
    max-height: 220px;
    overflow-y: auto;
}

.client-dropdown.open { display: block; }

.dropdown-item {
    padding: 0.7rem 0.9rem;
    cursor: pointer;
    font-size: 0.85rem;
    color: var(--text-primary);
    border-bottom: 1px solid var(--border-color);
    transition: var(--transition);
}

.dropdown-item:last-child { border-bottom: none; }
.dropdown-item:hover { background: var(--bg-table-hover); }

.dropdown-item strong { color: var(--text-accent); }
.dropdown-item small { color: var(--text-muted); display: block; font-size: 0.75rem; }

.dropdown-empty {
    padding: 1rem;
    text-align: center;
    color: var(--text-muted);
    font-size: 0.82rem;
}

/* =============================================
   FILTERS BAR
   ============================================= */
.filters-bar {
    display: flex;
    align-items: flex-end;
    gap: 1rem;
    flex-wrap: wrap;
}

.filter-group { display: flex; flex-direction: column; gap: 0.35rem; }

.filter-group label {
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

.filter-group select,
.filter-group input {
    background: var(--bg-input);
    border: 1.5px solid var(--border-color);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-family: inherit;
    font-size: 0.85rem;
    padding: 0.5rem 0.75rem;
    outline: none;
    transition: var(--transition);
}

.filter-group select:focus,
.filter-group input:focus {
    border-color: var(--border-focus);
}

/* =============================================
   PAGINATION
   ============================================= */
.pagination {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 0.4rem;
    padding: 1rem 0 0;
    flex-wrap: wrap;
}

.page-btn {
    min-width: 34px; height: 34px;
    display: flex; align-items: center; justify-content: center;
    border-radius: var(--radius-sm);
    background: var(--bg-input);
    border: 1px solid var(--border-color);
    color: var(--text-secondary);
    font-size: 0.82rem;
    font-weight: 500;
    cursor: pointer;
    transition: var(--transition);
    padding: 0 0.5rem;
}

.page-btn:hover { background: var(--bg-table-hover); color: var(--text-primary); }
.page-btn.active { background: var(--text-accent); color: white; border-color: var(--text-accent); }
.page-btn:disabled { opacity: 0.4; cursor: default; }

/* =============================================
   MODAL
   ============================================= */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.65);
    backdrop-filter: blur(4px);
    z-index: 2000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1rem;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.25s ease;
}

.modal-overlay.open {
    opacity: 1;
    pointer-events: all;
}

.modal {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    width: 100%;
    max-width: 680px;
    max-height: 90vh;
    display: flex;
    flex-direction: column;
    box-shadow: var(--shadow-lg);
    transform: scale(0.95);
    transition: transform 0.25s ease;
}

.modal-overlay.open .modal { transform: scale(1); }

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

.modal-header h3 { font-size: 1rem; font-weight: 700; color: var(--text-primary); }

.modal-close {
    width: 32px; height: 32px;
    background: var(--bg-input);
    border: none;
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
    cursor: pointer;
    font-size: 0.9rem;
    display: flex; align-items: center; justify-content: center;
    transition: var(--transition);
}

.modal-close:hover { background: rgba(239, 68, 68, 0.15); color: var(--danger); }

.modal-body {
    padding: 1.5rem;
    overflow-y: auto;
    flex: 1;
}

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

/* Receipt preview in modal */
.receipt-preview {
    background: white;
    color: var(--text-reciept);
    border-radius: var(--radius-sm);
    padding: 2rem;
    font-family: 'Inter', sans-serif;
    box-shadow: inset 0 0 0 1px rgba(0,0,0,0.1);
}

.receipt-preview * { color: var(--text-reciept) !important; }

.receipt-header { text-align: center; margin-bottom: 1.5rem; padding-bottom: 1rem; border-bottom: 2px solid #e5e7eb; }
.receipt-header h2 { font-size: 1.1rem; font-weight: 800; margin-bottom: 0.25rem; }
.receipt-header .dr-name { font-size: 0.9rem; font-weight: 600; margin-bottom: 0.25rem; }
.receipt-header .receipt-num { font-size: 0.8rem; color: #6b7280 !important; }

.receipt-info { margin-bottom: 1rem; }
.receipt-info h4 { font-size: 0.75rem; text-transform: uppercase; font-weight: 700; color: #9ca3af !important; margin-bottom: 0.5rem; letter-spacing: 0.05em; }

.receipt-row { display: flex; justify-content: space-between; padding: 0.35rem 0; border-bottom: 1px dashed #e5e7eb; font-size: 0.82rem; }
.receipt-row:last-child { border-bottom: none; }
.receipt-row .label { color: #6b7280 !important; }
.receipt-row .value { font-weight: 600; }

.receipt-valor {
    margin: 1.25rem 0;
    background: #f0fdf4;
    border: 1px solid #bbf7d0;
    border-radius: 8px;
    padding: 0.75rem 1rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.receipt-valor .label { font-size: 0.82rem; color: #6b7280 !important; }
.receipt-valor .value { font-size: 1.2rem; font-weight: 800; color: #059669 !important; }

.receipt-footer { text-align: center; margin-top: 1.5rem; padding-top: 1rem; border-top: 1px solid #e5e7eb; }
.receipt-signature-line { border-bottom: 1px solid #374151; width: 200px; margin: 0 auto 0.5rem; height: 30px; }
.receipt-footer p { font-size: 0.82rem; color: #6b7280 !important; }

/* =============================================
   TOAST NOTIFICATIONS
   ============================================= */
.toast-container {
    position: fixed;
    bottom: 1.5rem;
    right: 1.5rem;
    z-index: 3000;
    display: flex;
    flex-direction: column-reverse;
    gap: 0.5rem;
}

.toast {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.8rem 1.25rem;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-lg);
    font-size: 0.85rem;
    color: var(--text-primary);
    min-width: 280px;
    max-width: 380px;
    animation: slideIn 0.3s ease;
    border-left: 4px solid var(--success);
}

.toast.toast-error { border-left-color: var(--danger); }
.toast.toast-warning { border-left-color: var(--warning); }
.toast.toast-info { border-left-color: var(--info); }

.toast i { font-size: 1rem; }
.toast.toast-success i { color: var(--success); }
.toast.toast-error i { color: var(--danger); }
.toast.toast-warning i { color: var(--warning); }
.toast.toast-info i { color: var(--info); }

@keyframes slideIn {
    from { transform: translateX(110%); opacity: 0; }
    to { transform: translateX(0); opacity: 1; }
}

@keyframes slideOut {
    from { transform: translateX(0); opacity: 1; }
    to { transform: translateX(110%); opacity: 0; }
}

.toast.removing { animation: slideOut 0.3s ease forwards; }

/* =============================================
   SIDEBAR OVERLAY (mobile)
   ============================================= */
.sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.5);
    z-index: 999;
}

/* =============================================
   LOADING SPINNER
   ============================================= */
.spinner {
    width: 20px; height: 20px;
    border: 2px solid rgba(255,255,255,0.3);
    border-top-color: white;
    border-radius: 50%;
    animation: spin 0.7s linear infinite;
    display: inline-block;
}

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

/* =============================================
   RESPONSIVE
   ============================================= */
@media (max-width: 1200px) {
    .kpi-grid { grid-template-columns: repeat(2, 1fr); }
    .charts-row { grid-template-columns: 1fr; }
    .two-col-layout { grid-template-columns: 1fr; }
    .info-side { position: static; }
}

@media (max-width: 900px) {
    .sidebar {
        transform: translateX(-100%);
    }

    .sidebar.open {
        transform: translateX(0);
    }

    .sidebar-overlay.open { display: block; }

    .main-content { margin-left: 0; }

    .menu-toggle { display: flex; }
}

@media (max-width: 640px) {
    .kpi-grid { grid-template-columns: 1fr 1fr; }
    .page { padding: 1rem; }
    .form-grid { grid-template-columns: 1fr; }
    .form-group.full-width { grid-column: 1; }
    .rateio-grid { grid-template-columns: 1fr; }
    .rateio-item:first-child { border-right: none; border-bottom: 1px solid var(--border-color); }
    .rateio-row { grid-template-columns: 1fr 1fr; gap: 0.25rem; }
    .mini-stats { grid-template-columns: 1fr 1fr; }
    .filters-bar { flex-direction: column; align-items: stretch; }
    .modal { margin: 0.5rem; }
}

@media (max-width: 400px) {
    .kpi-grid { grid-template-columns: 1fr; }
    .kpi-card { padding: 1rem; }
}
