@charset "utf-8";
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&display=swap');

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

:root {
    --bg: rgba(221, 221, 221, 1);
    --card-bg: rgba(242, 242, 242, 1);
    --text: rgba(37, 37, 37, 1);
    --text-secondary: rgba(116, 99, 84, 1);
    --primary: rgba(142, 47, 55, 1);
    --primary-rgb: 142, 47, 55;
    --primary-hover: rgba(110, 32, 40, 1);
    --income: rgba(82, 153, 139, 1);
    --expense: rgba(206, 55, 55, 1);
    --warning: rgba(245, 158, 11, 1);
    --border: rgba(200, 200, 200, 1);
    --input-bg: rgba(228, 228, 228, 1);
    --on-primary: #fff;
    --income-bg: rgba(82, 153, 139, 0.12);
    --expense-bg: rgba(206, 55, 55, 0.12);
    --primary-bg: rgba(142, 47, 55, 0.12);
    --warning-bg: rgba(245, 158, 11, 0.12);
    --shadow: 0 1px 3px rgba(0, 0, 0, 0.1),
        0 1px 2px rgba(0, 0, 0, 0.06);

    --radius: 8px;
    --font: 'Inter', sans-serif;
    --sidebar-width: 240px;
    --header-height: 58px;
    --footer-height: 48px;

    --space-xs: 4px;
    --space-sm: 8px;
    --space-md: 12px;
    --space-lg: 16px;
    --space-xl: 20px;
    --space-xxl: 24px;
    --space-3xl: 32px;
    --space-4xl: 40px;

    --btn-sm: 6px 12px;
    --btn-md: 10px 20px;
    --btn-lg: 12px 24px;

    --radius-sm: 4px;
    --radius-lg: 12px;
    --radius-pill: 28px;

    --shadow-focus: 0 0 0 2px rgba(142, 47, 55, 0.25);
    --shadow-modal: 0 20px 60px rgba(0, 0, 0, 0.2);
    --shadow-fab: 0 4px 20px rgba(142, 47, 55, 0.45);
    --shadow-fab-hover: 0 6px 28px rgba(142, 47, 55, 0.55);

    /* Typography scale */
    --type-display: 1.75rem;
    --type-headline: 1.375rem;
    --type-title: 1rem;
    --type-body: 0.9rem;
    --type-label: 0.8125rem;
    --type-caption: 0.75rem;

    --lh-tight: 1.2;
    --lh-snug: 1.35;
    --lh-body: 1.5;

    --weight-regular: 400;
    --weight-medium: 500;
    --weight-semibold: 600;
    --weight-bold: 700;
}

html.dark {
    --bg: rgba(24, 23, 21, 1);
    --card-bg: rgba(38, 37, 34, 1);
    --text: rgba(211, 211, 211, 1);
    --text-secondary: rgba(163, 158, 148, 1);
    --primary: rgba(255, 145, 0, 1);
    --primary-rgb: 255, 145, 0;
    --primary-hover: rgba(230, 120, 0, 1);
    --income: rgba(0, 180, 117, 1);
    --expense: rgba(255, 99, 82, 1);
    --warning: rgba(255, 183, 77, 1);
    --border: rgba(58, 56, 52, 1);
    --input-bg: rgba(48, 46, 42, 1);
    --on-primary: rgba(24, 23, 21, 1);
    --income-bg: rgba(0, 180, 117, 0.15);
    --expense-bg: rgba(255, 99, 82, 0.15);
    --primary-bg: rgba(255, 145, 0, 0.15);
    --warning-bg: rgba(255, 183, 77, 0.15);
    --shadow: 0 1px 3px rgba(0, 0, 0, 0.3);
    --shadow-focus: 0 0 0 2px rgba(255, 145, 0, 0.35);
    --shadow-fab: 0 4px 20px rgba(255, 145, 0, 0.45);
    --shadow-fab-hover: 0 6px 28px rgba(255, 145, 0, 0.55);
}

html {
    font-size: 16px;
}

body {
    font-family: var(--font);
    font-size: var(--type-body);
    line-height: var(--lh-body);
    background: var(--bg);
    color: var(--text);
    min-height: 100vh;
    transition: background 0.3s, color 0.3s;
}

.skip-link {
    position: absolute;
    top: -40px;
    left: 0;
    background: var(--primary);
    color: var(--on-primary);
    padding: 8px 16px;
    z-index: 200;
    transition: top 0.2s;
}

.skip-link:focus {
    top: 0;
}

:focus-visible {
    outline: 2px solid var(--primary);
    outline-offset: 2px;
}

button:focus-visible,
.btn-primary:focus-visible,
.btn-secondary:focus-visible,
.btn-icon:focus-visible,
.btn-page:focus-visible,
.btn-logout:focus-visible,
.sidebar-link:focus-visible,
.sidebar-toggle:focus-visible,
.theme-toggle:focus-visible,
.modal-close:focus-visible,
.fab-tx:focus-visible,
.auth-theme-toggle:focus-visible {
    box-shadow: var(--shadow-focus);
    outline: none;
}

.sidebar-overlay:focus-visible {
    outline: none;
}

input,
select,
button,
textarea {
    font-family: inherit;
    font-size: inherit;
}

a {
    color: var(--primary);
    text-decoration: none;
}

/* ===== Theme toggle — toggle switch ===== */
.theme-toggle {
    background: none;
    border: none;
    padding: 4px;
    cursor: pointer;
    line-height: 1;
    min-height: 44px;
    min-width: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.toggle-track {
    display: inline-block;
    width: 44px;
    height: 24px;
    background: var(--border);
    border-radius: 12px;
    position: relative;
    transition: background 0.3s;
}

html.dark .toggle-track {
    background: var(--primary);
}

.toggle-thumb {
    position: absolute;
    top: 2px;
    left: 2px;
    width: 20px;
    height: 20px;
    background: #fff;
    border-radius: 50%;
    transition: transform 0.3s;
    z-index: 2;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
}

html.dark .toggle-thumb {
    transform: translateX(20px);
}

.toggle-icon {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    font-size: var(--type-caption);
    line-height: 1;
    z-index: 1;
    pointer-events: none;
}

.toggle-icon--light {
    left: 5px;
    color: var(--warning);
}

.toggle-icon--dark {
    right: 5px;
    color: #cbd5e1;
}

/* ===== Auth pages ===== */
.auth-container {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    padding: 20px;
    position: relative;
}

.auth-theme-row {
    display: flex;
    justify-content: center;
    margin-top: 20px;
}

.auth-theme-row .theme-toggle {
    display: inline-flex;
}

.auth-card {
    background: var(--card-bg);
    border-radius: 12px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.08),
        0 2px 8px rgba(0, 0, 0, 0.04);
    padding: 32px 24px;
    width: 100%;
    max-width: 380px;
    transition: background 0.3s,
        transform 0.2s ease-out,
        box-shadow 0.2s ease-out;
}

.auth-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.1),
        0 4px 12px rgba(0, 0, 0, 0.06);
}

.auth-header {
    text-align: center;
    margin-bottom: 32px;
}

.auth-header h1 {
    font-size: var(--type-display);
    font-weight: var(--weight-bold);
    line-height: var(--lh-tight);
    margin-bottom: 6px;
}

.auth-header p {
    color: var(--text-secondary);
    font-size: var(--type-body);
    line-height: var(--lh-snug);
}

.auth-form {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.auth-footer {
    text-align: center;
    margin-top: 24px;
    font-size: var(--type-body);
    color: var(--text-secondary);
}

/* ===== Form elements ===== */
.form-group {
    display: flex;
    flex-direction: column;
    gap: 4px;
    min-width: 0;
}

.form-group label {
    font-size: var(--type-label);
    font-weight: var(--weight-medium);
    color: var(--text-secondary);
}

.form-group input,
.form-group select,
.form-group textarea {
    padding: 10px 12px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--input-bg);
    color: var(--text);
    transition: border 0.2s, background 0.3s;
    width: 100%;
    min-width: 0;
    box-sizing: border-box;
}

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

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

.form-error {
    color: var(--expense);
    font-size: var(--type-label);
    min-height: 1.2em;
}

.form-success {
    color: var(--income);
    font-size: var(--type-label);
    min-height: 1.2em;
}

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

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

/* ===== Buttons ===== */
.btn-primary {
    padding: var(--btn-md);
    background: var(--primary);
    color: var(--on-primary);
    border: none;
    border-radius: var(--radius);
    cursor: pointer;
    font-weight: var(--weight-semibold);
    font-size: var(--type-body);
    line-height: var(--lh-snug);
    transition: background 0.2s,
        transform 0.1s ease-out;
}

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

.btn-primary:active {
    transform: scale(0.97);
}

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

.btn-danger {
    padding: var(--btn-md);
    background: var(--expense);
    color: #fff;
    border: none;
    border-radius: var(--radius);
    cursor: pointer;
    font-weight: var(--weight-semibold);
    font-size: var(--type-body);
    line-height: var(--lh-snug);
    transition: opacity 0.2s,
        transform 0.1s ease-out;
}

.btn-danger:hover {
    opacity: 0.85;
}

.btn-danger:active {
    transform: scale(0.97);
}

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

.btn-secondary {
    padding: var(--btn-md);
    background: transparent;
    color: var(--text);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    cursor: pointer;
    font-weight: var(--weight-semibold);
    font-size: var(--type-body);
    line-height: var(--lh-snug);
    transition: background 0.2s;
}

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

.btn-logout {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: var(--btn-sm);
    background: transparent;
    color: var(--text-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    cursor: pointer;
    transition: background 0.2s, color 0.2s;
}

.btn-logout:hover {
    background: var(--expense);
    color: #fff;
    border-color: var(--expense);
}

.btn-icon {
    background: none;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: var(--btn-sm);
    cursor: pointer;
    color: var(--text-secondary);
    font-size: var(--type-label);
    transition: background 0.2s;
}

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

.btn-icon-danger {
    color: var(--expense);
    border-color: rgba(220, 38, 38, 0.3);
}

.btn-icon-danger:hover {
    background: var(--expense);
    color: #fff;
    border-color: var(--expense);
}

/* ===== Dashboard layout ===== */
.dash-layout {
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

/* ===== Header ===== */
.dash-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    padding: 6px 16px;
    min-height: var(--header-height);
    height: auto;
    background: var(--card-bg);
    border-bottom: 1px solid var(--border);
    transition: background 0.3s;
    flex-shrink: 0;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 100;
}

/* Logo */
.header-logo {
    display: flex;
    align-items: center;
    gap: 8px;
    text-decoration: none;
    flex-shrink: 0;
    cursor: pointer;
}

.header-logo-icon {
    height: 32px;
    width: auto;
}

.header-logo-text {
    font-size: var(--type-title);
    font-weight: var(--weight-bold);
    color: var(--text);
    white-space: nowrap;
}

/* Nav tabs inside header */
.header-nav {
    display: none;
    align-items: center;
    gap: 4px;
    margin: 0 auto;
}

.header-nav-link {
    padding: 10px 18px;
    border: none;
    border-radius: var(--radius-pill);
    background: transparent;
    color: var(--text-secondary);
    font-size: var(--type-label);
    font-weight: var(--weight-medium);
    line-height: var(--lh-snug);
    cursor: pointer;
    transition: background 0.2s, color 0.2s;
    white-space: nowrap;
}

.header-nav-link:hover {
    background: rgba(var(--primary-rgb, 142, 47, 55), 0.08);
    color: var(--primary);
}

.header-nav-link.active {
    background: var(--primary);
    color: var(--on-primary);
}

.header-nav-link.active:hover {
    background: var(--primary-hover);
    color: var(--on-primary);
}

/* Header right group */
.header-right {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-shrink: 0;
}

/* Theme toggle icon */
.theme-toggle {
    display: none;
    background: none;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 6px;
    cursor: pointer;
    color: var(--text-secondary);
    line-height: 1;
    transition: background 0.2s, color 0.2s, border-color 0.2s;
    flex-shrink: 0;
}

.theme-toggle:hover {
    background: var(--border);
    color: var(--primary);
    border-color: var(--primary);
}

/* User greeting */
.header-user {
    display: flex;
    align-items: center;
    gap: 6px;
    flex-shrink: 0;
}

.header-greeting {
    display: none;
    font-size: var(--type-caption);
    color: var(--text-secondary);
}

.header-user-name {
    font-size: var(--type-body);
    font-weight: var(--weight-bold);
    color: var(--text);
    white-space: nowrap;
}

/* Header controls */
.dash-header .btn-logout {
    flex-shrink: 0;
    padding: var(--btn-sm);
    font-size: var(--type-label);
}

.dash-body {
    display: flex;
    flex: 1;
    min-height: 0;
    align-items: flex-start;
    padding-top: var(--header-height);
}

/* ===== Sidebar (mobile-first: fixed off-screen) ===== */
.dash-sidebar {
    position: fixed;
    top: var(--header-height);
    left: 0;
    bottom: 0;
    z-index: 99;
    transform: translateX(-100%);
    transition: transform 0.3s ease, background 0.3s;
    box-shadow: 2px 0 12px rgba(0, 0, 0, 0.2);
    width: 240px;
    flex-shrink: 0;
    background: var(--card-bg);
    border-right: 1px solid var(--border);
    padding: 12px 0;
    overflow-y: auto;
}

.dash-sidebar.open {
    transform: translateX(0);
}

.sidebar-nav {
    list-style: none;
    padding: 0;
    margin: 0;
}

.sidebar-link {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
    padding: 14px 32px;
    color: var(--text);
    background: none;
    border: none;
    font-size: var(--type-body);
    line-height: var(--lh-snug);
    cursor: pointer;
    text-align: left;
    transition: background 0.15s;
}

.sidebar-link:hover {
    background: var(--input-bg);
}

.sidebar-link.active {
    background: var(--primary);
    color: var(--on-primary);
}

.sidebar-link .icon {
    font-size: var(--type-title);
    width: 20px;
    text-align: center;
    flex-shrink: 0;
}

.sidebar-separator {
    border-top: 1px solid var(--border);
    margin: 8px 24px;
    list-style: none;
}

/* Theme toggle inside sidebar (mobile) */
.sidebar-theme-toggle {
    display: flex;
    margin: 65vh auto 0;
    padding: 8px;
}

/* Hamburger toggle */
.sidebar-toggle {
    display: block;
    background: none;
    border: none;
    font-size: 1.3rem;
    cursor: pointer;
    color: var(--text);
    padding: 4px 6px;
    line-height: 1;
    flex-shrink: 0;
    min-height: 44px;
    min-width: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.sidebar-toggle:hover {
    color: var(--primary);
}

/* Sidebar overlay for mobile */
.sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.4);
    z-index: 98;
}

.sidebar-overlay.open {
    display: block;
}

/* ===== Main content (mobile-first: compact padding) ===== */
.dash-main {
    flex: 1;
    padding: 16px;
    min-width: 0;
    overflow: visible;
}

/* ===== Dashboard Content Area ===== */
.dash-content-area {
    position: relative;
    background: var(--bg);
    border-radius: var(--radius-lg);
    padding: 20px 0;
    margin-top: 8px;
}

.dash-content-area::after {
    content: "";
    position: absolute;
    top: 0;
    right: 0;
    width: 40px;
    height: 52px;
    background: linear-gradient(to right, transparent, var(--bg));
    pointer-events: none;
    z-index: 1;
    opacity: 1;
    transition: opacity 0.2s;
}

.dash-content-area.scroll-end::after {
    opacity: 0;
}

/* ===== Dashboard Tabs (toggle style) ===== */
.dash-tabs {
    display: flex;
    gap: 4px;
    margin-bottom: 24px;
    border-bottom: 2px solid var(--border);
    padding-bottom: 0;
    overflow-x: auto;
    overflow-y: hidden;
    -webkit-overflow-scrolling: touch;
}

.dash-tab-btn {
    padding: 10px 20px;
    border: none;
    border-bottom: 2px solid transparent;
    margin-bottom: -2px;
    background: transparent;
    color: var(--text-secondary);
    font-size: var(--type-body);
    font-weight: var(--weight-medium);
    line-height: var(--lh-snug);
    cursor: pointer;
    transition: color 0.2s, border-color 0.2s, background 0.2s;
    white-space: nowrap;
    border-radius: var(--radius-pill) var(--radius-pill) 0 0;
}

.dash-tab-btn:hover {
    color: var(--primary);
    background: rgba(var(--primary-rgb, 142, 47, 55), 0.06);
}

.dash-tab-btn.active {
    color: var(--primary);
    border-bottom-color: var(--primary);
    font-weight: 600;
    background: rgba(var(--primary-rgb, 142, 47, 55), 0.08);
}

.dash-tab-panel {
    display: none;
}

.dash-tab-panel.active {
    display: block;
    animation: fadeSlideIn 0.3s cubic-bezier(0.16, 1, 0.3, 1) both;
}

/* ===== Footer ===== */
.dash-footer {
    padding: 16px 16px;
    font-size: var(--type-label);
    color: var(--text-secondary);
    border-top: 1px solid var(--border);
    background: var(--card-bg);
    flex-shrink: 0;
    box-shadow: 0 -2px 8px rgba(0, 0, 0, 0.04);
}

.footer-inner {
    display: flex;
    flex-direction: column;
    text-align: center;
    justify-content: space-between;
    align-items: center;
    margin: 0 auto;
    gap: 8px;
}

.footer-brand {
    font-weight: var(--weight-bold);
    color: var(--text);
    font-size: var(--type-title);
    white-space: nowrap;
}

.footer-links {
    display: flex;
    gap: 16px;
    align-items: center;
}

.footer-links a {
    color: var(--text-secondary);
    text-decoration: none;
    transition: color 0.2s;
    white-space: nowrap;
    font-size: var(--type-label);
}

.footer-links a:hover {
    color: var(--primary);
}

.footer-copy {
    white-space: nowrap;
    font-size: var(--type-caption);
}

.section-header {
    margin-bottom: 24px;
    animation: fadeSlideIn 0.4s cubic-bezier(0.16, 1, 0.3, 1) both;
}

.section-header h2 {
    font-size: var(--type-headline);
    font-weight: var(--weight-bold);
    line-height: var(--lh-tight);
    letter-spacing: -0.02em;
}

.section-header p {
    font-size: var(--type-label);
    color: var(--text-secondary);
    margin-top: 4px;
    font-weight: var(--weight-medium);
    line-height: var(--lh-snug);
}

#adminPeriodSubtitle h3 {
    font-size: var(--type-body);
    font-weight: var(--weight-semibold);
    color: var(--text);
    margin-top: 4px;
    line-height: var(--lh-snug);
}

#adminPeriodSubtitle span {
    font-size: var(--type-caption);
    color: var(--text-secondary);
}

/* ===== Summary cards (mobile-first: 1 column) ===== */
.summary-cards {
    display: grid;
    grid-template-columns: 1fr;
    gap: 20px;
    margin-bottom: 32px;
}

.summary-card {
    background: var(--card-bg);
    border-radius: var(--radius-lg);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08),
        0 2px 4px rgba(0, 0, 0, 0.04);
    padding: 24px;
    transition: background 0.3s,
        transform 0.2s ease-out,
        box-shadow 0.2s ease-out;
    animation: cardEnter 0.4s cubic-bezier(0.16, 1, 0.3, 1) both;
}

.summary-card:nth-child(1) {
    animation-delay: 0ms;
}

.summary-card:nth-child(2) {
    animation-delay: 80ms;
}

.summary-card:nth-child(3) {
    animation-delay: 160ms;
}

.summary-card:nth-child(4) {
    animation-delay: 240ms;
}

.summary-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.1),
        0 4px 8px rgba(0, 0, 0, 0.06);
}

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

.summary-label {
    display: block;
    font-size: var(--type-caption);
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    font-weight: var(--weight-medium);
}

.summary-icon {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.summary-icon.income {
    background: var(--income-bg);
    color: var(--income);
}

.summary-icon.expense {
    background: var(--expense-bg);
    color: var(--expense);
}

.summary-icon.balance {
    background: var(--primary-bg);
    color: var(--primary);
}

.summary-icon.saving {
    background: rgba(116, 99, 84, 0.12);
    color: var(--text-secondary);
}

.summary-value {
    display: block;
    font-size: 1.85rem;
    font-weight: var(--weight-bold);
    line-height: var(--lh-tight);
    margin-bottom: 4px;
    font-variant-numeric: tabular-nums;
}

.summary-change {
    display: block;
    font-size: var(--type-caption);
    color: var(--text-secondary);
    font-weight: var(--weight-medium);
}

.summary-change.positive {
    color: var(--income);
}

.summary-change.negative {
    color: var(--expense);
}

.income {
    color: var(--income);
}

.expense {
    color: var(--expense);
}

/* ===== Section actions ===== */
.section-actions {
    margin-bottom: 20px;
}

/* ===== Tables ===== */
.table-scroll {
    overflow-x: auto;
    border-radius: var(--radius);
    box-shadow: var(--shadow);
}

.data-table {
    width: 100%;
    border-collapse: collapse;
    background: var(--card-bg);
    transition: background 0.3s;
}

.data-table th {
    text-align: left;
    padding: 12px 12px;
    font-size: var(--type-caption);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-secondary);
    background: var(--input-bg);
    border-bottom: 2px solid var(--border);
    white-space: nowrap;
    font-weight: var(--weight-semibold);
}

.sortable-header {
    cursor: pointer;
    user-select: none;
}

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

.sort-header-content {
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.sort-icon {
    flex-shrink: 0;
    color: var(--primary);
}

.btn-with-icon {
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.data-table td {
    padding: 12px 12px;
    border-bottom: 1px solid var(--border);
    font-size: var(--type-body);
    line-height: var(--lh-body);
}

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

.data-table tbody tr:hover {
    background: var(--input-bg);
    box-shadow: inset 0 0 0 1px rgba(142, 47, 55, 0.08);
}

.amount {
    text-align: right;
    font-weight: var(--weight-semibold);
    white-space: nowrap;
    font-variant-numeric: tabular-nums;
}

.pct {
    text-align: right;
    font-variant-numeric: tabular-nums;
}

.data-table .actions-cell {
    white-space: nowrap;
    display: flex;
    gap: 6px;
}

.data-table .empty-state {
    text-align: center;
    color: var(--text-secondary);
    padding: 48px 14px;
}

/* Badge for category type */
.badge {
    display: inline-block;
    padding: 2px 10px;
    border-radius: 12px;
    font-size: var(--type-caption);
    font-weight: var(--weight-semibold);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.badge-income {
    background: var(--income-bg);
    color: var(--income);
}

.badge-expense {
    background: var(--expense-bg);
    color: var(--expense);
}

/* ===== Tree view (subcategories) ===== */
.tree-container {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.tree-category {
    background: var(--card-bg);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    overflow: hidden;
    transition: background 0.3s;
}

.tree-category-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px;
    border-bottom: 1px solid var(--border);
    gap: 10px;
    flex-wrap: wrap;
}

.tree-category-name {
    font-size: var(--type-title);
    font-weight: var(--weight-bold);
    color: var(--text);
    display: flex;
    align-items: center;
    gap: 8px;
}

.tree-category-meta {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-shrink: 0;
}

.tree-subcategory-count {
    font-size: var(--type-caption);
    color: var(--text-secondary);
    background: var(--input-bg);
    padding: 2px 8px;
    border-radius: 10px;
}

.tree-subcategory-list {
    list-style: none;
    padding: 0;
    margin: 0;
}

.tree-subcategory-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 20px 12px 40px;
    border-bottom: 1px solid var(--border);
    gap: 10px;
    transition: background 0.15s;
}

.tree-subcategory-item:last-child {
    border-bottom: none;
}

.tree-subcategory-item:hover {
    background: var(--input-bg);
}

.tree-subcategory-info {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.tree-subcategory-name {
    font-size: var(--type-body);
    font-weight: var(--weight-medium);
    color: var(--text);
    line-height: var(--lh-snug);
}

.tree-subcategory-comment {
    font-size: var(--type-caption);
    color: var(--text-secondary);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.tree-subcategory-actions {
    display: flex;
    gap: 6px;
    flex-shrink: 0;
}

.tree-empty {
    padding: 10px 18px;
    color: var(--text-secondary);
    font-size: var(--type-label);
    font-style: italic;
}

/* Pagination */
.pagination {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    margin-top: 20px;
}

.btn-page {
    padding: var(--btn-md);
    background: var(--card-bg);
    color: var(--text);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    cursor: pointer;
    font-size: var(--type-label);
    transition: background 0.2s;
}

.btn-page:hover:not(:disabled) {
    background: var(--border);
}

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

.btn-page-active {
    background: var(--primary);
    color: var(--on-primary);
    border-color: var(--primary);
}

.btn-page-active:hover {
    background: var(--primary-hover);
}

/* ===== Modal (mobile-first: bottom sheet) ===== */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.45);
    display: flex;
    align-items: flex-end;
    justify-content: center;
    z-index: 200;
    padding: 0;
}

.modal {
    background: var(--card-bg);
    border-radius: 12px 12px 0 0;
    box-shadow: var(--shadow-modal);
    width: 100%;
    max-width: 100%;
    max-height: 90vh;
    overflow-y: auto;
    animation: modalIn 0.2s ease-out;
}

@keyframes modalIn {
    from {
        opacity: 0;
        transform: scale(0.95) translateY(10px);
    }

    to {
        opacity: 1;
        transform: scale(1) translateY(0);
    }
}

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 24px 28px 0;
}

.modal-header h3 {
    font-size: var(--type-title);
    font-weight: var(--weight-semibold);
}

.modal-close {
    background: none;
    border: none;
    font-size: var(--type-title);
    cursor: pointer;
    color: var(--text-secondary);
    padding: 4px;
    line-height: 1;
    transition: color 0.2s;
    min-height: 44px;
    min-width: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
}

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

.modal-body {
    padding: 20px 28px 28px;
}

.modal-body .form-actions {
    margin-top: 20px;
}

/* Confirm modal */
.confirm-text {
    font-size: var(--type-body);
    line-height: var(--lh-body);
    margin-bottom: 4px;
}

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

/* ===== Toast ===== */
.toast-container {
    position: fixed;
    top: 16px;
    right: 16px;
    z-index: 300;
    display: flex;
    flex-direction: column;
    gap: 8px;
    pointer-events: none;
}

.toast {
    padding: 14px 24px;
    border-radius: var(--radius);
    font-size: var(--type-body);
    font-weight: var(--weight-medium);
    box-shadow: var(--shadow);
    pointer-events: auto;
    animation: toastIn 0.3s ease-out;
    transition: opacity 0.3s, transform 0.3s;
    max-width: 360px;
    line-height: var(--lh-snug);
}

.toast-success {
    background: var(--income);
    color: #fff;
}

.toast-error {
    background: var(--expense);
    color: #fff;
}

@keyframes toastIn {
    from {
        opacity: 0;
        transform: translateX(100%);
    }

    to {
        opacity: 1;
        transform: translateX(0);
    }
}

/* ===== Loading / error ===== */
.loading-message,
.error-message {
    text-align: center;
    padding: 40px 20px;
    color: var(--text-secondary);
    font-size: var(--type-body);
    line-height: var(--lh-body);
}

/* ===== Skeleton loading ===== */
.skeleton {
    background: linear-gradient(90deg, var(--border) 25%, var(--input-bg) 50%, var(--border) 75%);
    background-size: 200% 100%;
    animation: skeleton-shimmer 1.5s ease-in-out infinite;
    border-radius: var(--radius);
}

.skeleton-text {
    height: 1rem;
    width: 60%;
    margin: 8px 0;
}

.skeleton-text-sm {
    height: var(--type-caption);
    width: 40%;
    margin: 6px 0;
}

.skeleton-card {
    height: 80px;
    width: 100%;
}

.skeleton-chart {
    height: 200px;
    width: 100%;
}

@keyframes skeleton-shimmer {
    0% {
        background-position: -200% 0;
    }

    100% {
        background-position: 200% 0;
    }
}

.loading-spinner {
    display: inline-flex;
    align-items: center;
    gap: var(--space-sm);
}

.loading-spinner::before {
    content: '';
    display: inline-block;
    width: 18px;
    height: 18px;
    border: 2px solid var(--border);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 0.6s linear infinite;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

@keyframes cardEnter {
    from {
        opacity: 0;
        transform: translateY(12px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes fadeSlideIn {
    from {
        opacity: 0;
        transform: translateY(8px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.error-message {
    color: var(--expense);
}

.empty-state {
    text-align: center;
    padding: 40px 20px;
    color: var(--text-secondary);
    font-size: var(--type-body);
    font-style: italic;
    line-height: var(--lh-body);
}

/* ===== Dashboard charts (mobile-first: 1 column) ===== */
.dashboard-charts {
    display: grid;
    grid-template-columns: 1fr;
    gap: 20px;
    margin-bottom: 32px;
}

.chart-card {
    background: var(--card-bg);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 24px;
    transition: background 0.3s;
    overflow: hidden;
}

.chart-card-full {
    grid-column: 1 / -1;
}

.chart-title {
    font-size: var(--type-title);
    font-weight: var(--weight-semibold);
    margin-bottom: 20px;
    color: var(--text);
    text-align: center;
}

.chart-wrapper {
    position: relative;
    width: 100%;
    height: 100%;
    margin: 0 auto;
    overflow: hidden;
}

.chart-card-full .chart-wrapper {
    max-width: 100%;
}

.chart-header {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 14px;
    margin-bottom: 20px;
}

.chart-header--row {
    flex-direction: row;
    align-items: center;
}

.chart-header-label {
    font-size: var(--type-body);
    font-weight: var(--weight-semibold);
    color: var(--text);
    white-space: nowrap;
}

.chart-header select {
    padding: 6px 10px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--input-bg);
    color: var(--text);
    font-size: var(--type-label);
}

.chart-wrapper canvas {
    max-width: 100%;
    max-height: 220px;
}

/* ===== Filter controls (mobile-first: column) ===== */
.filter-controls {
    display: flex;
    flex-direction: column;
    gap: 14px;
    align-items: stretch;
}

.filter-controls label {
    font-size: var(--type-label);
    font-weight: var(--weight-semibold);
    color: var(--text-secondary);
    display: flex;
    align-items: center;
    gap: 6px;
    flex-wrap: wrap;
}

.filter-controls select,
.filter-controls input[type="month"] {
    padding: 8px 14px;
    border: 1.5px solid var(--primary);
    border-radius: var(--radius);
    background: var(--input-bg);
    color: var(--text);
    font-size: var(--type-label);
    font-weight: var(--weight-medium);
    cursor: pointer;
    transition: box-shadow 0.2s;
}

.filter-controls select:hover,
.filter-controls select:focus,
.filter-controls input[type="month"]:hover,
.filter-controls input[type="month"]:focus {
    box-shadow: var(--shadow-focus);
    outline: none;
}

/* ===== Filter section (marked card) ===== */
.filter-section {
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 14px;
    width: 100%;
}

/* ===== Section header row (mobile-first: column) ===== */
.section-header-row {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    flex-wrap: wrap;
    gap: 12px;
    margin-bottom: 24px;
}

.section-header-row .section-header {
    margin-bottom: 0;
}

/* ===== Comparison cards (prominent) ===== */
.comparison-cards {
    display: grid;
    grid-template-columns: 1fr;
    gap: 16px;
    margin-bottom: 32px;
}

.comparison-card {
    background: var(--card-bg);
    border-radius: var(--radius);
    padding: 16px 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    font-size: var(--type-label);
    color: var(--text);
    transition: background 0.3s,
        transform 0.2s ease-out,
        box-shadow 0.2s ease-out;
    border: 1px solid var(--border);
}

.comparison-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08),
        0 2px 4px rgba(0, 0, 0, 0.04);
}

.comparison-card#expenseComparisonCard {
    border-color: var(--expense);
}

.comparison-card#incomeComparisonCard {
    border-color: var(--income);
}

.comparison-content {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.comparison-period {
    display: block;
    font-size: var(--type-caption);
    font-weight: var(--weight-semibold);
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 2px;
}

.comparison-text {
    font-size: var(--type-label);
    font-weight: var(--weight-medium);
    color: var(--text);
    line-height: var(--lh-snug);
}

.comparison-icon {
    width: 48px;
    height: 48px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    flex-shrink: 0;
    font-size: 1.25rem;
}

.comparison-icon.income {
    background: var(--income-bg);
    color: var(--income);
}

.comparison-icon.expense {
    background: var(--expense-bg);
    color: var(--expense);
}

/* ===== Range checkboxes ===== */
.range-checkboxes {
    display: flex;
    gap: 8px;
}

.range-label {
    font-size: var(--type-label);
    font-weight: var(--weight-medium);
    display: flex;
    align-items: center;
    gap: 4px;
    cursor: pointer;
}

/* ===== Balance section (chart + table side by side) ===== */
.balance-section {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.monthly-summary-table {
    width: 100%;
}

.summary-mini-table {
    width: 100%;
    border-collapse: collapse;
    font-size: var(--type-caption);
}

.summary-mini-table th {
    text-align: left;
    padding: 5px 8px;
    border-bottom: 2px solid var(--border);
    color: var(--text-secondary);
    text-transform: uppercase;
    font-size: var(--type-caption);
    letter-spacing: 0.5px;
    font-weight: var(--weight-medium);
}

.summary-mini-table td {
    padding: 5px 8px;
    border-bottom: 1px solid var(--border);
    color: var(--text);
}

/* ===== Top expenses section ===== */
.top-expenses-section {
    display: grid;
    grid-template-columns: 1fr;
    gap: 20px;
}

.top-card {
    padding: 20px;
}

.top-card-period {
    display: block;
    font-size: var(--type-caption);
    font-weight: var(--weight-semibold);
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-top: -8px;
    margin-bottom: 8px;
}

.top-list {
    list-style: none;
    padding: 0;
    margin: 0;
}

.top-entry {
    display: flex;
    align-items: center;
    padding: 8px 0;
    border-bottom: 1px solid var(--border);
    font-size: var(--type-caption);
}

.top-entry:last-child {
    border-bottom: none;
}

.top-rank {
    color: var(--text-secondary);
    font-weight: var(--weight-bold);
    min-width: 20px;
    margin-right: 8px;
}

.top-name {
    flex: 1;
    font-weight: var(--weight-medium);
}

.top-amount {
    margin-right: 12px;
    font-weight: var(--weight-semibold);
    font-variant-numeric: tabular-nums;
}

.top-pct {
    color: var(--text-secondary);
    font-size: var(--type-label);
    min-width: 40px;
    text-align: right;
}

/* ===== Admin Hero Cards ===== */
.admin-hero-cards {
    display: grid;
    grid-template-columns: 1fr;
    gap: 12px;
    margin-bottom: 32px;
}

.admin-hero-card {
    background: var(--card-bg);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 20px 24px;
    text-align: center;
    transition: background 0.3s;
}

.admin-hero-label {
    display: block;
    font-size: var(--type-caption);
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 4px;
    font-weight: var(--weight-medium);
}

.admin-hero-value {
    display: block;
    font-size: 1.3rem;
    font-weight: var(--weight-bold);
    color: var(--text);
    line-height: var(--lh-tight);
    font-variant-numeric: tabular-nums;
}

.admin-hero-card.income .admin-hero-value {
    color: var(--income);
}

.admin-hero-card.expense .admin-hero-value {
    color: var(--expense);
}

/* ===== Admin Montos Section ===== */
.admin-montos-section {
    margin-bottom: 24px;
}

.admin-montos-header {
    display: flex;
    flex-direction: column;
    gap: 10px;
    align-items: center;
    margin-bottom: 16px;
}

.admin-montos-title {
    font-size: var(--type-title);
    font-weight: var(--weight-bold);
    color: var(--text);
    text-align: center;
}

.admin-montos-filter {
    display: flex;
    flex-direction: column;
    gap: 8px;
    align-items: center;
}

.admin-montos-filter label {
    font-size: var(--type-label);
    font-weight: var(--weight-semibold);
    color: var(--text-secondary);
    display: flex;
    align-items: center;
    gap: 4px;
}

.admin-montos-filter select {
    padding: 6px 10px;
    border: 1.5px solid var(--primary);
    border-radius: var(--radius);
    background: var(--input-bg);
    color: var(--text);
    font-size: var(--type-label);
    font-weight: var(--weight-medium);
    cursor: pointer;
    transition: box-shadow 0.2s;
}

.admin-montos-filter select:hover,
.admin-montos-filter select:focus {
    box-shadow: var(--shadow-focus);
    outline: none;
}

.admin-montos-filter .btn-primary {
    padding: var(--btn-sm);
    font-size: var(--type-label);
}

/* ===== Admin Dashboard Sections ===== */

.admin-section-criteria {
    font-size: var(--type-caption);
    font-style: italic;
    color: var(--text-secondary);
    margin-top: 2px;
    opacity: 0.8;
}

.admin-section-filters {
    display: flex;
    flex-direction: column;
    gap: 20px;
    align-items: stretch;
    margin-block: 1rem;
    padding: 16px;
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: var(--radius);
}

.admin-section-filters label {
    font-size: var(--type-label);
    font-weight: var(--weight-semibold);
    color: var(--text-secondary);
    display: grid;
    grid-template-columns: 90px 1fr;
    align-items: center;
    gap: 8px;
}

.admin-section-filters select,
.admin-section-filters input[type="month"] {
    flex: 1;
    min-width: 0;
    padding: 8px 10px;
    border: 1.5px solid var(--primary);
    border-radius: var(--radius);
    background: var(--input-bg);
    color: var(--text);
    font-size: var(--type-label);
    font-weight: var(--weight-medium);
    cursor: pointer;
    transition: box-shadow 0.2s;
}

.admin-section-filters select:hover,
.admin-section-filters select:focus,
.admin-section-filters input[type="month"]:hover,
.admin-section-filters input[type="month"]:focus {
    box-shadow: var(--shadow-focus);
    outline: none;
}

.admin-section-filters .btn-primary {
    padding: var(--btn-sm);
    font-size: var(--type-label);
    align-self: stretch;
    margin-top: 2px;
}

/* ===== Stat Cards with change indicator ===== */
.stat-cards {
    display: grid;
    grid-template-columns: 1fr;
    gap: 16px;
    margin-bottom: 20px;
}

.stat-card {
    background: var(--input-bg);
    border-radius: var(--radius);
    padding: 18px;
    text-align: center;
    transition: background 0.3s,
        transform 0.2s ease-out,
        box-shadow 0.2s ease-out;
}

.stat-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08),
        0 2px 4px rgba(0, 0, 0, 0.04);
}

.stat-card-label {
    display: block;
    font-size: var(--type-caption);
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 4px;
    font-weight: var(--weight-medium);
}

.stat-card-value {
    display: block;
    font-size: 1.5rem;
    font-weight: var(--weight-bold);
    color: var(--text);
    line-height: var(--lh-tight);
    font-variant-numeric: tabular-nums;
}

.stat-card-change {
    display: inline-flex;
    align-items: center;
    gap: 3px;
    font-size: var(--type-caption);
    font-weight: var(--weight-semibold);
    margin-top: 4px;
    padding: 2px 6px;
    border-radius: 10px;
}

.stat-card-change.up {
    color: var(--income);
    background: var(--income-bg);
}

.stat-card-change.down {
    color: var(--expense);
    background: var(--expense-bg);
}

.stat-card-change.neutral {
    color: var(--text-secondary);
    background: var(--border);
}

/* ===== Mini tables for top users ===== */
.mini-tables {
    display: grid;
    grid-template-columns: 1fr;
    gap: 20px;
}

.mini-table-card {
    background: var(--input-bg);
    border-radius: var(--radius);
    padding: 20px;
    overflow-x: auto;
    transition: transform 0.2s ease-out,
        box-shadow 0.2s ease-out;
}

.mini-table-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08),
        0 2px 4px rgba(0, 0, 0, 0.04);
}

.mini-table-card h4 {
    font-size: var(--type-title);
    font-weight: var(--weight-bold);
    color: var(--text);
    margin-bottom: 12px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

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

.mini-table th {
    text-align: left;
    padding: 4px 8px;
    font-size: var(--type-caption);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-secondary);
    border-bottom: 1px solid var(--border);
    font-weight: var(--weight-medium);
}

.mini-table td {
    padding: 5px 8px;
    font-size: var(--type-label);
    border-bottom: 1px solid var(--border);
    color: var(--text);
}

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

.mini-table .rank {
    font-weight: var(--weight-bold);
    color: var(--primary);
    width: 24px;
}

.mini-table .user-name {
    font-weight: var(--weight-medium);
}

.mini-table .user-value {
    font-weight: var(--weight-bold);
    text-align: right;
    white-space: nowrap;
    font-variant-numeric: tabular-nums;
}

/* ===== Activity distribution bars ===== */
.activity-bars {
    display: flex;
    flex-direction: column;
    gap: 12px;
    background: var(--input-bg);
    border-radius: var(--radius);
    padding: 18px;
}

.activity-row {
    display: grid;
    grid-template-columns: minmax(70px, 90px) 1fr minmax(35px, 45px) minmax(28px, 35px);
    gap: 8px;
    align-items: center;
}

.activity-label {
    font-size: var(--type-label);
    font-weight: var(--weight-semibold);
    color: var(--text);
}

.activity-bar {
    height: 24px;
    background: var(--border);
    border-radius: 10px;
    overflow: hidden;
    position: relative;
}

.activity-bar-fill {
    height: 100%;
    border-radius: 10px;
    transform-origin: left;
    transition: transform 0.5s ease;
    min-width: 2px;
}

.activity-bar-fill.frecuente {
    background: var(--primary);
}

.activity-bar-fill.regular {
    background: var(--income);
}

.activity-bar-fill.ocasional {
    background: var(--warning);
}

.activity-bar-fill.inactivo {
    background: var(--text-secondary);
}

.activity-percent {
    font-size: var(--type-title);
    font-weight: var(--weight-bold);
    color: var(--text);
    text-align: right;
}

.activity-count {
    font-size: var(--type-caption);
    color: var(--text-secondary);
    text-align: right;
}

.activity-legend {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-top: 16px;
    padding-top: 14px;
    border-top: 1px solid var(--border);
}

.activity-legend-item {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: var(--type-caption);
    color: var(--text-secondary);
}

.activity-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    flex-shrink: 0;
}

.activity-dot.frecuente {
    background: var(--primary);
}

.activity-dot.regular {
    background: var(--income);
}

.activity-dot.ocasional {
    background: var(--warning);
}

.activity-dot.inactivo {
    background: var(--text-secondary);
}

/* ===== Activity bars legend ===== */

/* ===== Floating Action Button — Transacciones (USER) ===== */
.fab-tx {
    position: fixed;
    bottom: 16px;
    left: 50%;
    right: auto;
    transform: translateX(-50%);
    height: 52px;
    padding: 0 22px;
    border-radius: 28px;
    background: transparent;
    color: var(--primary);
    font-size: var(--type-body);
    font-weight: var(--weight-semibold);
    display: inline-flex;
    align-items: center;
    gap: 8px;
    box-shadow: none;
    cursor: pointer;
    z-index: 50;
    transition: background 0.2s, color 0.2s, transform 0.2s, box-shadow 0.2s;
    border: 2px solid var(--primary);
    white-space: nowrap;
}

.fab-tx:hover {
    background: var(--primary);
    color: var(--on-primary);
    transform: translateX(-50%) scale(1.05);
    box-shadow: var(--shadow-fab-hover);
}

.fab-tx .fab-icon {
    font-size: var(--type-title);
}

.fab-tx .fab-label {
    line-height: 1;
    font-size: var(--type-caption);
}

.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

/* Page size selector */
.page-size-label {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: var(--type-caption);
    color: var(--text-secondary);
    margin: 10px 0;
}

.page-size-select {
    padding: 4px 8px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--bg);
    color: var(--text);
    font-size: var(--type-caption);
}

#txForm {
    display: grid;
    gap: 12px;
}

#catForm,
#subForm {
    display: grid;
    gap: 12px;
}

#subForm .form-group,
#catForm .form-group {
    gap: 12px;
}

@media (min-width: 401px) {
    .fab-tx {
        bottom: 30px;
        left: 50%;
        right: auto;
        background-color: rgba(0, 0, 0, 0.3);
        transform: translateX(-50%);
    }

    .fab-tx:hover {
        transform: translateX(-50%) scale(1.05);
    }
}

/* ===== Tablet: stat cards 2 cols ===== */
@media (min-width: 641px) {

    .admin-section-filters {
        flex-direction: column;
        align-items: center;
        flex-wrap: wrap;
    }

    .admin-section-filters label {
        display: flex;
    }

    .mini-tables {
        grid-template-columns: repeat(3, 1fr);
        gap: 20px;
    }

    .activity-row {
        grid-template-columns: 100px 1fr 50px 40px;
    }

    .admin-hero-cards {
        grid-template-columns: repeat(4, 1fr);
        gap: 16px;
    }

    .admin-montos-header {
        flex-direction: row;
        justify-content: space-between;
        align-items: center;
        gap: 16px;
    }

    .admin-montos-filter {
        flex-direction: row;
        flex-wrap: nowrap;
        align-items: center;
    }

    .tree-subcategory-item {
        padding-left: 48px;
    }

    .tree-subcategory-comment {
        white-space: normal;
    }

    .dash-main {
        padding: 18px;
    }

    .summary-cards {
        grid-template-columns: repeat(4, 1fr);
        gap: 20px;
    }

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

    .auth-card {
        padding: 44px;
    }

    .data-table th {
        padding: 14px 16px;
    }

    .data-table td {
        padding: 14px 16px;
    }

    .modal-overlay {
        align-items: center;
        padding: 24px;
    }

    .modal {
        max-width: 600px;
        border-radius: 12px;
    }

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

    .chart-wrapper canvas {
        max-height: 300px;
    }

    .chart-card-full .chart-wrapper canvas {
        max-height: 340px;
    }

    .section-header-row {
        flex-direction: row;
        align-items: center;
        justify-content: space-between;
    }

    .filter-section {
        width: auto;
        flex-shrink: 0;
        padding: 16px;
    }

    .filter-controls {
        flex-direction: row;
        align-items: center;
        flex-wrap: wrap;
    }

    .filter-controls label {
        flex-wrap: nowrap;
    }

    .range-checkboxes {
        flex-direction: row;
        gap: 10px;
    }

    .footer-inner {
        flex-direction: row;
        text-align: left;
        gap: 20px;
    }

    .footer-links {
        gap: 24px;
    }
}

/* ===== Small desktop: min-width 768px ===== */
@media (min-width: 768px) {
    .comparison-cards {
        grid-template-columns: 1fr 1fr;
        gap: 16px;
    }

    .top-expenses-section {
        grid-template-columns: 1fr 1fr;
        grid-column: 1 / -1;
        gap: 24px;
    }

    .stat-cards {
        grid-template-columns: repeat(2, 1fr);
        gap: 16px;
    }
}

@media (min-width: 1024px) {
    .fab-tx {
        display: none;
    }

    .admin-section-header {
        flex-direction: row;
        justify-content: space-between;
        align-items: flex-start;
    }

    #montosCards {
        grid-template-columns: repeat(3, 1fr);
    }

    .dash-header {
        padding: 6px 20px;
        display: grid;
        grid-template-columns: 1fr auto 1fr;
        align-items: center;
    }

    .header-logo {
        justify-self: start;
    }

    .header-nav {
        display: flex;
        justify-self: center;
    }

    .header-greeting {
        display: inline;
    }

    .header-right {
        justify-self: end;
    }

    .sidebar-toggle {
        display: none;
    }

    .theme-toggle {
        display: flex;
    }

    .dash-tabs {
        display: flex;
    }

    .dash-sidebar {
        display: none;
    }

    .sidebar-overlay {
        display: none !important;
    }

    .dash-body {
        padding-top: 0;
    }

    .dash-main {
        position: fixed;
        top: var(--header-height);
        left: 0;
        right: 0;
        bottom: var(--footer-height);
        overflow-y: auto;
        margin: 0 auto;
        padding: 28px 36px;
        z-index: 1;
        max-width: 90%;
    }

    .dash-footer {
        position: fixed;
        bottom: 0;
        left: 0;
        right: 0;
        z-index: 100;
        height: var(--footer-height);
    }

    .balance-section {
        flex-direction: row;
        align-items: start;
        gap: 48px;
    }

    .monthly-summary-table {
        min-width: 240px;
        max-width: 400px;
        flex-shrink: 0;
    }

    #monthlySummaryTable {
        font-size: var(--type-caption);
    }

    .chart-card-full .chart-wrapper {
        max-width: 60%;
    }

    .chart-wrapper {
        width: 100%;
        height: 100%;
    }

    div .activity-bars {
        width: 90%;
    }

    #sec6Cards {
        display: flex;
        gap: 28px;
        align-items: center;
    }

    #sec6Cards .activity-legend {
        margin-top: 0;
        padding-top: 0;
        border-top: none;
        border-left: 1px solid var(--border);
        padding-left: 20px;
    }

    .admin-section-filters {
        flex-direction: row;
        align-items: flex-end;
    }

    #section-mantenimiento {
        width: 80%;
        margin: 0 auto;
    }
}

/* ===== Reduced Motion ===== */
@media (prefers-reduced-motion: reduce) {

    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        scroll-behavior: auto !important;
    }

    /* Preserve transitions that communicate state changes */
    body,
    .dash-header,
    .dash-sidebar,
    .sidebar-overlay,
    .theme-toggle,
    .btn-primary,
    .btn-secondary,
    .btn-danger,
    .btn-icon,
    .btn-page,
    .btn-logout,
    .fab-tx,
    .modal,
    .summary-card,
    .stat-card,
    .mini-table-card,
    .comparison-card,
    .auth-card,
    .dash-tab-btn {
        transition-duration: 0.01ms !important;
    }
}