:root {
    --brand: #1f4e79;
    --brand-dark: #163a5a;
    --brand-light: #e8f0f8;
    --surface: #ffffff;
    --background: #f4f6f9;
    --border: #dfe4ea;
    --text: #1d2733;
    --muted: #66727f;
    --positive: #1b7f4b;
    --negative: #b42318;
    --warning-bg: #fff8e1;
    --warning-border: #f0d68a;
}

html, body {
    font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    color: var(--text);
    background: var(--background);
    font-size: 15px;
}

.app {
    display: flex;
    min-height: 100vh;
}

.sidebar {
    width: 230px;
    flex-shrink: 0;
    background: var(--brand-dark);
    color: #fff;
    display: flex;
    flex-direction: column;
    position: sticky;
    top: 0;
    height: 100vh;
}

.brand {
    display: flex;
    align-items: center;
    gap: .6rem;
    padding: 1.1rem 1rem;
    color: #fff;
    font-weight: 600;
    text-decoration: none;
    border-bottom: 1px solid rgba(255, 255, 255, .12);
}

.brand:hover {
    color: #fff;
}

.brand-mark {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 30px;
    height: 30px;
    border-radius: 8px;
    background: rgba(255, 255, 255, .15);
}

.nav-menu {
    display: flex;
    flex-direction: column;
    padding: .75rem .5rem;
    gap: 2px;
    flex: 1;
}

.nav-entry {
    color: rgba(255, 255, 255, .85);
    text-decoration: none;
    padding: .55rem .75rem;
    border-radius: 6px;
}

.nav-entry:hover {
    background: rgba(255, 255, 255, .08);
    color: #fff;
}

.nav-entry.active {
    background: rgba(255, 255, 255, .16);
    color: #fff;
    font-weight: 600;
}

.rates-status {
    margin: .75rem;
    padding: .6rem .75rem;
    border-radius: 6px;
    background: rgba(255, 255, 255, .08);
    color: #fff;
    text-decoration: none;
    display: flex;
    flex-direction: column;
    font-size: .85rem;
}

.rates-status:hover {
    color: #fff;
    background: rgba(255, 255, 255, .14);
}

.rates-status.rates-old {
    background: #8a5a00;
}

.rates-label {
    opacity: .75;
}

.rates-date {
    font-weight: 600;
}

.main {
    flex: 1;
    min-width: 0;
}

.content {
    padding: 1.5rem 2rem 3rem;
    max-width: 1800px;
}

h1 {
    font-size: 1.6rem;
    font-weight: 600;
    margin-bottom: 1rem;
}

h2 {
    font-size: 1.2rem;
    font-weight: 600;
    margin: 1.5rem 0 .75rem;
}

.page-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    margin-bottom: 1rem;
}

.page-header h1 {
    margin: 0;
}

.panel {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 1.1rem 1.25rem;
    margin-bottom: 1rem;
}

.panel > h2:first-child {
    margin-top: 0;
}

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

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

.stats {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
    gap: .75rem;
    margin-bottom: 1rem;
}

.stat {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: .8rem 1rem;
}

.stat-label {
    color: var(--muted);
    font-size: .85rem;
}

.stat-value {
    font-size: 1.35rem;
    font-weight: 600;
    font-variant-numeric: tabular-nums;
}

.stat-value.positive {
    color: var(--positive);
}

.stat-value.negative {
    color: var(--negative);
}

.stat-hint {
    color: var(--muted);
    font-size: .8rem;
}

.num {
    text-align: right;
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
}

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

.table-wrap {
    overflow: auto;
    max-height: 70vh;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--surface);
}

.table-wrap table {
    margin: 0;
}

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

.data-table th {
    position: sticky;
    top: 0;
    background: #f0f3f7;
    z-index: 1;
    white-space: nowrap;
    font-weight: 600;
    border-bottom: 1px solid var(--border);
}

.data-table td, .data-table th {
    padding: .35rem .55rem;
    vertical-align: middle;
}

.data-table tr.row-excluded td {
    color: #9aa4ae;
    text-decoration: line-through;
}

.data-table tr.row-added td {
    background: #eef7ee;
}

.data-table tr.row-warning td {
    background: var(--warning-bg);
}

.data-table tr.row-highlight td {
    background: #e6f0fb;
}

.text-cell {
    max-width: 300px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.warnings {
    background: var(--warning-bg);
    border: 1px solid var(--warning-border);
    border-radius: 8px;
    padding: .75rem 1rem;
    margin-bottom: 1rem;
}

.warnings ul {
    margin: .25rem 0 0;
    padding-left: 1.2rem;
}

.warnings li.warning-severe {
    color: var(--negative);
    font-weight: 600;
}

.severe-notice ul {
    margin: .35rem 0 .5rem;
    padding-left: 1.2rem;
}

.steps {
    display: flex;
    gap: .25rem;
    margin-bottom: 1.25rem;
    flex-wrap: wrap;
}

.step {
    border: 1px solid var(--border);
    background: var(--surface);
    border-radius: 999px;
    padding: .4rem .9rem;
    color: var(--muted);
    cursor: pointer;
    font-size: .9rem;
}

.step.done {
    color: var(--text);
}

.step.active {
    background: var(--brand);
    border-color: var(--brand);
    color: #fff;
    font-weight: 600;
}

.step:disabled {
    cursor: default;
    opacity: .5;
}

.dropzone {
    border: 2px dashed #b7c4d3;
    border-radius: 10px;
    background: #fbfcfe;
    padding: 2.5rem 1rem;
    text-align: center;
    position: relative;
}

.dropzone:hover {
    border-color: var(--brand);
    background: var(--brand-light);
}

.dropzone input[type=file] {
    position: absolute;
    inset: 0;
    opacity: 0;
    cursor: pointer;
}

.badge-soft {
    display: inline-block;
    padding: .1rem .5rem;
    border-radius: 999px;
    font-size: .78rem;
    background: var(--brand-light);
    color: var(--brand-dark);
}

.badge-final {
    background: #e3f4ea;
    color: var(--positive);
}

.badge-draft {
    background: #f1f1f1;
    color: var(--muted);
}

.preview td.preview-header {
    background: #dde7f0;
    font-weight: 600;
}

.preview td.preview-data {
    background: #f6faf6;
}

/* column mapping: the file as a sheet with clickable column letters and row numbers */
.sheet-toolbar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: .35rem .5rem;
    min-height: 2.6rem;
    padding: .4rem .6rem;
    margin-bottom: .5rem;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 8px;
}

.sheet-toolbar-label {
    font-size: .88rem;
    font-weight: 600;
    margin-right: .25rem;
}

.sheet-grid {
    border-collapse: separate;
    border-spacing: 0;
    font-size: .84rem;
    background: var(--surface);
}

.sheet-grid th, .sheet-grid td {
    border-right: 1px solid var(--border);
    border-bottom: 1px solid var(--border);
    padding: .25rem .5rem;
    max-width: 260px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.sheet-grid thead th {
    position: sticky;
    top: 0;
    z-index: 2;
    background: #f0f3f7;
    padding: 0;
}

.sheet-grid .sheet-row, .sheet-grid .sheet-corner {
    position: sticky;
    left: 0;
    z-index: 1;
    background: #f5f6f8;
    padding: 0;
}

.sheet-grid thead .sheet-corner {
    z-index: 3;
}

.sheet-grid button {
    display: flex;
    align-items: center;
    gap: .35rem;
    width: 100%;
    border: 0;
    background: transparent;
    padding: .3rem .5rem;
    font: inherit;
    font-weight: 600;
    color: var(--muted);
    cursor: pointer;
}

.sheet-grid .sheet-row button {
    justify-content: flex-end;
    min-width: 3rem;
}

.sheet-grid th:hover button, .sheet-grid th.selected button {
    background: var(--brand-light);
    color: var(--brand-dark);
}

.sheet-grid th.mapped button {
    color: var(--brand-dark);
}

.sheet-role {
    padding: .05rem .45rem;
    border-radius: 999px;
    font-size: .74rem;
    background: var(--brand);
    color: #fff;
}

.sheet-grid td.mapped {
    box-shadow: inset 2px 0 0 rgba(31, 78, 121, .25);
}

.sheet-grid tr.sheet-header td {
    background: #dde7f0;
    font-weight: 600;
}

.sheet-grid tr.sheet-data td {
    background: #eef7ef;
}

.sheet-grid tr.sheet-balance td {
    background: #e9eef4;
    font-style: italic;
}

.sheet-grid tr.sheet-skipped td {
    background: var(--warning-bg);
}

.sheet-grid tr.sheet-error td {
    background: #fde8e6;
    color: var(--negative);
}

.sheet-grid tr.sheet-outside td {
    color: #9aa4ae;
}

.sheet-grid tr.sheet-gap td {
    text-align: center;
    color: var(--muted);
    font-style: italic;
    background: #fafbfc;
}

.mapping-result h3 {
    font-size: 1rem;
    font-weight: 600;
    margin-bottom: .35rem;
}

.preview .row-number {
    color: var(--muted);
    background: #f5f6f8;
    text-align: right;
}

.form-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(230px, 1fr));
    gap: .75rem 1rem;
}

.form-grid label {
    font-size: .85rem;
    color: var(--muted);
    margin-bottom: .2rem;
}

.note-cell {
    min-width: 9rem;
    max-width: 13rem;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* „Buchungen prüfen“: tighter, so that Hinweis and Änderungen fit next to the amounts */
.transactions-table td, .transactions-table th {
    padding: .3rem .4rem;
}

.transactions-table .text-cell {
    max-width: 150px;
}

.transactions-table .note-cell {
    min-width: 8rem;
}

.transactions-table .changes-cell {
    min-width: 9.5rem;
}

.inline-input.note-input {
    width: 100%;
    text-align: left;
}

.changes-cell {
    min-width: 11rem;
    max-width: 18rem;
    white-space: normal;
    font-size: .8rem;
    line-height: 1.25;
    color: var(--brand-dark);
}

.help-box {
    background: var(--brand-light);
    border: 1px solid #c9d9ea;
    border-radius: 8px;
    padding: .6rem .9rem;
    margin-bottom: 1rem;
    font-size: .9rem;
}

.help-box summary {
    font-weight: 600;
    color: var(--brand-dark);
    cursor: pointer;
}

.help-box[open] summary {
    margin-bottom: .5rem;
}

.help-box ul, .help-box ol {
    padding-left: 1.3rem;
    margin-bottom: .6rem;
}

.help-box li {
    margin-bottom: .2rem;
}

.account-number-input {
    max-width: 22rem;
}

.manual-value {
    background: #fff1c2;
    border-radius: 3px;
    padding: 0 .25rem;
    font-weight: 600;
}

.stat.mismatch {
    border-color: var(--negative);
}

.stat.mismatch .stat-hint {
    color: var(--negative);
    font-weight: 600;
}

.check-columns {
    display: grid;
    grid-template-columns: 1fr 1fr;
    column-gap: .75rem;
}

.inline-input {
    width: 5.6rem;
    padding: .1rem .3rem;
    font-size: .85rem;
    text-align: right;
}

.icon-button {
    border: 1px solid var(--border);
    background: #fff;
    border-radius: 4px;
    padding: 0 .4rem;
    font-size: .8rem;
    line-height: 1.6;
}

.icon-button.on {
    background: var(--brand);
    border-color: var(--brand);
    color: #fff;
}

.tabs {
    display: flex;
    gap: .25rem;
    border-bottom: 1px solid var(--border);
    margin-bottom: .75rem;
}

.tab {
    border: none;
    background: none;
    padding: .5rem .9rem;
    color: var(--muted);
    border-bottom: 2px solid transparent;
}

.tab.active {
    color: var(--brand);
    border-bottom-color: var(--brand);
    font-weight: 600;
}

pre.json {
    background: #f6f8fa;
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: .75rem;
    font-size: .8rem;
    max-height: 60vh;
}

#blazor-error-ui {
    background: lightyellow;
    bottom: 0;
    box-shadow: 0 -1px 2px rgba(0, 0, 0, 0.2);
    display: none;
    left: 0;
    padding: 0.6rem 1.25rem 0.7rem 1.25rem;
    position: fixed;
    width: 100%;
    z-index: 1000;
}

#blazor-error-ui .dismiss {
    cursor: pointer;
    position: absolute;
    right: 0.75rem;
    top: 0.5rem;
}

.blazor-error-boundary {
    background: #b32121;
    padding: 1rem 1rem 1rem 1rem;
    color: white;
}

.blazor-error-boundary::after {
    content: "Es ist ein Fehler aufgetreten."
}

.tree-search {
    width: 330px;
}

.tree-list {
    list-style: none;
    margin: 0;
    padding: 0;
}

.tree-children {
    margin-left: 22px;
    border-left: 1px solid var(--border);
    padding-left: 8px;
}

.tree-row {
    display: flex;
    align-items: center;
    gap: 8px;
    min-height: 38px;
    padding: 3px 6px;
    border-radius: 6px;
    flex-wrap: wrap;
}

.tree-row:hover {
    background: var(--background);
}

.tree-toggle {
    width: 22px;
    height: 22px;
    border: 0;
    background: none;
    color: var(--muted);
    padding: 0;
    line-height: 1;
}

.tree-icon {
    width: 16px;
    height: 16px;
    flex-shrink: 0;
    fill: none;
    stroke: var(--muted);
    stroke-width: 1.25;
}

.tree-document {
    padding-left: 34px;
}

.tree-name {
    font-weight: 600;
}

.tree-document .tree-name {
    font-weight: 400;
}

.tree-meta {
    color: var(--muted);
    font-size: 0.85rem;
}

.tree-actions {
    margin-left: auto;
    display: flex;
    align-items: center;
    gap: 6px;
}

.tree-archived .tree-name {
    color: var(--muted);
    text-decoration: line-through;
}

.tree-empty {
    padding-left: 34px;
    font-size: 0.9rem;
}

.tree-rename {
    width: 260px;
}

.tree-account {
    width: 200px;
}

.tree-kind {
    width: 120px;
}

@media (max-width: 800px) {
    .app {
        flex-direction: column;
    }

    .sidebar {
        width: 100%;
        height: auto;
        position: static;
    }

    .nav-menu {
        flex-direction: row;
        flex-wrap: wrap;
    }

    .content {
        padding: 1rem;
    }

    .tree-search, .tree-rename {
        width: 100%;
    }

    .tree-actions {
        margin-left: 0;
    }
}

.user-box {
    margin: 0 .7rem .9rem;
    padding: .6rem .8rem;
    border-radius: 8px;
    background: rgba(255, 255, 255, .08);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: .5rem;
}

.user-name {
    color: #fff;
    text-decoration: none;
    font-weight: 600;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.user-logout {
    border: 0;
    background: none;
    color: rgba(255, 255, 255, .75);
    font-size: .85rem;
    padding: 0;
}

.user-logout:hover, .user-name:hover {
    color: #fff;
    text-decoration: underline;
}

.nav-section {
    margin: .8rem .9rem .2rem;
    font-size: .75rem;
    text-transform: uppercase;
    letter-spacing: .04em;
    color: rgba(255, 255, 255, .55);
}

.account-page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1rem;
    background: var(--background);
}

.account-card {
    width: 100%;
    max-width: 440px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 1.8rem;
}

.account-card h1 {
    font-size: 1.4rem;
    margin-bottom: 1rem;
}

.account-brand {
    display: flex;
    align-items: center;
    gap: .6rem;
    font-weight: 600;
    margin-bottom: 1.4rem;
    color: var(--brand-dark);
}

.account-brand .brand-mark {
    background: var(--brand);
    color: #fff;
}

.qr-code {
    width: 220px;
    margin: .5rem auto 1rem;
}

.qr-code svg {
    width: 100%;
    height: auto;
}

.recovery-codes {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: .4rem;
}

.recovery-codes code {
    font-size: .95rem;
    padding: .3rem .5rem;
    background: var(--background);
    border-radius: 6px;
    text-align: center;
}

.setup-steps {
    padding-left: 1.2rem;
}

.one-time-password code {
    font-size: 1.1rem;
    user-select: all;
}

h1:focus {
    outline: none;
}

/* „i“ next to a label: the explanation appears on hover or keyboard focus (InfoTip) */
.info-tip {
    position: relative;
    display: inline-block;
    margin-left: .3rem;
    vertical-align: text-bottom;
    font-size: .85rem;
    font-weight: 400;
    line-height: 1;
}

.info-tip-button {
    width: 1.1rem;
    height: 1.1rem;
    padding: 0;
    border: 1px solid var(--brand);
    border-radius: 50%;
    background: var(--surface);
    color: var(--brand);
    font: italic 700 .72rem/1 Georgia, "Times New Roman", serif;
    cursor: help;
}

.info-tip:hover .info-tip-button,
.info-tip:focus-within .info-tip-button {
    background: var(--brand);
    color: #fff;
}

.info-tip-content {
    display: none;
    position: absolute;
    z-index: 40;
    top: calc(100% + .45rem);
    left: -.6rem;
    width: max-content;
    max-width: min(26rem, calc(100vw - 2rem));
    padding: .55rem .75rem;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 6px;
    box-shadow: 0 6px 18px rgba(29, 39, 51, .16);
    color: var(--text);
    font-size: .85rem;
    font-style: normal;
    font-weight: 400;
    line-height: 1.45;
    text-align: left;
    white-space: normal;
}

/* keeps the explanation open while the mouse moves from the „i“ into it */
.info-tip-content::before {
    content: "";
    position: absolute;
    left: 0;
    right: 0;
    top: -.5rem;
    height: .5rem;
}

.info-tip:hover .info-tip-content,
.info-tip:focus-within .info-tip-content {
    display: block;
}

.info-tip-end .info-tip-content {
    left: auto;
    right: -.6rem;
}

/* warning that can be hidden for the moment (DismissibleNotice) */
.dismissible {
    position: relative;
    padding-right: 2.75rem;
}

.dismissible > .btn-close {
    position: absolute;
    top: .8rem;
    right: .8rem;
    font-size: .75rem;
}
