/* ============================================================
   CONTROLE FINANCEIRO — Light Theme, Professional Design
   ============================================================ */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700;800&display=swap');

/* ── Variáveis ── */
:root {
    --bg-primary: #f4f6f9;
    --bg-secondary: #ffffff;
    --bg-card: #ffffff;
    --bg-card-hover: #f8fafc;
    --bg-glass: rgba(0, 0, 0, 0.015);
    --bg-input: #f1f5f9;
    --bg-input-focus: #e8edf4;

    --border: #e2e8f0;
    --border-hover: #cbd5e1;
    --border-focus: rgba(59, 130, 246, 0.5);

    --text-primary: #1e293b;
    --text-secondary: #475569;
    --text-muted: #94a3b8;
    --text-dim: #cbd5e1;

    --accent: #3b82f6;
    --accent-hover: #2563eb;
    --accent-glow: rgba(59, 130, 246, 0.1);
    --accent-light: #eff6ff;

    --green: #16a34a;
    --green-soft: rgba(22, 163, 74, 0.08);
    --green-text: #15803d;
    --green-bg: #f0fdf4;

    --red: #dc2626;
    --red-soft: rgba(220, 38, 38, 0.06);
    --red-text: #b91c1c;

    --yellow: #d97706;
    --yellow-soft: rgba(217, 119, 6, 0.06);
    --yellow-text: #b45309;

    --purple: #7c3aed;
    --purple-soft: rgba(124, 58, 237, 0.06);

    --cyan: #0891b2;
    --cyan-soft: rgba(8, 145, 178, 0.06);

    --radius: 12px;
    --radius-sm: 8px;
    --radius-lg: 16px;
    --shadow-sm: 0 1px 3px rgba(0,0,0,0.04), 0 1px 2px rgba(0,0,0,0.03);
    --shadow: 0 4px 16px rgba(0, 0, 0, 0.05);
    --shadow-lg: 0 8px 30px rgba(0, 0, 0, 0.08);
    --transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

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

html {
    font-size: 15px;
    scroll-behavior: smooth;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    min-height: 100vh;
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
}

/* ── SVG Icon Base ── */
.icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 18px;
    height: 18px;
    flex-shrink: 0;
}

.icon svg {
    width: 100%;
    height: 100%;
    stroke: currentColor;
    stroke-width: 2;
    stroke-linecap: round;
    stroke-linejoin: round;
    fill: none;
}

.icon-sm { width: 15px; height: 15px; }
.icon-lg { width: 22px; height: 22px; }

/* ── Layout ── */
.app-container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 24px 28px 60px;
}

/* ── Header ── */
.app-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 20px 28px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    margin-bottom: 24px;
    box-shadow: var(--shadow-sm);
    position: sticky;
    top: 10px;
    z-index: 900;
}

.app-header h1 {
    font-size: 1.35rem;
    font-weight: 700;
    color: var(--text-primary);
    display: flex;
    align-items: center;
    gap: 10px;
}

.app-header h1 .icon {
    color: var(--accent);
    width: 24px;
    height: 24px;
}

.month-nav {
    display: flex;
    align-items: center;
    gap: 8px;
}

.month-nav .month-label {
    font-size: 1.05rem;
    font-weight: 600;
    color: var(--text-primary);
    min-width: 180px;
    text-align: center;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 8px 16px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--bg-secondary);
    color: var(--text-secondary);
    font-family: inherit;
    font-size: 0.85rem;
    font-weight: 500;
    cursor: pointer;
    transition: var(--transition);
    white-space: nowrap;
}

.btn:hover {
    background: var(--bg-card-hover);
    border-color: var(--border-hover);
    color: var(--text-primary);
    box-shadow: var(--shadow-sm);
}

.btn-icon {
    padding: 8px 10px;
    font-size: 1rem;
}

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

.btn-accent:hover {
    background: var(--accent-hover);
    border-color: var(--accent-hover);
    box-shadow: 0 2px 12px var(--accent-glow);
}

.btn-danger {
    color: var(--red);
    border-color: transparent;
    background: transparent;
    padding: 4px 8px;
    font-size: 0.8rem;
    transition: var(--transition);
}

.fin-table .btn-danger {
    opacity: 0;
}

.fin-table tr:hover .btn-danger {
    opacity: 1;
}

.btn-sm {
    padding: 5px 12px;
    font-size: 0.8rem;
}

/* ── Dashboard / Resumo ── */
.dashboard {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 16px;
    margin-bottom: 28px;
    align-items: start;
}

.dash-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 20px 22px;
    transition: var(--transition);
    position: relative;
    overflow: hidden;
    box-shadow: var(--shadow-sm);
}

.dash-card.entrada {
    position: sticky;
    top: 108px;
    z-index: 850;
}

.dash-card:hover {
    box-shadow: var(--shadow);
    transform: translateY(-1px);
}

.dash-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 3px;
    border-radius: var(--radius) var(--radius) 0 0;
}

.dash-card.entrada::before { background: linear-gradient(90deg, #16a34a, #0891b2); }
.dash-card.desconto::before { background: linear-gradient(90deg, #d97706, #ea580c); }
.dash-card.gastos::before { background: linear-gradient(90deg, #dc2626, #ea580c); }
.dash-card.saldo::before { background: linear-gradient(90deg, #3b82f6, #7c3aed); }
.dash-card.percentual::before { background: linear-gradient(90deg, #7c3aed, #0891b2); }

.dash-card .dash-header {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 8px;
}

.dash-card .dash-header .icon {
    color: var(--text-muted);
}

.dash-card .label {
    font-size: 0.72rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: var(--text-muted);
}

.dash-card .value {
    font-size: 1.45rem;
    font-weight: 700;
    color: var(--text-primary);
}

.dash-card.saldo .value.positivo { color: var(--green-text); }
.dash-card.saldo .value.negativo { color: var(--red-text); }

/* Progress bar */
.progress-bar {
    width: 100%;
    height: 6px;
    background: var(--bg-input);
    border-radius: 3px;
    margin-top: 12px;
    overflow: hidden;
}

.progress-fill {
    height: 100%;
    border-radius: 3px;
    transition: width 0.6s cubic-bezier(0.4, 0, 0.2, 1);
    background: linear-gradient(90deg, #16a34a, #d97706, #dc2626);
}

/* ── Sections Grid ── */
.sections-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 24px;
    margin-bottom: 28px;
}

/* ── Section Card ── */
.section {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
    overflow: hidden;
    animation: fadeInUp 0.4s ease-out;
}

@keyframes fadeInUp {
    from { opacity: 0; transform: translateY(12px); }
    to { opacity: 1; transform: translateY(0); }
}

.section-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 22px;
    border-bottom: 1px solid var(--border);
    background: var(--bg-glass);
}

.section-header h2 {
    font-size: 0.85rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.8px;
    color: var(--text-secondary);
    display: flex;
    align-items: center;
    gap: 8px;
}

.section-header h2 .icon {
    color: var(--accent);
}

.section-body {
    padding: 0;
}

/* ── Table ── */
.fin-table {
    width: 100%;
    border-collapse: collapse;
}

.fin-table th {
    padding: 10px 16px;
    font-size: 0.68rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: var(--text-muted);
    text-align: left;
    border-bottom: 1px solid var(--border);
    background: var(--bg-glass);
}

.fin-table th:last-child {
    text-align: center;
    width: 50px;
}

.fin-table td {
    padding: 10px 16px;
    font-size: 0.9rem;
    border-bottom: 1px solid var(--border);
    vertical-align: middle;
    transition: var(--transition);
}

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

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

.fin-table tr:hover .btn-danger {
    opacity: 1;
}

.fin-table tr.pago td {
    opacity: 0.45;
    background: var(--green-bg);
}

.fin-table tr.pago td:nth-child(2) {
    text-decoration: line-through;
    text-decoration-color: var(--green);
}

.fin-table tr.pago td:nth-child(3) {
    text-decoration: line-through;
    text-decoration-color: var(--green);
}

.fin-table tr.nao-validado td {
    color: var(--red);
    background: var(--red-soft);
}

.fin-table tr.nao-validado .col-valor,
.fin-table tr.nao-validado .col-desconto {
    color: var(--red);
}

.btn-validate {
    color: var(--yellow-text);
    background: transparent;
    border: none;
    cursor: pointer;
    padding: 4px;
    font-size: 0.9rem;
    transition: var(--transition);
}

.btn-validate:hover {
    color: var(--green);
    transform: scale(1.1);
}

/* Inline editing */
.fin-table .editable {
    cursor: pointer;
    padding: 3px 6px;
    border-radius: 4px;
    transition: var(--transition);
    display: inline-block;
    min-width: 30px;
}

.fin-table .editable:hover {
    background: var(--bg-input);
}

.inline-input {
    background: var(--bg-input-focus);
    border: 1px solid var(--border-focus);
    border-radius: 4px;
    color: var(--text-primary);
    font-family: inherit;
    font-size: 0.9rem;
    padding: 4px 8px;
    outline: none;
    width: 100%;
    max-width: 260px;
    transition: var(--transition);
}

.inline-input:focus {
    box-shadow: 0 0 0 3px var(--accent-glow);
}

.inline-input.input-valor {
    max-width: 130px;
    text-align: right;
    font-variant-numeric: tabular-nums;
}

/* Checkbox de baixa */
.check-pago {
    width: 20px;
    height: 20px;
    border: 2px solid var(--border-hover);
    border-radius: 5px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: var(--transition);
    background: transparent;
    margin: 0 auto;
    position: relative;
}

.check-pago:hover {
    border-color: var(--green);
    background: var(--green-soft);
}

.check-pago.checked {
    background: var(--green);
    border-color: var(--green);
}

.check-pago.checked::after {
    content: '';
    display: block;
    width: 5px;
    height: 9px;
    border: solid #fff;
    border-width: 0 2px 2px 0;
    transform: rotate(45deg);
    margin-top: -2px;
}

/* Number column */
.col-num {
    width: 35px;
    color: var(--text-muted);
    font-size: 0.75rem;
    font-weight: 500;
    text-align: center;
}

.col-valor {
    font-variant-numeric: tabular-nums;
    font-weight: 600;
    text-align: right;
    white-space: nowrap;
}

.col-desconto {
    font-variant-numeric: tabular-nums;
    color: var(--yellow-text);
    text-align: right;
}

.col-acoes {
    width: 50px;
    text-align: center;
}

.fin-table-wide-actions th:last-child,
.fin-table-wide-actions .col-acoes-wide {
    width: 86px;
    min-width: 86px;
}

.table-actions {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
}

.btn-icon-action {
    width: 22px;
    height: 22px;
    border: 1px solid var(--border-hover);
    border-radius: 6px;
    background: #f8fafc;
    color: #475569;
    cursor: pointer;
    padding: 4px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: var(--transition);
}

.btn-icon-action svg {
    width: 100%;
    height: 100%;
    display: block;
    stroke: currentColor;
    stroke-width: 2;
    fill: none;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.btn-icon-action:hover {
    color: #1e293b;
    border-color: #94a3b8;
    background: #eef2f7;
}

.btn-icon-action.danger {
    color: #b91c1c;
    border-color: rgba(220, 38, 38, 0.35);
    background: #fff5f5;
}

.btn-icon-action.danger:hover {
    color: #991b1b;
    border-color: rgba(220, 38, 38, 0.55);
    background: #fee2e2;
}

.saida-nome-wrap {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
}

.saida-drag-handle {
    width: 24px;
    height: 24px;
    border: none;
    background: transparent;
    color: var(--text-muted);
    cursor: grab;
    padding: 4px;
    border-radius: 6px;
    transition: var(--transition);
    opacity: 0.6;
}

.saida-drag-handle:hover {
    opacity: 1;
    color: var(--text-secondary);
    background: rgba(0, 0, 0, 0.04);
}

.saida-drag-handle:active {
    cursor: grabbing;
}

.saida-drag-handle svg {
    width: 100%;
    height: 100%;
    stroke: currentColor;
    stroke-width: 1.8;
    fill: none;
}

#saidas-body tr.dragging {
    opacity: 0.55;
}

#saidas-body tr.drop-target td {
    background: rgba(37, 99, 235, 0.08) !important;
    box-shadow: inset 0 2px 0 #2563eb, inset 0 -2px 0 #2563eb;
}

/* Footer row (total) */
.table-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 14px 22px;
    border-top: 1px solid var(--border);
    background: var(--bg-glass);
}

.table-footer .total-label {
    font-size: 0.78rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-muted);
}

.table-footer .total-value {
    font-size: 1.05rem;
    font-weight: 700;
    font-variant-numeric: tabular-nums;
    color: var(--text-primary);
}

.table-footer .total-value.green { color: var(--green-text); }
.table-footer .total-value.red { color: var(--red-text); }

/* ── Anotações (modal estilo Keep) ── */
.keep-modal {
    max-width: 980px;
    width: 94%;
    padding: 18px;
}

.keep-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 10px;
}

.keep-header h3 {
    margin: 0;
}

.keep-add-row {
    background: #fff9dc;
    border: 1px solid #f4e5a2;
    border-radius: 12px;
    padding: 12px;
    margin-bottom: 12px;
}

.keep-add-row input,
.keep-add-row textarea {
    width: 100%;
    background: transparent;
    border: none;
    outline: none;
    font-family: inherit;
    color: var(--text-primary);
}

.keep-add-row input {
    font-size: 0.95rem;
    font-weight: 600;
    margin-bottom: 6px;
}

.keep-add-row textarea {
    min-height: 34px;
    max-height: 160px;
    resize: none;
    overflow: hidden;
    font-size: 0.88rem;
    line-height: 1.35;
}

.keep-add-actions {
    display: flex;
    justify-content: flex-end;
    margin-top: 8px;
}

.keep-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 12px;
    max-height: 58vh;
    overflow: auto;
    padding: 4px;
}

.keep-card {
    background: #fffef3;
    border: 1px solid #f4e5a2;
    border-radius: 12px;
    padding: 10px;
    box-shadow: var(--shadow-sm);
    position: relative;
}

.keep-card.dragging {
    opacity: 0.55;
}

.keep-card.drop-target {
    border-color: #2563eb;
    box-shadow: 0 0 0 2px rgba(37, 99, 235, 0.18);
}

.keep-card-title {
    font-weight: 700;
    margin-bottom: 4px;
    font-size: 0.92rem;
}

.keep-card-text {
    font-size: 0.82rem;
    color: var(--text-secondary);
    white-space: pre-line;
    margin-bottom: 6px;
    padding-right: 0;
    min-height: 22px;
}

.keep-card-text-value {
    display: block;
    line-height: 1.3;
    max-height: 54px;
    overflow: hidden;
}

.keep-drag-handle {
    position: absolute;
    top: 8px;
    right: 8px;
    width: 24px;
    height: 24px;
    border: none;
    background: transparent;
    color: var(--text-muted);
    cursor: grab;
    padding: 4px;
    border-radius: 6px;
    transition: var(--transition);
}

.keep-drag-handle:active {
    cursor: grabbing;
}

.keep-drag-handle:hover {
    color: var(--text-secondary);
    background: rgba(0, 0, 0, 0.04);
}

.keep-drag-handle svg {
    width: 100%;
    height: 100%;
    stroke: currentColor;
    stroke-width: 1.8;
    fill: none;
}

.keep-card-actions {
    display: flex;
    justify-content: flex-end;
    gap: 6px;
}

.keep-action-btn {
    width: 26px;
    height: 26px;
    border: 1px solid var(--border);
    border-radius: 7px;
    background: var(--bg-secondary);
    color: var(--text-muted);
    cursor: pointer;
    padding: 5px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: var(--transition);
}

.keep-action-btn svg {
    width: 100%;
    height: 100%;
    stroke: currentColor;
    stroke-width: 2;
    fill: none;
    stroke-linecap: round;
    stroke-linejoin: round;
}

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

.keep-action-btn.keep-action-danger:hover {
    color: var(--red);
    border-color: rgba(220, 38, 38, 0.3);
    background: var(--red-soft);
}

/* ── Calculadora (modal estilo Windows) ── */
.calc-modal {
    max-width: 360px;
    width: 95%;
    padding: 0;
    overflow: hidden;
}

.calc-titlebar {
    background: #e6edf7;
    border-bottom: 1px solid #cfd8e6;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 12px;
}

.calc-titlebar h3 {
    margin: 0;
    font-size: 0.9rem;
    color: #25324a;
}

.calc-window {
    padding: 12px;
    background: #f5f7fb;
}

.calc-display {
    width: 100%;
    background: #ffffff;
    border: 1px solid #cfd8e6;
    border-radius: var(--radius-sm);
    color: #1d2a3f;
    font-family: inherit;
    font-size: 1.25rem;
    text-align: right;
    padding: 12px;
    margin-bottom: 10px;
}

.calc-keys {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 8px;
}

.calc-keys .btn {
    min-height: 40px;
}

.calc-equals {
    grid-column: span 2;
}

/* Add row */
.add-row {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 16px;
    border-top: 1px solid var(--border);
}

.add-row input {
    flex: 1;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-family: inherit;
    font-size: 0.85rem;
    padding: 8px 12px;
    outline: none;
    transition: var(--transition);
}

.add-row input:focus {
    border-color: var(--border-focus);
    background: #fff;
    box-shadow: 0 0 0 3px var(--accent-glow);
}

.add-row input::placeholder {
    color: var(--text-dim);
}

.add-row input.input-valor {
    max-width: 130px;
    text-align: right;
}

.add-row input.input-desconto {
    max-width: 130px;
    text-align: right;
}

/* ── Cartões ── */
.cartoes-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(340px, 1fr));
    gap: 20px;
    padding: 20px;
}

.cartao-card {
    background: var(--bg-card-hover);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
    transition: var(--transition);
}

.cartao-card:hover {
    border-color: var(--border-hover);
    box-shadow: var(--shadow-sm);
}

.cartao-card.pago {
    opacity: 0.78;
    background: var(--green-bg);
}

.cartao-card.pago .cartao-total {
    text-decoration: line-through;
    text-decoration-color: var(--green);
}

.cartao-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 18px;
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border);
}

.cartao-header .cartao-nome {
    font-weight: 600;
    font-size: 0.9rem;
    color: var(--text-primary);
    display: flex;
    align-items: center;
    gap: 8px;
}

.cartao-header .cartao-nome .icon {
    color: var(--accent);
}

.cartao-header .cartao-total {
    font-weight: 700;
    font-size: 1rem;
    color: var(--red-text);
    font-variant-numeric: tabular-nums;
}

.cartao-body {
    padding: 0;
}

.cartao-body .fin-table td {
    padding: 8px 14px;
    font-size: 0.85rem;
}

.cartao-body .add-row {
    padding: 8px 14px;
}

.cartao-body .add-row input {
    padding: 6px 10px;
    font-size: 0.8rem;
}

.cartao-actions {
    display: flex;
    gap: 4px;
    align-items: center;
}

.cartao-drag-handle {
    width: 24px;
    height: 24px;
    border: none;
    background: transparent;
    color: var(--text-muted);
    cursor: grab;
    padding: 4px;
    border-radius: 6px;
    transition: var(--transition);
    opacity: 0.7;
}

.cartao-drag-handle:hover {
    opacity: 1;
    color: var(--text-secondary);
    background: rgba(0, 0, 0, 0.04);
}

.cartao-drag-handle:active {
    cursor: grabbing;
}

.cartao-drag-handle svg {
    width: 100%;
    height: 100%;
    stroke: currentColor;
    stroke-width: 1.8;
    fill: none;
}

#cartoes-grid .cartao-card.dragging {
    opacity: 0.55;
}

#cartoes-grid .cartao-card.drop-target {
    border-color: #2563eb;
    box-shadow: 0 0 0 2px rgba(37, 99, 235, 0.18);
}

/* ── Despesas Fixas & Parceladas ── */
.fixas-parceladas-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 24px;
    margin-bottom: 28px;
}

.parcela-badge {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 10px;
    background: var(--purple-soft);
    color: var(--purple);
    font-size: 0.72rem;
    font-weight: 600;
    margin-left: 8px;
}

/* ── Modal ── */
.modal-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.3);
    backdrop-filter: blur(4px);
    z-index: 1000;
    align-items: center;
    justify-content: center;
    animation: fadeIn 0.2s ease;
}

.modal-overlay.active {
    display: flex;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

.modal {
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 32px;
    width: 90%;
    max-width: 480px;
    box-shadow: var(--shadow-lg);
    animation: slideUp 0.3s ease;
}

@keyframes slideUp {
    from { opacity: 0; transform: translateY(20px); }
    to { opacity: 1; transform: translateY(0); }
}

.modal h3 {
    font-size: 1.1rem;
    font-weight: 700;
    margin-bottom: 20px;
    color: var(--text-primary);
    display: flex;
    align-items: center;
    gap: 10px;
}

.modal h3 .icon {
    color: var(--accent);
}

.modal .form-group {
    margin-bottom: 16px;
}

.modal label {
    display: block;
    font-size: 0.78rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-muted);
    margin-bottom: 6px;
}

.modal input,
.modal select {
    width: 100%;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-family: inherit;
    font-size: 0.9rem;
    padding: 10px 14px;
    outline: none;
    transition: var(--transition);
}

.modal input:focus,
.modal select:focus {
    border-color: var(--border-focus);
    background: #fff;
    box-shadow: 0 0 0 3px var(--accent-glow);
}

.modal select {
    appearance: none;
    cursor: pointer;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' fill='%2394a3b8' viewBox='0 0 16 16'%3E%3Cpath d='M8 11L3 6h10l-5 5z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
    padding-right: 32px;
}

.modal select option {
    background: var(--bg-secondary);
    color: var(--text-primary);
}

.modal-actions {
    display: flex;
    gap: 10px;
    justify-content: flex-end;
    margin-top: 24px;
}

/* ── Toast ── */
.toast-container {
    position: fixed;
    bottom: 24px;
    right: 24px;
    z-index: 2000;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.toast {
    padding: 12px 20px;
    border-radius: var(--radius-sm);
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--text-primary);
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    box-shadow: var(--shadow);
    animation: slideInRight 0.3s ease, fadeOut 0.3s ease 2.5s forwards;
    max-width: 320px;
}

.toast.success { border-left: 3px solid var(--green); }
.toast.error { border-left: 3px solid var(--red); }

@keyframes slideInRight {
    from { opacity: 0; transform: translateX(40px); }
    to { opacity: 1; transform: translateX(0); }
}

@keyframes fadeOut {
    to { opacity: 0; transform: translateY(10px); }
}

/* ── Empty State ── */
.empty-state {
    padding: 30px;
    text-align: center;
    color: var(--text-muted);
    font-size: 0.85rem;
}

.empty-state .icon {
    margin-bottom: 6px;
    color: var(--text-dim);
    width: 28px;
    height: 28px;
}

/* ── Novo Cartão Button ── */
.add-cartao-btn {
    border: 2px dashed var(--border);
    border-radius: var(--radius);
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 120px;
    cursor: pointer;
    transition: var(--transition);
    color: var(--text-muted);
    font-size: 0.9rem;
    font-weight: 500;
    gap: 8px;
}

.add-cartao-btn:hover {
    border-color: var(--accent);
    color: var(--accent);
    background: var(--accent-light);
}

/* ── Responsive ── */
@media (max-width: 900px) {
    .sections-grid,
    .fixas-parceladas-grid {
        grid-template-columns: 1fr;
    }

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

    .cartoes-grid {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 640px) {
    html { font-size: 14px; }

    .app-container { padding: 12px 10px 40px; }

    .app-header {
        flex-direction: column;
        gap: 14px;
        padding: 16px 18px;
        top: 6px;
    }

    .dashboard {
        grid-template-columns: 1fr 1fr;
        gap: 10px;
    }

    .dash-card { padding: 14px 16px; }
    .dash-card .value { font-size: 1.15rem; }
    .dash-card.entrada { top: 128px; }

    .section-header { padding: 14px 16px; }

    .fin-table td,
    .fin-table th { padding: 8px 10px; }

    .add-row { flex-wrap: wrap; }
    .add-row input { min-width: 0; }

    .modal { padding: 24px 20px; width: 95%; }
    .table-footer { padding: 12px 16px; }
}

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

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

::selection { background: var(--accent); color: #fff; }

/* ============================================================
   LOGIN
   ============================================================ */
.login-page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
}

.login-card {
    width: 100%;
    max-width: 380px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    padding: 38px 34px 34px;
    position: relative;
    overflow: hidden;
}

.login-card::before {
    content: '';
    position: absolute;
    top: 0; left: 0; right: 0;
    height: 3px;
    background: linear-gradient(90deg, #3b82f6, #7c3aed);
}

.login-brand {
    display: flex;
    align-items: center;
    gap: 11px;
    margin-bottom: 6px;
}

.login-brand .icon {
    color: var(--accent);
    width: 26px;
    height: 26px;
}

.login-brand h1 {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--text-primary);
}

.login-sub {
    font-size: 0.82rem;
    color: var(--text-muted);
    margin-bottom: 26px;
}

.login-form { display: flex; flex-direction: column; gap: 16px; }

.login-field { display: flex; flex-direction: column; gap: 6px; }

.login-field label {
    font-size: 0.72rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: var(--text-muted);
}

.login-field input {
    width: 100%;
    padding: 11px 14px;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-family: inherit;
    font-size: 0.92rem;
    color: var(--text-primary);
    transition: var(--transition);
}

.login-field input:focus {
    outline: none;
    background: var(--bg-input-focus);
    border-color: var(--border-focus);
    box-shadow: 0 0 0 3px var(--accent-glow);
}

.login-form .btn-accent {
    width: 100%;
    padding: 11px 16px;
    font-size: 0.9rem;
    margin-top: 4px;
}

.login-error {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 13px;
    background: var(--red-soft);
    border: 1px solid rgba(220, 38, 38, 0.2);
    border-radius: var(--radius-sm);
    color: var(--red-text);
    font-size: 0.83rem;
    font-weight: 500;
    margin-bottom: 20px;
}

.login-error .icon { width: 15px; height: 15px; flex-shrink: 0; }

.login-foot {
    margin-top: 22px;
    text-align: center;
    font-size: 0.72rem;
    color: var(--text-dim);
    letter-spacing: 0.3px;
}
