/* BookKeeper — assets/style.css */

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

:root {
    --primary:       #1e40af;
    --primary-dark:  #1e3a8a;
    --accent:        #2563eb;
    --accent-hover:  #1d4ed8;
    --danger:        #dc2626;
    --success:       #16a34a;
    --warning:       #d97706;
    --text:          #1f2937;
    --text-muted:    #6b7280;
    --border:        #e5e7eb;
    --bg:            #f3f4f6;
    --card-bg:       #ffffff;
    --nav-bg:        #1e40af;
    --nav-text:      #ffffff;
    --nav-hover:     rgba(255,255,255,0.15);
    --radius:        6px;
    --shadow:        0 1px 3px rgba(0,0,0,0.1), 0 1px 2px rgba(0,0,0,0.06);
    --shadow-md:     0 4px 6px rgba(0,0,0,0.07), 0 2px 4px rgba(0,0,0,0.06);
    --font:          system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
}

html { font-size: 16px; overflow-y: scroll; }
body { font-family: var(--font); background: var(--bg); color: var(--text); min-height: 100vh; display: flex; flex-direction: column; }

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

/* ── Sidebar ──────────────────────────────────────────────────── */
:root {
    --sidebar-width: 220px;
    --topbar-height: 48px;
}

body.has-sidebar { display: block; }

.sidebar {
    position: fixed; top: 0; left: 0;
    width: var(--sidebar-width); height: 100vh;
    background: var(--primary); color: #fff;
    display: flex; flex-direction: column;
    transform: translateX(calc(-1 * var(--sidebar-width)));
    transition: transform 0.25s ease;
    z-index: 300; overflow-y: auto;
    box-shadow: 2px 0 12px rgba(0,0,0,0.15);
}
.sidebar.sidebar-open { transform: translateX(0); }

.sidebar-header {
    display: flex; align-items: center; justify-content: space-between;
    padding: 1rem 1.1rem 0.75rem;
    border-bottom: 1px solid rgba(255,255,255,0.12);
    flex-shrink: 0;
}
.sidebar-brand {
    font-size: 1.15rem; font-weight: 800;
    color: #fff; text-decoration: none; letter-spacing: -0.3px;
}
.sidebar-brand:hover { text-decoration: none; opacity: 0.9; }
.sidebar-close {
    background: none; border: none; color: rgba(255,255,255,0.7);
    font-size: 1rem; cursor: pointer; padding: 0.15rem 0.35rem;
    border-radius: var(--radius); line-height: 1;
}
.sidebar-close:hover { background: rgba(255,255,255,0.1); color: #fff; }

.sidebar-entity {
    font-size: 0.75rem; font-weight: 600;
    color: rgba(255,255,255,0.55);
    padding: 0.6rem 1.1rem 0.4rem;
    text-transform: uppercase; letter-spacing: 0.06em;
    flex-shrink: 0;
}

.sidebar-nav {
    flex: 1; padding: 0.5rem 0;
    display: flex; flex-direction: column; gap: 0.1rem;
}
.sidebar-link {
    display: flex; align-items: center; gap: 0.6rem;
    padding: 0.6rem 1.1rem;
    color: rgba(255,255,255,0.85); font-size: 0.9rem;
    text-decoration: none;
    transition: background 0.12s;
}
.sidebar-link:hover { background: rgba(255,255,255,0.1); color: #fff; text-decoration: none; }
.sidebar-link.nav-active { background: rgba(255,255,255,0.18); color: #fff; font-weight: 600; }
.sidebar-icon { font-size: 0.95rem; width: 18px; text-align: center; opacity: 0.8; }

.sidebar-footer {
    border-top: 1px solid rgba(255,255,255,0.12);
    padding: 0.5rem 0; flex-shrink: 0;
}
.sidebar-logout { color: rgba(255,255,255,0.6); font-size: 0.85rem; }
.sidebar-logout:hover { color: #fff; }

.sidebar-switcher { position: relative; padding: 0.25rem 0.75rem 0.5rem; }
.sidebar-switch-btn {
    width: 100%; background: rgba(255,255,255,0.1);
    border: 1px solid rgba(255,255,255,0.2);
    color: #fff; border-radius: var(--radius);
    padding: 0.4rem 0.75rem; font-size: 0.82rem;
    cursor: pointer; text-align: left;
}
.sidebar-switch-btn:hover { background: rgba(255,255,255,0.18); }
.sidebar-entity-menu {
    display: none; position: absolute;
    bottom: calc(100% + 4px); left: 0.75rem; right: 0.75rem;
    background: var(--primary-dark); border: 1px solid rgba(255,255,255,0.15);
    border-radius: var(--radius); overflow: hidden; z-index: 400;
}
.sidebar-entity-menu.open { display: block; }
.sidebar-entity-item {
    display: block; width: 100%; text-align: left;
    padding: 0.55rem 0.85rem; font-size: 0.875rem;
    color: rgba(255,255,255,0.85); background: none;
    border: none; cursor: pointer; text-decoration: none;
    transition: background 0.1s;
}
.sidebar-entity-item:hover { background: rgba(255,255,255,0.1); color: #fff; text-decoration: none; }

.sidebar-overlay {
    display: none; position: fixed; inset: 0;
    background: rgba(0,0,0,0.45); z-index: 299;
}
.sidebar-overlay-visible { display: block; }

/* ── Topbar ───────────────────────────────────────────────────── */
.topbar {
    position: fixed; top: 0; left: 0; right: 0;
    height: var(--topbar-height);
    background: var(--primary); color: #fff;
    display: flex; align-items: center; gap: 0.75rem;
    padding: 0 1rem; z-index: 200;
    box-shadow: 0 2px 6px rgba(0,0,0,0.2);
}
.topbar-auth { justify-content: center; }
.topbar-brand { color: #fff; font-weight: 800; font-size: 1.15rem; text-decoration: none; letter-spacing: -0.3px; }
.topbar-brand:hover { text-decoration: none; opacity: 0.9; }
.topbar-toggle {
    display: flex; flex-direction: column; gap: 4px;
    background: none; border: none; cursor: pointer;
    padding: 0.35rem; border-radius: var(--radius); flex-shrink: 0;
}
.topbar-toggle:hover { background: rgba(255,255,255,0.1); }
.topbar-toggle span {
    display: block; width: 20px; height: 2px;
    background: #fff; border-radius: 2px;
}
.topbar-title {
    font-size: 0.95rem; font-weight: 600; color: #fff;
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.topbar-entity { font-weight: 400; opacity: 0.7; margin-left: 0.25rem; }

/* ── Topbar quick-access nav ─────────────────────────────────── */
.topbar-quicknav {
    display: flex; align-items: center; gap: 0.25rem;
    position: absolute; left: 50%; transform: translateX(-50%);
    /* Centers the nav regardless of left/right content widths */
}
.topbar-quicknav-link {
    color: rgba(255,255,255,0.82);
    font-size: 0.82rem; font-weight: 500;
    text-decoration: none;
    padding: 0.3rem 0.75rem;
    border-radius: var(--radius);
    white-space: nowrap;
    transition: background 0.15s, color 0.15s;
}
.topbar-quicknav-link:hover {
    background: rgba(255,255,255,0.15);
    color: #fff;
    text-decoration: none;
}
.topbar-quicknav-active {
    background: rgba(255,255,255,0.2);
    color: #fff !important;
    font-weight: 600;
}

/* ── Topbar entity switcher ───────────────────────────────────── */
.topbar-switcher { position: relative; }
.topbar-switch-btn {
    background: rgba(255,255,255,0.15);
    border: 1px solid rgba(255,255,255,0.3);
    color: #fff; border-radius: var(--radius);
    padding: 0.3rem 0.75rem; font-size: 0.82rem;
    cursor: pointer; white-space: nowrap;
}
.topbar-switch-btn:hover { background: rgba(255,255,255,0.25); }
.topbar-entity-menu {
    display: none; position: absolute;
    top: calc(100% + 6px); right: 0;
    background: var(--card-bg); border: 1px solid var(--border);
    border-radius: var(--radius); box-shadow: var(--shadow-md);
    min-width: 180px; z-index: 400; overflow: hidden;
}
.topbar-entity-menu.open { display: block; }
.topbar-entity-item {
    display: block; width: 100%; text-align: left;
    padding: 0.55rem 0.85rem; font-size: 0.875rem;
    color: var(--text); background: none;
    border: none; cursor: pointer; text-decoration: none;
    transition: background 0.1s;
}
.topbar-entity-item:hover { background: var(--bg); text-decoration: none; }

/* ── Main Content ─────────────────────────────────── */
.main-content {
    max-width: 1400px; width: 100%;
    margin: 0 auto;
    padding: calc(var(--topbar-height) + 1.5rem) 1.5rem 1.5rem;
    min-height: 100vh;
}

/* ── Footer ───────────────────────────────────────── */
.footer { background: var(--card-bg); border-top: 1px solid var(--border); }
.footer-inner { max-width: 1400px; margin: 0 auto; padding: 1rem 1.5rem; color: var(--text-muted); font-size: 0.8rem; }

/* ── Alerts / Flash ───────────────────────────────── */
.alert {
    padding: 0.75rem 1rem; border-radius: var(--radius);
    margin-bottom: 1rem; font-size: 0.9rem; border: 1px solid transparent;
}
.alert-success { background: #dcfce7; border-color: #86efac; color: #166534; }
.alert-error   { background: #fee2e2; border-color: #fca5a5; color: #991b1b; }
.alert-warning { background: #fef9c3; border-color: #fde047; color: #713f12; }
.alert-info    { background: #dbeafe; border-color: #93c5fd; color: #1e40af; }

/* ── Cards ────────────────────────────────────────── */
.card {
    background: var(--card-bg); border: 1px solid var(--border);
    border-radius: var(--radius); box-shadow: var(--shadow);
    padding: 1.25rem;
    margin-left: auto; margin-right: auto;
}
.card-header {
    display: flex; align-items: center; justify-content: space-between;
    margin-bottom: 1rem; padding-bottom: 0.75rem;
    border-bottom: 1px solid var(--border);
}
.card-title { font-size: 1rem; font-weight: 600; color: var(--text); }
.cr-entry-type-callout {
    font-size: 1.15rem; font-weight: 700; color: var(--primary);
}
[data-theme="dark"] .cr-entry-type-callout { color: var(--accent); }

/* ── Collapsible card sections ───────────────────────────────── */
.collapsible-header {
    display: flex; align-items: center; justify-content: space-between;
    cursor: pointer; user-select: none;
}
.collapse-toggle-btn {
    background: none; border: none; cursor: pointer;
    font-size: 1rem; color: var(--text-muted);
    padding: 0.2rem 0.4rem; line-height: 1;
    transition: transform 0.25s ease;
}
.collapse-toggle-btn:hover { color: var(--text); }
.collapse-toggle-btn.is-collapsed { transform: rotate(-90deg); }

/* Animates open/closed by transitioning max-height (height: auto can't
   be transitioned directly, and display: none has no intermediate state
   to animate through). max-height is set generously high — 2000px is
   well beyond any realistic card content here — so the transition timing
   is driven by actual content height, not by counting down from an
   arbitrary large number every time. */
.collapsible-body {
    max-height: 2000px;
    opacity: 1;
    overflow: hidden;
    transition: max-height 0.3s ease, opacity 0.25s ease, margin-top 0.3s ease;
}
.collapsible-body.is-collapsed {
    max-height: 0;
    opacity: 0;
    margin-top: 0;
}
.collapsible-body.no-transition { transition: none; }

/* ── Page Header ──────────────────────────────────── */
.page-header {
    display: flex; align-items: center; justify-content: space-between;
    margin-bottom: 1.25rem;
}
.page-title { font-size: 1.4rem; font-weight: 700; color: var(--text); }
.page-title-entity {
    font-size: 1rem; font-weight: 500;
    color: var(--text-muted); margin-left: 0.25rem;
}

/* ── Stat Cards (Dashboard) ───────────────────────── */
.stat-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1rem; margin-bottom: 1.5rem;
}
.stat-card {
    background: var(--card-bg); border: 1px solid var(--border);
    border-radius: var(--radius); padding: 1.25rem;
    box-shadow: var(--shadow);
}
.stat-label { font-size: 0.8rem; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.05em; font-weight: 600; }
.stat-value { font-size: 1.75rem; font-weight: 700; color: var(--text); margin-top: 0.25rem; }
.stat-value.positive { color: var(--success); }
.stat-value.negative { color: var(--danger); }

/* ── Buttons ──────────────────────────────────────── */
.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 0.4rem;
    padding: 0.5rem 1rem; border-radius: var(--radius);
    font-size: 0.875rem; font-weight: 500; cursor: pointer;
    border: 1px solid transparent; transition: background 0.15s, opacity 0.15s;
    text-decoration: none; line-height: 1;
}
.btn:hover { text-decoration: none; }
.btn-primary  { background: var(--accent); color: #fff; border-color: var(--accent); }
.btn-primary:hover  { background: var(--accent-hover); border-color: var(--accent-hover); }
.btn-danger   { background: var(--danger); color: #fff; border-color: var(--danger); }
.btn-danger:hover   { background: #b91c1c; }
.btn-warning  { background: #d97706; color: #fff; border-color: #d97706; }
.btn-warning:hover  { background: #b45309; }
.btn-outline  { background: transparent; color: var(--nav-text); border-color: rgba(255,255,255,0.5); }
.btn-outline:hover  { background: var(--nav-hover); }
.btn-secondary { background: #e5e7eb; color: var(--text); border-color: #d1d5db; }
.btn-secondary:hover { background: #d1d5db; }
.btn-sm { padding: 0.3rem 0.65rem; font-size: 0.8rem; }

/* ── Forms ────────────────────────────────────────── */
.form-group  { margin-bottom: 1rem; }
.form-label  { display: block; font-size: 0.85rem; font-weight: 600; color: var(--text); margin-bottom: 0.3rem; }
.form-control {
    width: 100%; padding: 0.5rem 0.75rem;
    border: 1px solid var(--border); border-radius: var(--radius);
    font-size: 0.9rem; font-family: var(--font);
    background: #fff; color: var(--text);
    transition: border-color 0.15s, box-shadow 0.15s;
}
.form-control:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px rgba(37,99,235,0.15); }
.form-control.is-invalid { border-color: var(--danger); }
.form-control.is-invalid:focus { border-color: var(--danger); box-shadow: 0 0 0 3px rgba(220,38,38,0.15); }
.form-hint { font-size: 0.78rem; color: var(--text-muted); margin-top: 0.25rem; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }
.form-actions { display: flex; gap: 0.75rem; align-items: center; margin-top: 1.25rem; }

/* ── Tables ───────────────────────────────────────── */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 0.875rem; }

/* Payroll — YTD summary table and entries table share these column
   widths (via <colgroup>) so the two separate <table> elements line
   up visually even though tables don't share layout state with each
   other by default. */
.payroll-ytd-table { table-layout: fixed; width: 100%; border-collapse: collapse; font-size: 0.875rem; }
.payroll-ytd-table td, .payroll-ytd-table th { padding: 0.6rem 0.75rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pr-col-date     { width: 11%; }
.pr-col-employee { width: 15%; }
.pr-col-period   { width: 16%; }
.pr-col-money    { width: 9%; }
.pr-col-actions  { width: 150px; }
.payroll-ytd-label { font-size: 19px; font-weight: 700; white-space: normal; }
.payroll-ytd-table tbody tr:hover { background: transparent; }
.payroll-clickable-row { cursor: pointer; }
.payroll-clickable-row:hover td { background: #f0f4ff; }
[data-theme="dark"] .payroll-clickable-row:hover td { background: #263044; }

thead th {
    background: var(--bg); border-bottom: 2px solid var(--border);
    padding: 0.6rem 0.75rem; text-align: left;
    font-size: 0.78rem; font-weight: 700; color: var(--text-muted);
    text-transform: uppercase; letter-spacing: 0.05em; white-space: nowrap;
}
tbody td { padding: 0.65rem 0.75rem; border-bottom: 1px solid var(--border); vertical-align: middle; }
tbody tr:last-child td { border-bottom: none; }
tbody tr:hover { background: #f9fafb; }
.td-actions { display: flex; gap: 0.5rem; white-space: nowrap; }
.td-amount { font-weight: 600; font-variant-numeric: tabular-nums; }
.td-amount.credit { color: var(--success); }
.td-amount.debit  { color: var(--danger); }

/* ── Auth Pages (Login / Register) ───────────────── */
.auth-wrap {
    min-height: 100vh; display: flex;
    align-items: center; justify-content: center;
    background: var(--bg); padding: 1rem;
}
.auth-card {
    background: var(--card-bg); border: 1px solid var(--border);
    border-radius: var(--radius); box-shadow: var(--shadow-md);
    padding: 2rem; width: 100%; max-width: 420px;
}
.auth-logo {
    text-align: center; margin-bottom: 1.5rem;
}
.auth-logo h1 {
    font-size: 1.5rem; font-weight: 800;
    color: var(--primary); letter-spacing: -0.5px;
}
.auth-logo p { font-size: 0.85rem; color: var(--text-muted); margin-top: 0.25rem; }
.auth-card h2 { font-size: 1.1rem; font-weight: 700; margin-bottom: 1.25rem; }
.auth-footer { text-align: center; margin-top: 1.25rem; font-size: 0.85rem; color: var(--text-muted); }

/* ── Utilities ────────────────────────────────────── */
.text-right  { text-align: right; }
.text-center { text-align: center; }
.text-muted  { color: var(--text-muted); font-size: 0.85rem; }
.text-danger { color: var(--danger); }
.text-success{ color: var(--success); }
.mt-1 { margin-top: 0.5rem; }
.mt-2 { margin-top: 1rem; }
.mt-3 { margin-top: 1.5rem; }
.mb-1 { margin-bottom: 0.5rem; }
.mb-2 { margin-bottom: 1rem; }
.badge {
    display: inline-block; padding: 0.2em 0.55em;
    border-radius: 999px; font-size: 0.72rem; font-weight: 700;
    text-transform: uppercase; letter-spacing: 0.04em;
}
.badge-success { background: #dcfce7; color: #166534; }
.badge-danger  { background: #fee2e2; color: #991b1b; }
.badge-warning { background: #fef9c3; color: #713f12; }
.badge-info    { background: #dbeafe; color: #1e40af; }
.badge-gray    { background: #f3f4f6; color: #6b7280; }
.badge-purple  { background: #ede9fe; color: #5b21b6; }

/* ── Entity Switcher (nav) ────────────────────────────────────── */
.nav-entity {
    font-size: 0.85rem; opacity: 0.9;
    display: flex; align-items: center; gap: 0.35rem;
}
.entity-switcher { position: relative; }
.entity-switcher-btn {
    display: flex; align-items: center; gap: 0.4rem;
    background: rgba(255,255,255,0.15); border: 1px solid rgba(255,255,255,0.25);
    color: var(--nav-text); border-radius: var(--radius);
    padding: 0.3rem 0.65rem; font-size: 0.85rem; cursor: pointer;
    transition: background 0.15s;
}
.entity-switcher-btn:hover { background: rgba(255,255,255,0.25); }
.entity-switcher-caret { font-size: 0.7rem; opacity: 0.8; }

.entity-switcher-menu {
    display: none; position: absolute; top: calc(100% + 6px); right: 0;
    background: var(--card-bg); border: 1px solid var(--border);
    border-radius: var(--radius); box-shadow: var(--shadow-md);
    min-width: 200px; z-index: 200; overflow: hidden;
}
.entity-switcher-menu.open { display: block; }
.entity-menu-label {
    font-size: 0.72rem; font-weight: 700; text-transform: uppercase;
    letter-spacing: 0.06em; color: var(--text-muted);
    padding: 0.6rem 0.85rem 0.3rem;
}
.entity-menu-item {
    display: block; width: 100%; text-align: left;
    padding: 0.55rem 0.85rem; font-size: 0.875rem;
    color: var(--text); background: none; border: none; cursor: pointer;
    text-decoration: none; transition: background 0.1s;
}
.entity-menu-item:hover { background: var(--bg); text-decoration: none; }
.entity-menu-divider { border-top: 1px solid var(--border); margin: 0.25rem 0; }

/* ── Nav cog icon ─────────────────────────────────────────────── */
.nav-icon-btn {
    color: var(--nav-text); font-size: 1.1rem; opacity: 0.8;
    text-decoration: none; display: flex; align-items: center;
    transition: opacity 0.15s;
}
.nav-icon-btn:hover { opacity: 1; text-decoration: none; }

/* ── Entity Select Page ───────────────────────────────────────── */
.entity-list { display: flex; flex-direction: column; gap: 0.5rem; }
.entity-option {
    display: flex; align-items: center; gap: 0.85rem;
    padding: 0.9rem 1rem; border-radius: var(--radius);
    border: 1px solid var(--border); background: var(--card-bg);
    cursor: pointer; text-align: left; width: 100%;
    transition: border-color 0.15s, box-shadow 0.15s;
}
.entity-option:hover {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(37,99,235,0.1);
    text-decoration: none;
}
.entity-info { display: flex; flex-direction: column; flex: 1; }
.entity-name { font-weight: 600; font-size: 0.95rem; color: var(--text); }
.entity-arrow { color: var(--text-muted); font-size: 1rem; }

/* ── Opening Balances ─────────────────────────────────────────── */
.ob-intro {
    display: flex; gap: 1rem; align-items: flex-start;
    padding: 1.25rem;
}
.ob-intro-icon { font-size: 2rem; line-height: 1; }
.ob-intro p { margin-top: 0.35rem; font-size: 0.875rem; color: var(--text-muted); line-height: 1.5; }

.ob-hint {
    font-size: 0.8rem; color: var(--text-muted); font-style: italic;
    padding: 0 0 0.5rem 0; margin: 0 0 0.25rem;
}

.ob-account-list { display: flex; flex-direction: column; gap: 0; }

.ob-account-row {
    display: flex; align-items: center; justify-content: space-between;
    padding: 0.55rem 0; border-bottom: 1px solid var(--border);
    gap: 1rem;
}
.ob-account-row:last-child { border-bottom: none; }
.ob-account-row:hover { background: #fafafa; margin: 0 -1.25rem; padding-left: 1.25rem; padding-right: 1.25rem; }

.ob-account-info { display: flex; align-items: center; gap: 0.6rem; flex: 1; }
.ob-account-code {
    font-size: 0.75rem; font-weight: 700; color: var(--text-muted);
    background: var(--bg); padding: 0.15em 0.45em;
    border-radius: 3px; white-space: nowrap;
}
.ob-account-name { font-size: 0.9rem; color: var(--text); }

.ob-account-input {
    display: flex; align-items: center; gap: 0.4rem;
    width: 180px; flex-shrink: 0;
}
.ob-currency { color: var(--text-muted); font-weight: 600; }
.ob-amount { text-align: right; width: 130px; }
.ob-saved-indicator { color: var(--success); font-weight: 700; font-size: 1rem; }

.ob-obecard {
    display: flex; justify-content: space-between; align-items: center;
    padding: 1rem 1.25rem; background: var(--bg);
}
.ob-obecard-label { flex: 1; }
.ob-obecard-amount {
    font-size: 1.4rem; font-weight: 800;
    font-variant-numeric: tabular-nums;
}
.ob-obecard-amount.positive { color: var(--success); }
.ob-obecard-amount.negative { color: var(--danger); }

/* ── Collapsible Filter Bar ───────────────────────────────────── */
.filter-card {
    overflow: hidden;
    max-height: 0;
    opacity: 0;
    padding-top: 0 !important;
    padding-bottom: 0 !important;
    margin-bottom: 0;
    border-width: 0;
    transition: max-height 0.28s ease, opacity 0.2s ease,
                padding 0.2s ease, margin 0.2s ease, border-width 0.2s ease;
}
.filter-card.filter-open {
    max-height: 300px;
    opacity: 1;
    padding: 0.85rem 1.25rem !important;
    margin-bottom: 1rem;
    border-width: 1px;
}
.filter-card form { padding: 0; margin: 0; }
.btn-filter {
    display: inline-flex; align-items: center; gap: 0.4rem;
    padding: 0.4rem 0.85rem; border-radius: var(--radius);
    font-size: 0.85rem; font-weight: 500; cursor: pointer;
    border: 1px solid var(--border); background: var(--card-bg);
    color: var(--text); transition: background 0.15s, border-color 0.15s;
}
.btn-filter:hover { background: var(--bg); }
.btn-filter.filter-active {
    border-color: var(--accent); color: var(--accent);
    background: #eff6ff;
}
.btn-filter .filter-dot {
    width: 7px; height: 7px; border-radius: 50%;
    background: var(--accent); display: none;
}
.btn-filter.filter-active .filter-dot { display: inline-block; }

/* ── Check Register Inline Entry Form ────────────────────────── */
.cr-clickable-row { cursor: pointer; }
.cr-clickable-row:hover td { background: #f0f4ff; }
.cr-entry-card { margin-bottom: 1rem; }
/* Generic card-spacing modifier — same 1rem gap as the transaction
   register's cards, for use anywhere a page stacks multiple .card
   elements vertically (e.g. Payroll) and needs them visually separated
   rather than touching. */
.card-spaced { margin-bottom: 1rem; }
.cr-entry-row {
    display: flex; gap: 0.75rem;
    align-items: flex-end; flex-wrap: wrap;
    margin-bottom: 0.75rem;
}
.cr-entry-date     { flex: 0 0 130px; margin: 0; }
.cr-entry-checknum { flex: 0 0 110px; margin: 0; }
.cr-entry-payee    { flex: 1 1 200px; margin: 0; }
.cr-entry-bank     { flex: 1 1 180px; margin: 0; }
.cr-entry-amount   { flex: 0 0 120px; margin: 0; }
.cr-entry-what     { flex: 1 1 180px; margin: 0; }
.cr-entry-memo     { flex: 1 1 140px; margin: 0; }
.cr-entry-save     { flex: 0 0 80px; margin: 0; }

@media (max-width: 900px) {
    .cr-entry-date, .cr-entry-checknum, .cr-entry-payee,
    .cr-entry-bank, .cr-entry-amount, .cr-entry-what,
    .cr-entry-memo, .cr-entry-save { flex: 1 1 100%; }
}

/* ── Check Register ───────────────────────────────────────────── */
.cr-balance-bar {
    display: flex; justify-content: space-between; align-items: center;
    background: var(--card-bg); border: 1px solid var(--border);
    border-radius: var(--radius); padding: 0.75rem 1.25rem;
    margin-bottom: 1rem; font-size: 0.9rem; font-weight: 600;
    box-shadow: var(--shadow);
}
.cr-void-row td { opacity: 0.45; }
.cr-void-row td:first-child { text-decoration: line-through; }
.row-inactive td { opacity: 0.45; }
.row-inactive td:first-child { text-decoration: line-through; }

/* ── Reports ──────────────────────────────────────────────────── */
.report-tabs {
    display: flex; gap: 0; margin-bottom: 1.25rem;
    border-bottom: 2px solid var(--border);
}
.report-tab {
    padding: 0.6rem 1.25rem; font-size: 0.9rem; font-weight: 600;
    color: var(--text-muted); border-bottom: 2px solid transparent;
    margin-bottom: -2px; text-decoration: none; transition: color 0.15s;
}
.report-tab:hover { color: var(--accent); text-decoration: none; }
.report-tab.active { color: var(--accent); border-bottom-color: var(--accent); }

.report-card {
    background: var(--card-bg); border: 1px solid var(--border);
    border-radius: var(--radius); box-shadow: var(--shadow);
}
.report-header {
    padding: 1.5rem 1.75rem 1rem;
    border-bottom: 2px solid var(--border);
    position: relative;
}
.report-title {
    font-size: 1.4rem; font-weight: 800; color: var(--text);
}
.report-subtitle {
    font-size: 0.9rem; color: var(--text-muted); margin-top: 0.15rem;
}
.report-tenant {
    font-size: 0.85rem; font-weight: 600; color: var(--primary);
    margin-top: 0.15rem;
}
.report-print-btn {
    position: absolute; top: 1.25rem; right: 1.25rem;
}

.report-section {
    padding: 0.75rem 1.75rem;
    border-bottom: 1px solid var(--border);
}
.report-section-title {
    font-size: 0.75rem; font-weight: 700; text-transform: uppercase;
    letter-spacing: 0.06em; color: var(--text-muted);
    padding: 0.5rem 0 0.5rem; margin-bottom: 0.25rem;
}
.report-line {
    display: flex; justify-content: space-between; align-items: baseline;
    padding: 0.3rem 0.5rem; font-size: 0.9rem; border-radius: 3px;
}
.report-line:hover { background: var(--bg); }
.report-account { color: var(--text); }
.report-account code {
    font-size: 0.78rem; color: var(--text-muted);
    background: var(--bg); padding: 0.1em 0.35em;
    border-radius: 3px; margin-right: 0.4rem;
}
.report-amount {
    font-weight: 600; font-variant-numeric: tabular-nums;
    white-space: nowrap; margin-left: 1rem;
}
.report-subtotal {
    display: flex; justify-content: space-between;
    padding: 0.5rem 0.5rem 0.25rem;
    font-weight: 700; font-size: 0.9rem;
    border-top: 1px solid var(--border); margin-top: 0.25rem;
}
.report-total {
    display: flex; justify-content: space-between;
    padding: 1rem 1.75rem;
    font-size: 1rem; font-weight: 800;
    background: var(--bg); border-radius: 0 0 var(--radius) var(--radius);
}
.report-total.positive { color: var(--success); }
.report-total.negative { color: var(--danger); }
.report-warning {
    padding: 0.75rem 1.75rem;
    background: #fef9c3; color: #713f12;
    font-size: 0.85rem; border-top: 1px solid #fde047;
    border-radius: 0 0 var(--radius) var(--radius);
}

@media print {
    .topbar, .sidebar, .sidebar-overlay, .report-tabs, .card.mb-2,
    .report-print-btn, .page-header,
    #filter-card, .pagination, #acct-perpage-control,
    .tr-modal-overlay { display: none !important; }
    .main-content { padding: 0 !important; margin: 0 !important; max-width: 100%; }
    .report-card { border: none; box-shadow: none; max-width: 100%; }
    #acct-table, .cr-balance-bar { box-shadow: none; }

    /* Payroll — print only the data (entries/employees/totals tables and
       YTD summary), not the entry forms, filter controls, or row action
       buttons like Archive/Delete/Save. Scoped to Payroll's own tbody
       classes so this doesn't affect tables on other pages. */
    #entry-form, #employee-form, #entry-form-msg, #employee-form-msg { display: none !important; }
    .payroll-employees-tbody td:last-child,
    .payroll-entries-tbody td:last-child { display: none !important; }
    table:has(.payroll-employees-tbody) thead th:last-child,
    table:has(.payroll-entries-tbody) thead th:last-child { display: none !important; }
}

/* ── Transaction form tooltips & flow hint ────────────────────── */
.col-hint {
    cursor: help;
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    white-space: nowrap;
}
.col-hint-sub {
    font-size: 0.72rem;
    font-weight: 400;
    color: var(--text-muted);
    letter-spacing: 0;
}
.col-hint:hover .col-hint-sub { color: var(--accent); }

/* Native browser tooltip via title attr — enhanced with CSS tooltip */
[title] { position: relative; }

.tx-flow-hint {
    font-size: 0.8rem;
    color: var(--text-muted);
    font-style: italic;
    margin: 0 0 0.75rem;
    line-height: 1.5;
}
.tx-flow-hint strong { color: var(--text); font-style: normal; }

/* ── Transaction Form ─────────────────────────────────────────── */
#lines-table td { padding: 0.4rem 0.5rem; vertical-align: middle; }
#lines-table thead th { padding: 0.5rem; }
#lines-table tfoot td { padding: 0.65rem 0.5rem; border-top: 2px solid var(--border); }
#lines-table .form-control { margin: 0; }

.btn-remove-line {
    background: none; border: none; cursor: pointer;
    color: var(--text-muted); font-size: 1rem; line-height: 1;
    padding: 0.2rem 0.4rem; border-radius: var(--radius);
    transition: color 0.15s, background 0.15s;
}
.btn-remove-line:hover { color: var(--danger); background: #fee2e2; }

.tx-meta {
    display: flex; flex-wrap: wrap; gap: 1.25rem;
}
.tx-meta-item {
    display: flex; flex-direction: column; gap: 0.2rem;
}
.tx-meta-label {
    font-size: 0.75rem; font-weight: 700; text-transform: uppercase;
    letter-spacing: 0.05em; color: var(--text-muted);
}
.tx-totals-row td {
    border-top: 2px solid var(--border);
    background: var(--bg);
}

/* ── Pagination ───────────────────────────────────────────────── */
.pagination {
    display: flex; align-items: center; justify-content: center;
    gap: 0.75rem; padding: 1rem 0 0.25rem;
}
.pagination.pagination-right {
    justify-content: flex-end;
    padding: 0;
}

/* ── Settings Page ────────────────────────────────────────────── */
.form-row-3 {
    grid-template-columns: 2fr 1fr 1fr;
}
.section-divider {
    font-size: 0.8rem; font-weight: 700; text-transform: uppercase;
    letter-spacing: 0.05em; color: var(--text-muted);
    border-top: 1px solid var(--border);
    padding-top: 0.85rem; margin: 1rem 0 0.85rem;
    display: flex; align-items: center;
}
.section-divider-normal-case {
    text-transform: none; letter-spacing: normal;
    font-size: 0.85rem;
}
.logo-preview {
    display: flex; align-items: center; gap: 1rem;
    padding: 0.75rem; border: 1px solid var(--border);
    border-radius: var(--radius); background: var(--bg);
    margin-bottom: 0.5rem;
}
.logo-img { max-height: 60px; max-width: 180px; object-fit: contain; }
.logo-actions { display: flex; gap: 0.5rem; flex-wrap: wrap; }

/* ── User Management ──────────────────────────────────────────────────────── */
.invite-form-row {
    display: flex;
    flex-wrap: wrap;
    gap: 1rem;
    align-items: flex-end;
}
.invite-form-action { flex-shrink: 0; }

.form-control-sm {
    padding: .3rem .6rem;
    font-size: .85rem;
    height: auto;
    width: auto;
    min-width: 90px;
}

.row-muted td { opacity: .55; }

.tag {
    display: inline-block;
    padding: .2rem .6rem;
    border-radius: 20px;
    font-size: .75rem;
    font-weight: 600;
    line-height: 1.4;
    white-space: nowrap;
}
.tag-blue   { background: #dbeafe; color: #1d4ed8; }
.tag-green  { background: #dcfce7; color: #15803d; }
.tag-gray   { background: #f1f5f9; color: #64748b; }
.tag-yellow { background: #fef9c3; color: #a16207; }
.tag-red    { background: #fee2e2; color: #b91c1c; }

.record-count {
    display: inline-block;
    background: #e2e8f0;
    color: #475569;
    border-radius: 20px;
    font-size: .75rem;
    font-weight: 600;
    padding: .15rem .55rem;
    margin-left: .5rem;
}
.record-count-yellow {
    background: #fef9c3;
    color: #a16207;
}

/* ── Responsive ───────────────────────────────────── */
@media (max-width: 768px) {
    .form-row     { grid-template-columns: 1fr; }
    .form-row-3   { grid-template-columns: 1fr; }
    .page-header  { flex-direction: column; align-items: flex-start; gap: 0.75rem; }
    .main-content { padding: calc(var(--topbar-height) + 1rem) 1rem 1rem; }
    .topbar-quicknav { display: none; } /* hide on small screens — use sidebar instead */
}

/* ══════════════════════════════════════════════════════════════════
   Dark Mode — [data-theme="dark"]
   Same colour scheme as Job Tracker dark mode.
   Applied via localStorage preference; persists across sessions.
   ══════════════════════════════════════════════════════════════════ */

[data-theme="dark"] {
    --primary:       #3b82f6;
    --primary-dark:  #2563eb;
    --accent:        #60a5fa;
    --accent-hover:  #3b82f6;
    --danger:        #f87171;
    --success:       #4ade80;
    --warning:       #fbbf24;
    --text:          #f9fafb;
    --text-muted:    #9ca3af;
    --border:        #374151;
    --bg:            #111827;
    --card-bg:       #1f2937;
    --nav-bg:        #1a2035;
    --nav-text:      #ffffff;
    --nav-hover:     rgba(255,255,255,0.15);
    --shadow:        0 1px 3px rgba(0,0,0,0.5), 0 1px 2px rgba(0,0,0,0.4);
    --shadow-md:     0 4px 6px rgba(0,0,0,0.4), 0 2px 4px rgba(0,0,0,0.3);
}

[data-theme="dark"] body {
    background: #111827;
    color: var(--text);
    scrollbar-color: #4b5563 #1f2937;
    scrollbar-width: thin;
}
[data-theme="dark"] ::-webkit-scrollbar-track { background: #1f2937; }
[data-theme="dark"] ::-webkit-scrollbar-thumb { background: #4b5563; border-color: #1f2937; }

/* ── Topbar / Sidebar ───────────────────────────────────────────── */
[data-theme="dark"] .topbar-quicknav-active { background: rgba(255,255,255,0.25); }
[data-theme="dark"] .topbar,
[data-theme="dark"] .sidebar { background: #1a2035; }
[data-theme="dark"] .sidebar-header { border-color: rgba(255,255,255,0.1); }
[data-theme="dark"] .sidebar-footer { border-color: rgba(255,255,255,0.1); }
[data-theme="dark"] .sidebar-link { color: rgba(255,255,255,0.85); }
[data-theme="dark"] .sidebar-link:hover { background: rgba(255,255,255,0.12); color: #fff; }
[data-theme="dark"] .sidebar-link.nav-active { background: rgba(255,255,255,0.18); color: #fff; }
[data-theme="dark"] .sidebar-switch-btn { background: rgba(255,255,255,0.1); border-color: rgba(255,255,255,0.2); }
[data-theme="dark"] .sidebar-entity-menu { background: #111827; border-color: #374151; }
[data-theme="dark"] .topbar-switch-btn { background: rgba(255,255,255,0.15); border-color: rgba(255,255,255,0.3); }
[data-theme="dark"] .topbar-entity-menu { background: #1f2937; border-color: #374151; }
[data-theme="dark"] .topbar-entity-item { color: #e5e7eb; }
[data-theme="dark"] .topbar-entity-item:hover { background: #374151; }

/* ── Cards ──────────────────────────────────────────────────────── */
[data-theme="dark"] .card,
[data-theme="dark"] .stat-card {
    background: #1f2937;
    border-color: #374151;
}
[data-theme="dark"] .card-header { border-color: #4b5563; }
[data-theme="dark"] .card-title { color: #f3f4f6; }

/* ── Buttons ────────────────────────────────────────────────────── */
[data-theme="dark"] .btn-primary       { background: #1e40af; border-color: #1e40af; }
[data-theme="dark"] .btn-primary:hover { background: #3b82f6; border-color: #3b82f6; }
[data-theme="dark"] .btn-danger        { background: #b91c1c; border-color: #b91c1c; }
[data-theme="dark"] .btn-danger:hover  { background: #f87171; border-color: #f87171; color: #111; }
[data-theme="dark"] .btn-warning       { background: #b45309; border-color: #b45309; }
[data-theme="dark"] .btn-warning:hover { background: #d97706; border-color: #d97706; }
[data-theme="dark"] .btn-secondary     { background: #374151; color: #f3f4f6; border-color: #4b5563; }
[data-theme="dark"] .btn-secondary:hover { background: #4b5563; }
[data-theme="dark"] .btn-filter        { background: #1f2937; border-color: #4b5563; color: #e5e7eb; }
[data-theme="dark"] .btn-filter:hover  { background: #374151; }
[data-theme="dark"] .btn-filter.filter-active { background: #1e3a5f; border-color: var(--accent); color: var(--accent); }

/* ── Forms ──────────────────────────────────────────────────────── */
[data-theme="dark"] input,
[data-theme="dark"] select,
[data-theme="dark"] textarea {
    background: #374151;
    border-color: #4b5563;
    color: #f3f4f6;
}
[data-theme="dark"] input::placeholder,
[data-theme="dark"] textarea::placeholder { color: #6b7280; }
[data-theme="dark"] input:focus,
[data-theme="dark"] select:focus,
[data-theme="dark"] textarea:focus {
    border-color: var(--accent);
    background: #374151;
    box-shadow: 0 0 0 3px rgba(96,165,250,0.2);
}
[data-theme="dark"] .form-control { background: #374151; border-color: #4b5563; color: #f3f4f6; }
[data-theme="dark"] .form-control:focus { border-color: var(--accent); background: #374151; }
[data-theme="dark"] .form-hint { color: #9ca3af; }
[data-theme="dark"] .form-label { color: #e5e7eb; }
[data-theme="dark"] option { background: #374151; color: #f3f4f6; }

/* ── Tables ─────────────────────────────────────────────────────── */
[data-theme="dark"] thead th {
    background: #1f2937;
    color: #9ca3af;
    border-color: #374151;
}
[data-theme="dark"] tbody td {
    border-color: #374151;
    color: #e5e7eb;
}
[data-theme="dark"] tbody tr:last-child td { border-color: transparent; }
[data-theme="dark"] tbody tr:hover { background: #263044; }
[data-theme="dark"] .cr-clickable-row:hover td { background: #263044; }

/* ── Alerts ─────────────────────────────────────────────────────── */
[data-theme="dark"] .alert-success { background: #052e16; color: #4ade80; border-color: #166534; }
[data-theme="dark"] .alert-error   { background: #450a0a; color: #f87171; border-color: #7f1d1d; }
[data-theme="dark"] .alert-warning { background: #451a03; color: #fbbf24; border-color: #92400e; }
[data-theme="dark"] .alert-info    { background: #1e3a5f; color: #93c5fd; border-color: #1d4ed8; }

/* ── Badges & Tags ──────────────────────────────────────────────── */
[data-theme="dark"] .badge-success { background: #052e16; color: #4ade80; }
[data-theme="dark"] .badge-danger  { background: #450a0a; color: #f87171; }
[data-theme="dark"] .badge-warning { background: #451a03; color: #fbbf24; }
[data-theme="dark"] .badge-info    { background: #1e3a5f; color: #93c5fd; }
[data-theme="dark"] .badge-gray    { background: #374151; color: #d1d5db; }
[data-theme="dark"] .badge-purple  { background: #3b0764; color: #c4b5fd; }
[data-theme="dark"] .tag-blue      { background: #1e3a5f; color: #93c5fd; }
[data-theme="dark"] .tag-green     { background: #052e16; color: #4ade80; }
[data-theme="dark"] .tag-gray      { background: #374151; color: #d1d5db; }
[data-theme="dark"] .tag-yellow    { background: #451a03; color: #fbbf24; }
[data-theme="dark"] .tag-red       { background: #450a0a; color: #f87171; }

/* ── Auth pages ─────────────────────────────────────────────────── */
[data-theme="dark"] .auth-card { background: #1f2937; border-color: #374151; }
[data-theme="dark"] .auth-logo h1 { color: var(--accent); }

/* ── Filter card ─────────────────────────────────────────────────  */
[data-theme="dark"] .filter-card { background: #1f2937; border-color: #374151; }

/* ── Report card ────────────────────────────────────────────────── */
[data-theme="dark"] .report-card { background: #1f2937; border-color: #374151; }
[data-theme="dark"] .report-header { border-color: #4b5563; }
[data-theme="dark"] .report-title { color: #f9fafb; }
[data-theme="dark"] .report-subtitle { color: #9ca3af; }
[data-theme="dark"] .report-tenant { color: var(--accent); }
[data-theme="dark"] .report-section { border-color: #374151; }
[data-theme="dark"] .report-section-title { color: #9ca3af; }
[data-theme="dark"] .report-line:hover { background: #263044; }
[data-theme="dark"] .report-account { color: #e5e7eb; }
[data-theme="dark"] .report-account code { background: #374151; color: #9ca3af; }
[data-theme="dark"] .report-subtotal { border-color: #4b5563; }
[data-theme="dark"] .report-total { background: #263044; }
[data-theme="dark"] .report-tab { color: #9ca3af; border-color: #374151; }
[data-theme="dark"] .report-tab:hover { color: var(--accent); }
[data-theme="dark"] .report-tab.active { color: var(--accent); border-bottom-color: var(--accent); }

/* ── Opening balances ───────────────────────────────────────────── */
[data-theme="dark"] .ob-account-row { border-color: #374151; }
[data-theme="dark"] .ob-account-row:hover { background: #263044; }
[data-theme="dark"] .ob-account-code { background: #374151; color: #9ca3af; }
[data-theme="dark"] .ob-obecard { background: #263044; }

/* ── Check register ─────────────────────────────────────────────── */
[data-theme="dark"] .cr-balance-bar { background: #1f2937; border-color: #374151; }
[data-theme="dark"] .cr-void-row td { opacity: 0.4; }
[data-theme="dark"] .row-inactive td { opacity: 0.4; }

/* ── Entity switcher (topbar dropdown) ──────────────────────────── */
[data-theme="dark"] .entity-option { background: #1f2937; border-color: #374151; }
[data-theme="dark"] .entity-option:hover { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(96,165,250,0.15); }
[data-theme="dark"] .entity-name { color: #f3f4f6; }

/* ── Stat cards ─────────────────────────────────────────────────── */
[data-theme="dark"] .stat-label { color: #9ca3af; }
[data-theme="dark"] .stat-value { color: #f3f4f6; }

/* ── Footer ─────────────────────────────────────────────────────── */
[data-theme="dark"] .footer { background: #1f2937; border-color: #374151; }
[data-theme="dark"] .footer-inner { color: #6b7280; }

/* ── Misc utility ───────────────────────────────────────────────── */
[data-theme="dark"] .text-muted { color: #9ca3af; }
[data-theme="dark"] .section-divider { color: #9ca3af; border-color: #374151; }
[data-theme="dark"] .record-count { background: #374151; color: #d1d5db; }
[data-theme="dark"] .logo-preview { background: #374151; border-color: #4b5563; }
[data-theme="dark"] code { background: #374151; color: #93c5fd; }
[data-theme="dark"] .ob-obecard-label { color: #e5e7eb; }
[data-theme="dark"] .page-title { color: #f3f4f6; }

/* ── Suggestive search dropdown ─────────────────────────────────── */
[data-theme="dark"] .suggest-dropdown {
    background: #1f2937;
    border-color: #4b5563;
    box-shadow: 0 4px 12px rgba(0,0,0,0.5);
}
[data-theme="dark"] .suggest-item:hover,
[data-theme="dark"] .suggest-item.active { background: #263044; }
[data-theme="dark"] .suggest-item { color: #e5e7eb; border-color: #374151; }
[data-theme="dark"] .suggest-remove { color: #9ca3af; }
[data-theme="dark"] .suggest-remove:hover { color: #f87171; background: rgba(248,113,113,0.1); }

/* ── Theme toggle button ────────────────────────────────────────── */
.theme-toggle {
    background: none; border: none; cursor: pointer;
    color: rgba(255,255,255,0.82);
    display: flex; align-items: center;
    padding: 0.25rem 0.4rem; border-radius: var(--radius);
    transition: color 0.15s, background 0.15s;
    font-size: 1rem; line-height: 1;
}
.theme-toggle:hover { color: #fff; background: rgba(255,255,255,0.15); }

/* ── Suggestive search (light mode base) ────────────────────────── */
.suggest-wrap { position: relative; }
.suggest-dropdown {
    display: none;
    position: absolute; top: calc(100% + 2px); left: 0; right: 0;
    background: #fff; border: 1px solid var(--border);
    border-radius: var(--radius); box-shadow: var(--shadow-md);
    z-index: 500; max-height: 220px; overflow-y: auto;
}
.suggest-dropdown.open { display: block; }
.suggest-item {
    display: flex; align-items: center; justify-content: space-between;
    padding: 0.45rem 0.75rem; font-size: 0.875rem;
    color: var(--text); cursor: pointer; border-bottom: 1px solid var(--border);
    gap: 0.5rem;
}
.suggest-item:last-child { border-bottom: none; }
.suggest-item:hover,
.suggest-item.active { background: #eff6ff; }
.suggest-item-text { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.suggest-remove {
    flex-shrink: 0; background: none; border: none; cursor: pointer;
    color: var(--text-muted); font-size: 0.85rem; line-height: 1;
    padding: 0.15rem 0.3rem; border-radius: 3px;
    transition: color 0.15s, background 0.15s;
}
.suggest-remove:hover { color: var(--danger); background: #fee2e2; }

/* ── Check register new-row flash animation ──────────────────── */
@keyframes cr-flash-light {
    0%   { background-color: #dcfce7; }
    100% { background-color: transparent; }
}
@keyframes cr-flash-dark {
    0%   { background-color: #052e16; }
    100% { background-color: transparent; }
}
.cr-row-flash td {
    animation: cr-flash-light 1.5s ease-out forwards;
}
[data-theme="dark"] .cr-row-flash td {
    animation: cr-flash-dark 1.5s ease-out forwards;
}

/* ── Transaction Register: entry type selector ───────────────── */
.cr-entry-type { flex: 0 0 110px; margin: 0; }

/* ── Transaction Register: inline detail panel ───────────────── */
.tr-clickable-row { cursor: pointer; }
.tr-clickable-row:hover td { background: #f0f4ff; }
.tr-row-active td { background: #e0eaff !important; }

.tr-detail-row td { padding: 0 !important; border-bottom: 2px solid var(--primary); }
.tr-detail-panel {
    background: var(--bg);
    border-top: 2px solid var(--accent);
    animation: tr-slide-in 0.15s ease-out;
}
.tr-detail-inner { padding: 0; }
.tr-detail-loading {
    padding: 1rem 1.5rem;
    font-size: 0.9rem;
    color: var(--text-muted);
}
.tr-detail-meta {
    display: flex; flex-wrap: wrap; gap: 0.5rem 1.5rem;
    padding: 0.85rem 1.25rem 0.5rem;
    background: var(--card-bg);
    border-bottom: 1px solid var(--border);
}
.tr-detail-meta-item {
    display: flex; flex-direction: column; gap: 0.1rem;
    min-width: 100px;
}
.tr-detail-label {
    font-size: 0.72rem; font-weight: 700; text-transform: uppercase;
    letter-spacing: 0.05em; color: var(--text-muted);
}
.tr-detail-table {
    width: 100%; border-collapse: collapse; font-size: 0.875rem;
}
.tr-detail-table th {
    font-size: 0.75rem; font-weight: 700; text-transform: uppercase;
    letter-spacing: 0.04em; color: var(--text-muted);
    padding: 0.4rem 0.75rem; border-bottom: 1px solid var(--border);
    background: var(--card-bg); text-align: left;
}
.tr-detail-table td {
    padding: 0.4rem 0.75rem; border-bottom: 1px solid var(--border);
    color: var(--text);
}
.tr-detail-table tr:last-child td { border-bottom: none; }
.tr-detail-actions {
    display: flex; gap: 0.5rem; align-items: center;
    padding: 0.65rem 1.25rem;
    background: var(--card-bg);
    border-top: 1px solid var(--border);
}

@keyframes tr-slide-in {
    from { opacity: 0; transform: translateY(-4px); }
    to   { opacity: 1; transform: translateY(0); }
}

/* ── Add Account Modal ───────────────────────────────────────── */
.tr-modal-overlay {
    position: fixed; inset: 0; z-index: 1000;
    background: rgba(0,0,0,0.45);
    display: flex; align-items: center; justify-content: center;
}
.tr-modal-box {
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-md);
    padding: 1.5rem;
    width: 100%; max-width: 400px;
    margin: 1rem;
}
.tr-modal-header {
    display: flex; justify-content: space-between; align-items: center;
    margin-bottom: 1rem;
    font-size: 1rem;
}
.tr-modal-close {
    background: none; border: none; cursor: pointer;
    color: var(--text-muted); font-size: 1rem; line-height: 1;
    padding: 0.2rem 0.4rem; border-radius: var(--radius);
}
.tr-modal-close:hover { background: var(--bg); color: var(--text); }

/* ── Dark mode: transaction register panel + modal ───────────── */
[data-theme="dark"] .tr-clickable-row:hover td { background: #263044; }
[data-theme="dark"] .tr-row-active td { background: #1e3a5f !important; }
[data-theme="dark"] .tr-detail-panel { background: #111827; border-color: #3b82f6; }
[data-theme="dark"] .tr-detail-meta { background: #1f2937; border-color: #374151; }
[data-theme="dark"] .tr-detail-table th { background: #1f2937; color: #9ca3af; border-color: #374151; }
[data-theme="dark"] .tr-detail-table td { border-color: #374151; color: #e5e7eb; }
[data-theme="dark"] .tr-detail-actions { background: #1f2937; border-color: #374151; }
[data-theme="dark"] .tr-modal-box { background: #1f2937; border-color: #374151; }
[data-theme="dark"] .tr-modal-close:hover { background: #374151; color: #f3f4f6; }

/* ── Balance bar multi-account variant ───────────────────────── */
.cr-balance-bar-multi {
    flex-wrap: wrap;
    gap: 0.5rem 1.5rem;
    align-items: center;
}
[data-theme="dark"] .cr-balance-bar-multi { background: #1f2937; border-color: #374151; }

/* ── Account browser (browse all accounts button + panel) ────── */
.acct-browse-wrap { display: flex; align-items: stretch; gap: 0; }
.acct-browse-input { flex: 1; border-radius: var(--radius) 0 0 var(--radius) !important; }
.acct-browse-btn {
    flex-shrink: 0;
    padding: 0 0.65rem;
    background: var(--bg);
    border: 1px solid var(--border);
    border-left: none;
    border-radius: 0 var(--radius) var(--radius) 0;
    cursor: pointer;
    color: var(--text-muted);
    font-size: 1rem;
    line-height: 1;
    transition: background 0.15s, color 0.15s;
}
.acct-browse-btn:hover { background: var(--primary); color: #fff; border-color: var(--primary); }
.acct-browse-btn:focus { outline: none; border-color: var(--accent); }

.acct-browser-panel {
    position: absolute; top: calc(100% + 2px); left: 0; right: 0;
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-md);
    z-index: 600;
    max-height: 280px;
    overflow-y: auto;
}
.acct-browser-inner { padding: 0.25rem 0; }
.acct-browser-loading {
    padding: 0.75rem 1rem;
    font-size: 0.875rem;
    color: var(--text-muted);
}
.acct-browser-group { margin-bottom: 0.15rem; }
.acct-browser-group-label {
    font-size: 0.7rem; font-weight: 700; text-transform: uppercase;
    letter-spacing: 0.06em; color: var(--text-muted);
    padding: 0.45rem 0.85rem 0.2rem;
    border-top: 1px solid var(--border);
}
.acct-browser-group:first-child .acct-browser-group-label { border-top: none; }
.acct-browser-item {
    display: flex; align-items: baseline; gap: 0.55rem;
    padding: 0.35rem 0.85rem;
    cursor: pointer;
    font-size: 0.875rem;
    color: var(--text);
    transition: background 0.1s;
}
.acct-browser-item:hover { background: #eff6ff; }
.acct-browser-code {
    font-size: 0.78rem; color: var(--text-muted);
    background: var(--bg); padding: 0.1em 0.35em;
    border-radius: 3px; flex-shrink: 0;
}
.acct-browser-name { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ── Dark mode: account browser ─────────────────────────────── */
[data-theme="dark"] .acct-browse-btn {
    background: #374151; border-color: #4b5563; color: #9ca3af;
}
[data-theme="dark"] .acct-browse-btn:hover { background: var(--primary); color: #fff; border-color: var(--primary); }
[data-theme="dark"] .acct-browser-panel { background: #1f2937; border-color: #374151; }
[data-theme="dark"] .acct-browser-group-label { color: #9ca3af; border-color: #374151; }
[data-theme="dark"] .acct-browser-item { color: #e5e7eb; }
[data-theme="dark"] .acct-browser-item:hover { background: #263044; }
[data-theme="dark"] .acct-browser-code { background: #374151; color: #9ca3af; }

/* ── Journal Entry (dual-sided free-form entry) ─────────────────── */
/* When Journal Entry is selected, Amount joins the end of Row 1 —
   shrink Description/Memo's flex-basis so everything still fits. */
.cr-entry-row.journal-active .cr-entry-payee { flex: 1 1 140px; }
.cr-entry-row.journal-active .cr-entry-memo  { flex: 1 1 100px; }
.jrnl-sides {
    display: grid; grid-template-columns: 1fr 1fr; gap: 1rem;
    margin-top: 0.5rem;
}
@media (max-width: 800px) {
    .jrnl-sides { grid-template-columns: 1fr; }
}
.jrnl-side {
    border: 1px solid var(--border); border-radius: var(--radius);
    padding: 0.75rem;
}
.jrnl-side-header {
    display: flex; justify-content: space-between; align-items: center;
    margin-bottom: 0.5rem;
}
.jrnl-split-table { width: 100%; border-collapse: collapse; }
.jrnl-split-table td { padding: 0.3rem 0.3rem; vertical-align: top; }
.jrnl-split-table .jrnl-split-amount { text-align: right; }
.jrnl-split-subtotal { font-size: 0.85rem; font-weight: 600; white-space: nowrap; }
.jrnl-single .acct-browse-wrap { margin-bottom: 0; }
.jrnl-split-footer {
    display: flex; align-items: center; justify-content: space-between;
    flex-wrap: wrap; gap: 0.5rem; padding: 0.3rem;
}
.jrnl-split-footer-actions { display: flex; align-items: center; gap: 0.4rem; flex-wrap: wrap; }

/* ── CSV Import preview table ────────────────────────────────── */
.form-control-sm {
    padding: 0.25rem 0.4rem;
    font-size: 0.8rem;
    min-width: 0;
}
.import-row-error td { background: #fff5f5; }
[data-theme="dark"] .import-row-error td { background: #2d1515; }

/* ── Import review table — column overflow control ───────────── */
#review-table td { overflow: hidden; }
#review-table input.form-control-sm,
#review-table select.form-control-sm {
    width: 100%;
    box-sizing: border-box;
    min-width: 0;
}
#review-table select.form-control-sm,
#preview-table select.form-control-sm {
    appearance: none;
    -webkit-appearance: none;
    -moz-appearance: none;
    padding-right: 22px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    background-image: url("data:image/svg+xml;charset=UTF-8,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 8'%3e%3cpath fill='%23666' d='M1 1l5 5 5-5'/%3e%3c/svg%3e");
    background-repeat: no-repeat;
    background-position: right 6px center;
    background-size: 10px 7px;
}
[data-theme="dark"] #review-table select.form-control-sm,
[data-theme="dark"] #preview-table select.form-control-sm {
    background-image: url("data:image/svg+xml;charset=UTF-8,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 8'%3e%3cpath fill='%23bbb' d='M1 1l5 5 5-5'/%3e%3c/svg%3e");
}

/* ── Import preview table — no-scroll layout ─────────────────── */
#preview-table { table-layout: fixed; width: 100%; }
#preview-table input.form-control-sm,
#preview-table select.form-control-sm {
    width: 100%;
    min-width: 0;
    box-sizing: border-box;
    font-size: 0.78rem;
    padding: 0.2rem 0.35rem;
}
#preview-table td { padding: 0.25rem 0.3rem; overflow: hidden; }
#preview-table th { padding: 0.35rem 0.3rem; white-space: nowrap; }

/* ── Transaction detail modal ────────────────────────────────── */
/* NOTE: When a page has a single card as its primary content,
   do NOT set max-width on .card — let it fill the full content
   area. max-width is only appropriate when cards appear beside
   other cards or need to be constrained for readability. */

.tr-detail-modal-box {
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-md);
    width: 100%;
    max-width: 760px;
    max-height: 90vh;
    display: flex;
    flex-direction: column;
    margin: 1rem;
    overflow: hidden;
}
.tr-detail-modal-box .tr-modal-header {
    flex-shrink: 0;
    border-bottom: 1px solid var(--border);
    padding: 0.85rem 1.25rem;
}
.tr-modal-body {
    overflow-y: auto;
    flex: 1;
}
.tr-modal-edit-wrap { }

[data-theme="dark"] .tr-detail-modal-box {
    background: #1f2937;
    border-color: #374151;
}


/* ── Register sort toggle + pagination jump ─────────────────── */
.tr-sort-link {
    color: inherit; text-decoration: none;
    display: inline-flex; align-items: center; gap: 0.3rem;
    cursor: pointer;
}
.tr-sort-link:hover { color: var(--accent); text-decoration: none; }
.tr-sort-arrow { font-size: 0.7rem; opacity: 0.7; }
.pagination-jump {
    display: inline-flex; align-items: center; gap: 0.4rem;
    margin: 0 0.25rem;
}
.pagination-jump input[type="number"] {
    -moz-appearance: textfield;
}
