:root {
    color-scheme: light;
    --bg: #f5f7f4;
    --surface: #ffffff;
    --surface-soft: #eef3ef;
    --text: #17231d;
    --muted: #637066;
    --line: #dce5dd;
    --accent: #0e7c66;
    --accent-strong: #095a4a;
    --warn: #a55b00;
    --danger: #b93636;
    --income: #087f5b;
    --shadow: 0 18px 50px rgba(18, 35, 29, 0.12);
    --radius: 8px;
    font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

:root[data-theme="dark"] {
    color-scheme: dark;
    --bg: #101413;
    --surface: #181f1d;
    --surface-soft: #202a27;
    --text: #edf4f0;
    --muted: #aab8b0;
    --line: #31403b;
    --accent: #4ec9ad;
    --accent-strong: #91e3d1;
    --warn: #f0b35f;
    --danger: #ff7f7f;
    --income: #64d6aa;
    --shadow: 0 18px 50px rgba(0, 0, 0, 0.32);
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    min-height: 100vh;
    background: var(--bg);
    color: var(--text);
    overflow-x: clip;
}

.icon-sprite {
    display: none;
}

.ui-icon {
    width: 1.05em;
    height: 1.05em;
    fill: currentColor;
    flex: 0 0 auto;
}

button,
input,
select {
    font: inherit;
}

button {
    cursor: pointer;
}

.app-shell {
    display: grid;
    grid-template-columns: 285px minmax(0, 1fr);
    min-height: 100vh;
    transition: grid-template-columns 180ms ease;
}

body.is-sidebar-collapsed .app-shell {
    grid-template-columns: 76px minmax(0, 1fr);
}

.sidebar {
    border-right: 1px solid var(--line);
    background: var(--surface);
    padding: 24px;
    display: flex;
    flex-direction: column;
    gap: 24px;
    position: sticky;
    top: 0;
    height: 100vh;
    overflow: hidden;
    transition: padding 180ms ease, gap 180ms ease;
}

.sidebar-toggle {
    position: absolute;
    top: 14px;
    right: 12px;
    z-index: 2;
    width: 34px;
    height: 34px;
    border: 1px solid var(--line);
    border-radius: 999px;
    background: var(--surface-soft);
    color: var(--text);
    display: grid;
    place-items: center;
    font-size: 1.35rem;
    font-weight: 900;
    line-height: 1;
}

.sidebar-toggle__expand {
    display: none;
}

body.is-sidebar-collapsed .sidebar {
    padding: 18px 12px;
    gap: 18px;
}

body.is-sidebar-collapsed .sidebar-toggle {
    right: 50%;
    transform: translateX(50%);
}

body.is-sidebar-collapsed .sidebar-toggle__collapse {
    display: none;
}

body.is-sidebar-collapsed .sidebar-toggle__expand {
    display: inline;
}

.brand {
    display: flex;
    align-items: center;
    gap: 12px;
}

.brand-logo {
    display: block;
    width: min(100%, 235px);
    max-height: 112px;
    object-fit: contain;
    object-position: left center;
}

.brand-logo--shield {
    display: none;
}

body.is-sidebar-collapsed .brand {
    justify-content: center;
    margin-top: 40px;
}

body.is-sidebar-collapsed .brand-logo--nav {
    display: none;
}

body.is-sidebar-collapsed .brand-logo--shield {
    display: block;
    width: 48px;
    height: 48px;
    object-fit: contain;
    object-position: center;
    border-radius: var(--radius);
}

.brand__mark {
    display: grid;
    place-items: center;
    width: 48px;
    height: 48px;
    border-radius: var(--radius);
    background: var(--accent);
    color: #fff;
    font-weight: 800;
}

.brand h1,
.brand p,
.topbar h2,
.topbar p,
.panel h3,
.metric span,
.metric strong,
.metric small {
    margin: 0;
}

.brand h1 {
    font-size: 1.2rem;
}

.brand p,
.eyebrow,
.hint,
.metric small,
.account-card small,
.schedule-item small {
    color: var(--muted);
}

.nav-list {
    display: grid;
    gap: 8px;
}

.mobile-menu-actions {
    display: none;
}

.mobile-menu-button {
    width: 40px;
    height: 40px;
    justify-content: center;
}

.nav-link {
    min-height: 42px;
    border: 0;
    border-radius: var(--radius);
    background: transparent;
    color: var(--muted);
    text-align: left;
    padding: 0 12px;
    display: inline-flex;
    align-items: center;
    gap: 10px;
}

body.is-sidebar-collapsed .nav-link {
    justify-content: center;
    padding: 0;
}

body.is-sidebar-collapsed .nav-link span,
body.is-sidebar-collapsed .quick-tips {
    display: none;
}

.nav-link.is-active,
.nav-link:hover {
    background: var(--surface-soft);
    color: var(--text);
}

.quick-tips {
    margin-top: auto;
    border-top: 1px solid var(--line);
    padding-top: 18px;
}

.quick-tips h2 {
    font-size: 0.9rem;
    margin: 0 0 10px;
}

.quick-tips ul {
    margin: 0;
    padding: 0;
    list-style: none;
    color: var(--muted);
    font-size: 0.82rem;
    line-height: 1.45;
    display: grid;
    gap: 8px;
}

.quick-tips li {
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: var(--surface-soft);
    padding: 9px 10px;
}

.workspace {
    min-width: 0;
    padding: 24px;
}

.topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 24px;
}

.topbar h2 {
    font-size: clamp(1.7rem, 2.6vw, 2.4rem);
    letter-spacing: 0;
}

.topbar__actions {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}

.eyebrow {
    font-size: 0.78rem;
    text-transform: uppercase;
    font-weight: 700;
}

.theme-toggle {
    min-height: 40px;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: 0 12px;
    background: var(--surface);
}

.user-chip,
.topbar-link {
    min-height: 40px;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: var(--surface);
    color: var(--text);
    padding: 0 12px;
    text-decoration: none;
    font-size: 0.86rem;
    font-weight: 700;
}

.user-chip {
    color: var(--muted);
    max-width: 220px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.icon-button,
.text-button,
.primary-button {
    border-radius: var(--radius);
    min-height: 40px;
    border: 1px solid var(--line);
}

.icon-button {
    width: 40px;
    background: var(--surface);
    color: var(--text);
}

.text-button {
    background: transparent;
    color: var(--accent);
    border-color: transparent;
    padding: 0 8px;
    font-weight: 700;
    display: inline-flex;
    align-items: center;
    gap: 7px;
}

.primary-button {
    background: var(--accent);
    color: #fff;
    border-color: var(--accent);
    padding: 0 14px;
    font-weight: 800;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.action-button {
    min-height: 40px;
    border-radius: var(--radius);
    border: 1px solid var(--line);
    background: var(--surface);
    color: var(--text);
    padding: 0 14px;
    font-weight: 800;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.action-button.is-active {
    background: var(--accent);
    border-color: var(--accent);
    color: #fff;
}

.site-footer {
    border-top: 1px solid var(--line);
    color: var(--muted);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-top: 6px;
    padding: 18px 2px 2px;
    font-size: 0.8rem;
}

.site-footer span:first-child {
    color: var(--text);
    font-weight: 800;
}

.view {
    display: none;
}

.view.is-active {
    display: grid;
    gap: 18px;
}

.dashboard-alert {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr) auto;
    align-items: center;
    gap: 12px;
    border: 1px solid color-mix(in srgb, var(--warn), var(--line) 45%);
    border-radius: var(--radius);
    background: color-mix(in srgb, var(--warn), var(--surface) 91%);
    box-shadow: var(--shadow);
    padding: 14px 16px;
}

.dashboard-alert[hidden] {
    display: none;
}

.dashboard-alert__icon {
    width: 40px;
    height: 40px;
    border-radius: var(--radius);
    display: grid;
    place-items: center;
    background: color-mix(in srgb, var(--warn), transparent 82%);
    color: var(--warn);
}

.dashboard-alert strong,
.dashboard-alert p {
    margin: 0;
}

.dashboard-alert strong {
    display: block;
    font-size: 0.98rem;
}

.dashboard-alert p {
    color: var(--muted);
    font-size: 0.86rem;
}

.metric-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 14px;
}

.metric,
.panel {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
}

.metric {
    padding: 18px;
    display: grid;
    gap: 8px;
}

.metric--button {
    width: 100%;
    color: var(--text);
    text-align: left;
    cursor: pointer;
}

.metric--button:hover {
    border-color: color-mix(in srgb, var(--accent), var(--line) 35%);
}

.metric--button:focus-visible {
    outline: 3px solid color-mix(in srgb, var(--accent), transparent 70%);
    outline-offset: 2px;
}

.metric span {
    color: var(--muted);
    font-size: 0.85rem;
    display: inline-flex;
    align-items: center;
    gap: 8px;
}

.metric strong {
    font-size: clamp(1.35rem, 2vw, 1.9rem);
}

.content-grid {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    gap: 18px;
}

.schedule-grid {
    display: grid;
    grid-template-columns: minmax(240px, 0.85fr) minmax(240px, 0.85fr) minmax(320px, 1.3fr);
    gap: 18px;
    align-items: start;
}

.schedule-calendar-panel {
    grid-column: 1 / -1;
}

.calendar-controls {
    display: inline-flex;
    align-items: center;
    gap: 8px;
}

.panel {
    padding: 18px;
    min-width: 0;
}

.panel__header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 14px;
}

.panel h3 {
    font-size: 1.05rem;
}

.account-list,
.schedule-list,
.match-list {
    display: grid;
    gap: 10px;
    min-width: 0;
    max-width: 100%;
}

.schedule-calendar {
    display: grid;
    gap: 8px;
}

.schedule-calendar-summary {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 10px;
    margin-bottom: 12px;
}

.calendar-stat {
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: var(--surface-soft);
    min-height: 58px;
    padding: 10px;
    display: grid;
    gap: 2px;
}

.calendar-stat strong {
    font-size: 1rem;
}

.calendar-stat small {
    color: var(--muted);
    font-size: 0.74rem;
    font-weight: 800;
    text-transform: uppercase;
}

.schedule-calendar__weekdays,
.schedule-calendar__grid {
    display: grid;
    grid-template-columns: repeat(7, minmax(0, 1fr));
    gap: 8px;
}

.schedule-calendar__weekdays span {
    color: var(--muted);
    font-size: 0.72rem;
    font-weight: 800;
    text-align: center;
    text-transform: uppercase;
}

.schedule-day {
    min-height: 132px;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: var(--surface-soft);
    padding: 8px;
    display: grid;
    grid-template-rows: auto minmax(0, 1fr);
    gap: 8px;
}

.schedule-day.is-muted {
    opacity: 0.48;
}

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

.schedule-day__number {
    color: var(--muted);
    font-size: 0.78rem;
    font-weight: 850;
}

.schedule-day__items {
    display: grid;
    align-content: start;
    gap: 5px;
    min-width: 0;
}

.schedule-chip,
.schedule-chip-more {
    width: 100%;
    min-width: 0;
    min-height: 26px;
    border: 0;
    border-radius: 7px;
    padding: 0 7px;
    display: inline-flex;
    align-items: center;
    gap: 5px;
    color: var(--text);
    font-size: 0.74rem;
    font-weight: 800;
}

.schedule-chip span {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.schedule-chip.is-income {
    background: color-mix(in srgb, var(--income), transparent 82%);
    color: var(--income);
}

.schedule-chip.is-payment {
    background: color-mix(in srgb, var(--danger), transparent 84%);
    color: var(--danger);
}

.schedule-chip-more {
    background: transparent;
    color: var(--muted);
}

.action-strip {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
}

.action-strip button {
    min-width: 150px;
}

.account-panels {
    display: grid;
    gap: 18px;
}

.account-action-panel[hidden] {
    display: none;
}

.account-card,
.schedule-item,
.match-card {
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: var(--surface-soft);
    padding: 14px;
}

.account-card {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr) auto;
    gap: 10px;
    align-items: center;
    width: 100%;
    color: var(--text);
    text-align: left;
}

.account-card__icon {
    width: 38px;
    height: 38px;
    border-radius: var(--radius);
    display: grid;
    place-items: center;
    background: color-mix(in srgb, var(--accent), transparent 82%);
    color: var(--accent);
}

.account-logo {
    color: #fff;
    font-size: 0.66rem;
    font-weight: 950;
    letter-spacing: 0;
    overflow: hidden;
}

.account-logo span {
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.account-logo--bank { background: #246b5a; }
.account-logo--building-society { background: #3f6f91; }
.account-logo--credit-card { background: linear-gradient(135deg, #1a2638, #56657c); }
.account-logo--barclays { background: #00aEEF; }
.account-logo--hsbc { background: #db0011; }
.account-logo--lloyds { background: #005a30; }
.account-logo--natwest { background: #3c1053; }
.account-logo--santander { background: #ec0000; }
.account-logo--halifax { background: #005eb8; }
.account-logo--nationwide { background: #003c7f; }
.account-logo--monzo { background: linear-gradient(135deg, #14233c, #f36f45); }
.account-logo--starling { background: #6930c3; }
.account-logo--revolut { background: #111827; }
.account-logo--chase { background: #005eb8; }
.account-logo--tesco-bank { background: #00539f; }
.account-logo--virgin-money { background: #c0007a; }
.account-logo--amex { background: #2e77bc; }
.account-logo--visa { background: #1a1f71; }
.account-logo--mastercard { background: linear-gradient(90deg, #eb001b 0 48%, #f79e1b 52%); }
.account-logo--generic { background: color-mix(in srgb, var(--accent), #1c2b26 52%); }

.account-logo-preview {
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: var(--surface-soft);
    padding: 12px;
    display: grid;
    grid-template-columns: auto minmax(0, 1fr);
    gap: 10px;
    align-items: center;
}

.account-logo-preview strong,
.account-logo-preview small {
    display: block;
}

.account-logo-preview small {
    color: var(--muted);
    margin-top: 2px;
}

button.account-card {
    cursor: pointer;
}

button.account-card:hover {
    border-color: var(--accent);
}

.account-card.is-frozen,
.account-register-row.is-frozen .account-card,
.schedule-item.is-frozen {
    opacity: 0.72;
}

.account-summary-panel {
    padding: 0;
    overflow: hidden;
}

.account-summary-card {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr) auto;
    gap: 16px;
    align-items: start;
    padding: 18px;
}

.account-summary-card__main h3 {
    margin: 0 0 4px;
    font-size: clamp(1.35rem, 2.4vw, 2.05rem);
}

.account-summary-card__main .eyebrow {
    margin-bottom: 5px;
}

.account-summary-card__back {
    align-self: start;
}

.account-summary-stats {
    grid-column: 1 / -1;
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 10px;
    margin: 2px 0 0;
}

.account-summary-stats div {
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: var(--surface-soft);
    min-height: 74px;
    padding: 12px;
}

.account-summary-stats dt {
    color: var(--muted);
    font-size: 0.72rem;
    font-weight: 850;
    text-transform: uppercase;
}

.account-summary-stats dd {
    margin: 7px 0 0;
    font-size: clamp(1rem, 1.5vw, 1.35rem);
    font-weight: 900;
}

.account-summary-actions {
    grid-column: 1 / -1;
    border-top: 1px solid var(--line);
    margin-top: 2px;
    padding-top: 14px;
}

.account-register-row {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 10px;
    align-items: center;
}

.account-group {
    display: grid;
    gap: 10px;
}

.account-group + .account-group {
    margin-top: 16px;
}

.account-group__header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    border-bottom: 1px solid var(--line);
    padding-bottom: 8px;
}

.account-group__header h4 {
    margin: 0;
    font-size: 0.95rem;
}

.account-group__items {
    display: grid;
    gap: 10px;
}

.account-register-row.is-dragging {
    opacity: 0.55;
}

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

.drag-handle {
    min-height: 40px;
    min-width: 34px;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    display: inline-grid;
    place-items: center;
    color: var(--muted);
    cursor: grab;
    touch-action: none;
    user-select: none;
}

.ghost-button,
.danger-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 7px;
}

.account-card strong,
.schedule-item strong,
.match-card strong {
    display: block;
}

.balance {
    font-size: 1.15rem;
    font-weight: 800;
}

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

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

.table-wrap {
    width: 100%;
    max-width: 100%;
    min-width: 0;
    overflow-x: auto;
}

table {
    width: 100%;
    border-collapse: collapse;
    min-width: 980px;
}

.recent-table {
    min-width: 700px;
}

.recent-table:not(.statement-table) {
    table-layout: fixed;
}

.recent-table:not(.statement-table) th:nth-child(1),
.recent-table:not(.statement-table) td:nth-child(1) {
    width: 76px;
    white-space: nowrap;
}

.recent-table:not(.statement-table) th:nth-child(2),
.recent-table:not(.statement-table) td:nth-child(2) {
    width: 150px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.recent-table:not(.statement-table) th:nth-child(3),
.recent-table:not(.statement-table) td:nth-child(3) {
    width: 132px;
}

.recent-table:not(.statement-table) th:nth-child(4),
.recent-table:not(.statement-table) td:nth-child(4) {
    width: 108px;
}

.recent-table:not(.statement-table) th:nth-child(5),
.recent-table:not(.statement-table) td:nth-child(5) {
    width: 108px;
}

.recent-table:not(.statement-table) th:nth-child(6),
.recent-table:not(.statement-table) td:nth-child(6) {
    width: 126px;
}

.statement-table {
    min-width: 700px;
    table-layout: auto;
}

.statement-table th:nth-child(2),
.statement-table td:nth-child(2),
.statement-table th:nth-child(3),
.statement-table td:nth-child(3),
.statement-table th:nth-child(4),
.statement-table td:nth-child(4) {
    max-width: 180px;
    overflow-wrap: anywhere;
}

th,
td {
    text-align: left;
    padding: 12px 10px;
    border-bottom: 1px solid var(--line);
    vertical-align: middle;
}

th {
    color: var(--muted);
    font-size: 0.78rem;
    text-transform: uppercase;
}

.recent-table th,
.recent-table td {
    padding: 7px 8px;
    font-size: 0.88rem;
}

.recent-table th {
    font-size: 0.7rem;
}

.recent-table .money-icon {
    width: 18px;
    height: 18px;
    margin-right: 2px;
}

.verification-dot {
    display: inline-block;
    width: 9px;
    height: 9px;
    border-radius: 50%;
    margin-left: 5px;
    vertical-align: middle;
    box-shadow: 0 0 0 2px color-mix(in srgb, currentColor, transparent 82%);
}

.verification-dot.is-verified {
    background: var(--income);
    color: var(--income);
}

.verification-dot.is-unverified {
    background: #d6a300;
    color: #d6a300;
}

.amount {
    text-align: right;
    white-space: nowrap;
}

.pill {
    display: inline-flex;
    align-items: center;
    min-height: 24px;
    border-radius: 999px;
    background: var(--surface-soft);
    padding: 0 10px;
    font-size: 0.78rem;
    font-weight: 700;
}

.inline-edit {
    width: min(180px, 100%);
    min-height: 34px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--surface);
    color: var(--text);
    padding: 0 9px;
    font-size: 0.9rem;
    font-weight: 650;
}

.recent-table .inline-edit {
    width: 100%;
    min-height: 28px;
    border-radius: 7px;
    padding: 0 6px;
    font-size: 0.84rem;
}

.recent-table .inline-edit--payee {
    max-width: 112px;
}

.recent-table .inline-edit--category {
    max-width: 88px;
}

.recent-table .inline-edit--reference {
    max-width: 88px;
}

.compact-button {
    min-height: 34px;
    padding: 0 10px;
    white-space: nowrap;
}

.passkey-list {
    display: grid;
    gap: 10px;
}

.passkey-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: var(--surface-soft);
    padding: 12px;
}

.passkey-item strong,
.passkey-item small {
    display: block;
}

.passkey-item small {
    color: var(--muted);
    margin-top: 2px;
}

.money-icon {
    width: 22px;
    height: 22px;
    border-radius: 999px;
    display: inline-grid;
    place-items: center;
    margin-right: 4px;
    vertical-align: middle;
}

.money-icon .ui-icon {
    width: 0.82em;
    height: 0.82em;
}

.money-icon--in {
    background: color-mix(in srgb, var(--income), transparent 82%);
    color: var(--income);
}

.money-icon--out {
    background: color-mix(in srgb, var(--danger), transparent 84%);
    color: var(--danger);
}

.form-stack {
    display: grid;
    gap: 12px;
}

.form-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 12px;
    align-items: end;
}

.form-stack label,
.form-grid label {
    display: grid;
    gap: 6px;
    color: var(--muted);
    font-size: 0.86rem;
    font-weight: 700;
}

.form-stack input,
.form-stack select,
.form-grid input,
.form-grid select {
    width: 100%;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: var(--surface);
    color: var(--text);
    min-height: 42px;
    padding: 0 10px;
}

.form-stack input[type="date"],
.form-grid input[type="date"],
.date-input {
    min-height: 46px;
    padding: 0 42px 0 12px;
    background: var(--surface);
    color: var(--text);
    font-weight: 750;
    letter-spacing: 0;
    position: relative;
    cursor: pointer;
}

.form-stack input[type="date"]::-webkit-calendar-picker-indicator,
.form-grid input[type="date"]::-webkit-calendar-picker-indicator {
    width: 22px;
    height: 22px;
    border-radius: var(--radius);
    cursor: pointer;
    opacity: 0.72;
    filter: sepia(1) saturate(0.65) hue-rotate(115deg);
}

:root[data-theme="dark"] .form-stack input[type="date"]::-webkit-calendar-picker-indicator,
:root[data-theme="dark"] .form-grid input[type="date"]::-webkit-calendar-picker-indicator {
    filter: invert(1) sepia(1) saturate(0.7) hue-rotate(115deg);
}

.form-stack input[type="date"]:focus,
.form-grid input[type="date"]:focus,
.date-input:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent), transparent 78%);
    outline: none;
}

.date-modal[hidden] {
    display: none;
}

.net-worth-modal[hidden] {
    display: none;
}

.net-worth-modal,
.date-modal {
    position: fixed;
    inset: 0;
    z-index: 50;
    display: grid;
    place-items: center;
    padding: 18px;
}

.date-modal__backdrop {
    position: absolute;
    inset: 0;
    background: rgba(9, 18, 15, 0.58);
}

.net-worth-modal__backdrop {
    position: absolute;
    inset: 0;
    background: rgba(9, 18, 15, 0.58);
}

.net-worth-dialog {
    position: relative;
    z-index: 1;
    width: min(100%, 540px);
    max-height: min(86vh, 680px);
    overflow: auto;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 18px;
}

.net-worth-list {
    display: grid;
    gap: 10px;
}

.net-worth-row {
    width: 100%;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: var(--surface-soft);
    color: var(--text);
    min-height: 64px;
    padding: 10px;
    display: grid;
    grid-template-columns: auto minmax(0, 1fr) auto;
    gap: 12px;
    align-items: center;
    text-align: left;
}

.net-worth-row small {
    display: block;
    color: var(--muted);
    margin-top: 2px;
}

.net-worth-total {
    border-top: 1px solid var(--line);
    margin-top: 14px;
    padding-top: 14px;
    display: flex;
    justify-content: space-between;
    gap: 14px;
}

.date-picker {
    position: relative;
    z-index: 1;
    width: min(100%, 390px);
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 16px;
    display: grid;
    gap: 12px;
}

.date-picker__header,
.date-picker__footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
}

.date-picker__header h2 {
    margin: 0;
    font-size: 1rem;
    text-align: center;
}

.date-picker__weekdays,
.date-picker__grid {
    display: grid;
    grid-template-columns: repeat(7, minmax(0, 1fr));
    gap: 6px;
}

.date-picker__weekdays span {
    color: var(--muted);
    font-size: 0.72rem;
    font-weight: 800;
    text-align: center;
    text-transform: uppercase;
}

.date-picker__day {
    aspect-ratio: 1;
    min-height: 42px;
    min-width: 0;
    border: 1px solid transparent;
    border-radius: var(--radius);
    background: var(--surface-soft);
    color: var(--text);
    font-weight: 800;
}

.date-picker__day:hover,
.date-picker__day:focus {
    border-color: var(--accent);
    outline: none;
}

.date-picker__day.is-muted {
    color: var(--muted);
    opacity: 0.62;
}

.date-picker__day.is-today {
    border-color: var(--accent);
}

.date-picker__day.is-selected {
    background: var(--accent);
    border-color: var(--accent);
    color: #fff;
}

.has-modal {
    overflow: hidden;
}

.form-grid__wide {
    grid-column: span 2;
}

.form-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
}

.hint {
    margin: 0;
    line-height: 1.45;
    font-size: 0.86rem;
}

.match-card {
    display: grid;
    gap: 10px;
}

.match-card__main,
.match-card__actions,
.schedule-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

.schedule-item__main {
    flex: 1 1 auto;
    min-width: 0;
    max-width: 100%;
}

.schedule-item__main strong,
.schedule-item__main small {
    display: block;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.schedule-item__amount {
    flex: 0 0 auto;
    display: inline-flex;
    align-items: center;
    gap: 4px;
    max-width: 42%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.schedule-item__amount .money-icon {
    margin-right: 0;
}

.schedule-item--upcoming {
    display: grid;
    grid-template-columns: minmax(0, 1fr) fit-content(155px);
    align-items: center;
    justify-content: stretch;
    gap: 8px;
    width: 100%;
    max-width: 100%;
    overflow: hidden;
}

.schedule-item--upcoming .schedule-item__amount {
    justify-self: end;
    min-width: 0;
    max-width: min(34vw, 155px);
}

.match-card__actions {
    justify-content: flex-start;
    flex-wrap: wrap;
}

.ghost-button,
.danger-button {
    min-height: 36px;
    border-radius: var(--radius);
    padding: 0 12px;
    border: 1px solid var(--line);
    background: var(--surface);
    color: var(--text);
}

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

.import-summary p,
.feature-list p,
.empty-state {
    color: var(--muted);
    margin: 0;
    line-height: 1.5;
}

.bar-chart {
    display: grid;
    gap: 12px;
}

.bar-row {
    display: grid;
    gap: 6px;
}

.bar-row__meta {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    font-size: 0.88rem;
}

.bar {
    height: 10px;
    background: var(--surface-soft);
    border-radius: 999px;
    overflow: hidden;
}

.bar span {
    display: block;
    height: 100%;
    background: var(--accent);
}

.toast {
    position: fixed;
    right: 18px;
    bottom: 18px;
    max-width: min(360px, calc(100vw - 36px));
    background: var(--text);
    color: var(--surface);
    border-radius: var(--radius);
    padding: 12px 14px;
    box-shadow: var(--shadow);
    opacity: 0;
    transform: translateY(12px);
    pointer-events: none;
    transition: opacity 160ms ease, transform 160ms ease;
}

.toast.is-visible {
    opacity: 1;
    transform: translateY(0);
}

.suggest-menu {
    position: fixed;
    z-index: 70;
    max-height: min(280px, 42vh);
    overflow-y: auto;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: var(--surface);
    color: var(--text);
    box-shadow: var(--shadow);
    padding: 6px;
}

.suggest-menu[hidden] {
    display: none;
}

.suggest-menu button {
    width: 100%;
    min-height: 34px;
    border: 0;
    border-radius: 6px;
    background: transparent;
    color: var(--text);
    text-align: left;
    padding: 0 10px;
    font-weight: 700;
}

.suggest-menu button:hover,
.suggest-menu button:focus {
    background: var(--surface-soft);
    color: var(--accent-strong);
    outline: none;
}

.auth-body {
    min-height: 100vh;
    background: var(--bg);
}

.auth-layout {
    min-height: 100vh;
    display: grid;
    place-items: center;
    padding: 18px;
}

.auth-layout--wide {
    align-items: start;
    padding-top: 8vh;
}

.auth-panel {
    width: min(100%, 460px);
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 24px;
    display: grid;
    gap: 18px;
}

.auth-layout--wide .auth-panel {
    width: min(100%, 880px);
}

.auth-brand {
    border-bottom: 1px solid var(--line);
    padding-bottom: 18px;
}

.auth-brand .brand-logo {
    width: min(100%, 390px);
    max-height: 170px;
}

.auth-panel h1,
.auth-panel h2,
.auth-panel p {
    margin: 0;
}

.auth-panel h2 {
    font-size: 1.25rem;
}

.auth-alert {
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: var(--surface-soft);
    color: var(--text);
    padding: 12px;
    line-height: 1.45;
    overflow-wrap: anywhere;
}

.auth-alert--error {
    border-color: color-mix(in srgb, var(--danger), var(--line) 45%);
    color: var(--danger);
}

.auth-link {
    color: var(--accent);
    font-weight: 800;
    text-decoration: none;
}

.passkey-first {
    display: grid;
    gap: 12px;
}

.passkey-first[hidden] {
    display: none;
}

.passkey-first .primary-button,
.passkey-first .ghost-button {
    width: 100%;
}

.login-switcher {
    display: grid;
    overflow: hidden;
}

.login-switcher__panel {
    grid-area: 1 / 1;
    min-width: 0;
    transition: opacity 180ms ease, transform 180ms ease, visibility 180ms ease;
}

.login-switcher.has-passkey .passkey-first {
    opacity: 1;
    transform: translateX(0);
    visibility: visible;
}

.login-switcher.has-passkey [data-password-login-form] {
    opacity: 0;
    transform: translateX(18px);
    visibility: hidden;
    pointer-events: none;
}

.login-switcher.show-password .passkey-first {
    opacity: 0;
    transform: translateX(-18px);
    visibility: hidden;
    pointer-events: none;
}

.login-switcher.show-password [data-password-login-form],
.login-switcher:not(.has-passkey) [data-password-login-form] {
    opacity: 1;
    transform: translateX(0);
    visibility: visible;
    pointer-events: auto;
}

@media (prefers-reduced-motion: reduce) {
    .login-switcher__panel {
        transition: none;
    }
}

@media (max-width: 980px) {
    html,
    body {
        width: 100%;
        height: 100%;
        max-width: 100%;
        overflow: hidden;
        overscroll-behavior-x: none;
    }

    .app-shell {
        grid-template-columns: 1fr;
        width: 100%;
        height: 100dvh;
        min-height: 100dvh;
        max-width: 100%;
        overflow: hidden;
    }

    body.is-sidebar-collapsed .app-shell {
        grid-template-columns: 1fr;
    }

    .sidebar {
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        z-index: 60;
        height: auto;
        max-height: calc(100dvh - 12px);
        overflow: visible;
        border-right: 0;
        border-bottom: 1px solid var(--line);
        display: grid;
        grid-template-columns: minmax(0, 1fr) auto;
        align-items: center;
        gap: 12px;
        box-shadow: 0 10px 28px rgba(18, 35, 29, 0.08);
        padding-top: max(16px, env(safe-area-inset-top));
        transform: translateZ(0);
    }

    .workspace {
        height: 100dvh;
        overflow-y: auto;
        overflow-x: hidden;
        overscroll-behavior-y: contain;
        -webkit-overflow-scrolling: touch;
        padding-top: calc(102px + env(safe-area-inset-top));
    }

    .sidebar-toggle {
        display: none;
    }

    body.is-sidebar-collapsed .sidebar {
        padding: 24px;
        padding-top: max(16px, env(safe-area-inset-top));
        gap: 12px;
    }

    body.is-sidebar-collapsed .brand {
        justify-content: flex-start;
        margin-top: 0;
    }

    body.is-sidebar-collapsed .brand-logo {
        width: min(100%, 235px);
        height: auto;
        max-height: 112px;
        object-fit: contain;
    }

    body.is-sidebar-collapsed .brand-logo--nav {
        display: block;
    }

    body.is-sidebar-collapsed .brand-logo--shield {
        display: none;
    }

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

    .nav-list {
        grid-column: 1 / -1;
        display: none;
        border: 1px solid var(--line);
        border-radius: var(--radius);
        background: var(--surface-soft);
        padding: 8px;
        overflow: visible;
    }

    body.is-mobile-nav-open .nav-list {
        display: grid;
    }

    .nav-link,
    body.is-sidebar-collapsed .nav-link {
        justify-content: flex-start;
        text-align: left;
        white-space: nowrap;
        padding: 0 12px;
    }

    body.is-sidebar-collapsed .nav-link span {
        display: inline;
    }

    .topbar {
        position: relative;
    }

    .topbar__actions {
        position: fixed;
        top: calc(76px + env(safe-area-inset-top));
        right: 16px;
        z-index: 65;
        display: none;
        width: min(280px, calc(100vw - 32px));
        border: 1px solid var(--line);
        border-radius: var(--radius);
        background: var(--surface);
        box-shadow: var(--shadow);
        padding: 10px;
        max-height: calc(100dvh - 96px);
        overflow-y: auto;
    }

    body.is-mobile-account-open .topbar__actions {
        display: grid;
    }

    .topbar__actions > * {
        width: 100%;
        justify-content: center;
    }

    .topbar__actions [data-action="seed"] {
        display: none;
    }

    .quick-tips {
        display: none;
    }

    .metric-grid,
    .content-grid,
    .schedule-grid,
    .form-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .schedule-grid .panel:last-child {
        grid-column: 1 / -1;
    }

    .schedule-day {
        min-height: 110px;
    }

    .workspace,
    .view,
    .panel,
    .metric,
    .content-grid,
    .schedule-grid,
    .account-list,
    .schedule-list {
        min-width: 0;
        max-width: 100%;
    }

    .table-wrap {
        margin-inline: -2px;
        max-width: calc(100vw - 32px);
        overflow-x: auto;
        overscroll-behavior-x: contain;
        -webkit-overflow-scrolling: touch;
        border-inline: 1px solid transparent;
    }

    .table-wrap::after {
        content: "";
        position: sticky;
        right: 0;
        display: block;
        width: 24px;
        height: 1px;
        margin-top: -1px;
        background: linear-gradient(90deg, transparent, var(--surface));
        pointer-events: none;
    }
}

@media (max-width: 640px) {
    .workspace,
    .sidebar {
        padding: 12px;
    }

    .workspace {
        display: grid;
        gap: 14px;
        padding-top: calc(88px + env(safe-area-inset-top));
    }

    .sidebar {
        padding-top: max(12px, env(safe-area-inset-top));
    }

    body.is-sidebar-collapsed .sidebar {
        padding: 12px;
        padding-top: max(12px, env(safe-area-inset-top));
    }

    .brand-logo {
        max-height: 58px;
    }

    .mobile-menu-button {
        width: 38px;
        height: 38px;
    }

    .topbar {
        align-items: flex-start;
        flex-direction: column;
        gap: 8px;
        margin-bottom: 14px;
    }

    .topbar__actions {
        width: min(280px, calc(100vw - 32px));
        justify-content: initial;
    }

    .dashboard-alert {
        grid-template-columns: auto minmax(0, 1fr);
        align-items: start;
    }

    .dashboard-alert .text-button {
        grid-column: 1 / -1;
        width: 100%;
        justify-content: center;
    }

    .site-footer {
        align-items: flex-start;
        flex-direction: column;
        gap: 6px;
        padding-bottom: max(2px, env(safe-area-inset-bottom));
    }

    .metric-grid,
    .content-grid,
    .schedule-grid,
    .form-grid {
        grid-template-columns: 1fr;
        gap: 12px;
    }

    .view.is-active {
        gap: 12px;
    }

    .panel,
    .metric {
        padding: 14px;
    }

    .metric strong {
        font-size: 1.45rem;
    }

    .schedule-grid .panel:last-child {
        grid-column: auto;
    }

    .calendar-controls {
        width: 100%;
    }

    .calendar-controls button {
        flex: 1;
    }

    .schedule-calendar-summary {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .schedule-calendar__weekdays {
        display: none;
    }

    .schedule-calendar__grid {
        grid-template-columns: 1fr;
    }

    .schedule-day {
        min-height: auto;
        grid-template-columns: 42px minmax(0, 1fr);
        grid-template-rows: auto;
        align-items: start;
    }

    .schedule-day.is-muted:not(.has-items) {
        display: none;
    }

    .form-grid__wide {
        grid-column: auto;
    }

    .account-card,
    .account-summary-card,
    .account-register-row,
    .match-card__main,
    .schedule-item {
        align-items: flex-start;
        grid-template-columns: 1fr;
        flex-direction: column;
    }

    .account-summary-stats {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .schedule-item--upcoming {
        align-items: center;
        display: grid;
        grid-template-columns: minmax(0, 1fr) fit-content(38vw);
        justify-content: stretch;
        gap: 8px;
        width: 100%;
        max-width: 100%;
        flex-direction: row;
    }

    .schedule-item--upcoming .schedule-item__amount {
        max-width: 38vw;
        justify-self: end;
    }

    .account-summary-card__back {
        width: 100%;
        justify-content: center;
    }

    .action-strip,
    .action-strip button,
    .account-row-actions,
    .account-row-actions button,
    .form-actions,
    .form-actions button {
        width: 100%;
    }

    .action-strip {
        display: grid;
        grid-template-columns: 1fr;
    }

    .table-wrap {
        max-width: calc(100vw - 24px);
    }

    .recent-table:not(.statement-table) {
        min-width: 640px;
    }

    table {
        min-width: 0;
    }

    .date-modal {
        align-items: end;
        padding: 10px;
    }

    .date-picker {
        width: 100%;
        max-height: calc(100vh - 20px);
        overflow: auto;
        padding: 14px;
    }

    .date-picker__weekdays,
    .date-picker__grid {
        gap: 4px;
    }

    .date-picker__day {
        min-height: 40px;
        font-size: 0.92rem;
    }

    .date-picker__footer {
        display: grid;
        grid-template-columns: 1fr 1fr 1fr;
    }

    .date-picker__footer button {
        width: 100%;
        padding: 0 8px;
    }

    .statement-table {
        min-width: 0;
    }

    .statement-table th:nth-child(4),
    .statement-table td:nth-child(4) {
        display: none;
    }

    .statement-table th,
    .statement-table td {
        padding: 7px 5px;
        font-size: 0.78rem;
    }

    .statement-table .money-icon {
        width: 16px;
        height: 16px;
    }
}
