:root {
    --primary: #3FBED9;
    --primary-dark: #2da8c4;
    --secondary: #3D7BC4;
    --secondary-dark: #2f63a3;
    --bg: #0b1220;
    --bg-card: rgba(255, 255, 255, 0.06);
    --bg-card-hover: rgba(255, 255, 255, 0.09);
    --glass: rgba(255, 255, 255, 0.08);
    --glass-border: rgba(255, 255, 255, 0.12);
    --text: #f1f5f9;
    --text-muted: #94a3b8;
    --success: #22c55e;
    --danger: #ef4444;
    --warning: #f59e0b;
    --radius: 20px;
    --radius-sm: 12px;
    --shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.45);
    --font: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
}

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

html, body {
    min-height: 100%;
    font-family: var(--font);
    background: var(--bg);
    color: var(--text);
    -webkit-font-smoothing: antialiased;
}

body {
    background:
        radial-gradient(ellipse 80% 50% at 20% -10%, rgba(63, 190, 217, 0.18), transparent),
        radial-gradient(ellipse 60% 40% at 90% 10%, rgba(61, 123, 196, 0.15), transparent),
        var(--bg);
}

a { color: var(--primary); text-decoration: none; }
a:hover { color: #6dd5ea; }

.app-shell {
    display: grid;
    grid-template-columns: 280px 1fr;
    min-height: 100vh;
    max-width: 1600px;
    margin: 0 auto;
    padding: 24px;
    gap: 24px;
}

.sidebar {
    background: var(--glass);
    backdrop-filter: blur(24px);
    -webkit-backdrop-filter: blur(24px);
    border: 1px solid var(--glass-border);
    border-radius: calc(var(--radius) + 4px);
    padding: 28px 20px;
    display: flex;
    flex-direction: column;
    position: sticky;
    top: 24px;
    height: calc(100vh - 48px);
    box-shadow: var(--shadow);
}

.brand {
    display: flex;
    align-items: center;
    gap: 14px;
    margin-bottom: 32px;
    padding: 0 8px;
}

.brand-icon {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--primary), var(--secondary));
    display: grid;
    place-items: center;
    font-weight: 800;
    font-size: 22px;
    color: white;
    box-shadow: 0 8px 24px rgba(63, 190, 217, 0.35);
}

.brand-text h1 {
    font-size: 1.1rem;
    font-weight: 700;
    line-height: 1.2;
}

.brand-text span {
    font-size: 0.75rem;
    color: var(--text-muted);
}

.nav-section {
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--text-muted);
    margin: 20px 12px 8px;
}

.nav-link {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    border-radius: var(--radius-sm);
    color: var(--text-muted);
    font-weight: 500;
    font-size: 0.92rem;
    transition: all 0.2s ease;
    margin-bottom: 4px;
}

.nav-link:hover, .nav-link.active {
    background: linear-gradient(135deg, rgba(63,190,217,0.15), rgba(61,123,196,0.15));
    color: var(--text);
}

.nav-link.active {
    border: 1px solid rgba(63, 190, 217, 0.3);
}

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

.main-content { min-width: 0; }

.topbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 28px;
    flex-wrap: wrap;
    gap: 16px;
}

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

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

.topbar-actions {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
}

.unidade-select {
    background: var(--glass);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-sm);
    padding: 10px 14px;
    color: var(--text);
    font-size: 0.85rem;
}

.user-chip {
    display: flex;
    align-items: center;
    gap: 10px;
    background: var(--glass);
    border: 1px solid var(--glass-border);
    border-radius: 999px;
    padding: 6px 14px 6px 6px;
    font-size: 0.85rem;
}

.user-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--secondary), var(--primary));
    display: grid;
    place-items: center;
    font-weight: 700;
    font-size: 0.8rem;
}

.card {
    background: var(--bg-card);
    backdrop-filter: blur(20px);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius);
    padding: 24px;
    box-shadow: var(--shadow);
    transition: background 0.2s;
}

.card:hover { background: var(--bg-card-hover); }

.card-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 20px;
    margin-bottom: 28px;
}

.stat-card {
    position: relative;
    overflow: hidden;
}

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

.stat-label {
    font-size: 0.8rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 8px;
}

.stat-value {
    font-size: 1.75rem;
    font-weight: 700;
    letter-spacing: -0.02em;
}

.stat-meta {
    font-size: 0.8rem;
    color: var(--text-muted);
    margin-top: 6px;
}

.stat-receber .stat-value { color: var(--success); }
.stat-pagar .stat-value { color: var(--danger); }
.stat-info .stat-value { color: var(--primary); }

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 12px 20px;
    border-radius: var(--radius-sm);
    border: none;
    font-weight: 600;
    font-size: 0.9rem;
    cursor: pointer;
    transition: all 0.2s;
    font-family: inherit;
    text-decoration: none;
}

.btn-primary {
    background: linear-gradient(135deg, var(--primary), var(--secondary));
    color: white;
    box-shadow: 0 8px 24px rgba(63, 190, 217, 0.3);
}

.btn-primary:hover {
    transform: translateY(-1px);
    box-shadow: 0 12px 28px rgba(63, 190, 217, 0.4);
    color: white;
}

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

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

.btn-danger {
    background: rgba(239, 68, 68, 0.15);
    border: 1px solid rgba(239, 68, 68, 0.3);
    color: #fca5a5;
}

.btn-sm { padding: 8px 14px; font-size: 0.82rem; }

.table-wrap { overflow-x: auto; border-radius: var(--radius-sm); }

table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.88rem;
}

th {
    text-align: left;
    padding: 14px 16px;
    color: var(--text-muted);
    font-weight: 600;
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    border-bottom: 1px solid var(--glass-border);
}

td {
    padding: 14px 16px;
    border-bottom: 1px solid rgba(255,255,255,0.04);
}

tr:hover td { background: rgba(255,255,255,0.02); }

.badge {
    display: inline-block;
    padding: 4px 10px;
    border-radius: 999px;
    font-size: 0.75rem;
    font-weight: 600;
}

.badge-open { background: rgba(63,190,217,0.15); color: var(--primary); }
.badge-partial { background: rgba(245,158,11,0.15); color: var(--warning); }
.badge-paid { background: rgba(34,197,94,0.15); color: var(--success); }
.badge-cancel { background: rgba(148,163,184,0.15); color: var(--text-muted); }

.form-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 20px;
}

.form-group { display: flex; flex-direction: column; gap: 8px; }
.form-group.full { grid-column: 1 / -1; }

label {
    font-size: 0.82rem;
    font-weight: 600;
    color: var(--text-muted);
}

input, select, textarea {
    background: rgba(0,0,0,0.25);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-sm);
    padding: 12px 14px;
    color: var(--text);
    font-size: 0.92rem;
    font-family: inherit;
    transition: border-color 0.2s;
}

input:focus, select:focus, textarea:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(63,190,217,0.15);
}

textarea { min-height: 100px; resize: vertical; }

.alert {
    padding: 14px 18px;
    border-radius: var(--radius-sm);
    margin-bottom: 20px;
    font-size: 0.9rem;
}

.alert-success {
    background: rgba(34,197,94,0.12);
    border: 1px solid rgba(34,197,94,0.25);
    color: #86efac;
}

.alert-error {
    background: rgba(239,68,68,0.12);
    border: 1px solid rgba(239,68,68,0.25);
    color: #fca5a5;
}

.login-page {
    min-height: 100vh;
    display: grid;
    place-items: center;
    padding: 24px;
}

.login-card {
    width: 100%;
    max-width: 420px;
    padding: 40px;
}

.login-card .brand { justify-content: center; margin-bottom: 36px; }

.detail-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 16px;
    margin-bottom: 24px;
}

.detail-item label { display: block; margin-bottom: 4px; }
.detail-item span { font-size: 1rem; font-weight: 500; }

.tabs {
    display: flex;
    gap: 8px;
    margin-bottom: 24px;
    flex-wrap: wrap;
}

.tab {
    padding: 10px 18px;
    border-radius: var(--radius-sm);
    background: var(--glass);
    border: 1px solid transparent;
    color: var(--text-muted);
    font-size: 0.88rem;
    cursor: pointer;
}

.tab.active {
    border-color: rgba(63,190,217,0.4);
    color: var(--text);
    background: rgba(63,190,217,0.1);
}

.timeline {
    border-left: 2px solid var(--glass-border);
    padding-left: 20px;
    margin-left: 8px;
}

.timeline-item {
    position: relative;
    padding-bottom: 20px;
}

.timeline-item::before {
    content: '';
    position: absolute;
    left: -27px;
    top: 4px;
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: var(--primary);
    border: 2px solid var(--bg);
}

.timeline-date { font-size: 0.75rem; color: var(--text-muted); }
.timeline-text { font-size: 0.9rem; margin-top: 4px; }

.chart-bars {
    display: flex;
    align-items: flex-end;
    gap: 6px;
    height: 120px;
    padding-top: 20px;
}

.chart-bar-group {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
}

.chart-bar {
    width: 100%;
    max-width: 32px;
    border-radius: 6px 6px 0 0;
    min-height: 4px;
}

.chart-bar.entrada { background: linear-gradient(180deg, var(--success), rgba(34,197,94,0.4)); }
.chart-bar.saida { background: linear-gradient(180deg, var(--danger), rgba(239,68,68,0.4)); }

.chart-label { font-size: 0.65rem; color: var(--text-muted); }

.empty-state {
    text-align: center;
    padding: 48px 24px;
    color: var(--text-muted);
}

.actions-row {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    margin-top: 20px;
}

@media (max-width: 1024px) {
    .app-shell {
        grid-template-columns: 1fr;
        padding: 16px;
    }
    .sidebar {
        position: relative;
        height: auto;
        top: 0;
    }
}

@media (max-width: 768px) {
    .stat-value { font-size: 1.4rem; }
    .page-title h2 { font-size: 1.4rem; }
}
