/* ==========================================================================
   COMPONENTS - CARDS, FORMS, BUTTONS, TABLES, ALERTS & TOOLTIPS
   ========================================================================== */

/* Cards */
.card {
    background-color: var(--bg-surface);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: 24px;
    box-shadow: var(--shadow-card);
    transition: border-color 0.2s ease;
}

.card:hover {
    border-color: var(--border-highlight);
}

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

.card-title {
    font-size: 18px;
    font-weight: 700;
    color: var(--text-primary);
}

.card-subtitle {
    font-size: 14px;
    color: var(--text-secondary);
    margin-top: 4px;
}

/* Forms & Inputs */
.form-group {
    margin-bottom: 20px;
}

.form-label {
    display: block;
    font-size: 15px;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 8px;
}

.form-control, .form-select, .form-textarea {
    width: 100%;
    min-height: 48px;
    padding: 12px 16px;
    background-color: var(--bg-main);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-family: var(--font-family);
    font-size: 16px;
    transition: all 0.2s ease;
}

.form-textarea {
    min-height: 90px;
    resize: vertical;
}

.form-help {
    display: block;
    color: var(--text-muted);
    font-size: 13px;
    margin-top: 6px;
}

.role-list { display: grid; gap: 12px; }
.role-list > div { padding: 12px 14px; border: 1px solid var(--border-color); border-radius: var(--radius-sm); background: var(--bg-main); }
.role-list strong, .role-list span { display: block; }
.role-list span { color: var(--text-secondary); font-size: 13px; margin-top: 3px; }

@media (max-width: 768px) {
    .users-admin-grid { grid-template-columns: 1fr; }
    .users-table { min-width: 900px; }
}

.form-control:focus, .form-select:focus, .form-textarea:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-light);
}

/* Big Money Input Field */
.amount-input-wrapper {
    position: relative;
    display: flex;
    align-items: center;
}

.amount-currency-prefix {
    position: absolute;
    left: 16px;
    font-size: 20px;
    font-weight: 700;
    color: var(--info);
    pointer-events: none;
}

.amount-input-control {
    padding-left: 55px !important;
    font-size: 24px !important;
    font-weight: 700 !important;
    color: var(--info) !important;
    letter-spacing: 0.02em;
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    min-height: 48px;
    padding: 12px 24px;
    font-family: var(--font-family);
    font-size: 16px;
    font-weight: 600;
    border-radius: var(--radius-sm);
    border: none;
    cursor: pointer;
    transition: all 0.2s ease;
    text-decoration: none;
}

.btn-primary {
    background-color: var(--primary);
    color: white;
    box-shadow: 0 4px 12px rgba(2, 132, 199, 0.3);
}

.btn-primary:hover {
    background-color: var(--primary-hover);
    transform: translateY(-1px);
    color: white;
}

.btn-success {
    background-color: var(--success);
    color: white;
    box-shadow: 0 4px 12px rgba(16, 185, 129, 0.3);
}

.btn-success:hover {
    background-color: #059669;
    color: white;
}

.btn-secondary {
    background-color: var(--bg-surface-hover);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
}

.btn-secondary:hover {
    background-color: #475569;
    color: white;
}

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

.btn-danger:hover {
    background-color: #dc2626;
}

/* Tables */
.table-responsive {
    width: 100%;
    overflow-x: auto;
    border-radius: var(--radius-md);
    border: 1px solid var(--border-color);
}

.table {
    width: 100%;
    border-collapse: collapse;
    text-align: left;
}

.table th {
    background-color: #1a2332;
    color: var(--text-secondary);
    font-size: 13px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    padding: 16px 20px;
    border-bottom: 1px solid var(--border-color);
}

.table td {
    padding: 16px 20px;
    border-bottom: 1px solid var(--border-color);
    font-size: 15px;
    color: var(--text-primary);
}

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

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

.text-right { text-align: right; }
.text-center { text-align: center; }

/* Status Badges */
.badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 4px 12px;
    border-radius: 20px;
    font-size: 13px;
    font-weight: 600;
}

.badge-success { background: var(--success-light); color: var(--success); border: 1px solid rgba(16, 185, 129, 0.3); }
.badge-warning { background: var(--warning-light); color: var(--warning); border: 1px solid rgba(245, 158, 11, 0.3); }
.badge-danger { background: var(--danger-light); color: var(--danger); border: 1px solid rgba(239, 68, 68, 0.3); }
.badge-info { background: var(--primary-light); color: var(--info); border: 1px solid rgba(56, 189, 248, 0.3); }

/* Alerts */
.alert {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 16px 20px;
    border-radius: var(--radius-md);
    margin-bottom: 24px;
    font-size: 15px;
    font-weight: 500;
}

.alert-success { background: var(--success-light); color: #34d399; border: 1px solid rgba(16, 185, 129, 0.4); }
.alert-warning { background: var(--warning-light); color: #fbbf24; border: 1px solid rgba(245, 158, 11, 0.4); }
.alert-danger { background: var(--danger-light); color: #f87171; border: 1px solid rgba(239, 68, 68, 0.4); }
.alert-info { background: var(--primary-light); color: #38bdf8; border: 1px solid rgba(56, 189, 248, 0.4); }

/* Contextual Help Callouts (Bocadillos & Tooltips) */
.guide-box {
    background: linear-gradient(135deg, rgba(2, 132, 199, 0.1), rgba(15, 23, 42, 0.6));
    border: 1px solid rgba(56, 189, 248, 0.3);
    border-radius: var(--radius-md);
    padding: 18px 20px;
    margin-top: 16px;
    display: flex;
    gap: 14px;
}

.guide-box-icon {
    font-size: 24px;
    line-height: 1;
}

.guide-box-content h4 {
    font-size: 15px;
    font-weight: 700;
    color: var(--info);
    margin-bottom: 4px;
}

.guide-box-content p {
    font-size: 14px;
    color: var(--text-secondary);
    margin-bottom: 6px;
}

.guide-box-examples {
    font-size: 13px;
    color: var(--text-muted);
    font-style: italic;
}

.form-grid { display:grid; grid-template-columns:repeat(auto-fit,minmax(190px,1fr)); gap:16px; align-items:end; }
.form-grid > div[style*="grid-column"] { grid-column:1/-1; }
.table-responsive { overflow-x:auto; }
.data-table { width:100%; border-collapse:collapse; min-width:620px; }
.data-table th, .data-table td { padding:12px 10px; border-bottom:1px solid var(--border-color); text-align:left; }
.data-table th { color:var(--text-muted); font-size:12px; text-transform:uppercase; letter-spacing:.04em; }
.text-muted { color:var(--text-muted); }
.page-heading { display:flex; justify-content:space-between; align-items:center; gap:16px; margin-bottom:20px; }
.page-heading h1 { margin:0 0 4px; }
.stats-grid { display:grid; grid-template-columns:repeat(auto-fit,minmax(170px,1fr)); gap:16px; margin-bottom:20px; }
.stat-card { background:var(--bg-card); border:1px solid var(--border-color); border-radius:var(--radius-md); padding:18px; }
.stat-label { color:var(--text-muted); font-size:13px; }
.stat-value { font-size:28px; font-weight:800; margin-top:8px; }
.tabs .btn { text-decoration:none; }

/* Personal dashboard: compact metrics, charts and quick actions */
.finance-dashboard { max-width: 1500px; margin: 0 auto; }
.finance-dashboard-header, .record-header { display: flex; justify-content: space-between; align-items: flex-end; gap: 24px; margin-bottom: 18px; }
.finance-dashboard-header h1, .record-header h1 { margin: 4px 0; font-size: clamp(28px, 3vw, 38px); letter-spacing: -.035em; }
.finance-dashboard-header p, .record-header p { color: var(--text-secondary); }
.dashboard-period { min-width: 300px; padding: 13px 15px; background: var(--bg-surface); border: 1px solid var(--border-color); border-radius: var(--radius-md); }
.dashboard-period-row { display: flex; align-items: center; gap: 10px; }
.dashboard-period-row .form-control { min-height: 42px; }
.period-label { color: var(--info); font-size: 13px; font-weight: 700; white-space: nowrap; }
.period-switcher { display: flex; gap: 4px; border-bottom: 1px solid var(--border-color); margin-bottom: 16px; }
.period-switcher a { color: var(--text-secondary); padding: 10px 14px; border-bottom: 2px solid transparent; font-size: 13px; font-weight: 700; }
.period-switcher a:hover, .period-switcher a.active { color: var(--info); border-bottom-color: var(--info); }
.dashboard-kpis { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 10px; margin-bottom: 22px; }
.dashboard-kpi { min-height: 108px; padding: 15px 16px; background: var(--bg-surface); border: 1px solid var(--border-color); border-radius: var(--radius-md); }
.dashboard-kpi span, .dashboard-kpi small { display: block; color: var(--text-muted); font-size: 12px; }
.dashboard-kpi strong { display: block; margin: 9px 0 4px; color: var(--text-primary); font-size: 21px; line-height: 1.1; }
.dashboard-kpi strong.positive { color: var(--success); }.dashboard-kpi strong.negative { color: var(--danger); }.dashboard-kpi strong.info { color: var(--info); }
.chart-workspace { padding: 20px 0; }
.chart-toolbar, .section-heading { display: flex; align-items: end; justify-content: space-between; gap: 18px; margin-bottom: 14px; }
.chart-toolbar h2, .quick-access h2, .record-entry-panel h2, .catalog-group h2, .recurring-section h2 { margin: 3px 0; font-size: 20px; }
.chart-toolbar p, .section-heading p, .record-entry-panel p, .catalog-group-heading p { color: var(--text-muted); font-size: 13px; }
.chart-panel { height: 330px; margin-bottom: 14px; padding: 18px 20px 12px; background: var(--bg-surface); border: 1px solid var(--border-color); border-radius: var(--radius-md); }
.chart-panel-flow { height: 270px; }
.quick-access { border-top: 1px solid var(--border-color); padding-top: 24px; }
.quick-access-buttons { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 10px; margin-top: 14px; }
.quick-action { display: flex; flex-direction: column; align-items: flex-start; gap: 5px; min-height: 116px; padding: 16px; color: var(--text-primary); text-align: left; background: var(--bg-surface); border: 1px solid var(--border-color); border-radius: var(--radius-md); cursor: pointer; transition: border-color .2s, transform .2s, background .2s; }
.quick-action:hover { transform: translateY(-2px); background: var(--bg-surface-hover); border-color: var(--border-highlight); }.quick-action > span { color: var(--info); font-size: 22px; }.quick-action strong { font-size: 14px; }.quick-action small { color: var(--text-muted); }.quick-action-primary { border-color: rgba(16,185,129,.55); }.quick-action-primary > span { color: var(--success); }

/* Reusable modal surface */
.modal-layer { display: none; position: fixed; inset: 0; z-index: 300; align-items: center; justify-content: center; padding: 20px; background: rgba(2, 6, 23, .72); backdrop-filter: blur(4px); }
.modal-layer.is-open { display: flex; }.modal-open { overflow: hidden; }
.modal-window { position: relative; width: min(460px, 100%); max-height: min(90vh, 760px); overflow-y: auto; padding: 26px; background: var(--bg-surface); border: 1px solid var(--border-highlight); border-radius: var(--radius-lg); box-shadow: 0 25px 60px rgba(0,0,0,.5); }.modal-window-wide { width: min(720px, 100%); }
.modal-window h2 { margin: 5px 0 8px; }.modal-description { color: var(--text-muted); font-size: 13px; margin-bottom: 14px; }.modal-close { position: absolute; top: 12px; right: 14px; border: 0; background: transparent; color: var(--text-muted); font-size: 26px; cursor: pointer; }.modal-close:hover { color: var(--text-primary); }
.modal-form { display: grid; gap: 10px; }.modal-form-full { grid-column: 1 / -1; }.modal-actions { display: flex; justify-content: flex-end; align-items: center; gap: 8px; margin-top: 8px; }.movement-type-switch { display: flex; gap: 6px; margin: 16px 0; }.movement-type-switch button { flex: 1; min-height: 40px; color: var(--text-secondary); background: var(--bg-main); border: 1px solid var(--border-color); border-radius: var(--radius-sm); cursor: pointer; font-weight: 700; }.movement-type-switch button.active { color: white; background: var(--primary); border-color: var(--primary); }

/* Visual activity registration page */
.record-page { max-width: 1500px; margin: 0 auto; }.back-link { display: block; margin-bottom: 8px; color: var(--info); font-size: 13px; }.record-header-actions { display: flex; gap: 8px; }.record-layout { display: grid; grid-template-columns: minmax(0, 1.5fr) minmax(300px, .7fr); gap: 22px; align-items: start; }.catalog-area { display: grid; gap: 20px; }.catalog-group { padding-bottom: 2px; }.catalog-group-heading { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 10px; }.catalog-group-heading > div { display: flex; align-items: center; gap: 10px; }.catalog-icon { display: grid; place-items: center; width: 36px; height: 36px; color: var(--item-accent, var(--info)); background: var(--bg-surface); border: 1px solid var(--border-color); border-radius: 10px; font-size: 20px; }.catalog-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 9px; }.catalog-item { position: relative; min-height: 90px; background: var(--bg-surface); border: 1px solid var(--border-color); border-left: 3px solid var(--item-accent, var(--info)); border-radius: var(--radius-md); }.catalog-item-select { display: flex; align-items: center; width: 100%; height: 100%; gap: 10px; padding: 12px; color: var(--text-primary); text-align: left; background: transparent; border: 0; cursor: pointer; }.catalog-item-select:hover .catalog-item-copy strong { color: var(--info); }.catalog-thumbnail { flex: 0 0 40px; display: grid; place-items: center; width: 40px; height: 40px; overflow: hidden; color: var(--info); background: var(--primary-light); border-radius: 10px; font-weight: 800; }.catalog-thumbnail img { width: 100%; height: 100%; object-fit: cover; }.catalog-item-copy { min-width: 0; }.catalog-item-copy strong, .catalog-item-copy small { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }.catalog-item-copy strong { font-size: 13px; }.catalog-item-copy small { margin-top: 5px; color: var(--text-muted); font-size: 12px; }.catalog-item-edit { position: absolute; right: 6px; bottom: 5px; padding: 2px 4px; color: var(--text-muted); background: transparent; border: 0; cursor: pointer; }.catalog-item-edit:hover { color: var(--info); }.catalog-empty { min-height: 90px; color: var(--text-muted); background: transparent; border: 1px dashed var(--border-highlight); border-radius: var(--radius-md); cursor: pointer; }.record-entry-panel { position: sticky; top: 88px; padding: 20px; background: var(--bg-surface); border: 1px solid var(--border-color); border-radius: var(--radius-lg); }.record-entry-heading { margin-bottom: 15px; }.record-form .form-textarea { min-height: 70px; }.record-submit { width: 100%; margin-top: 6px; }.recurring-section { margin-top: 30px; padding-top: 22px; border-top: 1px solid var(--border-color); }.recurring-list { display: grid; gap: 8px; }.recurring-row { display: flex; align-items: center; justify-content: space-between; gap: 14px; padding: 13px 15px; background: var(--bg-surface); border: 1px solid var(--border-color); border-radius: var(--radius-md); }.recurring-main, .recurring-actions { display: flex; align-items: center; gap: 12px; }.recurring-main small { display: block; margin-top: 4px; color: var(--text-muted); font-size: 12px; }.recurring-kind { padding: 5px 8px; color: var(--info); background: var(--primary-light); border-radius: 6px; font-size: 11px; font-weight: 700; }.empty-state { padding: 24px; color: var(--text-muted); text-align: center; border: 1px dashed var(--border-color); border-radius: var(--radius-md); }

@media (max-width: 1024px) {
    .dashboard-kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); }.quick-access-buttons { grid-template-columns: repeat(2, minmax(0, 1fr)); }.record-layout { grid-template-columns: 1fr; }.record-entry-panel { position: static; }.catalog-area { order: 2; }.record-entry-panel { order: 1; }
}
@media (max-width: 640px) {
    .finance-dashboard-header, .record-header, .chart-toolbar, .section-heading { align-items: flex-start; flex-direction: column; }.dashboard-period { width: 100%; min-width: 0; }.dashboard-period-row { flex-wrap: wrap; }.period-switcher { overflow-x: auto; }.period-switcher a { white-space: nowrap; }.dashboard-kpis, .quick-access-buttons { grid-template-columns: 1fr 1fr; }.chart-panel { height: 280px; padding: 12px 8px; }.chart-panel-flow { height: 240px; }.record-header-actions { width: 100%; }.record-header-actions .btn { flex: 1; }.catalog-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }.catalog-item { min-height: 82px; }.recurring-row { align-items: flex-start; flex-direction: column; }.recurring-actions { width: 100%; justify-content: flex-end; }.modal-window { padding: 22px 16px; }.modal-form { grid-template-columns: 1fr !important; }.modal-form-full { grid-column: auto; }
}

/* Navigation grouped into calm, discoverable submenus */
.nav-group { margin: 4px 0; }
.nav-group summary {
    list-style: none;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    min-height: 46px;
    padding: 10px 16px;
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    transition: background .2s ease, color .2s ease;
}
.nav-group summary::-webkit-details-marker { display: none; }
.nav-group summary > span:first-child { display:flex; align-items:center; gap:12px; }
.nav-group summary:hover, .nav-group[open] > summary { color: var(--text-primary); background: rgba(51, 65, 85, .55); }
.nav-group[open] > summary { border-radius: var(--radius-sm) var(--radius-sm) 0 0; }
.nav-chevron { font-size: 18px; color: var(--text-muted); transition: transform .2s ease; }
.nav-group[open] .nav-chevron { transform: rotate(180deg); }
.nav-submenu { margin: 0 0 4px 12px; padding: 4px 0 2px 10px; border-left: 1px solid var(--border-color); }
.nav-submenu .nav-item { min-height: 38px; padding: 8px 12px; margin-bottom: 2px; font-size: 14px; }
.nav-submenu .nav-item .icon { font-size: 15px; width: 20px; }
.nav-divider { height: 1px; background: var(--border-color); margin: 14px 12px; opacity: .7; }
.nav-badge { margin-left: auto; font-size: 10px; line-height: 1; text-transform: uppercase; letter-spacing: .05em; color: var(--info); background: var(--primary-light); padding: 4px 6px; border-radius: 5px; }
.cta-plus { font-size: 20px; line-height: 1; }

/* Personal finance dashboard */
.personal-hero {
    display: flex;
    justify-content: space-between;
    gap: 28px;
    align-items: stretch;
    padding: 28px 30px;
    margin-bottom: 20px;
    border: 1px solid rgba(56, 189, 248, .25);
    border-radius: var(--radius-lg);
    background: radial-gradient(circle at 85% 15%, rgba(16,185,129,.18), transparent 32%), linear-gradient(135deg, rgba(2,132,199,.18), rgba(30,41,59,.92));
    box-shadow: var(--shadow-card);
}
.personal-hero h1 { margin: 5px 0 7px; font-size: clamp(26px, 3vw, 38px); letter-spacing: -.03em; }
.personal-hero p { max-width: 650px; color: var(--text-secondary); }
.eyebrow { color: var(--info); font-size: 11px; font-weight: 800; letter-spacing: .12em; text-transform: uppercase; }
.personal-quick-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 20px; }
.btn-ghost { background: transparent; color: var(--text-secondary); border: 1px solid var(--border-color); }
.btn-ghost:hover { background: var(--bg-surface-hover); color: var(--text-primary); }
.personal-quick-actions .btn { min-height: 40px; padding: 9px 14px; font-size: 14px; }
.period-picker { min-width: 260px; align-self: center; padding: 17px; border: 1px solid var(--border-color); border-radius: var(--radius-md); background: rgba(15, 23, 42, .46); }
.period-picker-row { display: flex; gap: 8px; }
.period-picker-row .btn { min-height: 48px; padding: 10px 15px; }
.period-picker small { display: block; color: var(--text-muted); margin-top: 8px; font-size: 12px; }
.personal-guide { margin-top: 0; }
.personal-wide-section { margin-top: 24px; }
#registrar-movimiento, #cuentas, #planificacion, #ppr, #patrimonio, #movimientos { scroll-margin-top: 90px; }
.patrimony-explainer { display: grid; grid-template-columns: minmax(0, 1fr) minmax(300px, 1fr); gap: 16px; margin: 0 0 20px; }
.patrimony-definition, .consumption-breakdown { padding: 16px; border: 1px solid var(--border-color); border-radius: var(--radius-md); background: rgba(15, 23, 42, .45); }
.patrimony-definition strong { display: block; margin: 8px 0 6px; color: var(--info); font-size: 18px; }
.patrimony-definition p { color: var(--text-secondary); font-size: 13px; line-height: 1.6; }
.consumption-breakdown-heading { display: flex; justify-content: space-between; gap: 12px; align-items: center; color: var(--text-primary); }
.consumption-breakdown-heading > span { color: var(--warning); font-weight: 800; white-space: nowrap; }
.consumption-list { display: grid; gap: 8px; margin-top: 12px; }
.consumption-list > div { display: flex; justify-content: space-between; gap: 12px; align-items: center; padding-top: 8px; border-top: 1px solid rgba(71, 85, 105, .55); font-size: 13px; }
.consumption-list small { display: block; color: var(--text-muted); font-size: 11px; margin-top: 2px; }
.consumption-list strong { color: var(--warning); white-space: nowrap; }
.personal-transactions-table { min-width: 980px; }
.personal-transactions-table tbody tr { transition: background .2s ease; }
.personal-transactions-table tbody tr:hover { background: rgba(51,65,85,.32); }
.movement-type { display: inline-flex; align-items: center; gap: 5px; font-weight: 700; font-size: 13px; }
.movement-type::before { content: ''; width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.movement-type.income, .movement-amount.income { color: var(--success); }
.movement-type.expense, .movement-amount.expense { color: var(--danger); }
.movement-amount { font-weight: 700; white-space: nowrap; }
.table-note { display: block; color: var(--info); font-size: 11px; margin-top: 3px; }
.inline-action-form { display: inline-flex; margin-left: 4px; }
.inline-edit { display: inline-block; position: relative; text-align: left; }
.inline-edit > summary { list-style: none; cursor: pointer; display: inline-flex; }
.inline-edit > summary::-webkit-details-marker { display: none; }
.transaction-edit-form { position: absolute; z-index: 20; right: 0; top: calc(100% + 8px); width: min(520px, calc(100vw - 42px)); display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; padding: 18px; background: var(--bg-surface); border: 1px solid var(--border-highlight); border-radius: var(--radius-md); box-shadow: 0 18px 40px rgba(0,0,0,.42); }
.ppr-edit-form { width: min(760px, calc(100vw - 42px)); }
.goal-actions { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 10px; }
.transaction-edit-form .form-label { font-size: 12px; margin-bottom: 5px; }
.transaction-edit-form .form-control, .transaction-edit-form .form-select { min-height: 40px; padding: 8px 10px; font-size: 14px; }
.transaction-edit-notes, .transaction-edit-actions, .transaction-edit-form .form-help { grid-column: 1 / -1; }
.transaction-edit-actions { display: flex; gap: 8px; justify-content: flex-end; }
.transaction-edit-form .form-help { margin-top: -4px; }

@media (max-width: 768px) {
    .personal-hero { padding: 22px 18px; flex-direction: column; }
    .period-picker { min-width: 0; width: 100%; }
    .personal-quick-actions .btn { flex: 1 1 auto; }
    .patrimony-explainer { grid-template-columns: 1fr; }
    .transaction-edit-form { position: fixed; left: 18px; right: 18px; top: 50%; transform: translateY(-50%); width: auto; max-height: 85vh; overflow-y: auto; }
}

@media (max-width: 480px) {
    .transaction-edit-form { grid-template-columns: 1fr; }
    .transaction-edit-notes, .transaction-edit-actions, .transaction-edit-form .form-help { grid-column: auto; }
    .period-picker-row { flex-direction: column; }
}

.history-list { display: grid; gap: 8px; }
.history-row { position: relative; display: grid; grid-template-columns: minmax(0, 1fr) auto auto; align-items: center; gap: 14px; padding: 12px 15px; background: var(--bg-surface); border: 1px solid var(--border-color); border-radius: var(--radius-md); }
.history-row > div:first-child strong, .history-row > div:first-child small { display: block; }
.history-row > div:first-child strong { margin: 4px 0 2px; }
.history-row > div:first-child small { color: var(--text-muted); font-size: 12px; }
.history-amount { font-weight: 800; white-space: nowrap; }
.history-amount.income { color: var(--success); }
.history-amount.expense { color: var(--danger); }
@media (max-width: 640px) {
    .history-row { grid-template-columns: minmax(0, 1fr) auto; }
    .history-row .inline-edit { grid-column: 1 / -1; justify-self: end; }
}

/* Compact personal finance dashboard */
.compact-dashboard-header { align-items: flex-start; margin-bottom: 14px; }
.dashboard-head-controls { display: flex; align-items: center; justify-content: flex-end; gap: 8px; flex-wrap: wrap; }
.dashboard-secondary-actions { display: flex; gap: 4px; flex-wrap: wrap; }
.quick-link { min-height: 34px; padding: 7px 10px; color: var(--text-secondary); background: transparent; border: 1px solid transparent; border-radius: var(--radius-sm); font-size: 12px; font-weight: 700; cursor: pointer; text-decoration: none; }
.quick-link:hover { color: var(--text-primary); background: var(--bg-surface); border-color: var(--border-color); }
.primary-kpis { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 10px; margin-bottom: 10px; }
.primary-kpis .dashboard-kpi { min-height: 100px; padding: 14px 16px; }
.secondary-summary { display: flex; flex-wrap: wrap; gap: 7px 20px; margin: 0 0 10px; padding: 4px 2px 14px; color: var(--text-muted); font-size: 12px; border-bottom: 1px solid var(--border-color); }
.secondary-summary span { white-space: nowrap; }
.secondary-summary strong { margin-left: 4px; color: var(--text-primary); font-size: 13px; }
.secondary-summary strong.negative { color: var(--danger); }
.period-arrow { width: 32px; height: 32px; color: var(--text-secondary); background: transparent; border: 1px solid transparent; border-radius: var(--radius-sm); cursor: pointer; font-size: 18px; }
.period-arrow:hover:not(:disabled) { color: var(--text-primary); background: var(--bg-surface); border-color: var(--border-color); }
.period-arrow:disabled { opacity: .3; cursor: not-allowed; }
.chart-panel-single { position: relative; height: 380px; margin-bottom: 0; }
.chart-empty { position: absolute; inset: 0; display: grid; place-items: center; color: var(--text-muted); font-size: 13px; pointer-events: none; }
.latest-movements { padding-top: 22px; }
.latest-movements .section-heading { align-items: center; margin-bottom: 10px; }
.latest-movements h2 { margin: 3px 0; font-size: 20px; }
.latest-movement-list { display: grid; gap: 2px; }
.latest-movement-row { display: grid; grid-template-columns: 8px minmax(0, 1fr) auto; align-items: center; gap: 11px; min-height: 52px; padding: 7px 2px; border-bottom: 1px solid rgba(71, 85, 105, .35); }
.movement-dot { width: 7px; height: 7px; border-radius: 50%; }
.movement-dot.income { background: var(--success); }.movement-dot.expense { background: var(--warning); }
.latest-movement-copy strong, .latest-movement-copy small { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.latest-movement-copy strong { font-size: 13px; }.latest-movement-copy small { margin-top: 3px; color: var(--text-muted); font-size: 11px; }
.latest-movement-amount { font-size: 13px; white-space: nowrap; }.latest-movement-amount.income { color: var(--success); }.latest-movement-amount.expense { color: var(--warning); }

/* Header module switcher */
.module-switcher { position: relative; z-index: 20; }
.module-switcher summary { display: flex; align-items: center; gap: 7px; min-height: 36px; padding: 7px 10px; color: var(--text-secondary); background: var(--bg-surface); border: 1px solid var(--border-color); border-radius: var(--radius-sm); list-style: none; cursor: pointer; font-size: 13px; font-weight: 700; }
.module-switcher summary::-webkit-details-marker { display: none; }
.module-switcher summary:hover, .module-switcher[open] summary { color: var(--text-primary); border-color: var(--border-highlight); }
.module-switcher-chevron { color: var(--text-muted); font-size: 16px; }
.module-switcher-menu { position: absolute; top: calc(100% + 6px); right: 0; display: grid; min-width: 230px; padding: 5px; background: var(--bg-surface); border: 1px solid var(--border-highlight); border-radius: var(--radius-md); box-shadow: 0 18px 36px rgba(0,0,0,.35); }
.module-switcher-menu a { display: flex; align-items: center; gap: 8px; padding: 9px 10px; color: var(--text-secondary); border-radius: var(--radius-sm); font-size: 13px; text-decoration: none; }
.module-switcher-menu a:hover, .module-switcher-menu a.active { color: var(--text-primary); background: var(--bg-surface-hover); }.module-switcher-menu a.active span { color: var(--success); }
.modal-existing-list { display: grid; gap: 5px; margin: 14px 0 18px; padding-bottom: 4px; border-bottom: 1px solid var(--border-color); }
.modal-existing-row { border: 1px solid var(--border-color); border-radius: var(--radius-sm); overflow: hidden; }
.modal-existing-row summary { display: flex; justify-content: space-between; gap: 10px; padding: 9px 10px; color: var(--text-secondary); cursor: pointer; font-size: 13px; list-style: none; }
.modal-existing-row summary::-webkit-details-marker { display: none; }.modal-existing-row summary strong { color: var(--text-primary); }.modal-existing-row[open] summary { color: var(--text-primary); background: var(--bg-surface-hover); }
.modal-inline-form { display: grid; gap: 8px; padding: 10px; border-top: 1px solid var(--border-color); }.modal-inline-form .btn { justify-self: end; }

/* Sidebar hierarchy */
.nav-top-label { margin: 14px 16px 5px; color: var(--text-muted); font-size: 10px; font-weight: 800; letter-spacing: .13em; text-transform: uppercase; }
.personal-nav > summary { color: var(--text-primary); }
.personal-nav > summary .nav-badge { margin-left: auto; }
.personal-nav > summary .nav-chevron { margin-left: 0; }

@media (max-width: 1024px) {
    .primary-kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .dashboard-head-controls { justify-content: flex-start; }
}
@media (max-width: 640px) {
    .compact-dashboard-header { gap: 14px; }
    .dashboard-head-controls { width: 100%; }
    .dashboard-secondary-actions { width: 100%; order: 3; }
    .quick-link { flex: 1 1 auto; text-align: center; }
    .dashboard-period { width: 100%; min-width: 0; }
    .primary-kpis { grid-template-columns: 1fr 1fr; }
    .primary-kpis .dashboard-kpi { min-height: 94px; padding: 12px; }
    .primary-kpis .dashboard-kpi strong { font-size: 18px; }
    .secondary-summary { gap: 8px 14px; }
    .chart-panel-single { height: 290px; }
    .latest-movement-row { grid-template-columns: 8px minmax(0, 1fr) auto; }
    .module-switcher summary span:nth-child(2) { max-width: 120px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
}
