/* ==========================================================================
   Gestão de Gastos — Redesign completo (Dark, organizado, intuitivo)
   ========================================================================== */
@import url('https://fonts.googleapis.com/css2?family=DM+Sans:ital,opsz,wght@0,9..40,400;0,9..40,500;0,9..40,600;0,9..40,700&display=swap');

:root {
    --bg: #0a0d12;
    --bg-elevated: #11141c;
    --bg-card: #151922;
    --bg-card-hover: #1a1e28;
    --border: rgba(255, 255, 255, 0.06);
    --border-strong: rgba(255, 255, 255, 0.1);
    --text: #e8ecf1;
    --text-muted: #8892a0;
    --text-faint: #5c6574;
    --accent: #3b9eff;
    --accent-hover: #5aafff;
    --accent-dim: rgba(59, 158, 255, 0.12);
    --accent-glow: rgba(59, 158, 255, 0.2);
    --success: #34c759;
    --success-dim: rgba(52, 199, 89, 0.12);
    --danger: #ff5c5c;
    --danger-dim: rgba(255, 92, 92, 0.12);
    --radius: 14px;
    --radius-sm: 10px;
    --sidebar-w: 260px;
    --page-max: 1100px;
    --transition: 0.2s ease;
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    font-family: 'DM Sans', -apple-system, sans-serif;
    font-size: 15px;
    line-height: 1.55;
    color: var(--text);
    background: var(--bg);
    min-height: 100vh;
    -webkit-font-smoothing: antialiased;
}

/* ========== App shell: sidebar + main ========== */
.app-body {
    display: flex;
    min-height: 100vh;
}

.sidebar {
    position: fixed;
    top: 0;
    left: 0;
    width: var(--sidebar-w);
    height: 100vh;
    background: var(--bg-elevated);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    z-index: 100;
    transition: transform var(--transition);
}

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

.sidebar-logo {
    width: 36px;
    height: 36px;
    border-radius: 10px;
    background: linear-gradient(135deg, var(--accent) 0%, #2b7dd9 100%);
    box-shadow: 0 4px 14px var(--accent-glow);
}

.sidebar-title {
    font-weight: 700;
    font-size: 1.05rem;
    letter-spacing: -0.02em;
    color: var(--text);
}

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

.sidebar-link {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.65rem 1rem;
    border-radius: var(--radius-sm);
    color: var(--text-muted);
    text-decoration: none;
    font-weight: 500;
    font-size: 0.9375rem;
    transition: background var(--transition), color var(--transition);
}

.sidebar-link:hover {
    color: var(--text);
    background: var(--border);
}

.sidebar-link.is-active {
    color: var(--accent);
    background: var(--accent-dim);
}

.sidebar-link-icon {
    font-size: 1.1rem;
    opacity: 0.9;
    width: 1.5em;
    text-align: center;
}

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

.sidebar-user {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.sidebar-user-name {
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--text);
}

.sidebar-logout {
    font-size: 0.8125rem;
    color: var(--text-faint);
    text-decoration: none;
    transition: color var(--transition);
}

.sidebar-logout:hover {
    color: var(--danger);
}

/* Hamburger (mobile) */
.sidebar-toggle {
    display: none;
    position: fixed;
    top: 1rem;
    left: 1rem;
    z-index: 101;
    width: 44px;
    height: 44px;
    border: none;
    border-radius: var(--radius-sm);
    background: var(--bg-card);
    border: 1px solid var(--border);
    cursor: pointer;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 5px;
    padding: 0;
}

.sidebar-toggle span {
    display: block;
    width: 18px;
    height: 2px;
    background: var(--text);
    border-radius: 1px;
    transition: var(--transition);
}

.app-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 99;
    opacity: 0;
    transition: opacity var(--transition);
}

.app-overlay.is-visible {
    display: block;
    opacity: 1;
}

.app-main {
    flex: 1;
    margin-left: var(--sidebar-w);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

.page {
    flex: 1;
    width: 100%;
    max-width: var(--page-max);
    margin: 0 auto;
    padding: 2rem 1.75rem;
}

@media (max-width: 900px) {
    .sidebar {
        transform: translateX(-100%);
    }
    .sidebar.is-open {
        transform: translateX(0);
    }
    .sidebar-toggle {
        display: flex;
    }
    .app-main {
        margin-left: 0;
        padding-top: 60px;
    }
    .page {
        padding: 1.5rem 1rem;
    }
}

/* ========== Page structure: header, sections ========== */
.page-header {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    margin-bottom: 1.75rem;
}

.page-title {
    margin: 0;
    font-size: 1.65rem;
    font-weight: 700;
    letter-spacing: -0.02em;
    color: var(--text);
}

.page-description {
    margin: 0.25rem 0 0;
    font-size: 0.9375rem;
    color: var(--text-muted);
    max-width: 56ch;
}

.section {
    margin-bottom: 2rem;
}

.section:last-child {
    margin-bottom: 0;
}

.section-title {
    margin: 0 0 1rem;
    font-size: 0.8125rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--text-muted);
}

/* ========== Toolbar (filtros + ação principal) ========== */
.toolbar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.75rem;
    margin-bottom: 1.25rem;
    padding: 1rem 1.25rem;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
}

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

.toolbar input[type="date"],
.toolbar select {
    padding: 0.5rem 0.85rem;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--bg-elevated);
    color: var(--text);
    font-size: 0.9375rem;
}

.toolbar input:focus,
.toolbar select:focus {
    border-color: var(--accent);
    outline: none;
}

.toolbar-actions {
    margin-left: auto;
    display: flex;
    gap: 0.5rem;
}

/* ========== Buttons ========== */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.4rem;
    padding: 0.55rem 1.1rem;
    border-radius: var(--radius-sm);
    font-size: 0.9375rem;
    font-weight: 500;
    font-family: inherit;
    cursor: pointer;
    border: none;
    text-decoration: none;
    transition: background var(--transition), color var(--transition), box-shadow var(--transition);
}

.btn-primary {
    background: var(--accent);
    color: #fff;
}

.btn-primary:hover {
    background: var(--accent-hover);
    box-shadow: 0 4px 20px var(--accent-glow);
}

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

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

.btn-danger {
    background: transparent;
    color: var(--danger);
    border: 1px solid var(--danger);
}

.btn-danger:hover {
    background: var(--danger-dim);
}

.btn-sm {
    padding: 0.4rem 0.75rem;
    font-size: 0.875rem;
}

/* ========== Cards ========== */
.cards {
    display: grid;
    gap: 1.25rem;
}

.cards-2 { grid-template-columns: repeat(2, 1fr); }
.cards-3 { grid-template-columns: repeat(3, 1fr); }
.cards-4 { grid-template-columns: repeat(4, 1fr); }

.card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.35rem 1.5rem;
    transition: border-color var(--transition), box-shadow var(--transition);
}

.card:hover {
    border-color: var(--border-strong);
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.25);
}

.card-label {
    font-size: 0.8125rem;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--text-muted);
    margin-bottom: 0.4rem;
}

.card-value {
    font-size: 1.5rem;
    font-weight: 700;
    letter-spacing: -0.02em;
    color: var(--text);
}

.card-value.positive { color: var(--success); }
.card-value.negative { color: var(--danger); }

/* Hero card (destaque) */
.card-hero {
    padding: 1.75rem 1.5rem;
    background: linear-gradient(145deg, var(--bg-card) 0%, var(--bg-card-hover) 100%);
    border-color: rgba(255, 255, 255, 0.08);
}

.card-hero .card-value {
    font-size: 1.85rem;
}

/* ========== Dashboard: fluxo + patrimônio ========== */
.dashboard-period {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.dashboard-period select {
    padding: 0.45rem 0.75rem;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--bg-card);
    color: var(--text);
    font-size: 0.9rem;
}

.dashboard-period select:focus {
    border-color: var(--accent);
    outline: none;
}

.dashboard-period-form {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.dashboard-actions {
    margin-top: 1.5rem;
    padding-top: 1.25rem;
    border-top: 1px solid var(--border);
}

/* ========== Tables ========== */
.table-section {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
}

.table-section table {
    width: 100%;
    border-collapse: collapse;
}

.table-section th,
.table-section td {
    padding: 0.9rem 1.25rem;
    text-align: left;
    border-bottom: 1px solid var(--border);
}

.table-section th {
    background: var(--bg-elevated);
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-muted);
}

.table-section tbody tr:last-child td {
    border-bottom: none;
}

.table-section tbody tr:hover td {
    background: var(--bg-card-hover);
}

.table-actions {
    display: flex;
    gap: 0.35rem;
}

/* ========== Forms ========== */
.form-group {
    margin-bottom: 1.1rem;
}

.form-group:last-of-type {
    margin-bottom: 0;
}

form label {
    display: block;
    margin-bottom: 0.4rem;
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--text-muted);
}

form input[type="text"],
form input[type="email"],
form input[type="password"],
form input[type="number"],
form input[type="date"],
form select {
    width: 100%;
    padding: 0.6rem 0.9rem;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--bg-elevated);
    color: var(--text);
    font-size: 0.9375rem;
    font-family: inherit;
    transition: border-color var(--transition), box-shadow var(--transition);
}

form input:focus,
form select:focus {
    border-color: var(--accent);
    outline: none;
    box-shadow: 0 0 0 3px var(--accent-dim);
}

form input::placeholder {
    color: var(--text-faint);
}

.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
}

.form-actions {
    margin-top: 1.5rem;
    padding-top: 1.25rem;
    border-top: 1px solid var(--border);
    display: flex;
    gap: 0.75rem;
    flex-wrap: wrap;
}

form button[type="submit"] {
    padding: 0.6rem 1.35rem;
    border-radius: var(--radius-sm);
    border: none;
    background: var(--accent);
    color: #fff;
    font-weight: 600;
    font-size: 0.9375rem;
    cursor: pointer;
    font-family: inherit;
    transition: background var(--transition), box-shadow var(--transition);
}

form button[type="submit"]:hover {
    background: var(--accent-hover);
    box-shadow: 0 4px 20px var(--accent-glow);
}

.hint {
    font-size: 0.8125rem;
    color: var(--text-faint);
    margin-top: 0.5rem;
}

.erro {
    font-size: 0.9rem;
    color: var(--danger);
    margin-bottom: 0.5rem;
}

/* ========== Modal ========== */
.modal {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.7);
    z-index: 200;
    align-items: center;
    justify-content: center;
    padding: 1.5rem;
    backdrop-filter: blur(8px);
}

.modal[data-open="true"] {
    display: flex;
}

.modal-content {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.75rem;
    max-width: 440px;
    width: 100%;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: 0 24px 56px rgba(0, 0, 0, 0.45);
}

.modal-content .section-title {
    margin-bottom: 0.75rem;
}

.modal-content h3 {
    margin: 0 0 1.25rem;
    font-size: 1.2rem;
    font-weight: 600;
    color: var(--text);
}

/* ========== Calculadora: dois blocos ========== */
.calc-layout {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 2rem;
    align-items: start;
}

.calc-form-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.5rem;
}

.calc-result-card {
    background: linear-gradient(145deg, var(--bg-card) 0%, var(--bg-card-hover) 100%);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: var(--radius);
    padding: 1.75rem;
}

.calc-result-card .card-label {
    margin-bottom: 0.5rem;
}

.calc-result-card .card-value {
    font-size: 1.35rem;
}

.range-row {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin-top: 0.5rem;
}

.range-row input[type="range"] {
    flex: 1;
    height: 6px;
    -webkit-appearance: none;
    appearance: none;
    background: var(--border);
    border-radius: 3px;
}

.range-row input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: var(--accent);
    cursor: pointer;
}

.range-value {
    font-weight: 600;
    color: var(--accent);
    min-width: 3ch;
}

/* ========== Configurações: grupos ========== */
.config-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.75rem;
    margin-bottom: 1.5rem;
}

.config-card:last-child {
    margin-bottom: 0;
}

.config-card-title {
    margin: 0 0 1.25rem;
    font-size: 1rem;
    font-weight: 600;
    color: var(--text);
    padding-bottom: 0.75rem;
    border-bottom: 1px solid var(--border);
}

.config-fields {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 1rem;
}

/* ========== Login ========== */
.login-page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1.5rem;
    background: 
        radial-gradient(ellipse 90% 60% at 50% -15%, var(--accent-dim) 0%, transparent 55%),
        var(--bg);
}

.login-card {
    width: 100%;
    max-width: 400px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 2.5rem;
    box-shadow: 0 24px 56px rgba(0, 0, 0, 0.35);
}

.login-brand {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin-bottom: 0.5rem;
}

.login-brand-icon {
    width: 44px;
    height: 44px;
    border-radius: 12px;
    background: linear-gradient(135deg, var(--accent) 0%, #2b7dd9 100%);
    box-shadow: 0 6px 20px var(--accent-glow);
}

.login-card h1 {
    margin: 0;
    font-size: 1.6rem;
    font-weight: 700;
    letter-spacing: -0.02em;
    color: var(--text);
}

.login-card .subtitle {
    margin: 0 0 1.75rem;
    font-size: 0.9375rem;
    color: var(--text-muted);
    line-height: 1.5;
}

.login-card .hint {
    margin-top: 1.25rem;
}

.login-card button[type="submit"] {
    width: 100%;
    padding: 0.75rem;
    margin-top: 0.75rem;
}

/* ========== Responsivo ========== */
@media (max-width: 900px) {
    .cards-2,
    .cards-3,
    .cards-4 {
        grid-template-columns: 1fr;
    }
    .calc-layout {
        grid-template-columns: 1fr;
    }
    .form-row {
        grid-template-columns: 1fr;
    }
    .config-fields {
        grid-template-columns: 1fr;
    }
    .page-header {
        flex-direction: column;
        align-items: flex-start;
    }
    .toolbar {
        flex-direction: column;
        align-items: stretch;
    }
    .toolbar-actions {
        margin-left: 0;
    }
    .table-section th,
    .table-section td {
        padding: 0.75rem 1rem;
        font-size: 0.875rem;
    }
}

@media (max-width: 500px) {
    .table-section {
        overflow-x: auto;
    }
    .table-section table {
        min-width: 560px;
    }
}
