@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&display=swap');

:root {
    /* Cooler, slightly deeper neutrals — the old blues read as muddy at
       large fills and made every surface look heavier than it was */
    --bg-dark: #0d1520;
    --bg-sidebar: #101a26;
    --bg-card: #141f2e;
    --bg-card-hover: #1a2739;
    --bg-input: #111c29;
    --accent: #3b82f6;
    --accent-hover: #2563eb;
    --accent-gradient: linear-gradient(135deg, #3b82f6, #06b6d4);
    --text-primary: #e8eef6;
    --text-secondary: #b6c4d4;
    --text-muted: #93a3b8;
    --border: #1c2b3d;
    --border-soft: #16222f;
    --success: #22c55e;
    --danger: #ef4444;
    --warning: #f59e0b;

    /* Density scale — single source of truth for the compact pass */
    --radius-sm: 6px;
    --radius: 8px;
    --radius-lg: 10px;
    --control-h: 30px;
    --control-pad-y: 0.25rem;
    --control-pad-x: 0.55rem;
    --fs-sm: 0.78rem;
    --fs-base: 0.845rem;
}

html, body {
    font-family: 'Inter', 'Segoe UI', system-ui, -apple-system, sans-serif;
    font-size: var(--fs-base);
    background-color: var(--bg-dark);
    color: var(--text-primary);
    margin: 0;
    min-height: 100vh;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    letter-spacing: -0.005em;
}

/* Lining, fixed-width figures so currency columns align down the page */
.stat-value,
.table td,
.table th,
.money,
input[type="date"],
input[type="number"] {
    font-variant-numeric: tabular-nums;
    font-feature-settings: "tnum" 1;
}

/* Scrollbar */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: var(--bg-dark); }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }

/* Layout */
.page {
    display: flex;
    min-height: 100vh;
}

.sidebar {
    width: 208px;
    background:
        linear-gradient(180deg, rgba(59, 130, 246, 0.07), rgba(6, 182, 212, 0.02) 40%, transparent 70%),
        var(--bg-sidebar);
    border-right: 1px solid var(--border-soft);
    position: fixed;
    top: 0;
    bottom: 0;
    left: 0;
    z-index: 100;
    display: flex;
    flex-direction: column;
}

main {
    flex: 1;
    /* min-width:0 lets wide children (e.g. the breakdown matrix) scroll
       inside their own overflow-x box instead of widening the whole page,
       which would push the right-aligned header actions off-screen */
    min-width: 0;
    margin-left: 208px;
    min-height: 100vh;
    background: var(--bg-dark);
}

.top-row {
    display: none;
}

.content {
    padding: 1.1rem 1.35rem;
    max-width: 100%;
}

/* Sidebar Brand */
.sidebar .top-row {
    display: flex;
    align-items: center;
    padding: 0.8rem 0.85rem;
    border-bottom: 1px solid var(--border-soft);
    background: transparent;
}

.navbar-brand {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.95rem;
    font-weight: 700;
    color: var(--text-primary);
    text-decoration: none;
    letter-spacing: -0.02em;
    padding: 0;
}

/* Gradient mark, so the wordmark itself stays legible */
.navbar-brand::before {
    content: 'R';
    display: grid;
    place-items: center;
    width: 24px;
    height: 24px;
    border-radius: 7px;
    background: var(--accent-gradient);
    color: #fff;
    font-size: 0.78rem;
    font-weight: 700;
    box-shadow: 0 2px 8px rgba(59, 130, 246, 0.35);
}

/* Group label above nav sections */
.nav-section {
    padding: 0.75rem 1.1rem 0.3rem;
    font-size: 0.6rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.9px;
    color: var(--text-muted);
    opacity: 0.65;
}

/* Nav Links */
.nav-scrollable {
    flex: 1;
    overflow-y: auto;
    padding: 0.5rem 0;
}

.nav-item {
    margin: 1px 0.5rem;
}

.nav-link {
    color: var(--text-secondary) !important;
    border-radius: var(--radius-sm);
    padding: 0.4rem 0.6rem !important;
    font-size: var(--fs-base);
    font-weight: 500;
    transition: background 0.15s, color 0.15s;
    display: flex;
    align-items: center;
    gap: 0.55rem;
}

.nav-link:hover {
    color: var(--text-primary) !important;
    background: rgba(255, 255, 255, 0.045);
}

.nav-link.active {
    color: #fff !important;
    background: var(--accent-gradient);
    box-shadow: 0 2px 8px rgba(59, 130, 246, 0.28);
    font-weight: 600;
}

/* Accent rail on the active item, so the selection still reads when the
   gradient is dim against the sidebar wash */
.nav-link.active::before {
    content: '';
    position: absolute;
    left: -0.5rem;
    top: 50%;
    transform: translateY(-50%);
    width: 3px;
    height: 16px;
    border-radius: 0 2px 2px 0;
    background: #fff;
    opacity: 0.9;
}

.nav-item {
    position: relative;
}

.nav-link.active .nav-icon {
    opacity: 1;
}

/* Nav icons */
.nav-icon {
    width: 16px;
    height: 16px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 0.875rem;
    opacity: 0.85;
}

/* Cards */
.card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    color: var(--text-primary);
    transition: border-color 0.2s;
}

/* No hover border on cards — with several on screen it made the page
   twitch as the pointer crossed it */
.card:hover {
    border-color: var(--border);
}

.card-header {
    background: transparent;
    border-bottom: 1px solid var(--border);
    padding: 0.6rem 0.9rem;
    font-weight: 600;
    font-size: 0.9rem;
}

.card-body {
    padding: 0.9rem;
}

/* KPI grid — auto-fit so tiles stay readable instead of stacking
   full-width at every breakpoint the way col-md-2 did */
.kpi-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 0.6rem;
    margin-bottom: 1rem;
}

/* Stat Cards */
.stat-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 0.65rem 0.8rem;
    position: relative;
    overflow: hidden;
}

/* Accent rail dropped entirely — six tiles each with a coloured bar was
   the single biggest source of visual noise. Value colour carries meaning
   now; the tile itself stays quiet. */
.stat-card::before {
    content: none;
}

.stat-card .stat-value {
    font-size: 1.1rem;
    font-weight: 600;
    line-height: 1.15;
    letter-spacing: -0.02em;
    color: var(--text-primary);
    white-space: nowrap;
}

.stat-card .stat-label {
    font-size: 0.66rem;
    font-weight: 500;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 0.15rem;
}

.stat-card.clickable:hover {
    border-color: rgba(59, 130, 246, 0.45);
    background: var(--bg-card-hover);
}

/* Clickable elements */
.stat-card.clickable,
.clickable-row {
    cursor: pointer;
    transition: background 0.15s, border-color 0.15s;
}
.stat-card.clickable:hover {
    border-color: var(--accent);
    background: var(--bg-card-hover);
}
.clickable-row:hover td {
    background: var(--bg-card-hover);
}

/* Tables */
.table {
    color: var(--text-primary);
    --bs-table-bg: transparent;
    --bs-table-hover-bg: rgba(59, 130, 246, 0.05);
    --bs-table-striped-bg: rgba(255, 255, 255, 0.02);
    margin-bottom: 0;
}

.table thead th {
    background: transparent;
    border-bottom: 1px solid var(--border);
    color: var(--text-muted);
    font-size: 0.65rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.6px;
    padding: 0.4rem 0.7rem;
    white-space: nowrap;
}

.table tbody td {
    border-bottom: 1px solid var(--border-soft);
    padding: 0.35rem 0.7rem;
    vertical-align: middle;
    color: var(--text-secondary);
    font-size: var(--fs-base);
}

/* Let the numeric column carry the emphasis instead of every cell */
.table tbody td.fw-bold,
.table tbody td:first-child {
    color: var(--text-primary);
}

.table tbody tr:last-child td {
    border-bottom: none;
}

/* Buttons — every variant shares one height so controls line up on a row */
.btn {
    --bs-btn-padding-y: var(--control-pad-y);
    --bs-btn-padding-x: 0.85rem;
    --bs-btn-font-size: var(--fs-base);
    --bs-btn-border-radius: var(--radius);
    min-height: var(--control-h);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.35rem;
    font-weight: 500;
    line-height: 1.2;
}

.btn i {
    font-size: 0.9em;
    line-height: 1;
}

.btn-primary {
    background: var(--accent-gradient);
    border: none;
    color: #fff;
    font-weight: 600;
    transition: filter 0.15s, box-shadow 0.15s;
}

/* No translate on hover — buttons sitting in a toolbar jumped out of
   alignment with the inputs beside them */
.btn-primary:hover {
    background: var(--accent-gradient);
    filter: brightness(1.1);
    box-shadow: 0 2px 10px rgba(59, 130, 246, 0.25);
}

.btn-outline-primary {
    color: var(--accent);
    border-color: var(--border);
}

.btn-outline-primary:hover {
    background: var(--accent);
    border-color: var(--accent);
}

.btn-outline-danger {
    color: var(--danger);
    border-color: var(--danger);
}

.btn-outline-danger:hover {
    background: var(--danger);
    color: #fff;
}

.btn-outline-secondary {
    color: var(--text-secondary);
    border-color: var(--border);
}

.btn-outline-secondary:hover {
    background: var(--bg-card-hover);
    color: var(--text-primary);
    border-color: var(--text-muted);
}

.btn-sm,
.btn-group-sm > .btn {
    --bs-btn-padding-y: 0.2rem;
    --bs-btn-padding-x: 0.6rem;
    --bs-btn-font-size: var(--fs-sm);
    min-height: 27px;
}

/* Segmented button groups (This Month / 3 Months / YTD) */
.btn-group > .btn-outline-primary {
    border-color: var(--border);
}
.btn-group > .btn-outline-primary:hover {
    background: var(--bg-card-hover);
    color: var(--text-primary);
}
.btn-group > .btn-check:checked + .btn-outline-primary,
.btn-group > .btn-outline-primary.active {
    background: var(--accent);
    border-color: var(--accent);
    color: #fff;
}

/* Forms */
.form-control, .form-select {
    background-color: var(--bg-input);
    border: 1px solid var(--border);
    color: var(--text-primary);
    border-radius: var(--radius);
    padding: var(--control-pad-y) var(--control-pad-x);
    font-size: var(--fs-base);
    min-height: var(--control-h);
}

/* Must come after the base rule — same specificity, and Bootstrap's own
   .form-control-sm was being overridden by it, which is why -sm inputs
   still rendered full height next to btn-sm buttons */
.form-control-sm, .form-select-sm {
    padding: 0.2rem 0.5rem;
    font-size: var(--fs-sm);
    min-height: 27px;
    border-radius: var(--radius-sm);
}

/* Dark-theme the native date/time picker indicator */
input[type="date"], input[type="datetime-local"], input[type="time"] {
    color-scheme: dark;
}

.form-control:focus, .form-select:focus {
    background-color: var(--bg-input);
    border-color: var(--accent);
    color: var(--text-primary);
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.15);
}

.form-control::placeholder {
    color: var(--text-muted);
}

.form-label {
    color: var(--text-secondary);
    font-size: 0.85rem;
    font-weight: 500;
    margin-bottom: 0.35rem;
}

.form-select option {
    background: var(--bg-card);
    color: var(--text-primary);
}

.form-check-input {
    background-color: var(--bg-input);
    border-color: var(--border);
}

.form-check-input:checked {
    background-color: var(--accent);
    border-color: var(--accent);
}

/* Badges */
.badge {
    font-weight: 500;
    font-size: 0.75rem;
    padding: 0.35em 0.65em;
    border-radius: 6px;
}

.badge-priority-0 { background: var(--text-muted); }
.badge-priority-1 { background: #3b82f6; }
.badge-priority-2 { background: #f59e0b; }
.badge-priority-3 { background: #f97316; }
.badge-priority-4 { background: #ef4444; }

.badge-status { background: rgba(59, 130, 246, 0.15); color: var(--accent); }

.badge-call { background: rgba(34, 197, 94, 0.15); color: var(--success); }
.badge-put { background: rgba(239, 68, 68, 0.15); color: var(--danger); }

/* Page Header */
.page-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 0.75rem;
    flex-wrap: wrap;
    margin-bottom: 0.9rem;
}

/* Toolbar — keeps filters, buttons and segmented groups on one
   baseline instead of relying on .row/.col-auto wrappers */
.toolbar {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 0.4rem;
    margin-bottom: 0.9rem;
}

.toolbar .toolbar-sep {
    width: 1px;
    align-self: stretch;
    background: var(--border);
    margin: 0 0.35rem;
}

.toolbar .form-control,
.toolbar .form-select {
    width: auto;
    min-width: 130px;
}

.page-header {
    padding-bottom: 0.7rem;
    border-bottom: 1px solid var(--border);
    margin-bottom: 1rem;
}

/* Left cluster: icon chip + title stack */
.page-header .page-title {
    display: flex;
    align-items: center;
    gap: 0.65rem;
    min-width: 0;
}

.page-header .page-icon {
    flex: 0 0 auto;
    width: 30px;
    height: 30px;
    display: grid;
    place-items: center;
    border-radius: var(--radius);
    background: var(--accent-gradient);
    color: #fff;
    font-size: 0.9rem;
    box-shadow: 0 2px 8px rgba(59, 130, 246, 0.3);
}

.page-header h1 {
    font-size: 1.1rem;
    font-weight: 650;
    letter-spacing: -0.02em;
    margin: 0;
    background: var(--accent-gradient);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    line-height: 1.25;
}

.page-header .page-subtitle {
    font-size: 0.75rem;
    color: var(--text-muted);
    margin: 0;
    line-height: 1.3;
}

.page-header .page-actions {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    flex-wrap: wrap;
}

/* Modal override */
.modal-content {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 12px;
    color: var(--text-primary);
}

.modal-header {
    border-bottom: 1px solid var(--border);
}

.modal-footer {
    border-top: 1px solid var(--border);
}

.modal-backdrop.show {
    opacity: 0.7;
}

.btn-close {
    filter: invert(1) grayscale(100%) brightness(200%);
}

/* Profit/Loss colors */
.text-profit { color: var(--success) !important; }
.text-loss { color: var(--danger) !important; }

/* Due date colors */
.text-overdue { color: var(--danger) !important; font-weight: 600; }
.text-due-soon { color: var(--warning) !important; }

/* Completed task */
.task-completed td {
    opacity: 0.5;
    text-decoration: line-through;
}
.task-completed td:first-child,
.task-completed td:last-child {
    text-decoration: none;
}

/* Sortable table headers */
th.sortable {
    cursor: pointer;
    user-select: none;
    white-space: nowrap;
}
th.sortable:hover {
    color: var(--accent);
}
th.sortable i {
    font-size: 0.7rem;
    margin-left: 3px;
    vertical-align: middle;
}
.sort-icon-inactive {
    opacity: 0.3;
}

/* Nav tabs — rendered as a segmented control rather than Bootstrap's
   underlined tab strip, which left a stray rule across the page */
.nav-tabs {
    border-bottom: none;
    display: inline-flex;
    gap: 1px;
    padding: 2px;
    background: var(--bg-input);
    border: 1px solid var(--border-soft);
    border-radius: var(--radius);
    margin-bottom: 0.8rem;
}

.nav-tabs .nav-item {
    margin-bottom: 0;
}

.nav-tabs .nav-link {
    color: var(--text-muted);
    border: none;
    border-radius: var(--radius-sm);
    padding: 0.28rem 0.75rem;
    background: none;
    font-size: var(--fs-base);
    font-weight: 500;
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    transition: background 0.15s, color 0.15s;
}

.nav-tabs .nav-link:hover {
    color: var(--text-primary);
    background: rgba(255, 255, 255, 0.04);
    border: none;
}

.nav-tabs .nav-link.active {
    color: #fff;
    background: var(--accent-gradient);
    border: none;
    box-shadow: 0 1px 4px rgba(59, 130, 246, 0.35);
}

.nav-tabs .nav-link i {
    font-size: 0.9em;
}

/* Bootstrap's .text-muted is a half-opacity token that all but disappears
   on these backgrounds — bind it to our own muted colour instead */
.text-muted {
    color: var(--text-muted) !important;
    --bs-secondary-color: var(--text-muted);
}

/* Secondary line under a primary value (raw merchant string, hints) */
.subtle {
    color: var(--text-muted);
    font-size: 0.72rem;
    line-height: 1.3;
}

.fw-500 { font-weight: 500; }
.text-accent { color: var(--accent) !important; }

/* Dashboard category filter chips */
.cat-filter {
    display: flex;
    flex-wrap: wrap;
    gap: 0.35rem;
    margin-bottom: 0.9rem;
}

.cat-chip {
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
    border: 1px solid var(--border);
    background: var(--bg-card);
    color: var(--text-secondary);
    font-size: 0.74rem;
    font-weight: 500;
    padding: 0.2rem 0.55rem;
    border-radius: 999px;
    cursor: pointer;
    line-height: 1.3;
    transition: background 0.12s, color 0.12s, border-color 0.12s;
}

.cat-chip:hover {
    border-color: var(--text-muted);
    color: var(--text-primary);
}

/* Selected category chip: filled with its own colour (set inline),
   white text for contrast */
.cat-chip.active {
    color: #fff;
    border-color: var(--accent);
    background: var(--accent);
}

.cat-chip.active .cat-dot {
    display: none;
}

/* The "All categories" chip when nothing is selected */
.cat-chip.active:first-child {
    background: var(--accent-gradient);
    border-color: transparent;
}

.cat-chip-clear {
    color: var(--danger);
    border-color: transparent;
    background: transparent;
}

.cat-chip-clear:hover {
    background: rgba(239, 68, 68, 0.12);
    color: var(--danger);
}

/* =========================================================================
   Expenses screen — dashboard filter row, discreet category/person
   dropdowns, active-filter pills, opposing-currency sub-amounts, source
   badges. (Replaces the .cat-filter/.cat-chip chip row above.)
   ========================================================================= */

/* Filter row that holds the category + person dropdowns and active pills */
.dash-filter-row {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex-wrap: wrap;
    margin-bottom: 0.9rem;
}

/* Dropdown anchors — the button + floating menu live inside these */
.cat-dropdown,
.person-dropdown {
    position: relative;
    display: inline-block;
}

/* The floating popup panel below the dropdown button */
.cat-menu {
    position: absolute;
    top: 100%;
    left: 0;
    margin-top: 4px;
    min-width: 230px;
    max-height: 340px;
    overflow-y: auto;
    padding: 0.35rem;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
    z-index: 50;
}

/* Menu header (title + a clear/close action) */
.cat-menu-head {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.25rem 0.4rem 0.4rem;
    border-bottom: 1px solid var(--border-soft);
    margin-bottom: 0.25rem;
}

/* Individual selectable row in the menu */
.cat-menu-item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.3rem 0.4rem;
    border-radius: var(--radius-sm);
    cursor: pointer;
    font-size: 0.8rem;
    color: var(--text-secondary);
}

.cat-menu-item:hover {
    background: var(--bg-card-hover);
}

.cat-menu-item input[type="checkbox"] {
    margin: 0;
    accent-color: var(--accent);
    cursor: pointer;
}

/* Category / person name text — truncate rather than wrap */
.cat-menu-item span:last-child {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* Active-filter pills shown next to the dropdowns */
.active-cat-pills {
    display: flex;
    flex-wrap: wrap;
    gap: 0.3rem;
    align-items: center;
}

/* A small removable pill — border-color often overridden inline with the
   category's colour */
.mini-pill {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    font-size: 0.68rem;
    font-weight: 500;
    padding: 0.1rem 0.2rem 0.1rem 0.5rem;
    border: 1px solid var(--border);
    border-radius: 999px;
    background: transparent;
    color: var(--text-secondary);
    white-space: nowrap;
}

.mini-pill i {
    cursor: pointer;
    opacity: 0.6;
    font-size: 0.7rem;
}

.mini-pill i:hover {
    opacity: 1;
    color: var(--danger);
}

/* Compact link-style button (e.g. "Clear all") */
.btn-link-sm {
    border: none;
    background: none;
    color: var(--accent);
    font-size: 0.7rem;
    cursor: pointer;
    padding: 0;
}

.btn-link-sm:hover {
    text-decoration: underline;
}

/* Opposing-currency amount shown discreetly under the main amount */
.amount-sub {
    display: block;
    font-size: 0.64rem;
    color: var(--text-muted);
    font-variant-numeric: tabular-nums;
    line-height: 1.15;
    margin-top: 1px;
    font-weight: 400;
}

/* Tiny uppercase badge marking a transaction's source */
.source-badge {
    font-size: 0.56rem;
    font-weight: 600;
    letter-spacing: 0.4px;
    text-transform: uppercase;
    padding: 0.05rem 0.3rem;
    border-radius: var(--radius-sm);
    line-height: 1.4;
}

.source-chase {
    background: rgba(59, 130, 246, 0.15);
    color: #60a5fa;
}

.source-c6 {
    background: rgba(168, 85, 247, 0.15);
    color: #c084fc;
}

/* Average-per-category dashboard widget */
.avg-cat-list {
    display: flex;
    flex-direction: column;
    gap: 0.15rem;
}

.avg-cat-row {
    display: grid;
    grid-template-columns: 120px 1fr 96px 74px;
    align-items: center;
    gap: 0.55rem;
    padding: 0.3rem 0.4rem;
    border-radius: var(--radius-sm);
    cursor: pointer;
}

.avg-cat-val .subtle {
    font-size: 0.62rem;
    margin-left: 1px;
}

.avg-cat-row:hover {
    background: var(--bg-card-hover);
}

.avg-cat-name {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    min-width: 0;
    font-size: var(--fs-base);
}

.avg-cat-bar {
    height: 7px;
    background: var(--bg-input);
    border-radius: 4px;
    overflow: hidden;
}

.avg-cat-bar-fill {
    height: 100%;
    border-radius: 4px;
    min-width: 2px;
    transition: width 0.3s ease;
}

.avg-cat-val {
    text-align: right;
    font-weight: 600;
    font-size: var(--fs-base);
    font-variant-numeric: tabular-nums;
}

.avg-cat-count {
    text-align: right;
    white-space: nowrap;
}

/* Inline transaction note — discreet: the "add note" chip stays hidden
   until the row is hovered; an existing note shows as a quiet italic line */
.btn-note-add {
    border: none;
    background: transparent;
    color: var(--text-muted);
    font-size: 0.62rem;
    padding: 0 0.25rem;
    border-radius: var(--radius-sm);
    cursor: pointer;
    opacity: 0;
    white-space: nowrap;
    transition: opacity 0.12s, color 0.12s, background 0.12s;
}

.table tbody tr:hover .btn-note-add {
    opacity: 0.55;
}

.btn-note-add:hover {
    opacity: 1;
    color: var(--accent);
    background: rgba(59, 130, 246, 0.1);
}

.note-line {
    font-size: 0.7rem;
    font-style: italic;
    color: var(--text-secondary);
    cursor: text;
    margin-top: 0.1rem;
    max-width: 260px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.note-line i {
    font-size: 0.62rem;
    color: var(--text-muted);
    margin-right: 0.1rem;
    font-style: normal;
}

.note-line:hover {
    color: var(--text-primary);
}

.note-input {
    margin-top: 0.15rem;
    width: 260px;
    max-width: 100%;
    background: var(--bg-input);
    border: 1px solid var(--accent);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-size: 0.72rem;
    font-style: italic;
    padding: 0.15rem 0.4rem;
    outline: none;
}

/* Ghost delete button for grid rows: quiet until you reach for it */
.btn-row-delete {
    border: none;
    background: transparent;
    color: var(--text-muted);
    width: 26px;
    height: 26px;
    border-radius: var(--radius-sm);
    display: inline-grid;
    place-items: center;
    font-size: 0.82rem;
    cursor: pointer;
    opacity: 0.35;
    transition: opacity 0.12s, background 0.12s, color 0.12s;
}

.table tbody tr:hover .btn-row-delete {
    opacity: 1;
}

.btn-row-delete:hover {
    background: rgba(239, 68, 68, 0.14);
    color: var(--danger);
    opacity: 1;
}

/* Page subtitle sits on the dark page background, so it needs the same
   treatment as .subtle rather than Bootstrap's muted token */
.page-header .page-subtitle {
    color: var(--text-muted);
}

/* Category swatch + inline category select in the transactions table */
.cat-dot {
    display: inline-block;
    width: 11px;
    height: 11px;
    border-radius: 3px;
    vertical-align: middle;
}

.category-select {
    background-color: transparent;
    border-color: transparent;
    padding-left: 0.45rem;
}

.category-select:hover {
    background-color: var(--bg-input);
    border-color: var(--border);
}

.category-select:focus {
    background-color: var(--bg-input);
}

/* Table rows hold inline controls now — keep them from feeling cramped */
.table tbody td .form-select-sm,
.table tbody td .form-control-sm {
    min-height: 26px;
}

/* Calendar */
.calendar-grid {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 1px;
    background: var(--border);
    border: 1px solid var(--border);
    border-radius: 8px;
    overflow: hidden;
}
.calendar-header {
    background: var(--bg-sidebar);
    color: var(--text-muted);
    text-align: center;
    padding: 0.5rem;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
}
.calendar-day {
    background: var(--bg-card);
    min-height: 100px;
    padding: 0.35rem;
    position: relative;
}
.calendar-day-other {
    background: var(--bg-dark);
    opacity: 0.5;
}
.calendar-day-today {
    background: var(--bg-card-hover);
}
.calendar-day-today .calendar-day-number {
    background: var(--accent);
    color: #fff;
    border-radius: 50%;
    width: 24px;
    height: 24px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}
.calendar-day-number {
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: 2px;
}
.calendar-item {
    font-size: 0.7rem;
    padding: 1px 4px;
    margin-bottom: 1px;
    border-radius: 3px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    cursor: pointer;
    border-left: 3px solid var(--text-muted);
    background: rgba(148, 163, 184, 0.1);
    color: var(--text-primary);
}
.calendar-item:hover {
    background: rgba(148, 163, 184, 0.2);
}
.calendar-item-priority-1 { border-left-color: var(--accent); }
.calendar-item-priority-2 { border-left-color: var(--warning); }
.calendar-item-priority-3 { border-left-color: #f97316; }
.calendar-item-priority-4 { border-left-color: var(--danger); }
.calendar-item-done {
    opacity: 0.4;
    text-decoration: line-through;
}
.calendar-item-more {
    font-size: 0.65rem;
    color: var(--text-muted);
    padding-left: 4px;
}

/* Empty state */
.empty-state {
    text-align: center;
    padding: 3rem 1rem;
    color: var(--text-muted);
}

.empty-state-icon {
    font-size: 3rem;
    margin-bottom: 1rem;
    opacity: 0.5;
}

/* Blazor error UI */
.blazor-error-boundary {
    background: var(--danger);
    padding: 1rem;
    color: white;
    border-radius: 8px;
}

.blazor-error-boundary::after {
    content: "An error has occurred.";
}

#blazor-error-ui {
    background: var(--danger);
    color: white;
    bottom: 0;
    box-shadow: 0 -4px 20px rgba(0, 0, 0, 0.3);
}

/* Validation */
.valid.modified:not([type=checkbox]) {
    outline: none;
}

.invalid {
    outline: 1px solid var(--danger);
}

.validation-message {
    color: var(--danger);
    font-size: 0.85rem;
}

/* AI Report */
.ai-report {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(400px, 1fr));
    gap: 1rem;
}

.ai-section {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 12px;
    overflow: hidden;
    transition: border-color 0.2s;
}

.ai-section:hover {
    border-color: rgba(59, 130, 246, 0.3);
}

.ai-section:first-child {
    grid-column: 1 / -1;
}

.ai-section-header {
    padding: 0.85rem 1.25rem;
    font-weight: 600;
    font-size: 0.95rem;
    color: var(--text-primary);
    background: rgba(59, 130, 246, 0.08);
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    gap: 0.6rem;
}

.ai-section-header i {
    color: var(--accent);
    font-size: 1rem;
}

.ai-section-body {
    padding: 1rem 1.25rem;
}

.ai-text {
    color: var(--text-secondary);
    font-size: 0.9rem;
    line-height: 1.65;
    margin-bottom: 0.5rem;
}

.ai-text:last-child {
    margin-bottom: 0;
}

.ai-list {
    list-style: none;
    padding-left: 0;
    margin: 0;
}

ul.ai-list li {
    position: relative;
    padding: 0.4rem 0 0.4rem 1.25rem;
    color: var(--text-secondary);
    font-size: 0.9rem;
    line-height: 1.55;
    border-bottom: 1px solid rgba(30, 58, 95, 0.3);
}

ul.ai-list li:last-child {
    border-bottom: none;
}

ul.ai-list li::before {
    content: '';
    position: absolute;
    left: 0;
    top: 50%;
    transform: translateY(-50%);
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--accent-gradient);
}

ol.ai-list {
    padding-left: 0;
    counter-reset: ai-counter;
}

ol.ai-list li {
    counter-increment: ai-counter;
    position: relative;
    padding: 0.6rem 0 0.6rem 2.25rem;
    color: var(--text-secondary);
    font-size: 0.9rem;
    line-height: 1.55;
    border-bottom: 1px solid rgba(30, 58, 95, 0.3);
}

ol.ai-list li:last-child {
    border-bottom: none;
}

ol.ai-list li::before {
    content: counter(ai-counter);
    position: absolute;
    left: 0;
    top: 0.55rem;
    width: 22px;
    height: 22px;
    border-radius: 50%;
    background: var(--accent-gradient);
    color: #fff;
    font-size: 0.7rem;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
}

.ai-text strong,
.ai-list strong {
    color: var(--text-primary);
}

.ai-text code,
.ai-list code {
    background: rgba(59, 130, 246, 0.1);
    color: var(--accent);
    padding: 0.1em 0.4em;
    border-radius: 4px;
    font-size: 0.85em;
}

.ai-subsection {
    color: var(--text-muted);
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin: 0.75rem 0 0.35rem;
}

/* Mobile */
.navbar-toggler {
    display: none;
}

@media (max-width: 768px) {
    .sidebar {
        width: 100%;
        height: auto;
        position: relative;
    }

    main {
        margin-left: 0;
    }

    .navbar-toggler {
        display: block;
    }
}

/* ========== Minimal Layout ========== */
.minimal-page {
    min-height: 100vh;
    background: var(--bg-dark);
}

/* ========== Login Page ========== */
.login-container {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    padding: 20px;
}

.login-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 16px;
    padding: 40px;
    width: 100%;
    max-width: 380px;
}

.login-header {
    text-align: center;
    margin-bottom: 30px;
}

.login-header h1 {
    font-size: 2rem;
    font-weight: 700;
    background: var(--accent-gradient);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    margin-bottom: 8px;
}

.login-header p {
    color: var(--text-muted);
    font-size: 0.9rem;
}

.login-field input {
    width: 100%;
    padding: 12px 16px;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: 10px;
    color: var(--text-primary);
    font-size: 1rem;
    outline: none;
    box-sizing: border-box;
    margin-bottom: 16px;
}

.login-field input:focus {
    border-color: var(--accent);
}

.login-btn {
    width: 100%;
    padding: 12px;
    background: var(--accent);
    color: white;
    border: none;
    border-radius: 10px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
}

.login-btn:hover {
    background: var(--accent-hover);
}

.login-error {
    background: rgba(239, 68, 68, 0.15);
    color: var(--danger);
    padding: 10px 14px;
    border-radius: 8px;
    font-size: 0.85rem;
    text-align: center;
    margin-bottom: 16px;
}

/* ========== Mobile Trade Page ========== */
.mobile-denied {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    color: var(--text-muted);
}

.mobile-trade-page {
    padding: 16px;
    max-width: 600px;
    margin: 0 auto;
    padding-bottom: 40px;
}

.mobile-header {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    margin-bottom: 12px;
}

.mobile-header h1 {
    font-size: 1.5rem;
    font-weight: 700;
    margin: 0;
}

.mobile-date {
    color: var(--text-muted);
    font-size: 0.8rem;
}

.mobile-range-bar {
    display: flex;
    gap: 6px;
    margin-bottom: 16px;
}

.mobile-range-bar a {
    flex: 1;
    padding: 8px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 8px;
    color: var(--text-secondary);
    font-size: 0.8rem;
    font-weight: 600;
    cursor: pointer;
    text-decoration: none;
    text-align: center;
}

.mobile-range-bar a.active {
    background: var(--accent);
    border-color: var(--accent);
    color: white;
}

.mobile-hero {
    text-align: center;
    padding: 20px;
    border-radius: 14px;
    margin-bottom: 16px;
}

.mobile-hero.profit {
    background: rgba(34, 197, 94, 0.1);
    border: 1px solid rgba(34, 197, 94, 0.3);
}

.mobile-hero.loss {
    background: rgba(239, 68, 68, 0.1);
    border: 1px solid rgba(239, 68, 68, 0.3);
}

.mobile-hero-label {
    font-size: 0.8rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 4px;
}

.mobile-hero-value {
    font-size: 2rem;
    font-weight: 700;
}

.mobile-hero.profit .mobile-hero-value { color: var(--success); }
.mobile-hero.loss .mobile-hero-value { color: var(--danger); }

.mobile-stats-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
    margin-bottom: 16px;
}

.mobile-stats-grid.cols-2 {
    grid-template-columns: 1fr 1fr;
}

.mobile-stat-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 12px;
    text-align: center;
}

.mobile-stat-label {
    font-size: 0.7rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.3px;
    margin-bottom: 4px;
}

.mobile-stat-value {
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--text-primary);
}

.mobile-stat-sub {
    font-size: 0.7rem;
    color: var(--text-muted);
    margin-top: 2px;
}

.mobile-section {
    margin-bottom: 20px;
}

.mobile-section-title {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 10px;
}

.mobile-chart-container {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 12px;
    height: 200px;
}

.mobile-trade-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 12px 14px;
    margin-bottom: 6px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.mobile-trade-left {
    display: flex;
    align-items: center;
    gap: 8px;
}

.mobile-trade-ticker {
    font-weight: 700;
    font-size: 0.95rem;
}

.mobile-trade-type {
    font-size: 0.65rem;
    font-weight: 700;
    padding: 2px 6px;
    border-radius: 4px;
    text-transform: uppercase;
}

.badge-call {
    background: rgba(59, 130, 246, 0.2);
    color: #3b82f6;
}

.badge-put {
    background: rgba(168, 85, 247, 0.2);
    color: #a855f7;
}

.mobile-trade-contracts {
    font-size: 0.8rem;
    color: var(--text-muted);
}

.mobile-trade-right {
    text-align: right;
}

.mobile-trade-pl {
    font-weight: 700;
    font-size: 0.95rem;
}

.mobile-trade-date {
    font-size: 0.7rem;
    color: var(--text-muted);
}

.text-profit { color: var(--success) !important; }
.text-loss { color: var(--danger) !important; }

@keyframes spin {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

.spin { animation: spin 1s linear infinite; }

/* Month × category breakdown matrix */
.breakdown-matrix { min-width: 640px; }
.breakdown-matrix th,
.breakdown-matrix td { padding: 0.35rem 0.6rem; white-space: nowrap; }
.breakdown-matrix .bd-cat-col {
    text-align: left;
    position: sticky;
    left: 0;
    background: var(--bg-card);
    z-index: 1;
    min-width: 150px;
}
.breakdown-matrix tbody tr:hover .bd-cat-col { background: var(--bg-card-hover); }
.breakdown-matrix .bd-cat-col .cat-dot { margin-right: 0.4rem; }
.breakdown-matrix .bd-total-col {
    border-left: 1px solid var(--border);
    font-variant-numeric: tabular-nums;
}
.breakdown-matrix .bd-cell {
    cursor: pointer;
    font-variant-numeric: tabular-nums;
    transition: background 0.1s;
}
.breakdown-matrix .bd-cell:hover {
    background: rgba(59, 130, 246, 0.18);
    color: var(--text-primary);
}
.breakdown-matrix .bd-empty { color: var(--text-muted); opacity: 0.4; }
.breakdown-matrix tfoot .bd-foot td {
    border-top: 1px solid var(--border);
    font-weight: 600;
    color: var(--text-primary);
    font-variant-numeric: tabular-nums;
}

/* Clickable merchant name in the transactions grid → rename popup */
.merchant-link {
    cursor: pointer;
    border-bottom: 1px dashed transparent;
    transition: color 0.12s, border-color 0.12s;
}
.merchant-link:hover {
    color: var(--accent);
    border-bottom-color: rgba(59, 130, 246, 0.5);
}

/* Post-import review banner on the transactions tab */
.review-banner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    flex-wrap: wrap;
    padding: 0.5rem 0.8rem;
    margin-bottom: 0.8rem;
    border-radius: var(--radius);
    background: rgba(34, 197, 94, 0.1);
    border: 1px solid rgba(34, 197, 94, 0.3);
    color: var(--text-primary);
    font-size: var(--fs-base);
}
.review-banner strong { color: var(--success); }

/* Per-transaction splits */
.split-chip {
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
    border: 1px solid rgba(168, 85, 247, 0.4);
    background: rgba(168, 85, 247, 0.12);
    color: #c084fc;
    font-size: 0.72rem;
    font-weight: 500;
    padding: 0.15rem 0.5rem;
    border-radius: 999px;
    cursor: pointer;
    white-space: nowrap;
}
.split-chip:hover { background: rgba(168, 85, 247, 0.2); }
.split-chip i { font-size: 0.62rem; }

.btn-split-open {
    border: none;
    background: transparent;
    color: var(--text-muted);
    width: 24px;
    height: 24px;
    border-radius: var(--radius-sm);
    display: inline-grid;
    place-items: center;
    cursor: pointer;
    flex: 0 0 auto;
    transition: color 0.12s, background 0.12s;
}
.btn-split-open:hover { color: #c084fc; background: rgba(168, 85, 247, 0.12); }

.split-badge {
    font-size: 0.56rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.4px;
    color: #c084fc;
    background: rgba(168, 85, 247, 0.15);
    padding: 0.02rem 0.28rem;
    border-radius: var(--radius-sm);
    margin-left: 0.35rem;
}

.split-row {
    display: grid;
    grid-template-columns: 1fr 96px 84px 28px;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 0.4rem;
}
.split-pct { display: flex; align-items: center; gap: 0.2rem; }
.split-pct input { text-align: right; }
.split-amt { text-align: right; font-variant-numeric: tabular-nums; }
