@import url('https://fonts.googleapis.com/css2?family=Sora:wght@400;500;600;700;800&family=Plus+Jakarta+Sans:wght@400;500;600;700&display=swap');

:root {
    --bg:              #F7F8FC;
    --surface:         #FFFFFF;
    --primary:         #5A67F2;
    --primary-light:   #ECEFFE;
    --income:          #059669;
    --income-light:    #ECFDF5;
    --expense:         #E11D48;
    --expense-light:   #FFF1F2;
    --text:            #111827;
    --text-secondary:  #6B7280;
    --text-muted:      #9CA3AF;
    --border:          #E5E7EB;
    --border-light:    #F3F4F6;
    --font-display:    'Sora', sans-serif;
    --font-body:       'Plus Jakarta Sans', sans-serif;
    --r-sm:  8px;
    --r-md:  12px;
    --r-lg:  16px;
    --r-xl:  20px;
    --shadow-sm: 0 1px 3px rgba(0,0,0,0.04), 0 1px 2px rgba(0,0,0,0.06);
    --shadow-md: 0 4px 6px -1px rgba(0,0,0,0.07), 0 2px 4px -1px rgba(0,0,0,0.04);
    --shadow-lg: 0 10px 15px -3px rgba(0,0,0,0.08), 0 4px 6px -2px rgba(0,0,0,0.04);
    --topbar-h: 56px;
}

* { box-sizing: border-box; }

body {
    background-color: var(--bg);
    font-family: var(--font-body);
    color: var(--text);
    font-size: 14px;
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
}

/* ─── App Layout (flexbox) ─────────────────────────── */
.app-layout {
    display: flex;
    align-items: stretch;
    min-height: 100vh;
    min-height: 100dvh;
}

/* ─── Sidebar ──────────────────────────────────────── */
.sidebar {
    width: 220px;
    flex-shrink: 0;
    background: var(--surface);
    border-right: 1px solid var(--border);
}

.sidebar-sticky {
    position: sticky;
    top: 0;
    height: 100vh;
    padding: 1.5rem 1rem;
    overflow-x: hidden;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
}

.sidebar-brand {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 0.25rem 0.5rem;
    margin-bottom: 2rem;
    text-decoration: none;
}

.sidebar-brand-icon {
    width: 36px;
    height: 36px;
    background: var(--primary);
    border-radius: var(--r-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 16px;
    flex-shrink: 0;
}

.sidebar-brand-text {
    font-family: var(--font-display);
    font-weight: 700;
    font-size: 17px;
    color: var(--text);
    letter-spacing: -0.3px;
}

.nav-section-label {
    font-size: 10px;
    font-weight: 700;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    color: var(--text-muted);
    padding: 0 0.5rem;
    margin: 1.25rem 0 0.4rem;
    display: block;
}

.nav-link {
    display: flex;
    align-items: center;
    gap: 10px;
    color: var(--text-secondary);
    font-weight: 500;
    font-size: 13.5px;
    padding: 0.6rem 0.75rem;
    border-radius: var(--r-sm);
    margin-bottom: 2px;
    transition: background 0.14s, color 0.14s;
    border-left: 3px solid transparent;
    line-height: 1.4;
    text-decoration: none;
}

.nav-link i {
    font-size: 16px;
    width: 20px;
    text-align: center;
    flex-shrink: 0;
}

.nav-link:hover {
    background-color: var(--border-light);
    color: var(--text);
    text-decoration: none;
}

.nav-link.active {
    background-color: var(--primary-light);
    color: var(--primary);
    border-left-color: var(--primary);
    font-weight: 600;
}

.nav-link.nav-danger { color: var(--expense) !important; }
.nav-link.nav-danger:hover {
    background-color: var(--expense-light);
    color: var(--expense) !important;
}

.sidebar hr {
    border-color: var(--border);
    margin: 0.75rem 0.5rem;
    opacity: 1;
}

/* ─── Main content area ────────────────────────────── */
.app-main {
    flex: 1 1 0;
    min-width: 0;
    padding: 1.75rem 2rem;
}

#page-title {
    font-family: var(--font-display);
    font-weight: 700;
    font-size: 21px;
    letter-spacing: -0.4px;
    color: var(--text);
    line-height: 1;
}

/* ─── Mobile top bar ───────────────────────────────── */
.mobile-topbar {
    position: sticky;
    top: 0;
    z-index: 200;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.65rem 1rem;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    box-shadow: var(--shadow-sm);
    height: var(--topbar-h);
}

.mobile-topbar .sidebar-brand {
    margin-bottom: 0;
    padding: 0;
}

.mobile-menu-btn {
    background: none;
    border: 1.5px solid var(--border);
    color: var(--text);
    font-size: 20px;
    line-height: 1;
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--r-sm);
    cursor: pointer;
    transition: background 0.14s;
    padding: 0;
}

.mobile-menu-btn:hover {
    background: var(--border-light);
}

/* ─── Offcanvas sidebar ────────────────────────────── */
.offcanvas-header {
    padding: 1rem;
    border-bottom: 1px solid var(--border) !important;
}

.offcanvas-header .sidebar-brand {
    margin-bottom: 0;
    padding: 0;
}

.offcanvas-body .nav-section-label:first-child {
    margin-top: 0;
}

/* ─── Page header ──────────────────────────────────── */
.page-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 0.5rem;
    padding-bottom: 0.75rem;
    margin-bottom: 1.25rem;
    border-bottom: 1px solid var(--border);
}

.page-header h1 {
    margin: 0;
    font-family: var(--font-display);
    font-weight: 700;
    font-size: 20px;
    letter-spacing: -0.3px;
    color: var(--text);
    line-height: 1;
}

/* ─── Cards ────────────────────────────────────────── */
.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--r-lg);
    box-shadow: var(--shadow-sm);
}

.card-body { padding: 1.5rem; }

.card-title {
    font-family: var(--font-display);
    font-weight: 600;
    font-size: 14px;
    color: var(--text);
    letter-spacing: -0.1px;
}

/* KPI Cards — colored left strip */
.kpi-card {
    border-left: 4px solid transparent;
    transition: transform 0.15s, box-shadow 0.15s;
}
.kpi-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}
.kpi-card.income { border-left-color: var(--income); }
.kpi-card.expense { border-left-color: var(--expense); }
.kpi-card.balance { border-left-color: var(--primary); }

.kpi-icon {
    width: 40px;
    height: 40px;
    border-radius: var(--r-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    margin-bottom: 1rem;
}
.kpi-card.income .kpi-icon { background: var(--income-light); color: var(--income); }
.kpi-card.expense .kpi-icon { background: var(--expense-light); color: var(--expense); }
.kpi-card.balance .kpi-icon { background: var(--primary-light); color: var(--primary); }

.kpi-label {
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.07em;
    text-transform: uppercase;
    margin-bottom: 0.35rem;
    line-height: 1;
}
.kpi-card.income .kpi-label { color: var(--income); }
.kpi-card.expense .kpi-label { color: var(--expense); }
.kpi-card.balance .kpi-label { color: var(--primary); }

.kpi-value {
    font-family: var(--font-display);
    font-size: 24px;
    font-weight: 700;
    letter-spacing: -0.5px;
    color: var(--text);
    line-height: 1.1;
}

/* ─── Table ────────────────────────────────────────── */
.table {
    color: var(--text);
    font-size: 13.5px;
    margin: 0;
}
.table th {
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.07em;
    text-transform: uppercase;
    color: var(--text-muted);
    border-top: none;
    border-bottom: 1px solid var(--border) !important;
    padding: 0.75rem 1.25rem;
    background: transparent;
}
.table td {
    padding: 0.9rem 1.25rem;
    vertical-align: middle;
}
.table > :not(caption) > * > * { border-bottom-color: var(--border-light); }
.table-hover tbody tr:hover td { background-color: var(--border-light); }
.table-light th { background: var(--border-light); }
.table-responsive { border-radius: var(--r-lg); overflow: hidden; }

/* ─── Buttons ──────────────────────────────────────── */
.btn {
    font-family: var(--font-body);
    font-weight: 600;
    font-size: 13.5px;
    border-radius: var(--r-sm);
    transition: all 0.14s;
    line-height: 1.4;
}

.btn-primary { background: var(--primary); border-color: var(--primary); }
.btn-primary:hover, .btn-primary:focus {
    background: #4754e0;
    border-color: #4754e0;
    box-shadow: 0 4px 12px rgba(90,103,242,0.3);
}

.btn-sm { font-size: 12px; padding: 0.3rem 0.65rem; border-radius: 6px; }

.btn-outline-primary { color: var(--primary); border-color: var(--primary); }
.btn-outline-primary:hover { background: var(--primary); border-color: var(--primary); color: white; }

.btn-outline-danger {
    color: var(--expense);
    border-color: #FECDD3;
    background: var(--expense-light);
}
.btn-outline-danger:hover {
    background: var(--expense);
    border-color: var(--expense);
    color: white;
}

.btn-outline-success {
    color: var(--income);
    border-color: #A7F3D0;
    background: var(--income-light);
}
.btn-outline-success:hover {
    background: var(--income);
    border-color: var(--income);
    color: white;
}

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

.btn-secondary {
    background: var(--border-light);
    border-color: var(--border);
    color: var(--text-secondary);
}
.btn-secondary:hover {
    background: var(--border);
    border-color: var(--border);
    color: var(--text);
}

/* ─── Forms ────────────────────────────────────────── */
.form-control, .form-select {
    border: 1.5px solid var(--border);
    border-radius: var(--r-sm);
    font-family: var(--font-body);
    font-size: 13.5px;
    color: var(--text);
    background: var(--surface);
    transition: border-color 0.14s, box-shadow 0.14s;
    padding: 0.55rem 0.85rem;
}
.form-control:focus, .form-select:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(90,103,242,0.12);
    outline: none;
}
.form-label {
    font-size: 12px;
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: 0.35rem;
    letter-spacing: 0.02em;
}
.form-control-color { padding: 0.35rem; height: 40px; }

/* ─── Modal ────────────────────────────────────────── */
.modal-content {
    border: none;
    border-radius: var(--r-xl);
    box-shadow: 0 20px 40px rgba(0,0,0,0.12);
}
.modal-header {
    border-bottom: 1px solid var(--border);
    padding: 1.25rem 1.5rem;
}
.modal-title {
    font-family: var(--font-display);
    font-weight: 700;
    font-size: 16px;
    letter-spacing: -0.2px;
}
.modal-footer {
    border-top: 1px solid var(--border);
    padding: 1rem 1.5rem;
    gap: 0.5rem;
}
.modal-body { padding: 1.5rem; }

/* ─── Badge ────────────────────────────────────────── */
.badge {
    font-family: var(--font-body);
    font-size: 11px;
    font-weight: 600;
    padding: 0.3em 0.7em;
    border-radius: 20px;
    letter-spacing: 0.02em;
}
.bg-success { background-color: var(--income) !important; }
.bg-danger  { background-color: var(--expense) !important; }

/* ─── Auth ─────────────────────────────────────────── */
.auth-wrapper {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg);
    position: relative;
    overflow: hidden;
    padding: 1rem;
}
.auth-wrapper::before {
    content: '';
    position: absolute;
    top: -35%;
    right: -15%;
    width: 550px;
    height: 550px;
    background: radial-gradient(circle, rgba(90,103,242,0.09) 0%, transparent 65%);
    pointer-events: none;
}
.auth-wrapper::after {
    content: '';
    position: absolute;
    bottom: -25%;
    left: -10%;
    width: 400px;
    height: 400px;
    background: radial-gradient(circle, rgba(5,150,105,0.07) 0%, transparent 65%);
    pointer-events: none;
}
.auth-card {
    width: 100%;
    max-width: 420px;
    padding: 2.5rem;
    background: var(--surface);
    border-radius: var(--r-xl);
    border: 1px solid var(--border);
    box-shadow: var(--shadow-lg);
    position: relative;
    z-index: 1;
    animation: slideUp 0.35s cubic-bezier(0.16, 1, 0.3, 1);
}
@keyframes slideUp {
    from { opacity: 0; transform: translateY(16px); }
    to   { opacity: 1; transform: translateY(0); }
}
.auth-logo {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 0.4rem;
}
.auth-logo-icon {
    width: 44px;
    height: 44px;
    background: var(--primary);
    border-radius: var(--r-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 20px;
}
.auth-logo-text {
    font-family: var(--font-display);
    font-weight: 700;
    font-size: 22px;
    letter-spacing: -0.5px;
    color: var(--text);
}
.auth-subtitle {
    font-size: 14px;
    color: var(--text-secondary);
    margin-bottom: 0;
}

/* ─── Category icon ────────────────────────────────── */
.cat-icon {
    width: 52px;
    height: 52px;
    border-radius: var(--r-md);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 22px;
    color: white;
    margin: 0 auto 0.75rem;
    flex-shrink: 0;
}

.cat-card {
    transition: transform 0.15s, box-shadow 0.15s;
    cursor: default;
}
.cat-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

/* ─── Amount colors ────────────────────────────────── */
.text-income  { color: var(--income) !important; }
.text-expense { color: var(--expense) !important; }
.text-success { color: var(--income) !important; }
.text-danger  { color: var(--expense) !important; }

/* ─── Transaction icon ─────────────────────────────── */
.txn-icon {
    width: 34px;
    height: 34px;
    border-radius: var(--r-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    color: white;
    flex-shrink: 0;
}

/* ─── Misc ─────────────────────────────────────────── */
#app-loader { background: var(--bg); }
.spinner-border { color: var(--primary) !important; }
.border-bottom { border-color: var(--border) !important; }
.text-muted { color: var(--text-muted) !important; }
.bg-light { background-color: var(--border-light) !important; }

.toast {
    border: none;
    border-radius: var(--r-md);
    box-shadow: var(--shadow-lg);
    font-family: var(--font-body);
    font-size: 13.5px;
    font-weight: 500;
}

::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-muted); }

/* ─── Responsive: tablet (md) ──────────────────────── */
@media (max-width: 991.98px) {
    .sidebar { width: 200px; }
    .app-main { padding: 1.5rem 1.25rem; }
}

/* ─── Responsive: mobile (< md = 768px) ────────────── */
@media (max-width: 767.98px) {
    .app-main {
        padding: 1rem;
    }

    /* Modais com margem adequada */
    .modal-dialog {
        margin: 0.75rem;
        max-width: calc(100vw - 1.5rem);
    }

    /* Auth card menor padding no celular */
    .auth-card {
        padding: 1.75rem 1.25rem;
    }

    /* KPI value menor no mobile */
    .kpi-value { font-size: 20px; }

    /* Card body com menos padding */
    .card-body { padding: 1rem; }

    /* Tabela: células com padding menor */
    .table th, .table td {
        padding: 0.6rem 0.75rem;
    }

    /* Nav tabs: rolagem horizontal */
    .nav-tabs {
        flex-wrap: nowrap;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        scrollbar-width: none;
    }
    .nav-tabs::-webkit-scrollbar { display: none; }
    .nav-tabs .nav-link {
        white-space: nowrap;
    }

    /* Formulários em linha nos modais: empilhar */
    .modal-body .row > [class*="col-md-"] {
        width: 100%;
    }
}

/* Utilitário: ocultar coluna em mobile */
@media (max-width: 767.98px) {
    .col-hide-mobile { display: none !important; }
}
