:root {
    --primary: #2563eb;
    --primary-dark: #1d4ed8;
    --primary-light: #dbeafe;
    --success: #16a34a;
    --success-light: #dcfce7;
    --warning: #d97706;
    --warning-light: #fef3c7;
    --danger: #dc2626;
    --danger-light: #fee2e2;
    --gray-50: #f9fafb;
    --gray-100: #f3f4f6;
    --gray-200: #e5e7eb;
    --gray-300: #d1d5db;
    --gray-400: #9ca3af;
    --gray-500: #6b7280;
    --gray-600: #4b5563;
    --gray-700: #374151;
    --gray-800: #1f2937;
    --gray-900: #111827;
    --radius: 8px;
    --shadow: 0 1px 3px rgba(0,0,0,0.1), 0 1px 2px rgba(0,0,0,0.06);
    --shadow-md: 0 4px 6px rgba(0,0,0,0.1), 0 2px 4px rgba(0,0,0,0.06);
    --shadow-lg: 0 10px 15px rgba(0,0,0,0.1), 0 4px 6px rgba(0,0,0,0.05);
}

* { margin: 0; padding: 0; box-sizing: border-box; }

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: var(--gray-50);
    color: var(--gray-800);
    line-height: 1.6;
}

/* ─── LAYOUT ─────────────────────────────────────────────── */

.app-container {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

.navbar {
    background: var(--gray-900);
    color: white;
    padding: 0 2rem;
    height: 56px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    position: sticky;
    top: 0;
    z-index: 100;
    box-shadow: var(--shadow-md);
}

.navbar-brand {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-weight: 700;
    font-size: 1.1rem;
    color: white;
    text-decoration: none;
}

.navbar-brand span { color: var(--primary); }

.navbar-right {
    display: flex;
    align-items: center;
    gap: 1.5rem;
}

.navbar-user {
    font-size: 0.875rem;
    color: var(--gray-300);
}

.navbar-user strong { color: white; }

.navbar-links {
    display: flex;
    gap: 0.25rem;
}

.navbar-links a {
    color: var(--gray-300);
    text-decoration: none;
    padding: 0.4rem 0.75rem;
    border-radius: var(--radius);
    font-size: 0.875rem;
    transition: all 0.15s;
}

.navbar-links a:hover,
.navbar-links a.active {
    background: rgba(255,255,255,0.1);
    color: white;
}

.main-content {
    flex: 1;
    padding: 2rem;
    max-width: 1400px;
    margin: 0 auto;
    width: 100%;
}

/* ─── CARDS ──────────────────────────────────────────────── */

.card {
    background: white;
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    overflow: hidden;
}

.card-header {
    padding: 1rem 1.5rem;
    border-bottom: 1px solid var(--gray-200);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.card-header h2 {
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--gray-800);
}

.card-body { padding: 1.5rem; }

/* ─── SUMMARY CARDS ──────────────────────────────────────── */

.summary-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 1rem;
    margin-bottom: 2rem;
}

.summary-card {
    background: white;
    border-radius: var(--radius);
    padding: 1.25rem;
    box-shadow: var(--shadow);
    border-left: 4px solid var(--primary);
}

.summary-card.green { border-left-color: var(--success); }
.summary-card.orange { border-left-color: var(--warning); }
.summary-card.red { border-left-color: var(--danger); }

.summary-card .label {
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--gray-500);
    margin-bottom: 0.25rem;
}

.summary-card .value {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--gray-900);
}

.summary-card .sub {
    font-size: 0.8rem;
    color: var(--gray-400);
    margin-top: 0.25rem;
}

/* ─── TABLE ──────────────────────────────────────────────── */

.table-container {
    overflow-x: auto;
}

table {
    width: 100%;
    border-collapse: collapse;
}

thead th {
    background: var(--gray-50);
    padding: 0.75rem 1rem;
    text-align: left;
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--gray-500);
    font-weight: 600;
    border-bottom: 2px solid var(--gray-200);
    white-space: nowrap;
}

tbody td {
    padding: 0.75rem 1rem;
    border-bottom: 1px solid var(--gray-100);
    font-size: 0.875rem;
}

tbody tr:hover { background: var(--gray-50); }

.text-right { text-align: right; }
.text-center { text-align: center; }

.money { font-variant-numeric: tabular-nums; font-weight: 500; }
.money.positive { color: var(--success); }
.money.negative { color: var(--danger); }

/* ─── BADGES ─────────────────────────────────────────────── */

.badge {
    display: inline-block;
    padding: 0.2rem 0.6rem;
    border-radius: 999px;
    font-size: 0.75rem;
    font-weight: 500;
}

.badge-paid {
    background: var(--success-light);
    color: var(--success);
}

.badge-pending {
    background: var(--warning-light);
    color: var(--warning);
}

/* ─── BUTTONS ────────────────────────────────────────────── */

.btn {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.5rem 1rem;
    border: none;
    border-radius: var(--radius);
    font-size: 0.875rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.15s;
    text-decoration: none;
    line-height: 1.4;
}

.btn-primary {
    background: var(--primary);
    color: white;
}
.btn-primary:hover { background: var(--primary-dark); }

.btn-success {
    background: var(--success);
    color: white;
}
.btn-success:hover { background: #15803d; }

.btn-danger {
    background: var(--danger);
    color: white;
}
.btn-danger:hover { background: #b91c1c; }

.btn-outline {
    background: white;
    color: var(--gray-600);
    border: 1px solid var(--gray-300);
}
.btn-outline:hover {
    background: var(--gray-50);
    border-color: var(--gray-400);
}

.btn-sm {
    padding: 0.3rem 0.6rem;
    font-size: 0.8rem;
}

.btn-icon {
    padding: 0.4rem;
    border-radius: 6px;
    background: transparent;
    border: none;
    cursor: pointer;
    color: var(--gray-400);
    transition: all 0.15s;
}

.btn-icon:hover { color: var(--gray-700); background: var(--gray-100); }
.btn-icon.danger:hover { color: var(--danger); background: var(--danger-light); }

/* ─── FORMS ──────────────────────────────────────────────── */

.form-group {
    margin-bottom: 1rem;
}

.form-group label {
    display: block;
    font-size: 0.8rem;
    font-weight: 500;
    color: var(--gray-600);
    margin-bottom: 0.3rem;
}

.form-control {
    width: 100%;
    padding: 0.5rem 0.75rem;
    border: 1px solid var(--gray-300);
    border-radius: var(--radius);
    font-size: 0.875rem;
    color: var(--gray-800);
    background: white;
    transition: border-color 0.15s;
}

.form-control:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-light);
}

select.form-control {
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' fill='%236b7280' viewBox='0 0 16 16'%3E%3Cpath d='M8 11L3 6h10l-5 5z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 0.75rem center;
    padding-right: 2rem;
}

.form-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 1rem;
}

.form-inline {
    display: flex;
    gap: 0.75rem;
    align-items: flex-end;
    flex-wrap: wrap;
}

.form-inline .form-group { margin-bottom: 0; }

/* ─── MODAL ──────────────────────────────────────────────── */

.modal-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 200;
    align-items: center;
    justify-content: center;
}

.modal-overlay.active { display: flex; }

.modal {
    background: white;
    border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
    width: 90%;
    max-width: 600px;
    max-height: 90vh;
    overflow-y: auto;
}

.modal-header {
    padding: 1rem 1.5rem;
    border-bottom: 1px solid var(--gray-200);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.modal-header h3 {
    font-size: 1.1rem;
    font-weight: 600;
}

.modal-body { padding: 1.5rem; }

.modal-footer {
    padding: 1rem 1.5rem;
    border-top: 1px solid var(--gray-200);
    display: flex;
    justify-content: flex-end;
    gap: 0.5rem;
}

/* ─── DASHBOARD MONTH GRID ───────────────────────────────── */

.month-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 1rem;
}

.month-card {
    background: white;
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 1rem 1.25rem;
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    transition: all 0.15s;
    text-decoration: none;
    color: inherit;
    border: 2px solid transparent;
}

.month-card:hover {
    box-shadow: var(--shadow-md);
    border-color: var(--primary-light);
    transform: translateY(-1px);
}

.month-card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.month-card-header h3 {
    font-size: 1rem;
    font-weight: 600;
    color: var(--gray-800);
}

.month-card-header .count {
    font-size: 0.75rem;
    color: var(--gray-400);
}

.month-card-stats {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.5rem;
}

.month-stat {
    font-size: 0.8rem;
}

.month-stat .label {
    color: var(--gray-500);
    font-size: 0.7rem;
}

.month-stat .value {
    font-weight: 600;
    font-variant-numeric: tabular-nums;
}

.month-card-footer {
    padding-top: 0.5rem;
    border-top: 1px solid var(--gray-100);
    font-size: 0.85rem;
    font-weight: 600;
}

.month-card-footer.positive { color: var(--success); }
.month-card-footer.negative { color: var(--danger); }

/* ─── LOGIN ──────────────────────────────────────────────── */

.login-container {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, var(--gray-900) 0%, #1e3a5f 100%);
}

.login-card {
    background: white;
    border-radius: 12px;
    box-shadow: var(--shadow-lg);
    padding: 2.5rem;
    width: 90%;
    max-width: 400px;
}

.login-card h1 {
    text-align: center;
    font-size: 1.5rem;
    margin-bottom: 0.25rem;
    color: var(--gray-900);
}

.login-card .subtitle {
    text-align: center;
    color: var(--gray-500);
    font-size: 0.875rem;
    margin-bottom: 2rem;
}

.login-card .error-msg {
    background: var(--danger-light);
    color: var(--danger);
    padding: 0.75rem;
    border-radius: var(--radius);
    font-size: 0.875rem;
    margin-bottom: 1rem;
    text-align: center;
}

.login-card .btn-primary {
    width: 100%;
    justify-content: center;
    padding: 0.75rem;
    font-size: 1rem;
}

/* ─── PAGE HEADER ────────────────────────────────────────── */

.page-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 1.5rem;
    flex-wrap: wrap;
    gap: 1rem;
}

.page-header h1 {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--gray-900);
}

.page-header .breadcrumb {
    font-size: 0.875rem;
    color: var(--gray-500);
}

.page-header .breadcrumb a {
    color: var(--primary);
    text-decoration: none;
}

/* ─── EMPTY STATE ────────────────────────────────────────── */

.empty-state {
    text-align: center;
    padding: 3rem 1rem;
    color: var(--gray-400);
}

.empty-state .icon { font-size: 3rem; margin-bottom: 1rem; }
.empty-state p { font-size: 0.95rem; }

/* ─── UTILITIES ──────────────────────────────────────────── */

.mt-1 { margin-top: 0.5rem; }
.mt-2 { margin-top: 1rem; }
.mt-3 { margin-top: 1.5rem; }
.mb-2 { margin-bottom: 1rem; }
.gap-1 { gap: 0.5rem; }
.flex { display: flex; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }

/* ─── BADGE CATEGORY ──────────────────────────────────────── */

.badge-cat {
    display: inline-block;
    padding: 0.15rem 0.5rem;
    border-radius: 999px;
    font-size: 0.7rem;
    font-weight: 500;
    background: var(--primary-light);
    color: var(--primary-dark);
}

.positive { color: var(--success); }

/* ─── PREVIEW BOX ────────────────────────────────────────── */

.preview-box {
    background: var(--gray-50);
    border: 1px solid var(--gray-200);
    border-radius: var(--radius);
    padding: 0.75rem 1rem;
    font-size: 0.8rem;
    color: var(--gray-600);
    margin-top: 0.5rem;
}

/* ─── RESPONSIVE DISPLAY ─────────────────────────────────── */

.desktop-only { display: block; }
.mobile-only { display: none; }

/* ─── MOBILE TRANSACTION CARDS ───────────────────────────── */

.tx-card {
    background: white;
    border: 1px solid var(--gray-200);
    border-radius: var(--radius);
    padding: 0.75rem 1rem;
    margin-bottom: 0.75rem;
}

.tx-card-top {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 0.5rem;
    margin-bottom: 0.5rem;
}

.tx-card-top strong {
    font-size: 0.9rem;
    color: var(--gray-800);
}

.tx-card-valor {
    font-weight: 700;
    font-size: 0.95rem;
    font-variant-numeric: tabular-nums;
    color: var(--gray-900);
    white-space: nowrap;
}

.tx-card-cat {
    font-size: 0.7rem;
    color: var(--primary);
    margin-top: 0.15rem;
}

.tx-card-details {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem 1rem;
    font-size: 0.75rem;
    color: var(--gray-500);
}

.tx-card-actions {
    display: flex;
    gap: 0.5rem;
    margin-top: 0.5rem;
    padding-top: 0.5rem;
    border-top: 1px solid var(--gray-100);
}

/* ─── RESPONSIVE ─────────────────────────────────────────── */

@media (max-width: 768px) {
    .main-content { padding: 1rem; }
    .navbar { padding: 0 0.75rem; }
    .navbar-brand { font-size: 0.95rem; }
    .navbar-user { display: none; }
    .page-header { flex-direction: column; align-items: flex-start; }
    .summary-grid { grid-template-columns: repeat(2, 1fr); }
    .summary-card { padding: 0.75rem; }
    .summary-card .value { font-size: 1.15rem; }
    .month-grid { grid-template-columns: 1fr; }
    .form-row { grid-template-columns: 1fr; }

    .desktop-only { display: none !important; }
    .mobile-only { display: block !important; }

    /* Touch-friendly targets */
    .btn { min-height: 44px; min-width: 44px; }
    .btn-sm { min-height: 38px; }
    .form-control { min-height: 44px; font-size: 16px; /* prevent iOS zoom */ }
    select.form-control { font-size: 16px; }

    /* Modal full-width on mobile */
    .modal { width: 95%; max-height: 85vh; }
    .modal-body { padding: 1rem; }
    .modal-header { padding: 0.75rem 1rem; }
    .modal-footer { padding: 0.75rem 1rem; }
}
