/* Dantas Lopes Finance – Design System */
:root {
    --color-bg: #f8fafc;
    --color-surface: #ffffff;
    --color-border: #e2e8f0;
    --color-border-light: #f1f5f9;
    --color-text: #1e293b;
    --color-text-muted: #64748b;
    --color-text-light: #94a3b8;
    --color-primary: #2563eb;
    --color-primary-hover: #1d4ed8;
    --color-primary-light: #dbeafe;
    --color-success: #059669;
    --color-success-bg: #d1fae5;
    --color-danger: #dc2626;
    --color-danger-bg: #fee2e2;
    --color-warning: #d97706;
    --color-warning-bg: #fef3c7;
    --sidebar-width: 260px;
    --topbar-height: 64px;
    --radius-sm: 6px;
    --radius-md: 10px;
    --radius-lg: 14px;
    --shadow-sm: 0 1px 2px rgba(0,0,0,0.05);
    --shadow-md: 0 4px 6px -1px rgba(0,0,0,0.1), 0 2px 4px -2px rgba(0,0,0,0.1);
    --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
}

* { margin: 0; padding: 0; box-sizing: border-box; }

body {
    font-family: var(--font-sans);
    background: var(--color-bg);
    color: var(--color-text);
    min-height: 100vh;
    line-height: 1.5;
}

/* Layout — fixar sidebar e topbar: só o .container rola */
html:has(.app-layout), body:has(.app-layout) {
    height: 100%;
    overflow: hidden;
}

.app-layout {
    display: flex;
    height: 100vh;
    min-height: 100vh;
    overflow: hidden;
}

/* Tela de seleção de banco */
.database-selection-view {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.database-selection-card {
    background: white;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-md);
    padding: 48px;
    max-width: 480px;
    width: 100%;
}

.database-selection-card h1 {
    text-align: center;
    margin-bottom: 8px;
}

.database-selection-subtitle {
    text-align: center;
    color: var(--color-text-muted);
    margin-bottom: 24px;
}

.auth-card .auth-form { max-width: 320px; margin: 0 auto; }
.auth-error { color: var(--color-danger, #dc3545); font-size: 14px; margin-top: 8px; }
.nav-user { cursor: default; opacity: 0.9; }

.databases-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-bottom: 24px;
}

.db-option {
    padding: 16px 20px;
    border: 2px solid var(--color-border);
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: all 0.2s;
    font-size: 1rem;
}

.db-option:hover {
    border-color: var(--color-primary);
    background: var(--color-primary-light);
}

.btn-create-db {
    width: 100%;
}

.loading-databases {
    color: var(--color-text-muted);
    text-align: center;
}

.databases-empty {
    color: var(--color-text-light);
    text-align: center;
    padding: 24px;
}

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

.sidebar-brand {
    padding: 24px;
    border-bottom: 1px solid var(--color-border-light);
}

.brand-logo {
    display: block;
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--color-primary);
    letter-spacing: -0.02em;
}

.brand-tagline {
    display: block;
    font-size: 0.75rem;
    color: var(--color-text-muted);
    margin-top: 2px;
}

.sidebar-nav {
    flex: 1;
    padding: 16px 12px;
    overflow-y: auto;
}

.nav-section {
    margin-bottom: 24px;
}

.nav-section-title {
    display: block;
    font-size: 0.7rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--color-text-light);
    padding: 0 12px;
    margin-bottom: 8px;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 12px;
    border-radius: var(--radius-sm);
    color: var(--color-text);
    text-decoration: none;
    font-size: 0.9rem;
    transition: background 0.15s, color 0.15s;
    margin-bottom: 2px;
}

.nav-item:hover {
    background: var(--color-border-light);
    color: var(--color-primary);
}

.nav-item.active {
    background: var(--color-primary-light);
    color: var(--color-primary);
    font-weight: 500;
}

.nav-item-pluggy {
    background: linear-gradient(135deg, #ede9fe 0%, #e0e7ff 100%);
    color: #5b21b6;
}

.nav-item-pluggy:hover {
    background: linear-gradient(135deg, #e0e7ff 0%, #c7d2fe 100%);
}

.nav-icon {
    font-size: 1rem;
    opacity: 0.8;
}

/* Main content */
.main-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-width: 0;
    min-height: 0;
    overflow: hidden;
}

.topbar {
    height: var(--topbar-height);
    background: var(--color-surface);
    border-bottom: 1px solid var(--color-border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 24px;
    flex-shrink: 0;
}

.page-title {
    font-size: 1.25rem;
    font-weight: 600;
    color: var(--color-text);
}

.topbar-actions {
    display: flex;
    align-items: center;
    gap: 12px;
}

.container {
    flex: 1;
    min-height: 0;
    padding: 24px;
    overflow-y: auto;
}

/* Buttons */
.btn {
    padding: 10px 18px;
    border: none;
    border-radius: var(--radius-sm);
    font-size: 0.9rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
    font-family: inherit;
}

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

.btn-primary:hover {
    background: var(--color-primary-hover);
    box-shadow: var(--shadow-md);
}

.btn-secondary {
    background: var(--color-text-muted);
    color: white;
}

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

.btn-ghost {
    background: transparent;
    color: var(--color-text-muted);
}

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

.btn-pluggy {
    background: #7c3aed;
    color: white;
}

.btn-pluggy:hover { background: #6d28d9; }

.btn-danger {
    background: var(--color-danger);
    color: white;
    padding: 6px 12px;
    font-size: 0.85rem;
}

.btn-danger:hover { background: #b91c1c; }

.btn-edit {
    background: #f59e0b;
    color: white;
    padding: 6px 12px;
    font-size: 0.85rem;
}

.btn-edit:hover { background: #d97706; }

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

.btn-icon { margin-right: 6px; }

.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* View bars */
.view-bar {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    border-radius: var(--radius-md);
    margin-bottom: 16px;
}

.view-bar-future {
    background: var(--color-primary-light);
    border: 1px solid #93c5fd;
}

.view-bar-ignored {
    background: var(--color-warning-bg);
    border: 1px solid #fcd34d;
}

/* Filters */
.filters-bar {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
    margin-bottom: 16px;
}

.filter-btn {
    padding: 8px 16px;
    border: 1px solid var(--color-border);
    background: var(--color-surface);
    border-radius: 20px;
    cursor: pointer;
    font-size: 0.9rem;
    transition: all 0.2s;
}

.filter-btn:hover {
    border-color: var(--color-primary);
    color: var(--color-primary);
}

.filter-btn.active {
    background: var(--color-primary);
    color: white;
    border-color: var(--color-primary);
}

/* Period selector dropdown */
.period-selector-wrap {
    display: flex;
    align-items: center;
    gap: 8px;
}

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

.period-dropdown {
    position: relative;
}

.period-btn {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 8px 14px;
    border: 1px solid var(--color-border);
    background: var(--color-surface);
    border-radius: var(--radius-sm);
    cursor: pointer;
    font-size: 0.9rem;
    min-width: 140px;
}

.period-btn:hover {
    border-color: var(--color-primary);
    color: var(--color-primary);
}

.period-chevron {
    font-size: 0.7rem;
    opacity: 0.7;
}

.period-dropdown-menu {
    position: absolute;
    top: 100%;
    left: 0;
    margin-top: 4px;
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-md);
    min-width: 180px;
    z-index: 100;
    padding: 6px 0;
}

.period-dropdown-menu[aria-hidden="true"] {
    display: none;
}

.period-shortcut {
    display: block;
    width: 100%;
    padding: 10px 16px;
    border: none;
    background: none;
    text-align: left;
    font-size: 0.9rem;
    cursor: pointer;
    transition: background 0.15s;
}

.period-shortcut:hover {
    background: var(--color-border-light);
}

.period-shortcut.active {
    background: var(--color-primary-light);
    color: var(--color-primary);
    font-weight: 500;
}

.search-input {
    flex: 1;
    min-width: 200px;
    max-width: 320px;
    padding: 10px 16px;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-sm);
    font-size: 0.9rem;
}

.search-input:focus {
    outline: none;
    border-color: var(--color-primary);
    box-shadow: 0 0 0 2px rgba(37, 99, 235, 0.15);
}

.column-filters-details {
    margin-bottom: 16px;
    padding: 12px 16px;
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
}

.column-filters-details summary {
    cursor: pointer;
    font-size: 0.9rem;
    color: var(--color-text-muted);
}

.filter-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    gap: 12px;
    margin-top: 16px;
}

.form-group-action { display: flex; align-items: flex-end; }

/* Pagination */
.pagination-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 12px;
    padding: 12px 0;
    margin-bottom: 16px;
}

.pagination-left, .pagination-controls {
    display: flex;
    align-items: center;
    gap: 8px;
}

.pagination-info {
    font-size: 0.9rem;
    color: var(--color-text-muted);
}

.pagination-bar select {
    padding: 6px 10px;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-sm);
    font-size: 0.9rem;
}

/* Batch actions */
.batch-actions-bar {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 10px;
    padding: 12px 16px;
    background: var(--color-primary-light);
    border-radius: var(--radius-md);
    margin-bottom: 16px;
}

.batch-actions-bar span {
    font-weight: 600;
    color: var(--color-primary);
    margin-right: 8px;
}

/* Table */
.transactions-container {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    overflow: hidden;
    box-shadow: var(--shadow-sm);
}

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

.transactions-table thead {
    background: var(--color-bg);
    border-bottom: 1px solid var(--color-border);
}

.transactions-table th {
    padding: 14px 16px;
    text-align: left;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--color-text-muted);
}

.col-sortable { cursor: pointer; }

.col-sortable:hover { color: var(--color-primary); }

.col-checkbox { width: 44px; }

.col-actions { width: 180px; min-width: 180px; }

.sort-indicator { font-size: 10px; margin-left: 4px; }

.transactions-table td {
    padding: 14px 16px;
    border-bottom: 1px solid var(--color-border-light);
    font-size: 0.9rem;
}

.transactions-table tbody tr:hover {
    background: var(--color-bg);
}

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

.income-row { border-left: 3px solid var(--color-success); }

.expense-row { border-left: 3px solid var(--color-danger); }

.ignored-transaction { background: var(--color-warning-bg) !important; }

.amount-income { color: var(--color-success); font-weight: 600; }

.amount-expense { color: var(--color-danger); font-weight: 600; }

.action-buttons { display: flex; gap: 8px; flex-wrap: nowrap; }
.action-buttons .btn { white-space: nowrap; }
.automation-from-tx-btn { color: #d97706; font-size: 1rem; padding: 4px 8px; }
.automation-from-tx-btn:hover { background: rgba(217, 119, 6, 0.15); color: #b45309; }

.empty-state {
    text-align: center;
    padding: 48px 24px !important;
    color: var(--color-text-muted);
}

/* Form */
.form-group {
    margin-bottom: 16px;
}

.form-group label {
    display: block;
    margin-bottom: 6px;
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--color-text);
}

.form-group-checkbox .checkbox-label {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 0;
    cursor: pointer;
}

.form-group-checkbox .checkbox-label input[type="checkbox"] {
    width: auto;
    margin: 0;
    flex-shrink: 0;
}

.form-group input,
.form-group select {
    width: 100%;
    padding: 10px 14px;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-sm);
    font-size: 0.9rem;
    font-family: inherit;
}

.form-group input:focus,
.form-group select:focus {
    outline: none;
    border-color: var(--color-primary);
}

.form-group small {
    display: block;
    font-size: 0.8rem;
    color: var(--color-text-muted);
    margin-top: 4px;
}

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

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

.form-hint {
    display: block;
    font-size: 12px;
    color: var(--color-text-muted, #64748b);
    margin-top: 4px;
}

.category-budgets-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
}
.category-budgets-table th,
.category-budgets-table td {
    padding: 8px 10px;
    text-align: left;
    border-bottom: 1px solid var(--color-border, #e2e8f0);
}
.category-budgets-table th { font-weight: 600; color: var(--color-text-muted, #64748b); }
.category-budgets-table td:first-child { font-variant-numeric: tabular-nums; }
.category-budgets-table .btn-remove-budget,
.category-budgets-table .btn-edit-budget { padding: 4px 8px; font-size: 12px; margin-right: 4px; }
.category-budget-fields { margin-top: 8px; }
.category-budget-row-period { margin-bottom: 8px; }
.category-budget-row-value { align-items: flex-end; }

/* Modal */
.modal {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 1000;
    background: rgba(15, 23, 42, 0.5);
    backdrop-filter: blur(4px);
    overflow-y: auto;
}

body.modal-open {
    overflow: hidden;
}

body.modal-open .app-layout,
body.modal-open .container {
    pointer-events: none;
}

body.modal-open .app-layout.search-hidden,
body.modal-open .container.search-hidden {
    transform: translateX(-99999px);
    position: fixed;
    visibility: hidden;
}

.modal-content {
    background: var(--color-surface);
    margin: 4% auto;
    padding: 28px;
    border-radius: var(--radius-lg);
    max-width: 500px;
    width: 90%;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: 0 25px 50px -12px rgba(0,0,0,0.25);
    position: relative;
    pointer-events: auto;
}

.modal-narrow { max-width: 420px; }

.modal-wide { max-width: 640px; }

.automation-apply-modal { max-width: 800px; }

.close {
    position: absolute;
    right: 20px;
    top: 20px;
    font-size: 1.5rem;
    color: var(--color-text-light);
    cursor: pointer;
    line-height: 1;
}

.close:hover { color: var(--color-text); }

.modal-content h2 {
    margin-bottom: 20px;
    font-size: 1.25rem;
}

.modal-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    align-items: center;
    margin-bottom: 20px;
}

.info-box {
    padding: 12px 16px;
    background: var(--color-warning-bg);
    border-radius: var(--radius-sm);
    font-size: 0.85rem;
    margin-bottom: 16px;
}

.status-message {
    padding: 12px 16px;
    border-radius: var(--radius-sm);
    margin: 16px 0;
    font-size: 0.9rem;
}

/* Banks */
.banks-selection {
    padding: 20px;
    background: var(--color-bg);
    border-radius: var(--radius-md);
    margin-bottom: 24px;
}

.banks-selection-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 12px;
    margin-bottom: 16px;
}

.banks-selection-header h3 {
    margin: 0;
    font-size: 1rem;
}

.banks-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    gap: 12px;
}

.pluggy-item-id-row {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    align-items: center;
}

.pluggy-item-id-row input:first-of-type {
    flex: 1;
    min-width: 200px;
}

.pluggy-item-label-input {
    flex: 0 0 140px;
    max-width: 180px;
}

.bank-card {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 20px;
    background: var(--color-surface);
    border: 2px solid var(--color-border);
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: all 0.2s;
}

.bank-card:hover {
    border-color: var(--color-primary);
    box-shadow: var(--shadow-md);
}

.bank-card.selected {
    border-color: var(--color-primary);
    background: var(--color-primary-light);
}

.bank-card-remove {
    position: absolute;
    top: 6px;
    right: 6px;
    width: 24px;
    height: 24px;
    padding: 0;
    border: none;
    background: var(--color-border-light);
    color: var(--color-text-muted);
    border-radius: 50%;
    cursor: pointer;
    font-size: 18px;
    line-height: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0.7;
}

.bank-card-remove:hover {
    background: var(--color-danger-bg);
    color: var(--color-danger);
    opacity: 1;
}

.bank-logo {
    width: 48px;
    height: 48px;
    object-fit: contain;
    margin-bottom: 8px;
}

.bank-name { font-weight: 600; font-size: 0.9rem; }

.bank-last-updated {
    font-size: 0.7rem;
    color: var(--color-text-muted);
    margin-top: 4px;
}

.bank-never-updated { color: var(--color-text-light); }

/* Page views */
.page-view { padding: 0; }

.page-header {
    display: flex;
    align-items: center;
    gap: 16px;
    margin-bottom: 24px;
}

.page-header h2 { font-size: 1.25rem; margin: 0; }

.categories-summary-filters {
    display: flex;
    flex-wrap: wrap;
    gap: 16px;
    align-items: flex-end;
    margin-bottom: 20px;
}

.categories-summary-filters .form-group { margin: 0; }

.categories-summary-total {
    font-size: 1.25rem;
    font-weight: 700;
    padding: 12px 16px;
    border-radius: var(--radius-sm);
    margin-bottom: 16px;
    display: inline-block;
}

.categories-summary-total.expense {
    background: var(--color-danger-bg);
    color: var(--color-danger);
}

.categories-summary-total.income {
    background: var(--color-success-bg);
    color: var(--color-success);
}

.categories-manage-section { padding-top: 24px; }

.categories-manage-section h3 { margin-bottom: 8px; font-size: 1.1rem; }

.categories-manage-desc {
    color: var(--color-text-muted);
    font-size: 0.9rem;
    margin-bottom: 16px;
}

/* DRE */
.dre-month-nav {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 24px;
    margin-bottom: 24px;
    padding: 20px;
    background: var(--color-bg);
    border-radius: var(--radius-md);
}

.dre-nav-btn {
    width: 40px;
    height: 40px;
    border: 1px solid var(--color-border);
    border-radius: 50%;
    background: var(--color-surface);
    font-size: 1.5rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--color-text);
}

.dre-nav-btn:hover {
    background: var(--color-border-light);
}

.dre-month-label {
    font-size: 1.1rem;
    font-weight: 600;
    min-width: 160px;
    text-align: center;
}

.dre-content { max-width: 560px; margin: 0 auto; }

.dre-loading { text-align: center; color: var(--color-text-muted); }

.dre-table {
    width: 100%;
    border-collapse: collapse;
    background: var(--color-surface);
    border-radius: var(--radius-md);
    overflow: hidden;
}

.dre-table td {
    padding: 12px 16px;
    border-bottom: 1px solid var(--color-border-light);
}

.dre-table tr.dre-total-row td { font-weight: 700; background: var(--color-bg); }

.dre-table tr.dre-resultado-liquido td {
    font-weight: 700;
    background: var(--color-primary-light);
    color: var(--color-primary);
}

.dre-table .dre-value { text-align: right; font-variant-numeric: tabular-nums; }

.dre-table .dre-value.positive { color: var(--color-success); }

.dre-table .dre-value.negative { color: var(--color-danger); }

.dre-table tr.dre-section-row td {
    background: var(--color-border-light);
    font-weight: 700;
}

.dre-table tr.dre-cat-row:hover td { background: var(--color-bg) !important; }

/* DRE Orçado vs Realizado */
.dre-table-budget thead th {
    text-align: left;
    font-weight: 600;
    padding: 10px 16px;
    background: var(--color-border-light);
    border-bottom: 1px solid var(--color-border);
}
.dre-table-budget thead th.dre-value,
.dre-table-budget thead th.dre-limite { text-align: right; }
.dre-table-budget .dre-value-cell { min-width: 140px; }
.dre-table-budget .dre-limite { text-align: right; font-variant-numeric: tabular-nums; color: var(--color-text-muted); }
.dre-table-budget .dre-limite.dre-empty { border: none; background: transparent; }
.budget-bar {
    height: 6px;
    background: var(--color-border-light);
    border-radius: 3px;
    margin-top: 4px;
    overflow: hidden;
}
.budget-bar-fill {
    height: 100%;
    border-radius: 3px;
    transition: width 0.2s ease;
}
.budget-bar-green { background: var(--color-success); }
.budget-bar-orange { background: var(--color-warning); }
.budget-bar-red { background: var(--color-danger); }
.budget-bar-neutral { background: var(--color-text-light); }

/* Categories list */
.saved-categories-list { list-style: none; }

.saved-category-section {
    font-size: 0.9rem;
    font-weight: 700;
    padding: 12px 14px;
    margin: 16px 0 8px;
    border-radius: var(--radius-sm);
}

.saved-category-section-income { background: var(--color-success-bg); color: var(--color-success); }

.saved-category-section-expense { background: var(--color-danger-bg); color: var(--color-danger); }

.saved-category-section-transfer { background: var(--color-border-light); color: var(--color-text); }

.saved-category-section-investment { background: var(--color-primary-light); color: var(--color-primary); }

.saved-category-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 12px;
    margin-bottom: 6px;
    background: var(--color-bg);
    border-radius: var(--radius-sm);
}

.saved-category-parent { font-weight: 600; }

.saved-category-child {
    margin-left: 24px;
    border-left: 3px solid var(--color-primary);
}

.saved-category-order {
    font-weight: 600;
    color: var(--color-primary);
    min-width: 24px;
}

.saved-category-budget-wrap { margin-left: auto; }
.saved-category-budget-input {
    width: 90px;
    padding: 4px 8px;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-sm);
    font-size: 0.9rem;
}
.saved-category-budget-input:focus {
    outline: none;
    border-color: var(--color-primary);
}
.saved-category-actions { display: flex; gap: 6px; }

.categories-summary-table {
    width: 100%;
    border-collapse: collapse;
    background: var(--color-surface);
    border-radius: var(--radius-md);
    overflow: hidden;
}

.categories-summary-table th,
.categories-summary-table td {
    padding: 12px 16px;
    border-bottom: 1px solid var(--color-border-light);
}

.categories-summary-table thead {
    background: var(--color-bg);
    font-weight: 600;
}

.account-item {
    padding: 12px 16px;
    margin: 8px 0;
    background: var(--color-bg);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-sm);
    cursor: pointer;
}

.account-item:hover { border-color: var(--color-primary); }

.account-item.selected {
    background: var(--color-primary-light);
    border-color: var(--color-primary);
}

/* Responsive */
/* Botão Voltar ao topo — semi-transparente, acompanha o scroll */
.back-to-top {
    position: fixed;
    left: calc(var(--sidebar-width) + 16px);
    bottom: 24px;
    padding: 10px 16px;
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--color-text);
    background: rgba(248, 250, 252, 0.9);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
    cursor: pointer;
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transition: opacity 0.2s, visibility 0.2s, background 0.2s;
    z-index: 500;
}
.back-to-top.visible {
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
}
.back-to-top:hover {
    background: rgba(255, 255, 255, 0.95);
}

/* Automações */
.automations-subtitle {
    color: var(--color-text-muted);
    font-size: 0.9rem;
    margin-bottom: 20px;
}

.automations-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.automation-card {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    padding: 16px 20px;
    display: flex;
    align-items: flex-start;
    gap: 16px;
    position: relative;
}

.automation-drag-handle {
    cursor: grab;
    color: var(--color-text-muted);
    padding: 4px;
    font-size: 1.2rem;
}

.automation-drag-handle:hover { color: var(--color-text); }

.automation-priority {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: var(--color-border-light);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--color-text-muted);
    flex-shrink: 0;
}

.automation-content {
    flex: 1;
    min-width: 0;
}

.automation-title {
    font-weight: 600;
    font-size: 1rem;
    margin-bottom: 6px;
}

.automation-summary {
    font-size: 0.85rem;
    color: var(--color-text-muted);
    line-height: 1.5;
}

.automation-card.inactive .automation-title,
.automation-card.inactive .automation-summary { opacity: 0.6; }

.automation-card.dragging { opacity: 0.6; }

.automation-toggle {
    flex-shrink: 0;
}

.automation-menu-btn {
    background: none;
    border: none;
    cursor: pointer;
    padding: 8px;
    color: var(--color-text-muted);
    font-size: 1.2rem;
}

.automation-menu-btn:hover { color: var(--color-text); }

.automation-dropdown {
    position: absolute;
    top: 100%;
    right: 16px;
    margin-top: 4px;
    background: white;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-sm);
    box-shadow: var(--shadow-md);
    padding: 6px 0;
    min-width: 180px;
    z-index: 100;
}

.automation-dropdown.up {
    top: auto;
    bottom: 100%;
    margin-top: 0;
    margin-bottom: 4px;
}

.automation-dropdown button {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
    padding: 10px 16px;
    border: none;
    background: none;
    cursor: pointer;
    font-size: 0.9rem;
    text-align: left;
}

.automation-dropdown button:hover { background: var(--color-bg); }

.automation-dropdown button.danger { color: var(--color-danger); }

.automation-condition-row {
    display: grid;
    grid-template-columns: 1fr 1fr 1.5fr auto;
    gap: 12px;
    align-items: end;
    margin-bottom: 12px;
}

.automation-condition-row .form-group { margin-bottom: 0; }

.automation-section {
    margin-bottom: 24px;
    padding-bottom: 20px;
    border-bottom: 1px solid var(--color-border-light);
}

.automation-section:last-of-type { border-bottom: none; }

.automation-section h3 { font-size: 1rem; margin-bottom: 6px; }

.section-hint {
    font-size: 0.85rem;
    color: var(--color-text-muted);
    margin-bottom: 12px;
}

.btn-add-condition { margin-top: 8px; }

.automation-preview-subhint {
    font-size: 0.9rem;
    color: var(--color-text-muted);
    margin-bottom: 12px;
}

.automation-preview-table-wrap {
    max-height: 360px;
    overflow: auto;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-sm);
    margin: 16px 0;
}

.automation-preview-table {
    width: 100%;
    min-width: 560px;
    border-collapse: collapse;
    font-size: 0.9rem;
}

.automation-preview-table th,
.automation-preview-table td {
    white-space: nowrap;
}

.automation-preview-table th {
    text-align: left;
    padding: 12px 16px;
    font-weight: 600;
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--color-text-muted);
    border-bottom: 1px solid var(--color-border);
}

.automation-preview-table td {
    padding: 12px 16px;
    border-bottom: 1px solid var(--color-border-light);
}

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

.automation-preview-table .automation-preview-arrow {
    text-align: center;
    color: var(--color-text-muted);
    width: 32px;
}

.automation-preview-table .automation-preview-newcat {
    color: var(--color-primary);
    font-weight: 500;
}

.automation-preview-list {
    max-height: 320px;
    overflow-y: auto;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-sm);
    margin: 16px 0;
}

.automation-preview-item {
    padding: 12px 16px;
    border-bottom: 1px solid var(--color-border-light);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.automation-preview-item:last-child { border-bottom: none; }

.loading-msg { color: var(--color-text-muted); }

@media (max-width: 768px) {
    .sidebar { width: 72px; padding: 12px 8px; }
    .back-to-top { left: 88px; }
    .brand-tagline, .nav-section-title, .nav-item span { display: none; }
    .nav-item { justify-content: center; padding: 12px; }
    .filters-bar { flex-direction: column; align-items: stretch; }
    .search-input { max-width: none; }
    .form-row { grid-template-columns: 1fr; }
}
