/* ─── Design tokens ─────────────────────────────────────────────── */
:root {
    --bg: #f0f4f1;
    --surface: #ffffff;
    --surface-2: #f5faf7;
    --surface-3: #e8f5ed;
    --border: #d2e0d7;
    --border-light: #b8cfc1;
    --text: #1a1d23;
    --text-dim: #4a6355;
    --text-muted: #7d9b8a;
    --accent: #059669;
    --accent-light: #10b981;
    --accent-dark: #047857;
    --accent-glow: rgba(5, 150, 105, 0.18);
    --success: #16a34a;
    --success-bg: rgba(22, 163, 74, 0.10);
    --danger: #dc2626;
    --danger-bg: rgba(220, 38, 38, 0.08);
    --warning: #d97706;
    --warning-bg: rgba(217, 119, 6, 0.10);
    --info: #0891b2;
    --info-bg: rgba(8, 145, 178, 0.10);
    --purple: #7c3aed;
    --purple-bg: rgba(124, 58, 237, 0.08);
    --radius: 10px;
    --radius-lg: 16px;
    --shadow: 0 4px 24px rgba(0,0,0,0.06);
    --shadow-sm: 0 1px 3px rgba(0,0,0,0.05);
}

/* ─── Dark mode ─── */
[data-theme="dark"] {
    --bg: #0f1714;
    --surface: #1a2420;
    --surface-2: #22302a;
    --surface-3: #2a3a33;
    --border: #2e3e36;
    --border-light: #3a4f44;
    --text: #e4ece7;
    --text-dim: #9ab5a6;
    --text-muted: #6b8576;
    --accent: #10b981;
    --accent-light: #34d399;
    --accent-dark: #059669;
    --accent-glow: rgba(16, 185, 129, 0.25);
    --success: #22c55e;
    --success-bg: rgba(34, 197, 94, 0.14);
    --danger: #ef4444;
    --danger-bg: rgba(239, 68, 68, 0.12);
    --warning: #f59e0b;
    --warning-bg: rgba(245, 158, 11, 0.12);
    --info: #22d3ee;
    --info-bg: rgba(34, 211, 238, 0.12);
    --purple: #a78bfa;
    --purple-bg: rgba(167, 139, 250, 0.10);
    --shadow: 0 4px 24px rgba(0,0,0,0.3);
    --shadow-sm: 0 1px 3px rgba(0,0,0,0.2);
}
[data-theme="dark"] body {
    background-image:
        radial-gradient(ellipse at 10% 10%, rgba(16,185,129,0.06) 0%, transparent 50%),
        radial-gradient(ellipse at 90% 90%, rgba(34,211,238,0.04) 0%, transparent 50%);
}
[data-theme="dark"] tbody tr:hover { background: rgba(16,185,129,0.06); }
[data-theme="dark"] .alert-success { background: rgba(34,197,94,0.12); border-color: rgba(34,197,94,0.3); color: #4ade80; }
[data-theme="dark"] .alert-danger { background: rgba(239,68,68,0.12); border-color: rgba(239,68,68,0.3); color: #f87171; }
[data-theme="dark"] .alert-warning { background: rgba(245,158,11,0.12); border-color: rgba(245,158,11,0.3); color: #fbbf24; }
[data-theme="dark"] .alert-info { background: rgba(34,211,238,0.12); border-color: rgba(34,211,238,0.3); color: #67e8f9; }
[data-theme="dark"] .badge-success { background: rgba(34,197,94,0.15); color: #4ade80; }
[data-theme="dark"] .badge-danger { background: rgba(239,68,68,0.15); color: #f87171; }
[data-theme="dark"] .badge-warning { background: rgba(245,158,11,0.15); color: #fbbf24; }
[data-theme="dark"] .badge-info { background: rgba(34,211,238,0.15); color: #67e8f9; }
[data-theme="dark"] .badge-gray { background: rgba(148,163,184,0.15); color: #cbd5e1; }
[data-theme="dark"] select.form-control {
    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='%239ab5a6' stroke-width='2'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
}

/* ─── Light mode (default greenish, but allow blue-ish "light" alt) ─── */
/* (default :root is the green/light) */

/* ─── Blue mode ─── */
[data-theme="blue"] {
    --bg: #f0f2f5;
    --surface: #ffffff;
    --surface-2: #f7f8fa;
    --surface-3: #eef0f4;
    --border: #d8dde6;
    --border-light: #c5ccd6;
    --text: #1a1d23;
    --text-dim: #5a6478;
    --text-muted: #8b95a8;
    --accent: #2563eb;
    --accent-light: #3b82f6;
    --accent-dark: #1d4ed8;
    --accent-glow: rgba(37, 99, 235, 0.2);
}
[data-theme="blue"] body {
    background-image:
        radial-gradient(ellipse at 10% 10%, rgba(37,99,235,0.05) 0%, transparent 50%),
        radial-gradient(ellipse at 90% 90%, rgba(124,58,237,0.03) 0%, transparent 50%);
}
[data-theme="blue"] tbody tr:hover { background: rgba(37,99,235,0.04); }

/* ─── Pink mode ─── */
[data-theme="pink"] {
    --bg: #fdf2f4;
    --surface: #ffffff;
    --surface-2: #fef7f8;
    --surface-3: #fceef1;
    --border: #e8d0d6;
    --border-light: #d6b8c0;
    --text: #1a1d23;
    --text-dim: #6b5a64;
    --text-muted: #a08b95;
    --accent: #db2777;
    --accent-light: #ec4899;
    --accent-dark: #be185d;
    --accent-glow: rgba(219, 39, 119, 0.2);
}
[data-theme="pink"] body {
    background-image:
        radial-gradient(ellipse at 10% 10%, rgba(219,39,119,0.04) 0%, transparent 50%),
        radial-gradient(ellipse at 90% 90%, rgba(168,85,247,0.03) 0%, transparent 50%);
}
[data-theme="pink"] tbody tr:hover { background: rgba(219,39,119,0.04); }

/* ─── Yellow mode ─── */
[data-theme="yellow"] {
    --bg: #fefcf0;
    --surface: #ffffff;
    --surface-2: #fefdf5;
    --surface-3: #fdf8e6;
    --border: #e6dbb0;
    --border-light: #d4c88e;
    --text: #1a1d23;
    --text-dim: #6b5f3a;
    --text-muted: #a09060;
    --accent: #ca8a04;
    --accent-light: #eab308;
    --accent-dark: #a16207;
    --accent-glow: rgba(202, 138, 4, 0.2);
}
[data-theme="yellow"] body {
    background-image:
        radial-gradient(ellipse at 10% 10%, rgba(202,138,4,0.05) 0%, transparent 50%),
        radial-gradient(ellipse at 90% 90%, rgba(234,179,8,0.03) 0%, transparent 50%);
}
[data-theme="yellow"] tbody tr:hover { background: rgba(202,138,4,0.04); }

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

body {
    font-family: 'DM Sans', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    font-size: 14px;
    background: var(--bg);
    color: var(--text);
    min-height: 100vh;
    background-image:
        radial-gradient(ellipse at 10% 10%, rgba(5,150,105,0.05) 0%, transparent 50%),
        radial-gradient(ellipse at 90% 90%, rgba(16,185,129,0.03) 0%, transparent 50%);
}

a { color: var(--accent); }

/* ─── Navbar ─────────────────────────────────────────────────────── */
.navbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 24px;
    height: 60px;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    z-index: 100;
    backdrop-filter: blur(12px);
    gap: 16px;
}
.nav-brand a {
    display: flex;
    align-items: center;
    gap: 10px;
    text-decoration: none;
    color: var(--text);
}
.brand-icon {
    font-size: 1.4rem;
    background: linear-gradient(135deg, #059669, #10b981);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}
[data-theme="blue"] .brand-icon { background: linear-gradient(135deg, #2563eb, #7c3aed); -webkit-background-clip: text; background-clip: text; }
[data-theme="pink"] .brand-icon { background: linear-gradient(135deg, #db2777, #a855f7); -webkit-background-clip: text; background-clip: text; }
[data-theme="yellow"] .brand-icon { background: linear-gradient(135deg, #ca8a04, #d97706); -webkit-background-clip: text; background-clip: text; }
.brand-text {
    font-size: 1rem;
    font-weight: 700;
    letter-spacing: 0.5px;
}
.nav-links {
    display: flex;
    gap: 4px;
    flex: 1;
    justify-content: center;
}
.nav-link {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 14px;
    border-radius: 8px;
    text-decoration: none;
    color: var(--text-dim);
    font-size: 0.85rem;
    font-weight: 500;
    transition: all 0.15s;
    white-space: nowrap;
}
.nav-link:hover {
    color: var(--text);
    background: var(--surface-2);
}
.nav-link.active {
    color: var(--accent);
    background: var(--accent-glow);
}
.nav-link.nav-link-cta {
    background: var(--accent);
    color: #fff;
    border: 1px solid var(--accent);
    box-shadow: 0 2px 8px var(--accent-glow);
}
.nav-link.nav-link-cta:hover {
    background: var(--accent-dark);
    color: #fff;
    box-shadow: 0 3px 12px var(--accent-glow);
}
.nav-link.nav-link-cta.active {
    background: var(--accent-dark);
    color: #fff;
}
.nav-user {
    display: flex;
    align-items: center;
    gap: 12px;
}
.user-name {
    font-size: 0.8rem;
    color: var(--text-dim);
    font-weight: 500;
}
.btn-theme {
    background: none;
    border: none;
    font-size: 1.1rem;
    cursor: pointer;
    padding: 6px 8px;
    border-radius: 6px;
    transition: background 0.15s;
    line-height: 1;
}
.btn-theme:hover { background: var(--surface-2); }
.btn-logout {
    color: var(--text-dim);
    transition: color 0.15s;
    display: inline-flex;
    align-items: center;
    padding: 6px;
    border-radius: 6px;
}
.btn-logout:hover { color: var(--danger); background: var(--surface-2); }

/* Mobile hamburger / overlay */
.nav-hamburger {
    display: none;
    background: none;
    border: none;
    color: var(--text);
    cursor: pointer;
    padding: 6px;
    border-radius: 6px;
}
.nav-hamburger:hover { background: var(--surface-2); }
.nav-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.3);
    z-index: 149;
}
.nav-overlay.show { display: block; }

/* ─── Layout ─────────────────────────────────────────────────────── */
.container,
.main-content {
    max-width: 1400px;
    margin: 0 auto;
    padding: 24px;
    width: 100%;
}

.page-title {
    font-size: 1.5rem;
    font-weight: 700;
    margin: 0 0 20px;
    color: var(--text);
    letter-spacing: -0.01em;
}

.flex-between {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    flex-wrap: wrap;
}
.mb-1 { margin-bottom: .5rem; }
.mb-2 { margin-bottom: 1rem; }
.mb-3 { margin-bottom: 1.5rem; }
.mt-1 { margin-top: .5rem; }
.mt-2 { margin-top: 1rem; }
.mt-3 { margin-top: 1.5rem; }

/* ─── Flash messages ─────────────────────────────────────────────── */
.flash-messages { margin-bottom: 16px; }
.flash, .alert {
    padding: 12px 16px;
    border-radius: var(--radius);
    font-size: 0.88rem;
    border: 1px solid transparent;
    margin-bottom: 8px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    animation: slideDown 0.3s ease;
}
@keyframes slideDown {
    from { opacity: 0; transform: translateY(-8px); }
    to { opacity: 1; transform: translateY(0); }
}
.alert-success, .flash-success { background: var(--success-bg); border-color: rgba(22,163,74,0.25); color: #15803d; }
.alert-danger, .alert-error, .flash-danger, .flash-error { background: var(--danger-bg); border-color: rgba(220,38,38,0.25); color: #b91c1c; }
.alert-warning, .flash-warning { background: var(--warning-bg); border-color: rgba(217,119,6,0.3); color: #92400e; }
.alert-info, .flash-info { background: var(--info-bg); border-color: rgba(8,145,178,0.3); color: #0e7490; }
.flash-close {
    background: none;
    border: none;
    color: inherit;
    font-size: 1.2rem;
    cursor: pointer;
    opacity: 0.6;
    line-height: 1;
}
.flash-close:hover { opacity: 1; }

/* ─── Cards ──────────────────────────────────────────────────────── */
.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 20px 22px;
    box-shadow: var(--shadow-sm);
    margin-bottom: 16px;
    width: 100%;
}
.card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 16px;
    gap: 12px;
    flex-wrap: wrap;
}
.card-header h2,
.card-header h3,
.card-title {
    font-size: 1rem;
    font-weight: 600;
    margin: 0;
    color: var(--text);
}

/* ─── Summary grid (dashboard) ───────────────────────────────────── */
.summary-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 14px;
    margin-bottom: 20px;
}
.summary-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 16px 18px;
    box-shadow: var(--shadow-sm);
    transition: transform 0.15s, box-shadow 0.15s;
}
.summary-card:hover {
    transform: translateY(-1px);
    box-shadow: var(--shadow);
}
.summary-card .label {
    font-size: 0.72rem;
    color: var(--text-dim);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    font-weight: 600;
    margin-bottom: 6px;
}
.summary-card .value {
    font-size: 1.4rem;
    font-weight: 700;
    letter-spacing: -0.01em;
}
.summary-card.summary-accent  { border-left: 3px solid var(--accent); }
.summary-card.summary-success { border-left: 3px solid var(--success); }
.summary-card.summary-danger  { border-left: 3px solid var(--danger); }
.summary-card.summary-info    { border-left: 3px solid var(--info); }
.summary-card.summary-warning { border-left: 3px solid var(--warning); }

.dashboard-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
}
@media (max-width: 768px) {
    .dashboard-grid { grid-template-columns: 1fr; gap: 12px; }
}

/* ─── Tables ─────────────────────────────────────────────────────── */
.table-wrapper, .table-container {
    width: 100%;
    overflow-x: auto;
    border-radius: var(--radius);
    border: 1px solid var(--border);
}
.card .table-wrapper, .card .table-container {
    border: none;
    border-radius: 0;
}
table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.85rem;
}
thead th, th {
    padding: 11px 14px;
    text-align: left;
    background: var(--surface-2);
    font-size: 0.72rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-dim);
    border-bottom: 1px solid var(--border);
    white-space: nowrap;
}
td {
    padding: 10px 14px;
    border-bottom: 1px solid var(--border);
    vertical-align: middle;
}
tbody tr {
    transition: background 0.15s;
}
tbody tr:last-child td { border-bottom: none; }
tbody tr:hover { background: rgba(5,150,105,0.04); }
.table-nowrap { width: 100%; border-collapse: collapse; }
.table-nowrap td, .table-nowrap th { white-space: nowrap; }
.text-right { text-align: right; }
.text-center { text-align: center; }

/* ─── Buttons ────────────────────────────────────────────────────── */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 9px 16px;
    border-radius: 8px;
    border: 1px solid var(--border);
    background: var(--surface-2);
    color: var(--text);
    font-family: inherit;
    font-size: 0.85rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.15s;
    text-decoration: none;
    white-space: nowrap;
    line-height: 1.4;
}
.btn:hover {
    background: var(--surface-3);
    border-color: var(--border-light);
}
.btn-primary {
    background: var(--accent);
    border-color: var(--accent);
    color: #fff;
}
.btn-primary:hover {
    background: var(--accent-dark);
    border-color: var(--accent-dark);
    color: #fff;
}
.btn-secondary {
    background: var(--surface-2);
    border-color: var(--border);
    color: var(--text);
}
.btn-secondary:hover {
    background: var(--surface-3);
    border-color: var(--border-light);
}
.btn-success {
    background: var(--success-bg);
    border-color: rgba(22,163,74,0.3);
    color: #15803d;
}
.btn-success:hover { background: rgba(22,163,74,0.18); }
.btn-danger {
    background: var(--danger-bg);
    border-color: rgba(220,38,38,0.3);
    color: #b91c1c;
}
.btn-danger:hover { background: rgba(220,38,38,0.16); }
.btn-warning {
    background: var(--warning-bg);
    border-color: rgba(217,119,6,0.3);
    color: #92400e;
}
.btn-warning:hover { background: rgba(217,119,6,0.18); }
.btn-sm {
    padding: 5px 10px;
    font-size: 0.78rem;
}
.btn-lg {
    padding: 12px 22px;
    font-size: 0.95rem;
}
.btn-block {
    width: 100%;
}
.btn-icon {
    width: 32px;
    height: 32px;
    padding: 0;
    border-radius: 6px;
}
.btn-link {
    background: none;
    border: none;
    color: var(--accent);
    cursor: pointer;
    padding: 0;
    font-size: 0.85rem;
    text-decoration: underline;
}
.btn-link:hover { color: var(--accent-dark); }

/* ─── Forms ──────────────────────────────────────────────────────── */
.form-group { margin-bottom: 16px; }
.form-group label {
    display: block;
    font-size: 0.74rem;
    font-weight: 600;
    color: var(--text-dim);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 6px;
}
.form-group.form-check label {
    display: inline;
    text-transform: none;
    letter-spacing: 0;
    font-size: 0.88rem;
    color: var(--text);
    margin-left: 6px;
}
.form-control {
    display: block;
    width: 100%;
    padding: 10px 14px;
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: 8px;
    color: var(--text);
    font-family: inherit;
    font-size: 0.9rem;
    outline: none;
    transition: border-color 0.15s, box-shadow 0.15s;
}
.form-control:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-glow);
    background: var(--surface);
}
select.form-control {
    cursor: pointer;
    appearance: none;
    -webkit-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='%234a6355' stroke-width='2'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
    padding-right: 36px;
}
textarea.form-control {
    min-height: 100px;
    resize: vertical;
    line-height: 1.5;
}
.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
}
.form-error {
    display: block;
    font-size: 0.78rem;
    color: var(--danger);
    margin-top: 4px;
}
.form-hint {
    font-size: 0.76rem;
    color: var(--text-muted);
    margin-top: 4px;
}
.form-actions {
    display: flex;
    gap: 10px;
    margin-top: 20px;
    flex-wrap: wrap;
}
@media (max-width: 480px) {
    .form-actions { flex-direction: column; }
    .form-actions > .btn { width: 100%; }
}

/* ─── Auth card ──────────────────────────────────────────────────── */
.auth-card {
    max-width: 420px;
    margin: 4rem auto;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow);
    padding: 2rem 2.25rem;
}
.auth-card h1 {
    font-size: 1.4rem;
    margin-bottom: 1.5rem;
    text-align: center;
    font-weight: 700;
}
.auth-link {
    text-align: center;
    font-size: 0.88rem;
    margin-top: 1.25rem;
    color: var(--text-dim);
}
.auth-link a {
    color: var(--accent);
    font-weight: 600;
    text-decoration: none;
}
.auth-link a:hover { text-decoration: underline; }

/* ─── Badges ─────────────────────────────────────────────────────── */
.badge {
    display: inline-flex;
    align-items: center;
    padding: 3px 10px;
    border-radius: 999px;
    font-size: 0.72rem;
    font-weight: 600;
    letter-spacing: 0.02em;
    white-space: nowrap;
}
.badge-success { background: rgba(22,163,74,0.12); color: #15803d; }
.badge-danger  { background: rgba(220,38,38,0.10); color: #b91c1c; }
.badge-warning { background: rgba(217,119,6,0.12); color: #92400e; }
.badge-info    { background: rgba(8,145,178,0.10); color: #0e7490; }
.badge-gray    { background: rgba(100,116,139,0.10); color: #475569; }
.badge-purple  { background: rgba(124,58,237,0.10); color: #6d28d9; }
.badge-extraordinary { background: rgba(234,88,12,0.12); color: #c2410c; border: 1px solid rgba(234,88,12,0.25); font-size:.72rem; }

/* ─── Utilities ──────────────────────────────────────────────────── */
.text-green { color: var(--success); font-weight: 600; }
.text-red   { color: var(--danger); font-weight: 600; }
.text-gray  { color: var(--text-muted); }
.text-muted { color: var(--text-muted); }
.text-dim   { color: var(--text-dim); }
.text-accent { color: var(--accent); font-weight: 600; }

small.text-gray, small.text-muted {
    font-size: 0.78rem;
    margin-left: 4px;
}

.empty-state {
    text-align: center;
    color: var(--text-muted);
    padding: 40px 20px;
    font-size: 0.9rem;
}
.empty-state svg {
    margin-bottom: 12px;
    opacity: 0.3;
}

/* ─── Bill rows ──────────────────────────────────────────────────── */
.bill-row.bill-receivable  { background: rgba(22, 163, 74, 0.10); }
.bill-row.bill-payable     { background: rgba(220, 38, 38, 0.09); }
.bill-row.bill-transfer    { background: rgba(8, 145, 178, 0.10); }

.bill-row.bill-receivable.bill-paid { background: rgba(22, 163, 74, 0.04); color: var(--text-muted); }
.bill-row.bill-payable.bill-paid    { background: rgba(220, 38, 38, 0.04); color: var(--text-muted); }
.bill-row.bill-transfer.bill-paid   { background: rgba(8, 145, 178, 0.04); color: var(--text-muted); }

/* ─── Action bar / toolbar ───────────────────────────────────────── */
.action-bar {
    display: flex;
    gap: 10px;
    margin-bottom: 20px;
    flex-wrap: wrap;
    align-items: center;
}

/* ─── Filter bar (filtros em listagens) ─────────────────────────── */
.filter-bar {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
    align-items: flex-end;
}
.filter-bar .form-group {
    margin: 0;
    display: flex;
    flex-direction: column;
    gap: 4px;
    min-width: 0;
}
.filter-bar .form-group label {
    margin: 0;
    font-size: 0.7rem;
}
.filter-bar .form-control {
    padding: 7px 12px;
    font-size: 0.85rem;
    height: 36px;
    min-width: 0;
}
.filter-bar select.form-control {
    padding-right: 32px;
}
.filter-bar input[type="date"].form-control {
    width: auto;
    min-width: 140px;
}
.filter-bar .btn {
    height: 36px;
    padding: 0 14px;
}
.filter-bar .filter-spacer { flex: 1; }
@media (max-width: 600px) {
    .filter-bar { gap: 8px; }
    .filter-bar .form-group { flex: 1 1 calc(50% - 4px); }
    .filter-bar input[type="date"].form-control { width: 100%; min-width: 0; }
    .filter-bar .btn { flex: 1 1 auto; }
}

/* ─── Modal (utility) ────────────────────────────────────────────── */
.modal-backdrop {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.35);
    backdrop-filter: blur(4px);
    z-index: 200;
    align-items: center;
    justify-content: center;
    padding: 20px;
}
.modal-backdrop.show { display: flex; }
.modal {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 24px;
    width: 100%;
    max-width: 540px;
    box-shadow: 0 25px 60px rgba(0,0,0,0.18);
    animation: modalIn 0.2s ease;
    max-height: 90vh;
    overflow-y: auto;
}
@keyframes modalIn {
    from { opacity: 0; transform: scale(0.96) translateY(8px); }
    to { opacity: 1; transform: scale(1) translateY(0); }
}

/* ─── Responsive ─────────────────────────────────────────────────── */
@media (max-width: 900px) {
    .nav-links { gap: 2px; }
    .nav-link { padding: 8px 10px; font-size: 0.8rem; }
    .nav-link span.nav-text { display: none; }
}

@media (max-width: 768px) {
    .navbar { padding: 0 14px; gap: 8px; }
    .nav-hamburger { display: inline-flex; align-items: center; justify-content: center; }


    .nav-links {
        display: none;
        position: fixed;
        top: 0;
        left: 0;
        width: 270px;
        height: 100vh;
        background: var(--surface);
        border-right: 1px solid var(--border);
        flex-direction: column;
        padding: 20px 12px;
        gap: 4px;
        z-index: 150;
        box-shadow: 4px 0 24px rgba(0,0,0,0.1);
        overflow-y: auto;
        justify-content: flex-start;
    }
    .nav-links.open {
        display: flex;
        animation: slideIn 0.2s ease;
    }
    @keyframes slideIn {
        from { transform: translateX(-100%); }
        to { transform: translateX(0); }
    }
    .nav-link {
        padding: 12px 14px;
        font-size: 0.92rem;
        border-radius: 8px;
        justify-content: flex-start;
    }
    .nav-link span.nav-text { display: inline; }

    .user-name { display: none; }
    .container, .main-content { padding: 14px; }
    .form-row { grid-template-columns: 1fr; }
    .summary-grid { grid-template-columns: repeat(2, 1fr); gap: 10px; }
    .summary-card { padding: 12px; }
    .summary-card .value { font-size: 1.15rem; }
    .page-title { font-size: 1.25rem; }
    .action-bar { flex-direction: column; align-items: stretch; }
    .action-bar > .btn { width: 100%; }
}

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

/* ─── Tabela → cards no mobile (opt-in via .table-cards) ───────── */
@media (max-width: 768px) {
    .table-cards { border: none; }
    .table-cards table,
    .table-cards table tbody,
    .table-cards table tr,
    .table-cards table td { display: block; width: 100%; }
    .table-cards table thead { display: none; }
    .table-cards table tr {
        background: var(--surface);
        border: 1px solid var(--border);
        border-radius: var(--radius);
        padding: 12px 14px;
        margin-bottom: 10px;
        box-shadow: 0 1px 3px rgba(0,0,0,0.04);
    }
    .table-cards table td {
        padding: 5px 0;
        border: none;
        font-size: 0.86rem;
        display: flex;
        justify-content: space-between;
        align-items: center;
        gap: 10px;
        text-align: right;
    }
    .table-cards table td::before {
        content: attr(data-label);
        font-size: 0.7rem;
        font-weight: 700;
        color: var(--text-dim);
        text-transform: uppercase;
        letter-spacing: 0.4px;
        margin-right: 8px;
        flex-shrink: 0;
        text-align: left;
    }
    .table-cards table td:empty,
    .table-cards table td[data-label=""] { display: none; }
    .table-cards table td.actions,
    .table-cards table td.text-right { justify-content: flex-end; }
    .table-cards table td.actions {
        flex-wrap: wrap;
        gap: 6px;
        padding-top: 10px;
        margin-top: 6px;
        border-top: 1px solid var(--border);
        justify-content: flex-start;
    }
    .table-cards table td.actions::before { display: none; }

    /* Linhas pintadas viram fundo do card */
    .table-cards .bill-row.bill-receivable              { background: rgba(22, 163, 74, 0.10); }
    .table-cards .bill-row.bill-payable                 { background: rgba(220, 38, 38, 0.09); }
    .table-cards .bill-row.bill-transfer                { background: rgba(8, 145, 178, 0.10); }
    .table-cards .bill-row.bill-receivable.bill-paid    { background: rgba(22, 163, 74, 0.04); }
    .table-cards .bill-row.bill-payable.bill-paid       { background: rgba(220, 38, 38, 0.04); }
    .table-cards .bill-row.bill-transfer.bill-paid      { background: rgba(8, 145, 178, 0.04); }
}

/* ─── Settings: categorias accordion ───────────────────────────── */
.cat-summary {
    list-style: none;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: .55rem 1rem;
    cursor: pointer;
    user-select: none;
    border-top: 1px solid var(--border);
}
.cat-summary::-webkit-details-marker { display: none; }
.cat-summary-left {
    display: flex;
    align-items: center;
    gap: .4rem;
}
.cat-chevron {
    display: inline-block;
    font-size: .7rem;
    color: var(--text-muted);
    transition: transform .15s;
    line-height: 1;
}
details[open] > .cat-summary .cat-chevron {
    transform: rotate(90deg);
}
.cat-body {
    padding: .5rem 1rem .75rem 2.2rem;
    background: var(--bg);
    border-top: 1px solid var(--border);
}
.sub-chips {
    display: flex;
    flex-wrap: wrap;
    gap: .35rem;
    margin-bottom: .5rem;
}
.chip-remove {
    background: none;
    border: none;
    padding: 0 0 0 .25rem;
    cursor: pointer;
    font-size: .85rem;
    color: var(--text-muted);
    line-height: 1;
}
.chip-remove:hover { color: var(--danger); }
.quick-add-form {
    display: flex;
    gap: .4rem;
    align-items: center;
    margin-top: .25rem;
}
.quick-add-top {
    display: flex;
    gap: .4rem;
    align-items: center;
    padding: .6rem 1rem;
    border-bottom: 1px solid var(--border);
}
