@font-face {
    font-family: "Noto Sans";
    font-style: normal;
    font-weight: 400;
    font-display: swap;
    src: url("../fonts/NotoSans-Regular.ttf") format("truetype");
}

@font-face {
    font-family: "Noto Sans";
    font-style: normal;
    font-weight: 700;
    font-display: swap;
    src: url("../fonts/NotoSans-Bold.ttf") format("truetype");
}

@font-face {
    font-family: "Noto Serif";
    font-style: normal;
    font-weight: 400;
    font-display: swap;
    src: url("../fonts/NotoSerif-Regular.ttf") format("truetype");
}

@font-face {
    font-family: "Lato";
    font-style: normal;
    font-weight: 400;
    font-display: swap;
    src: url("../fonts/Lato-Regular.ttf") format("truetype");
}

@font-face {
    font-family: "Open Sans";
    font-style: normal;
    font-weight: 400;
    font-display: swap;
    src: url("../fonts/OpenSans-Regular.ttf") format("truetype");
}

@font-face {
    font-family: "Source Sans 3";
    font-style: normal;
    font-weight: 400;
    font-display: swap;
    src: url("../fonts/SourceSans3-Regular.ttf") format("truetype");
}

@font-face {
    font-family: "Montserrat";
    font-style: normal;
    font-weight: 400;
    font-display: swap;
    src: url("../fonts/Montserrat-Regular.ttf") format("truetype");
}

@font-face {
    font-family: "Merriweather";
    font-style: normal;
    font-weight: 400;
    font-display: swap;
    src: url("../fonts/Merriweather-Regular.ttf") format("truetype");
}

@font-face {
    font-family: "Caveat";
    font-style: normal;
    font-weight: 400;
    font-display: swap;
    src: url("../fonts/Caveat-Regular.ttf") format("truetype");
}

@font-face {
    font-family: "Bungee";
    font-style: normal;
    font-weight: 400;
    font-display: swap;
    src: url("../fonts/Bungee-Regular.ttf") format("truetype");
}

@font-face {
    font-family: "Cormorant Garamond";
    font-style: normal;
    font-weight: 400;
    font-display: swap;
    src: url("../fonts/CormorantGaramond.ttf") format("truetype");
}

@font-face {
    font-family: "DM Serif Display";
    font-style: normal;
    font-weight: 400;
    font-display: swap;
    src: url("../fonts/DMSerifDisplay-Regular.ttf") format("truetype");
}

@font-face {
    font-family: "Yeseva One";
    font-style: normal;
    font-weight: 400;
    font-display: swap;
    src: url("../fonts/YesevaOne-Regular.ttf") format("truetype");
}

@font-face {
    font-family: "Poiret One";
    font-style: normal;
    font-weight: 400;
    font-display: swap;
    src: url("../fonts/PoiretOne-Regular.ttf") format("truetype");
}

@font-face {
    font-family: "Play";
    font-style: normal;
    font-weight: 400;
    font-display: swap;
    src: url("../fonts/Play-Regular.ttf") format("truetype");
}

@font-face {
    font-family: "Fraunces";
    font-style: normal;
    font-weight: 400;
    font-display: swap;
    src: url("../fonts/Fraunces.ttf") format("truetype");
}

@font-face {
    font-family: "Righteous";
    font-style: normal;
    font-weight: 400;
    font-display: swap;
    src: url("../fonts/Righteous-Regular.ttf") format("truetype");
}

*,
*::before,
*::after {
    box-sizing: border-box;
}

html,
body {
    font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    font-weight: 400;
}

.valid.modified:not([type=checkbox]) {
    outline: 1px solid #26b050;
}

.invalid {
    outline: 1px solid red;
}

.validation-message {
    color: red;
}

.invoice-pdf-error {
    background: var(--theme-danger);
    border: 1px solid var(--theme-danger-text);
    border-radius: 0.6rem;
    color: var(--theme-danger-text);
    margin: 0 0 1rem;
    padding: 0.75rem 1rem;
}

#blazor-error-ui {
    color-scheme: light only;
    background: lightyellow;
    bottom: 0;
    box-shadow: 0 -1px 2px rgba(0, 0, 0, 0.2);
    box-sizing: border-box;
    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: url(data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iNTYiIGhlaWdodD0iNDkiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyIgeG1sbnM6eGxpbms9Imh0dHA6Ly93d3cudzMub3JnLzE5OTkveGxpbmsiIG92ZXJmbG93PSJoaWRkZW4iPjxkZWZzPjxjbGlwUGF0aCBpZD0iY2xpcDAiPjxyZWN0IHg9IjIzNSIgeT0iNTEiIHdpZHRoPSI1NiIgaGVpZ2h0PSI0OSIvPjwvY2xpcFBhdGg+PC9kZWZzPjxnIGNsaXAtcGF0aD0idXJsKCNjbGlwMCkiIHRyYW5zZm9ybT0idHJhbnNsYXRlKC0yMzUgLTUxKSI+PHBhdGggZD0iTTI2My41MDYgNTFDMjY0LjcxNyA1MSAyNjUuODEzIDUxLjQ4MzcgMjY2LjYwNiA1Mi4yNjU4TDI2Ny4wNTIgNTIuNzk4NyAyNjcuNTM5IDUzLjYyODMgMjkwLjE4NSA5Mi4xODMxIDI5MC41NDUgOTIuNzk1IDI5MC42NTYgOTIuOTk2QzI5MC44NzcgOTMuNTEzIDI5MSA5NC4wODE1IDI5MSA5NC42NzgyIDI5MSA5Ny4wNjUxIDI4OS4wMzggOTkgMjg2LjYxNyA5OUwyNDAuMzgzIDk5QzIzNy45NjMgOTkgMjM2IDk3LjA2NTEgMjM2IDk0LjY3ODIgMjM2IDk0LjM3OTkgMjM2LjAzMSA5NC4wODg2IDIzNi4wODkgOTMuODA3MkwyMzYuMzM4IDkzLjAxNjIgMjM2Ljg1OCA5Mi4xMzE0IDI1OS40NzMgNTMuNjI5NCAyNTkuOTYxIDUyLjc5ODUgMjYwLjQwNyA1Mi4yNjU4QzI2MS4yIDUxLjQ4MzcgMjYyLjI5NiA1MSAyNjMuNTA2IDUxWk0yNjMuNTg2IDY2LjAxODNDMjYwLjczNyA2Ni4wMTgzIDI1OS4zMTMgNjcuMTI0NSAyNTkuMzEzIDY5LjMzNyAyNTkuMzEzIDY5LjYxMDIgMjU5LjMzMiA2OS44NjA4IDI1OS4zNzEgNzAuMDg4N0wyNjEuNzk1IDg0LjAxNjEgMjY1LjM4IDg0LjAxNjEgMjY3LjgyMSA2OS43NDc1QzI2Ny44NiA2OS43MzA5IDI2Ny44NzkgNjkuNTg3NyAyNjcuODc5IDY5LjMxNzkgMjY3Ljg3OSA2Ny4xMTgyIDI2Ni40NDggNjYuMDE4MyAyNjMuNTg2IDY2LjAxODNaTTI2My41NzYgODYuMDU0N0MyNjEuMDQ5IDg2LjA1NDcgMjU5Ljc4NiA4Ny4zMDA1IDI1OS43ODYgODkuNzkyMSAyNTkuNzg2IDkyLjI4MzcgMjYxLjA0OSA5My41Mjk1IDI2My41NzYgOTMuNTI5NSAyNjYuMTE2IDkzLjUyOTUgMjY3LjM4NyA5Mi4yODM3IDI2Ny4zODcgODkuNzkyMSAyNjcuMzg3IDg3LjMwMDUgMjY2LjExNiA4Ni4wNTQ3IDI2My41NzYgODYuMDU0N1oiIGZpbGw9IiNGRkU1MDAiIGZpbGwtcnVsZT0iZXZlbm9kZCIvPjwvZz48L3N2Zz4=) no-repeat 1rem/1.8rem, #b32121;
    padding: 1rem 1rem 1rem 3.7rem;
    color: white;
}

    .blazor-error-boundary::after {
        content: "An error has occurred."
    }

.loading-progress {
    position: absolute;
    display: block;
    width: 8rem;
    height: 8rem;
    inset: 20vh 0 auto 0;
    margin: 0 auto 0 auto;
}

#boot-loading {
    background: var(--theme-page, #f5f7fb);
    inset: 0;
    position: fixed;
    transition: opacity 0.25s ease, visibility 0.25s ease;
    z-index: 10;
}

#boot-loading.boot-loading-dismissed {
    opacity: 0;
    pointer-events: none;
    visibility: hidden;
}

    .loading-progress circle {
        fill: none;
        stroke: var(--boot-spinner-track, #e0e0e0);
        stroke-width: 0.6rem;
        transform-origin: 50% 50%;
        transform: rotate(-90deg);
    }

        .loading-progress circle:last-child {
            stroke: var(--boot-spinner-indicator, #1b6ec2);
            stroke-dasharray: calc(3.141 * var(--blazor-load-percentage, 0%) * 0.8), 500%;
            transition: stroke-dasharray 0.05s ease-in-out;
        }

.loading-progress-text {
    color: var(--boot-spinner-text, #1f2937);
    position: absolute;
    text-align: center;
    font-weight: bold;
    inset: calc(20vh + 3.25rem) 0 auto 0.2rem;
}

.loading-progress-text:after {
    content: var(--blazor-load-percentage-text, "Ladataan");
}

.loading-brand-mark {
    width: 6rem;
    height: 6rem;
    object-fit: contain;
    opacity: 0;
    transform: scale(0.72);
    filter: drop-shadow(0 0 0 var(--theme-sidebar-glow, rgba(37, 99, 235, 0.28)));
    pointer-events: none;
}

.loading-brand-lockup {
    align-items: center;
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
    position: absolute;
    inset: 21vh 0 auto 0;
    margin: 0 auto;
    pointer-events: none;
}

.loading-brand-name {
    display: flex;
    gap: 0.28rem;
    width: max-content;
}

:root {
    --theme-warning: #facc15;
    --theme-warning-text: #111827;
    --theme-warning-border: #111827;
}

.loading-brand-word-lockup {
    align-items: stretch;
    display: flex;
    flex-direction: column;
    width: max-content;
}

.loading-brand-word {
    color: var(--boot-spinner-text, var(--theme-text));
    font-family: "Trebuchet MS", "Segoe UI", sans-serif;
    font-size: 1.05rem;
    font-weight: 700;
    letter-spacing: 0.08em;
    opacity: 0;
    transform: translateX(-1.5rem);
}

.loading-brand-underline {
    background: var(--theme-accent, var(--boot-spinner-indicator, #2563eb));
    border-radius: 999px;
    box-shadow: 0 0 0 var(--theme-sidebar-glow, rgba(37, 99, 235, 0.28));
    height: 0.16rem;
    margin-top: 0.12rem;
    opacity: 0;
    transform: scaleX(0);
    transform-origin: left center;
    width: 100%;
}

.boot-brand-reveal .loading-progress {
    opacity: 0;
    transform: scale(0.72);
    transition: opacity 0.3s ease, transform 0.45s ease;
}

.boot-brand-reveal .loading-brand-mark {
    animation: loading-brand-reveal 1.0s cubic-bezier(0.22, 0.8, 0.28, 1) forwards;
}

.boot-brand-reveal .loading-brand-word {
    animation: loading-brand-name-reveal 0.72s cubic-bezier(0.22, 0.8, 0.28, 1) forwards;
}

.boot-brand-reveal .loading-brand-word-second {
    animation-delay: 0.24s;
}

.boot-brand-reveal .loading-brand-underline {
    animation: loading-brand-underline-reveal 0.62s cubic-bezier(0.22, 0.8, 0.28, 1) 0.86s forwards;
}

@keyframes loading-brand-reveal {
    0% {
        opacity: 0;
        transform: scale(0.72);
        filter: drop-shadow(0 0 0 var(--theme-sidebar-glow));
    }

    45% {
        opacity: 1;
        transform: scale(1.01);
        filter: drop-shadow(0 0 0.55rem var(--theme-sidebar-glow));
    }

    100% {
        opacity: 1;
        transform: scale(1);
        filter: drop-shadow(0 0 0.45rem var(--theme-sidebar-glow));
    }
}

@keyframes loading-brand-name-reveal {
    from {
        opacity: 0;
        transform: translateX(-1.5rem);
    }

    to {
        opacity: 1;
        transform: translateX(0);
    }
}

@keyframes loading-brand-underline-reveal {
    0% {
        opacity: 0;
        transform: scaleX(0);
        box-shadow: 0 0 0 var(--theme-sidebar-glow, rgba(37, 99, 235, 0.28));
    }

    45% {
        opacity: 1;
        transform: scaleX(1.04);
        box-shadow: 0 0 0.65rem var(--theme-sidebar-glow, rgba(37, 99, 235, 0.28));
    }

    100% {
        opacity: 1;
        transform: scaleX(1);
        box-shadow: 0 0 0.4rem var(--theme-sidebar-glow, rgba(37, 99, 235, 0.28));
    }
}

code {
    color: #c02d76;
}

.template-json-editor {
    height: 32rem;
    width: 100%;
    border: 1px solid #d7e0ec;
    border-radius: 0.5rem;
    overflow: hidden;
}

.pdfme-template-designer {
    height: calc(100vh - 8rem);
    min-height: 30rem;
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
    overflow: hidden;
    border: 1px solid var(--theme-border, #d7e0ec);
    border-radius: 0.5rem;
    background: var(--theme-surface-raised, #ffffff);
}

.pdfme-editor-workspace {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 300px;
    gap: 1rem;
    align-items: start;
}

.pdfme-editor-workspace-full { grid-template-columns: minmax(0, 1fr); }

.pdfme-static-toolbar {
    align-items: center;
    display: flex;
    margin: -0.35rem 0 0.45rem;
}

.pdfme-static-status-line {
    background: var(--theme-border);
    border-radius: 999px;
    flex: 1;
    height: 2px;
    margin-left: 0.75rem;
    transition: background 140ms ease, box-shadow 140ms ease;
}

.pdfme-static-status-line-active {
    background: var(--theme-accent);
    box-shadow: 0 0 0.45rem var(--theme-accent);
}

.pdfme-static-status-label {
    color: var(--theme-accent);
    font-size: 0.78rem;
    font-weight: 700;
    letter-spacing: 0.04em;
    margin: 0 0.75rem;
    white-space: nowrap;
}

.pdfme-static-toggle {
    align-items: center;
    background: var(--theme-surface-raised);
    border: 1px solid var(--theme-border);
    border-radius: 0.45rem;
    box-shadow: 0 0.1rem 0.25rem var(--theme-shadow);
    color: var(--theme-muted);
    cursor: pointer;
    display: inline-flex;
    font: inherit;
    gap: 0.45rem;
    padding: 0.35rem 0.6rem;
    transition: background 140ms ease, border-color 140ms ease, box-shadow 140ms ease, color 140ms ease;
}

.pdfme-static-toggle:hover,
.pdfme-static-toggle:focus-visible {
    border-color: var(--theme-accent);
    color: var(--theme-text);
    outline: none;
}

.pdfme-static-toggle[aria-pressed="true"] {
    background: var(--theme-secondary);
    border-color: var(--theme-accent);
    box-shadow: inset 0 0.1rem 0.25rem var(--theme-shadow), 0 0 0 1px var(--theme-accent);
    color: var(--theme-text);
}

.pdfme-static-toggle-active {
    background: var(--theme-secondary);
    border-color: var(--theme-accent);
    box-shadow: inset 0 0.1rem 0.25rem var(--theme-shadow), 0 0 0 1px var(--theme-accent);
    color: var(--theme-text);
}

.pdfme-static-toggle-indicator {
    background: var(--theme-muted);
    border-radius: 50%;
    box-shadow: 0 0 0 2px var(--theme-border);
    height: 0.55rem;
    width: 0.55rem;
}

.pdfme-static-toggle[aria-pressed="true"] .pdfme-static-toggle-indicator {
    background: var(--theme-accent);
    box-shadow: 0 0 0 2px var(--theme-accent), 0 0 0 4px var(--theme-secondary);
}

.pdfme-static-toggle-active .pdfme-static-toggle-indicator {
    background: var(--theme-primary);
    box-shadow: 0 0 0 2px var(--theme-accent), 0 0 0 4px var(--theme-secondary);
}

.template-variable-panel {
    background: var(--theme-surface-raised);
    border: 1px solid var(--theme-border);
    border-radius: 0.75rem;
    color: var(--theme-text);
    padding: 1rem;
    max-height: calc(100vh - 8rem);
    overflow: auto;
}

.main-content:has(.pdfme-editor-menu) {
    box-sizing: border-box;
    height: 100vh;
    min-height: 0;
    overflow: hidden;
    padding-bottom: 1rem;
    padding-top: 1rem;
}

.main-content:has(.pdfme-editor-menu) .pdfme-editor-workspace {
    min-height: 0;
}

.main-content:has(.pdfme-editor-menu) .template-variable-panel {
    max-height: calc(100vh - 8rem);
}

.mobile-editor-warning {
    align-items: center;
    background: var(--theme-warning);
    border: 2px solid var(--theme-warning-border);
    border-radius: 0.45rem;
    box-sizing: border-box;
    color: var(--theme-warning-text);
    display: flex;
    gap: 1rem;
    justify-content: space-between;
    margin-bottom: 0.75rem;
    padding: 0.7rem 0.85rem;
}

.mobile-editor-warning-dismiss {
    background: transparent;
    border: 0;
    color: var(--theme-warning-text);
    cursor: pointer;
    font: inherit;
    font-size: 1.5rem;
    line-height: 1;
    padding: 0.15rem 0.35rem;
}

.mobile-editor-warning-dismiss:focus-visible {
    outline: 2px solid var(--theme-warning-text);
    outline-offset: 2px;
}

.main-content:has(.mobile-editor-warning) .pdfme-template-designer {
    height: calc(100vh - 11.5rem);
}

.main-content:has(.mobile-editor-warning) .template-variable-panel {
    max-height: calc(100vh - 11.5rem);
}

.template-variable-panel h2,
.template-variable-panel h3 { margin: 0 0 0.5rem; }
.template-variable-panel h3 { border-top: 1px solid var(--theme-border); margin-top: 1rem; padding-top: 1rem; font-size: 0.95rem; }
.template-variable-help,
.template-variable-empty { color: var(--theme-muted); font-size: 0.85rem; }
.template-image-section { border-top: 1px solid var(--theme-border); margin-top: 1.25rem; padding-top: 1.25rem; }
.template-image-section h3,
.template-image-section p { margin-top: 0; }
.template-image-section .section-header .field { margin-inline-start: 10px; }
.template-image-section > .invoice-image-upload { margin-inline: 10px; }
.invoice-section-toggle { white-space: nowrap; }
.invoice-section-toggle-icon {
    align-items: center;
    display: inline-flex;
    height: 3rem;
    justify-content: center;
    padding: 0;
    width: 2.45rem;
}
.invoice-section-toggle-icon svg {
    fill: none;
    height: 1.2rem;
    stroke: currentColor;
    stroke-linecap: round;
    stroke-linejoin: round;
    stroke-width: 1.8;
    width: 1.2rem;
}
.invoice-template-details-card {
    position: relative;
}
.invoice-template-details-card .section-header { padding-inline-end: 3.5rem; position: static; }
.invoice-template-details-card .section-header > .section-actions {
    align-items: center;
    display: flex;
    gap: 0.5rem;
    position: static;
}
.collapsible-content {
    display: grid;
    grid-template-rows: 0fr;
    opacity: 0;
    transition: grid-template-rows 650ms ease, opacity 300ms ease;
}
.collapsible-content.is-open {
    grid-template-rows: 1fr;
    opacity: 1;
}
.collapsible-content-inner {
    min-height: 0;
    overflow: hidden;
    transition: opacity 300ms ease;
}
.collapsible-content.is-open > .collapsible-content-inner {
    opacity: 1;
}
.invoice-template-details-card .invoice-section-toggle-icon {
    position: absolute;
    right: 1rem;
    top: 1rem;
    z-index: 1;
}
.invoice-template-details-card .invoice-section-toggle-icon:focus-visible { z-index: 2; }
.invoice-after-template-actions { display: flex; justify-content: flex-end; min-height: 0; }
.template-image-options { margin-top: 1rem; }
.template-image-alignment-field { max-width: 12rem; }
.settings-image-options { margin-top: 1rem; }
.settings-image-alignment-field { max-width: 12rem; }
.company-brand-editor { display: grid; gap: 0.75rem; }
.company-brand-heading-row { align-items: start; display: flex; gap: 1rem; justify-content: space-between; }
.company-brand-heading { display: grid; gap: 0.25rem; }
.company-brand-actions { align-items: center; display: flex; gap: 0.5rem; margin-inline-start: auto; }
.company-brand-editor h3 { margin: 0; }
.company-brand-editor p { margin: 0.25rem 0 0; }
.company-brand-toggle {
    align-self: start;
    background: transparent;
    border: 0;
    color: var(--theme-accent);
    cursor: pointer;
    font: inherit;
    font-size: 0.9rem;
    padding: 0.2rem 0;
    text-align: start;
    text-decoration: underline;
    text-underline-offset: 0.15em;
}
.company-brand-toggle:focus-visible { border-radius: 0.25rem; outline: 2px solid var(--theme-accent); outline-offset: 2px; }
.company-brand-toggle:hover { color: var(--theme-primary); }
.company-brand-editor-fields { display: grid; gap: 0.75rem; }
.company-brand-mode-field { margin-inline: 10px; max-width: 24rem; }
.company-brand-divider { align-items: center; color: var(--theme-muted); display: flex; gap: 0.75rem; margin-inline: 10px; }
.company-brand-divider::before,
.company-brand-divider::after { border-top: 1px solid var(--theme-border); content: ""; flex: 1; }
.company-brand-text-layout { align-items: stretch; display: grid; gap: 1rem; grid-template-columns: minmax(0, 2fr) minmax(12rem, 1fr); margin-inline: 10px; }
.company-brand-fallback { display: grid; gap: 1rem; grid-template-columns: minmax(0, 2fr) repeat(3, minmax(9rem, 1fr)); }
.company-brand-text-preview {
    align-items: center;
    background: var(--theme-secondary);
    border: 1px solid var(--theme-border);
    border-radius: 0.5rem;
    display: flex;
    justify-content: center;
    min-height: 8rem;
    overflow-wrap: anywhere;
    padding: 1rem;
    text-align: center;
}
.company-brand-text-preview span { max-width: 100%; }
.company-brand-style-field { min-width: 9rem; }
.company-brand-style-option {
    align-items: center;
    color: var(--theme-text);
    display: flex;
    gap: 0.45rem;
    margin-top: 0.55rem;
}
.company-brand-style-option span {
    color: var(--theme-text);
    font-size: 0.9rem;
    font-weight: 400;
}
.company-brand-font-picker { position: relative; }
.company-brand-font-button {
    cursor: pointer;
    text-align: start;
}
.company-brand-font-button:disabled { cursor: not-allowed; }
.company-brand-font-options {
    background: var(--theme-input);
    border: 1px solid var(--theme-border);
    border-radius: 0.5rem;
    box-shadow: 0 8px 20px var(--theme-shadow);
    display: grid;
    left: 0;
    bottom: calc(100% + 0.25rem);
    max-height: 16rem;
    overflow-y: auto;
    position: absolute;
    right: 0;
    z-index: 20;
}
.company-brand-font-button,
.company-brand-font-option {
    font-size: 1rem;
    font-synthesis: none;
    font-weight: 400;
}
.company-brand-font-option {
    background: transparent;
    border: 0;
    color: var(--theme-text);
    cursor: pointer;
    padding: 0.65rem 0.9rem;
    text-align: start;
}
.company-brand-font-option:hover,
.company-brand-font-option:focus-visible,
.company-brand-font-option.is-selected {
    background: var(--theme-secondary);
}
.company-brand-editor-help { color: var(--theme-muted); font-size: 0.85rem; }
.image-file-label-disabled { cursor: not-allowed; opacity: 0.55; }
.secondary-button.image-file-label-disabled,
.secondary-button.image-file-label-disabled:hover,
.secondary-button.image-file-label-disabled:focus-visible {
    cursor: not-allowed;
    transform: none;
}
.template-logo-status { border: 1px solid var(--theme-border); border-radius: 0.45rem; display: grid; gap: 0.15rem; margin: 0.5rem 0 0.75rem; padding: 0.6rem 0.7rem; }
.template-logo-status span { color: var(--theme-muted); font-size: 0.8rem; }
.template-logo-status-active { background: var(--theme-secondary); }
.template-logo-status-empty { background: var(--theme-danger); }
.template-logo-status-warning { background: transparent; color: var(--theme-muted); }
.template-logo-status-warning span { color: var(--theme-muted); }
.template-variable-row { align-items: center; display: flex; gap: 0.5rem; justify-content: space-between; padding: 0.4rem 0; }
.template-variable-row > div { min-width: 0; }
.template-variable-actions { align-items: center; display: inline-flex; flex: 0 0 auto; gap: 0.1rem; }
.template-variable-row strong { display: block; font-size: 0.85rem; }
.template-variable-row code { color: var(--theme-accent); font-size: 0.75rem; }
.template-variable-usage { color: var(--theme-muted); font-size: 0.72rem; margin-left: 0.25rem; }
.template-variable-copy { align-items: center; background: transparent; border: 1px solid var(--theme-border); border-radius: 0.35rem; color: var(--theme-muted); cursor: pointer; display: inline-flex; flex: 0 0 auto; justify-content: center; padding: 0.35rem; }
.template-variable-copy svg { fill: none; height: 1rem; stroke: currentColor; stroke-linecap: round; stroke-linejoin: round; stroke-width: 1.8; width: 1rem; }
.template-variable-copy:hover,
.template-variable-copy:focus-visible { background: var(--theme-secondary); color: var(--theme-text); }
.template-variable-remove { background: transparent; border: 0; color: var(--theme-muted); cursor: pointer; font-size: 1.1rem; line-height: 1; padding: 0.2rem 0.35rem; }
.template-variable-remove:hover,
.template-variable-remove:focus-visible { color: var(--theme-danger-text); }
.template-variable-edit-button { background: transparent; border: 0; color: var(--theme-muted); cursor: pointer; font-size: 1rem; padding: 0.2rem 0.35rem; }
.template-variable-edit-button:hover,
.template-variable-edit-button:focus-visible { color: var(--theme-text); }
.template-variable-edit { display: grid; flex: 1; gap: 0.5rem; }
.template-variable-editor { display: grid; flex: 1; gap: 0.5rem; }
.template-variable-edit-actions { display: flex; gap: 0.5rem; }
.template-variable-edit-actions button { padding: 0.4rem 0.65rem; }
.template-variable-add { display: grid; gap: 0.5rem; margin-top: 0.75rem; }

@media (max-width: 1100px) {
    .pdfme-editor-workspace { grid-template-columns: 1fr; }
    .template-variable-panel { max-height: none; }
}

.template-empty-state {
    align-items: center;
    background: var(--theme-surface-raised);
    border: 1px solid var(--theme-border);
    border-radius: 0.5rem;
    color: var(--theme-text);
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    justify-content: center;
    min-height: 24rem;
    padding: 2rem;
    text-align: center;
}

.template-empty-state h1,
.template-empty-state p {
    margin: 0;
}

.template-empty-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
    justify-content: center;
}

.template-empty-import {
    cursor: pointer;
}

.pdfme-editor-menu {
    align-items: center;
    background: var(--theme-surface-raised);
    border: 1px solid var(--theme-border);
    border-radius: 0.45rem;
    box-shadow: 0 0.2rem 0.6rem var(--theme-shadow);
    display: flex;
    gap: 0.1rem;
    margin-bottom: 0.75rem;
    min-height: 2.2rem;
    padding: 0.15rem;
}

.pdfme-menu-item {
    background: transparent;
    border: 0;
    border-radius: 0.3rem;
    color: var(--theme-text);
    cursor: pointer;
    font: inherit;
    padding: 0.35rem 0.7rem;
}

.pdfme-menu-item:hover,
.pdfme-menu-item:focus-visible {
    background: var(--theme-secondary);
    color: var(--theme-text);
    outline: none;
}

.pdfme-menu-item[aria-pressed="true"] {
    background: var(--theme-secondary);
    color: var(--theme-text);
}

.pdfme-menu-file-label {
    cursor: pointer;
}

.pdfme-menu-file-input {
    display: none;
}

.pdfme-current-template-name {
    color: var(--theme-muted);
    font-weight: 600;
    margin-left: auto;
    max-width: min(28rem, 35vw);
    overflow: hidden;
    padding: 0.35rem 0.7rem;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.pdfme-menu-divider {
    align-self: stretch;
    border-left: 1px solid var(--theme-border);
    margin: 0.2rem 0.25rem;
}

.pdfme-menu-danger {
    background: var(--theme-danger, #dc2626);
    color: var(--theme-danger-text, #ffffff);
    margin-left: 0;
}

.pdfme-menu-danger:hover,
.pdfme-menu-danger:focus-visible {
    background: var(--theme-danger-hover, #b91c1c);
    color: var(--theme-danger-text, #ffffff);
}

.template-dialog-backdrop {
    align-items: center;
    background: rgba(0, 0, 0, 0.45);
    display: flex;
    inset: 0;
    justify-content: center;
    padding: 1rem;
    position: fixed;
    z-index: 100;
}

.template-dialog {
    background: var(--theme-surface-raised);
    border: 1px solid var(--theme-border);
    border-radius: 1rem;
    box-shadow: 0 1rem 3rem var(--theme-shadow);
    color: var(--theme-text);
    display: flex;
    flex-direction: column;
    max-width: 32rem;
    max-height: calc(100vh - 2rem);
    min-height: 0;
    width: 100%;
}

.template-dialog-header,
.template-dialog-actions {
    align-items: center;
    display: flex;
    justify-content: space-between;
    padding: 1rem 1.25rem;
}

.template-dialog-header {
    border-bottom: 1px solid var(--theme-border);
}

.template-dialog-header h2 {
    font-size: 1.15rem;
    margin: 0;
}

.template-dialog-close {
    background: transparent;
    border: 0;
    color: var(--theme-muted);
    cursor: pointer;
    font-size: 1.5rem;
    line-height: 1;
}

.template-dialog-body {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    min-height: 0;
    overflow-y: auto;
    padding: 1.25rem;
}

.template-dialog-actions {
    flex: 0 0 auto;
}

.template-margin-grid {
    display: grid;
    gap: 0.75rem;
    grid-template-columns: repeat(2, minmax(0, 1fr));
}

.template-size-grid {
    display: grid;
    gap: 0.75rem;
    grid-template-columns: repeat(2, minmax(0, 1fr));
}

.template-max-lines-input {
    max-width: 6rem;
}

.template-name-error {
    color: var(--theme-danger-text);
    margin: 0;
    white-space: normal;
}

.template-dialog-subheading {
    border-top: 1px solid var(--theme-border);
    font-size: 0.95rem;
    margin: 0;
    padding-top: 1rem;
}

.template-dialog-actions {
    border-top: 1px solid var(--theme-border);
    gap: 0.6rem;
    justify-content: space-between;
}

/* pdfme uses Ant Design for its property editor. Keep its controls in the
   same palette as the surrounding application and all available themes. */
.pdfme-template-designer .ant-app,
.pdfme-template-designer .ant-layout,
.pdfme-template-designer .ant-layout-sider,
.pdfme-template-designer .ant-card,
.pdfme-template-designer .ant-collapse,
.pdfme-template-designer .ant-tabs-content-holder {
    background: var(--theme-surface-raised) !important;
    color: var(--theme-text) !important;
}

.pdfme-template-designer .ant-input,
.pdfme-template-designer .ant-input-affix-wrapper,
.pdfme-template-designer .ant-select-selector,
.pdfme-template-designer .ant-input-number,
.pdfme-template-designer .ant-input-number-input,
.pdfme-template-designer textarea {
    background: var(--theme-input) !important;
    border-color: var(--theme-border) !important;
    color: var(--theme-text) !important;
}

.pdfme-template-designer .ant-input::placeholder,
.pdfme-template-designer textarea::placeholder {
    color: var(--theme-muted) !important;
}

.pdfme-template-designer .ant-form-item-label > label,
.pdfme-template-designer .ant-form-item-label > label span,
.pdfme-template-designer .ant-card-head,
.pdfme-template-designer .ant-card-head-title,
.pdfme-template-designer .ant-typography,
.pdfme-template-designer .ant-collapse-header,
.pdfme-template-designer .ant-tabs-tab,
.pdfme-template-designer .ant-select-selection-item {
    color: var(--theme-text) !important;
}

.pdfme-template-designer .ant-form-item-extra,
.pdfme-template-designer .ant-form-item-explain,
.pdfme-template-designer .ant-select-arrow,
.pdfme-template-designer .anticon {
    color: var(--theme-muted) !important;
}

.pdfme-template-designer .ant-btn-default,
.pdfme-template-designer .ant-btn-text,
.pdfme-template-designer .ant-btn-variant-outlined {
    background: var(--theme-surface-raised) !important;
    border-color: var(--theme-border) !important;
    color: var(--theme-text) !important;
}

.pdfme-template-designer .ant-btn-default:hover,
.pdfme-template-designer .ant-btn-text:hover,
.pdfme-template-designer .ant-select:hover .ant-select-selector,
.pdfme-template-designer .ant-input:hover,
.pdfme-template-designer .ant-input-affix-wrapper:hover {
    border-color: var(--theme-accent) !important;
    color: var(--theme-text) !important;
}

.pdfme-template-designer .ant-input:focus,
.pdfme-template-designer .ant-input-focused,
.pdfme-template-designer .ant-input-affix-wrapper-focused,
.pdfme-template-designer .ant-select-focused .ant-select-selector,
.pdfme-template-designer .ant-input-number-focused {
    border-color: var(--theme-accent) !important;
    box-shadow: 0 0 0 2px var(--theme-focus) !important;
}

.pdfme-template-designer .ant-dropdown,
.pdfme-template-designer .ant-dropdown-menu,
.pdfme-template-designer .ant-select-dropdown,
.pdfme-template-designer .ant-popover-inner,
.pdfme-template-designer .ant-tooltip-inner {
    background: var(--theme-surface-raised) !important;
    color: var(--theme-text) !important;
}

.pdfme-template-designer .ant-dropdown-menu-item,
.pdfme-template-designer .ant-select-item,
.pdfme-template-designer .ant-popover-inner-content {
    color: var(--theme-text) !important;
}

.pdfme-template-designer .ant-dropdown-menu-item:hover,
.pdfme-template-designer .ant-select-item-option-active,
.pdfme-template-designer .ant-select-item-option-selected {
    background: var(--theme-secondary) !important;
    color: var(--theme-text) !important;
}

.pdfme-template-designer .pdfme-designer-right-sidebar,
.pdfme-template-designer .pdfme-designer-left-sidebar,
.pdfme-template-designer .pdfme-designer-right-sidebar > div,
.pdfme-template-designer .pdfme-designer-right-sidebar .fr-form,
.pdfme-template-designer .pdfme-designer-right-sidebar .fr-field,
.pdfme-template-designer .pdfme-designer-right-sidebar .fr-panel-bordered,
.pdfme-template-designer .pdfme-designer-right-sidebar .fr-obj-card,
.pdfme-template-designer .pdfme-designer-right-sidebar .fr-obj-collapse,
.pdfme-template-designer .pdfme-designer-right-sidebar .fr-search {
    background: var(--theme-surface-raised) !important;
    color: var(--theme-text) !important;
}

.pdfme-template-designer .pdfme-designer-right-sidebar .fr-form,
.pdfme-template-designer .pdfme-designer-right-sidebar .fr-field,
.pdfme-template-designer .pdfme-designer-right-sidebar .fr-panel-bordered,
.pdfme-template-designer .pdfme-designer-right-sidebar .fr-obj-card,
.pdfme-template-designer .pdfme-designer-right-sidebar .fr-obj-collapse {
    border-color: var(--theme-border) !important;
}

.pdfme-template-designer .pdfme-designer-right-sidebar .fr-field,
.pdfme-template-designer .pdfme-designer-right-sidebar .fr-field label,
.pdfme-template-designer .pdfme-designer-right-sidebar .fr-field span,
.pdfme-template-designer .pdfme-designer-right-sidebar .fr-obj-header,
.pdfme-template-designer .pdfme-designer-right-sidebar .fr-header-title,
.pdfme-template-designer .pdfme-designer-right-sidebar .fr-obj-collapse .collapse-title,
.pdfme-template-designer .pdfme-designer-right-sidebar .fr-obj-collapse .header-item-label,
.pdfme-template-designer .pdfme-designer-right-sidebar .fr-obj-collapse .ant-collapse-header-text,
.pdfme-template-designer .pdfme-designer-right-sidebar .fr-obj-line-title,
.pdfme-template-designer .pdfme-designer-right-sidebar .fr-void-title,
.pdfme-template-designer .pdfme-designer-right-sidebar .ant-form-item-required {
    color: var(--theme-text) !important;
}

.pdfme-template-designer .pdfme-designer-right-sidebar .fr-desc,
.pdfme-template-designer .pdfme-designer-right-sidebar .fr-header-desc,
.pdfme-template-designer .pdfme-designer-right-sidebar .ant-form-item-extra,
.pdfme-template-designer .pdfme-designer-right-sidebar .ant-form-item-explain {
    color: var(--theme-muted) !important;
}

.pdfme-template-designer .pdfme-designer-right-sidebar .ant-form-item-required::before {
    color: var(--theme-danger-text) !important;
}

.pdfme-template-designer .pdfme-designer-right-sidebar button,
.pdfme-template-designer .pdfme-designer-right-sidebar button svg,
.pdfme-template-designer .pdfme-designer-right-sidebar .anticon,
.pdfme-template-designer .pdfme-designer-right-sidebar .anticon svg {
    color: var(--theme-text) !important;
    fill: currentColor !important;
}

.pdfme-template-designer .pdfme-designer-right-sidebar button:hover,
.pdfme-template-designer .pdfme-designer-right-sidebar button:hover svg {
    color: var(--theme-accent) !important;
}

.pdfme-template-designer .pdfme-designer-right-sidebar .fr-obj-collapse .ant-collapse-header,
.pdfme-template-designer .pdfme-designer-right-sidebar .fr-obj-collapse .ant-collapse-content,
.pdfme-template-designer .pdfme-designer-right-sidebar .fr-obj-collapse .ant-collapse-content-box,
.pdfme-template-designer .pdfme-designer-right-sidebar .fr-obj-subinline-background,
.pdfme-template-designer .pdfme-designer-right-sidebar .fr-list-simple-background {
    background: var(--theme-surface-raised) !important;
    color: var(--theme-text) !important;
}

.pdfme-template-designer .pdfme-designer-left-sidebar [class*="pdfme-designer-plugin-"] > div,
.pdfme-template-designer .pdfme-designer-left-sidebar [class*="pdfme-designer-plugin-"] > div svg,
.pdfme-template-designer .pdfme-designer-left-sidebar [class*="pdfme-designer-plugin-"] > div svg * {
    color: var(--theme-accent) !important;
    stroke: currentColor !important;
}

.pdfme-template-designer .pdfme-designer-left-sidebar [class*="pdfme-designer-plugin-"] > button {
    background: var(--theme-secondary) !important;
    border-color: var(--theme-border) !important;
    color: var(--theme-accent) !important;
}

.pdfme-template-designer .pdfme-designer-left-sidebar [class*="pdfme-designer-plugin-"] > button:hover {
    background: var(--theme-accent) !important;
    color: var(--theme-surface-raised) !important;
}

.pdfme-template-designer .pdfme-ui-control-bar {
    background: var(--theme-surface-raised) !important;
    border: 1px solid var(--theme-border) !important;
    box-shadow: 0 0.35rem 1rem var(--theme-shadow) !important;
}

.pdfme-template-designer .pdfme-ui-control-bar button,
.pdfme-template-designer .pdfme-ui-control-bar button svg,
.pdfme-template-designer .pdfme-ui-control-bar button svg * {
    color: var(--theme-accent) !important;
    stroke: currentColor !important;
}

.pdfme-template-designer .pdfme-ui-control-bar button:hover {
    background: var(--theme-secondary) !important;
}

.pdfme-template-designer .pdfme-ui-control-bar .ant-typography,
.pdfme-template-designer .pdfme-ui-control-bar span {
    color: var(--theme-text) !important;
}

.template-editor-page {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    width: 100%;
    max-width: none;
    margin: 0;
}

.template-editor-page .page-heading {
    max-width: none;
}

.template-editor-card {
    background: rgba(255, 255, 255, 0.92);
    border: 1px solid #dbe4f0;
    border-radius: 1.1rem;
    box-shadow: 0 18px 40px rgba(15, 23, 42, 0.06);
    padding: 1rem;
    width: 100%;
    box-sizing: border-box;
}

.template-editor-page .template-json-editor {
    height: calc(100vh - 16rem);
    min-height: 32rem;
}

.form-floating > .form-control-plaintext::placeholder, .form-floating > .form-control::placeholder {
    color: var(--bs-secondary-color);
    text-align: end;
}

.form-floating > .form-control-plaintext:focus::placeholder, .form-floating > .form-control:focus::placeholder {
    text-align: start;
}

html, body {
    height: 100%;
    background: var(--theme-page, #f5f7fb);
}

:root {
    --theme-page: #f5f7fb;
    --theme-surface: rgba(255, 255, 255, 0.92);
    --theme-surface-raised: #ffffff;
    --theme-border: #d7e0ec;
    --theme-text: #1f2937;
    --theme-muted: #6b7280;
    --theme-input: #ffffff;
    --theme-sidebar: #111827;
    --theme-sidebar-text: #e5e7eb;
    --theme-sidebar-active: #2563eb;
    --theme-sidebar-glow: rgba(37, 99, 235, 0.28);
    --theme-primary: #1d4ed8;
    --theme-primary-text: #ffffff;
    --theme-secondary: #e5eefc;
    --theme-secondary-text: #1d4ed8;
    --theme-danger: #fee2e2;
    --theme-danger-text: #b91c1c;
    --theme-accent: #2563eb;
    --theme-focus: rgba(37, 99, 235, 0.12);
    --theme-code: #c02d76;
    --theme-shadow: rgba(15, 23, 42, 0.06);
}

body {
    margin: 0;
    background: var(--theme-page);
    color: var(--theme-text);
}

#app {
    min-height: 100vh;
}

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

.sidebar {
    width: 16rem;
    padding: 1.5rem 1rem;
    background: #111827;
    color: #f9fafb;
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
    position: sticky;
    top: 0;
    height: 100vh;
    box-sizing: border-box;
    box-shadow: 7px 0 16px -6px rgba(15, 23, 42, 0.36);
}

.mobile-menu-toggle,
.mobile-menu-backdrop {
    display: none;
}

.sidebar-brand {
    align-items: center;
    color: inherit;
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
    text-align: center;
    text-decoration: none;
}

.sidebar-brand:focus-visible {
    border-radius: 0.75rem;
    outline: 2px solid var(--theme-accent);
    outline-offset: 0.35rem;
}

.sidebar-brand-name {
    font-family: "Trebuchet MS", "Segoe UI", sans-serif;
    font-size: 1.3rem;
    font-weight: 700;
    letter-spacing: 0.01em;
}

.sidebar-brand-version {
    font-size: 0.75rem;
    margin-top: -0.1rem;
}

.sidebar-nav {
    display: flex;
    flex-direction: column;
    flex: 1;
    gap: 0.75rem;
}

.sidebar-version {
    margin-top: auto;
}

.sidebar-nav-divider {
    border-top: 1px solid var(--theme-border);
    margin: 0.25rem 0;
}

.sidebar-logo {
    border-radius: 1.1rem;
    height: 5.5rem;
    object-fit: contain;
    width: 5.5rem;
    filter: drop-shadow(0 0 0.4rem var(--theme-sidebar-glow));
}

.sidebar-link {
    align-items: center;
    display: flex;
    gap: 0.7rem;
    padding: 0.85rem 1rem;
    border-radius: 0.75rem;
    color: #e5e7eb;
    text-decoration: none;
    background: rgba(255, 255, 255, 0.04);
    transition: background-color 0.15s ease, color 0.15s ease;
}

.nav-icon {
    fill: none;
    flex: 0 0 1.2rem;
    height: 1.2rem;
    stroke: currentColor;
    stroke-linecap: round;
    stroke-linejoin: round;
    stroke-width: 1.8;
    width: 1.2rem;
}

.sidebar-link.active {
    background: #2563eb;
    color: #ffffff;
}

.sidebar-link-main {
    background: rgba(255, 255, 255, 0.04);
    color: #e5e7eb;
    box-shadow: none;
}

.sidebar-link-main.active {
    background: #2563eb;
    color: #ffffff;
    box-shadow: 0 8px 18px rgba(37, 99, 235, 0.28);
}

.sidebar-support-link {
    align-items: center;
    border: 1px solid color-mix(in srgb, var(--theme-sidebar-text) 22%, transparent);
    border-radius: 0.65rem;
    color: var(--theme-sidebar-text);
    display: flex;
    font-size: 0.85rem;
    gap: 0.55rem;
    margin-top: 1rem;
    padding: 0.65rem 0.8rem;
    text-decoration: none;
    transition: background-color 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}

.sidebar-support-link:hover,
.sidebar-support-link:focus-visible {
    background: var(--theme-sidebar-active);
    border-color: var(--theme-sidebar-active);
    color: var(--theme-sidebar-text);
}

.sidebar-support-link:focus-visible {
    outline: 2px solid var(--theme-accent);
    outline-offset: 2px;
}

@media (hover: hover) and (pointer: fine) {
    .sidebar-link:hover,
    .sidebar-link-main:hover {
        background: #2563eb;
        color: #ffffff;
    }

    .sidebar-link-main.active:hover {
        background: #1d4ed8;
        color: #ffffff;
    }
}

.customer-page {
    box-sizing: border-box;
    display: flex;
    flex-direction: column;
    height: calc(100vh - 4rem);
    margin-inline: auto;
    max-width: 1000px;
    overflow: hidden;
    width: 100%;
}

.customer-hero {
    align-items: end;
    display: flex;
    gap: 1.5rem;
    justify-content: space-between;
    margin-bottom: 1.25rem;
}

.customer-hero-actions {
    align-items: center;
    display: flex;
    gap: 0.65rem;
}

.customer-layout {
    display: grid;
    gap: 1.25rem;
    grid-template-columns: minmax(0, 1.1fr) minmax(320px, 0.9fr);
    margin-top: 1.25rem;
}

.customer-list {
    display: grid;
    gap: 0.75rem;
}

.customer-list-card {
    display: flex;
    flex-direction: column;
    flex: 1 1 auto;
    min-height: 0;
    max-height: calc(100vh - 10rem);
    max-width: none;
    margin-inline: auto;
    width: 100%;
}

.customer-search-card {
    margin-inline: auto;
    max-width: none;
    width: 100%;
}

.customer-list-card .customer-list {
    flex: 1 1 auto;
    min-height: 0;
    overflow-y: auto;
}

.customer-list-item {
    align-items: center;
    border: 1px solid #d7e0ec;
    border-radius: 0.8rem;
    cursor: pointer;
    display: flex;
    gap: 0.75rem;
    justify-content: space-between;
    padding: 0.7rem 0.85rem;
    transition: background-color 120ms ease;
}

.customer-list-item:hover {
    background-color: var(--theme-surface-raised);
}

.customer-list-item:focus-visible {
    outline: 2px solid var(--theme-accent, #2563eb);
    outline-offset: 2px;
}

.customer-list-item div:first-child {
    display: grid;
    gap: 0.1rem;
}

.customer-list-item-removing {
    animation: customer-list-item-remove 180ms ease-in forwards;
    pointer-events: none;
}

@keyframes customer-list-item-remove {
    to {
        opacity: 0;
        transform: translateX(1rem);
    }
}

.customer-list-item span,
.customer-list-item small,
.customer-count,
.empty-state {
    color: #6b7280;
}

.customer-list-actions,
.customer-form-actions,
.customer-picker-controls {
    align-items: center;
    display: flex;
    gap: 0.65rem;
}

.customer-picker {
    display: grid;
    gap: 0.75rem;
    margin-bottom: 1rem;
}

.customer-add-actions {
    display: flex;
    justify-content: flex-end;
    margin-top: 1rem;
}

.customer-add-button {
    align-items: center;
    display: inline-flex;
    height: 2.75rem;
    justify-content: center;
    padding: 0;
    width: 3.25rem;
}

.customer-add-icon {
    fill: none;
    height: 1.75rem;
    stroke: currentColor;
    stroke-linecap: round;
    stroke-linejoin: round;
    stroke-width: 1.8;
    width: 2.1rem;
}

.customer-new-button,
.settings-save-button {
    bottom: max(1.25rem, env(safe-area-inset-bottom));
    position: fixed;
    right: max(1.25rem, env(safe-area-inset-right));
    z-index: 5;
}

.customer-dialog-backdrop {
    align-items: center;
    background: rgba(17, 24, 39, 0.45);
    display: flex;
    inset: 0;
    justify-content: center;
    padding: 1rem;
    position: fixed;
    z-index: 20;
}

.customer-dialog {
    background: #ffffff;
    border-radius: 1rem;
    box-shadow: 0 1.5rem 4rem rgba(17, 24, 39, 0.25);
    display: flex;
    flex-direction: column;
    max-height: min(680px, 90vh);
    max-width: 620px;
    overflow: hidden;
    padding: 1.5rem;
    width: 100%;
}

.customer-edit-dialog {
    max-width: 760px;
}

.customer-dialog h3 {
    margin: 0;
}

.customer-dialog .customer-search {
    flex: 0 0 auto;
}

.customer-dialog-list {
    display: grid;
    flex: 1 1 auto;
    gap: 0.65rem;
    min-height: 0;
    margin-top: 1rem;
    overflow-y: auto;
}

.customer-picker-limit {
    color: var(--theme-muted, #6b7280);
    flex: 0 0 auto;
    font-size: 0.85rem;
    margin: 0.75rem 0 0;
}

.customer-dialog-item {
    background: #ffffff;
    border: 1px solid #d7e0ec;
    border-radius: 0.75rem;
    cursor: pointer;
    display: grid;
    gap: 0.2rem;
    padding: 0.8rem 1rem;
    text-align: left;
    width: 100%;
}

.customer-dialog-item:hover {
    border-color: #2563eb;
    background: #eff6ff;
}

.customer-dialog-item span,
.customer-dialog-item small {
    color: #6b7280;
}

.customer-picker-controls .field-input {
    max-width: 360px;
}

.customer-form-actions {
    justify-content: space-between;
    margin-top: 1.25rem;
}

.main-content {
    flex: 1;
    padding: 2rem;
    min-width: 0;
}

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

    .mobile-menu-toggle {
        align-items: center;
        background: var(--theme-sidebar);
        border: 1px solid var(--theme-border);
        border-radius: 0.65rem;
        color: var(--theme-sidebar-text);
        cursor: pointer;
        display: inline-flex;
        font: inherit;
        gap: 0.5rem;
        margin: 0.75rem;
        padding: 0.7rem 0.85rem;
        position: relative;
        text-align: left;
        width: fit-content;
        z-index: 2002;
    }

    .mobile-menu-toggle:focus-visible {
        outline: 2px solid var(--theme-accent);
        outline-offset: 2px;
    }

    .mobile-menu-icon {
        font-size: 1.15rem;
        line-height: 1;
    }

    .sidebar {
        display: none;
        height: auto;
        left: 0;
        padding: 1rem;
        position: absolute;
        right: 0;
        top: 4.25rem;
        width: auto;
        z-index: 2001;
    }

    .sidebar.sidebar-open {
        display: flex;
    }

    .sidebar-version {
        display: none;
    }

    .mobile-menu-backdrop-open {
        background: var(--theme-shadow);
        display: block;
        inset: 0;
        position: fixed;
        box-shadow: none;
        z-index: 2000;
    }
}

/* Shared component palette. Themes only provide the variables above. */
[data-theme] {
    background-color: var(--theme-page);
    color: var(--theme-text);
}

[data-theme] .sidebar {
    background: var(--theme-sidebar);
    color: var(--theme-sidebar-text);
}

[data-theme] .sidebar-link,
[data-theme] .sidebar-link-main { color: var(--theme-sidebar-text); }

[data-theme] .invoice-card,
[data-theme] .settings-card,
[data-theme] .template-editor-card,
[data-theme] .customer-dialog,
[data-theme] .settings-dialog,
[data-theme] .info-popover-panel {
    background: var(--theme-surface);
    border-color: var(--theme-border);
    color: var(--theme-text);
    box-shadow: 0 18px 40px var(--theme-shadow);
}

[data-theme] .field span,
[data-theme] .info-popover-panel strong,
[data-theme] .line-table th { color: var(--theme-text); }

[data-theme] .invoice-lead,
[data-theme] .section-header p,
[data-theme] .customer-list-item span,
[data-theme] .customer-list-item small,
[data-theme] .customer-count,
 [data-theme] .empty-state,
 [data-theme] .image-file-name,
 [data-theme] .app-version,
[data-theme] .date-difference,
[data-theme] .totals-row-sub { color: var(--theme-muted); }

[data-theme] .field-input,
[data-theme] .date-picker-control,
[data-theme] .date-picker-control.form-control,
[data-theme] .date-picker-control .form-control,
[data-theme] .date-picker-control input {
    background: var(--theme-input);
    border-color: var(--theme-border);
    color: var(--theme-text);
}

[data-theme] .field-input:focus {
    border-color: var(--theme-accent);
    box-shadow: 0 0 0 4px var(--theme-focus);
}

.theme-picker { position: relative; }
.theme-picker-toggle { align-items: center; display: flex; justify-content: space-between; text-align: left; width: 100%; }
.theme-picker-chevron { color: var(--theme-muted); font-size: 1.1rem; line-height: 1; }
.theme-picker-menu {
    background: var(--theme-surface-raised);
    border: 1px solid var(--theme-border);
    border-radius: 0.45rem;
    box-shadow: 0 0.6rem 1.4rem var(--theme-shadow);
    left: 0;
    margin-top: 0.3rem;
    max-height: 18rem;
    overflow-y: auto;
    padding: 0.25rem;
    position: absolute;
    right: 0;
    z-index: 20;
}
.theme-picker-option {
    align-items: center;
    background: transparent;
    border: 0;
    border-radius: 0.3rem;
    color: var(--theme-text);
    cursor: pointer;
    display: flex;
    font: inherit;
    justify-content: space-between;
    padding: 0.55rem 0.7rem;
    text-align: left;
    width: 100%;
}
.theme-picker-option:hover,
.theme-picker-option:focus-visible,
.theme-picker-option.is-highlighted { background: var(--theme-secondary); color: var(--theme-text); outline: none; }
.theme-picker-option.is-selected { color: var(--theme-accent); font-weight: 600; }

[data-theme] .customer-list-item,
[data-theme] .customer-dialog-item,
[data-theme] .line-table th,
[data-theme] .line-table td,
 [data-theme] .settings-image-section,
[data-theme] .invoice-image-preview img { border-color: var(--theme-border); }

[data-theme] .customer-dialog-item {
    background: var(--theme-surface-raised);
    color: var(--theme-text);
}

[data-theme] .customer-dialog-item:hover,
[data-theme] .sidebar-link.active,
[data-theme] .sidebar-link-main.active { background: var(--theme-sidebar-active); color: #ffffff; }

@media (hover: hover) and (pointer: fine) {
    [data-theme] .sidebar-link:hover,
    [data-theme] .sidebar-link-main.active:hover { background: var(--theme-sidebar-active); color: #ffffff; }
}

[data-theme] .sidebar-link-main.active {
    box-shadow: 0 8px 18px var(--theme-sidebar-glow);
}

[data-theme] .primary-button,
[data-theme] .add-button,
[data-theme] .invoice-page .add-button,
[data-theme] .invoice-page .invoice-actions-row .primary-button,
[data-theme] .invoice-page .invoice-hero-actions .primary-button {
    background: var(--theme-primary);
    box-shadow: 0 10px 18px var(--theme-focus);
    color: #ffffff;
}

[data-theme] .add-button,
[data-theme] .invoice-page .add-button {
    box-shadow: none;
}

[data-theme] .secondary-button,
[data-theme] .invoice-page .secondary-button {
    background: var(--theme-secondary);
    color: var(--theme-secondary-text);
}

[data-theme] .danger-button { background: var(--theme-danger); color: var(--theme-danger-text); }
[data-theme] .info-popover-button { background: var(--theme-secondary); border-color: var(--theme-border); color: var(--theme-secondary-text); }
[data-theme] .info-popover-button:hover,
[data-theme] .info-popover-button:focus-visible {
    background: var(--theme-primary);
    border-color: var(--theme-accent);
    color: var(--theme-text);
    outline-color: var(--theme-focus);
}
[data-theme] .invoice-eyebrow,
[data-theme] .section-header .invoice-eyebrow { color: var(--theme-accent); }
[data-theme] .settings-danger-zone { border-color: var(--theme-danger-text); }
[data-theme] code { color: var(--theme-code); }

[data-theme] .invoice-loading-spinner {
    border-color: var(--theme-border);
    border-top-color: var(--theme-primary);
    box-shadow: 0 0 0 6px var(--theme-focus);
}

[data-theme] .invoice-loading-label {
    color: var(--theme-text);
}

/* Datepicker follows the active application theme instead of Bootstrap's palette. */
[data-theme] .datepicker .datepicker-calendar.dropdown-menu {
    color: var(--theme-text);
    background: var(--theme-surface-raised);
    border-color: var(--theme-border);
    box-shadow: 0 0.75rem 1.75rem var(--theme-shadow);
}

[data-theme] .datepicker .datepicker-navigation:hover:not(:disabled),
[data-theme] .datepicker .datepicker-navigation:focus-visible,
[data-theme] .datepicker .datepicker-day:hover:not(:disabled),
[data-theme] .datepicker .datepicker-month:hover:not(:disabled),
[data-theme] .datepicker .datepicker-time .datepicker-button:hover:not(:disabled),
[data-theme] .datepicker .datepicker-time .datepicker-button:focus-visible,
[data-theme] .datepicker .datepicker-actions .datepicker-button:hover:not(:disabled),
[data-theme] .datepicker .datepicker-actions .datepicker-button:focus-visible,
[data-theme] .datepicker .datepicker-time-input:hover:not(:disabled),
[data-theme] .datepicker .datepicker-time-input:focus {
    background: var(--theme-focus);
}

[data-theme] .datepicker .datepicker-title select,
[data-theme] .datepicker .datepicker-title input,
[data-theme] .datepicker .datepicker-title > button,
[data-theme] .datepicker .datepicker-title > span,
[data-theme] .datepicker .datepicker-navigation,
[data-theme] .datepicker .datepicker-day,
[data-theme] .datepicker .datepicker-month,
[data-theme] .datepicker .datepicker-time > span,
[data-theme] .datepicker .datepicker-time .datepicker-button,
[data-theme] .datepicker .datepicker-actions .datepicker-button,
[data-theme] .datepicker .datepicker-time-input {
    color: var(--theme-text);
}

[data-theme] .datepicker .datepicker-title select,
[data-theme] .datepicker .datepicker-title select option {
    background-color: var(--theme-input);
    color: var(--theme-text);
}

[data-theme] .datepicker .datepicker-weekday,
[data-theme] .datepicker .datepicker-week-number,
[data-theme] .datepicker .datepicker-time-input:disabled {
    color: var(--theme-muted);
}

[data-theme] .datepicker .datepicker-day-outside {
    color: var(--theme-muted);
    opacity: 0.55;
}

[data-theme] .datepicker .datepicker-day-today {
    border-color: var(--theme-accent);
}

[data-theme] .datepicker .datepicker-day-in-range {
    background: var(--theme-secondary);
}

[data-theme] .datepicker .datepicker-day-selected,
[data-theme] .datepicker .datepicker-day-range-start,
[data-theme] .datepicker .datepicker-day-range-end,
[data-theme] .datepicker .datepicker-month-selected,
[data-theme] .datepicker .datepicker-calendar[data-week-mode=true] .datepicker-week[data-week-fully-selected=true],
[data-theme] .datepicker .datepicker-calendar[data-week-mode=true] .datepicker-week[data-week-selected=true] .datepicker-week-number {
    color: var(--theme-text);
    background: var(--theme-primary);
    border-color: var(--theme-primary);
}

[data-theme] .datepicker .datepicker-day-focused,
[data-theme] .datepicker .datepicker-month-focused {
    box-shadow: 0 0 0 0.25rem var(--theme-focus);
}

[data-theme] .datepicker .datepicker-time,
[data-theme] .datepicker .datepicker-actions {
    border-block-start-color: var(--theme-border);
}

.invoice-page {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    max-width: 1280px;
    margin-inline: auto;
    padding-bottom: 6.5rem;
    width: 100%;
}

.invoice-page > .invoice-hero {
    margin-bottom: -1rem;
}

.invoice-pdf-button {
    bottom: max(1.25rem, env(safe-area-inset-bottom));
    position: fixed;
    right: max(1.25rem, env(safe-area-inset-right));
    z-index: 5;
}

.invoice-loading-state {
    align-items: center;
    display: flex;
    flex-direction: column;
    gap: 1rem;
    justify-content: center;
    min-height: calc(100vh - 4rem);
    text-align: center;
}

.invoice-pdf-loading-overlay {
    align-items: center;
    background: rgba(107, 114, 128, 0.45);
    display: flex;
    flex-direction: column;
    gap: 1rem;
    inset: 0;
    justify-content: center;
    position: fixed;
    z-index: 1000;
}

.invoice-loading-spinner {
    animation: invoice-loading-spin 0.9s linear infinite;
    border: 4px solid #dbe4f0;
    border-radius: 50%;
    border-top-color: #2563eb;
    box-shadow: 0 0 0 6px rgba(37, 99, 235, 0.06);
    display: block;
    height: 3rem;
    width: 3rem;
}

.invoice-loading-label {
    color: #475569;
    font-size: 0.95rem;
    font-weight: 600;
}

@keyframes invoice-loading-spin {
    to {
        transform: rotate(360deg);
    }
}

@media (prefers-reduced-motion: reduce) {
    .invoice-loading-spinner {
        animation-duration: 1.8s;
    }
}

.invoice-hero {
    display: flex;
    align-items: end;
    justify-content: space-between;
    gap: 1rem;
    padding: 0.5rem 0 0.25rem;
}

.invoice-hero-actions {
    display: flex;
    align-items: flex-start;
    gap: 0.75rem;
}

.invoice-eyebrow {
    margin: 0 0 0.4rem;
    text-transform: uppercase;
    letter-spacing: 0.14em;
    font-size: 0.78rem;
    color: #2563eb;
    font-weight: 700;
}

.invoice-hero h1 {
    margin: 0;
    font-size: clamp(2rem, 3vw, 3rem);
    line-height: 1.05;
}

.invoice-lead {
    margin: 0.65rem 0 0;
    max-width: 56rem;
    color: #4b5563;
}

.landing-page {
    display: flex;
    flex-direction: column;
    gap: 2rem;
    margin: 0 auto;
    max-width: 1100px;
}

.landing-hero {
    background: var(--theme-surface);
    border: 1px solid var(--theme-border);
    border-radius: 1.25rem;
    box-shadow: 0 18px 40px var(--theme-shadow);
    padding: clamp(1.5rem, 5vw, 4rem);
}

.landing-hero h1 {
    color: var(--theme-text);
    font-size: clamp(2rem, 5vw, 3.7rem);
    line-height: 1.05;
    margin: 0;
    max-width: 800px;
}

.landing-lead {
    color: var(--theme-muted);
    font-size: clamp(1.05rem, 2vw, 1.3rem);
    line-height: 1.6;
    margin: 1rem 0 1.5rem;
    max-width: 700px;
}

.landing-start-button {
    display: inline-block;
    text-decoration: none;
}

.landing-features {
    display: grid;
    gap: 1rem;
    grid-template-columns: repeat(3, minmax(0, 1fr));
}

.landing-card,
.landing-details {
    background: var(--theme-surface);
    border: 1px solid var(--theme-border);
    border-radius: 1rem;
    box-shadow: 0 12px 28px var(--theme-shadow);
    padding: 1.25rem;
}

.landing-card h2,
.landing-details h2 {
    color: var(--theme-text);
    font-size: 1.2rem;
    margin: 0 0 0.6rem;
}

.landing-card p,
.landing-details p {
    color: var(--theme-muted);
    line-height: 1.6;
    margin: 0;
}

.landing-details {
    max-width: 800px;
}

.landing-details p + p {
    margin-top: 0.8rem;
}

.landing-details a,
.landing-secondary-link a {
    color: var(--theme-primary);
    font-weight: 700;
}

.landing-secondary-link {
    margin-top: 1rem !important;
}

@media (max-width: 720px) {
    .landing-page {
        gap: 1rem;
    }

    .landing-features {
        grid-template-columns: 1fr;
    }
}

.invoice-card {
    background: rgba(255, 255, 255, 0.92);
    border: 1px solid #dbe4f0;
    border-radius: 1.1rem;
    box-shadow: 0 18px 40px rgba(15, 23, 42, 0.06);
    padding: 1.25rem;
}

.settings-page {
    display: flex;
    flex-direction: column;
    gap: 1.25rem;
    max-width: 1000px;
    margin-inline: auto;
    width: 100%;
}

.settings-card {
    background: rgba(255, 255, 255, 0.92);
    border: 1px solid #dbe4f0;
    border-radius: 1.1rem;
    box-shadow: 0 18px 40px rgba(15, 23, 42, 0.06);
    padding: 1.25rem;
}

.settings-vat-card {
    box-sizing: border-box;
    width: 50%;
}

.settings-actions {
    align-items: center;
    display: flex;
    gap: 1rem;
    margin-top: 1.25rem;
}

.settings-subsections {
    display: grid;
    gap: 1.25rem;
}

.settings-subsection + .settings-subsection {
    border-top: 1px solid var(--theme-border);
    padding-top: 1.25rem;
}

.settings-subsection-heading h3 {
    margin: 0;
}

.settings-subsection-heading p,
.settings-template-card .section-header p {
    color: var(--theme-muted);
    margin: 0.25rem 0 0;
}

.settings-template-card .section-header {
    align-items: start;
}

.settings-template-actions {
    align-items: center;
    display: flex;
    gap: 0.65rem;
}

.settings-icon-button {
    align-items: center;
    cursor: pointer;
    display: inline-flex;
    height: 2.45rem;
    justify-content: center;
    padding: 0;
    width: 3rem;
}

.settings-icon-button svg {
    fill: none;
    height: 1.6rem;
    stroke: currentColor;
    stroke-linecap: round;
    stroke-linejoin: round;
    stroke-width: 1.8;
    width: 1.6rem;
}

.template-library-delete svg {
    fill: none;
    height: 1.2rem;
    stroke: currentColor;
    stroke-linecap: round;
    stroke-linejoin: round;
    stroke-width: 1.8;
    width: 1.2rem;
}

.settings-template-error {
    margin: 0 0 1rem;
    position: static;
}

.template-library-layout {
    display: grid;
    gap: 1.25rem;
    grid-template-columns: minmax(14rem, 0.78fr) minmax(0, 1.22fr);
    margin-top: 1.25rem;
}

.template-library-list {
    display: grid;
    gap: 0.55rem;
    align-content: start;
}

.template-library-item {
    align-items: center;
    background: var(--theme-surface-raised);
    border: 1px solid var(--theme-border);
    border-radius: 0.7rem;
    color: var(--theme-text);
    cursor: pointer;
    display: flex;
    gap: 0.65rem;
    justify-content: space-between;
    min-height: 3.6rem;
    padding: 0.7rem 0.75rem;
    text-align: left;
    transition: border-color 120ms ease, background-color 120ms ease, box-shadow 120ms ease;
}

.template-library-item:hover,
.template-library-item-selected {
    border-color: var(--theme-accent);
}

.template-library-item-selected {
    box-shadow: 0 0 0 1px var(--theme-accent);
}

.template-library-item-active {
    background: var(--theme-secondary);
}

.template-library-item-main {
    align-items: center;
    display: flex;
    gap: 0.65rem;
    min-width: 0;
}

.template-library-check {
    align-items: center;
    border: 1px solid var(--theme-border);
    border-radius: 50%;
    color: var(--theme-accent);
    display: inline-flex;
    flex: 0 0 1.35rem;
    height: 1.35rem;
    justify-content: center;
    width: 1.35rem;
}

.template-library-check-visible {
    border-color: var(--theme-accent);
}

.template-library-check svg {
    fill: none;
    height: 1rem;
    stroke: currentColor;
    stroke-linecap: round;
    stroke-linejoin: round;
    stroke-width: 2.4;
    width: 1rem;
}

.template-library-item-copy {
    display: grid;
    gap: 0.15rem;
    min-width: 0;
}

.template-library-item-copy strong,
.template-library-item-meta {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.template-library-item-meta {
    color: var(--theme-muted);
    font-size: 0.78rem;
}

.template-library-delete {
    align-items: center;
    background: transparent;
    border: 0;
    border-radius: 0.45rem;
    color: var(--theme-danger-text);
    cursor: pointer;
    display: inline-flex;
    flex: 0 0 auto;
    justify-content: center;
    padding: 0.35rem;
}

.template-library-delete:hover,
.template-library-delete:focus-visible {
    background: var(--theme-danger);
}

.template-library-details {
    background: var(--theme-surface-raised);
    border: 1px solid var(--theme-border);
    border-radius: 0.8rem;
    display: grid;
    gap: 1rem;
    grid-template-columns: minmax(10rem, 0.72fr) minmax(0, 1fr);
    min-width: 0;
    padding: 1rem;
}

.template-library-preview {
    align-items: center;
    background: var(--theme-input);
    border: 1px solid var(--theme-border);
    border-radius: 0.55rem;
    display: flex;
    justify-content: center;
    min-height: 15rem;
    overflow: hidden;
}

.template-library-preview img {
    display: block;
    height: auto;
    max-height: 26rem;
    max-width: 100%;
    object-fit: contain;
    width: 100%;
}

.template-library-preview-empty {
    color: var(--theme-muted);
    font-size: 0.85rem;
    padding: 1rem;
    text-align: center;
}

.template-library-details-copy h3 {
    margin: 0;
}

.template-library-details-copy > p {
    color: var(--theme-muted);
    line-height: 1.45;
    margin: 0.45rem 0 1rem;
}

.template-library-facts {
    display: grid;
    gap: 0.55rem;
    margin: 0;
}

.template-library-facts div {
    display: flex;
    gap: 0.75rem;
    justify-content: space-between;
}

.template-library-facts dt {
    color: var(--theme-muted);
}

.template-library-facts dd {
    font-weight: 600;
    margin: 0;
    text-align: right;
}

.template-library-apply {
    margin-top: 1.25rem;
    width: 100%;
}

.settings-image-section {
    border-top: 1px solid #dbe4f0;
    margin-top: 1.25rem;
    padding-top: 1.25rem;
}

.settings-image-section h3,
.settings-image-section p {
    margin-top: 0;
}

@media (max-width: 640px) {
    .company-brand-text-layout { grid-template-columns: 1fr; }
    .company-brand-fallback { grid-template-columns: 1fr; }
}

.validation-hint {
    background: var(--theme-input);
    border-inline-start: 1px solid var(--theme-danger-text);
    color: var(--theme-danger-text);
    font-size: 0.72rem;
    font-weight: 600;
    line-height: 1;
    max-width: calc(100% - 1rem);
    overflow: hidden;
    padding-inline-start: 0.3rem;
    pointer-events: none;
    position: absolute;
    right: 0.75rem;
    text-overflow: ellipsis;
    top: 50%;
    transform: translateY(-50%);
    white-space: nowrap;
}

.settings-saved {
    color: #15803d;
    font-weight: 600;
}

.settings-toast {
    animation: settings-toast-in 180ms ease-out;
    background: var(--theme-secondary, #e5eefc);
    border: 1px solid var(--theme-accent, #2563eb);
    border-radius: 0.7rem;
    box-shadow: 0 12px 28px var(--theme-shadow, rgba(15, 23, 42, 0.18));
    color: var(--theme-secondary-text, #1d4ed8);
    font-weight: 600;
    left: 50%;
    max-width: calc(100vw - 2rem);
    padding: 1rem 1.5rem;
    position: fixed;
    top: max(1rem, env(safe-area-inset-top));
    transform: translateX(-50%);
    z-index: 1050;
}

@keyframes settings-toast-in {
    from { opacity: 0; transform: translate(-50%, -0.5rem); }
    to { opacity: 1; transform: translate(-50%, 0); }
}

.settings-toast.is-closing {
    animation: settings-toast-out 180ms ease-in forwards;
}

@keyframes settings-toast-out {
    from { opacity: 1; transform: translate(-50%, 0); }
    to { opacity: 0; transform: translate(-50%, -0.5rem); }
}

@media (max-width: 720px) {
    .settings-toast {
        left: 50%;
        text-align: center;
    }
}

.settings-danger-zone {
    border-color: #fecaca;
}

.app-version {
    color: #6b7280;
    font-size: 0.75rem;
    margin: 0;
    text-align: center;
}

.settings-dialog-backdrop {
    align-items: center;
    background: rgba(15, 23, 42, 0.45);
    display: flex;
    inset: 0;
    justify-content: center;
    padding: 1rem;
    position: fixed;
    z-index: 1100;
}

.settings-dialog {
    background: #ffffff;
    border-radius: 1rem;
    box-shadow: 0 20px 50px rgba(15, 23, 42, 0.2);
    max-width: 30rem;
    padding: 1.5rem;
    width: 100%;
}

.settings-dialog h2 {
    margin-top: 0;
}

.settings-dialog-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
    justify-content: space-between;
    margin-top: 1.5rem;
}

[data-theme] .settings-navigation-dialog .settings-dialog-cancel {
    background: var(--theme-muted);
    color: var(--theme-surface-raised);
}

[data-theme] .settings-navigation-dialog .settings-dialog-leave {
    background: var(--theme-danger-text);
    color: var(--theme-surface-raised);
}

.invoice-image-upload {
    display: grid;
    gap: 0.5rem;
}

.image-file-picker {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    flex-wrap: wrap;
    justify-content: center;
}

.image-file-input {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0 0 0 0);
    white-space: nowrap;
}

.image-file-label {
    display: inline-block;
}

.image-file-name {
    color: #6b7280;
}

.invoice-image-preview {
    align-items: center;
    display: flex;
    gap: 1rem;
    justify-content: center;
}

.invoice-image-preview img {
    border: 1px solid var(--border-color, #d7e0ec);
    height: 216px;
    max-width: 100%;
    object-fit: contain;
    padding: 0.25rem;
    width: 432px;
}

.section-header {
    display: flex;
    align-items: start;
    justify-content: space-between;
    gap: 1rem;
    margin-block-end: 10px;
    position: relative;
}

.section-header > .section-actions,
.section-header > .clear-button,
.section-header > .default-button,
.section-header > button {
    inset-block-start: 0;
    inset-inline-end: 0;
    position: absolute;
}

.section-header:has(> .section-actions),
.section-header:has(> .clear-button),
.section-header:has(> .default-button),
.section-header:has(> button) {
    padding-inline-end: 6rem;
}

.section-header h2 {
    margin: 0;
    font-size: 1.15rem;
}

.section-header p {
    margin: 0.3rem 0 0;
    color: #6b7280;
}

.section-actions {
    display: flex;
    gap: 0.5rem;
    align-items: center;
}

.invoice-columns {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 1.25rem;
}

.invoice-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0.95rem;
    margin-left: 10px;
    margin-right: 10px;
}

.invoice-grid-meta {
    grid-template-columns: repeat(4, minmax(0, 1fr));
}

.field {
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
    min-width: 0;
}

.template-checkbox-field {
    align-items: center;
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.template-checkbox-field input[type="checkbox"] {
    flex: 0 0 auto;
    margin: 0;
}

.template-checkbox-field small {
    flex-basis: 100%;
    margin-left: 1.35rem;
}

.field-wide {
    grid-column: span 2;
}

.field-reference {
    grid-column: auto;
}

.field-business-id {
    max-width: 18rem;
}

.template-field-textarea {
    min-height: 7rem;
    resize: vertical;
}

.field span {
    font-size: 0.92rem;
    font-weight: 600;
    color: #374151;
}

.field-label-with-info {
    align-items: center;
    display: inline-flex !important;
    gap: 0.4rem;
}

.invoice-template-details-card .field-label-with-info {
    align-items: flex-end;
    display: flex !important;
    line-height: 1.35;
    max-width: 100%;
    min-width: 0;
    min-height: 2lh;
}

.invoice-template-details-card .field-label-text {
    min-width: 0;
    overflow-wrap: anywhere;
}

.info-popover {
    flex: 0 0 1.2rem;
    display: inline-flex;
    height: 1.2rem;
    position: relative;
    width: 1.2rem;
}

.invoice-page .invoice-lines-card {
    order: 0;
}

.field .info-popover {
    display: inline-flex;
}

.info-popover-button {
    align-items: center;
    background: #e8eef8;
    border: 1px solid #c9d6e8;
    border-radius: 50%;
    box-sizing: border-box;
    color: #31547d;
    cursor: pointer;
    display: inline-flex;
    flex: 0 0 1.2rem;
    font-family: inherit;
    font-size: 0.72rem;
    font-weight: 700;
    height: 1.2rem;
    justify-content: center;
    line-height: 1;
    padding: 0;
    min-width: 1.2rem;
    max-width: 1.2rem;
    width: 1.2rem;
}

.info-popover-button:hover,
.info-popover-button:focus-visible {
    background: #dbe7f6;
    border-color: #8da9cb;
    outline: 2px solid rgba(49, 84, 125, 0.25);
    outline-offset: 2px;
}

.field .info-popover-button span {
    color: inherit;
    display: inline;
    font-size: inherit;
    font-weight: inherit;
}

.info-popover-panel {
    background: #ffffff;
    border: 1px solid #d5dfec;
    border-radius: 0.75rem;
    box-shadow: 0 14px 28px rgba(15, 23, 42, 0.14);
    color: #374151;
    display: block;
    font-size: 0.85rem;
    font-weight: 400;
    left: 0;
    line-height: 1.5;
    opacity: 0;
    padding: 0.85rem 1rem;
    pointer-events: none;
    position: absolute;
    top: calc(100% + 0.55rem);
    transform: translateY(-0.25rem);
    transition: opacity 180ms ease, transform 180ms ease;
    width: min(23rem, calc(100vw - 3rem));
    z-index: 20;
}

@media (max-width: 720px) {
    .main-content,
    .settings-page,
    .invoice-page {
        overflow-x: clip;
    }

    .settings-page {
        padding-bottom: 4.5rem;
    }

    .invoice-page {
        padding-bottom: 6.5rem;
    }

    .customer-list-card {
        max-height: calc(100vh - 13rem);
    }

    .customer-new-button,
    .settings-save-button {
        bottom: max(1rem, env(safe-area-inset-bottom));
        right: 0.75rem;
    }

    .info-popover-panel {
        box-sizing: border-box;
        max-width: calc(100vw - 1.5rem);
    }

    .field-label-with-info {
        position: relative;
    }

    .field-label-with-info .info-popover {
        position: static;
    }

    .field-label-with-info .info-popover-panel {
        left: 0;
        right: auto;
    }
}

.field .info-popover-panel {
    font-size: 0.85rem;
    font-weight: 400;
}

.info-popover-panel.is-open {
    opacity: 1;
    pointer-events: auto;
    transform: translateY(0);
}

.info-popover-panel strong {
    color: #1f2937;
    display: block;
    font-size: 1rem;
    margin-bottom: 0.35rem;
}

.info-popover-content,
.info-popover-content p {
    color: inherit;
    display: block;
    font-size: inherit;
    font-weight: inherit;
    margin: 0;
}

.field .info-popover-content {
    display: block;
}

.info-popover-content p + p {
    margin-top: 0.65rem;
}

.field-input {
    width: 100%;
    padding: 0.78rem 0.9rem;
    border: 1px solid #cfd8e6;
    border-radius: 0.8rem;
    background: #ffffff;
    color: #111827;
    font: inherit;
    box-sizing: border-box;
}

.field-input:focus {
    outline: none;
    border-color: #2563eb;
    box-shadow: 0 0 0 4px rgba(37, 99, 235, 0.12);
}

[data-theme] .field-input:disabled {
    background: var(--theme-secondary);
    border-color: var(--theme-border);
    color: var(--theme-muted);
    cursor: not-allowed;
    opacity: 0.7;
}

.date-input {
    min-width: 0;
}

.date-picker-field {
    width: 10.5rem;
    max-width: 100%;
}

.date-picker-field-with-difference {
    align-items: center;
    display: flex;
    gap: 0.45rem;
    width: max-content;
}

.date-picker {
    position: relative;
    width: 100%;
}

.date-picker-input-row {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 3.1rem;
    width: 100%;
}

.date-picker-input {
    box-sizing: border-box;
    min-width: 0;
    width: 100%;
    border: 1px solid var(--theme-border);
    border-radius: 0.8rem 0 0 0.8rem;
    background: var(--theme-input);
    color: var(--theme-text);
    height: 3.1rem;
    padding: 0.78rem 0.9rem;
    font: inherit;
}

.date-picker-input:focus {
    border-color: var(--theme-accent);
    box-shadow: 0 0 0 2px var(--theme-focus);
    outline: 0;
    position: relative;
    z-index: 1;
}

.date-picker-toggle,
.date-picker-nav {
    border: 1px solid var(--theme-border);
    background: var(--theme-input);
    color: var(--theme-text);
    cursor: pointer;
}

.date-picker-toggle {
    flex: 0 0 3.1rem;
    border-left: 0;
    border-radius: 0 0.8rem 0.8rem 0;
    font-size: 1.05rem;
}

.date-picker-toggle:hover,
.date-picker-toggle:focus-visible,
.date-picker-nav:hover,
.date-picker-nav:focus-visible {
    background: var(--theme-secondary);
    border-color: var(--theme-accent);
    color: var(--theme-text);
    outline: 0;
}

.date-picker-popup {
    position: absolute;
    z-index: 20;
    top: calc(100% + 0.35rem);
    left: 0;
    width: min(19rem, 90vw);
    padding: 0.75rem;
    border: 1px solid var(--theme-border);
    border-radius: 0.8rem;
    background: var(--theme-surface-raised);
    box-shadow: 0 0.5rem 1.5rem var(--theme-shadow);
    color: var(--theme-text);
}

.date-picker-header,
.date-picker-weekdays,
.date-picker-grid {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 0.2rem;
}

.date-picker-header {
    grid-template-columns: 2.2rem 1fr 2.2rem;
    align-items: center;
    margin-bottom: 0.65rem;
    text-align: center;
}

.date-picker-nav {
    width: 2.2rem;
    height: 2.2rem;
    border-radius: 0.45rem;
    font-size: 1.45rem;
    line-height: 1;
}

.date-picker-weekdays {
    margin-bottom: 0.2rem;
    color: var(--theme-muted);
    font-size: 0.75rem;
    font-weight: 600;
    text-align: center;
    text-transform: uppercase;
}

.date-picker-day {
    min-height: 2.35rem;
    border: 1px solid transparent;
    border-radius: 0.45rem;
    background: transparent;
    color: var(--theme-text);
    cursor: pointer;
    font: inherit;
}

.date-picker-day:hover,
.date-picker-day:focus-visible {
    border-color: var(--theme-accent);
    background: var(--theme-secondary);
    outline: 0;
}

.date-picker-day-outside {
    color: var(--theme-muted);
    opacity: 0.65;
}

.date-picker-day-selected {
    background: var(--theme-accent);
    color: var(--theme-input);
    font-weight: 700;
}

.date-picker-day-today {
    box-shadow: inset 0 0 0 1px var(--theme-accent);
}

.date-picker-footer {
    display: flex;
    justify-content: flex-start;
    gap: 0.3rem;
    margin-top: 0.65rem;
    padding-top: 0.65rem;
    border-top: 1px solid var(--theme-border);
}

.date-picker-today {
    padding: 0.35rem 0.55rem;
    border: 0;
    border-radius: 0.4rem;
    background: transparent;
    color: var(--theme-accent);
    cursor: pointer;
    font: inherit;
    font-weight: 600;
}

.date-picker-today:hover,
.date-picker-today:focus-visible {
    background: var(--theme-secondary);
    color: var(--theme-text);
    outline: 0;
}

.date-picker-calendar-icon {
    display: inline-block;
    width: 0.95rem;
    height: 0.85rem;
    border: 1.5px solid currentColor;
    border-radius: 0.18rem;
    box-sizing: border-box;
    position: relative;
}

.date-picker-calendar-icon::before {
    content: "";
    position: absolute;
    top: 0.2rem;
    left: 0;
    right: 0;
    border-top: 1.5px solid currentColor;
}

.date-picker-calendar-icon::after {
    content: "";
    position: absolute;
    top: -0.18rem;
    left: 0.18rem;
    width: 0.42rem;
    height: 0.22rem;
    border-inline: 1.5px solid currentColor;
}

.date-picker-field-with-difference .date-picker {
    flex: 0 0 10rem;
    width: 10rem;
}

.date-difference {
    color: #6b7280;
    font-size: 0.9rem;
    white-space: nowrap;
}

.invoice-grid-meta {
    grid-template-columns: repeat(2, minmax(0, 1fr));
}

.validation-field {
    min-width: 0;
    position: relative;
}

.validation-hint-hidden {
    visibility: hidden;
}

.validation-field .field-input {
    padding-right: 9rem;
}

.validation-field--below-input .field-input {
    padding-right: 0.9rem;
}

.validation-field--below-input .validation-hint {
    border-inline-end: 1px solid var(--theme-danger-text);
    border-inline-start: 0;
    display: block;
    margin: 4px 0 0;
    max-width: 100%;
    overflow-wrap: anywhere;
    overflow: visible;
    padding-inline-end: 0.3rem;
    padding-inline-start: 0;
    position: static;
    right: auto;
    text-align: right;
    text-overflow: clip;
    transform: none;
    white-space: normal;
    width: 100%;
}

.field .validation-hint {
    color: var(--theme-danger-text);
    font-size: 0.72rem;
    font-weight: 600;
}

.reference-check-digit {
    color: var(--theme-accent);
}

.validation-hint-with-check-digit {
    border-inline-start: 0;
    padding-inline-start: 0;
}

.reference-check-suggestion {
    padding-inline-end: 0.3rem;
}

.reference-validation-message {
    border-inline-start: 1px solid var(--theme-danger-text);
    padding-inline-start: 0.3rem;
}

.reference-validation-message-short { display: none; }

@media (max-width: 720px) {
    .reference-validation-message-full { display: none; }
    .reference-validation-message-short { display: inline; }
}

.input-invalid,
.valid.modified:not([type=checkbox]).input-invalid {
    border-color: var(--theme-danger-text);
    outline: 1px solid var(--theme-danger-text);
}

.currency-input {
    position: relative;
    display: block;
}

.numeric-input {
    text-align: right;
}

.line-number-input {
    padding-inline: 0.75rem;
}

.line-number-input-small {
    max-width: 8rem;
}

.line-vat-cell .vat-rate-input .field-input {
    width: 100%;
    max-width: none;
    padding: 0.78rem 0.3rem;
    padding-right: 12px;
    border: 1px solid var(--theme-border, #cfd8e6);
    border-radius: 0.8rem;
    text-align: right;
}

.line-vat-cell .vat-rate-input {
    display: flex;
    justify-content: flex-end;
}

.line-vat-cell .vat-rate-input input {
    text-align: right !important;
}

.currency-input .line-number-input {
    padding-right: 44px;
}

.currency-suffix {
    position: absolute;
    top: 50%;
    right: 0.85rem;
    transform: translateY(-50%);
    color: #6b7280;
    font-weight: 700;
    pointer-events: none;
}

.primary-button,
.secondary-button,
.danger-button {
    border: 0;
    border-radius: 0.8rem;
    padding: 0.65rem 0.9rem;
    font: inherit;
    font-weight: 700;
    cursor: pointer;
    transition: transform 0.12s ease, box-shadow 0.12s ease, background-color 0.12s ease;
}

.primary-button {
    background: #1d4ed8;
    color: #ffffff;
    box-shadow: 0 10px 18px rgba(29, 78, 216, 0.22);
}

.secondary-button {
    background: #e5eefc;
    color: #1d4ed8;
}

.clear-button {
    align-items: center;
    display: inline-flex;
    height: 2.45rem;
    justify-content: center;
    padding: 0;
    width: 2.45rem;
}

.default-button {
    align-items: center;
    display: inline-flex;
    height: 2.45rem;
    justify-content: center;
    padding: 0;
    width: 2.45rem;
}

.default-button svg {
    fill: none;
    height: 1.2rem;
    stroke: currentColor;
    stroke-linecap: round;
    stroke-linejoin: round;
    stroke-width: 1.8;
    width: 1.2rem;
}

.clear-button svg {
    fill: none;
    height: 1.2rem;
    stroke: currentColor;
    stroke-linecap: round;
    stroke-linejoin: round;
    stroke-width: 1.8;
    width: 1.2rem;
}

.clear-button-all svg {
    height: 1.45rem;
    width: 1.45rem;
}

.clear-button-all svg circle {
    fill: currentColor;
    stroke: none;
}

.clear-button-hidden {
    pointer-events: none;
    visibility: hidden;
}

.invoice-page .default-button:disabled,
.invoice-page .clear-button:disabled {
    background: transparent;
    border: 1px solid var(--theme-border);
    color: var(--theme-muted);
    cursor: not-allowed;
    opacity: 0.62;
    transform: none;
}

.line-add-row {
    display: flex;
    justify-content: flex-end;
    margin-top: 0.75rem;
}

.line-add-button {
    align-items: center;
    display: inline-flex;
    height: 37px;
    justify-content: center;
    padding: 0;
    width: 37px;
}

.line-add-button svg {
    fill: none;
    height: 1.25rem;
    stroke: currentColor;
    stroke-linecap: round;
    stroke-width: 2;
    width: 1.25rem;
}

.line-remove-button {
    align-items: center;
    display: inline-flex;
    height: 37px;
    justify-content: center;
    padding: 0;
    width: 37px;
}

.line-remove-button svg {
    fill: none;
    height: 1.9rem;
    stroke: currentColor;
    stroke-linecap: round;
    stroke-width: 2.4;
    transition: transform 0.18s ease;
    width: 1.9rem;
}

.line-remove-button-confirm svg {
    transform: rotate(45deg);
}

.primary-action-button {
    align-items: center;
    background: var(--theme-primary);
    border: 0;
    box-shadow: 0 0.65rem 1.5rem var(--theme-shadow), 0 0 0.65rem var(--theme-accent), 0 0 0 3px var(--theme-secondary);
    color: var(--theme-text);
    display: inline-flex;
    gap: 0.55rem;
    justify-content: center;
    min-height: 3.75rem;
    min-width: 14rem;
    padding: 1rem 1.5rem;
}

.primary-action-button:not(:disabled) {
    animation: invoice-pdf-breathe 2.8s ease-in-out infinite;
}

@media (hover: hover) and (pointer: fine) {
    .primary-action-button:not(:disabled):hover {
        animation: none;
        background: var(--theme-accent);
        box-shadow: 0 0.8rem 1.8rem var(--theme-shadow), 0 0 1rem var(--theme-accent), 0 0 0 4px var(--theme-secondary);
        transform: translateY(-2px) scale(1.02);
    }
}

.primary-action-button:focus-visible {
    outline: 3px solid var(--theme-accent);
    outline-offset: 3px;
}

.invoice-page .primary-button,
.invoice-page .secondary-button {
    background: #e5e7eb;
    color: #374151;
    box-shadow: none;
}

.invoice-page .invoice-actions-row .primary-button {
    background: #1d4ed8;
    color: #ffffff;
    box-shadow: 0 10px 18px rgba(29, 78, 216, 0.22);
}

.invoice-page .invoice-hero-actions .primary-button {
    background: #1d4ed8;
    color: #ffffff;
    box-shadow: 0 10px 18px rgba(29, 78, 216, 0.22);
}

.invoice-page .invoice-pdf-button {
    align-items: center;
    background: var(--theme-primary);
    border: 0;
    box-shadow: 0 0.65rem 1.5rem var(--theme-shadow), 0 0 0.65rem var(--theme-accent), 0 0 0 3px var(--theme-secondary);
    color: var(--theme-primary-text);
    display: inline-flex;
    gap: 0.55rem;
    justify-content: center;
    letter-spacing: normal;
    font-size: 1.1rem;
    min-height: 3.75rem;
    min-width: 14rem;
    padding: 1rem 1.5rem;
}

.invoice-page .invoice-pdf-button:not(:disabled) {
    animation: invoice-pdf-breathe 2.8s ease-in-out infinite;
}

.invoice-pdf-icon {
    fill: none;
    flex: 0 0 1.35rem;
    height: 1.35rem;
    stroke: currentColor;
    stroke-linecap: round;
    stroke-linejoin: round;
    stroke-width: 1.8;
    width: 1.35rem;
}

@media (hover: hover) and (pointer: fine) {
    .invoice-page .invoice-pdf-button:hover {
        animation: none;
        background: var(--theme-accent);
        box-shadow: 0 0.8rem 1.8rem var(--theme-shadow), 0 0 1rem var(--theme-accent), 0 0 0 4px var(--theme-secondary);
        transform: translateY(-2px) scale(1.02);
    }
}

@keyframes invoice-pdf-breathe {
    0%,
    100% {
        box-shadow: 0 0.65rem 1.5rem var(--theme-shadow), 0 0 0.65rem var(--theme-accent), 0 0 0 3px var(--theme-secondary);
    }

    50% {
        box-shadow: 0 0.75rem 1.7rem var(--theme-shadow), 0 0 0.95rem var(--theme-accent), 0 0 0 3px var(--theme-secondary);
    }
}

.invoice-page .invoice-pdf-button:focus-visible {
    outline: 3px solid var(--theme-accent);
    outline-offset: 3px;
}

.danger-button {
    background: #fee2e2;
    color: #b91c1c;
    padding-inline: 0.9rem;
}

.primary-button:hover,
.secondary-button:hover,
.danger-button:hover {
    transform: translateY(-1px);
}

[data-theme] .settings-save-button:disabled {
    background: var(--theme-secondary);
    box-shadow: none;
    color: var(--theme-muted);
    cursor: not-allowed;
    opacity: 0.7;
    transform: none;
}

.invoice-actions-row {
    align-items: center;
}

.line-table-wrap {
    overflow-x: auto;
}

.line-table {
    width: 100%;
    border-collapse: collapse;
    min-width: 880px;
}

.line-table th,
.line-table td {
    padding: 0.72rem 0.6rem;
    border-bottom: 1px solid #e5eaf2;
    vertical-align: middle;
}

.line-table th {
    text-align: left;
    color: #475569;
    font-size: 0.9rem;
}

.line-table th.numeric-column,
.numeric-column,
.numeric-cell {
    text-align: right;
}

.line-table thead th.numeric-column {
    text-align: right;
}

.line-description-cell {
    width: 44%;
}

.line-quantity-cell {
    width: 12%;
}

.line-price-cell {
    width: 18%;
}

.line-vat-cell {
    width: 10%;
}

.vat-settings-grid { display: grid; gap: 0.95rem; margin-inline: 10px; }
.vat-use-field .field-input { max-width: 7rem; }
.vat-rates-field { min-width: 0; }
.vat-rate-list-input { background: var(--theme-input); border: 1px solid var(--theme-border); border-radius: 0.8rem; box-sizing: border-box; max-width: 15rem; padding: 0.65rem; width: 100%; }
.vat-rate-settings-list { display: grid; gap: 0.5rem; justify-items: start; max-width: none; width: 100%; }
.vat-rate-input { position: relative; }
.vat-rate-options {
    position: fixed;
    z-index: 5;
    padding: 0.2rem;
    background: var(--theme-surface-raised, #ffffff);
    border: 0.5px solid var(--theme-border, #d7e0ec);
    border-radius: 0.4rem;
    box-shadow: 0 8px 18px rgba(15, 23, 42, 0.12);
}
.vat-rate-option {
    display: block;
    width: 100%;
    padding: 0.45rem 0.55rem;
    border: 0;
    border-radius: 0.25rem;
    background: var(--theme-surface-raised, #ffffff);
    color: var(--theme-text, #1f2937);
    font: inherit;
    text-align: right;
    cursor: pointer;
}
.vat-rate-option:hover, .vat-rate-option:focus { background: var(--theme-secondary, #eef4fb); }
.vat-rate-setting-row, .vat-rate-add-row { display: flex; align-items: end; gap: 0.75rem; }
.vat-rate-setting-row { align-items: center; width: 100%; }
.vat-rate-value { display: inline-flex; align-items: center; justify-content: center; width: 6rem; box-sizing: border-box; padding: 0.45rem 0.4rem; border: 0.5px solid var(--theme-border); border-radius: 0.4rem; text-align: center; }
.vat-rate-add-row { display: block; margin-top: 1rem; max-width: 15rem; width: 100%; }
.vat-rate-add-row .field { min-width: 0; width: 6rem; }
.vat-rate-new-label { color: var(--theme-text); font-size: 0.92rem; font-weight: 600; white-space: nowrap; }
.vat-rate-add-control { align-items: center; display: flex; gap: 0.75rem; width: max-content; }
.vat-rate-add-control .field-input { flex: 0 0 6rem; max-width: 6rem; width: 6rem; }
.vat-rate-add-control .add-button { flex: 0 0 37px; }
.vat-rate-error { margin: 0.5rem 0 0; max-width: 15rem; overflow: visible; padding: 0.3rem 0.4rem; position: static; transform: none; white-space: normal; }
.settings-template-field .field-input { min-width: 18rem; }

.line-total-cell {
    font-variant-numeric: tabular-nums;
}

.line-col-description {
    width: 44%;
}

.line-col-quantity {
    width: 12%;
}

.line-col-price {
    width: 18%;
}

.line-col-vat {
    width: 10%;
}

.line-col-total {
    width: auto;
    min-width: 7rem;
}

.line-col-actions {
    width: 2%;
}

.line-total-cell {
    text-align: right;
    min-width: 7rem;
    white-space: nowrap;
}

.action-cell {
    width: 1%;
    white-space: nowrap;
}

.totals-panel {
    display: flex;
    justify-content: flex-end;
    margin-top: 1.1rem;
}

.totals-box {
    width: min(100%, 25rem);
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.totals-row {
    display: flex;
    justify-content: space-between;
    gap: 1rem;
    font-size: 1rem;
}

.totals-row-sub {
    color: #475569;
}

.totals-row-grand {
    font-size: 1.25rem;
}

.totals-divider {
    height: 1px;
    background: linear-gradient(90deg, transparent, #cfd8e6, transparent);
    margin: 0.35rem 0;
}

@media (max-width: 1080px) {
    .invoice-columns,
    .invoice-grid-meta,
    .customer-layout {
        grid-template-columns: 1fr;
    }

    .field-wide,
    .field-business-id,
    .field-reference {
        grid-column: auto;
        max-width: none;
    }
}

@media (max-width: 720px) {
    .main-content {
        padding: 0.75rem;
    }

    .invoice-grid {
        grid-template-columns: 1fr;
    }

    .invoice-grid .field-wide {
        grid-column: auto;
    }

    .customer-page {
        height: auto;
        overflow: visible;
    }

    .vat-settings-grid {
        max-width: none;
    }

    .settings-vat-card {
        width: 100%;
    }

    .settings-template-field .field-input {
        min-width: 0;
    }

    .settings-template-card .section-header {
        align-items: stretch;
    }

    .settings-template-actions {
        align-self: flex-end;
    }

    .template-library-layout,
    .template-library-details {
        grid-template-columns: 1fr;
    }

    .invoice-page {
        gap: 1rem;
    }

    .invoice-card {
        padding: 1rem;
    }

    .invoice-hero {
        align-items: center;
        flex-direction: row;
    }

    .invoice-hero-actions {
        align-self: center;
        margin-inline-start: auto;
    }

    .section-header,
    .invoice-actions-row,
    .customer-hero,
    .customer-list-item {
        flex-direction: column;
        align-items: stretch;
        padding-inline-end: 0;
    }

    .section-header:has(> .section-actions),
    .section-header:has(> .clear-button),
    .section-header:has(> .default-button),
    .section-header:has(> button) {
        padding-inline-end: 0;
    }

    .section-header > .section-actions,
    .section-header > .clear-button,
    .section-header > .default-button,
    .section-header > button {
        align-self: flex-end;
        margin-inline-start: auto;
        position: static;
    }

    .section-header > .section-actions {
        justify-content: flex-end;
        width: max-content;
    }

    .invoice-template-details-card .section-header {
        align-items: flex-start;
        flex-direction: row;
        padding-inline-end: 3.5rem;
    }

    .invoice-template-details-card .section-header > .section-actions {
        align-self: flex-start;
        margin-inline-start: auto;
    }

    .customer-hero-actions {
        align-items: stretch;
        flex-direction: column;
    }

    .totals-panel {
        justify-content: stretch;
    }

    .totals-box {
        width: 100%;
    }

    .line-table-wrap {
        overflow-x: visible;
    }

    .line-table {
        display: block;
        min-width: 0;
    }

    .line-table colgroup,
    .line-table thead {
        display: none;
    }

    .line-table tbody {
        display: grid;
        gap: 0.75rem;
    }

    .line-table tbody tr {
        background: var(--theme-surface-raised);
        border: 1px solid var(--theme-border);
        border-radius: 0.8rem;
        display: grid;
        gap: 0.7rem;
        grid-template-columns: repeat(2, minmax(0, 1fr));
        padding: 0.8rem;
    }

    .line-table tbody td {
        align-items: stretch;
        border: 0;
        display: flex;
        flex-direction: column;
        gap: 0.3rem;
        min-width: 0;
        padding: 0;
        text-align: left !important;
        width: auto !important;
    }

    .line-table tbody td::before {
        color: var(--theme-muted);
        content: attr(data-label);
        font-size: 0.78rem;
        font-weight: 700;
    }

    .line-table .line-description-cell {
        grid-column: 1 / -1;
    }

    .line-table .line-total-cell {
        align-items: center;
        justify-content: center;
        min-width: 0;
        text-align: center !important;
    }

    .line-table .action-cell {
        align-items: flex-end;
        grid-column: 1 / -1;
        min-height: 2.35rem;
    }

    .line-table .action-cell-empty::before {
        content: none;
    }

    .line-table .field-input,
    .line-table .currency-input,
    .line-table .vat-rate-input,
    .line-table .line-vat-cell .vat-rate-input .field-input {
        max-width: none;
        width: 100%;
    }
}

.help-page {
    margin: 0 auto;
    max-width: 58rem;
    padding: 2rem 2.5rem 4rem;
}

.help-page h1 {
    color: var(--theme-text);
    font-size: clamp(1.8rem, 4vw, 2.7rem);
    margin: 0.2rem 0 0.65rem;
}

.help-intro {
    color: var(--theme-muted);
    font-size: 1.05rem;
    line-height: 1.65;
    margin: 0;
    max-width: 44rem;
}

.help-toc {
    align-items: center;
    background: var(--theme-surface-raised);
    border: 1px solid var(--theme-border);
    border-radius: 0.8rem;
    box-shadow: 0 0.2rem 0.6rem var(--theme-shadow);
    display: flex;
    flex-wrap: wrap;
    gap: 0.55rem 1rem;
    margin: 1.5rem 0;
    padding: 0.9rem 1rem;
    position: sticky;
    top: 0.75rem;
    z-index: 5;
}

.help-toc-toggle {
    align-items: center;
    background: transparent;
    border: 0;
    color: var(--theme-text);
    display: flex;
    font: inherit;
    font-weight: 700;
    justify-content: space-between;
    padding: 0;
}

.help-toc-chevron {
    display: none;
    font-size: 1.3rem;
    line-height: 1;
    transition: transform 180ms ease;
}

.help-toc strong {
    color: var(--theme-text);
    margin-right: 0.25rem;
}

.help-toc-links {
    align-items: center;
    display: flex;
    flex-wrap: wrap;
    gap: 0.55rem 1rem;
}

.help-toc-links button {
    background: transparent;
    border: 0;
    color: var(--theme-accent);
    cursor: pointer;
    font: inherit;
    font-size: 0.9rem;
    padding: 0;
}

.help-toc-links button:hover,
.help-toc-links button:focus-visible,
.help-toc-toggle:focus-visible {
    color: var(--theme-primary);
    text-decoration: underline;
}

.help-content {
    display: grid;
    gap: 1rem;
}

.help-card {
    background: var(--theme-surface-raised);
    border: 1px solid var(--theme-border);
    border-radius: 0.8rem;
    box-shadow: 0 0.2rem 0.6rem var(--theme-shadow);
    color: var(--theme-text);
    line-height: 1.65;
    padding: 1.35rem 1.5rem;
    scroll-margin-top: 1rem;
}

.help-card h2 {
    border-bottom: 1px solid var(--theme-border);
    font-size: 1.3rem;
    margin: 0 0 1rem;
    padding-bottom: 0.55rem;
}

.help-card h3 {
    font-size: 1rem;
    margin: 1.25rem 0 0.35rem;
}

.help-card p,
.help-card ol,
.help-card ul {
    margin: 0 0 0.85rem;
}

.help-card li + li {
    margin-top: 0.35rem;
}

.help-card a {
    color: var(--theme-accent);
}

.help-muted {
    color: var(--theme-muted);
    font-size: 0.9rem;
}

@media (max-width: 720px) {
    .help-page {
        padding: 1.25rem 1rem 3rem;
    }

    .help-toc {
        align-items: flex-start;
        display: block;
        padding: 0.8rem 1rem;
    }

    .help-toc-toggle {
        width: 100%;
    }

    .help-toc-chevron {
        display: block;
    }

    .help-toc-open .help-toc-chevron {
        transform: rotate(180deg);
    }

    .help-toc-links {
        display: none;
        flex-direction: column;
        align-items: flex-start;
        gap: 0.55rem;
        padding-top: 0.75rem;
    }

    .help-toc-open .help-toc-links {
        display: flex;
    }

    .help-card {
        padding: 1.1rem 1rem;
    }
}

/* Theme previews settle instead of flashing while the pointer moves through the list. */
[data-theme],
[data-theme] * {
    transition-property: background-color, border-color, color, box-shadow;
    transition-duration: 220ms;
    transition-timing-function: ease;
}

@media (prefers-reduced-motion: reduce) {
    [data-theme],
    [data-theme] * {
        transition-duration: 0ms !important;
    }

    .invoice-page .invoice-pdf-button:not(:disabled) {
        animation: none;
    }
}
