:root {
    --primary: #305ca7;
    --primary-dark: #264986;
    --primary-darker: #1b3563;
    --primary-light: #4370c0;
    --primary-soft: rgba(48, 92, 167, 0.08);
    --dark: #18294d;
    --darker: #0e1b35;
    --light: #f0f4f8;
    --lighter: #f7f9fb;
    --white: #ffffff;
    --text-dark: #1e1e1e;
    --text: #444444;
    --text-light: #5f6673;
    --border: #dee2e6;
    --border-strong: #cfd6de;
    --shadow: rgba(24, 41, 77, 0.08);
    --shadow-lg: rgba(24, 41, 77, 0.14);
    --success: #2e7d32;
    --success-soft: rgba(46, 125, 50, 0.1);
    --warning: #b45309;
    --warning-soft: rgba(180, 83, 9, 0.1);
    --danger: #c53030;
    --danger-soft: rgba(197, 48, 48, 0.09);
    --font-heading: 'Montserrat', sans-serif;
    --font-body: 'Open Sans', sans-serif;
    --transition: 0.25s ease;
    --sidebar-width: 256px;
    --topbar-height: 64px;
}

*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html {
    -webkit-text-size-adjust: 100%;
    scrollbar-gutter: stable;
    scroll-padding-top: calc(var(--topbar-height) + 1rem);
}

body {
    min-height: 100vh;
    font-family: var(--font-body);
    font-size: 15px;
    line-height: 1.6;
    color: var(--text);
    background-color: var(--light);
}

h1, h2, h3, h4, h5 {
    font-family: var(--font-heading);
    color: var(--text-dark);
    line-height: 1.3;
}

a {
    color: var(--primary);
    text-decoration: none;
    transition: color var(--transition);
}

a:hover {
    color: var(--primary-dark);
}

[hidden] {
    display: none !important;
}

button, input, select, textarea {
    font: inherit;
    color: inherit;
}

button {
    cursor: pointer;
}

svg.icon {
    width: 18px;
    height: 18px;
    flex-shrink: 0;
    stroke: currentColor;
    fill: none;
    stroke-width: 2;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.visually-hidden {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

.skip-link {
    position: absolute;
    top: -100px;
    left: 1rem;
    z-index: 3000;
    padding: 0.6rem 1rem;
    background: var(--primary);
    color: var(--white);
    font-weight: 600;
}

.skip-link:focus {
    top: 1rem;
    color: var(--white);
}

:focus-visible {
    outline: 2px solid var(--primary-light);
    outline-offset: 2px;
}

.sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    z-index: 1000;
    display: flex;
    flex-direction: column;
    width: var(--sidebar-width);
    background-color: var(--darker);
    transition: transform 0.35s cubic-bezier(0.4, 0, 0.2, 1);
}

.sidebar-brand {
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: var(--topbar-height);
    padding: 0 1.5rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}

.sidebar-brand img {
    display: block;
    height: 30px;
    width: auto;
    filter: brightness(0) invert(1);
}

.sidebar-close {
    display: none;
    width: 32px;
    height: 32px;
    align-items: center;
    justify-content: center;
    border: none;
    background: none;
    color: rgba(255, 255, 255, 0.5);
}

.sidebar-close:hover {
    color: var(--white);
}

.sidebar-nav {
    flex: 1;
    padding: 1rem 0;
    overflow-y: auto;
}

.sidebar-label {
    padding: 1rem 1.5rem 0.5rem;
    font-family: var(--font-heading);
    font-size: 0.65rem;
    font-weight: 700;
    letter-spacing: 2px;
    text-transform: uppercase;
    color: rgba(255, 255, 255, 0.6);
}

.sidebar-link {
    position: relative;
    display: flex;
    align-items: center;
    gap: 0.8rem;
    padding: 0.7rem 1.5rem;
    font-size: 0.87rem;
    font-weight: 500;
    color: rgba(255, 255, 255, 0.6);
    transition: background-color var(--transition), color var(--transition);
}

.sidebar-link:hover {
    color: rgba(255, 255, 255, 0.95);
    background-color: rgba(255, 255, 255, 0.05);
}

.sidebar-link.active {
    color: var(--white);
    background-color: var(--primary);
}

.sidebar-link.active::before {
    content: '';
    position: absolute;
    inset: 0 auto 0 0;
    width: 3px;
    background-color: var(--white);
}

.sidebar-sublink {
    padding-left: 2.6rem;
    font-size: 0.82rem;
}

.sidebar-link-text {
    min-width: 0;
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
}

.sidebar-footer {
    padding: 1rem 1.5rem 1.25rem;
    border-top: 1px solid rgba(255, 255, 255, 0.06);
    font-size: 0.75rem;
    color: rgba(255, 255, 255, 0.6);
}

.sidebar-footer strong {
    display: block;
    font-family: var(--font-heading);
    font-size: 0.7rem;
    letter-spacing: 1.5px;
    text-transform: uppercase;
    color: rgba(255, 255, 255, 0.75);
}

.sidebar-overlay {
    position: fixed;
    inset: 0;
    z-index: 999;
    display: none;
    background: rgba(14, 27, 53, 0.55);
    backdrop-filter: blur(3px);
}

.sidebar-overlay.active {
    display: block;
}

.topbar {
    position: fixed;
    top: 0;
    right: 0;
    left: var(--sidebar-width);
    z-index: 900;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    height: var(--topbar-height);
    padding: 0 2rem;
    background-color: var(--white);
    border-bottom: 1px solid var(--border);
}

.topbar-left {
    display: flex;
    align-items: center;
    gap: 1rem;
    min-width: 0;
}

.topbar-left > nav {
    flex: 1 1 auto;
    min-width: 0;
}

.topbar-toggle {
    display: none;
    padding: 0.35rem;
    border: none;
    background: none;
    color: var(--text);
}

.topbar-toggle svg.icon {
    width: 22px;
    height: 22px;
}

.breadcrumb {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    min-width: 0;
    font-size: 0.85rem;
    list-style: none;
}

.breadcrumb li {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    min-width: 0;
}

.breadcrumb li + li::before {
    content: '/';
    color: var(--border-strong);
}

.breadcrumb a {
    font-weight: 500;
    color: var(--text-light);
}

.breadcrumb a:hover {
    color: var(--primary);
}

.breadcrumb [aria-current] {
    overflow: hidden;
    font-weight: 600;
    color: var(--text-dark);
    white-space: nowrap;
    text-overflow: ellipsis;
}

.topbar-right {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    font-size: 0.8rem;
    color: var(--text-light);
}

.topbar-chip {
    display: inline-flex;
    align-items: center;
    gap: 0.45rem;
    padding: 0.35rem 0.8rem;
    font-family: var(--font-heading);
    font-size: 0.7rem;
    font-weight: 700;
    letter-spacing: 0.5px;
    text-transform: uppercase;
    color: var(--primary);
    background: var(--primary-soft);
}

.content {
    min-height: 100vh;
    margin-left: var(--sidebar-width);
    padding: calc(var(--topbar-height) + 2rem) 2rem 3rem;
}

.page-header {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-end;
    justify-content: space-between;
    gap: 1.25rem;
    margin-bottom: 1.75rem;
}

fieldset {
    min-width: 0;
    border: 0;
}

.back-link {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    margin-bottom: 0.6rem;
    font-family: var(--font-heading);
    font-size: 0.72rem;
    font-weight: 700;
    letter-spacing: 1px;
    text-transform: uppercase;
    color: var(--text-light);
}

.back-link svg.icon {
    width: 15px;
    height: 15px;
}

.back-link:hover {
    color: var(--primary);
}

.page-title {
    font-size: 1.6rem;
    font-weight: 800;
    word-break: break-word;
}

.page-subtitle {
    margin-top: 0.35rem;
    font-size: 0.9rem;
    color: var(--text-light);
}

.page-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin-top: 0.75rem;
}

.page-actions {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.6rem;
}

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.6rem 1.15rem;
    font-family: var(--font-heading);
    font-size: 0.75rem;
    font-weight: 600;
    line-height: 1.5;
    letter-spacing: 0.5px;
    text-transform: uppercase;
    white-space: nowrap;
    border: 2px solid transparent;
    background: none;
    transition: background-color var(--transition), border-color var(--transition), color var(--transition), box-shadow var(--transition), transform var(--transition);
}

.btn svg.icon {
    width: 16px;
    height: 16px;
}

.btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none;
}

.btn-primary {
    color: var(--white);
    background-color: var(--primary);
    border-color: var(--primary);
}

.btn-primary:hover:not(:disabled) {
    color: var(--white);
    background-color: var(--primary-dark);
    border-color: var(--primary-dark);
    box-shadow: 0 4px 15px rgba(48, 92, 167, 0.3);
    transform: translateY(-1px);
}

.btn-outline {
    color: var(--text-light);
    background-color: var(--white);
    border-color: var(--border);
}

.btn-outline:hover:not(:disabled) {
    color: var(--primary);
    border-color: var(--primary);
}

.btn-danger {
    color: var(--white);
    background-color: var(--danger);
    border-color: var(--danger);
}

.btn-danger:hover:not(:disabled) {
    background-color: #a82828;
    border-color: #a82828;
    box-shadow: 0 4px 15px rgba(197, 48, 48, 0.3);
}

.btn-sm {
    padding: 0.35rem 0.75rem;
    font-size: 0.68rem;
}

.btn-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 34px;
    height: 34px;
    padding: 0;
    color: var(--text-light);
    background: var(--white);
    border: 1.5px solid var(--border);
}

.btn-icon svg.icon {
    width: 15px;
    height: 15px;
}

.btn-icon:hover {
    color: var(--primary);
    border-color: var(--primary);
}

.btn-icon.danger:hover {
    color: var(--danger);
    border-color: var(--danger);
}

.btn.is-loading {
    position: relative;
    color: transparent !important;
    pointer-events: none;
}

.btn.is-loading::after {
    content: '';
    position: absolute;
    width: 16px;
    height: 16px;
    border: 2px solid rgba(255, 255, 255, 0.35);
    border-top-color: var(--white);
    border-radius: 50%;
    animation: spin 0.7s linear infinite;
}

.btn-outline.is-loading::after {
    border-color: var(--border);
    border-top-color: var(--primary);
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

.segmented {
    display: inline-flex;
    background: var(--white);
    border: 1.5px solid var(--border);
}

.segmented a,
.segmented label {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.45rem 0.95rem;
    font-family: var(--font-heading);
    font-size: 0.75rem;
    font-weight: 700;
    letter-spacing: 0.5px;
    color: var(--text-light);
    cursor: pointer;
    transition: background-color var(--transition), color var(--transition);
}

.segmented a + a,
.segmented label + input + label,
.segmented label + label {
    border-left: 1.5px solid var(--border);
}

.segmented a:hover,
.segmented label:hover {
    color: var(--primary);
}

.segmented a.active,
.segmented input:checked + label {
    color: var(--white);
    background: var(--primary);
}

.segmented input {
    position: absolute;
    opacity: 0;
    pointer-events: none;
}

.segmented input:focus-visible + label {
    outline: 2px solid var(--white);
    outline-offset: -4px;
    box-shadow: 0 0 0 2px var(--primary-darker);
}

.segmented.type-toggle {
    display: flex;
}

.segmented.type-toggle label {
    flex: 1;
    justify-content: center;
    padding: 0.65rem 1rem;
    font-size: 0.8rem;
    text-transform: uppercase;
}

.segmented.type-toggle input[value="Income"]:checked + label {
    background: var(--success);
}

.segmented.type-toggle input[value="Expense"]:checked + label {
    background: var(--danger);
}

.summary {
    display: grid;
    gap: 1rem;
    margin-bottom: 1.5rem;
    container: summary / inline-size;
}

.flow-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 1rem;
}

.stat-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 1rem;
}

.stat-grid.is-four {
    grid-template-columns: repeat(4, minmax(0, 1fr));
}

.stat-grid > .stat-card {
    display: grid;
    grid-row: span 3;
    grid-template-rows: subgrid;
    row-gap: 0.35rem;
}

.stat-grid .stat-value {
    font-size: clamp(1rem, 2.6cqi, 1.3rem);
}

.stat-grid.is-four .stat-value {
    font-size: clamp(1rem, 2.1cqi, 1.3rem);
}

@container summary (max-width: 880px) {
    .stat-grid.is-four {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .stat-grid.is-four .stat-value {
        font-size: clamp(1rem, 3.5cqi, 1.3rem);
    }
}

@container summary (max-width: 640px) {
    .flow-grid,
    .stat-grid,
    .stat-grid.is-four {
        grid-template-columns: minmax(0, 1fr);
    }

    .stat-grid .stat-value,
    .stat-grid.is-four .stat-value {
        font-size: clamp(1rem, 5cqi, 1.3rem);
    }
}

.stat-card {
    position: relative;
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
    padding: 1.25rem 1.35rem;
    background: var(--white);
    border: 1px solid var(--border);
    transition: box-shadow var(--transition), transform var(--transition);
}

.stat-card:hover {
    box-shadow: 0 4px 15px var(--shadow);
    transform: translateY(-2px);
}

.stat-card::before {
    content: '';
    position: absolute;
    inset: 0 auto 0 0;
    width: 3px;
    background: var(--primary);
}

.stat-card.tone-income::before {
    background: var(--success);
}

.stat-card.tone-expense::before {
    background: var(--danger);
}

.stat-card.tone-tax::before {
    background: var(--warning);
}

.stat-card.tone-dark {
    background: var(--dark);
    border-color: var(--dark);
}

.stat-card.tone-dark::before {
    background: var(--primary-light);
}

.stat-card.tone-dark .stat-label,
.stat-card.tone-dark .stat-sub {
    color: rgba(255, 255, 255, 0.6);
}

.stat-card.tone-dark .stat-value {
    color: var(--white);
}

.stat-label {
    font-family: var(--font-heading);
    font-size: 0.68rem;
    font-weight: 700;
    letter-spacing: 1px;
    text-transform: uppercase;
    color: var(--text-light);
}

.stat-value {
    font-family: var(--font-heading);
    font-size: clamp(1.05rem, 1.2vw, 1.3rem);
    font-weight: 800;
    line-height: 1.2;
    color: var(--text-dark);
    font-variant-numeric: tabular-nums;
}

.stat-sub {
    font-size: 0.78rem;
    color: var(--text-light);
    font-variant-numeric: tabular-nums;
}

.flow-card {
    container-type: inline-size;
}

.flow-figures {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0.75rem 1.5rem;
    margin-top: 0.2rem;
}

.flow-figure {
    display: flex;
    flex-direction: column;
    gap: 0.2rem;
    min-width: 0;
}

.flow-figure:last-child {
    grid-column: 1 / -1;
    flex-direction: row;
    align-items: baseline;
    justify-content: space-between;
    gap: 0.75rem;
    padding-top: 0.6rem;
    border-top: 1px dashed var(--border);
}

.flow-figure dt {
    font-size: 0.74rem;
    font-weight: 600;
    color: var(--text-light);
}

.flow-figure dd {
    font-family: var(--font-heading);
    font-size: 0.9rem;
    font-weight: 700;
    line-height: 1.2;
    color: var(--text);
    font-variant-numeric: tabular-nums;
}

.flow-figure.is-primary dd {
    font-size: clamp(0.9rem, 5.4cqi, 1.25rem);
    font-weight: 800;
    color: var(--text-dark);
}

.th-note {
    display: block;
    margin-top: 0.15rem;
    font-family: var(--font-body);
    font-size: 0.64rem;
    font-weight: 500;
    letter-spacing: 0;
    text-transform: none;
    color: var(--text-light);
}

.layout-split {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 360px;
    gap: 1.5rem;
    align-items: start;
}

.layout-split.has-lower {
    grid-template-rows: auto 1fr;
}

.layout-split.has-lower > aside {
    grid-column: 2;
    grid-row: 1 / span 2;
}

.layout-split.has-lower > .card:not(:first-child) {
    grid-column: 1;
}

.layout-split > *,
.panel-grid > *,
.stat-grid > *,
.stack > * {
    min-width: 0;
}

.panel-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 1.5rem;
    margin-top: 1.5rem;
    align-items: start;
}

.panel-grid .span-2 {
    grid-column: 1 / -1;
}

.stack {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

.card {
    position: relative;
    background: var(--white);
    border: 1px solid var(--border);
    transition: box-shadow var(--transition);
}

.card:hover {
    box-shadow: 0 4px 15px var(--shadow);
}

.card-header {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    padding: 1.1rem 1.5rem;
    border-bottom: 1px solid var(--border);
}

.card-title {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    font-family: var(--font-heading);
    font-size: 0.85rem;
    font-weight: 700;
    letter-spacing: 0.5px;
    text-transform: uppercase;
    color: var(--text-dark);
}

.card-title svg.icon {
    color: var(--primary);
}

.card-hint {
    font-size: 0.78rem;
    color: var(--text-light);
}

.card-actions {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.6rem;
}

.card-body {
    padding: 1.35rem 1.5rem;
}

.card-body.flush {
    padding: 0;
}

.card-note {
    padding: 0.85rem 1.5rem;
    font-size: 0.78rem;
    line-height: 1.55;
    color: var(--text-light);
    background: var(--lighter);
    border-top: 1px solid var(--border);
}

.badge {
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
    padding: 0.22rem 0.6rem;
    font-family: var(--font-heading);
    font-size: 0.64rem;
    font-weight: 700;
    letter-spacing: 0.5px;
    line-height: 1.4;
    text-transform: uppercase;
    white-space: nowrap;
    color: var(--primary);
    background: var(--primary-soft);
}

.badge-income {
    color: #27692a;
    background: var(--success-soft);
}

.badge-expense {
    color: var(--danger);
    background: var(--danger-soft);
}

.badge-warning {
    color: #9a4508;
    background: var(--warning-soft);
}

.badge-muted {
    color: var(--text-light);
    background: rgba(107, 114, 128, 0.1);
}

.badge-dark {
    color: var(--white);
    background: var(--dark);
}

.table-wrapper {
    position: relative;
    overflow-x: auto;
}

.table {
    width: 100%;
    border-collapse: collapse;
    font-variant-numeric: tabular-nums;
}

.table th {
    padding: 0.8rem 1rem;
    font-family: var(--font-heading);
    font-size: 0.66rem;
    font-weight: 700;
    letter-spacing: 0.5px;
    text-align: left;
    text-transform: uppercase;
    white-space: nowrap;
    color: var(--text-light);
    background-color: var(--lighter);
    border-bottom: 2px solid var(--border);
}

.table td {
    padding: 0.85rem 1rem;
    font-size: 0.85rem;
    vertical-align: middle;
    border-bottom: 1px solid var(--border);
}

.table tbody tr {
    transition: background-color var(--transition);
}

.table tbody tr:hover {
    background-color: var(--lighter);
}

.table tbody tr:last-child td {
    border-bottom: none;
}

.table tfoot td {
    font-weight: 700;
    color: var(--text-dark);
    background: var(--lighter);
    border-top: 2px solid var(--border);
}

.table .num {
    text-align: right;
    white-space: nowrap;
}

.table .actions {
    width: 1%;
    white-space: nowrap;
}

.table .row-actions {
    display: flex;
    justify-content: flex-end;
    gap: 0.4rem;
}

.table tr.is-highlighted td {
    background: var(--primary-soft);
}

.table tr.is-highlighted td:first-child {
    box-shadow: inset 3px 0 0 var(--primary);
}

.cell-title {
    font-weight: 600;
    color: var(--text-dark);
}

.table .col-name {
    min-width: 220px;
}

a.cell-title:hover {
    color: var(--primary);
}

.cell-sub {
    margin-top: 0.1rem;
    font-size: 0.75rem;
    color: var(--text-light);
}

.cell-badges {
    display: flex;
    flex-wrap: wrap;
    gap: 0.3rem;
}

.amount-positive {
    color: var(--success);
}

.amount-negative {
    color: var(--danger);
}

.amount-muted {
    color: var(--text-light);
}

.filter-tabs {
    display: inline-flex;
    gap: 0.25rem;
}

.filter-tabs button {
    padding: 0.35rem 0.8rem;
    font-family: var(--font-heading);
    font-size: 0.7rem;
    font-weight: 700;
    letter-spacing: 0.5px;
    text-transform: uppercase;
    color: var(--text-light);
    background: none;
    border: 1.5px solid transparent;
}

.filter-tabs button:hover {
    color: var(--primary);
}

.filter-tabs button[aria-pressed="true"] {
    color: var(--primary);
    border-color: var(--primary);
    background: var(--primary-soft);
}

.attachment-link {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 34px;
    height: 34px;
    color: var(--primary);
    background: var(--primary-soft);
    border: none;
}

.attachment-link:hover {
    color: var(--white);
    background: var(--primary);
}

.empty-state {
    padding: 3.5rem 1.5rem;
    text-align: center;
}

.empty-state-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 64px;
    height: 64px;
    margin-bottom: 1rem;
    color: var(--primary);
    background: var(--primary-soft);
}

.empty-state-icon svg.icon {
    width: 28px;
    height: 28px;
}

.empty-state h3 {
    margin-bottom: 0.35rem;
    font-size: 1rem;
}

.empty-state p {
    max-width: 420px;
    margin: 0 auto 1.25rem;
    font-size: 0.87rem;
    color: var(--text-light);
}

.summary-list {
    list-style: none;
}

.summary-row {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 1rem;
    padding: 0.6rem 0;
    font-size: 0.86rem;
    border-bottom: 1px dashed var(--border);
}

.summary-row:last-child {
    border-bottom: none;
}

.summary-row dt,
.summary-row .label {
    color: var(--text);
}

.summary-row dd,
.summary-row .value {
    font-family: var(--font-heading);
    font-weight: 600;
    color: var(--text-dark);
    text-align: right;
    white-space: nowrap;
    font-variant-numeric: tabular-nums;
}

.summary-row .hint {
    display: block;
    font-size: 0.72rem;
    color: var(--text-light);
}

.summary-row.is-sub dt {
    padding-left: 1rem;
    color: var(--text-light);
}

.summary-row.is-total {
    margin-top: 0.35rem;
    padding: 0.8rem 0.9rem;
    background: var(--lighter);
    border: 1px solid var(--border);
}

.summary-row.is-total dt {
    font-family: var(--font-heading);
    font-size: 0.78rem;
    font-weight: 700;
    letter-spacing: 0.5px;
    text-transform: uppercase;
    color: var(--text-dark);
}

.summary-row.is-total dd {
    font-size: 1rem;
    font-weight: 800;
}

.summary-row.is-accent {
    background: var(--dark);
    border-color: var(--dark);
}

.summary-row.is-accent dt,
.summary-row.is-accent dd {
    color: var(--white);
}

.section-divider {
    margin: 1.25rem 0 0.5rem;
    padding-bottom: 0.4rem;
    font-family: var(--font-heading);
    font-size: 0.7rem;
    font-weight: 700;
    letter-spacing: 1px;
    text-transform: uppercase;
    color: var(--text-light);
    border-bottom: 1px solid var(--border);
}

.section-divider:first-child {
    margin-top: 0;
}

.taxpayer-block + .taxpayer-block {
    margin-top: 1.25rem;
    padding-top: 1.25rem;
    border-top: 1px solid var(--border);
}

.taxpayer-block-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
    margin-bottom: 0.5rem;
}

.taxpayer-block-head h3 {
    font-size: 0.9rem;
    font-weight: 700;
}

.provisional-block + .provisional-block {
    border-top: 1px solid var(--border);
}

.provisional-head {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
    padding: 1rem 1.5rem 0.75rem;
}

.provisional-head h3 {
    font-size: 0.9rem;
    font-weight: 700;
}

.provisional-table tfoot th,
.provisional-table tfoot td {
    background: var(--lighter);
    border-top: 1px solid var(--border);
}

.provisional-table tfoot th {
    font-weight: 600;
    text-align: right;
    color: var(--text);
}

.provisional-table tfoot tr:first-child th,
.provisional-table tfoot tr:first-child td {
    border-top: 2px solid var(--border);
}

.provisional-table tfoot tr.is-total th,
.provisional-table tfoot tr.is-total td {
    font-weight: 700;
    color: var(--text-dark);
}

.card-empty-text {
    padding: 1.25rem 1.5rem;
    color: var(--text-light);
}

.progress {
    display: block;
    width: 100%;
    height: 6px;
    margin: 0.6rem 0 0.35rem;
    border: none;
    background: var(--light);
    appearance: none;
}

.progress::-webkit-progress-bar {
    background: var(--light);
}

.progress::-webkit-progress-value {
    background: linear-gradient(90deg, var(--primary), var(--primary-light));
}

.progress::-moz-progress-bar {
    background: linear-gradient(90deg, var(--primary), var(--primary-light));
}

.progress-caption {
    display: flex;
    justify-content: space-between;
    gap: 0.5rem;
    font-size: 0.72rem;
    color: var(--text-light);
}

.bracket-table td,
.bracket-table th {
    padding: 0.55rem 0.75rem;
}

.bracket-table tr.is-current td {
    font-weight: 700;
    color: var(--primary);
    background: var(--primary-soft);
}

.alert {
    display: flex;
    align-items: flex-start;
    gap: 0.7rem;
    padding: 0.85rem 1.1rem;
    font-size: 0.83rem;
    line-height: 1.55;
    border: 1px solid;
}

.alert svg.icon {
    margin-top: 2px;
}

.alert-info {
    color: var(--primary-darker);
    background: #eff6ff;
    border-color: #bfdbfe;
}

.alert-warning {
    color: #92400e;
    background: #fffbeb;
    border-color: #fde68a;
}

.alert-success {
    color: #1f5f23;
    background: #f0fdf4;
    border-color: #bbf7d0;
}

.page-alert {
    margin-bottom: 1.5rem;
}

.alert-danger {
    color: var(--danger);
    background: #fef2f2;
    border-color: #fecaca;
}

dialog.modal {
    position: fixed;
    inset: 0;
    width: min(480px, calc(100vw - 2rem));
    max-width: none;
    max-height: calc(100dvh - 3rem);
    margin: auto;
    padding: 0;
    overflow: hidden;
    color: var(--text);
    background: var(--white);
    border: 1px solid var(--border);
    box-shadow: 0 24px 64px -18px rgba(14, 27, 53, 0.45), 0 2px 8px rgba(14, 27, 53, 0.08);
}

dialog.modal[open] {
    display: flex;
    flex-direction: column;
    animation: dialogFade 0.2s ease;
}

dialog.modal[open] > .modal-form {
    animation: dialogRise 0.28s cubic-bezier(0.22, 1, 0.36, 1);
}

dialog.modal::backdrop {
    background: rgba(14, 27, 53, 0.58);
    backdrop-filter: blur(3px);
    animation: dialogFade 0.2s ease;
}

dialog.modal.modal-lg {
    width: min(780px, calc(100vw - 2rem));
}

dialog.modal.modal-xl {
    width: min(980px, calc(100vw - 2rem));
}

dialog.modal.modal-ask {
    width: min(440px, calc(100vw - 2rem));
}

.modal-ask .modal-header {
    border-bottom: none;
    padding-bottom: 0.25rem;
}

.modal-ask .modal-body {
    padding-top: 0.5rem;
}

.modal-ask .modal-body p {
    color: var(--text);
    line-height: 1.6;
}

.modal-form {
    display: flex;
    flex: 1 1 auto;
    flex-direction: column;
    min-height: 0;
}

@keyframes dialogFade {
    from {
        opacity: 0;
    }

    to {
        opacity: 1;
    }
}

@keyframes dialogRise {
    from {
        opacity: 0;
        transform: translateY(14px) scale(0.985);
    }

    to {
        opacity: 1;
        transform: none;
    }
}

.modal-header {
    flex: none;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    padding: 1.1rem 1.5rem;
    border-bottom: 1px solid var(--border);
}

.modal-title {
    min-width: 0;
    font-size: 1rem;
    font-weight: 700;
    overflow-wrap: anywhere;
}

.modal-actions {
    display: flex;
    flex-shrink: 0;
    align-items: center;
    gap: 0.6rem;
}

.modal-close {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    color: var(--text-light);
    background: none;
    border: none;
}

.modal-close:hover {
    color: var(--text-dark);
}

.modal-body {
    flex: 1 1 auto;
    min-height: 0;
    padding: 1.5rem;
    overflow-y: auto;
    overscroll-behavior: contain;
}

.modal-body p {
    font-size: 0.9rem;
}

.modal-footer {
    flex: none;
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 0.6rem;
    padding: 1rem 1.5rem;
    background: var(--lighter);
    border-top: 1px solid var(--border);
}

.modal-preview img {
    display: block;
    max-width: 100%;
    max-height: 75vh;
    margin: 0 auto;
}

.form-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 1.1rem 1.25rem;
}

.form-grid .span-2 {
    grid-column: 1 / -1;
}

.form-group {
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.form-label {
    display: block;
    margin-bottom: 0.45rem;
    font-family: var(--font-heading);
    font-size: 0.72rem;
    font-weight: 700;
    letter-spacing: 0.5px;
    text-transform: uppercase;
    color: var(--text-dark);
}

.form-label .optional {
    font-weight: 500;
    letter-spacing: 0;
    text-transform: none;
    color: var(--text-light);
}

.form-control {
    width: 100%;
    padding: 0.68rem 0.9rem;
    font-size: 0.9rem;
    color: var(--text-dark);
    background-color: var(--white);
    border: 1.5px solid var(--border);
    border-radius: 0;
    outline: none;
    transition: border-color var(--transition), box-shadow var(--transition), background-color var(--transition);
    appearance: none;
}

select.form-control {
    padding-right: 2.2rem;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%236b7280' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 0.75rem center;
    background-size: 16px;
}

.form-control:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(48, 92, 167, 0.12);
}

.form-control:disabled,
.form-control[readonly] {
    color: var(--text-light);
    background-color: var(--lighter);
}

.form-control:disabled {
    cursor: not-allowed;
}

.form-control.is-invalid {
    border-color: var(--danger);
}

.form-control::placeholder {
    color: #adb5bd;
}

.input-affix {
    position: relative;
}

.input-affix .form-control {
    padding-right: 2.2rem;
}

.input-affix .affix {
    position: absolute;
    top: 50%;
    right: 0.9rem;
    font-weight: 600;
    color: var(--text-light);
    transform: translateY(-50%);
    pointer-events: none;
}

.form-hint {
    margin-top: 0.3rem;
    font-size: 0.74rem;
    color: var(--text-light);
}

.form-error {
    margin-top: 0.3rem;
    font-size: 0.76rem;
    font-weight: 600;
    color: var(--danger);
}

.form-error:empty {
    display: none;
}

.form-alert:empty {
    display: none;
}

.form-alert {
    margin-bottom: 1rem;
}

.form-section {
    grid-column: 1 / -1;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin-top: 0.35rem;
    font-family: var(--font-heading);
    font-size: 0.7rem;
    font-weight: 700;
    letter-spacing: 1px;
    text-transform: uppercase;
    color: var(--text-light);
}

.form-section::after {
    content: '';
    flex: 1;
    height: 1px;
    background: var(--border);
}

.switch {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    min-height: 44px;
    padding: 0.55rem 0.9rem;
    background: var(--lighter);
    border: 1.5px solid var(--border);
    cursor: pointer;
    user-select: none;
    transition: border-color var(--transition), background-color var(--transition);
}

.switch:hover {
    border-color: var(--border-strong);
}

.switch input {
    position: absolute;
    opacity: 0;
    pointer-events: none;
}

.switch-track {
    position: relative;
    flex-shrink: 0;
    width: 38px;
    height: 20px;
    background: var(--border-strong);
    transition: background-color var(--transition);
}

.switch-track::after {
    content: '';
    position: absolute;
    top: 3px;
    left: 3px;
    width: 14px;
    height: 14px;
    background: var(--white);
    transition: transform var(--transition);
}

.switch input:checked + .switch-track {
    background: var(--primary);
}

.switch input:checked + .switch-track::after {
    transform: translateX(18px);
}

.switch input:focus-visible + .switch-track {
    outline: 2px solid var(--primary-light);
    outline-offset: 2px;
}

.switch input:disabled + .switch-track {
    opacity: 0.45;
}

.switch-text {
    display: flex;
    flex-direction: column;
    font-size: 0.85rem;
    font-weight: 600;
    line-height: 1.35;
    color: var(--text-dark);
}

.switch-text small {
    font-size: 0.72rem;
    font-weight: 400;
    color: var(--text-light);
}

.switch.is-disabled {
    cursor: not-allowed;
    opacity: 0.7;
}

.calc-preview {
    grid-column: 1 / -1;
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    background: var(--dark);
}

.calc-preview-item {
    padding: 0.85rem 1rem;
    border-right: 1px solid rgba(255, 255, 255, 0.08);
}

.calc-preview-item:last-child {
    border-right: none;
}

.calc-preview-label {
    font-family: var(--font-heading);
    font-size: 0.6rem;
    font-weight: 700;
    letter-spacing: 1px;
    text-transform: uppercase;
    color: rgba(255, 255, 255, 0.5);
}

.calc-preview-value {
    margin-top: 0.2rem;
    font-family: var(--font-heading);
    font-size: 0.95rem;
    font-weight: 700;
    color: var(--white);
    font-variant-numeric: tabular-nums;
    word-break: break-word;
}

.calc-note {
    grid-column: 1 / -1;
}

.calc-note:empty {
    display: none;
}

.dropzone {
    position: relative;
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 1rem 1.1rem;
    background: var(--lighter);
    border: 1.5px dashed var(--border-strong);
    cursor: pointer;
    transition: border-color var(--transition), background-color var(--transition);
}

.dropzone:hover,
.dropzone.is-dragover {
    background: var(--primary-soft);
    border-color: var(--primary);
}

.dropzone:has(input:focus-visible) {
    background: var(--primary-soft);
    border-color: var(--primary);
    outline: 2px solid var(--primary-light);
    outline-offset: 2px;
}

.dropzone input[type="file"] {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    opacity: 0;
    cursor: pointer;
}

.dropzone-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    width: 44px;
    height: 44px;
    color: var(--primary);
    background: var(--white);
    border: 1px solid var(--border);
}

.dropzone-text {
    min-width: 0;
    font-size: 0.83rem;
}

.dropzone-text strong {
    display: block;
    overflow: hidden;
    color: var(--text-dark);
    white-space: nowrap;
    text-overflow: ellipsis;
}

.dropzone-text span {
    font-size: 0.75rem;
    color: var(--text-light);
}

.dropzone-thumb {
    display: none;
    width: 44px;
    height: 44px;
    flex-shrink: 0;
    object-fit: cover;
    border: 1px solid var(--border);
}

.dropzone-thumb.visible {
    display: block;
}

.current-attachment {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    margin-top: 0.6rem;
    padding: 0.6rem 0.8rem;
    font-size: 0.8rem;
    background: var(--white);
    border: 1px solid var(--border);
}

.current-attachment label {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    color: var(--danger);
    cursor: pointer;
}

.toast-stack {
    position: fixed;
    right: 1.5rem;
    bottom: 1.5rem;
    z-index: 3000;
    display: flex;
    flex-direction: column;
    gap: 0.6rem;
    width: min(400px, calc(100vw - 2rem));
    pointer-events: none;
}

.toast-stack.is-top {
    top: 1rem;
    bottom: auto;
}

.toast {
    position: relative;
    display: flex;
    align-items: flex-start;
    gap: 0.75rem;
    padding: 0.9rem 0.8rem 1rem 1rem;
    overflow: hidden;
    color: var(--text-dark);
    background: var(--white);
    border: 1px solid var(--border);
    border-left: 3px solid var(--primary);
    box-shadow: 0 18px 44px -16px rgba(14, 27, 53, 0.35), 0 2px 8px rgba(14, 27, 53, 0.06);
    pointer-events: auto;
    opacity: 0;
    transform: translateY(14px) scale(0.98);
    transition: opacity 0.3s ease, transform 0.3s cubic-bezier(0.22, 1, 0.36, 1);
}

.toast.is-in {
    opacity: 1;
    transform: none;
}

.toast.is-out {
    opacity: 0;
    transform: translateX(24px);
}

.toast.is-bump {
    animation: toastBump 0.34s cubic-bezier(0.22, 1, 0.36, 1);
}

@keyframes toastBump {
    38% {
        transform: translateX(-4px) scale(1.015);
    }
}

.toast-success {
    border-left-color: var(--success);
}

.toast-error {
    border-left-color: var(--danger);
}

.toast-mark {
    display: inline-flex;
    flex: none;
    margin-top: 1px;
}

.toast-success .toast-mark {
    color: var(--success);
}

.toast-error .toast-mark {
    color: var(--danger);
}

.toast-body {
    flex: 1 1 auto;
    min-width: 0;
}

.toast-head {
    display: flex;
    align-items: center;
    gap: 0.45rem;
}

.toast-title {
    font-family: var(--font-heading);
    font-size: 0.86rem;
    font-weight: 700;
    line-height: 1.35;
}

.toast-count {
    flex: none;
    padding: 0.05rem 0.45rem;
    font-family: var(--font-heading);
    font-size: 0.65rem;
    font-weight: 700;
    color: var(--text-light);
    background: var(--lighter);
    border: 1px solid var(--border);
}

.toast-message {
    margin-top: 0.2rem;
    font-size: 0.82rem;
    line-height: 1.5;
    color: var(--text);
    overflow-wrap: anywhere;
}

.toast-list {
    display: grid;
    gap: 0.25rem;
    margin-top: 0.5rem;
    padding: 0.5rem 0.65rem;
    list-style: none;
    background: var(--lighter);
    border: 1px solid var(--border);
}

.toast-list li {
    position: relative;
    padding-left: 0.8rem;
    font-size: 0.78rem;
    line-height: 1.45;
    overflow-wrap: anywhere;
}

.toast-list li::before {
    content: '';
    position: absolute;
    top: 0.55em;
    left: 0;
    width: 5px;
    height: 5px;
    background: var(--primary-light);
}

.toast-list .toast-more {
    color: var(--text-light);
}

.toast-meta {
    display: flex;
    justify-content: space-between;
    gap: 0.6rem;
    margin-top: 0.45rem;
    font-size: 0.7rem;
    color: var(--text-light);
}

.toast-meta span:first-child {
    min-width: 0;
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
}

.toast-time {
    flex: none;
    font-variant-numeric: tabular-nums;
}

.toast-action {
    margin-top: 0.5rem;
    padding: 0.3rem 0.7rem;
    font-family: var(--font-heading);
    font-size: 0.7rem;
    font-weight: 700;
    letter-spacing: 0.4px;
    text-transform: uppercase;
    color: var(--primary);
    background: var(--primary-soft);
    border: 1px solid rgba(48, 92, 167, 0.3);
}

.toast-action:hover {
    color: var(--white);
    background: var(--primary);
}

.toast-close {
    display: inline-flex;
    flex: none;
    align-items: center;
    justify-content: center;
    width: 26px;
    height: 26px;
    color: var(--text-light);
    background: transparent;
    border: none;
}

.toast-close svg.icon {
    width: 14px;
    height: 14px;
}

.toast-close:hover {
    color: var(--text-dark);
    background: var(--lighter);
}

.toast-timer {
    position: absolute;
    right: 0;
    bottom: 0;
    left: 0;
    height: 2px;
    background: currentColor;
    opacity: 0.5;
    transform-origin: left center;
}

.toast-success .toast-timer {
    background: var(--success);
}

.toast-error .toast-timer {
    background: var(--danger);
}

.page-progress {
    position: fixed;
    top: 0;
    right: 0;
    left: 0;
    z-index: 3500;
    height: 3px;
    background: linear-gradient(90deg, var(--primary), var(--primary-light), var(--primary));
    background-size: 200% 100%;
    opacity: 0;
    transform: scaleX(0);
    transform-origin: left center;
    transition: opacity 0.2s ease, transform 0.4s ease;
    pointer-events: none;
}

html.is-loading .page-progress {
    opacity: 1;
    transform: scaleX(0.85);
    transition: transform 6s cubic-bezier(0.1, 0.8, 0.2, 1), opacity 0.2s ease;
    animation: progressShine 1.2s linear infinite;
}

@keyframes progressShine {
    to {
        background-position: -200% 0;
    }
}

.content.is-swapping {
    opacity: 0.6;
    transition: opacity 0.15s ease;
}

.content.is-locked {
    pointer-events: none;
}

.content:focus,
.page-title:focus {
    outline: none;
}

.table tbody tr.is-flash td {
    animation: rowFlash 2.6s ease;
}

@keyframes rowFlash {
    0%,
    30% {
        background-color: rgba(48, 92, 167, 0.16);
    }

    100% {
        background-color: transparent;
    }
}

.btn-danger-outline:hover:not(:disabled) {
    color: var(--danger);
    border-color: var(--danger);
}

.error-page {
    max-width: 520px;
    margin: 8vh auto 0;
    padding: 3rem 2rem;
    text-align: center;
    background: var(--white);
    border: 1px solid var(--border);
}

.error-code {
    font-family: var(--font-heading);
    font-size: 4rem;
    font-weight: 800;
    line-height: 1;
    color: var(--primary);
}

.error-page h1 {
    margin: 1rem 0 0.5rem;
    font-size: 1.3rem;
}

.error-page p {
    margin-bottom: 1.5rem;
    color: var(--text-light);
}

.error-page small {
    display: block;
    margin-top: 1.5rem;
    font-size: 0.72rem;
    color: var(--text-light);
    word-break: break-all;
}

.text-muted {
    color: var(--text-light);
}

.nowrap {
    white-space: nowrap;
}

@media (max-width: 1600px) {
    .layout-split {
        grid-template-columns: minmax(0, 1fr);
    }

    .layout-split.has-lower {
        grid-template-rows: none;
    }

    .layout-split.has-lower > aside,
    .layout-split.has-lower > .card:not(:first-child) {
        grid-column: auto;
        grid-row: auto;
    }

    .layout-split > .stack {
        display: grid;
        grid-template-columns: repeat(2, minmax(0, 1fr));
        align-items: start;
    }
}

@media (max-width: 900px) {
    .layout-split > .stack {
        grid-template-columns: minmax(0, 1fr);
    }
}

@media (max-width: 1100px) {
    .panel-grid {
        grid-template-columns: minmax(0, 1fr);
    }
}

.card-link {
    font-family: var(--font-heading);
    font-size: 0.7rem;
    font-weight: 700;
    letter-spacing: 0.5px;
    text-transform: uppercase;
}

.btn-icon:disabled {
    opacity: 0.45;
    cursor: not-allowed;
}

.btn-icon:disabled:hover {
    color: var(--text-light);
    border-color: var(--border);
}

.settings-alert {
    align-items: center;
}

.settings-alert > span {
    flex: 1 1 auto;
}

.settings-alert .btn {
    flex: none;
}

.settings-years {
    display: grid;
    gap: 1.25rem;
    margin-bottom: 1.5rem;
}

.year-card-title {
    font-size: 1rem;
    letter-spacing: 0.3px;
}

.year-card .row-actions {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.5rem;
}

.year-card-body {
    display: grid;
    grid-template-columns: minmax(0, 1.35fr) minmax(0, 1fr);
}

.year-card-section {
    min-width: 0;
    padding: 1.25rem 1.5rem;
}

.year-card-section + .year-card-section {
    border-left: 1px solid var(--border);
}

.year-card-heading {
    margin-bottom: 0.6rem;
    font-size: 0.7rem;
    font-weight: 700;
    letter-spacing: 1px;
    text-transform: uppercase;
    color: var(--text-light);
}

.year-card-heading:not(:first-child) {
    margin-top: 1.25rem;
}

.year-card-section .bracket-table th,
.year-card-section .bracket-table td {
    padding-left: 0;
}

.rate-chips {
    display: flex;
    flex-wrap: wrap;
    justify-content: flex-end;
    gap: 0.35rem;
}

.rate-chip {
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
    padding: 0.15rem 0.55rem;
    font-size: 0.78rem;
    font-weight: 600;
    color: var(--dark);
    background: var(--light);
    border: 1px solid var(--border);
}

.rate-chip.is-default {
    color: var(--white);
    background: var(--primary);
    border-color: var(--primary);
}

.rate-chip-remove {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 18px;
    height: 18px;
    font-size: 1rem;
    line-height: 1;
    color: var(--text-light);
    background: none;
    border: none;
    cursor: pointer;
}

.rate-chip-remove:hover,
.rate-chip-remove:focus-visible {
    color: var(--danger);
}

.rate-editor {
    display: flex;
    flex-direction: column;
    gap: 0.6rem;
}

.rate-editor .rate-chips {
    justify-content: flex-start;
    min-height: 1.75rem;
}

.rate-editor-entry {
    display: flex;
    gap: 0.5rem;
}

.rate-editor-entry .input-affix {
    flex: 1 1 auto;
}

.check-grid {
    display: grid;
    grid-template-columns: repeat(5, minmax(0, 1fr));
    gap: 0.5rem;
}

.check-pill {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 0.7rem;
    font-size: 0.8rem;
    background: var(--white);
    border: 1.5px solid var(--border);
    cursor: pointer;
    transition: border-color var(--transition), background-color var(--transition);
}

.check-pill:has(input:checked) {
    color: var(--dark);
    background: var(--primary-soft);
    border-color: var(--primary);
}

.check-pill:has(input:focus-visible) {
    box-shadow: 0 0 0 3px rgba(48, 92, 167, 0.18);
}

.check-pill input {
    accent-color: var(--primary);
}

.bracket-editor {
    display: flex;
    flex-direction: column;
    gap: 0.6rem;
}

.bracket-rows {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.bracket-row {
    display: grid;
    grid-template-columns: 2rem minmax(0, 1fr) minmax(0, 1.3fr) minmax(0, 0.8fr) minmax(0, 1fr) 34px;
    grid-template-areas: "index lower upper rate base remove";
    align-items: start;
    gap: 0.6rem;
}

.bracket-head {
    font-family: var(--font-heading);
    font-size: 0.64rem;
    font-weight: 700;
    letter-spacing: 0.5px;
    text-transform: uppercase;
    color: var(--text-light);
}

.bracket-index {
    grid-area: index;
}

.bracket-lower {
    grid-area: lower;
}

.bracket-upper-field {
    grid-area: upper;
}

.bracket-rate-field {
    grid-area: rate;
}

.bracket-base {
    grid-area: base;
}

.bracket-remove {
    grid-area: remove;
    margin-top: 4px;
}

.bracket-index,
.bracket-lower,
.bracket-base {
    padding-top: 0.7rem;
    font-size: 0.85rem;
    font-variant-numeric: tabular-nums;
}

.bracket-head > span {
    padding-top: 0;
}

.bracket-index {
    font-weight: 700;
    color: var(--dark);
}

.bracket-lower,
.bracket-base {
    color: var(--text-light);
}

.bracket-field {
    min-width: 0;
}

.bracket-editor-foot {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.75rem;
}

.bracket-editor-foot .form-hint {
    margin-top: 0;
}

.source-note {
    padding: 0.6rem 0.8rem;
    font-size: 0.8rem;
    line-height: 1.5;
    color: #9a4508;
    background: var(--warning-soft);
}

.general-settings-actions {
    align-self: start;
    align-items: flex-start;
    padding-top: 1.6rem;
}

.card.is-flash {
    animation: cardFlash 2.6s ease;
}

@keyframes cardFlash {
    0%,
    30% {
        box-shadow: 0 0 0 3px rgba(48, 92, 167, 0.35);
    }

    100% {
        box-shadow: 0 0 0 3px rgba(48, 92, 167, 0);
    }
}

.topbar-user {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    padding-left: 0.9rem;
    border-left: 1px solid var(--border);
}

.topbar-user-avatar {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 34px;
    height: 34px;
    color: var(--primary);
    background: var(--primary-soft);
}

.topbar-user-text {
    display: flex;
    flex-direction: column;
    min-width: 0;
    max-width: 200px;
    line-height: 1.25;
}

.topbar-user-name {
    overflow: hidden;
    font-weight: 700;
    color: var(--text-dark);
    white-space: nowrap;
    text-overflow: ellipsis;
}

.topbar-user-email {
    overflow: hidden;
    font-size: 0.72rem;
    white-space: nowrap;
    text-overflow: ellipsis;
}

.topbar-logout {
    display: inline-flex;
}

.password-field .form-control {
    padding-right: 2.9rem;
}

.password-toggle {
    position: absolute;
    top: 50%;
    right: 0.35rem;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 34px;
    height: 34px;
    color: var(--text-light);
    background: none;
    border: none;
    transform: translateY(-50%);
    cursor: pointer;
}

.password-toggle:hover,
.password-toggle:focus-visible {
    color: var(--primary);
}

.password-rules {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0.3rem 1rem;
    margin-top: 0.6rem;
    padding: 0;
    list-style: none;
}

.password-rules li {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    font-size: 0.76rem;
    color: var(--text-light);
    transition: color var(--transition);
}

.password-rules li svg.icon {
    flex: none;
    width: 14px;
    height: 14px;
    opacity: 0.35;
    transition: opacity var(--transition);
}

.password-rules li.is-met {
    color: var(--success);
}

.password-rules li.is-met svg.icon {
    opacity: 1;
}

.password-rules.is-dirty li:not(.is-met) {
    color: var(--danger);
}

.password-match {
    display: block;
    margin-top: 0.3rem;
    font-size: 0.76rem;
    font-weight: 600;
    color: var(--danger);
}

.password-match.is-met {
    color: var(--success);
}

.check-row {
    display: inline-flex;
    align-items: center;
    gap: 0.55rem;
    font-size: 0.85rem;
    color: var(--text);
    cursor: pointer;
}

.check-row input {
    width: 16px;
    height: 16px;
    accent-color: var(--primary);
}

.check-row.compact {
    margin-top: 0.5rem;
    font-size: 0.78rem;
}

.auth-options {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem 1rem;
}

.auth-options-link {
    font-size: 0.85rem;
    font-weight: 600;
    line-height: 1.6;
}

.form-grid.single {
    grid-template-columns: minmax(0, 1fr);
}

.form-actions {
    display: flex;
    flex-wrap: wrap;
    justify-content: flex-end;
    gap: 0.6rem;
}

.modal-intro {
    margin-bottom: 1rem;
    color: var(--text);
}

.modal-form[hidden] {
    display: none;
}

.modal-heading {
    min-width: 0;
}

.modal-step {
    margin-top: 0.15rem;
    font-size: 0.75rem;
    font-weight: 600;
    letter-spacing: 0.02em;
    color: var(--text-light);
}

.password-target {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.8rem 1rem;
    background: var(--lighter);
    border: 1px solid var(--border);
    border-left: 3px solid var(--primary);
}

.password-target-icon {
    display: inline-flex;
    flex: none;
    align-items: center;
    justify-content: center;
    width: 34px;
    height: 34px;
    color: var(--primary);
    background: var(--primary-soft);
}

.password-target-text {
    display: flex;
    flex-direction: column;
    min-width: 0;
    font-size: 0.85rem;
    line-height: 1.4;
    overflow-wrap: anywhere;
}

.password-target-text strong {
    color: var(--text-dark);
}

.link-button {
    margin-top: 0.75rem;
    padding: 0;
    font: inherit;
    font-size: 0.82rem;
    font-weight: 600;
    color: var(--primary);
    background: none;
    border: none;
    cursor: pointer;
}

.link-button:hover {
    text-decoration: underline;
}

.link-button:disabled {
    color: var(--text-light);
    cursor: progress;
    text-decoration: none;
}

.card-body-alert {
    padding-bottom: 0;
}

.email-port-row {
    display: grid;
    grid-template-columns: minmax(0, 0.8fr) minmax(0, 1.2fr);
    gap: 1rem;
}

.btn-block {
    width: 100%;
}

.validation-summary-valid {
    display: none;
}

.validation-summary-errors ul {
    margin: 0;
    padding: 0;
    list-style: none;
}

.auth-body {
    background: var(--light);
}

.auth-shell {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 0.9fr);
    min-height: 100vh;
}

.auth-main {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 1.25rem;
    padding: 3rem 1.5rem;
}

.auth-card {
    width: min(100%, 440px);
    padding: 2.5rem 2.25rem;
    background: var(--white);
    border: 1px solid var(--border);
    border-top: 3px solid var(--primary);
    box-shadow: 0 18px 50px -24px rgba(14, 27, 53, 0.35);
}

.auth-brand {
    display: inline-block;
    margin-bottom: 1.75rem;
}

.auth-brand img {
    display: block;
    width: 170px;
    height: auto;
}

.auth-heading {
    margin-bottom: 1.5rem;
}

.auth-heading h1 {
    margin-bottom: 0.4rem;
    font-size: 1.45rem;
    font-weight: 800;
}

.auth-heading p {
    font-size: 0.88rem;
    color: var(--text-light);
}

.auth-heading strong {
    color: var(--text-dark);
    word-break: break-all;
}

.auth-alert {
    margin-bottom: 1.25rem;
}

.auth-form {
    display: flex;
    flex-direction: column;
    gap: 1.1rem;
}

.auth-form .btn-block {
    margin-top: 0.4rem;
    padding-top: 0.8rem;
    padding-bottom: 0.8rem;
}

.auth-switch {
    margin-top: 1.5rem;
    font-size: 0.85rem;
    text-align: center;
    color: var(--text-light);
}

.auth-footnote {
    font-size: 0.75rem;
    color: var(--text-light);
}

.code-input {
    font-family: var(--font-heading);
    font-size: 1.6rem;
    font-weight: 800;
    letter-spacing: 0.6em;
    text-align: center;
    font-variant-numeric: tabular-nums;
}

.auth-aside {
    position: relative;
    display: flex;
    align-items: center;
    padding: 3rem 3.5rem;
    overflow: hidden;
    color: var(--white);
    background:
        linear-gradient(160deg, rgba(48, 92, 167, 0.35), transparent 55%),
        var(--darker);
}

.auth-aside::after {
    content: '';
    position: absolute;
    inset: auto -120px -160px auto;
    width: 420px;
    height: 420px;
    border: 60px solid rgba(255, 255, 255, 0.04);
    border-radius: 50%;
}

.auth-aside-content {
    position: relative;
    z-index: 1;
    max-width: 440px;
}

.auth-aside-title {
    margin-bottom: 1.75rem;
    font-family: var(--font-heading);
    font-size: 1.7rem;
    font-weight: 800;
    line-height: 1.3;
}

.auth-aside-list {
    display: grid;
    gap: 0.9rem;
    padding: 0;
    list-style: none;
}

.auth-aside-list li {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    font-size: 0.92rem;
    color: rgba(255, 255, 255, 0.82);
}

.auth-aside-list svg.icon {
    flex: none;
    color: #9fb8e6;
}

@media (max-width: 991px) {
    .sidebar {
        transform: translateX(-100%);
    }

    .sidebar.open {
        transform: none;
        box-shadow: 8px 0 30px rgba(0, 0, 0, 0.3);
    }

    .sidebar-close,
    .topbar-toggle {
        display: inline-flex;
    }

    .topbar {
        left: 0;
        padding: 0 1rem;
    }

    .content {
        margin-left: 0;
        padding: calc(var(--topbar-height) + 1.25rem) 1rem 2rem;
    }

    .topbar-right .topbar-chip {
        display: none;
    }

    .auth-shell {
        grid-template-columns: minmax(0, 1fr);
    }

    .auth-aside {
        display: none;
    }

    .topbar-user-text {
        display: none;
    }

    .topbar-user {
        padding-left: 0.5rem;
    }
}

@media (max-width: 640px) {
    .page-title {
        font-size: 1.3rem;
    }

    .page-actions,
    .page-actions .btn {
        width: 100%;
    }

    .page-actions .segmented {
        width: 100%;
    }

    .page-actions .segmented a {
        flex: 1;
        justify-content: center;
    }

    .form-grid {
        grid-template-columns: minmax(0, 1fr);
    }

    .calc-preview {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .calc-preview-item:nth-child(2) {
        border-right: none;
    }

    .calc-preview-item:nth-child(-n + 2) {
        border-bottom: 1px solid rgba(255, 255, 255, 0.08);
    }

    dialog.modal:not(.modal-ask),
    dialog.modal.modal-lg,
    dialog.modal.modal-xl {
        width: 100vw;
        height: 100dvh;
        max-height: 100dvh;
        border: none;
    }

    .card-header,
    .card-body {
        padding-left: 1rem;
        padding-right: 1rem;
    }

    .toast-stack {
        right: 1rem;
        left: 1rem;
        width: auto;
    }

    .year-card-body {
        grid-template-columns: minmax(0, 1fr);
    }

    .year-card-section + .year-card-section {
        border-top: 1px solid var(--border);
        border-left: none;
    }

    .check-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .bracket-head {
        display: none;
    }

    .bracket-row {
        grid-template-columns: 1.6rem minmax(0, 1.3fr) minmax(0, 1fr) 34px;
        grid-template-areas:
            "index upper rate remove"
            "index lower base base";
        row-gap: 0.25rem;
        padding-bottom: 0.5rem;
        border-bottom: 1px dashed var(--border);
    }

    .bracket-lower,
    .bracket-base {
        padding-top: 0;
        font-size: 0.74rem;
    }

    .bracket-lower::before {
        content: 'Alt sınır ';
    }

    .bracket-base::before {
        content: 'Önceki vergi ';
    }

    .rate-chips {
        justify-content: flex-start;
    }

    .year-card-section .bracket-table th {
        white-space: normal;
    }

    .password-rules {
        grid-template-columns: minmax(0, 1fr);
    }

    .auth-card {
        padding: 2rem 1.35rem;
    }

    .email-port-row {
        grid-template-columns: minmax(0, 1fr);
    }

    .topbar-user-avatar {
        display: none;
    }

    .general-settings-actions {
        padding-top: 0;
    }
}

.savebar {
    position: fixed;
    right: 0;
    bottom: 0;
    left: var(--sidebar-width);
    z-index: 2900;
    transform: translateY(105%);
    transition: transform 0.28s cubic-bezier(0.22, 1, 0.36, 1);
}

.savebar.is-in {
    transform: none;
}

.savebar[hidden] {
    display: none;
}

.savebar.is-docked {
    position: relative;
    inset: auto;
    z-index: auto;
    flex: none;
    transform: none;
    transition: none;
}

.savebar-inner {
    display: flex;
    align-items: center;
    gap: 0.9rem;
    min-height: 60px;
    padding: 0.7rem 2rem;
    color: var(--white);
    background: var(--dark);
    border-top: 3px solid var(--primary);
    box-shadow: 0 -18px 40px -18px rgba(14, 27, 53, 0.55);
}

.savebar.is-docked .savebar-inner {
    min-height: 0;
    padding: 0.65rem 1.5rem;
    box-shadow: none;
}

.savebar-state {
    flex: none;
    width: 10px;
    height: 10px;
    background: #8fb0e6;
}

.savebar[data-mode="dirty"] .savebar-state,
.savebar[data-mode="manual"] .savebar-state {
    background: #f6c453;
    animation: savebarPulse 1.8s ease-in-out infinite;
}

.savebar[data-mode="saving"] .savebar-state {
    background: #8fb0e6;
    animation: savebarSpin 1s linear infinite;
}

.savebar[data-mode="saved"] .savebar-state {
    background: #6fcf8f;
}

.savebar[data-mode="error"] .savebar-state {
    background: #ff8a8a;
}

@keyframes savebarPulse {
    0%, 100% {
        opacity: 0.45;
        transform: scale(0.8);
    }

    50% {
        opacity: 1;
        transform: scale(1);
    }
}

@keyframes savebarSpin {
    to {
        transform: rotate(360deg);
    }
}

.savebar-text {
    display: flex;
    flex: 1 1 auto;
    align-items: baseline;
    gap: 0.6rem;
    min-width: 0;
}

.savebar-title {
    flex: none;
    font-family: var(--font-heading);
    font-size: 0.85rem;
    font-weight: 700;
}

.savebar-detail {
    min-width: 0;
    overflow: hidden;
    font-size: 0.8rem;
    color: rgba(255, 255, 255, 0.72);
    white-space: nowrap;
    text-overflow: ellipsis;
}

.savebar-actions {
    display: flex;
    flex: none;
    align-items: center;
    gap: 0.5rem;
}

.savebar-actions [hidden] {
    display: none;
}

.savebar-ghost {
    color: var(--white);
    background: rgba(255, 255, 255, 0.08);
    border-color: rgba(255, 255, 255, 0.24);
}

.savebar-ghost:hover {
    color: var(--white);
    background: rgba(255, 255, 255, 0.16);
    border-color: rgba(255, 255, 255, 0.4);
}

.savebar-primary {
    color: var(--white);
    background: var(--primary);
    border-color: var(--primary);
}

.savebar-primary:hover {
    color: var(--white);
    background: var(--primary-light);
    border-color: var(--primary-light);
}

.savebar .btn:disabled {
    opacity: 0.5;
    cursor: progress;
}

.savebar-close {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    color: rgba(255, 255, 255, 0.72);
    background: transparent;
    border: none;
}

.savebar-close:hover {
    color: var(--white);
    background: rgba(255, 255, 255, 0.1);
}

.savebar button:focus-visible {
    outline: 2px solid #8fb0e6;
    outline-offset: 2px;
}

body.has-savebar .content {
    padding-bottom: calc(3rem + 64px);
}

body.has-savebar .toast-stack:not(.is-top) {
    bottom: calc(1.5rem + 64px);
}

@media (max-width: 991px) {
    .savebar {
        left: 0;
    }
}

@media (max-width: 640px) {
    .savebar-inner {
        flex-wrap: wrap;
        gap: 0.5rem 0.75rem;
        padding: 0.6rem 1rem;
    }

    .savebar.is-docked .savebar-inner {
        padding: 0.6rem 1rem;
    }

    .savebar-text {
        flex-basis: calc(100% - 1.5rem);
        flex-direction: column;
        gap: 0.1rem;
    }

    .savebar-detail {
        white-space: normal;
    }

    .savebar-actions {
        justify-content: flex-end;
        width: 100%;
    }

    body.has-savebar .toast-stack:not(.is-top) {
        bottom: calc(1rem + 120px);
    }
}

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }

    .btn.is-loading::after,
    html.is-loading .page-progress {
        animation: none !important;
    }

    .table tbody tr.is-flash td {
        animation: none !important;
        background-color: rgba(48, 92, 167, 0.16);
    }

    .card.is-flash {
        animation: none !important;
        box-shadow: 0 0 0 3px rgba(48, 92, 167, 0.35);
    }
}
