/* ─── Variables ──────────────────────────────────────────────────────────── */
:root {
    --bg: #0f1117;
    --surface: #1a1d27;
    --surface2: #22263a;
    --surface3: #2a2f47;
    --border: #2d3148;
    --accent: #388dc9;
    --accent2: #4ecdc4;
    --text: #e8eaf6;
    --text2: #9198b5;
    --text3: #5a6080;
    --text-muted: var(--text3);
    --danger: #ff5c5c;
    --warning: #ffb347;
    --success: #4caf50;
    --income: #4ecdc4;
    --expense: #ff6b6b;
    --transfer: #6c63ff;

    --icon-size: 16px;
    --icon-size-s: 12px;
    --radius: 10px;
    --radius-sm: 6px;
    --shadow: 0 4px 24px rgba(0, 0, 0, .4);
    --transition: .18s ease;
    --scrollbar-track: rgba(255, 255, 255, 0.06);
    --scrollbar-thumb: color-mix(in srgb, var(--surface3) 78%, #ffffff 22%);
    --scrollbar-thumb-hover: color-mix(in srgb, var(--surface3) 62%, #ffffff 38%);
    --scrollbar-size: 11px;

    --sidebar-w: 220px;
    --balance-bar-h: 0px;
    --tx-filters-h: 0px;
    --topbar-h: 56px;
}

:root[data-theme="light"] {
    --bg: #f6f7fb;
    --surface: #ffffff;
    --surface2: #eef2f8;
    --surface3: #e3e9f3;
    --border: #d6deeb;
    --accent: #2474b5;
    --accent2: #1b9d8f;
    --text: #182033;
    --text2: #54627d;
    --text3: #8c98af;
    --text-muted: var(--text3);
    --shadow: 0 10px 35px rgba(15, 23, 42, .08);
}

ul.list {
    padding-left: 30px;
}

details > summary {
    cursor: pointer;
}

details > summary:hover {
    color: var(--accent);
}

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

html {
    font-size: 15px;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.5;
    min-height: 100vh;
    scrollbar-width: thin;
    scrollbar-color: var(--scrollbar-thumb) var(--scrollbar-track);
}

body.app-booting {
    overflow: hidden;
}

.app-boot-overlay {
    position: fixed;
    inset: 0;
    z-index: 9999;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
    background:
        radial-gradient(circle at top, rgba(56, 141, 201, 0.16), transparent 34%),
        linear-gradient(180deg, rgba(15, 17, 23, 0.98), rgba(11, 13, 19, 0.995));
    transition: opacity .2s ease, transform .2s ease;
}

.app-boot-overlay.is-hidden {
    opacity: 0;
    pointer-events: none;
    transform: scale(0.992);
}

.app-boot-card {
    width: min(420px, 100%);
    padding: 24px;
    border-radius: 18px;
    border: 1px solid rgba(255, 255, 255, 0.08);
    background: color-mix(in srgb, var(--surface) 88%, transparent);
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.42);
    backdrop-filter: blur(16px);
}

.app-boot-label {
    font-size: 12px;
    font-weight: 700;
    letter-spacing: .14em;
    text-transform: uppercase;
    color: var(--text2);
    margin-bottom: 8px;
}

.app-boot-title {
    font-size: 22px;
    font-weight: 700;
    line-height: 1.2;
    margin-bottom: 16px;
}

.app-boot-row {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 12px;
}

.app-boot-spinner {
    width: 14px;
    height: 14px;
    border-radius: 50%;
    border: 2px solid rgba(255, 255, 255, 0.2);
    border-top-color: var(--accent2);
    animation: appBootSpin .85s linear infinite;
}

.app-boot-seconds {
    font-size: 18px;
    font-weight: 700;
    color: var(--text);
}

.app-boot-note {
    margin-bottom: 16px;
    color: var(--text2);
}

.app-boot-reload {
    width: 100%;
}

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

body.ui-compact .main-content {
    padding: 16px;
}

body.ui-compact .card {
    padding: 16px;
}

body.ui-compact .card-header {
    margin-bottom: 12px;
}

body.ui-compact td {
    padding-top: 6px;
    padding-bottom: 6px;
}

body.ui-compact .balance-card {
    padding: 10px 12px;
}

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

a:hover {
    color: var(--accent2);
}

img {
    max-width: 100%;
}

button {
    cursor: pointer;
    font-family: inherit;
}

* {
    scrollbar-width: thin;
    scrollbar-color: var(--scrollbar-thumb) var(--scrollbar-track);
}

*::-webkit-scrollbar {
    width: var(--scrollbar-size);
    height: var(--scrollbar-size);
}

*::-webkit-scrollbar-track {
    background: var(--scrollbar-track);
    border-radius: 999px;
}

*::-webkit-scrollbar-thumb {
    background: var(--scrollbar-thumb);
    border: 2px solid var(--scrollbar-track);
    border-radius: 999px;
}

*::-webkit-scrollbar-thumb:hover {
    background: var(--scrollbar-thumb-hover);
}

*::-webkit-scrollbar-corner {
    background: var(--scrollbar-track);
}

/* ─── Icons ──────────────────────────────────────────────────────────────── */
.icon {
    display: inline-block;
    vertical-align: middle;
    flex-shrink: 0;
    color: inherit;
    stroke-width: var(--icon-stroke-width, 1.5);
    width: var(--icon-size, 24px);
    height: var(--icon-size, 24px);
}

.icon path,
.icon use {
    stroke: currentColor;
    stroke-width: var(--icon-stroke-width, 1.5);
    fill: none;
}

.icon path[stroke="none"] {
    stroke: none;
}

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

.icon--muted {
    color: var(--text3);
}

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

.icons-browser-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px;
    background: var(--surface2);
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
}

.icons-browser-icon svg {
    width: 24px;
    height: 24px;
    stroke: currentColor;
}

.icons-browser-name {
    font-size: .95rem;
    word-break: break-all;
}

.icons-browser-empty {
    color: var(--text3);
}

/* ─── App shell layout ───────────────────────────────────────────────────── */
.app-shell {
    display: flex;
    min-height: 100vh;
}

.main-wrap {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-width: 0;
    margin-left: var(--sidebar-w);
    transition: margin var(--transition), width var(--transition);
}

.sidebar-collapsed .main-wrap {
    margin-left: 0;
}

.main-content {
    flex: 1;
    padding: 24px 24px 70px 24px;
    /*max-width: 1200px;*/
    width: 100%;
    margin: 0 auto;
}

/* ─── Sidebar ────────────────────────────────────────────────────────────── */
.sidebar {
    position: fixed;
    top: 0;
    left: 0;
    width: var(--sidebar-w);
    height: 100vh;
    background: var(--surface);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    z-index: 100;
    transition: transform var(--transition), width var(--transition), opacity var(--transition);
}

.sidebar-collapsed .sidebar {
    transform: translateX(-100%);
    opacity: 0;
    pointer-events: none;
}

.sidebar-logo {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 16px 15px 16px;
    border-bottom: 1px solid var(--border);
}

.logo-link {
    display: flex;
    align-items: center;
    gap: 10px;
    flex: 1;
    min-width: 0;
    color: var(--text);
}

.logo-link:hover {
    color: var(--text);
    opacity: .9;
}

.logo-img {
    height: 28px;
    width: auto;
    display: block;
}

.logo-img-light {
    display: none;
}

:root[data-theme="light"] .logo-img-dark {
    display: none;
}

:root[data-theme="light"] .logo-img-light {
    display: block;
}

.nav-list {
    list-style: none;
    padding: 12px 8px;
    flex: 1;
    overflow-y: auto;
}

.nav-item {
    margin-bottom: 2px;
}

.nav-link {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 9px 12px;
    border-radius: var(--radius-sm);
    color: var(--text2);
    font-size: .9rem;
    transition: background var(--transition), color var(--transition);
}

.nav-link:hover {
    background: var(--surface2);
    color: var(--text);
}

.nav-item.active .nav-link {
    background: var(--surface3);
    color: var(--accent);
    font-weight: 600;
}

.nav-icon {
    font-size: 1rem;
    width: 20px;
    text-align: center;
    flex-shrink: 0;
}

#icon_Settings {
    font-size: 2rem;
    line-height: .1;
}

/* Submenu */
.nav-group-toggle {
    cursor: pointer;
    justify-content: space-between;
    position: relative;
}

.nav-group-toggle:hover {
    background: var(--surface2);
    color: var(--text);
}

.nav-chevron {
    font-size: .75rem;
    color: var(--text3);
    transition: transform var(--transition);
    margin-left: auto;
}

.nav-group-toggle.expanded .nav-chevron {
    transform: rotate(90deg);
}

.nav-sublist {
    list-style: none;
    padding: 6px 6px 6px 36px;
    background: rgba(255, 255, 255, 0.03);
    border-radius: var(--radius-sm);
    display: flex;
    flex-direction: column;
    gap: 2px;
    margin-bottom: 6px;
    overflow: hidden;
    max-height: 500px;
    transition: max-height var(--transition), padding var(--transition), margin var(--transition), opacity var(--transition);
}

.nav-sublist.collapsed {
    max-height: 0;
    padding-top: 0;
    padding-bottom: 0;
    margin-bottom: 0;
    opacity: 0;
    pointer-events: none;
}

.nav-subitem .sub-link {
    display: block;
    padding: 6px 12px;
    border-radius: var(--radius-sm);
    color: var(--text2);
    font-size: .85rem;
    transition: background var(--transition), color var(--transition);
}

.nav-subitem .sub-link:hover {
    color: var(--text);
    background: var(--surface2);
}

.nav-subitem.active .sub-link {
    color: var(--accent);
    font-weight: 600;
    background: var(--surface3);
}

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

.nav-logout {
    color: var(--text3);
}

.nav-logout:hover {
    color: var(--danger);
    background: rgba(255, 92, 92, .08);
}

.nav-install {
    color: var(--text3);
    font-size: .85rem;
}

.nav-install:hover {
    color: var(--warning);
    background: rgba(255, 179, 71, .08);
}

.sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, .5);
    z-index: 99;
}

/* ─── Topbar ─────────────────────────────────────────────────────────────── */
.topbar {
    height: var(--topbar-h);
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    padding: 0 20px;
    gap: 12px;
    position: sticky;
    top: 0;
    z-index: 50;
}

.topbar-title {
    flex: 1;
    font-size: 1rem;
    font-weight: 600;
    color: var(--text2);
}

.topbar-right {
    display: flex;
    align-items: center;
    gap: 10px;
}

.topbar-user-wrap {
    display: flex;
    align-items: center;
    gap: 8px;
    text-decoration: none;
    border-radius: 24px;
    padding: 3px 3px 3px 3px;
    background: none;
    transition: background var(--transition);
    border: 0;
}

.topbar-user-wrap:hover {
    background: var(--surface2);
}

.topbar-user {
    font-size: .8rem;
    color: var(--text3);
    padding: 2px 8px 2px 2px;
}

.topbar-user-meta {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    line-height: 1.1;
}

.topbar-conn-status {
    font-size: .7rem;
    color: var(--text2);
    padding-left: 2px;
}

.topbar-conn-status.online {
    color: #8be4a6;
}

.topbar-conn-status.offline {
    color: #ff9faa;
}

/* ── Small avatar in topbar ─────────────────────────────────────────────── */
.topbar-avatar {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: var(--accent);
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    flex-shrink: 0;
}

.topbar-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.topbar-avatar-initials {
    font-size: .7rem;
    font-weight: 700;
    color: #fff;
    line-height: 1;
    text-transform: uppercase;
}

@media (max-width: 480px) {
    .topbar {
        width: 100%;
        max-width: 100%;
        box-sizing: border-box;
    }
}

.budget-calendar-card-body {
    padding: 0 !important;
}

#budgetCalendarAnalyticsWrap {
    max-width: 900px;
    margin: 20px auto;
}

#budgetCalendarMonth {
    max-width: 140px;
}

@media (max-width: 750px) {
    .budget-calendar-toolbar {
        grid-template-columns: 1fr auto;
        grid-template-areas:
      "nav title"
      "go go";
        justify-items: stretch;
        align-items: center;
    }

    .budget-calendar-toolbar-nav {
        grid-area: nav;
        justify-content: flex-start;
    }

    .budget-calendar-toolbar .card-title {
        grid-area: title;
        min-width: 0;
        text-align: right !important;
    }

    .budget-calendar-toolbar-go {
        grid-area: go;
        flex-wrap: wrap;
        justify-content: flex-start;
        margin-top: 4px;
    }

    .budget-calendar-toolbar-go > * {
        min-width: 0;
    }

    #budgetCalendarMonth {
        min-width: 0 !important;
        width: 100%;
        flex: 1 1 160px;
    }

    .budget-calendar-grid {
        grid-template-columns: repeat(7, minmax(120px, 1fr));
        min-width: 920px;
    }

    .budget-calendar-weekday {
        display: block;
    }

    .budget-calendar-day {
        min-height: 0;
    }
}

/* ── User Dropdown ──────────────────────────────────────────────────────────── */
.user-dropdown {
    position: absolute;
    top: calc(100% + 8px);
    right: 0;
    width: 220px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    box-shadow: var(--shadow);
    padding: 8px 0;
    opacity: 0;
    visibility: hidden;
    transform: translateY(-10px);
    transition: opacity var(--transition), transform var(--transition), visibility var(--transition);
    z-index: 100;
}

.user-dropdown.show {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

.dropdown-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 16px;
    color: var(--text2);
    font-size: .9rem;
    text-decoration: none;
    transition: background var(--transition), color var(--transition);
}

.dropdown-item:hover {
    background: var(--surface2);
    color: var(--text);
}

.dropdown-icon {
    font-size: 1.1rem;
    width: 24px;
    text-align: center;
}

.dropdown-divider {
    height: 1px;
    background: var(--border);
    margin: 6px 0;
}

/* ─── DB status badge in topbar ──────────────────────────────────────────── */
.db-status-badge {
    display: flex;
    align-items: center;
    gap: 5px;
    font-size: .75rem;
    font-weight: 600;
    padding: 4px 10px;
    border-radius: 20px;
    text-decoration: none;
    transition: opacity var(--transition);
}

.db-status-badge:hover {
    opacity: .8;
}

.db-status-no-db {
    background: rgba(255, 92, 92, .15);
    color: var(--danger);
    border: 1px solid rgba(255, 92, 92, .3);
}

.db-status-missing-tables {
    background: rgba(255, 179, 71, .15);
    color: var(--warning);
    border: 1px solid rgba(255, 179, 71, .3);
}

/* ─── Tax XN notification badge (topbar) ─────────────────────────────────── */
.tax-xn-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 20px;
    height: 20px;
    padding: 0 5px;
    border-radius: 10px;
    background: var(--danger);
    color: #fff;
    font-size: .7rem;
    font-weight: 700;
    line-height: 1;
    text-decoration: none;
    cursor: pointer;
    animation: badgePulse 2s ease-in-out infinite;
}

@keyframes badgePulse {
    0%, 100% {
        box-shadow: 0 0 0 0 rgba(255, 92, 92, .4);
    }
    50% {
        box-shadow: 0 0 0 4px rgba(255, 92, 92, 0);
    }
}

.burger {
    display: flex;
    flex-direction: column;
    gap: 4px;
    background: none;
    border: none;
    padding: 4px;
}

.burger span {
    display: block;
    width: 22px;
    height: 2px;
    background: var(--text2);
    border-radius: 2px;
    transition: var(--transition);
}

/* ─── Auth shell ─────────────────────────────────────────────────────────── */
.auth-shell {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    background: radial-gradient(ellipse at 60% 40%, #1a1d3a 0%, var(--bg) 70%);
}

.auth-card {
    width: 100%;
    max-width: 380px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 40px 36px;
    box-shadow: var(--shadow);
}

.auth-brand {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
    margin-bottom: 18px;
}

.auth-logo {
    display: block;
    width: auto;
    max-width: 220px;
    height: 42px;
    object-fit: contain;
}

.auth-version {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 4px 10px;
    border-radius: 999px;
    border: 1px solid var(--border);
    background: var(--surface2);
    color: var(--text2);
    font-size: .72rem;
    font-weight: 700;
    letter-spacing: .04em;
}

.auth-updated {
    margin-top: -4px;
    color: var(--text3);
    font-size: .72rem;
    letter-spacing: .03em;
}

.auth-card h1 {
    font-size: 1.5rem;
    margin-bottom: 4px;
    font-weight: 700;
    text-align: center;
}

.auth-card .subtitle {
    color: var(--text2);
    font-size: .85rem;
    margin-bottom: 28px;
    text-align: center;
}

.auth-flow {
    margin-top: 22px;
    padding: 16px;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
}

.auth-flow-title {
    font-size: .72rem;
    font-weight: 700;
    letter-spacing: .08em;
    text-transform: uppercase;
    color: var(--text3);
}

.auth-flow-summary {
    margin-top: 8px;
    font-size: .84rem;
    color: var(--text2);
}

.auth-flow-summary[data-tone="success"] {
    color: var(--success);
}

.auth-flow-summary[data-tone="error"] {
    color: var(--danger);
}

.auth-flow-summary[data-tone="info"] {
    color: var(--text2);
}

.auth-flow-steps {
    list-style: none;
    margin: 14px 0 0;
    padding: 0;
}

.auth-flow-empty {
    color: var(--text3);
    font-size: .8rem;
}

.auth-flow-step {
    padding-top: 10px;
    margin-top: 10px;
    border-top: 1px solid var(--border);
}

.auth-flow-step-toggle {
    width: 100%;
    display: grid;
    grid-template-columns: 10px minmax(0, 1fr) auto auto;
    gap: 10px;
    align-items: start;
    padding: 0;
    border: 0;
    background: transparent;
    color: inherit;
    text-align: left;
    cursor: pointer;
}

.auth-flow-step-toggle-static {
    cursor: default;
}

.auth-flow-step-toggle:focus-visible {
    outline: 1px solid var(--accent);
    outline-offset: 4px;
    border-radius: var(--radius-sm);
}

.auth-flow-step-dot {
    width: 10px;
    height: 10px;
    border-radius: 999px;
    margin-top: 4px;
    background: var(--text3);
}

.auth-flow-step-info .auth-flow-step-dot {
    background: var(--accent);
}

.auth-flow-step-pending .auth-flow-step-dot {
    background: var(--warning);
}

.auth-flow-step-success .auth-flow-step-dot {
    background: var(--success);
}

.auth-flow-step-error .auth-flow-step-dot {
    background: var(--danger);
}

.auth-flow-step-title {
    font-size: .83rem;
    font-weight: 600;
    color: var(--text);
}

.auth-flow-step-chevron {
    min-width: 36px;
    font-size: .72rem;
    color: var(--text3);
    text-align: right;
}

.auth-flow-step-detail {
    margin: 8px 0 0 20px;
    font-size: .78rem;
    line-height: 1.45;
    color: var(--text2);
    white-space: pre-wrap;
    word-break: break-word;
}

.auth-flow-step-time {
    font-size: .72rem;
    color: var(--text3);
    white-space: nowrap;
}

.auth-flow-debug {
    margin-top: 14px;
    border-top: 1px solid var(--border);
    padding-top: 12px;
}

.auth-flow-debug > summary {
    cursor: pointer;
    font-size: .78rem;
    color: var(--text2);
    user-select: none;
}

.auth-flow-debug[open] > summary {
    margin-bottom: 10px;
}

.auth-flow-details {
    margin: 0;
    padding: 12px;
    background: var(--surface2);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: .74rem;
    line-height: 1.45;
    color: var(--text2);
    white-space: pre-wrap;
    word-break: break-word;
    max-height: 220px;
    overflow: auto;
}

/* ─── Status colors (tests) ─────────────────────────────────────────────── */
.success {
    color: var(--success);
}

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

.error {
    color: var(--danger);
}

/* ─── System Tests responsive ───────────────────────────────────────────── */
.tests-page {
    --tests-sticky-h: 0px;
}

.tests-page .tests-sticky-toolbar {
    position: sticky;
    top: var(--topbar-h);
    z-index: 45;
    padding-bottom: 12px;
}

.tests-page .tests-toolbar-card {
    margin-bottom: 0;
}

.tests-page .tests-table-card {
    position: relative;
    z-index: 1;
}

.tests-page .tests-snapshots-card {
    position: relative;
    z-index: 1;
}

.tests-page #testsTable {
    border-collapse: separate;
    border-spacing: 0;
}

.tests-page #snapshotsTable {
    border-collapse: separate;
    border-spacing: 0;
}

.tests-page #testsTable thead th {
    background: var(--surface);
    box-shadow: inset 0 -1px 0 var(--border);
}

.tests-page #snapshotsTable thead th {
    background: var(--surface);
    box-shadow: inset 0 -1px 0 var(--border);
}

.tests-page .card-header {
    gap: 12px;
}

.tests-page .card-header .card-title {
    margin-bottom: 4px;
}

.tests-page .tests-cli-subtitle {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 6px;
}

.tests-page .tests-cli-command-row {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
    max-width: 100%;
}

.tests-page .tests-cli-command {
    display: inline-block;
    max-width: 100%;
    padding: 6px 10px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--surface2);
    color: var(--text);
    font-size: .85rem;
    overflow-wrap: anywhere;
}

.tests-page .tests-cli-copy-btn {
    flex: 0 0 auto;
}

.snapshot-toolbar {
    display: flex;
    align-items: center;
    gap: 16px;
    flex-wrap: wrap;
}

.snapshot-toolbar .form-group {
    min-width: 220px;
}

.snapshot-toolbar-actions {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    padding-top: 8px;
}

.snapshot-row-actions {
    display: inline-flex;
    gap: 8px;
    justify-content: flex-end;
}

.snapshot-date-cell-link {
    display: block;
    color: inherit;
    text-decoration: none;
}

.snapshot-date-link {
    color: inherit;
    font-weight: 700;
    text-decoration: underline;
    text-decoration-color: var(--border);
    text-underline-offset: 2px;
}

.snapshot-date-cell-link:hover .snapshot-date-link {
    color: var(--accent);
    text-decoration-color: var(--accent);
}

.snapshot-view-wrap {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.snapshot-detail-header {
    display: flex;
    flex-direction: column;
    gap: 4px;
    margin-bottom: 16px;
}

.snapshot-view-head {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.snapshot-view-date {
    font-size: 1.2rem;
    font-weight: 700;
}

.snapshot-view-summary {
    display: flex;
    justify-content: flex-end;
}

.snapshot-view-total {
    font-size: .95rem;
    font-weight: 700;
}

.snapshot-diff-card {
    padding: 14px 16px;
    border: 1px solid rgba(215, 78, 78, .28);
    border-radius: var(--radius);
    background: rgba(215, 78, 78, .08);
}

.snapshot-diff-card-warning {
    border-color: rgba(255, 179, 71, .28);
    background: rgba(255, 179, 71, .08);
}

.snapshot-diff-title {
    font-weight: 700;
    color: var(--danger);
}

.snapshot-diff-card-warning .snapshot-diff-title {
    color: var(--warning);
}

.snapshot-diff-meta {
    margin-top: 4px;
}

.snapshot-history-modal {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.snapshot-history-entry {
    padding: 12px 14px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--surface2);
}

.snapshot-history-entry-clickable {
    cursor: pointer;
    transition: border-color var(--transition), background var(--transition);
}

.snapshot-history-entry-clickable:hover,
.snapshot-history-entry-clickable:focus {
    border-color: var(--accent);
    background: var(--surface);
    outline: none;
}

.snapshot-history-head {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    margin-bottom: 4px;
}

.snapshot-history-date {
    font-weight: 700;
}

.snapshot-history-meta {
    line-height: 1.5;
}

.snapshot-history-diff-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.snapshot-history-diff-item {
    padding: 10px 12px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--surface);
}

.snapshot-accounts-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
    gap: 14px;
}

@media (max-width: 520px) {
    .tests-page .tests-sticky-toolbar {
        padding-bottom: 10px;
    }

    .tests-page .card-header {
        flex-direction: column;
        align-items: flex-start;
    }

    .tests-page .card-header .flex-gap-8 {
        width: 100%;
        display: flex;
        gap: 8px;
    }

    .tests-page .card-header .btn {
        flex: 1;
    }

    .tests-page .tests-cli-command-row .btn {
        flex: 0 0 auto;
    }

    .tests-page .table-wrap {
        overflow-x: visible;
    }

    .tests-page #testsTable td[data-label="Runtime"] {
        text-align: left;
        justify-content: flex-start;
    }

    .tests-page #snapshotsTable td[data-label="Total"],
    .tests-page #snapshotsTable td[data-label="Actions"] {
        text-align: left;
        justify-content: flex-start;
    }

    .snapshot-toolbar {
        align-items: stretch;
    }

    .snapshot-toolbar .form-group,
    .snapshot-toolbar-actions {
        width: 100%;
    }

    .snapshot-row-actions {
        width: 100%;
        justify-content: flex-start;
    }

    .snapshot-row-actions .btn,
    .snapshot-toolbar-actions .btn {
        flex: 1;
    }

    .snapshot-accounts-grid {
        grid-template-columns: 1fr;
    }
}

.summary-badges {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.badge-pill {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 10px;
    border-radius: 999px;
    font-size: 0.85rem;
    background: var(--surface2);
    border: 1px solid var(--border);
    cursor: pointer;
    color: var(--text3);
}

.badge-pill.active {
    border-color: var(--accent);
    box-shadow: 0 0 0 1px var(--accent);
}

.badge-pill.success {
    color: var(--success);
}

.badge-pill.warning {
    color: var(--warning);
}

.badge-pill.error {
    color: var(--danger);
}

/* ─── Forms ──────────────────────────────────────────────────────────────── */
.form-group {
    margin-bottom: 16px;
    position: relative;
}

.form-group label {
    display: block;
    font-size: .8rem;
    font-weight: 600;
    color: var(--text2);
    margin-bottom: 6px;
    text-transform: uppercase;
    letter-spacing: .04em;
}

.form-label {
    display: block;
    font-size: .8rem;
    font-weight: 600;
    color: var(--text2);
    margin-bottom: 6px;
    text-transform: uppercase;
    letter-spacing: .04em;
}

.form-control {
    width: 100%;
    padding: 4px 5px;
    background: var(--surface2);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text);
    font-size: .9rem;
    font-family: inherit;
    transition: border-color var(--transition), box-shadow var(--transition);
    outline: none;
}

.form-control:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(108, 99, 255, .15);
}

input.form-control[type="date"] {
    display: block;
    /*width: 100%;*/
    min-width: 0;
    -webkit-min-logical-width: 0;
    box-sizing: border-box;
    min-height: 31px;
    line-height: 1.2;
    text-align: left;
    -webkit-appearance: none;
    appearance: none;
}

input.form-control[type="date"]::-webkit-date-and-time-value {
    min-height: 1.2em;
    text-align: left;
}

input.form-control[type="date"]::-webkit-calendar-picker-indicator {
    opacity: .9;
}

select.form-control {
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%239198b5' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M6 9l6 6l6-6'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 6px center;
    padding-right: 28px;
}

.form-error {
    font-size: .8rem;
    color: var(--danger);
    margin-top: 4px;
}

.form-row {
    display: flex;
    gap: 12px;
}

.form-row .form-group {
    flex: 1;
}

.settings-check-stack {
    display: flex;
    flex-direction: column;
}

.form-check {
    position: relative;
    display: flex;
    align-items: flex-start;
    gap: 12px;
    padding: 14px 16px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--surface);
    cursor: pointer;
    transition: border-color var(--transition), background var(--transition);
}

.form-check:hover {
    border-color: var(--accent);
    background: rgba(56, 141, 201, .06);
}

.form-check-input {
    flex-shrink: 0;
    width: 16px;
    height: 16px;
    margin-top: 2px;
    accent-color: var(--accent);
}

.form-check-label {
    font-size: .95rem;
    font-weight: 600;
    line-height: 1.45;
}

.card-body.analytics-menu-mini {
    padding: 0;
}

.analytics-menu-mini-list {
    border: 1px solid var(--surface2);
    padding: 15px 15px;
    border-radius: var(--radius);
}

.assistant-rights-grid {
    display: grid;
    grid-template-columns: minmax(0, 1.3fr) minmax(280px, 0.8fr);
    gap: 24px;
    align-items: start;
}

.assistant-rights-column {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.assistant-rights-title {
    font-size: .95rem;
    font-weight: 700;
    letter-spacing: .02em;
    text-transform: uppercase;
    color: var(--text3);
}

.assistant-rights-column .assistant-analyst-settings {
    height: 100%;
}

label.form-check.analytics-menu-mini-item {
    border: none;
    padding: 4px 0;
}

.analytics-menu-mini-handle {
    cursor: grab;
    color: var(--text3);
    padding: 0 4px 0 0;
    user-select: none;
}

.analytics-menu-mini-handle:active {
    cursor: grabbing;
}

.analytics-menu-mini-item.analytics-menu-mini-dragging {
    opacity: .55;
}

.analytics-menu-mini-item.analytics-menu-mini-drop-target {
    outline: 1px dashed var(--accent);
    outline-offset: 4px;
}

.form-check-label-inline {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    flex-wrap: nowrap;
    min-width: 0;
}

.form-check-inline-number {
    width: 60px;
    min-width: 60px;
    padding: 4px 8px;
    text-align: center;
    flex: 0 0 auto;
}

@media (max-width: 760px) {
    .form-check-label-inline {
        flex-wrap: wrap;
    }

    .assistant-rights-grid {
        grid-template-columns: 1fr;
    }
}

.theme-switcher {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 16px;
}

.theme-option {
    position: relative;
    display: block;
    cursor: pointer;
}

.theme-option > input {
    position: absolute;
    opacity: 0;
    pointer-events: none;
}

.theme-box {
    display: flex;
    flex-direction: column;
    gap: 14px;
    min-height: 164px;
    padding: 16px;
    border: 1px solid var(--border);
    border-radius: 14px;
    background: var(--surface2);
    transition: transform var(--transition), border-color var(--transition), box-shadow var(--transition);
}

.theme-option:hover .theme-box {
    border-color: var(--accent);
    transform: translateY(-1px);
}

.theme-option > input:checked + .theme-box {
    border-color: var(--accent);
    box-shadow: 0 0 0 1px var(--accent), 0 10px 24px rgba(56, 141, 201, .14);
}

.theme-option > input:focus-visible + .theme-box {
    box-shadow: 0 0 0 3px rgba(56, 141, 201, .2);
}

.theme-preview {
    display: grid;
    grid-template-columns: 34% 1fr;
    gap: 10px;
    height: 92px;
    padding: 10px;
    border-radius: 12px;
    border: 1px solid rgba(255, 255, 255, .08);
    overflow: hidden;
}

.preview-sidebar,
.preview-header,
.preview-card {
    border-radius: 8px;
}

.preview-content {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.preview-header {
    height: 12px;
    width: 70%;
}

.preview-card {
    flex: 1;
}

.theme-light .theme-preview {
    background: linear-gradient(135deg, #f8faff 0%, #eef3fb 100%);
    border-color: rgba(36, 116, 181, .12);
}

.theme-light .preview-sidebar {
    background: #dce5f4;
}

.theme-light .preview-header {
    background: #c5d3e8;
}

.theme-light .preview-card {
    background: #ffffff;
    box-shadow: inset 0 0 0 1px rgba(24, 32, 51, .06);
}

.theme-dark .theme-preview {
    background: linear-gradient(135deg, #10131b 0%, #1f2435 100%);
}

.theme-dark .preview-sidebar {
    background: #171b27;
}

.theme-dark .preview-header {
    background: #3b4564;
}

.theme-dark .preview-card {
    background: #262d41;
}

.theme-auto .theme-preview {
    background: linear-gradient(115deg, #f8faff 0%, #eef3fb 48%, #171b27 52%, #252d42 100%);
    border-color: rgba(36, 116, 181, .12);
}

.theme-auto .preview-sidebar {
    background: linear-gradient(180deg, #dce5f4 0%, #dce5f4 48%, #171b27 52%, #171b27 100%);
}

.theme-auto .preview-header {
    background: linear-gradient(90deg, #c5d3e8 0%, #c5d3e8 48%, #3b4564 52%, #3b4564 100%);
}

.theme-auto .preview-card {
    background: linear-gradient(115deg, #ffffff 0%, #ffffff 48%, #262d41 52%, #262d41 100%);
}

.theme-label {
    font-size: .95rem;
    font-weight: 700;
}

@media (max-width: 700px) {
    .theme-switcher {
        grid-template-columns: 1fr;
        gap: 12px;
    }

    .theme-box {
        min-height: 0;
        flex-direction: row;
        align-items: center;
        gap: 12px;
        padding: 12px 14px;
    }

    .theme-preview {
        grid-template-columns: 32% 1fr;
        width: 108px;
        min-width: 108px;
        height: 62px;
        padding: 7px;
        gap: 7px;
        border-radius: 10px;
    }

    .preview-sidebar,
    .preview-header,
    .preview-card {
        border-radius: 6px;
    }

    .preview-content {
        gap: 7px;
    }

    .preview-header {
        height: 9px;
    }

    .theme-label {
        margin: 0;
        line-height: 1.2;
        white-space: nowrap;
    }
}

/* ─── Buttons ────────────────────────────────────────────────────────────── */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 9px 18px;
    border-radius: var(--radius-sm);
    font-size: .88rem;
    font-weight: 600;
    border: 1px solid transparent;
    transition: background var(--transition), transform .1s, box-shadow var(--transition);
    outline: none;
    white-space: nowrap;
    background: var(--surface2);
}

.btn:active {
    transform: scale(.97);
}

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

.btn-primary:hover {
    background: #7c74ff;
    box-shadow: 0 4px 16px rgba(108, 99, 255, .35);
}

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

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

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

.btn-danger:hover {
    background: rgba(255, 92, 92, .1);
}

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

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

.btn-ss {
    padding: 0 10px;
    font-size: .8rem;
}

.btn-full {
    width: 100%;
    justify-content: center;
}

.btn-icon {
    /*padding: 7px;*/
    /*width: 32px;*/
    /*height: 32px;*/
    justify-content: center;
}

/* ─── Cards ──────────────────────────────────────────────────────────────── */
.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 20px;
    max-width: 1200px;
    margin: 0 auto;
    width: 100%;
}

/* ─── Danger zone (collapsible details) ──────────────────────────────────── */
.danger-zone {
    border: 1px solid rgba(255, 92, 92, .3);
    background: rgb(23 15 15);
}

.danger-zone > summary {
    list-style: none;
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    font-weight: 700;
    color: var(--danger);
    user-select: none;
    padding: 0;
    margin: 0;
}

.danger-zone > summary::after {
    content: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%235a6080' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M9 6l6 6l-6 6'/%3E%3C/svg%3E");
    margin-left: auto;
    font-size: .85rem;
    color: var(--text3);
    transition: transform .2s ease;
}

.danger-zone[open] > summary::after {
    transform: rotate(90deg);
}

.danger-zone > summary::-webkit-details-marker {
    display: none;
}

.card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 16px;
    gap: 12px;
    font-size: 1.3rem;
}

.card-title {
    font-size: 1rem;
    font-weight: 700;
}

.card-title-inline {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

.card-subtitle {
    font-size: .8rem;
    color: var(--text2);
    margin-top: 2px;
}

@media (max-width: 480px) {
    .card-header {
        display: block;
    }

    .card-subtitle {
        display: block;
        padding-bottom: 10px;
    }
}

/* ─── Tables ─────────────────────────────────────────────────────────────── */
.table-wrap {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    margin: 0 -20px 0 -20px;
    padding: 0 20px;
}

table {
    width: 100%;
    border-collapse: collapse;
    font-size: .88rem;
}

thead th {
    padding: 8px 12px;
    text-align: left;
    font-size: .75rem;
    font-weight: 700;
    /*text-transform: uppercase;*/
    letter-spacing: .05em;
    color: var(--text2);
    border-bottom: 1px solid var(--border);
    white-space: nowrap;
}

tbody tr {
    border-bottom: 1px solid var(--border);
    transition: background var(--transition);
}

tbody tr:hover {
    background: var(--surface2);
}

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

td {
    padding: 10px 12px;
    vertical-align: top;
}

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

/* Single-line dense tables for settings lists */
.single-line-table td,
.single-line-table th {
    white-space: nowrap;
    vertical-align: middle;
    overflow: hidden;
    text-overflow: ellipsis;
}

.single-line-table .col-name {
    max-width: 320px;
    overflow: hidden;
    text-overflow: ellipsis;
}

.single-line-table tr[data-type="subcategory"] td {
    background: rgba(0, 0, 0, 0.015);
}

.single-line-table .badge {
    white-space: nowrap;
}


/* ─── Badges ─────────────────────────────────────────────────────────────── */
.badge {
    display: inline-block;
    border-radius: 20px;
    font-size: .6rem;
    font-weight: 700;
    letter-spacing: .03em;
    background: var(--surface3);
    border: 1px solid;
    /*margin: 4px 4px 4px 4px;*/
    padding: 0 11px;
    margin: auto 0;
}

.badge-expense {
    background: rgba(255, 107, 107, .15);
    color: var(--expense);
}

.badge-income {
    background: rgba(78, 205, 196, .15);
    color: var(--income);
}

.badge-transfer {
    background: rgba(108, 99, 255, .15);
    color: var(--transfer);
}

.badge-active {
    background: rgba(76, 175, 80, .15);
    color: var(--success);
}

.badge-inactive {
    background: rgba(90, 96, 128, .15);
    color: var(--text3);
}

.badge-period {
    font-weight: normal;
    font-size: 0.65rem;
    vertical-align: middle;
    opacity: 0.8;
    position: relative;
    top: -2px;
    margin-left: 9px;
}

.version-badge {
    display: inline-block;
    padding: 1px 7px;
    border-radius: 20px;
    font-size: .8rem;
    font-weight: 400;
    letter-spacing: .03em;
    background: transparent;
    border: 1px solid var(--border);
    color: var(--text2);
    margin-left: 12px;
    transition: border-color var(--transition), color var(--transition);
    position: relative;
    top: 2px;
}

.version-badge:hover {
    border-color: var(--accent);
    color: var(--accent);
}

.kpi-at-info {
    font-size: 0.85em;
    opacity: 0.75;
    margin-left: 8px;
}

/* Tax badges */
.badge-tax-t {
    background: rgba(255, 179, 71, .2);
    color: var(--warning);
}

.tx-invoice-icon {
    margin-left: 2px;
    color: var(--warning);
}

/* ─── Modal ──────────────────────────────────────────────────────────────── */
.modal-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, .6);
    z-index: 200;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 16px;
    animation: fadeIn .15s ease;
}

.modal-backdrop.align-top {
    align-items: flex-start;
    padding-top: 50px;
}

.modal {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    width: 100%;
    max-width: 640px;
    max-height: calc(100vh - 32px);
    display: flex;
    flex-direction: column;
    box-shadow: var(--shadow);
    animation: slideUp .2s ease;
}

.modal-sm {
    max-width: 400px;
}

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

.modal-import {
    max-width: min(95vw, 1200px);
    width: 1200px;
}

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

.modal-title {
    font-size: 1rem;
    font-weight: 700;
}

.modal-close {
    background: none;
    border: none;
    color: var(--text2);
    font-size: 1.4rem;
    line-height: 1;
    padding: 0;
    transition: color var(--transition);
}

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

.modal-body {
    padding: 16px 20px;
    overflow-y: auto;
    flex: 1;
    min-height: 0;
}

.modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 8px;
    padding: 12px 20px 20px;
    border-top: 1px solid var(--border);
}

@media (max-width: 480px) {
    .modal-header {
        padding: 6px 9px 0;
    }

    .modal-body {
        padding: 4px 9px;
    }
}

/* ─── Tabs ───────────────────────────────────────────────────────────────── */
.tabs {
    display: flex;
    gap: 4px;
    border-bottom: 1px solid var(--border);
    margin-bottom: 20px;
}

.tab-btn {
    background: none;
    border: none;
    text-decoration: none;
    cursor: pointer;
    padding: 9px 16px;
    font-size: .88rem;
    font-weight: 600;
    color: var(--text2);
    border-bottom: 2px solid transparent;
    margin-bottom: -1px;
    transition: color var(--transition), border-color var(--transition);
}

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

.tab-btn.active {
    color: var(--accent);
    border-bottom-color: var(--accent);
}

.tab-pane {
    display: none;
}

.tab-pane.active {
    display: block;
}

.budget-calendar-toolbar {
    width: 100%;
    display: grid;
    grid-template-columns: auto 1fr auto;
    gap: 16px;
    align-items: center;
}

.budget-calendar-toolbar-nav,
.budget-calendar-toolbar-go {
    display: flex;
    align-items: center;
    gap: 10px;
    justify-content: flex-end;
}

.budget-calendar-type-filters {
    display: flex;
    align-items: center;
    gap: 0;
}

.budget-calendar-type-filters .btn {
    border-radius: 0;
}

.budget-calendar-type-filters .btn:first-child {
    border-top-left-radius: 6px;
    border-bottom-left-radius: 6px;
}

.budget-calendar-type-filters .btn:last-child {
    border-top-right-radius: 6px;
    border-bottom-right-radius: 6px;
    margin-left: -1px;
}

.budget-calendar-type-filters .btn.is-active {
    background: var(--accent);
    border-color: var(--accent);
    color: #fff;
}

.budget-calendar-toolbar .card-title {
    margin: 0;
}

.budget-item-form .form-group {
    margin-bottom: 12px;
}

.budget-item-form > .form-group {
    width: 100%;
}

.budget-item-form-row {
    align-items: flex-end;
}

.budget-item-form-row .form-group {
    min-width: 0;
}

.budget-amount-inline {
    display: flex;
    gap: 10px;
}

.budget-amount-inline [name="item_period_mode"] {
    width: 85px;
}

.budget-amount-inline [name="item_repeat_value"] {
    width: 50px;
}

.budget-footer-toggle {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    margin-right: auto;
}

.budget-footer-toggle-input {
    position: absolute;
    opacity: 0;
    pointer-events: none;
}

.budget-footer-toggle-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.budget-create-tx-label-short {
    display: none;
}

@media (max-width: 480px) {
    .budget-create-tx-label-full {
        display: none;
    }

    .budget-create-tx-label-short {
        display: inline;
    }
}

.budget-calendar-grid {
    display: grid;
    grid-template-columns: repeat(7, minmax(0, 1fr));
    gap: 4px;
}

.budget-calendar-scroll {
    width: 100%;
    overflow-x: auto;
    overflow-y: hidden;
    -webkit-overflow-scrolling: touch;
}

.budget-calendar-weekday {
    font-size: .78rem;
    font-weight: 700;
    color: var(--text2);
    text-transform: uppercase;
    letter-spacing: .03em;
    text-align: center;
}

.budget-calendar-day {
    min-height: 150px;
    border: 1px solid var(--surface3);
    border-radius: 12px;
    /*background: var(--surface2);*/
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.budget-calendar-day--empty {
    background: transparent;
    border-style: dashed;
    opacity: 0;
}

.budget-calendar-day--today {
    background: var(--surface2);
    border-color: var(--accent);
    box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--accent) 35%, transparent);
}

.budget-calendar-day-top {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    padding: 3px 9px 0 8px;
}

.budget-calendar-date {
    font-weight: 700;
}

.budget-calendar-day-total {
    font-size: .78rem;
    color: var(--text2);
}

.budget-calendar-cards-wrap {
    margin-top: 12px;
}

.budget-calendar-list-table td:nth-child(1),
.budget-calendar-list-table th:nth-child(1) {
    display: table-cell !important;
    width: 60px !important;
    min-width: 60px !important;
    max-width: 60px !important;
}

.budget-calendar-list-table td,
.budget-calendar-list-table th {
    padding: 7px 7px !important;
}

.budget-calendar-list-table .budget-calendar-list-row--today td {
    background: var(--surface2);
}

.budget-calendar-list-table .budget-calendar-list-group-header td {
    background: color-mix(in srgb, var(--surface2) 82%, var(--accent) 6%);
    border-top: 1px solid var(--border);
}

.budget-calendar-sort-btn {
    border: 0;
    background: transparent;
    color: inherit;
    font: inherit;
    font-weight: 700;
    padding: 0;
    cursor: pointer;
}

.budget-calendar-sort-btn.is-active {
    color: var(--accent);
}

.budget-calendar-list-table {
    table-layout: fixed !important;
    width: 100%;
    max-width: 1180px;
    margin: 0 auto;
}

.budget-calendar-list-table td:nth-child(4),
.budget-calendar-list-table th:nth-child(4) {
    width: 96px !important;
    min-width: 96px !important;
    max-width: 96px !important;
}

.budget-calendar-list-table td:nth-child(5),
.budget-calendar-list-table th:nth-child(5) {
    width: 110px !important;
    min-width: 110px !important;
    max-width: 110px !important;
}

.budget-calendar-list-table .budget-calendar-list-date {
    white-space: nowrap;
}

.budget-calendar-list-table .budget-calendar-list-item-group {
    display: none;
    margin-bottom: 3px;
    font-size: .72rem;
    line-height: 1.2;
    text-transform: uppercase;
    letter-spacing: .04em;
    color: var(--text2);
}

.budget-calendar-list-table .budget-calendar-list-item-cell {
    cursor: pointer;
}

.budget-calendar-list-table .budget-calendar-list-item-cell:hover {
    background: color-mix(in srgb, var(--surface) 40%, var(--accent) 8%);
}

.budget-calendar-list-table .budget-calendar-list-item {
    font-weight: 600;
    color: var(--accent);
}

.budget-calendar-list-table .budget-calendar-list-item-note {
    font-weight: 400;
    font-size: .82rem;
    line-height: 1.25;
    color: var(--text2);
    white-space: normal;
}

.budget-calendar-list-table .budget-calendar-list-period {
    white-space: nowrap;
    color: var(--text2);
}

.budget-calendar-list-table .budget-calendar-list-group-header-cell {
    padding-top: 10px !important;
    padding-bottom: 10px !important;
}

.budget-calendar-list-table .budget-calendar-list-group-header-inner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

.budget-calendar-list-table .budget-calendar-list-group-header-name {
    font-size: .74rem;
    font-weight: 700;
    line-height: 1.2;
    text-transform: uppercase;
    letter-spacing: .04em;
    color: var(--text2);
}

.budget-calendar-list-table .budget-calendar-list-group-header-amount {
    white-space: nowrap;
    font-weight: 700;
}

.budget-calendar-list-table .budget-calendar-list-comment {
    color: var(--text2);
    white-space: normal;
}

@media (max-width: 500px) {
    .budget-calendar-list-table td:nth-child(3),
    .budget-calendar-list-table th:nth-child(3) {
        display: none !important;
    }

    .budget-calendar-list-table .budget-calendar-list-item-group {
        display: block;
    }

    .budget-calendar-toolbar-go {
        flex-wrap: wrap;
    }

    .budget-calendar-external-modal-grid {
        grid-template-columns: 1fr;
    }
}

.budget-calendar-items {
    display: flex;
    flex-direction: column;
    gap: 6px;
    min-height: 0;
}

.budget-calendar-item-row {
    display: flex;
    align-items: stretch;
    gap: 6px;
}

.budget-calendar-item {
    flex: 1 1 auto;
    border-radius: 10px;
    background: color-mix(in srgb, var(--surface) 55%, var(--surface2));
    padding: 8px;
    border: 0;
    width: 100%;
    text-align: left;
    cursor: pointer;
    appearance: none;
}

.budget-calendar-item:hover {
    background: color-mix(in srgb, var(--surface) 40%, var(--accent) 10%);
}

.budget-calendar-item--readonly {
    cursor: default;
}

.budget-calendar-item--readonly:hover {
    background: color-mix(in srgb, var(--surface) 55%, var(--surface2));
}

.budget-calendar-external-modal {
    display: flex;
    flex-direction: column;
    gap: 14px;
}

.budget-calendar-external-modal-lead {
    font-size: 1rem;
    font-weight: 600;
    color: var(--text);
}

.budget-calendar-external-modal-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 12px;
}

.budget-calendar-external-modal-field {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.budget-calendar-external-modal-label {
    font-size: .75rem;
    text-transform: uppercase;
    letter-spacing: .05em;
    color: var(--text2);
}

.budget-calendar-external-modal-value {
    color: var(--text);
    word-break: break-word;
}

.budget-calendar-external-modal-note {
    color: var(--text2);
    font-size: .85rem;
}

.budget-calendar-item:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 1px;
}

.budget-calendar-item-name {
    font-size: .85rem;
    font-weight: 600;
    line-height: 1.25;
    color: var(--accent);
}

.budget-calendar-item-meta,
.budget-calendar-item-amount,
.budget-calendar-empty {
    font-size: .74rem;
    color: var(--text2);
}

.budget-calendar-item-amount {
    margin-top: 8px;
    text-align: right;
    line-height: 1;
}

.budget-calendar-item-create-tx {
    flex: 0 0 auto;
    min-width: 42px;
    padding: 8px 7px;
    border-radius: 10px;
    border: 1px solid var(--border);
    background: var(--surface2);
    color: var(--text2);
    cursor: pointer;
    font-size: .72rem;
    font-weight: 700;
}

.budget-calendar-item-create-tx:hover,
.budget-calendar-item-create-tx:focus-visible {
    border-color: var(--accent);
    color: var(--accent);
    outline: none;
}

/* ─── Transaction History details ───────────────────────────────────────── */
.tx-history-entry {
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--surface2);
    padding: 8px 10px;
}

.tx-history-entry summary {
    cursor: pointer;
    font-weight: 600;
}

.tx-history-json {
    margin: 6px 0 0;
    padding: 10px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: rgba(0, 0, 0, .2);
    max-height: 260px;
    overflow: auto;
    font-size: .78rem;
    line-height: 1.35;
}

.tx-history-section-title {
    margin: 10px 0 6px;
    font-weight: 700;
    color: var(--text);
}

.tx-history-diff-table {
    overflow-x: auto;
}

.tx-history-change-table,
.tx-history-snapshot-table {
    width: 100%;
    border-collapse: collapse;
    font-size: .82rem;
}

.tx-history-change-table th,
.tx-history-change-table td,
.tx-history-snapshot-table td {
    padding: 8px 10px;
    border: 1px solid var(--border);
    vertical-align: top;
}

.tx-history-change-table th {
    color: var(--text2);
    font-size: .72rem;
    text-transform: uppercase;
    letter-spacing: .04em;
}

.tx-history-change-table code,
.tx-history-snapshot-table code {
    white-space: pre-wrap;
    word-break: break-word;
    font-family: monospace;
    font-size: .78rem;
    color: var(--text);
}

.tx-history-inline-change {
    margin-top: 4px;
    font-size: .76rem;
}

.tx-history-inline-change-label {
    color: var(--warning, #f5a623);
    font-weight: 600;
}

.tx-history-inline-change-old {
    margin-top: 2px;
    color: var(--text2);
    font-size: .76rem;
}

.tx-history-amount-wrap {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    flex-wrap: wrap;
}

.tx-history-snapshots-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
    margin-top: 12px;
}

.tx-history-snapshot-box {
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--surface);
    padding: 10px;
}

.tx-history-modal-summary {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
    color: var(--text2);
    font-size: .85rem;
}

.tx-history-modal-summary-main,
.tx-history-modal-summary-meta {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.tx-history-transaction-head {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    gap: 10px;
    margin-bottom: 8px;
}

.tx-history-transaction-date {
    font-weight: 700;
    color: var(--text);
}

.tx-history-transaction-created {
    color: var(--text2);
    font-size: .8rem;
    text-align: right;
}

@media (max-width: 700px) {
    .tx-history-modal-summary {
        grid-template-columns: 1fr;
    }

    .tx-history-snapshots-grid {
        grid-template-columns: 1fr;
    }
}

/* ─── Toast ──────────────────────────────────────────────────────────────── */
.toast-container {
    position: fixed;
    top: calc(var(--topbar-h) + 16px);
    right: 24px;
    z-index: 12000;
    display: flex;
    flex-direction: column;
    gap: 8px;
    pointer-events: none;
}

.toast {
    padding: 12px 18px;
    border-radius: var(--radius-sm);
    font-size: .88rem;
    font-weight: 500;
    color: #fff;
    box-shadow: var(--shadow);
    animation: slideInDown .2s ease;
    pointer-events: all;
    max-width: 380px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    cursor: pointer;
}

.toast-close {
    background: none;
    border: none;
    color: rgba(255, 255, 255, .7);
    font-size: 1.4rem;
    line-height: 1;
    padding: 0;
    margin-top: -2px;
    transition: color var(--transition);
}

.toast-close:hover {
    color: #fff;
}

.toast-action {
    background: rgba(255, 255, 255, .14);
    border: 1px solid rgba(255, 255, 255, .2);
    color: #fff;
    border-radius: 8px;
    padding: 6px 12px;
    font-weight: 600;
    cursor: pointer;
    white-space: nowrap;
}

.toast-action:hover {
    background: rgba(255, 255, 255, .22);
}

.toast-success {
    background: var(--success);
}

.toast-error {
    background: var(--danger);
}

.toast-info {
    background: var(--accent);
}

/* ─── Connection status badge ───────────────────────────────────────────── */
/* (inline status only; floating badge removed) */

/* ─── Empty state ────────────────────────────────────────────────────────── */
.empty-state {
    text-align: center;
    padding: 60px 20px;
    color: var(--text2);
}

.empty-state h2 {
    font-size: 2rem;
    margin-bottom: 8px;
    color: var(--text3);
}

.empty-state p {
    margin-bottom: 20px;
}

.offline-shell-card {
    max-width: 640px;
}

.offline-shell-state {
    display: grid;
    gap: 10px;
    margin-bottom: 20px;
}

.offline-shell-state h2 {
    margin: 0;
}

.offline-shell-actions {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
}

@media (max-width: 640px) {
    .offline-shell-actions .btn {
        width: 100%;
    }
}

/* ─── Install / Status ───────────────────────────────────────────────────── */
.status-list {
    list-style: none;
}

.status-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 0;
    border-bottom: 1px solid var(--border);
    font-size: .88rem;
}

.status-item:last-child {
    border: none;
}

.status-ok {
    color: var(--success);
}

.status-fail {
    color: var(--danger);
}

/* ─── Page header ────────────────────────────────────────────────────────── */
.page-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 24px;
    flex-wrap: wrap;
    gap: 12px;
}

.page-header h1 {
    font-size: 1.4rem;
    font-weight: 800;
}

/* ─── Animations ─────────────────────────────────────────────────────────── */
@keyframes fadeIn {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

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

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

@keyframes slideInDown {
    from {
        transform: translateY(-40px);
        opacity: 0;
    }
    to {
        transform: translateY(0);
        opacity: 1;
    }
}

@keyframes savedFade {
    0% {
        opacity: 0;
        transform: translateY(-4px);
    }
    15% {
        opacity: 1;
        transform: translateY(0);
    }
    75% {
        opacity: 1;
    }
    100% {
        opacity: 0;
    }
}

/* ─── Setting saved indicator ────────────────────────────────────────────── */
.setting-saved {
    display: inline-flex;
    align-items: center;
    font-size: .75rem;
    font-weight: 600;
    color: var(--success);
    position: absolute;
    top: 10px;
    right: 12px;
    padding: 2px 8px;
    border-radius: 999px;
    border: 1px solid rgba(76, 175, 80, .28);
    background: rgba(76, 175, 80, .14);
    animation: savedFade 2s ease forwards;
    pointer-events: none;
    line-height: 1.2;
    z-index: 2;
}

/* ─── Utilities ──────────────────────────────────────────────────────────── */
.text-muted {
    color: var(--text2);
}

.text-small {
    font-size: .8rem;
}

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

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

.text-success {
    color: var(--success);
}

.text-danger {
    color: var(--danger);
}

.text-warning {
    color: var(--warning);
}

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

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

/* Changelog Timeline */
.changelog-list {
    display: flex;
    flex-direction: column;
    gap: 24px;
    padding: 8px 0;
}

.changelog-item {
    position: relative;
    padding-left: 24px;
}

.changelog-item::before {
    content: '';
    position: absolute;
    left: 0;
    top: 6px;
    bottom: -30px;
    width: 2px;
    background: var(--border);
}

.changelog-item:last-child::before {
    display: none;
}

.changelog-dot {
    position: absolute;
    left: -4px;
    top: 6px;
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: var(--accent);
    box-shadow: 0 0 0 4px var(--bg);
}

.changelog-header {
    display: flex;
    align-items: baseline;
    gap: 12px;
    margin-bottom: 8px;
}

.changelog-ver {
    font-weight: 700;
    font-size: 1.1rem;
    color: var(--text);
}

.changelog-date {
    font-size: 0.85rem;
    color: var(--text3);
}

.changelog-changes {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.changelog-changes li {
    font-size: 0.9rem;
    color: var(--text2);
    display: flex;
    gap: 8px;
}

.changelog-changes li::before {
    content: '→';
    color: var(--accent);
    opacity: 0.6;
}

.filter-group {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

.me-1 {
    margin-right: 4px;
}

.me-2 {
    margin-right: 8px;
}

.me-3 {
    margin-right: 16px;
}

.mb-3 {
    margin-bottom: 16px;
}

select[multiple].form-control {
    padding: 2px;
}

select[multiple].form-control option {
    padding: 4px 8px;
    border-radius: 4px;
}

select[multiple].form-control option:checked {
    background: var(--accent) linear-gradient(0deg, var(--accent) 0%, var(--accent) 100%);
    color: #fff;
}

.mt-8 {
    margin-top: 8px;
}

.mt-16 {
    margin-top: 16px;
}

.mt-24 {
    margin-top: 24px;
}

.flex, .d-flex {
    display: flex !important;
}

.flex-between {
    display: flex !important;
    justify-content: space-between;
    align-items: center;
}

.d-block {
    display: block !important;
}

.d-inline-block {
    display: inline-block !important;
}

.gap-8 {
    gap: 8px;
}

.gap-12 {
    gap: 12px;
}

.d-none {
    display: none !important;
}

/* Toggle switch */
.toggle-wrap {
    display: flex;
    align-items: center;
    gap: 8px;
}

.toggle {
    position: relative;
    width: 36px;
    height: 20px;
}

.toggle input {
    opacity: 0;
    width: 0;
    height: 0;
}

.toggle-slider {
    position: absolute;
    inset: 0;
    background: var(--surface3);
    border-radius: 20px;
    cursor: pointer;
    transition: background var(--transition);
}

.toggle-slider:before {
    content: '';
    position: absolute;
    left: 3px;
    top: 3px;
    width: 14px;
    height: 14px;
    background: var(--text2);
    border-radius: 50%;
    transition: transform var(--transition), background var(--transition);
}

.toggle input:checked + .toggle-slider {
    background: var(--accent);
}

.toggle input:checked + .toggle-slider:before {
    transform: translateX(16px);
    background: #fff;
}

/* Drag handle */
.drag-handle {
    cursor: grab;
    color: var(--text3);
    padding: 0 4px;
    user-select: none;
}

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

tr.dragging {
    opacity: .4;
    background: var(--surface3) !important;
}

.categories-table.touch-drag-active {
    user-select: none;
}

#banksTable.touch-drag-active,
#accountsTable.touch-drag-active {
    user-select: none;
}

.table-drag-ghost {
    position: absolute;
    z-index: 9999;
    pointer-events: none;
    border-collapse: separate;
    border-spacing: 0;
}

.table-drag-ghost tr.dragging {
    opacity: .96;
    background: var(--surface2) !important;
    box-shadow: 0 8px 24px rgba(0, 0, 0, .18);
}

.table-drag-placeholder {
    position: relative;
    background: var(--surface2) !important;
    outline: 2px dashed var(--accent);
    outline-offset: -2px;
}

.table-drag-placeholder > * {
    opacity: 0;
}

.bank-row-icon {
    width: 16px;
    height: 16px;
    object-fit: contain;
    border-radius: 3px;
    vertical-align: middle;
    margin-right: 6px;
}

/* Keep bank/account names readable regardless of active state */
.settings-entity-name {
    color: var(--text);
}

.settings-entity-name.settings-entity-name-inactive {
    color: var(--text3);
}

.account-mobile-line {
    display: block;
}

.account-mobile-line-2,
.account-mobile-link-note {
    display: none;
}

.account-mobile-chip {
    display: none;
}

.account-mobile-chip,
.account-mobile-subitem {
    white-space: nowrap;
}

.bank-mobile-line-2,
.bank-mobile-chip {
    display: none;
}

.currency-mobile-line-2,
.currency-mobile-chip,
.pair-mobile-line-2,
.pair-mobile-summary {
    display: none;
}

.currency-mobile-tag {
    display: none;
}

.pair-base-text {
    display: inline;
}

/* Icon editor in bank modal */
.bank-icon-row {
    display: flex;
    align-items: flex-start;
    gap: 12px;
}

.bank-icon-row > div {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.bank-icon-preview-wrap {
    max-width: 55px;
}

.bank-icon-preview-wrap {
    width: 56px;
    height: 56px;
    flex-shrink: 0;
    border: 2px dashed var(--border);
    border-radius: 10px;
    background: var(--surface2);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    transition: border-color var(--transition), background var(--transition);
    position: relative;
}

.bank-icon-preview-wrap:hover {
    border-color: var(--accent);
    background: rgba(108, 99, 255, .07);
}

.bank-icon-preview-wrap img {
    width: 100%;
    height: 100%;
    object-fit: contain;
}

.bank-icon-preview-emoji {
    font-size: 1.6rem;
    line-height: 1;
    user-select: none;
}

.bank-icon-upload-spinner {
    position: absolute;
    font-size: 1.2rem;
}

.bank-icon-presets {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
}

.bank-icon-presets .btn {
    font-size: .9rem;
    padding: 2px 7px;
    min-width: 0;
}

/* ─── Mobile/Desktop toggle buttons ─────────────────────────────────────── */
.mobile-toggle-btn {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    background: none;
    border: none;
    color: var(--text2);
    font-size: .82rem;
    font-weight: 600;
    padding: 4px 0;
    cursor: pointer;
    user-select: none;
}

.mobile-toggle-label {
    display: flex;
    align-items: center;
    flex-wrap: nowrap;
    gap: 8px;
    color: var(--accent);
    cursor: pointer;
}

.mobile-toggle-arrow {
    transition: transform .2s ease;
    font-size: .7rem;
}

/* Balance bar collapsed */
.balance-bar.collapsed .balance-bar-scroll {
    display: none;
}

.balance-bar.collapsed .mobile-toggle-arrow {
    transform: rotate(-90deg);
}

.balance-bar.collapsed {
    padding: 10px 10px 8px;
}

/* Filters collapsed */
.tx-sticky-header.collapsed .filters-row,
.tx-sticky-header.collapsed .filters-row-extra {
    display: none;
}

.tx-sticky-header.collapsed .mobile-toggle-arrow {
    transform: rotate(-90deg);
}

.tx-sticky-header.collapsed {
    padding-bottom: 4px;
}

/* Filter applied indicator */
.filter-applied-indicator {
    font-size: 0.72rem;
    font-weight: 700;
    color: #8B0000; /* Dark red */
    text-transform: uppercase;
    letter-spacing: 0.04em;
    animation: fadeIn 0.3s ease;
}

.btn-quick-clear {
    background: none;
    border: 1px solid #8B0000;
    color: #8B0000;
    font-size: 0.65rem;
    padding: 1px 6px;
    border-radius: 4px;
    cursor: pointer;
    text-transform: lowercase;
    font-weight: 600;
    transition: all 0.2s ease;
    vertical-align: middle;
}

.btn-quick-clear:hover {
    background: #8B0000;
    color: #fff;
}

.filter-ms-selected-group {
    background: var(--surface2);
    border-bottom: 1px solid var(--border);
}

.filter-ms-item-duplicate {
    opacity: 0.85;
}

.filter-ms-divider {
    height: 1px;
    background: var(--border);
    margin: 4px 8px;
}

.btn-has-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.btn-has-icon .icon {
    flex-shrink: 0;
}

/* ─── Responsive ─────────────────────────────────────────────────────────── */
@media (max-width: 1100px) {
    :root {
        --sidebar-w: 0px;
    }

    .sidebar {
        transform: translateX(-220px);
        width: 220px;
    }

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

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

    .main-wrap {
        margin-left: 0;
        width: 100%;
    }

    /* .burger is now always flex, but we might want to adjust its look on mobile if needed */
    .main-content {
        padding: 10px 10px 80px 10px;
    }

    .balance-bar {
        padding: 8px 16px 12px;
    }

    .form-row {
        flex-direction: column;
    }

    .budget-item-form-row {
        flex-direction: row;
    }

    .btn-has-icon .btn-text {
        display: none;
    }

    .btn-has-icon .icon.mr-1 {
        margin-right: 0 !important;
    }
}

@media (max-width: 480px) {
    .tabs {
        overflow-x: auto;
        overflow-y: hidden;
    }

    .tab-btn {
        white-space: nowrap;
    }

    .card {
        padding: 14px;
    }

    .budget-item-form-row {
        gap: 3px;
    }

    .budget-item-form .autocomplete-wrap,
    .budget-item-form > .form-group {
        width: 100%;
    }

    .budget-amount-inline {
        flex-direction: column;
    }

    .theme-switcher {
        grid-template-columns: 1fr;
    }

    .display-pref-inline-row {
        align-items: stretch;
    }

    .offline-cache-stats,
    .offline-cache-status {
        grid-template-columns: 1fr;
    }

    .offline-cache-table {
        min-width: 720px;
    }

    .offline-cache-table thead {
        display: table-header-group;
    }

    .offline-cache-table tbody tr {
        display: table-row;
        padding: 0;
    }

    .offline-cache-table td,
    .offline-cache-table th {
        display: table-cell;
        padding: 12px;
        font-size: .78rem;
    }

    .offline-cache-table td:before {
        content: none;
    }

    thead {
        display: none;
    }

    tbody tr {
        display: block;
        padding: 10px 0;
    }

    td {
        display: flex;
        justify-content: space-between;
        padding: 4px 12px;
        font-size: .82rem;
    }

    td[data-label]:before {
        content: attr(data-label);
        font-weight: 700;
        color: var(--text2);
        font-size: .75rem;
        text-transform: uppercase;
    }

    #accountsTable td[data-label]:before {
        content: none;
        display: none;
    }

    #banksTable td[data-label]:before {
        content: none;
        display: none;
    }

    #currenciesTable td[data-label]:before,
    #pairsTable td[data-label]:before,
    .table-drag-ghost[data-source-table-id="currenciesTable"] td[data-label]:before,
    .table-drag-ghost[data-source-table-id="pairsTable"] td[data-label]:before {
        content: none;
        display: none;
    }

    .table-drag-ghost[data-source-table-id="banksTable"] td[data-label]:before {
        content: none;
        display: none;
    }

    .table-drag-ghost[data-source-table-id="accountsTable"] td[data-label]:before {
        content: none;
        display: none;
    }

    #banksTable td:nth-child(3),
    #banksTable th:nth-child(3),
    #banksTable td:nth-child(4),
    #banksTable th:nth-child(4) {
        display: none;
    }

    .table-drag-ghost[data-source-table-id="banksTable"] td:nth-child(3),
    .table-drag-ghost[data-source-table-id="banksTable"] td:nth-child(4) {
        display: none;
    }

    #currenciesTable td:nth-child(2),
    #currenciesTable th:nth-child(2),
    #currenciesTable td:nth-child(4),
    #currenciesTable th:nth-child(4),
    .table-drag-ghost[data-source-table-id="currenciesTable"] td:nth-child(2),
    .table-drag-ghost[data-source-table-id="currenciesTable"] td:nth-child(4),
    #pairsTable td:nth-child(3),
    #pairsTable th:nth-child(3),
    .table-drag-ghost[data-source-table-id="pairsTable"] td:nth-child(3) {
        display: none;
    }

    #accountsTable td:nth-child(3),
    #accountsTable th:nth-child(3),
    #accountsTable td:nth-child(4),
    #accountsTable th:nth-child(4),
    #accountsTable td:nth-child(5),
    #accountsTable th:nth-child(5),
    #accountsTable td:nth-child(6),
    #accountsTable th:nth-child(6) {
        display: none;
    }

    .table-drag-ghost[data-source-table-id="accountsTable"] td:nth-child(3),
    .table-drag-ghost[data-source-table-id="accountsTable"] td:nth-child(4),
    .table-drag-ghost[data-source-table-id="accountsTable"] td:nth-child(5),
    .table-drag-ghost[data-source-table-id="accountsTable"] td:nth-child(6) {
        display: none;
    }

    .td-actions {
        justify-content: flex-start;
    }

    #banksTable td:first-child,
    #currenciesTable td:first-child,
    #currenciesTable th:first-child,
    #pairsTable td:first-child,
    #pairsTable th:first-child,
    #banksTable th:first-child,
    #accountsTable td:first-child,
    #accountsTable th:first-child {
        display: none;
    }

    #accountsTable tr.bank-group-header td:first-child {
        display: flex;
        align-items: center;
        justify-content: flex-start;
        gap: 8px;
        width: 100%;
    }

    #banksTable tbody tr[data-id] {
        display: flex;
        align-items: stretch;
        justify-content: space-between;
        gap: 10px;
        padding: 10px 0;
    }

    .table-drag-ghost[data-source-table-id="banksTable"] tbody tr.dragging {
        display: flex;
        align-items: stretch;
        justify-content: space-between;
        gap: 10px;
        padding: 10px 0;
    }

    #banksTable tbody tr[data-id] td {
        padding: 0;
    }

    .table-drag-ghost[data-source-table-id="banksTable"] tbody tr.dragging td {
        padding: 0;
    }

    #banksTable tbody tr[data-id] td:nth-child(2) {
        display: block;
        flex: 1;
        min-width: 0;
    }

    .table-drag-ghost[data-source-table-id="banksTable"] tbody tr.dragging td:nth-child(2) {
        display: block;
        flex: 1;
        min-width: 0;
    }

    #banksTable tbody tr[data-id] td.td-actions {
        display: flex;
        flex-direction: row;
        justify-content: center;
        align-items: stretch;
        gap: 6px;
        flex: 0 0 auto;
        min-width: 86px;
    }

    .table-drag-ghost[data-source-table-id="banksTable"] tbody tr.dragging td.td-actions {
        display: flex;
        flex-direction: row;
        justify-content: center;
        align-items: stretch;
        gap: 6px;
        flex: 0 0 auto;
        min-width: 86px;
    }

    #banksTable tbody tr[data-id] td.td-actions .btn {
        width: 40px;
        min-width: 40px;
        height: 40px;
        padding: 0;
        justify-content: center;
    }

    .table-drag-ghost[data-source-table-id="banksTable"] tbody tr.dragging td.td-actions .btn {
        width: 40px;
        min-width: 40px;
        height: 40px;
        padding: 0;
        justify-content: center;
    }

    #banksTable tbody tr[data-id] td.td-actions .btn .icon {
        margin-right: 0 !important;
    }

    .table-drag-ghost[data-source-table-id="banksTable"] tbody tr.dragging td.td-actions .btn .icon {
        margin-right: 0 !important;
    }

    #banksTable .bank-mobile-line-1 {
        display: flex;
        align-items: center;
        gap: 6px;
        flex-wrap: wrap;
        margin-bottom: 4px;
    }

    .table-drag-ghost[data-source-table-id="banksTable"] .bank-mobile-line-1 {
        display: flex;
        align-items: center;
        gap: 6px;
        flex-wrap: wrap;
        margin-bottom: 4px;
    }

    #banksTable .bank-mobile-name {
        font-weight: 700;
        color: var(--text);
        min-width: 0;
    }

    .table-drag-ghost[data-source-table-id="banksTable"] .bank-mobile-name {
        font-weight: 700;
        color: var(--text);
        min-width: 0;
    }

    #banksTable .settings-entity-name-inactive .bank-mobile-name {
        color: var(--text3);
    }

    .table-drag-ghost[data-source-table-id="banksTable"] .settings-entity-name-inactive .bank-mobile-name {
        color: var(--text3);
    }

    #banksTable .bank-mobile-chip {
        display: inline-flex;
    }

    .table-drag-ghost[data-source-table-id="banksTable"] .bank-mobile-chip {
        display: inline-flex;
    }

    #banksTable .bank-mobile-line-2 {
        display: block;
        font-size: .8rem;
        color: var(--text2);
    }

    .table-drag-ghost[data-source-table-id="banksTable"] .bank-mobile-line-2 {
        display: block;
        font-size: .8rem;
        color: var(--text2);
    }

    #currenciesTable tbody tr[data-id],
    #pairsTable tbody tr[data-id],
    .table-drag-ghost[data-source-table-id="currenciesTable"] tbody tr.dragging,
    .table-drag-ghost[data-source-table-id="pairsTable"] tbody tr.dragging {
        display: flex;
        align-items: stretch;
        justify-content: space-between;
        gap: 10px;
        padding: 10px 0;
    }

    #currenciesTable tbody tr[data-id] td,
    #pairsTable tbody tr[data-id] td,
    .table-drag-ghost[data-source-table-id="currenciesTable"] tbody tr.dragging td,
    .table-drag-ghost[data-source-table-id="pairsTable"] tbody tr.dragging td {
        padding: 0;
    }

    #currenciesTable tbody tr[data-id] td:nth-child(3),
    #pairsTable tbody tr[data-id] td:nth-child(2),
    .table-drag-ghost[data-source-table-id="currenciesTable"] tbody tr.dragging td:nth-child(3),
    .table-drag-ghost[data-source-table-id="pairsTable"] tbody tr.dragging td:nth-child(2) {
        display: block;
        flex: 1;
        min-width: 0;
    }

    #currenciesTable tbody tr[data-id] td.td-actions,
    #pairsTable tbody tr[data-id] td.td-actions,
    .table-drag-ghost[data-source-table-id="currenciesTable"] tbody tr.dragging td.td-actions,
    .table-drag-ghost[data-source-table-id="pairsTable"] tbody tr.dragging td.td-actions {
        display: flex;
        flex-direction: row;
        justify-content: center;
        align-items: stretch;
        gap: 6px;
        flex: 0 0 auto;
        min-width: 86px;
    }

    #currenciesTable tbody tr[data-id] td.td-actions .btn,
    #pairsTable tbody tr[data-id] td.td-actions .btn,
    .table-drag-ghost[data-source-table-id="currenciesTable"] tbody tr.dragging td.td-actions .btn,
    .table-drag-ghost[data-source-table-id="pairsTable"] tbody tr.dragging td.td-actions .btn {
        width: 40px;
        min-width: 40px;
        height: 40px;
        padding: 0;
        justify-content: center;
    }

    #currenciesTable tbody tr[data-id] td.td-actions .btn .icon,
    #pairsTable tbody tr[data-id] td.td-actions .btn .icon,
    .table-drag-ghost[data-source-table-id="currenciesTable"] tbody tr.dragging td.td-actions .btn .icon,
    .table-drag-ghost[data-source-table-id="pairsTable"] tbody tr.dragging td.td-actions .btn .icon {
        margin-right: 0 !important;
    }

    #currenciesTable .currency-mobile-line-1,
    .table-drag-ghost[data-source-table-id="currenciesTable"] .currency-mobile-line-1 {
        display: flex;
        align-items: center;
        gap: 8px;
        flex-wrap: wrap;
        margin-bottom: 4px;
    }

    #currenciesTable .currency-mobile-name,
    .table-drag-ghost[data-source-table-id="currenciesTable"] .currency-mobile-name {
        font-weight: 700;
        color: var(--text);
        min-width: 0;
    }

    #currenciesTable .currency-mobile-tag,
    .table-drag-ghost[data-source-table-id="currenciesTable"] .currency-mobile-tag {
        display: inline-flex;
        align-items: center;
        padding: 1px 6px;
        border: 1px solid var(--border);
        border-radius: 999px;
        font-size: .72rem;
        line-height: 1.3;
        color: var(--text2);
        background: var(--surface2);
    }

    #currenciesTable .currency-mobile-line-2,
    .table-drag-ghost[data-source-table-id="currenciesTable"] .currency-mobile-line-2 {
        display: block;
        font-size: .8rem;
        color: var(--text2);
    }

    #pairsTable .pair-mobile-summary,
    .table-drag-ghost[data-source-table-id="pairsTable"] .pair-mobile-summary {
        display: block;
    }

    #pairsTable .pair-base-text,
    .table-drag-ghost[data-source-table-id="pairsTable"] .pair-base-text {
        display: none;
    }

    #pairsTable .pair-mobile-line-1,
    .table-drag-ghost[data-source-table-id="pairsTable"] .pair-mobile-line-1 {
        font-weight: 700;
        color: var(--text);
        margin-bottom: 4px;
    }

    #pairsTable .pair-mobile-line-2,
    .table-drag-ghost[data-source-table-id="pairsTable"] .pair-mobile-line-2 {
        display: block;
        font-size: .8rem;
        color: var(--text2);
    }

    #accountsTable tbody tr[data-id] {
        display: flex;
        align-items: stretch;
        justify-content: space-between;
        gap: 10px;
        padding: 10px 0;
    }

    .table-drag-ghost[data-source-table-id="accountsTable"] tbody tr.dragging {
        display: flex;
        align-items: stretch;
        justify-content: space-between;
        gap: 10px;
        padding: 10px 0;
    }

    #accountsTable tbody tr[data-id] td {
        padding: 0;
    }

    .table-drag-ghost[data-source-table-id="accountsTable"] tbody tr.dragging td {
        padding: 0;
    }

    #accountsTable tbody tr[data-id] td:nth-child(2) {
        display: block;
        flex: 1;
        min-width: 0;
    }

    .table-drag-ghost[data-source-table-id="accountsTable"] tbody tr.dragging td:nth-child(2) {
        display: block;
        flex: 1;
        min-width: 0;
    }

    #accountsTable tbody tr[data-id] td.td-actions {
        display: flex;
        flex-direction: row;
        justify-content: center;
        align-items: stretch;
        gap: 6px;
        flex: 0 0 auto;
        min-width: 86px;
    }

    .table-drag-ghost[data-source-table-id="accountsTable"] tbody tr.dragging td.td-actions {
        display: flex;
        flex-direction: row;
        justify-content: center;
        align-items: stretch;
        gap: 6px;
        flex: 0 0 auto;
        min-width: 86px;
    }

    #accountsTable tbody tr[data-id] td.td-actions .btn {
        width: 40px;
        min-width: 40px;
        height: 40px;
        padding: 0;
        justify-content: center;
    }

    .table-drag-ghost[data-source-table-id="accountsTable"] tbody tr.dragging td.td-actions .btn {
        width: 40px;
        min-width: 40px;
        height: 40px;
        padding: 0;
        justify-content: center;
    }

    #accountsTable tbody tr[data-id] td.td-actions .btn .icon {
        margin-right: 0 !important;
    }

    .table-drag-ghost[data-source-table-id="accountsTable"] tbody tr.dragging td.td-actions .btn .icon {
        margin-right: 0 !important;
    }

    #accountsTable .account-mobile-line-1 {
        display: flex;
        align-items: center;
        gap: 6px;
        flex-wrap: wrap;
        margin-bottom: 4px;
    }

    .table-drag-ghost[data-source-table-id="accountsTable"] .account-mobile-line-1 {
        display: flex;
        align-items: center;
        gap: 6px;
        flex-wrap: wrap;
        margin-bottom: 4px;
    }

    #accountsTable .account-mobile-name {
        font-weight: 600;
        color: var(--text);
        min-width: 0;
    }

    #accountsTable .account-mobile-chip {
        display: inline-flex;
    }

    #accountsTable .settings-entity-name-inactive .account-mobile-name {
        color: var(--text3);
    }

    .table-drag-ghost[data-source-table-id="accountsTable"] .account-mobile-name {
        font-weight: 600;
        color: var(--text);
        min-width: 0;
    }

    .table-drag-ghost[data-source-table-id="accountsTable"] .account-mobile-chip {
        display: inline-flex;
    }

    .table-drag-ghost[data-source-table-id="accountsTable"] .settings-entity-name-inactive .account-mobile-name {
        color: var(--text3);
    }

    #accountsTable .account-mobile-line-2 {
        display: flex;
        align-items: center;
        justify-content: space-between;
        gap: 10px;
        font-size: .8rem;
    }

    .table-drag-ghost[data-source-table-id="accountsTable"] .account-mobile-line-2 {
        display: flex;
        align-items: center;
        justify-content: space-between;
        gap: 10px;
        font-size: .8rem;
    }

    #accountsTable .account-mobile-balance {
        text-align: right;
    }

    .table-drag-ghost[data-source-table-id="accountsTable"] .account-mobile-balance {
        text-align: right;
    }

    #accountsTable .account-mobile-link-note {
        display: block;
        margin-top: 4px;
    }

    .table-drag-ghost[data-source-table-id="accountsTable"] .account-mobile-link-note {
        display: block;
        margin-top: 4px;
    }
}


/* ── Bank group header rows in accounts table ─────────────────────────────── */
tr.bank-group-header td {
    background: var(--surface2);
    padding: 6px 14px;
    border-bottom: 1px solid var(--border);
}

.bank-group-label {
    font-size: 0.86rem;
    font-weight: 600;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    color: #fff;
}

/* ── Full-width slot (sits between topbar and main-content, no max-width cap) */
/* position:sticky here (not on children) — the child div is the same height,
   so sticky on a child never activates; the wrapper is inside the tall .main-wrap */
.main-full-width {
    width: 100%;
    position: sticky;
    top: var(--topbar-h);
    z-index: 48;
}

/* ── Balance bar ─────────────────────────────────────────────────────────── */
.balance-bar {
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    padding: 10px 14px 14px;
}

.balance-bar-scroll {
    overflow-x: auto;
    /* hide scrollbar but keep scrollable */
    scrollbar-width: thin;
    scrollbar-color: var(--border) transparent;
}

.balance-bar-scroll::-webkit-scrollbar {
    height: 4px;
}

.balance-bar-scroll::-webkit-scrollbar-track {
    background: transparent;
}

.balance-bar-scroll::-webkit-scrollbar-thumb {
    background: var(--border);
    border-radius: 2px;
}

.balance-bar-inner {
    display: flex;
    gap: 10px;
    min-width: max-content;
    padding-bottom: 2px;
}

.balance-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 12px 14px;
    min-width: 200px;
    max-width: 240px;
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
}

.balance-bank {
    display: flex;
    align-items: center;
    gap: 0;
    font-size: .72rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .05em;
    color: var(--text2);
    margin-bottom: 8px;
    padding-bottom: 6px;
    border-bottom: 1px solid var(--border);
}

.balance-bank-icon {
    width: 16px;
    height: 16px;
    object-fit: contain;
    border-radius: 3px;
    flex-shrink: 0;
}

.balance-bank-emoji {
    font-size: 13px;
    line-height: 1;
    flex-shrink: 0;
}

.balance-bank-icon, .balance-bank-emoji {
    margin-right: 5px;
}

.balance-row {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    gap: 6px;
    padding: 2px 0;
}

.balance-acc-name {
    font-size: .78rem;
    color: var(--text2);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    max-width: 100px;
}

.balance-amount {
    font-size: .82rem;
    font-weight: 600;
    white-space: nowrap;
    font-variant-numeric: tabular-nums;
}

.balance-amount.positive {
    color: var(--income);
}

.balance-amount.negative {
    color: var(--expense);
}

.balance-cur-tag {
    display: inline-block;
    margin-left: 0;
    margin-top: -1px;
    font-size: .6em;
    font-weight: 700;
    color: var(--text2);
    background: var(--surface3);
    border: 1px solid var(--border);
    border-radius: 3px;
    padding: 0 4px;
    vertical-align: middle;
    letter-spacing: .03em;
    opacity: .8;
}

.balance-stocks-chip {
    display: inline-block;
    margin-left: 6px;
    padding: 1px 6px;
    border-radius: 999px;
    border: 1px solid var(--border);
    background: var(--surface3);
    color: var(--text2);
    font-size: .65rem;
    line-height: 1.2;
}

.balance-total {
    margin-top: auto;
    padding-top: 6px;
    border-top: 1px solid var(--border);
    font-size: .78rem;
    font-weight: 700;
    color: var(--text);
    text-align: right;
}

/* ── Filters row ─────────────────────────────────────────────────────────── */
.filters-row {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    align-items: center;
    margin-bottom: 8px;
}

/* Only direct children of .filters-row get flex sizing (not nested .filter-ms-btn etc.) */
.filters-row > .form-control,
.filters-row > .form-control-sm {
    flex: 1;
    min-width: 80px;
    width: 0;
    height: 32px;
    padding: 0 8px;
    font-size: .82rem;
    box-sizing: border-box;
    line-height: 32px;
}

.filters-row > .btn {
    height: 32px;
    padding-top: 0;
    padding-bottom: 0;
}

/* Date inputs */
#filterFrom, #filterTo {
    flex: 1.1;
    min-width: 110px;
}

/* Order toggle — compact */
#filterOrder {
    flex: 0 0 auto;
    min-width: 90px;
    justify-content: center;
    margin: 0 0 0 10px;
    padding: 0;
    font-weight: 400;
}

/* Search field stretches more */
.filters-row > .filter-search {
    flex: 2;
    min-width: 100px;
}


/* ── Category + Subcategory multi-select dropdown ────────────────────────── */
.filter-ms-wrap {
    position: relative;
    flex: 1;
    min-width: 100px;
    width: 0;
    height: 32px;
}

.filter-ms-wrap.filter-ms-open {
    z-index: 10020;
}

#filterTaxWrap {
    min-width: 50px;
    max-width: 50px;
}

.filter-ms-btn {
    width: 100%;
    height: 32px;
    padding: 0 8px;
    font-size: .82rem;
    line-height: 32px;
    text-align: left;
    cursor: pointer;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    background: var(--surface2);
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 24 24' fill='none' stroke='%239198b5' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M6 9l6 6l6-6'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 8px center;
    border: 1px solid var(--border);
    border-radius: 6px;
    color: var(--text);
    user-select: none;
    box-sizing: border-box;
    padding-right: 24px;
}

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

.filter-ms-dropdown {
    position: absolute;
    top: calc(100% + 3px);
    left: 0;
    min-width: min(230px, calc(100vw - 24px));
    max-width: min(300px, calc(100vw - 24px));
    background: var(--surface2);
    border: 1px solid var(--border);
    border-radius: 8px;
    z-index: 600;
    box-shadow: 0 8px 28px rgba(0, 0, 0, .4);
    max-height: 340px;
    overflow-y: auto;
    overflow-x: hidden;
    box-sizing: border-box;
    overscroll-behavior: contain;
}

.filter-ms-wrap.filter-ms-open .filter-ms-dropdown {
    z-index: 10021;
}

.filter-ms-dropdown.drop-up {
    top: auto;
    bottom: calc(100% + 3px);
}

.filter-ms-topbar {
    display: flex;
    gap: 6px;
    align-items: center;
    padding: 8px 8px 6px;
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    background: var(--surface2);
    z-index: 1;
}

.filter-ms-search {
    flex: 1;
    padding: 4px 8px;
    font-size: .82rem;
    min-width: 0;
}

.filter-ms-clear-all {
    font-size: .75rem;
    padding: 3px 8px;
    background: none;
    border: 1px solid var(--border);
    border-radius: 4px;
    cursor: pointer;
    color: var(--text-muted);
    white-space: nowrap;
    flex-shrink: 0;
    transition: color var(--transition), border-color var(--transition);
}

.filter-ms-clear-all:hover {
    color: var(--danger);
    border-color: var(--danger);
}

.filter-ms-section-header {
    display: flex;
    align-items: center;
    padding: 7px 10px 4px;
    font-size: .70rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .07em;
    color: var(--text-muted);
    border-bottom: 1px solid var(--border);
    background: var(--surface2);
    cursor: pointer;
}

.filter-ms-section-header:hover {
    background: var(--surface3);
    color: var(--text);
}

.filter-ms-group-cb {
    margin: 0;
    accent-color: var(--accent);
    width: 14px;
    height: 14px;
    cursor: pointer;
}

.filter-ms-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 5px 12px;
    cursor: pointer;
    font-size: .82rem;
    transition: background var(--transition);
}

.filter-ms-item:hover {
    background: var(--surface3);
}

.filter-ms-item-indented {
    padding-left: 30px;
}

.filter-ms-item-indented .filter-ms-item-text {
    font-size: 0.8rem;
    opacity: 0.9;
}

.filter-ms-item-icon {
    width: 16px;
    height: 16px;
    object-fit: contain;
    margin-right: 8px;
    border-radius: 2px;
}

.filter-ms-item input[type="checkbox"] {
    margin: 0;
    width: 14px;
    height: 14px;
    flex-shrink: 0;
    accent-color: var(--accent);
    cursor: pointer;
}

.filter-ms-item-text {
    flex: 1;
}

/* Show Change rates row */
.filters-row-extra {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 8px 0 0px;
}

.filter-show-rates-label {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: .82rem;
    cursor: pointer;
    color: var(--text-muted);
    user-select: none;
    transition: color var(--transition);
}

.filter-show-rates-label:hover {
    color: var(--text);
}

.filter-show-rates-label input[type="checkbox"],
.filter-selection-label input[type="checkbox"] {
    margin: 0;
    accent-color: var(--accent);
    cursor: pointer;
    width: 16px;
    height: 16px;
}

.filter-selection-label {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: .82rem;
    cursor: pointer;
    color: var(--text2);
    user-select: none;
    transition: color var(--transition);
}

.filter-selection-label:hover {
    color: var(--text);
}

.bookmark-tools {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    order: 2;
    margin-left: auto;
    flex-shrink: 0;
}

.bookmark-filter-wrap {
    display: inline-flex;
    align-items: center;
    gap: 8px;
}

.filter-bookmarks-toggle {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 38px;
    padding-inline: 10px;
}

.bookmark-nav {
    display: inline-flex;
    align-items: center;
    gap: 0;
}

.bookmark-nav > .btn:first-child {
    border-top-right-radius: 0;
    border-bottom-right-radius: 0;
}

.bookmark-nav > .btn:last-child {
    border-top-left-radius: 0;
    border-bottom-left-radius: 0;
}

.bookmark-nav.is-empty {
    opacity: .55;
}

.bookmark-nav-count {
    min-width: 24px;
    color: var(--text2);
    font-size: .82rem;
    text-align: center;
}

.filters-extra-divider {
    width: 1px;
    height: 14px;
    background: var(--border);
    margin: 0 4px;
}

/* Hide rate-change banners when toggle is off */
#txList {
    padding-bottom: 80px;
}

#txList.hide-rate-banners .tx-rate-change {
    display: none;
}

/* Active filter highlight */
.filters-row .filter-active,
.filters-row-extra .filter-active,
.filter-ms-clear-all.filter-active {
    border-color: var(--accent);
    background: rgba(108, 99, 255, .12);
    color: var(--text);
}

.filter-ms-btn.filter-active {
    border-color: var(--accent);
    background: rgba(108, 99, 255, .12);
    color: var(--text);
}

/* Highlight for filter button when changes are pending */
.btn-filter-highlight {
    border-color: var(--success) !important;
    box-shadow: 0 0 0 2px rgba(76, 175, 80, 0.25);
}

.amt-decimal {
    /*color: var(--text3);*/
    font-size: 0.7em;
}

/* Filter / Clear buttons — don't stretch */
#btnFilter, #btnClearFilter {
    flex: none;
}

/* Clear button — visible only when filters active */
#btnClearFilter {
    display: none;
    background: rgba(255, 92, 92, .12);
    border-color: var(--danger);
    color: var(--danger);
}

#btnClearFilter:hover {
    background: rgba(255, 92, 92, .22);
}

#btnClearFilter.visible {
    display: inline-flex;
}

/* ── Transaction day header ──────────────────────────────────────────────── */
.tx-day-wrap {
    display: flex;
    flex-direction: column;
    max-width: 1200px;
    margin: 0 auto;
}

.tx-day-wrap:first-child .tx-day-header {
    margin-top: 0;
}

.tx-day-header {
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 5px 22px 6px;
    /* margin-top: 8px; */
    /* margin-left: -24px; */
    /* margin-right: -24px; */
    position: sticky;
    top: calc(var(--topbar-h) + var(--balance-bar-h, 0px) + var(--tx-filters-h, 0px));
    z-index: 40;
    background: #1a1d279e;
    max-width: 200px;
    margin: 30px auto 15px;
    border-radius: 27px;
}

.tx-day-label {
    font-size: .78rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .05em;
    color: var(--text2);
}


.tx-day-group {
    display: flex;
    flex-direction: column;
    gap: 6px;
    margin-bottom: 6px;
}

.tx-rate-change {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    color: var(--text3);
    letter-spacing: .03em;
    white-space: normal;
    overflow-wrap: anywhere;
    gap: 8px;
    padding: 14px 0;
    font-size: .92rem;
    line-height: 1.35;
}

.tx-rate-change::before,
.tx-rate-change::after {
    content: '';
    flex: 1 1 80px;
    min-width: 24px;
    height: 1px;
    background: var(--border);
}

/* ── Transaction card ────────────────────────────────────────────────────── */
.tx-card {
    display: grid;
    grid-template-columns: 22px 1fr auto;
    align-items: center;
    gap: 10px;
    /*background: var(--surface);*/
    /*background: linear-gradient(360deg, var(--surface), transparent);*/
    background: linear-gradient(356deg, #1a1d27ad, transparent);
    border-bottom: 1px solid var(--surface2);
    border-radius: var(--radius);
    padding: 0 10px;
    transition: background var(--transition), border-color var(--transition);
}

.tx-card:hover {
    background: var(--surface2);
    border-color: var(--surface3);
}

:root[data-theme="light"] .tx-day-header {
    background: #b9bac170;
}

:root[data-theme="light"] .tx-card {
    background: linear-gradient(356deg, #dadadaad, transparent);
}

/*.tx-card.tx-positive,*/
/*.tx-card.tx-negative {*/
/*  background: var(--surface);*/
/*}*/


/*.tx-card.tx-positive { border-color: rgba(52,199,89,.25); }*/
/*.tx-card.tx-negative { border-color: rgba(255,69,58,.2); }*/
/*.tx-card.tx-positive:hover { border-color: rgba(52,199,89,.4); }*/
/*.tx-card.tx-negative:hover { border-color: rgba(255,69,58,.35); }*/

.tx-left {
    flex: 1;
    min-width: 0;
    align-self: stretch;
    display: flex;
    flex-direction: column;
    justify-content: center;
    cursor: pointer;
    border-radius: 6px;
    padding: 2px 6px 6px 6px;
    margin: 0 -6px;
}

.tx-card:hover .tx-left:hover .tx-category {
    color: var(--accent);
}

.tx-category {
    transition: color var(--transition);
    font-size: 1rem;
    font-weight: 600;
    color: var(--text);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.tx-subcategory {
    color: var(--text2);
    font-weight: 400;
}

.tx-tax-badge {
    font-size: .65rem;
    padding: 0 5px 2px;
    vertical-align: middle;
    margin-left: 6px;
    position: relative;
    top: -1px;
}

.tx-project-badge {
    font-size: .6rem;
    /*padding: 1px 5px;*/
    vertical-align: middle;
    margin-left: 6px;
    position: relative;
    top: -1px;
    background: rgb(205 190 15 / 12%);
    color: #b8b53c;
    border: 1px solid rgb(52 199 119 / 35%);
}

/* Rate-change badge on transaction cards */
.tx-rate-badge {
    font-size: .6rem;
    padding: 1px 4px;
    vertical-align: middle;
    margin-left: 5px;
    position: relative;
    top: -1px;
    background: rgba(108, 99, 255, .12);
    color: var(--accent);
    border: 1px solid rgba(108, 99, 255, .3);
    cursor: default;
}

/* Highlighted form-group for a changed exchange rate */
.rate-changed-fg {
    position: relative;
    border-radius: 6px;
    padding: 6px 8px !important;
    background: rgba(108, 99, 255, .06);
    border: 1px solid rgba(108, 99, 255, .3) !important;
}

/* Reset icon button next to a changed rate */
.btn-reset-rate {
    position: absolute;
    top: 4px;
    right: 4px;
    background: none;
    border: none;
    cursor: pointer;
    color: var(--text3);
    font-size: .9rem;
    padding: 0 3px;
    line-height: 1;
    border-radius: 3px;
    transition: color var(--transition);
}

.btn-reset-rate:hover {
    color: var(--danger, #ef4444);
}

.tx-meta {
    display: flex;
    align-items: center;
    gap: 6px;
    /*margin-top: 3px;*/
    flex-wrap: wrap;
}

.tx-meta:empty {
    display: none;
}

.tx-right {
    display: flex;
    align-items: center;
    gap: 15px;
    justify-content: flex-end;
}

.tx-comment {
    font-size: .9rem;
    color: var(--text2);
    white-space: normal;
    line-height: 1;
    padding-top: 6px;
}

.tx-legs {
    display: flex;
    flex-direction: column;
    gap: 0;
    text-align: right;
    width: 400px;
    min-width: 0;
    flex-shrink: 0;
    padding: 0;
}

.tx-leg {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    gap: 12px;
}

.tx-leg-account {
    color: var(--text2);
    font-weight: 500;
    max-width: 180px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: .85em;
}

.tx-leg-account-icon {
    width: 14px;
    height: 14px;
    object-fit: contain;
    margin-right: 4px;
    flex-shrink: 0;
    border-radius: 2px;
    opacity: 0.8;
}

.tx-leg-account-emoji {
    margin-right: 4px;
    font-size: 0.9em;
    flex-shrink: 0;
    opacity: 0.8;
}

.tx-leg-amount {
    font-size: .9rem;
    font-weight: 600;
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
    min-width: 90px;
    text-align: right;
}

.tx-leg-amount.positive {
    color: var(--income);
}

.tx-leg-amount.negative {
    color: var(--expense);
}

/* Pending confirm button on tx card */
.tx-pending-confirm {
    flex-shrink: 0;
    align-self: center;
    opacity: 0;
    transition: opacity var(--transition);
}

.tx-card:hover .tx-pending-confirm {
    opacity: 1;
}

/* Result column — total EUR */
.tx-result {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    flex-shrink: 0;
    min-width: 80px;
    padding: 6px 0;
}

.tx-result-amount {
    font-size: .6rem;
    font-weight: 700;
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
}

.tx-result-amount.positive {
    color: var(--income);
}

.tx-result-amount.negative {
    color: var(--expense);
}

/* ── Drag handle ────────────────────────────────────────────────────────── */
.tx-drag-handle {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 3px;
    flex-shrink: 0;
    width: 22px;
    cursor: default;
    user-select: none;
    position: relative;
}

/* Checkbox — visible on hover or when card is selected */
.tx-select-check {
    width: 14px;
    height: 14px;
    margin: 0;
    cursor: pointer;
    accent-color: var(--accent);
    opacity: 0;
    transition: opacity var(--transition);
    flex-shrink: 0;
}

.tx-card:hover .tx-select-check,
.tx-card.tx-selected .tx-select-check {
    opacity: 1;
}

/* Drag icon — visible on hover */
.tx-drag-icon {
    font-size: 1.1rem;
    color: var(--text3);
    cursor: grab;
    opacity: 0;
    transition: opacity var(--transition);
    line-height: 1;
}

.tx-card:hover .tx-drag-icon {
    opacity: 1;
}

.tx-drag-icon:active {
    cursor: grabbing;
}

/* Selected card highlight */
.tx-card.tx-card-focus-target {
    box-shadow: 0 0 0 2px rgba(120, 162, 255, .65), 0 0 18px rgba(120, 162, 255, .22);
    transition: box-shadow .2s ease;
}

.tx-card.tx-selected {
    border-color: var(--accent);
    background: rgba(108, 99, 255, .07);
}

.tx-card.tx-selected:hover {
    background: rgba(108, 99, 255, .12);
}

.tx-card.tx-dragging {
    position: absolute;
    z-index: 9999;
    opacity: .85;
    box-shadow: 0 8px 32px rgba(0, 0, 0, .5);
    pointer-events: none;
    border-color: var(--accent);
}

.tx-card.tx-bookmarked {
    box-shadow: inset 3px 0 0 #f59e0b;
}

.tx-bookmark-toggle {
    width: 24px;
    height: 24px;
    padding: 0;
    border: 0;
    background: transparent;
    color: var(--text3);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    border-radius: 6px;
    transition: background var(--transition), color var(--transition), transform var(--transition);
}

.tx-bookmark-toggle:hover {
    background: rgba(245, 158, 11, .12);
    color: #f59e0b;
}

.tx-bookmark-toggle.is-active {
    color: #f59e0b;
}

.tx-bookmark-toggle:focus-visible {
    outline: 2px solid rgba(245, 158, 11, .35);
    outline-offset: 1px;
}

.tx-bookmark-icon {
    width: 12px;
    height: 16px;
    background: currentColor;
    clip-path: polygon(0 0, 100% 0, 100% 100%, 50% 76%, 0 100%);
    opacity: .8;
}

.tx-bookmark-toggle.is-active .tx-bookmark-icon {
    opacity: 1;
}

.tx-drag-placeholder {
    background: var(--surface2);
    border: 2px dashed var(--accent);
    opacity: .4;
}

/* ── Bulk-edit FAB ──────────────────────────────────────────────────────── */
.fab-bulk-edit {
    position: fixed;
    bottom: 96px;
    right: 28px;
    z-index: 201;
    width: 56px;
    height: 56px;
    border-radius: 50%;
    background: var(--surface2);
    color: var(--text);
    font-size: 1.3rem;
    border: 1px solid var(--border);
    box-shadow: 0 4px 18px rgba(0, 0, 0, .35);
    cursor: pointer;
    display: none;
    align-items: center;
    justify-content: center;
    gap: 3px;
    transition: background var(--transition), transform .15s, box-shadow var(--transition), border-color var(--transition);
}

.fab-bulk-edit.fab-bulk-visible {
    display: flex;
}

.fab-bulk-edit:hover {
    background: var(--surface3);
    border-color: var(--accent);
    transform: scale(1.08);
    box-shadow: 0 6px 24px rgba(0, 0, 0, .45);
}

.fab-bulk-edit:active {
    transform: scale(.96);
}

#fabBulkCount {
    font-size: .72rem;
    font-weight: 700;
    min-width: 14px;
    text-align: center;
}

/* Floating selection summary */
.bulk-selection-summary {
    position: fixed;
    bottom: 5px;
    left: 50%;
    transform: translateX(-50%) translateY(20px);
    z-index: 200;
    background: var(--surface2);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 0 18px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, .35);
    display: none;
    align-items: center;
    gap: 14px;
    font-size: .9rem;
    opacity: 0;
    transition: opacity .2s, transform .2s;
}

.bulk-selection-summary.bss-visible {
    display: flex;
    opacity: 1;
    transform: translateX(-50%) translateY(0);
}

.bss-count {
    color: var(--text2);
    font-size: .8rem;
}

.bss-total {
    font-weight: 700;
    font-size: 1.05rem;
}

.bss-total.positive {
    color: var(--green);
}

.bss-total.negative {
    color: var(--red);
}

.bss-total small {
    font-weight: 400;
    font-size: .75rem;
    color: var(--text3);
    margin-left: 2px;
}

.bss-clear {
    width: 24px;
    height: 24px;
    border: 1px solid var(--border);
    border-radius: 999px;
    background: transparent;
    color: var(--text2);
    cursor: pointer;
    font-size: .82rem;
    font-weight: 700;
    line-height: 1;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: background-color .15s ease, color .15s ease, border-color .15s ease;
}

.bss-clear:hover {
    background: var(--surface3);
    color: var(--text);
}

.bulk-field-is-mixed input::placeholder {
    color: var(--text3);
    font-style: italic;
}

/* Highlight changed fields in bulk edit */
.bulk-field-changed .form-control,
.bulk-field-changed .filter-ms-btn,
.bulk-field-changed .autocomplete-input,
.bulk-field-changed select {
    border-color: var(--danger) !important;
    background-color: rgba(255, 92, 92, 0.05) !important;
    box-shadow: 0 0 0 3px rgba(255, 92, 92, 0.1) !important;
}

.bulk-field-changed-label {
    color: var(--danger) !important;
}

/* ── Bulk action menu popup ─────────────────────────────────────────────── */
.bulk-menu {
    position: fixed;
    z-index: 300;
    background: var(--surface2);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: 0 8px 28px rgba(0, 0, 0, .45);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    min-width: 170px;
}

.bulk-menu-item {
    display: block;
    width: 100%;
    padding: 11px 16px;
    text-align: left;
    background: none;
    border: none;
    cursor: pointer;
    font-size: .88rem;
    color: var(--text);
    transition: background var(--transition), color var(--transition);
    border-bottom: 1px solid var(--border);
}

.bulk-menu-item:last-child {
    border-bottom: none;
}

.bulk-menu-item:hover {
    background: var(--surface3);
}

.bulk-menu-item.bulk-menu-danger:hover {
    color: var(--danger);
}

/* ── Bulk edit field states ──────────────────────────────────────────────── */
.bulk-field-disabled input,
.bulk-field-disabled select,
.bulk-field-disabled .form-control {
    opacity: .45;
    cursor: pointer;
    border-style: dashed;
}

.bulk-field-forced input,
.bulk-field-forced select,
.bulk-field-forced .form-control {
    border-color: var(--danger) !important;
    background: rgba(255, 92, 92, .06) !important;
}

/* ── Bulk confirm overlay ───────────────────────────────────────────────── */
.bulk-confirm-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, .6);
    z-index: 9999;
    display: flex;
    align-items: center;
    justify-content: center;
}

.bulk-confirm-box {
    background: var(--surface2);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 28px 32px;
    max-width: 420px;
    width: 90%;
    box-shadow: 0 12px 40px rgba(0, 0, 0, .6);
}

.bulk-confirm-box p {
    margin: 0 0 20px;
    line-height: 1.5;
}

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

/* Currency tag after account name in tx leg */
.tx-leg-cur-tag {
    display: inline-block;
    margin-left: 5px;
    font-size: .65rem;
    font-weight: 700;
    color: var(--text3);
    background: var(--surface3);
    border: 1px solid var(--border);
    border-radius: 3px;
    padding: 1px 4px;
    line-height: 1;
    vertical-align: middle;
    letter-spacing: .03em;
    opacity: .8;
}

/* ── Import Preview Table ───────────────────────────────────────────────── */
.import-preview-wrap {
    margin-top: 20px;
    border-top: 1px solid var(--border);
    padding-top: 16px;
}

.import-preview-table-wrap {
    max-height: 400px;
    overflow-y: auto;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    margin-top: 10px;
    background: var(--surface);
}

.import-preview-table-wrap .import-sample-table {
    margin: 0;
    border: none;
    font-size: 0.82rem;
}

.import-preview-table-wrap thead tr {
    position: sticky;
    top: 0;
    z-index: 10;
    background: var(--surface2);
    box-shadow: 0 1px 0 var(--border);
}

.import-preview-table-wrap td {
    padding: 8px 12px;
    border-bottom: 1px solid var(--border);
}

.import-preview-table-wrap tr:last-child td {
    border-bottom: none;
}

/* ── Running balance after transaction ──────────────────────────────────── */
.tx-leg-amt-group {
    display: flex;
    align-items: baseline;
    justify-content: flex-end;
    gap: 0;
}

.tx-leg-balance {
    font-size: .72rem;
    color: var(--text2);
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
    opacity: .75;
    min-width: 100px;
    text-align: left;
    padding-left: 8px;
}

/* ── Floating action button (FAB) ───────────────────────────────────────── */
.fab-add-tx {
    position: fixed;
    padding: 0 0 3px 0;
    bottom: 28px;
    right: 28px;
    z-index: 200;
    width: 56px;
    height: 56px;
    border-radius: 50%;
    background: var(--accent);
    color: #fff;
    font-size: 1.8rem;
    line-height: 1;
    border: none;
    box-shadow: 0 4px 20px rgba(108, 99, 255, .5);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background var(--transition), transform .15s, box-shadow var(--transition);
}

.fab-add-tx:hover {
    background: var(--accent2);
    transform: scale(1.08);
    box-shadow: 0 6px 28px rgba(108, 99, 255, .65);
}

.fab-add-tx:active {
    transform: scale(.96);
}

.assistant-quick-btn {
    border: 1px solid var(--border);
    background: var(--surface);
    color: var(--text);
    width: 38px;
    height: 38px;
    border-radius: 999px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    box-shadow: var(--shadow);
}

.assistant-quick-btn:hover {
    background: var(--surface2);
}

.assistant-drawer-overlay {
    position: fixed;
    inset: 0;
    background: rgba(5, 8, 14, .45);
    opacity: 0;
    pointer-events: none;
    transition: opacity .2s ease;
    z-index: 1000;
}

.assistant-drawer-overlay.open {
    opacity: 1;
    pointer-events: auto;
}

.assistant-drawer {
    position: fixed;
    top: 0;
    right: 0;
    width: min(460px, 100vw);
    height: 100vh;
    background: var(--surface);
    border-left: 1px solid var(--border);
    transform: translateX(100%);
    transition: transform .22s ease;
    z-index: 1001;
    display: flex;
    flex-direction: column;
}

.assistant-drawer.open {
    transform: translateX(0);
}

.assistant-drawer-close-float {
    position: absolute;
    top: 6px;
    right: 6px;
    z-index: 4;
    background: none;
    border: 1px transparent;
}

.assistant-drawer-header,
.assistant-drawer-footer {
    padding: 6px;
    border-bottom: 1px solid var(--border);
    position: sticky;
    background: var(--surface);
    z-index: 2;
}

.assistant-drawer-header {
    top: 0;
}

.assistant-drawer-footer {
    bottom: 0;
    border-top: 1px solid var(--border);
    border-bottom: 0;
}

.assistant-drawer-title {
    font-weight: 800;
    display: flex;
    align-items: center;
    gap: 8px;
    padding-right: 44px;
}

.assistant-drawer-actions .btn-icon,
#assistantStartNewBtn {
    padding: 0 9px;
}

.assistant-drawer-actions .btn-icon .icon,
.assistant-drawer-title .icon {
    width: 24px;
    height: 24px;
}

.assistant-drawer-actions {
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.assistant-drawer-subtitle {
    font-size: .85rem;
    color: var(--text2);
}

.assistant-conversations-panel {
    padding: 10px 12px;
    border-bottom: 1px solid var(--border);
    background: var(--surface2);
}

.assistant-conversations-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
    max-height: 220px;
    overflow: auto;
}

.assistant-conversation-item {
    width: 100%;
    border: 1px solid rgba(130, 147, 211, .18);
    background: rgba(255, 255, 255, .03);
    color: inherit;
    border-radius: 10px;
    padding: 10px 12px;
    display: flex;
    flex-direction: column;
    gap: 6px;
    cursor: pointer;
}

.assistant-conversation-item:hover {
    border-color: rgba(130, 147, 211, .34);
    background: rgba(255, 255, 255, .045);
}

.assistant-conversation-item.active {
    border-color: rgba(99, 179, 237, .45);
    background: rgba(61, 127, 196, .14);
}

.assistant-conversation-top {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 10px;
}

.assistant-conversation-open {
    appearance: none;
    flex: 1 1 auto;
    min-width: 0;
    padding: 0;
    border: 0;
    background: transparent;
    color: inherit;
    text-align: left;
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 10px;
    cursor: pointer;
}

.assistant-conversation-title {
    font-weight: 700;
    line-height: 1.25;
}

.assistant-conversation-remove {
    flex: 0 0 auto;
}

.assistant-conversation-time {
    font-size: .72rem;
    color: var(--text3);
    white-space: nowrap;
}

.assistant-conversation-preview {
    font-size: .82rem;
    color: var(--text2);
    line-height: 1.35;
}

.assistant-conversation-meta {
    font-size: .72rem;
    color: var(--text3);
}

.assistant-conversations-empty {
    font-size: .82rem;
    color: var(--text2);
    padding: 4px 2px;
}

.assistant-drawer-body {
    flex: 1;
    min-height: 0;
    overflow: auto;
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.assistant-msg-row {
    display: flex;
    align-items: flex-end;
    gap: 6px;
}

.assistant-msg-row-user {
    justify-content: flex-end;
}

.assistant-msg-row-assistant {
    justify-content: flex-start;
    box-sizing: border-box;
}

.assistant-msg-meta {
    display: flex;
    flex-direction: column;
    gap: 3px;
    padding-bottom: 4px;
}

.assistant-msg-time {
    font-size: .72rem;
    line-height: 1;
    color: var(--text3);
    opacity: .8;
    white-space: nowrap;
}

.assistant-msg-elapsed {
    font-size: .68rem;
    line-height: 1;
    color: var(--text3);
    opacity: .72;
    white-space: nowrap;
}

.assistant-msg {
    padding: 10px 12px;
    border-radius: 14px;
    background: #1b2131;
    border: 1px solid #2b334a;
    white-space: normal;
}

.assistant-msg-text {
    white-space: pre-wrap;
}

.assistant-msg-speaker {
    font-size: .72rem;
    font-weight: 700;
    color: var(--text3);
    margin-bottom: 4px;
    text-transform: none;
}

.assistant-msg-user {
    background: #20345a;
    border-color: #35598f;
    max-width: 90%;
}

.assistant-msg-assistant {
    width: 100%;
}

.assistant-msg-muted {
    opacity: .65;
    background: #141925;
    border-style: dashed;
}

.assistant-tech-details {
    display: block;
}

.assistant-tech-details > summary {
    cursor: pointer;
    font-weight: 600;
    color: var(--text2);
}

.assistant-tech-body {
    margin-top: 8px;
}

.assistant-tech-pre {
    margin: 0;
    white-space: pre-wrap;
    font-size: .78rem;
    line-height: 1.4;
    color: var(--text2);
}

.assistant-msg-error {
    color: #ff8e8e;
    margin-top: 6px;
}

.assistant-loading {
    position: relative;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding-right: 28px;
}

.assistant-loading-spinner {
    width: 14px;
    height: 14px;
    display: inline-block;
    border: 2px solid color-mix(in srgb, var(--text3) 35%, transparent);
    border-top-color: var(--accent);
    border-right-color: color-mix(in srgb, var(--text3) 12%, transparent);
    border-radius: 999px;
    animation: assistant-spin .8s linear infinite;
    flex-shrink: 0;
    will-change: transform;
}

.assistant-loading-text {
    font-weight: 600;
}

.assistant-loading-timer {
    color: var(--text3);
    font-size: .8rem;
    font-variant-numeric: tabular-nums;
}

.assistant-loading-stop {
    position: absolute;
    top: -8px;
    right: -8px;
    width: 22px;
    height: 22px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border: 1px solid var(--border);
    border-radius: 999px;
    background: var(--surface2);
    color: var(--text2);
    font-size: .8rem;
    font-weight: 700;
    line-height: 1;
    padding: 0;
    box-shadow: var(--shadow);
}

.assistant-loading-stop:hover {
    color: var(--danger);
    border-color: color-mix(in srgb, var(--danger) 55%, var(--border));
}

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

.assistant-finance-summary {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.assistant-finance-header {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    gap: 10px;
}

.assistant-finance-title {
    font-weight: 700;
}

.assistant-finance-period {
    color: var(--text3);
    font-size: .78rem;
}

.assistant-finance-rows {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.assistant-finance-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
}

.assistant-finance-label {
    color: var(--text2);
    font-size: .9rem;
}

.assistant-finance-value {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-weight: 700;
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
}

.assistant-finance-note {
    color: var(--text3);
    font-size: .8rem;
}

.assistant-search-results {
    gap: 10px;
}

.assistant-search-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.assistant-search-summary {
    display: flex;
    flex-wrap: wrap;
    gap: 10px 14px;
    font-size: .82rem;
    color: var(--text2);
}

.assistant-alias-card {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.assistant-alias-title {
    font-weight: 700;
}

.assistant-alias-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.assistant-alias-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    padding: 8px 10px;
    border: 1px solid rgba(130, 147, 211, .18);
    background: rgba(255, 255, 255, .03);
    border-radius: 8px;
}

.assistant-alias-main {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

.assistant-alias-actions {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
}

.assistant-search-item {
    appearance: none;
    width: 100%;
    text-align: left;
    color: inherit;
    cursor: pointer;
    position: relative;
    border: 1px solid rgba(130, 147, 211, .18);
    background: rgba(255, 255, 255, .03);
    border-radius: 6px;
    padding: 0 6px 20px 6px;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.assistant-search-item:hover {
    border-color: rgba(130, 147, 211, .34);
    background: rgba(255, 255, 255, .045);
}

.assistant-search-top {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
}

.assistant-search-side {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
    justify-content: flex-end;
    top: 4px;
    position: relative;
}

.assistant-search-date {
    font-size: .78rem;
    color: var(--text3);
    font-weight: 700;
}

.assistant-search-amount {
    display: inline-flex;
    align-items: center;
    font-weight: 800;
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
}

.assistant-search-comment {
    line-height: 1;
}

.assistant-search-eur {
    position: absolute;
    right: 8px;
    bottom: 4px;
    display: inline-flex;
    align-items: center;
    font-size: .72rem;
    font-weight: 700;
    opacity: .88;
}

.assistant-search-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.assistant-search-chip {
    display: inline-flex;
    align-items: center;
    padding: 0 8px;
    border-radius: 999px;
    background: rgba(103, 120, 188, .16);
    border: 1px solid rgba(125, 143, 208, .22);
    font-size: .74rem;
    color: var(--text2);
}

.assistant-search-chip-pending {
    background: rgba(255, 193, 7, .14);
    border-color: rgba(255, 193, 7, .28);
    color: #f5d97a;
}

.assistant-draft-card {
    border: 1px solid #6c7aab;
    background: #1d2640;
    border-radius: 14px;
    padding: 14px;
}

.assistant-draft-title {
    font-weight: 800;
    margin-bottom: 6px;
}

.assistant-draft-text {
    margin-bottom: 8px;
}

.assistant-draft-preview {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-bottom: 8px;
}

.assistant-draft-row {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    padding: 8px 10px;
    border-radius: 10px;
    background: rgba(255, 255, 255, .04);
}

.assistant-draft-row-block {
    align-items: flex-start;
}

.assistant-draft-label {
    color: var(--text2);
    font-size: .78rem;
}

.assistant-draft-value {
    text-align: right;
    font-size: .84rem;
}

.assistant-draft-leg {
    display: flex;
    justify-content: space-between;
    gap: 12px;
}

.assistant-draft-card pre,
.assistant-msg pre,
.assistant-quick-preview pre {
    margin: 0;
    white-space: pre-wrap;
    word-break: break-word;
    font-size: .8rem;
}

.assistant-composer textarea {
    resize: vertical;
    min-height: 60px;
}

#assistantComposerActions {
    display: flex;
    justify-content: space-between;
    gap: 8px;
    align-items: center;
}

.assistant-composer-submit-group {
    display: inline-flex;
    align-items: center;
    gap: 8px;
}

.assistant-tech-toggle {
    display: flex;
    align-items: center;
    gap: 8px;
}

.assistant-quick-preview {
    max-height: 320px;
    overflow: auto;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

#assistantOpenBtn svg {
    width: 24px;
    height: 24px;
}

/* ── Transaction form ────────────────────────────────────────────────────── */
.tx-form {
    width: 100%;
}

.tx-form .form-row {
    display: flex;
    gap: 12px;
}

.tx-form .form-row .form-group {
    flex: 1;
    min-width: 0;
}

.tx-form .form-row .fg-tax {
    flex: 0 0 110px;
    min-width: 0;
}

.tx-form .form-row .fg-tax select.form-control {
    padding-bottom: 9px;
}

/* Legs section */
.legs-section {
    background: var(--surface);
    /* border: 1px solid var(--border); */
    border-radius: var(--radius-sm);
    padding: 12px 0 0 0;
    margin-top: 8px;
}

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

.legs-container {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

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

.leg-row select.form-control {
    flex: 2;
    min-width: 150px;
}

.leg-row input.leg-amount {
    flex: 1;
    min-width: 80px;
    max-width: 130px;
}

.leg-currency {
    flex-shrink: 0;
    min-width: 38px;
    text-align: center;
}

.leg-stocks-hint {
    flex-basis: 100%;
    font-size: .72rem;
    color: var(--warning);
    margin-top: -4px;
}

.leg-row .btn-icon {
    flex-shrink: 0;
}

/* ── Rates container  ──────────────────────────────────── */
.tx-rates-panel {
    background: rgb(0 0 0 / 26%);
    padding: 10px 12px;
    border-radius: 6px;
    border: 1px solid var(--border);
    margin-bottom: 12px;
}

.tx-rates-panel.hidden {
    display: none;
}

.tx-rates-panel-title {
    color: var(--text2);
    font-size: .78rem;
    font-weight: 700;
    letter-spacing: .08em;
    text-transform: uppercase;
}

.tx-rates-panel.is-open .tx-rates-panel-title {
    margin-bottom: 10px;
}

.tx-rates-body.hidden {
    display: none;
}

.tx-form .tx-rates-container.form-row {
    padding: 0;
    border: 0;
    background: none;
    margin-bottom: 12px;
    display: grid;
    gap: 12px;
    grid-template-columns: repeat(auto-fill, minmax(90px, 1fr));
}

.tx-rates-actions {
    display: flex;
    justify-content: flex-end;
    gap: 8px;
    flex-wrap: wrap;
}

/* Legs title */
.legs-title {
    font-weight: 600;
}

/* Legs header actions row */
.legs-header-actions {
    display: flex;
    gap: 8px;
}

/* Currency badge in leg row (was inline) */
.leg-currency.badge {
    background: rgba(108, 99, 255, .15);
    color: var(--accent);
    min-width: 36px;
    text-align: center;
}

/* Stocks hint default hidden */
.leg-stocks-hint {
    display: none;
}

.leg-stocks-hint.visible {
    display: inline;
}

/* ── Legs total summary ──────────────────────────────────────────────────── */
.legs-total {
    display: flex;
    justify-content: flex-end;
    align-items: center;
    gap: 8px;
    padding: 10px 0 2px;
    margin-top: 8px;
    border-top: 1px solid var(--border);
}

.legs-total-label {
    font-size: .78rem;
    color: var(--text3);
    font-weight: 600;
}

.legs-total-value {
    font-size: .92rem;
    font-weight: 700;
    font-variant-numeric: tabular-nums;
}

.legs-total-value.positive {
    color: var(--income);
}

.legs-total-value.negative {
    color: var(--expense);
}

/* ── Autocomplete ────────────────────────────────────────────────────────── */
.autocomplete-wrap {
    position: relative;
}

.autocomplete-dropdown {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: var(--surface2);
    border: 1px solid var(--accent);
    border-top: none;
    border-radius: 0 0 var(--radius-sm) var(--radius-sm);
    max-height: 200px;
    overflow-y: auto;
    z-index: 300;
    box-shadow: 0 8px 24px rgba(0, 0, 0, .4);
}

.autocomplete-dropdown.drop-up {
    top: auto;
    bottom: 100%;
    margin-bottom: 2px;
    border-top: 1px solid var(--accent);
    border-bottom: 1px solid var(--accent);
    border-radius: var(--radius-sm) var(--radius-sm) 0 0;
}

.autocomplete-dropdown::-webkit-scrollbar {
    width: 4px;
}

.autocomplete-dropdown::-webkit-scrollbar-thumb {
    background: var(--border);
}

.autocomplete-item {
    padding: 8px 12px;
    font-size: .88rem;
    cursor: pointer;
    transition: background var(--transition);
    border-bottom: 1px solid var(--border);
}

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

.autocomplete-item:hover,
.autocomplete-item.focused {
    background: var(--surface3);
    color: var(--accent);
}

/* ── Accounts grid page ──────────────────────────────────────────────────── */
#accountsGrid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
    gap: 14px;
}

.acc-bank-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
    transition: border-color var(--transition);
}

.acc-bank-card.acc-bank-inactive {
    opacity: .6;
}

.acc-bank-card:hover {
    border-color: var(--surface3);
}

.acc-bank-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 14px;
    background: var(--surface2);
    border-bottom: 1px solid var(--border);
}

.acc-bank-name {
    display: flex;
    align-items: center;
    font-size: .8rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .05em;
    color: var(--text2);
}

.acc-bank-total {
    font-size: .82rem;
    font-weight: 700;
    color: var(--text);
}

.acc-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 2px 10px;
    gap: 8px;
    border-bottom: 1px solid var(--border);
    transition: background var(--transition);
}

.acc-row.acc-row-inactive {
    opacity: .6;
}

.acc-row:last-child {
    border-bottom: none;
}

.acc-row:hover {
    background: var(--surface2);
}

.acc-row-name {
    display: flex;
    align-items: center;
    gap: 6px;
    min-width: 0;
}

.acc-row-name > span:first-child {
    font-size: .88rem;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.acc-type-tag {
    font-size: .65rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .04em;
    color: var(--text3);
    background: var(--surface2);
    padding: 1px 5px 0px 5px;
    border-radius: 3px;
    white-space: nowrap;
    flex-shrink: 0;
}

.acc-row-amount {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 1px;
    flex-shrink: 0;
}

.acc-amount-native {
    font-size: .88rem;
    font-weight: 600;
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
}

.acc-amount-native.positive {
    color: var(--income);
}

.acc-amount-native.negative {
    color: var(--expense);
}

.acc-amount-eur {
    font-size: .72rem;
    color: var(--text3);
    white-space: nowrap;
}

/* ── badge-tax-o (missing variant) ──────────────────────────────────────── */
.badge-tax-o {
    background: rgba(76, 175, 80, .1);
    color: var(--success);
}

/* ── Mobile adjustments for new components ───────────────────────────────── */
@media (max-width: 1100px) {
    .filters-row {
        flex-wrap: wrap;
    }

    .filters-row > .form-control,
    .filters-row > .form-control-sm {
        min-width: 80px;
        width: auto;
    }

    .filter-ms-wrap {
        min-width: 100px;
        width: auto;
    }

    .filters-row-extra {
        flex-wrap: wrap;
        align-items: flex-start;
    }

    .bookmark-tools {
        margin-left: auto;
    }

    .bookmark-nav {
        flex-wrap: nowrap;
    }

    .tx-card {
        display: flex;
        flex-wrap: wrap;
        position: relative;
        align-items: flex-start;
        gap: 5px;
        padding: 4px 0 7px;
    }

    .tx-drag-handle {
        padding-top: 5px;
    }

    .tx-legs {
        min-width: 0;
        width: 100%;
        text-align: right;
        padding-right: 4px;
    }

    .tx-left {
        padding: 0 6px 0 0;
    }

    .tx-right {
        width: 100%;
        display: flex;
        flex-direction: column;
        gap: 10px;
        align-items: flex-end;
        margin-left: 21px;
    }

    .tx-leg {
        justify-content: space-between;
        gap: 12px;
    }

    .tx-leg-account {
        max-width: none;
        flex: 1;
        text-align: left;
    }

    .tx-leg-amt-group {
        flex-wrap: wrap;
        justify-content: flex-end;
        top: -3px;
        position: relative;
    }

    .tx-meta {
        margin-top: -2px;
    }

    .tx-result {
        position: absolute;
        top: 5px;
        right: 10px;
        padding: 0;
    }

    .tx-bookmark-toggle {
        position: absolute;
        top: -4px;
        right: 20%;
    }

    .tx-pending-confirm {
        display: none;
    }

    .tx-drag-icon {
        opacity: 1;
        display: none;
        position: relative;
        top: -8px;
    }

    .tx-select-check {
        opacity: 1;
    }

    .fab-add-tx {
        bottom: 16px;
        right: 16px;
        width: 50px;
        height: 50px;
        font-size: 1.5rem;
    }

    .fab-bulk-edit {
        bottom: 80px;
        right: 16px;
        width: 50px;
        height: 50px;
        font-size: 1.1rem;
    }

    .tx-form .form-row {
        flex-direction: row;
        gap: 12px;
    }

    .tx-form .form-row .fg-tax {
        flex: 0 0 110px;
        min-width: 0;
    }

    #accountsGrid {
        grid-template-columns: 1fr 1fr 1fr;
    }
}

@media (max-width: 600px) {
    .bookmark-tools {
        margin-left: 0;
    }
}

@media (max-width: 800px) {
    #accountsGrid {
        grid-template-columns: 1fr 1fr;
    }
}

/*@media (max-width: 600px) {
  #accountsGrid {
    grid-template-columns: 1fr;
  }
}*/

@media (max-width: 500px) {
    .leg-row select.form-control {
        min-width: 100%;
    }

    .leg-row input.leg-amount {
        min-width: 100px;
    }

    .acc-row {
        display: block;
    }

    .acc-bank-header {
        display: block;
    }

    .acc-bank-total {
        text-align: right;
    }
}


@media (max-width: 480px) {
    .balance-card {
        min-width: 140px;
    }
}

/* ─── Import Wizard ──────────────────────────────────────────────────────── */

/* Step indicator */
.import-steps {
    display: flex;
    align-items: center;
    gap: 4px;
    margin-bottom: 24px;
    flex-wrap: wrap;
}

.import-step {
    font-size: .82rem;
    color: var(--text3);
    padding: 4px 10px;
    border-radius: 99px;
    border: 1px solid var(--border);
    background: var(--surface2);
    white-space: nowrap;
}

.import-step.active {
    color: var(--accent);
    border-color: var(--accent);
    background: rgba(108, 99, 255, .1);
}

.import-step.done {
    color: var(--success);
    border-color: rgba(76, 175, 80, .3);
    background: rgba(76, 175, 80, .08);
}

.import-step-sep {
    color: var(--text3);
    font-size: .9rem;
    padding: 0 2px;
}

/* Drop Zone (Step 1) */
.import-drop-zone {
    border: 2px dashed var(--border);
    border-radius: var(--radius);
    padding: 40px 24px;
    text-align: center;
    cursor: pointer;
    transition: border-color var(--transition), background var(--transition);
}

.import-drop-zone:hover,
.import-drop-zone.drag-over {
    border-color: var(--accent);
    background: rgba(108, 99, 255, .06);
}

.import-drop-icon {
    font-size: 2.4rem;
    margin-bottom: 12px;
    display: block;
}

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

.import-drop-text {
    font-size: .92rem;
    margin-bottom: 6px;
}

.import-drop-hint {
    font-size: .82rem;
    color: var(--text2);
    margin-bottom: 16px;
}

.import-drop-btn {
    pointer-events: none;
}

.import-browse-link {
    color: var(--accent);
    cursor: pointer;
    text-decoration: underline;
}

.import-browse-link:hover {
    color: var(--accent2);
}

.import-filename {
    font-size: .85rem;
    color: var(--text2);
    margin-top: 8px;
    font-style: italic;
}

.import-err-msg {
    color: var(--danger);
    font-size: .85rem;
    margin-top: 8px;
}

.import-status {
    font-size: .82rem;
    color: var(--text2);
    margin-top: 6px;
}

/* Column mapping (Step 2) */
.import-map-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
    margin-bottom: 16px;
    align-items: start;
}

.import-map-section {
    background: var(--surface2);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 14px;
}

.import-map-title {
    font-size: .78rem;
    color: var(--text2);
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .05em;
    margin-bottom: 12px;
}

.import-map-row {
    display: flex;
    flex-direction: column;
    gap: 4px;
    margin-bottom: 10px;
}

.import-map-row:last-child {
    margin-bottom: 0;
}

.import-map-row label {
    font-size: .78rem;
    color: var(--text2);
    font-weight: 600;
}

.import-note-row {
    font-size: .75rem;
    color: var(--text3);
    margin-top: -6px;
    margin-bottom: 8px;
}

.import-required {
    color: var(--danger);
    margin-left: 2px;
}

.import-init-bal-block {
    margin: 12px 0;
    padding: 12px 14px;
    border: 1px solid rgba(var(--accent-rgb, 100, 149, 237), .35);
    border-radius: 8px;
    background: rgba(var(--accent-rgb, 100, 149, 237), .06);
    font-size: .82rem;
}

.import-init-bal-title {
    display: flex;
    align-items: center;
    gap: 8px;
    font-weight: 600;
    cursor: pointer;
    margin-bottom: 4px;
}

.import-init-bal-hint {
    font-size: .76rem;
    margin-bottom: 8px;
}

.import-init-bal-list {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-bottom: 2px;
}

.import-init-bal-item {
    display: inline-flex;
    gap: 5px;
    align-items: center;
    background: var(--surface2);
    border: 1px solid var(--border);
    border-radius: 4px;
    padding: 2px 7px;
    font-size: .75rem;
}

.import-init-bal-name {
    color: var(--text2);
}

.import-init-bal-amount {
    font-weight: 600;
    color: var(--text);
}

.import-legs-list {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 8px;
    margin-top: 8px;
}

.import-leg-row {
    background: var(--surface3);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 8px 10px;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.import-leg-name {
    font-size: .78rem;
    font-weight: 600;
    color: var(--text);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.import-leg-cur {
    font-size: .72rem;
    color: var(--text2);
}

.import-leg-col label {
    font-size: .72rem;
    color: var(--text2);
    display: block;
    margin-bottom: 3px;
}

/* Sample table */
.import-sample-wrap {
    overflow-x: auto;
    overflow-y: auto;
    max-height: 500px;
    margin-top: 16px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    position: relative;
}

.import-sample-table {
    border-collapse: separate; /* needed for sticky to work with borders */
    border-spacing: 0;
    font-size: .75rem;
    white-space: nowrap;
}

.import-sample-table th,
.import-sample-table td {
    padding: 5px 8px;
    border-bottom: 1px solid var(--border);
    border-right: 1px solid var(--border);
    text-align: left;
    max-width: 92px;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Sticky header row */
.import-sample-table thead th {
    position: sticky;
    top: 0;
    z-index: 3;
    background: var(--surface2);
    color: var(--text2);
    font-weight: 600;
    white-space: normal;
    overflow: visible;
    text-overflow: clip;
    word-break: break-word;
    line-height: 1.3;
    vertical-align: top;
}

.import-sample-table td {
    color: var(--text);
    background: var(--bg);
}

/* Sticky left columns (date/cat/etc) */
.import-sample-table .sample-sticky {
    position: sticky;
    z-index: 2;
    background: var(--surface2);
}

.import-sample-table thead .sample-sticky {
    z-index: 4; /* above both sticky header and sticky cols */
}

/* Highlighted (mapped) columns */
.import-sample-table td.sample-highlight {
    background: rgba(108, 99, 255, .10);
    color: var(--accent);
}

.import-sample-table th.sample-highlight {
    background: rgba(108, 99, 255, .22);
    color: var(--accent);
}

/* Sticky + highlighted */
.import-sample-table .sample-sticky.sample-highlight {
    background: rgba(108, 99, 255, .18);
}

/* Column hover */
.import-sample-table td.col-hover {
    background: rgba(255, 255, 255, .06);
}

.import-sample-table th.col-hover {
    background: rgba(108, 99, 255, .30);
}

.import-sample-table td.sample-highlight.col-hover {
    background: rgba(108, 99, 255, .22);
}

/* Row hover */
.import-sample-table tbody tr:hover td {
    background: rgba(255, 255, 255, .04);
}

.import-sample-table tbody tr:hover td.sample-highlight {
    background: rgba(108, 99, 255, .18);
}

/* Unmapped account rows */
.import-leg-row.import-leg-unmapped select {
    border-color: var(--warning);
}

.import-leg-duplicate select {
    border-color: var(--danger);
    outline: 2px solid var(--danger);
}

.import-leg-row.import-leg-unmapped {
    border-color: rgba(255, 92, 92, .55) !important;
    background: rgba(255, 92, 92, .06) !important;
}

.import-leg-row.import-leg-unmapped .import-leg-col {
    border-color: rgba(255, 92, 92, .6);
}

/* Restored-mapping banner */
.import-mapping-restored {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 7px 12px;
    margin-bottom: 10px;
    background: rgba(78, 205, 196, .10);
    border: 1px solid rgba(78, 205, 196, .30);
    border-radius: var(--radius-sm);
    font-size: .8rem;
    color: var(--accent2);
}

.import-mapping-clear {
    background: none;
    border: none;
    color: var(--text2);
    font-size: .78rem;
    cursor: pointer;
    text-decoration: underline;
    padding: 0;
    margin-left: auto;
}

.import-mapping-clear:hover {
    color: var(--danger);
}

/* Step 3 — summary cards */
.import-step3-summary {
    display: flex;
    gap: 16px;
    margin: 20px 0 24px;
}

.import-step3-stat {
    flex: 1;
    padding: 20px 24px;
    background: var(--surface2);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    text-align: center;
}

.import-step3-stat--ok {
    border-color: rgba(76, 175, 80, .4);
    background: rgba(76, 175, 80, .07);
}

.import-step3-stat--skip {
    border-color: rgba(145, 152, 181, .25);
}

.import-step3-stat-val {
    font-size: 2.2rem;
    font-weight: 700;
    line-height: 1;
    margin-bottom: 6px;
    color: var(--text);
}

.import-step3-stat--ok .import-step3-stat-val {
    color: var(--success);
}

.import-step3-stat--skip .import-step3-stat-val {
    color: var(--text2);
}

.import-step3-stat-lbl {
    font-size: .78rem;
    color: var(--text2);
}

/* Unknown categories alert */
.import-unknown-cats {
    margin: 12px 0;
    padding: 12px 16px;
    background: rgba(255, 92, 92, .08);
    border: 1px solid rgba(255, 92, 92, .45);
    border-radius: var(--radius-sm);
}

.import-unknown-cats-title {
    font-size: .82rem;
    font-weight: 700;
    color: var(--danger);
    margin-bottom: 8px;
}

.import-unknown-cats-list {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-bottom: 8px;
}

.import-unknown-cats-chip {
    background: rgba(255, 92, 92, .15);
    border: 1px solid rgba(255, 92, 92, .35);
    border-radius: 4px;
    padding: 2px 8px;
    font-size: .78rem;
    color: var(--danger);
    font-weight: 600;
}

.import-unknown-cats-hint {
    font-size: .76rem;
    color: var(--text2);
}

/* Category resolve dialog */
.cat-resolve-block {
    margin: 12px 0;
    padding: 12px 16px;
    background: rgba(255, 92, 92, .07);
    border: 1px solid rgba(255, 92, 92, .4);
    border-radius: var(--radius-sm);
}

.cat-resolve-title {
    font-size: .82rem;
    font-weight: 700;
    color: var(--danger);
    margin-bottom: 10px;
}

.cat-resolve-subtitle {
    font-size: .76rem;
    color: var(--text2);
    margin-bottom: 12px;
}

.cat-resolve-rows {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-bottom: 10px;
}

.cat-resolve-row {
    display: grid;
    grid-template-columns: 180px 1fr auto;
    gap: 8px;
    align-items: center;
    background: var(--surface2);
    border-radius: var(--radius-sm);
    padding: 6px 10px;
}

.cat-resolve-csv-name {
    font-size: .8rem;
    font-weight: 600;
    color: var(--danger);
    word-break: break-all;
}

.cat-resolve-select {
    font-size: .8rem;
    padding: 4px 8px;
    height: 30px;
}

.cat-resolve-create-btn {
    font-size: .75rem;
    padding: 4px 10px;
    height: 30px;
    white-space: nowrap;
    background: var(--surface3);
    border: 1px solid var(--border);
    color: var(--text2);
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: color var(--transition), border-color var(--transition);
}

.cat-resolve-create-btn:hover {
    color: var(--accent2);
    border-color: var(--accent2);
}

.cat-resolve-resolved-chip {
    font-size: .72rem;
    padding: 2px 8px;
    border-radius: 4px;
    background: rgba(76, 175, 80, .15);
    border: 1px solid rgba(76, 175, 80, .35);
    color: var(--success);
    white-space: nowrap;
}

.cat-resolve-warn {
    font-size: .76rem;
    color: var(--warning);
    margin-top: 4px;
}

/* Progress bar */
.import-progress-label {
    display: flex;
    justify-content: space-between;
    font-size: .8rem;
    color: var(--text2);
    margin-bottom: 6px;
}

.import-progress-bar-wrap {
    height: 10px;
    background: var(--surface2);
    border-radius: 99px;
    overflow: hidden;
    margin-bottom: 8px;
}

.import-progress-bar {
    height: 100%;
    background: var(--accent);
    border-radius: 99px;
    width: 0;
    transition: width .35s ease;
}

.import-progress-bar.done {
    background: var(--success);
}

.import-progress-bar.error {
    background: var(--danger);
}

.import-progress-stats {
    font-size: .78rem;
    color: var(--text2);
    min-height: 18px;
}

/* Result / Summary */
.import-result {
    background: var(--surface2);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 16px 20px;
    margin-top: 12px;
}

.import-result.success {
    border-color: rgba(76, 175, 80, .35);
}

.import-result.error {
    border-color: rgba(255, 92, 92, .35);
}

.import-result-ok {
    display: flex;
    align-items: flex-start;
    gap: 12px;
}

.import-result-icon {
    font-size: 1.8rem;
    line-height: 1;
}

.import-result-title {
    font-weight: 700;
    margin-bottom: 10px;
    font-size: .95rem;
}

.import-summary {
    display: flex;
    gap: 20px;
    flex-wrap: wrap;
    font-size: .82rem;
    margin-bottom: 14px;
}

.import-result-table {
    width: 100%;
    table-layout: auto;
}

.import-result-table th,
.import-result-table td {
    max-width: none !important;
    white-space: normal !important;
    overflow: visible !important;
    text-overflow: clip !important;
}

.import-summary-item {
    font-size: .88rem;
    color: var(--text);
}

.import-summary-item strong {
    font-weight: 700;
}

/* Resume banner */
.import-resume-banner {
    background: rgba(255, 179, 71, .1);
    border: 1px solid rgba(255, 179, 71, .25);
    border-radius: var(--radius-sm);
    padding: 12px 16px;
    font-size: .85rem;
    color: var(--warning);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 16px;
}

/* Import batches table (Settings) */
.batch-status {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 99px;
    font-size: .72rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .04em;
}

.batch-status-done {
    background: rgba(76, 175, 80, .12);
    color: var(--success);
}

.batch-status-in_progress {
    background: rgba(108, 99, 255, .12);
    color: var(--accent);
}

.batch-status-failed {
    background: rgba(255, 92, 92, .12);
    color: var(--danger);
}

.batch-status-pending {
    background: rgba(145, 152, 181, .12);
    color: var(--text2);
}

.restore-log-meta {
    margin-bottom: 10px;
    font-size: .82rem;
    color: var(--text2);
}

.restore-log-status {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 6px 10px;
    border-radius: 999px;
    font-size: .75rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .04em;
    margin-bottom: 12px;
}

.restore-log-status-running {
    background: rgba(108, 99, 255, .12);
    color: var(--accent);
    border: 1px solid rgba(108, 99, 255, .28);
}

.restore-log-status-success {
    background: rgba(76, 175, 80, .12);
    color: var(--success);
    border: 1px solid rgba(76, 175, 80, .28);
}

.restore-log-status-error {
    background: rgba(255, 92, 92, .12);
    color: var(--danger);
    border: 1px solid rgba(255, 92, 92, .28);
}

.restore-log-output {
    margin: 0;
    min-height: 260px;
    max-height: min(60vh, 560px);
    overflow: auto;
    padding: 12px 14px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
    background: rgba(10, 14, 25, .78);
    color: #d8e0f0;
    font-size: .78rem;
    line-height: 1.45;
    white-space: pre-wrap;
    word-break: break-word;
}

@media (max-width: 1100px) {
    .import-map-grid {
        grid-template-columns: 1fr;
    }

    .import-summary {
        gap: 12px;
    }
}

/* ── Pending transactions block ─────────────────────────────────────────── */
#pendingBlock {
    margin-bottom: 20px;
}

.pending-header {
    display: block;
    /*align-items: center;*/
    gap: 10px;
    padding: 40px 0 10px;
    text-align: center;
    position: relative;
}
.pending-header:after,
.pending-header:before {
    content: '';
    border-bottom: 1px solid var(--border);
    display: block;
    height: 1px;
    top: 50px;
    position: absolute;
    left: 25px;
    width: calc(50% - 100px);
}
.pending-header:after {
    left: auto;
    right: 25px;
}
.pending-header .badge {
    margin-left: 10px;
}
.pending-title {
    font-weight: 600;
    font-size: .88rem;
    color: var(--text2);
    text-transform: uppercase;
    letter-spacing: .04em;
}
.pending-title .icon {
    width: 24px;
    height: 24px;
    margin-right: 5px;
    top: -2px;
    position: relative;
}
.pending-count {
    background: rgba(255, 170, 0, .18);
    color: #ffaa00;
    border: 1px solid rgba(255, 170, 0, .4);
    border-radius: 99px;
    font-size: .72rem;
    font-weight: 700;
    padding: 1px 8px;
}

/* Pending transaction card */
.tx-pending {
    border-color: rgba(255, 170, 0, .45) !important;
    background: linear-gradient(45deg, rgba(255, 170, 0, .05), transparent);
    margin-bottom: 5px;
}

/* Overdue pending card */
.tx-pending-overdue {
    border-color: rgba(255, 80, 80, .55) !important;
    background: rgba(255, 80, 80, .07) !important;
}

.pending-overdue-badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-size: .7rem;
    font-weight: 700;
    color: var(--danger);
    background: rgba(255, 80, 80, .12);
    border: 1px solid rgba(255, 80, 80, .35);
    border-radius: 4px;
    padding: 1px 7px;
    margin-bottom: 4px;
}

/* Pending toggle in tx modal */
.pending-toggle-wrap {
    margin-bottom: 8px;
}

.pending-toggle-label {
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    font-size: .88rem;
    color: var(--text2);
    user-select: none;
}

.pending-toggle-label input[type="checkbox"] {
    width: 15px;
    height: 15px;
    cursor: pointer;
    accent-color: var(--warning, #ffaa00);
}

.pending-toggle-icon {
    font-size: 1rem;
}


/* ── Display preferences (Settings > Display) ───────────────────────────── */
.display-pref-row {
    position: relative;
    display: flex;
    align-items: flex-start;
    gap: 12px;
    padding: 14px 16px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    cursor: pointer;
    transition: border-color var(--transition), background var(--transition);
}

.display-pref-row:hover {
    border-color: var(--accent);
    background: rgba(56, 141, 201, .06);
}

.display-pref-row input[type="radio"] {
    flex-shrink: 0;
    accent-color: var(--accent);
    width: 16px;
    height: 16px;
}

.display-pref-stack {
    display: flex;
    flex-direction: column;
    gap: 18px;
}

.display-pref-group {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.display-pref-group .form-group {
    padding-left: 5%;
}

.display-pref-heading {
    font-size: .8rem;
    font-weight: 700;
    letter-spacing: .04em;
    text-transform: uppercase;
    color: var(--text2);
}

.display-pref-divider {
    height: 1px;
    background: var(--border);
}

.display-pref-inline {
    padding: 4px 2px 0;
}

.display-pref-inline-row {
    position: relative;
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
}

.display-pref-title {
    font-weight: 600;
    font-size: .9rem;
    margin-bottom: 4px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.display-pref-desc {
    font-size: .82rem;
    color: var(--text2);
    line-height: 1.5;
}

.offline-cache-settings {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.offline-cache-table-wrap {
    overflow-x: auto;
}

.offline-cache-table {
    width: 100%;
    min-width: 760px;
    border-collapse: separate;
    border-spacing: 0;
    table-layout: fixed;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
}

.offline-cache-table th,
.offline-cache-table td {
    padding: 14px 16px;
    border-right: 1px solid var(--border);
    border-bottom: 1px solid var(--border);
    vertical-align: top;
}

.offline-cache-table thead th {
    background: var(--surface2);
}

.offline-cache-table tbody th {
    width: 18%;
    background: var(--surface2);
    text-align: left;
    font-size: .8rem;
    color: var(--text2);
    font-weight: 700;
}

.offline-cache-table tr:last-child th,
.offline-cache-table tr:last-child td {
    border-bottom: 0;
}

.offline-cache-table th:last-child,
.offline-cache-table td:last-child {
    border-right: 0;
}

.offline-cache-choice {
    display: flex;
    align-items: center;
    gap: 10px;
    cursor: pointer;
    font-weight: 700;
}

.offline-cache-choice input {
    margin: 0;
}

.offline-cache-table [data-offline-mode-column] {
    transition: background-color .15s ease, box-shadow .15s ease;
}

.offline-cache-table [data-offline-mode-column].is-selected {
    background: rgb(56 141 201 / 43%);
}

.offline-cache-table [data-offline-mode-column].is-current {
    /*box-shadow: inset 0 0 0 2px rgba(255, 255, 255, 0.5);*/
}

.is-selected label.offline-cache-choice {
    text-transform: uppercase;
    color: var(--text);
}

.offline-cache-stats {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 12px;
}

.offline-cache-stat {
    display: flex;
    flex-direction: column;
    gap: 6px;
    padding: 12px 14px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--surface2);
}

.offline-cache-status {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 12px;
    padding: 12px 14px;
    border: 1px dashed var(--border);
    border-radius: var(--radius);
}

.offline-cache-actions {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

.currency-tag-settings-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.currency-tag-settings-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    padding: 14px 16px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--surface);
}

.currency-tag-settings-main {
    display: flex;
    align-items: center;
    gap: 14px;
    min-width: 220px;
}

.currency-tag-settings-meta {
    display: flex;
    flex-direction: column;
    gap: 4px;
    min-width: 0;
}

.currency-tag-settings-code {
    font-size: .9rem;
    font-weight: 700;
    letter-spacing: .05em;
}

.currency-tag-settings-name {
    font-size: .82rem;
    color: var(--text2);
}

.currency-tag-settings-preview {
    margin-left: 0;
}

.currency-tag-settings-fields {
    display: flex;
    flex-wrap: wrap;
    justify-content: flex-end;
    gap: 12px;
}

.currency-tag-settings-field {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 10px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--surface2);
}

.currency-tag-settings-label {
    font-size: .7rem;
    font-weight: 700;
    letter-spacing: .06em;
    text-transform: uppercase;
    color: var(--text2);
}

.currency-tag-settings-input {
    width: 36px;
    height: 28px;
    padding: 0;
    border: none;
    background: transparent;
    cursor: pointer;
}

.currency-tag-settings-hex {
    width: 76px;
    font-size: .78rem;
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    text-transform: uppercase;
    color: var(--text2);
}

/* ── User avatar upload widget (Settings > Display > Profile) ────────────── */
.user-avatar-upload {
    position: relative;
    width: 72px;
    height: 72px;
    border-radius: 50%;
    background: var(--surface2);
    border: 2px solid var(--border);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    flex-shrink: 0;
    transition: border-color var(--transition), box-shadow var(--transition);
}

.user-avatar-upload:hover {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(108, 99, 255, .18);
}

.user-avatar-upload-hint {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    background: rgba(0, 0, 0, .52);
    color: #fff;
    font-size: .6rem;
    font-weight: 600;
    text-align: center;
    padding: 3px 0;
    opacity: 0;
    transition: opacity var(--transition);
    letter-spacing: .04em;
    text-transform: uppercase;
}

.user-avatar-upload:hover .user-avatar-upload-hint {
    opacity: 1;
}

@media (max-width: 900px) {
    .currency-tag-settings-row {
        flex-direction: column;
        align-items: flex-start;
    }

    .currency-tag-settings-main {
        min-width: 0;
    }

    .currency-tag-settings-fields {
        justify-content: flex-start;
    }
}

/* ── Sticky header block on Transactions page ───────────────────────────── */
.tx-sticky-header {
    position: sticky;
    top: calc(var(--topbar-h) + var(--balance-bar-h, 0px));
    z-index: 45;
    background: var(--surface2);
    border-radius: 22px;
    margin-left: -24px;
    margin-right: -24px;
    padding: 5px 24px 12px;
}

/* Tighten page-header bottom gap inside sticky block */
.tx-sticky-header .page-header {
    margin-bottom: 14px;
}

/* Remove filters-row bottom margin — sticky block padding handles spacing */
.tx-sticky-header .filters-row {
    margin-bottom: 0;
}

@media (max-width: 1100px) {
    .tx-sticky-header {
        margin-left: -10px;
        margin-right: -10px;
        padding-left: 16px;
        padding-right: 16px;
    }

    .tx-day-header {
        padding-left: 20px;
        padding-right: 20px;
    }
}


/* ══════════════════════════════════════════════════════════════════════════ */
/* ── Analytics page ────────────────────────────────────────────────────── */
/* ══════════════════════════════════════════════════════════════════════════ */

/* Clean up: Use standard layout for analytics */
.page-analytics .app-shell {
    min-height: 100vh;
    height: 100dvh;
    overflow: hidden;
}

.page-analytics .main-wrap {
    height: 100%;
    display: flex;
    flex-direction: column;
}

.page-analytics .main-content {
    max-width: none;
    padding: 0;
    flex: 1;
    display: flex;
    flex-direction: column;
    min-height: 0;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
}

.page-analytics-crypto .app-shell {
    height: auto;
    min-height: 100vh;
    overflow: visible;
}

.page-analytics-crypto .main-wrap {
    height: auto;
    min-height: 100vh;
}

.page-analytics-crypto .main-content {
    min-height: auto;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
}

.page-analytics-budget-calendar .app-shell {
    height: auto;
    min-height: 100vh;
    overflow: visible;
}

.page-analytics-budget-calendar .main-wrap {
    height: auto;
    min-height: 100vh;
}

.page-analytics-budget-calendar .main-content {
    min-height: auto;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
}

/* ── Filter bar ─────────────────────────────────────────────────────────── */
.stats-filter-bar {
    flex-shrink: 0;
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 8px;
    padding: 9px 18px;
    background: var(--surface2);
    border-bottom: 1px solid var(--border);
    position: relative;
    z-index: 20;
    margin-bottom: 2px;
}

/* Ensure the row with an active dropdown stays on top of subsequent rows */
.stats-filter-bar.ms-active {
    z-index: 9999 !important;
    isolation: isolate;
}

.stats-date-input {
    width: 110px;
}


#statsPreset {
    max-width: 85px;
}

.stats-inline-select {
    width: auto;
    display: inline-block;
}

.stats-show-empty-label {
    font-size: 0.85rem;
    cursor: pointer;
    user-select: none;
}

.stats-show-empty-input {
    vertical-align: middle;
}

.stats-show-empty-text {
    vertical-align: middle;
}

.stats-toggle-group {
    display: inline-flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 10px;
}

.stats-label, .stats-sep {
    color: var(--text2);
    font-size: .82rem;
    white-space: nowrap;
}

#graphsFilterBar {
    display: block;
    padding-top: 12px;
    padding-bottom: 12px;
    z-index: 30;
}

#graphsFilterBar.ms-active {
    z-index: 10030 !important;
}

#graphsFilterBar .graphs-filter-tabs {
    display: flex;
    gap: 4px;
    border-bottom: 1px solid var(--border);
    margin-bottom: 12px;
}

#graphsFilterBar .graphs-filter-tab-btn {
    border-bottom: 2px solid transparent;
    margin-bottom: -1px;
}

#graphsFilterBar .graphs-filter-tab-btn.active {
    color: var(--accent);
    border-bottom-color: var(--accent);
}

#graphsFilterBar .graphs-filter-panes {
    display: block;
}

#graphsFilterBar .graphs-filter-pane {
    display: none;
}

#graphsFilterBar .graphs-filter-pane.active {
    display: block;
}

#graphsFilterBar .graphs-filter-row {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 10px 14px;
}

#graphsFilterBar .graphs-filter-panes + .graphs-filter-row,
#graphsFilterBar .graphs-filter-row + .graphs-filter-row {
    margin-top: 10px;
}

#graphsFilterBar .filter-group {
    margin-right: 0 !important;
    gap: 6px;
    flex-wrap: nowrap;
}

#graphsFilterBar .filter-ms-wrap {
    flex: 0 0 auto;
    width: 180px;
    min-width: 180px;
}

#graphsFilterBar #graphAccountTypesWrap {
    width: 130px;
    min-width: 130px;
}

#graphsFilterBar #graphCategoriesWrap,
#graphsFilterBar #graphProjectsWrap {
    width: 170px;
    min-width: 170px;
}

#graphsFilterBar #graphPreset {
    width: 170px;
}

#graphsFilterBar .graphs-filter-period {
    min-width: 0;
}

#graphsFilterBar .graphs-filter-period .stats-date-input {
    width: 170px;
    min-width: 170px;
}

#graphsFilterBar .graphs-filter-row-compare .filter-ms-wrap {
    flex: 0 0 auto;
    width: 230px;
    min-width: 230px;
}

#graphsFilterBar .graphs-filter-compare-label {
    flex: 0 0 auto;
}

#graphsFilterBar .graphs-filter-toggle {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    margin: 0;
    white-space: nowrap;
}

#graphsFilterBar .graphs-filter-actions {
    /*margin-left: auto;*/
}

@media (max-width: 1100px) {
    #graphsFilterBar .graphs-filter-row {
        gap: 8px 10px;
    }

    #graphsFilterBar .filter-group {
        flex-wrap: wrap;
    }

    #graphsFilterBar .filter-ms-wrap,
    #graphsFilterBar #graphAccountTypesWrap,
    #graphsFilterBar #graphCategoriesWrap,
    #graphsFilterBar #graphProjectsWrap,
    #graphsFilterBar #graphPreset,
    #graphsFilterBar .graphs-filter-period .stats-date-input,
    #graphsFilterBar .graphs-filter-row-compare .filter-ms-wrap {
        width: 100%;
        min-width: 0;
    }

    #graphsFilterBar .graphs-filter-actions {
        margin-left: 0;
    }
}

@media (max-width: 576px) {
    .stats-filter-bar {
        padding: 8px 12px;
    }

    .stats-date-input {
        flex: 1;
        min-width: 120px;
    }

    .stats-toggle-group {
        width: 100%;
        flex-wrap: nowrap;
        gap: 10px;
    }

    .stats-toggle-group .stats-show-empty-label {
        display: inline-flex;
        align-items: center;
        white-space: nowrap;
    }

    #graphsFilterBar .graphs-filter-tabs {
        overflow-x: auto;
        overflow-y: hidden;
    }

    #graphsFilterBar .graphs-filter-tab-btn {
        white-space: nowrap;
    }
}

.stats-drill-info {
    display: flex;
    visibility: hidden;
    align-items: center;
    gap: 8px;
    min-width: 180px; /* Reserve space to prevent layout jump */
}

.stats-drill-info.visible {
    visibility: visible;
}

.stats-drill-divider {
    color: var(--border);
    margin: 0 4px;
}

.stats-drill-name {
    color: var(--accent);
    font-weight: 600;
    font-size: .88rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 120px;
}

.tax-calc-total-main {
    font-size: 2rem;
    line-height: 1;
}

.tax-calc-hint {
    margin-top: 5px;
}

.tax-calc-table-num {
    width: 40px;
}

/* ── Table wrapper ──────────────────────────────────────────────────────── */
.stats-table-wrap {
    width: 100%;
    flex: 0 0 auto;
    overflow: visible !important;
    background: var(--bg);
    position: relative;
}

.stats-table-scroll {
    width: 100%;
    overflow-x: auto;
    overflow-y: visible;
    -webkit-overflow-scrolling: touch;
}

.working-stats-help-group-title {
    margin: 0;
    padding: 10px 0;
}

.budget-analytics-summary {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 12px;
    padding: 16px;
}

.budget-analytics-summary-card {
    background: var(--surface2);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 16px;
}

.budget-analytics-summary-label {
    color: var(--text2);
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.budget-analytics-summary-label-bold {
    font-weight: 700;
}

.budget-analytics-summary-value {
    margin-top: 10px;
    font-size: 1.5rem;
    font-weight: 700;
    line-height: 1.1;
}

.budget-analytics-reserve-card {
    grid-column: 1 / -1;
    padding: 0;
    overflow: hidden;
}

.budget-analytics-reserve-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px;
    padding: 16px 16px 0;
}

.budget-analytics-reserve-heading {
    min-width: 0;
}

.budget-analytics-reserve-controls {
    display: flex;
    flex-wrap: wrap;
    justify-content: flex-end;
    gap: 8px;
}

.budget-reserve-switcher {
    flex: 0 0 auto;
}

.budget-analytics-reserve-table-wrap {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    padding: 8px 16px 16px;
}

.budget-analytics-reserve-table {
    width: 100%;
    min-width: 760px;
    border-collapse: collapse;
    font-size: .88rem;
}

.budget-analytics-reserve-table thead {
    display: table-header-group !important;
}

.budget-analytics-reserve-table tbody {
    display: table-row-group !important;
}

.budget-analytics-reserve-table tr {
    display: table-row;
}

.budget-analytics-reserve-table th,
.budget-analytics-reserve-table td {
    display: table-cell !important;
}

.budget-analytics-reserve-table td[data-label]:before {
    display: none !important;
}

.budget-analytics-reserve-table th,
.budget-analytics-reserve-table td {
    padding: 11px 12px;
    border-bottom: 1px solid var(--border);
    white-space: nowrap;
}

.budget-analytics-reserve-table th {
    color: var(--text2);
    font-size: .78rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .04em;
}

.budget-analytics-reserve-table tbody tr:last-child td {
    border-bottom: 0;
}

.budget-analytics-reserve-table .is-total td {
    font-weight: 700;
    background: var(--surface3);
}

@media (max-width: 480px) {
    .stats-table-wrap {
        overflow: visible !important;
        display: block;
        width: 100%; /* Changed from 100vw to be safer */
        margin: 0;
    }

    .budget-analytics-summary {
        grid-template-columns: 1fr;
        padding: 12px;
    }

    .budget-analytics-reserve-head {
        padding: 14px 14px 0;
        flex-direction: column;
        align-items: stretch;
    }

    .budget-analytics-reserve-controls {
        justify-content: flex-start;
    }

    .budget-analytics-reserve-table-wrap {
        padding: 8px 14px 14px;
        overflow-x: auto;
    }

    .budget-analytics-reserve-table {
        min-width: 760px;
    }
}

.stats-loading {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 60px;
    color: var(--text2);
    font-size: .9rem;
}

/* ── Stats table ────────────────────────────────────────────────────────── */
.stats-table {
    border-collapse: collapse;
    width: max-content;
    min-width: 100%;
    font-size: .82rem;
    table-layout: auto;
}

/* Force standard table row behavior even on mobile where global rules try to make it display:block */
.stats-table thead {
    display: table-header-group !important;
}

.stats-table tbody {
    display: table-row-group !important;
}

.stats-table tr {
    display: table-row;
}

.stats-table th,
.stats-table td {
    display: table-cell !important;
    white-space: nowrap !important;
}

/* Do not show data-labels (from global mobile table styles) in the analytics table */
.stats-table td[data-label]:before {
    display: none !important;
}

/* Sticky thead */
.stats-table thead th {
    position: sticky;
    top: 0;
    z-index: 12;
    background: var(--surface);
    border-bottom: 2px solid var(--border);
    padding: 9px 14px;
    white-space: nowrap;
    text-align: center;
    font-weight: 600;
    font-size: .75rem;
    letter-spacing: .05em;
    /*text-transform: uppercase;*/
    color: var(--text2);
}

/* Sticky period column */
.stats-table .col-period {
    position: sticky;
    left: 0;
    z-index: 11;
    background: var(--surface2);
    border-right: 1px solid var(--border);
    min-width: 120px;
    max-width: 120px;
    white-space: nowrap;
    text-align: right;
    padding: 5px 14px;
    color: var(--text2);
    font-size: .82rem;
}

@media (max-width: 400px) {
    .stats-table .col-period {
        min-width: 100px;
        max-width: 100px;
        font-size: 0.75rem;
        padding: 5px 8px;
    }
}

/* Sticky corner: both top + left */
.stats-table thead th.col-period {
    z-index: 16;
    text-align: left;
    background: var(--surface);
}

/* Category headers */
.stats-table thead th.col-cat {
    min-width: 110px;
}

.stats-table thead th.col-clickable {
    cursor: pointer;
}

.stats-table thead th.col-clickable:hover {
    background: var(--surface2);
    color: var(--accent);
}

/* Type colour stripe on top */
.stats-table thead th.col-type-income {
    border-top: 3px solid var(--income);
}

.stats-table thead th.col-type-expense {
    border-top: 3px solid var(--expense);
}

.stats-table thead th.col-type-transfer {
    border-top: 3px solid var(--transfer);
}

.th-name {
    display: inline;
}

.th-hint {
    font-size: .68em;
    opacity: .45;
    margin-left: 4px;
    vertical-align: middle;
}

/* Total column header */
.stats-table thead th.col-total-head {
    border-left: 1px solid var(--border);
    min-width: 110px;
    color: var(--text);
}

/* ── Data cells ─────────────────────────────────────────────────────────── */
.stats-table td {
    padding: 4px 14px;
    text-align: right;
    border-bottom: 1px solid rgba(45, 49, 72, .4);
    white-space: nowrap;
    color: var(--text3);
}

.stats-table td.col-amt {
    font-variant-numeric: tabular-nums;
    font-size: .83rem;
    min-width: 110px;
}

.stats-table td .amt-main {
    display: block;
}

.stats-table td .amt-future {
    display: block;
    margin-top: 2px;
    font-size: .72rem;
    line-height: 1.2;
    opacity: .78;
    color: var(--text2);
}

.stats-table td .amt-breakdown {
    display: block;
    margin-top: 2px;
    font-size: .69rem;
    line-height: 1.2;
    opacity: .92;
}

.stats-table td .amt-breakdown-label {
    margin-left: 4px;
    color: var(--text2);
    text-transform: uppercase;
    letter-spacing: .03em;
    font-size: .66rem;
}

.stats-table td.col-row-total {
    border-left: 1px solid var(--border);
    font-weight: 600;
}

.stats-table td.val-pos {
    color: var(--income);
}

.stats-table td.val-neg {
    color: var(--expense);
}

/* ── Row variants ───────────────────────────────────────────────────────── */

/* Year separator */
.stats-table tr.row-year-sep td {
    background: var(--surface3);
    padding: 4px 14px;
    border-bottom: 1px solid var(--border);
}

.stats-table tr.row-year-sep td.col-period {
    background: var(--surface3);
    color: var(--text);
    font-weight: 700;
    font-size: .78rem;
    letter-spacing: .07em;
    text-transform: uppercase;
}

/* Month hover */
.stats-table tr.row-month:hover td {
    background: rgba(108, 99, 255, .055);
}

.stats-table tr.row-month:hover td.col-period {
    background: var(--surface3);
}

/* Year total */
.stats-table tr.row-year-total td {
    background: var(--surface);
    font-weight: 700;
    border-top: 1px solid var(--border);
    border-bottom: 2px solid var(--border);
    color: var(--text);
}

.stats-table tr.row-year-total td.col-period {
    background: var(--surface);
    text-align: left;
}

.stats-table tr.row-year-total td.val-pos {
    color: var(--income);
}

.stats-table tr.row-year-total td.val-neg {
    color: var(--expense);
}

.stats-table tr.row-year-total.year-toggle td {
    cursor: pointer;
}

.stats-table tr.row-year-total.collapsed td {
    opacity: .85;
}

.stats-table tr.collapsed-row {
    display: none !important;
}

@media (max-width: 1100px) {
    /* Allow header to stack naturally on narrow screens; sticky stays on thead */
    .stats-table thead th {
        padding: 8px 10px;
        line-height: 1.2;
        white-space: normal;
    }
}

/* Grand total — sticky bottom */
.stats-table tr.row-grand-total td {
    position: sticky;
    bottom: 0;
    z-index: 10;
    background: var(--surface2);
    font-weight: 700;
    font-size: .87rem;
    border-top: 2px solid var(--accent);
    color: var(--text);
}

.stats-table tr.row-grand-total td.col-period {
    background: var(--surface2);
    z-index: 14;
    color: var(--text);
}

.stats-table tr.row-grand-total td.val-pos {
    color: var(--income);
}

/* ── Accessibility utilities ─────────────────────────────────────────────── */
.visually-hidden {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

.stats-table tr.row-grand-total td.val-neg {
    color: var(--expense);
}

td.pe-2 {
    padding: 5px 5px;
}

.mb-3 {
    padding-bottom: 15px;
}

/* ── Tax Calculator (Analytics) ──────────────────────────────────────────── */
.tax-calc-grid {
    display: flex;
    flex-direction: column;
    gap: 20px;
    padding: 20px;
}

.tax-calc-col-base {
    display: flex;
    flex-direction: column;
}

@media (min-width: 992px) {
    .tax-calc-grid {
        flex-direction: row;
        align-items: flex-start;
    }

    .tax-calc-col-base {
        flex: 0 0 300px;
        max-width: 380px;
    }

    .tax-calc-col-rates {
        flex: 1;
        min-width: 0;
    }
}

.tax-calc-input-wrap {
    display: flex;
    align-items: center;
    background: var(--surface2);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    overflow: hidden;
    transition: border-color var(--transition);
}

.tax-calc-input-wrap:focus-within {
    border-color: var(--accent);
}

.tax-calc-input-wrap input {
    border: none;
    background: transparent;
    width: 100%;
    outline: none;
    box-shadow: none !important;
}

.tax-calc-input-wrap .suffix {
    padding: 0 12px;
    color: var(--text2);
    font-size: 0.9rem;
    height: 100%;
    display: flex;
    align-items: center;
    font-weight: 500;
}

.tax-calc-input-wrap .suffix-bg {
    background: rgba(0, 0, 0, 0.1);
}

.bank-group-header .btn-add-group-item {
    padding: 0;
    width: 24px;
    height: 24px;
    min-width: 24px;
    font-size: 1.1rem;
    line-height: 22px;
    vertical-align: middle;
    opacity: 0.2;
    transition: opacity var(--transition), background var(--transition);
    border: none;
    background: transparent;
    color: var(--text);
}

.bank-group-header:hover .btn-add-group-item {
    opacity: 1;
    background: var(--surface3);
}

.tx-filter-count {
    font-size: 0.82rem;
    color: var(--text3);
    order: 1;
    margin-left: 0;
}

/* Sign toggle button for amount inputs */
.btn-sign-toggle {
    flex-shrink: 0;
    width: 34px;
    height: 100%;
    /*min-height: 36px;*/
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
    font-size: 1.1rem;
    z-index: 2;
    border-top-right-radius: 0;
    border-bottom-right-radius: 0;
    border-right: none;
}

/* When used with form-control, make them look like a single unit if possible */
.leg-row .btn-sign-toggle + .leg-amount {
    border-top-left-radius: 0;
    border-bottom-left-radius: 0;
}

/* ── Final Override for Settings One-line Tables on Mobile ──────────────── */
@media (max-width: 480px) {
    /* We use higher specificity here to override global mobile rules without !important where possible */
    div.table-wrap table.single-line-table {
        display: table !important;
        table-layout: fixed !important;
        width: 100% !important;
        border-collapse: collapse !important;
    }

    .single-line-table thead {
        display: table-header-group !important;
    }

    /* NO !important here so JavaScript can toggle display: none/table-row */
    .single-line-table tbody tr {
        display: table-row;
    }

    .single-line-table td {
        display: table-cell !important;
        padding: 8px 4px !important;
        vertical-align: middle !important;
        border-bottom: 1px solid var(--border) !important;
    }

    /* Hide drag handle column */
    .single-line-table td:nth-child(1),
    .single-line-table th:nth-child(1) {
        display: none !important;
    }

    .budget-calendar-list-table td:nth-child(1),
    .budget-calendar-list-table th:nth-child(1) {
        display: table-cell !important;
    }

    /* Tax types specific adjustments */
    .single-line-table.tax-types-table td:nth-child(2),
    .single-line-table.tax-types-table th:nth-child(2) {
        width: 55px !important;
    }

    .single-line-table.tax-types-table td:nth-child(4),
    .single-line-table.tax-types-table th:nth-child(4) {
        display: none !important;
    }

    /* Column name takes all available space */
    .single-line-table td.col-name {
        width: 100% !important;
        max-width: 220px !important;
        font-size: 0.9rem !important;
        overflow: hidden !important;
        text-overflow: ellipsis !important;
        white-space: nowrap !important;
    }

    /* Action buttons pinned to the right edge */
    .single-line-table td.td-actions {
        width: 105px !important;
        text-align: right !important;
        white-space: nowrap !important;
        padding-right: 4px !important;
    }

    .single-line-table td.td-actions .btn {
        display: inline-flex !important;
        margin-left: 2px !important;
        padding: 6px 0 !important;
    }
}

/* ── Maintenance Card-style Tables for Mobile ──────────────────────────── */
@media (max-width: 480px) {
    .table-mobile-cards thead {
        display: none !important;
    }

    .table-mobile-cards,
    .table-mobile-cards tbody,
    .table-mobile-cards tr,
    .table-mobile-cards td {
        display: block !important;
        width: 100% !important;
    }

    .table-mobile-cards tr {
        margin-bottom: 16px;
        background: var(--surface2);
        border: 1px solid var(--border);
        border-radius: var(--radius);
        padding: 12px;
    }

    .table-mobile-cards tr:hover {
        background: var(--surface3);
    }

    .table-mobile-cards td {
        border: none !important;
        padding: 4px 0 !important;
        display: flex !important;
        justify-content: space-between;
        align-items: center;
        text-align: right;
        font-size: 0.9rem;
    }

    .table-mobile-cards td:before {
        content: attr(data-label);
        flex: 1;
        font-weight: 600;
        color: var(--text2);
        text-transform: uppercase;
        font-size: 0.75rem;
        margin-right: 12px;
        text-align: left;
        flex-shrink: 0;
    }

    .table-mobile-cards td.td-actions {
        margin-top: 8px;
        padding-top: 8px !important;
        border-top: 1px solid var(--border) !important;
        justify-content: flex-end;
    }

    .table-mobile-cards td.td-actions:before {
        display: none;
    }

    .table-mobile-cards td:empty {
        display: none !important;
    }

    /* Hide #/ID column label on mobile to save space */
    .table-mobile-cards td[data-label="#"]:before,
    .table-mobile-cards td[data-label="ID"]:before,
    .table-mobile-cards td[data-label="Test"]:before {
        display: none;
    }

    .table-mobile-cards td[data-label="#"],
    .table-mobile-cards td[data-label="ID"],
    .table-mobile-cards td[data-label="Test"] {
        font-weight: bold;
        color: var(--accent);
        justify-content: flex-start;
        text-align: left;
    }

    .table-mobile-cards td[data-label="Test"] {
        display: block !important;
    }
}


/* ── Maintenance Utilities & Cleanup ────────────────────────────────────── */
.flex-gap-8 {
    display: flex;
    gap: 8px;
}

.flex-column {
    display: flex;
    flex-direction: column;
}

.gap-4 {
    gap: 4px !important;
}

.gap-8 {
    gap: 8px !important;
}

.gap-10 {
    gap: 10px !important;
}

.gap-12 {
    gap: 12px !important;
}

.gap-16 {
    gap: 16px !important;
}

.gap-20 {
    gap: 20px !important;
}

.gap-24 {
    gap: 24px !important;
}

.gap-28 {
    gap: 28px !important;
}

.flex-1 {
    flex: 1 !important;
}

.flex-wrap {
    flex-wrap: wrap !important;
}

.align-items-center {
    align-items: center !important;
}

.justify-content-center {
    justify-content: center !important;
}

.justify-content-between {
    justify-content: space-between !important;
}

.pos-relative {
    position: relative !important;
}

.border-collapse {
    border-collapse: collapse !important;
}

.flex-grow-1 {
    flex-grow: 1 !important;
}

.d-contents {
    display: contents !important;
}

.va-top {
    vertical-align: top !important;
}

.mt-4 {
    margin-top: 4px !important;
}

.mt-8 {
    margin-top: 8px !important;
}

.mt-12 {
    margin-top: 12px !important;
}

.mt-16 {
    margin-top: 16px !important;
}

.mt-24 {
    margin-top: 24px !important;
}

.mt-2 {
    margin-top: 2px !important;
}

.mt-6 {
    margin-top: 6px !important;
}

.mt-3 {
    margin-top: 1rem !important;
}

.mb-4 {
    margin-bottom: 4px !important;
}

.mb-8 {
    margin-bottom: 8px !important;
}

.mb-12 {
    margin-bottom: 12px !important;
}

.mb-14 {
    margin-bottom: 14px !important;
}

.mb-16 {
    margin-bottom: 16px !important;
}

.mb-24 {
    margin-bottom: 24px !important;
}

.mr-auto {
    margin-right: auto !important;
}

.mr-4 {
    margin-right: 4px !important;
}

.mr-1 {
    margin-right: 4px !important;
}

.mr-6 {
    margin-right: 6px !important;
}

.ml-10 {
    margin-left: 10px !important;
}

.ml-8 {
    margin-left: 8px !important;
}

.mt-n6 {
    margin-top: -6px !important;
}

.pt-8 {
    padding-top: 8px !important;
}

.p-2 {
    padding: 2px !important;
}

.p-10 {
    padding: 10px !important;
}

.p-16 {
    padding: 16px !important;
}

.p-20 {
    padding: 20px !important;
}

.p-20-24 {
    padding: 20px 24px !important;
}

.p-y-48 {
    padding-top: 48px !important;
    padding-bottom: 48px !important;
}

.p-y-60 {
    padding-top: 60px !important;
    padding-bottom: 60px !important;
}

.p-x-8 {
    padding-left: 8px !important;
    padding-right: 8px !important;
}

.m-y-12-14 {
    margin-top: 12px !important;
    margin-bottom: 14px !important;
}

.m-y-14-4 {
    margin-top: 14px !important;
    margin-bottom: 4px !important;
}

.m-y-4-0 {
    margin: 4px 0 !important;
}

.p-y-12 {
    padding-top: 12px !important;
    padding-bottom: 12px !important;
}

.p-x-24 {
    padding-left: 24px !important;
    padding-right: 24px !important;
}

.p-x-4 {
    padding-left: 4px !important;
    padding-right: 4px !important;
}

.p-y-6 {
    padding-top: 6px !important;
    padding-bottom: 6px !important;
}

.pl-24 {
    padding-left: 24px !important;
}

.pl-28 {
    padding-left: 28px !important;
}

.text-left {
    text-align: left !important;
}

.text-center {
    text-align: center !important;
}

.text-right {
    text-align: right !important;
}

.text-nowrap {
    white-space: nowrap !important;
}

.fw-normal {
    font-weight: normal !important;
}

.fw-600 {
    font-weight: 600 !important;
}

.fw-bold {
    font-weight: bold !important;
}

.fs-075 {
    font-size: 0.75rem !important;
}

.fs-07rem {
    font-size: 0.7rem !important;
}

.fs-08 {
    font-size: 0.8rem !important;
}

.fs-085 {
    font-size: 0.85rem !important;
}

.fs-082 {
    font-size: 0.82rem !important;
}

.fs-088 {
    font-size: 0.88rem !important;
}

.fs-09 {
    font-size: 0.9rem !important;
}

.fs-092 {
    font-size: 0.92rem !important;
}

.fs-1rem {
    font-size: 1rem !important;
}

.fs-11 {
    font-size: 1.1rem !important;
}

.fs-12rem {
    font-size: 1.2rem !important;
}

.fs-14rem {
    font-size: 1.4rem !important;
}

.fs-2rem {
    font-size: 2rem !important;
}

.fs-25rem {
    font-size: 2.5rem !important;
}

.lh-1 {
    line-height: 1 !important;
}

.lh-12 {
    line-height: 1.2 !important;
}

.cursor-pointer {
    cursor: pointer !important;
}

.text-success {
    color: var(--success) !important;
}

.text-danger {
    color: var(--danger) !important;
}

.text-warning {
    color: var(--warning) !important;
}

.text-muted {
    color: var(--text3) !important;
}

.text-income {
    color: var(--income) !important;
}

.text-expense {
    color: var(--expense) !important;
}

.text-darkred {
    color: #8B0000 !important;
}

.text-disabled {
    color: var(--text3) !important;
}

.text-disabled {
    color: var(--text3) !important;
}

.text-default {
    color: var(--text) !important;
}

.bg-success {
    background: var(--success) !important;
}

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

.bg-surface2 {
    background: var(--surface2) !important;
}

.bg-stocks {
    background: rgba(78, 205, 196, .15) !important;
}

.bg-stocks {
    background: rgba(78, 205, 196, .15) !important;
}

.bg-accent-light {
    background: rgba(108, 99, 255, .15) !important;
}

.bg-warning-light {
    background: rgba(255, 165, 0, .15) !important;
}

.bg-danger-light {
    background: rgba(255, 92, 92, .1) !important;
}

.bg-opacity-02 {
    background: rgba(0, 0, 0, 0.02) !important;
}

.text-teal {
    color: #4ecdc4 !important;
}

.text-accent {
    color: var(--accent) !important;
}

.w-0 {
    width: 0 !important;
}

.w-40 {
    width: 40% !important;
}

.w-50 {
    width: 50% !important;
}

.w-100 {
    width: 100% !important;
}

.h-100 {
    height: 100% !important;
}

.max-w-140 {
    max-width: 140px !important;
}

.max-w-200 {
    max-width: 200px !important;
}

.max-w-300 {
    max-width: 300px !important;
}

.min-w-100px {
    min-width: 100px !important;
}

.min-w-0 {
    min-width: 0 !important;
}

.border-top {
    border-top: 1px solid var(--border) !important;
}

.border-bottom {
    border-bottom: 1px solid var(--border) !important;
}

.border-left {
    border-left: 1px solid var(--border) !important;
}

.border-right {
    border-right: 1px solid var(--border) !important;
}

.opacity-05 {
    opacity: 0.5 !important;
}

.opacity-06 {
    opacity: 0.6 !important;
}

.opacity-085 {
    opacity: 0.85 !important;
}

.opacity-09 {
    opacity: 0.9 !important;
}

.opacity-08 {
    opacity: 0.8 !important;
}

.visibility-hidden {
    visibility: hidden !important;
}

.overflow-y-auto {
    overflow-y: auto !important;
}

.max-h-300 {
    max-height: 300px !important;
}

.object-fit-cover {
    object-fit: cover !important;
}

.rounded-6 {
    border-radius: 6px !important;
}

.rounded-circle {
    border-radius: 50% !important;
}

.w-auto {
    width: auto !important;
}

.w-100 {
    width: 100% !important;
}

.max-w-560 {
    max-width: 560px !important;
}

.p-24 {
    padding: 24px !important;
}

.lh-1 {
    line-height: 1 !important;
}

.accent-accent {
    accent-color: var(--accent) !important;
}

.border-left-3-danger {
    border-left: 3px solid var(--danger) !important;
}

.balance-chart-container {
    margin: 10px;
    padding: 10px;
    width: calc(100% - 20px);
    height: 500px;
    background: var(--surface2);
    border-radius: var(--radius);
    border: 1px solid var(--border);
    box-sizing: border-box;
}

.graph-diff-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 12px;
    margin: 0 10px 10px;
}

.graph-diff-card {
    background: var(--surface2);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 14px 16px;
    min-width: 0;
}

.graph-diff-label {
    color: var(--text2);
    font-size: 1.2rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    line-height: 1.3;
}

.graph-diff-value {
    margin-top: 10px;
    font-size: 1.35rem;
    font-weight: 700;
    line-height: 1.1;
}

.graph-diff-meta {
    color: var(--text3);
    font-size: 0.82rem;
}

.graph-diff-lines {
    margin-top: 12px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    padding-top: 10px;
    border-top: 1px solid var(--border);
}

.graph-diff-line {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    font-size: 0.88rem;
}

.graph-diff-line-label {
    color: var(--text2);
}

.graph-diff-line-value {
    text-align: right;
    font-weight: 700;
    white-space: nowrap;
}

.crypto-analytics-wrap {
    padding: 10px;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.crypto-kpi-grid {
    display: grid;
    grid-template-columns: repeat(6, minmax(0, 1fr));
    gap: 10px;
}

.crypto-kpi-card,
.crypto-panel,
.crypto-chart-container,
.crypto-warnings,
.crypto-last-sync {
    background: var(--surface2);
    border: 1px solid var(--border);
    border-radius: var(--radius);
}

.crypto-kpi-card {
    padding: 14px;
    min-width: 0;
}

.crypto-kpi-label {
    color: var(--text2);
    font-size: 0.78rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.crypto-kpi-value {
    margin-top: 10px;
    font-size: 1.35rem;
    font-weight: 700;
    line-height: 1.1;
}

.crypto-kpi-sub {
    margin-top: 8px;
    color: var(--text3);
    font-size: 0.82rem;
}

.crypto-warnings {
    padding: 12px 16px;
    border-color: rgba(255, 179, 71, .4);
}

.crypto-last-sync {
    padding: 14px 16px;
}

.crypto-last-sync.crypto-last-sync-alert {
    border-color: rgba(255, 179, 71, .4);
}

.crypto-sync-summary {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px;
    flex-wrap: wrap;
}

.crypto-sync-summary-meta {
    min-width: 0;
    flex: 1 1 280px;
}

.crypto-sync-summary-title {
    color: var(--text2);
    font-size: 0.76rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.crypto-sync-summary-date {
    margin-top: 4px;
    font-size: 1.18rem;
    font-weight: 700;
    line-height: 1.08;
}

.crypto-sync-summary-subtitle {
    margin-top: 6px;
    color: var(--text2);
    font-size: 0.86rem;
}

.crypto-sync-actions {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

.crypto-sync-toggle {
    display: inline-flex;
    align-items: center;
    gap: 8px;
}

.crypto-sync-toggle-alert {
    color: var(--warning);
    border-color: rgba(255, 179, 71, .4);
}

.crypto-sync-toggle-chevron {
    display: inline-block;
    font-size: 1rem;
    line-height: 1;
    transition: transform .15s ease;
}

.crypto-sync-toggle.expanded .crypto-sync-toggle-chevron {
    transform: rotate(90deg);
}

.crypto-sync-details {
    margin-top: 14px;
    padding-top: 14px;
    border-top: 1px solid var(--border);
}

.crypto-sync-detail-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 10px;
}

.crypto-sync-detail-row {
    min-width: 0;
    padding: 10px 12px;
    background: var(--surface3);
    border: 1px solid var(--border);
    border-radius: 10px;
}

.crypto-sync-detail-label {
    color: var(--text3);
    font-size: 0.74rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.crypto-sync-detail-value {
    margin-top: 6px;
    color: var(--text);
    font-size: 0.9rem;
    word-break: break-word;
}

.crypto-sync-warning-block {
    margin-top: 12px;
    padding-top: 12px;
    border-top: 1px dashed var(--border);
}

.crypto-last-sync-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    flex-wrap: wrap;
}

.crypto-last-sync-line {
    color: var(--text2);
    font-size: 0.88rem;
}

.page-analytics-crypto .tx-leg-cur-tag {
    color: var(--text3) !important;
    background: var(--surface3) !important;
    border-color: var(--border) !important;
    opacity: .8 !important;
}

.crypto-warnings-title {
    font-weight: 700;
    color: var(--warning);
    margin-bottom: 6px;
}

.crypto-warning-list {
    margin: 0;
    padding-left: 18px;
    color: var(--text2);
}

.crypto-warning-list li + li {
    margin-top: 4px;
}

.crypto-chart-container {
    min-height: 460px;
    padding: 10px;
}

.crypto-panels-grid {
    display: grid;
    grid-template-columns: minmax(0, 1.6fr) minmax(320px, 0.9fr);
    gap: 10px;
}

.crypto-panel-head {
    padding: 14px 16px;
    border-bottom: 1px solid var(--border);
}

.crypto-panel-head h3 {
    font-size: 0.95rem;
    font-weight: 700;
}

.crypto-assets-wrap,
.crypto-sync-body {
    padding: 12px;
}

.crypto-assets-wrap {
    overflow-x: auto;
    overflow-y: hidden;
    -webkit-overflow-scrolling: touch;
}

.crypto-assets-table {
    width: max-content;
    min-width: 100%;
}

.crypto-assets-table td {
    vertical-align: top;
}

.crypto-asset-primary {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    color: #fff;
}

.crypto-asset-code {
    color: #fff;
    font-size: 1.08rem;
    font-weight: 700;
    line-height: 1.2;
}

.crypto-value-main {
    color: #fff;
}

.crypto-asset-name {
    margin-top: 4px;
    color: var(--text2);
    font-size: 0.92rem;
}

.crypto-map-input {
    min-width: 160px;
}

.crypto-settings-table-wrap {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

.crypto-sync-lines {
    display: flex;
    flex-direction: column;
    gap: 6px;
    color: var(--text2);
    font-size: 0.88rem;
}

.crypto-sync-line {
    padding: 8px 10px;
    background: rgba(255, 255, 255, .02);
    border: 1px solid rgba(255, 255, 255, .04);
    border-radius: var(--radius-sm);
}

.crypto-sync-actions {
    display: flex;
    gap: 8px;
    margin-top: 12px;
    flex-wrap: wrap;
}

.crypto-sync-progress {
    margin-bottom: 14px;
}

.crypto-sync-progress-wrap {
    background: rgba(255, 255, 255, .06);
}

.crypto-sync-progress-bar.is-running {
    width: 42%;
    animation: crypto-sync-indeterminate 1.35s ease-in-out infinite;
}

@keyframes crypto-sync-indeterminate {
    0% {
        width: 18%;
        transform: translateX(-10%);
    }
    50% {
        width: 62%;
        transform: translateX(40%);
    }
    100% {
        width: 22%;
        transform: translateX(320%);
    }
}

@media (max-width: 1200px) {
    .crypto-kpi-grid {
        grid-template-columns: repeat(3, minmax(0, 1fr));
    }

    .crypto-panels-grid {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 768px) {
    .crypto-kpi-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .crypto-chart-container {
        min-height: 380px;
    }

    .crypto-last-sync-row {
        align-items: stretch;
    }
}

@media (max-width: 520px) {
    .crypto-kpi-grid {
        grid-template-columns: 1fr 1fr;
    }
}

.font-mono {
    font-family: monospace !important;
}

.grid-2col-gap-24 {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 24px;
}

@media (max-width: 1100px) {
    .grid-2col-gap-24 {
        grid-template-columns: 1fr;
    }
}

.maintenance-table-scroll {
    max-height: 400px;
    overflow-y: auto;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 10px;
}

.text-fs-85 {
    font-size: 0.85rem !important;
}

.text-fs-100 {
    font-size: 1rem !important;
}

.maintenance-row-hidden {
    opacity: 0.5;
    filter: grayscale(0.5);
}

.truncate-180 {
    max-width: 180px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.truncate-140 {
    max-width: 140px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.tx-history-json {
    background: var(--surface2);
    padding: 10px;
    border-radius: var(--radius-sm);
    font-family: monospace;
    font-size: 0.8rem;
    overflow-x: auto;
}

#btnTxHistoryLoadMore {
    margin: 12px auto;
    display: block;
}

.tx-history-mobile-head,
.tx-history-mobile-status,
.tx-history-items-mobile,
.tx-history-mobile-conflicts {
    display: none;
}

.tx-history-footer-id {
    display: inline-flex;
    align-items: center;
    margin-right: auto;
    color: var(--text2);
    font-size: 0.78rem;
    line-height: 1;
}

.tx-history-type-text {
    font-weight: 700;
    color: var(--text);
}

@media (max-width: 480px) {
    #tab-tx-history .card-subtitle {
        display: none;
    }

    #btnRefreshTxHistory {
        padding-inline: 10px;
    }

    #btnRefreshTxHistory .tx-history-refresh-text {
        display: none;
    }

    #txHistoryTable tr {
        margin-bottom: 10px;
        padding: 9px 10px;
    }

    #txHistoryTable td {
        padding: 2px 0 !important;
        font-size: 0.82rem;
        min-height: 0;
    }

    #txHistoryTable td:before {
        display: none;
    }

    #txHistoryTable .tx-history-col-id,
    #txHistoryTable .tx-history-col-number,
    #txHistoryTable .tx-history-col-type,
    #txHistoryTable .tx-history-col-actions {
        display: flex !important;
        width: 100% !important;
        justify-content: flex-start;
        text-align: left;
    }

    #txHistoryTable .tx-history-col-number {
        justify-content: space-between;
        align-items: flex-start;
        margin-bottom: 2px;
        color: var(--text);
    }

    #txHistoryTable .tx-history-col-type {
        align-items: center;
        gap: 6px;
        margin-bottom: 1px;
    }

    #txHistoryTable .tx-history-col-items {
        display: none !important;
    }

    #txHistoryTable .tx-history-col-user,
    #txHistoryTable .tx-history-col-id,
    #txHistoryTable .tx-history-col-created,
    #txHistoryTable .tx-history-col-status,
    #txHistoryTable .tx-history-col-conflicts {
        display: none !important;
    }

    #txHistoryTable .tx-history-mobile-meta-left {
        display: inline-flex;
        align-items: center;
        gap: 6px;
    }

    #txHistoryTable .tx-history-mobile-date {
        font-weight: 700;
        color: var(--accent);
    }

    #txHistoryTable .tx-history-id-main {
        display: none;
    }

    #txHistoryTable .tx-history-mobile-head {
        display: flex;
        width: 100%;
        justify-content: space-between;
        align-items: flex-start;
        gap: 8px;
    }

    #txHistoryTable .tx-history-mobile-user {
        color: var(--text2);
        font-weight: 400;
        font-size: 0.74rem;
        text-align: right;
    }

    #txHistoryTable .tx-history-mobile-status {
        display: inline-flex;
        align-items: center;
        color: var(--text2);
    }

    #txHistoryTable .tx-history-col-actions {
        margin-top: 6px;
        padding-top: 6px !important;
        border-top: 1px solid var(--border) !important;
        justify-content: space-between;
        align-items: center;
        gap: 4px;
    }

    #txHistoryTable .tx-history-footer-id {
        font-size: 0.72rem;
    }

    #txHistoryTable .tx-history-col-actions .btn {
        padding: 5px 7px;
    }

    #txHistoryTable .tx-history-btn-text {
        display: none;
    }
}

.tx-history-status-icon-stack {
    position: relative;
    display: inline-flex;
    width: 14px;
    height: 14px;
    align-items: center;
    justify-content: center;
}

.tx-history-status-icon-stack .icon {
    width: 14px;
    height: 14px;
}

.tx-history-status-check {
    position: absolute;
    right: -3px;
    bottom: -3px;
    display: inline-flex;
    width: 9px;
    height: 9px;
    align-items: center;
    justify-content: center;
    border-radius: 999px;
    background: var(--success);
    color: #fff;
    font-size: 8px;
    line-height: 1;
    font-weight: 700;
}

.doc-view-toolbar {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 18px;
}

.doc-markdown {
    color: var(--text);
    line-height: 1.65;
    overflow-wrap: anywhere;
}

.doc-markdown > :first-child {
    margin-top: 0;
}

.doc-markdown > :last-child {
    margin-bottom: 0;
}

.doc-markdown h1,
.doc-markdown h2,
.doc-markdown h3,
.doc-markdown h4,
.doc-markdown h5,
.doc-markdown h6 {
    margin: 1.4rem 0 0.7rem;
    color: var(--text);
    line-height: 1.25;
}

.doc-markdown h1 {
    font-size: 1.55rem;
}

.doc-markdown h2 {
    font-size: 1.25rem;
}

.doc-markdown h3 {
    font-size: 1.1rem;
}

.doc-markdown p {
    margin: 0 0 0.9rem;
    color: var(--text2);
}

.doc-markdown blockquote {
    margin: 0 0 1rem;
    padding: 0.85rem 1rem;
    border-left: 3px solid var(--accent);
    background: rgba(108, 99, 255, 0.08);
    border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
}

.doc-markdown blockquote p {
    margin: 0;
}

.doc-markdown ul,
.doc-markdown ol {
    margin: 0 0 1rem 1.35rem;
    padding: 0;
}

.doc-markdown li {
    margin: 0 0 0.45rem;
    color: var(--text2);
}

.doc-markdown code {
    display: inline;
    padding: 0.08rem 0.38rem;
    border-radius: 5px;
    background: var(--surface2);
    border: 1px solid var(--border);
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    font-size: 0.92em;
    color: var(--text);
}

.doc-markdown a {
    color: var(--accent);
    text-decoration: underline;
    text-underline-offset: 2px;
    cursor: pointer;
}

.doc-markdown a:hover {
    color: var(--accent2);
}

.doc-markdown hr {
    border: 0;
    border-top: 1px solid var(--border);
    margin: 1.35rem 0;
}

.doc-code-block {
    margin: 0 0 1rem;
    padding: 14px 16px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
    background: var(--surface2);
    overflow-x: auto;
}

.doc-code-block code {
    display: block;
    margin: 0;
    padding: 0;
    border: 0;
    background: transparent;
    color: var(--text);
    font-size: 0.88rem;
    line-height: 1.55;
    white-space: pre;
}

.doc-table-wrap {
    margin: 0 0 1rem;
    overflow-x: auto;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
}

.doc-markdown table {
    width: max-content;
    min-width: 100%;
    margin: 0;
    border-collapse: collapse;
    table-layout: auto;
    font-size: 0.9rem;
}

.doc-markdown th,
.doc-markdown td {
    padding: 10px 12px;
    border-bottom: 1px solid var(--border);
    border-right: 1px solid var(--border);
    vertical-align: top;
    white-space: nowrap;
}

.doc-markdown th:last-child,
.doc-markdown td:last-child {
    border-right: 0;
}

.doc-markdown thead th {
    background: var(--surface2);
    color: var(--text);
    font-weight: 600;
}

.doc-markdown tbody tr:nth-child(odd) td {
    background: rgba(255, 255, 255, 0.02);
}

.doc-markdown tbody tr:last-child td {
    border-bottom: 0;
}

.doc-markdown .doc-align-center {
    text-align: center;
}

.doc-markdown .doc-align-right {
    text-align: right;
}

.maintenance-table-scroll {
    max-height: 400px;
    overflow-y: auto;
}

.cat-selector-list {
    max-height: 240px;
    overflow-y: auto;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 10px;
    background: var(--surface2);
}

.cat-selector-item {
    display: flex;
    align-items: center;
    gap: 10px;
    cursor: pointer;
    border-radius: 4px;
    transition: background 0.2s;
}

.cat-selector-item:not(.disabled):hover {
    background: rgba(0, 0, 0, 0.03);
}

.cat-selector-item.disabled {
    cursor: not-allowed;
}

.category-groups-layout {
    display: grid;
    grid-template-columns: minmax(0, 2fr) minmax(280px, 1fr);
    gap: 20px;
    align-items: start;
}

.category-groups-column {
    min-width: 0;
}

.category-groups-column-title {
    font-size: .8rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .04em;
    color: var(--text2);
    margin-bottom: 10px;
}

.category-groups-board {
    display: grid;
    gap: 14px;
}

.category-group-card {
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--surface2);
    box-shadow: var(--shadow-sm);
}

.category-group-card.is-dragging-group {
    opacity: .7;
}

.category-group-card-unassigned {
    min-height: 240px;
}

.category-group-card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 14px 14px 10px;
    border-bottom: 1px solid var(--border);
}

.category-group-card-title {
    display: flex;
    align-items: center;
    gap: 8px;
    min-width: 0;
}

.category-group-card-title strong {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.category-group-card-handle {
    flex: 0 0 auto;
}

.category-group-card-body {
    padding: 12px;
}

.category-group-dropzone {
    min-height: 96px;
    display: grid;
    gap: 8px;
    padding: 10px;
    border: 1px dashed transparent;
    border-radius: var(--radius-sm);
    background: var(--bg);
    transition: border-color .15s ease, background .15s ease;
}

.category-group-dropzone.is-drop-target {
    border-color: var(--accent);
    background: color-mix(in srgb, var(--accent) 10%, var(--surface));
}

.category-group-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    padding: 9px 10px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
    background: var(--surface);
    cursor: grab;
}

.category-group-item.is-dragging {
    opacity: .55;
}

.category-group-item-label {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.category-groups-empty {
    color: var(--text2);
    font-size: .86rem;
    text-align: center;
    padding: 18px 12px;
}

@media (max-width: 900px) {
    .category-groups-layout {
        grid-template-columns: 1fr;
    }
}

.expand-toggle {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 18px;
    height: 18px;
    user-select: none;
    color: var(--text2);
    transition: transform var(--transition);
}

.expand-toggle::before {
    content: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='10' viewBox='0 0 24 24' fill='none' stroke='%239198b5' stroke-width='3' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M9 6l6 6l-6 6'/%3E%3C/svg%3E");
    display: block;
    line-height: 1;
}

.expand-toggle.expanded {
    transform: rotate(90deg);
}

.field-hint {
    font-size: 0.74rem;
    color: var(--text2);
}

.fs-095 {
    font-size: 0.95rem !important;
}

.fs-08 {
    font-size: 0.8rem !important;
}

.w-16px {
    width: 16px !important;
}

.h-16px {
    height: 16px !important;
}

.w-30px {
    width: 30px !important;
}

.w-40px {
    width: 40px !important;
}

.w-50px {
    width: 50px !important;
}

.w-60px {
    width: 60px !important;
}

.w-80px {
    width: 80px !important;
}

.max-w-200 {
    max-width: 200px !important;
}

.h-32px {
    height: 32px !important;
}

.color-input-preview {
    padding: 2px;
    border-radius: 6px;
    border: 1px solid var(--border);
    background: var(--surface2);
    cursor: pointer;
}

/* ─── Scroll Navigation ──────────────────────────────────────────────────── */
.scroll-nav {
    position: fixed;
    bottom: 15px;
    left: calc(var(--sidebar-w) + 15px);
    display: flex;
    flex-direction: column;
    gap: 12px;
    z-index: 90;
    pointer-events: none;
    transition: left var(--transition);
}

.sidebar-collapsed .scroll-nav {
    left: 15px;
}

.btn-scroll {
    pointer-events: auto;
    width: 44px;
    height: 44px;
    border-radius: 12px;
    border: 1px solid rgba(255, 255, 255, 0.1);
    background: rgba(26, 29, 39, 0.6);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    color: var(--text);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: transform var(--transition), background var(--transition), box-shadow var(--transition), opacity var(--transition);
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
    opacity: 0;
    transform: translateX(-20px);
}

.btn-scroll.is-visible {
    opacity: 1;
    transform: translateX(0);
}

.btn-scroll:hover {
    background: var(--accent);
    color: #fff;
    transform: scale(1.05) translateX(4px);
    box-shadow: 0 12px 40px rgba(56, 141, 201, 0.4);
}

.btn-scroll:active {
    transform: scale(0.95) translateX(2px);
}

:root[data-theme="light"] .btn-scroll {
    background: rgba(255, 255, 255, 0.7);
    border-color: rgba(0, 0, 0, 0.05);
    color: var(--text);
    box-shadow: 0 8px 32px rgba(15, 23, 42, 0.12);
}

:root[data-theme="light"] .btn-scroll:hover {
    background: var(--accent);
    color: #fff;
}
