:root {
    --bg: #edf0f4;
    --ink: #263244;
    --muted: #68788b;
    --line: #d4dce6;
    --blue: #2f5792;
    --nav: #243f69;
}
* {
    box-sizing: border-box;
}
body {
    margin: 0;
    background: var(--bg);
    color: var(--ink);
    font:
        13px Arial,
        Helvetica,
        sans-serif;
}
button,
input,
select,
textarea {
    font: inherit;
}
button,
a {
    touch-action: manipulation;
}
button {
    cursor: pointer;
}
a {
    color: var(--blue);
    text-decoration: none;
}
a:hover {
    text-decoration: underline;
}
button:focus-visible,
a:focus-visible {
    outline: 2px solid #3269bc;
    outline-offset: 3px;
}
#sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    width: 204px;
    background: #f9fafc;
    border-right: 1px solid #c9d3e1;
    overflow-y: auto;
    z-index: 20;
}
.shoutbox {
    margin: 0 9px 16px;
    border-top: 1px solid #dbe2ec;
    padding-top: 12px;
    font-size: 11px;
}
.shoutbox h2 {
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-size: 12px;
    margin: 0 4px 8px;
}
.shoutbox-refresh,
.shout-delete {
    border: 0;
    background: transparent;
    color: #526a8a;
    cursor: pointer;
    padding: 4px;
}
.shoutbox-messages {
    max-height: 260px;
    overflow-y: auto;
    scrollbar-width: thin;
}
.shout {
    padding: 7px 4px;
    border-bottom: 1px solid #e1e7ef;
}
.shout-meta {
    display: flex;
    align-items: center;
    gap: 5px;
    flex-wrap: wrap;
    color: #677a94;
    font-size: 10px;
}
.shout-meta b {
    color: #334f73;
    overflow-wrap: anywhere;
}
.shout-meta time {
    margin-left: auto;
}
.shout p {
    margin: 4px 0;
    line-height: 1.45;
    white-space: pre-wrap;
    overflow-wrap: anywhere;
}
.shout-empty {
    margin: 10px 4px;
    color: #74859c;
}
#shoutbox-form {
    margin-top: 8px;
}
#shoutbox-form textarea {
    width: 100%;
    min-height: 52px;
    resize: vertical;
    padding: 7px;
    font-size: 12px;
}
#shoutbox-form .button {
    margin-top: 5px;
    width: 100%;
    padding: 5px;
}
#shoutbox-feedback {
    margin: 5px 0 0;
    overflow-wrap: anywhere;
}
.account-button {
    border: 0;
    background: transparent;
    color: inherit;
    padding: 6px 0;
}
.permission-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(230px, 1fr));
    gap: 10px;
    border: 1px solid #c7d2df;
    margin: 12px 0;
    padding: 12px;
}
.permission-grid label {
    display: flex;
    align-items: flex-start;
    gap: 7px;
    font-size: 12px;
}
.permission-grid input {
    flex-shrink: 0;
}
@media (max-width: 650px) {
    .permission-grid {
        grid-template-columns: 1fr;
    }
    .shoutbox-refresh,
    .shout-delete {
        min-width: 44px;
        min-height: 44px;
    }
}
.brand {
    display: flex;
    align-items: center;
    gap: 8px;
    background: var(--nav);
    color: white;
    height: 58px;
    padding: 0 18px;
    font-size: 18px;
    font-weight: 700;
    white-space: nowrap;
}
.brand:hover {
    text-decoration: none;
}
.brand span {
    font-weight: 400;
    color: #c0d0e7;
    font-size: 12px;
}
nav {
    padding: 15px 9px;
    display: grid;
    gap: 3px;
}
nav a {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px;
    color: #3e526d;
    border-radius: 3px;
    border: 1px solid transparent;
    font-size: 13px;
}
nav a:hover {
    background: #e9eef6;
    text-decoration: none;
}
nav a.active {
    background: #e0e9f6;
    color: #1f4d8f;
    border-color: #c9d8ec;
    font-weight: 600;
}
nav b {
    margin-left: auto;
    font-size: 11px;
    color: #607b9f;
    font-weight: 400;
}
nav a[data-page='settings'] {
    border-top: 1px solid #dbe2ec;
    margin-top: 12px;
    padding-top: 15px;
    border-radius: 0;
}
.main-shell {
    margin-left: 204px;
}
header {
    position: sticky;
    top: 0;
    z-index: 15;
    height: 58px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 25px;
    border-bottom: 1px solid #cdd6e1;
    background: #fff;
    gap: 15px;
}
.breadcrumb {
    font-size: 12px;
    color: #738095;
}
.breadcrumb span {
    padding: 0 9px;
    color: #b3bdca;
}
.breadcrumb b {
    font-weight: 500;
    color: #3c4e68;
}
.breadcrumb .settings-back-link {
    color: #1e4e91;
}
.breadcrumb .settings-back-link:hover,
.breadcrumb .settings-back-link:focus-visible {
    text-decoration: underline;
}
.settings-mobile-back {
    display: none;
}
@media (max-width: 850px) {
    .settings-mobile-back {
        display: inline-flex;
        position: sticky;
        top: 58px;
        z-index: 5;
        background: #edf1f6;
        align-items: center;
        min-height: 44px;
        padding: 8px 0;
        margin-bottom: 8px;
        color: #1e4e91;
        font-size: 13px;
    }
}
.header-right {
    display: flex;
    align-items: center;
    gap: 15px;
}
.settings-shortcut {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 44px;
    height: 44px;
    flex-shrink: 0;
    border-radius: 4px;
    color: #4b5e76;
}
.settings-shortcut:hover,
.settings-shortcut:focus-visible {
    color: #1e4e91;
    background: #e0e9f6;
    text-decoration: none;
}
.invoice-hints {
    position: relative;
}
.invoice-hints[hidden],
.invoice-hints-list[hidden] {
    display: none;
}
.invoice-hints .settings-shortcut {
    position: relative;
    border: 0;
    background: transparent;
    cursor: pointer;
}
.invoice-hints .settings-shortcut.has-overdue {
    background: #fff0f0;
    color: #b42332;
}
.invoice-hints .settings-shortcut.has-overdue:hover,
.invoice-hints .settings-shortcut.has-overdue:focus-visible {
    background: #ffe2e5;
}
.invoice-hints .settings-shortcut.has-warning {
    background: #fff5dc;
    color: #8a5800;
}
.invoice-hints .settings-shortcut.has-info {
    background: #eaf2fc;
    color: #1e4e91;
}
.has-warning #invoice-hints-count {
    background: #8a5800;
}
.has-info #invoice-hints-count {
    background: #1e4e91;
}
.notification-heading {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    padding: 12px;
    font-size: 12px;
}
.invoice-hints-list h3 {
    margin: 0;
    padding: 9px 12px;
    background: #edf2f8;
    color: #3e526d;
    font-size: 12px;
}
.notification-item {
    border-left: 3px solid #1e4e91;
    border-bottom: 1px solid #e0e6ef;
    padding-bottom: 5px;
}
.notification-error {
    border-left-color: #b42332;
}
.notification-warning {
    border-left-color: #a56d00;
}
.notification-read {
    padding: 5px 9px;
    margin: 0 8px;
    background: transparent;
    border: 1px solid #c7d2df;
    border-radius: 3px;
    color: #3e526d;
    cursor: pointer;
    min-height: 32px;
    font-size: 11px;
}
.notification-read:hover,
.notification-read:focus-visible {
    background: #eaf2fc;
}
@media (max-width: 650px) {
    .notification-read {
        min-height: 44px;
    }
}
.invoice-hint-attention svg {
    transform-origin: 50% 20%;
    animation: invoice-bell-ring 700ms ease-in-out 1;
}
@keyframes invoice-bell-ring {
    0%,
    100% {
        transform: rotate(0);
    }
    20% {
        transform: rotate(-12deg);
    }
    40% {
        transform: rotate(12deg);
    }
    60% {
        transform: rotate(-8deg);
    }
    80% {
        transform: rotate(8deg);
    }
}
.shoutbox-refresh span {
    display: inline-block;
}
.shoutbox-refresh.is-loading span {
    animation: shoutbox-refresh-spin 450ms linear infinite;
}
.shoutbox-refresh:disabled {
    cursor: pointer;
}
@keyframes shoutbox-refresh-spin {
    to {
        transform: rotate(360deg);
    }
}
@media (prefers-reduced-motion: reduce) {
    .shoutbox-refresh.is-loading span {
        animation: none;
    }
    .invoice-hint-attention svg {
        animation: none;
    }
}
#invoice-hints-count {
    position: absolute;
    top: 1px;
    right: 0;
    font-size: 10px;
    color: #fff;
    background: #b42332;
    border: 2px solid #fff;
    border-radius: 12px;
    min-width: 18px;
    height: 18px;
    line-height: 14px;
    padding: 0 3px;
    text-align: center;
    font-weight: 700;
}
#invoice-hints-count:empty {
    display: none;
}
.invoice-hints-list {
    position: fixed;
    right: 16px;
    top: 62px;
    width: min(380px, calc(100vw - 224px));
    max-height: 65dvh;
    overflow: auto;
    background: white;
    border: 1px solid #c7d2df;
    border-radius: 4px;
    box-shadow: 0 5px 18px #20375325;
}
.invoice-hints-list > p {
    padding: 12px;
    font-size: 12px;
}
#invoice-notification-settings {
    margin: 16px 0;
}
@media (max-width: 650px) {
    .invoice-hints-list {
        position: fixed;
        top: 58px;
        left: 10px;
        right: 10px;
        width: auto;
    }
}
main {
    padding: 22px 25px;
    max-width: 1600px;
    margin: auto;
}
.page-heading {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 15px;
    margin-bottom: 18px;
}
h1 {
    font-size: 22px;
    font-weight: 600;
    margin: 0;
    color: #233c61;
    letter-spacing: 0;
}
.heading-actions {
    display: flex;
    gap: 8px;
}
.button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    min-height: 34px;
    padding: 8px 12px;
    border: 1px solid #c2cddb;
    border-radius: 3px;
    background: #fff;
    color: #344c6e;
    font-size: 12px;
    font-weight: 500;
}
.button:hover {
    background: #edf3fb;
}
.button.primary {
    color: #fff;
    background: var(--blue);
    border-color: #294e85;
}
.button.primary:hover {
    background: #244675;
}
.button:disabled {
    opacity: 0.4;
    cursor: default;
}
.button > span {
    font-size: 15px;
}
.dashboard-actions {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    margin-bottom: 17px;
}
.stats {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 13px;
    margin-bottom: 20px;
}
.stats article {
    background: #fff;
    border: 1px solid var(--line);
    border-radius: 4px;
    padding: 14px 16px;
    border-top: 3px solid #809cc1;
}
.stats article > div {
    font-size: 12px;
    color: #61738c;
}
.stats strong {
    display: block;
    margin: 8px 0;
    font-size: 23px;
    font-weight: 600;
    color: #263f63;
    white-space: nowrap;
}
.stats small {
    font-size: 11px;
    color: #8290a2;
}
.panel {
    border: 1px solid #c7d2df;
    border-radius: 4px;
    background: #fff;
    overflow: hidden;
}
.dashboard-panel {
    margin-bottom: 19px;
}
.backup-progress {
    margin: 12px 0 18px;
}
.backup-progress progress {
    display: block;
    width: 100%;
    height: 14px;
    margin: 8px 0;
    accent-color: var(--blue);
}
.backup-progress small {
    color: #61738c;
}
.backup-cli-help {
    margin-top: 18px;
}
.backup-cli-help pre {
    white-space: pre-wrap;
    overflow-wrap: anywhere;
    font-size: 12px;
}
.reminder-cron-help {
    margin: 22px 0;
    padding: 14px;
    border: 1px solid var(--line);
    border-radius: 4px;
    background: #f8fafc;
    line-height: 1.6;
}
.reminder-cron-help summary {
    color: var(--blue);
    cursor: pointer;
    font-weight: 600;
}
.reminder-cron-help pre {
    padding: 10px;
    white-space: pre-wrap;
    overflow-wrap: anywhere;
    background: #edf1f6;
    border: 1px solid var(--line);
    border-radius: 3px;
    font-size: 12px;
}
.reminder-cron-help ol,
.reminder-cron-help ul {
    padding-left: 20px;
}
#backup-settings .document-history > div {
    align-items: center;
    flex-wrap: wrap;
}
.backup-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}
.system-check-summary {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 10px;
}
.system-check-summary .button {
    margin-left: auto;
}
.system-check-group {
    margin-top: 24px;
}
.system-check-row {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 16px;
    padding: 12px 0;
    border-bottom: 1px solid #e0e7ef;
}
.system-check-row small {
    display: block;
    margin-top: 5px;
    color: #68788b;
    line-height: 1.5;
    overflow-wrap: anywhere;
}
.system-check-row .badge {
    flex-shrink: 0;
    white-space: nowrap;
}
.panel-heading {
    padding: 12px 15px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    background: #e6ecf4;
    border-bottom: 1px solid #ccd6e4;
}
.panel h2 {
    margin: 0;
    font-size: 13px;
    font-weight: 600;
    color: #2d486e;
}
.panel-heading a {
    font-size: 11px;
}
.table-scroll {
    overflow-x: auto;
}
.record-panel {
    container-type: inline-size;
    container-name: records;
    min-width: 0;
}
.record-panel .record-table td {
    white-space: normal;
    overflow-wrap: normal;
}
.record-panel .record-table .row-link {
    max-width: 280px;
    white-space: normal;
    overflow-wrap: anywhere;
}
table {
    width: 100%;
    border-collapse: collapse;
    white-space: nowrap;
    font-size: 12px;
    text-align: left;
}
th {
    background: #f3f5f8;
    font-weight: 600;
    font-size: 11px;
    color: #586c86;
    padding: 10px 14px;
    border-bottom: 1px solid #d8e0e9;
}
td {
    padding: 10px 14px;
    border-bottom: 1px solid #e3e8ef;
    color: #53637a;
}
tbody tr:nth-child(even) {
    background: #f8fafd;
}
tbody tr:hover {
    background: #edf3fb;
}
tbody tr:last-child td {
    border-bottom: 0;
}
.row-link {
    border: 0;
    background: none;
    padding: 0;
    font-weight: 600;
    font-size: 12px;
    color: #29558e;
    text-align: left;
}
.row-link:hover {
    text-decoration: underline;
}
.row-link small,
td > small {
    display: block;
    color: #7a899c;
    font-size: 11px;
    font-weight: 400;
    margin-top: 4px;
}
.amount {
    font-variant-numeric: tabular-nums;
    font-weight: 500;
}
.badge {
    display: inline-block;
    white-space: nowrap;
    overflow-wrap: normal;
    word-break: normal;
    font-size: 11px;
    border-radius: 3px;
    padding: 3px 7px;
}
.green {
    background: #e3f0e5;
    color: #3d714a;
}
.amber {
    background: #f8edcf;
    color: #926b1a;
}
.blue {
    background: #e2ebfa;
    color: #3e67a1;
}
.red {
    background: #f8e4e4;
    color: #a55050;
}
.icon {
    border: 0;
    background: transparent;
    color: #5b7392;
    padding: 6px 8px;
    min-width: 30px;
    min-height: 30px;
}
.empty {
    padding: 23px 15px;
    font-size: 12px;
    color: #7a8797;
}
.list-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 10px 12px;
    background: #fafbfd;
    border-bottom: 1px solid var(--line);
}
.sort-toolbar {
    display: none;
    align-items: center;
    justify-content: flex-end;
    flex-wrap: wrap;
    gap: 8px;
    padding: 8px 12px;
    border-bottom: 1px solid var(--line);
    font-size: 12px;
}
.customer-contact {
    display: flex;
    flex-direction: column;
    gap: 3px;
    width: 210px;
    min-width: 0;
    max-width: 100%;
    white-space: normal;
    overflow-wrap: anywhere;
    font-size: 12px;
    line-height: 1.45;
}
.customer-contact small {
    display: block;
    font: inherit;
    color: #64748b;
    margin: 0;
}
.sort-toolbar select {
    width: auto;
    max-width: 55vw;
    min-height: 32px;
    padding: 5px 8px;
    border: 1px solid #c7d2e0;
    border-radius: 3px;
    background: #fff;
    color: var(--ink);
    font: inherit;
}
.sort-direction {
    min-width: 34px;
    min-height: 32px;
}
.sort-heading {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    border: 0;
    padding: 0;
    background: transparent;
    color: inherit;
    font: inherit;
    text-align: left;
    cursor: pointer;
}
.sort-heading span {
    opacity: 0.8;
    font-size: 14px;
    font-weight: 600;
}
.sort-heading.active,
.sort-heading:hover {
    color: #174d8d;
}
.sort-heading.active span {
    opacity: 1;
}
.sort-heading:focus-visible {
    outline: 2px solid #5185c2;
    outline-offset: 4px;
}
@media (max-width: 650px) {
    .sort-toolbar {
        display: flex;
    }
    .sort-toolbar select,
    .sort-direction {
        min-height: 44px;
    }
}
.tabs {
    display: flex;
    gap: 3px;
    flex-wrap: wrap;
}
.tabs button {
    border: 1px solid transparent;
    border-radius: 3px;
    background: transparent;
    color: #657a96;
    font-size: 12px;
    padding: 7px 10px;
}
.tabs button.selected {
    background: #e1eaf8;
    border-color: #c7d6eb;
    color: #31588b;
}
.search {
    display: flex;
    align-items: center;
    border: 1px solid #cdd7e4;
    background: #fff;
    padding: 0 8px;
    border-radius: 3px;
    color: #7d8fa6;
}
.search input {
    border: 0;
    padding: 7px;
    width: 180px;
    font-size: 12px;
    background: transparent;
}
.pagination {
    display: flex;
    justify-content: flex-end;
    align-items: center;
    gap: 7px;
    padding: 10px 14px;
    border-top: 1px solid #dbe3ed;
    color: #7c8ba0;
    font-size: 11px;
}
.pagination > span {
    margin-right: auto;
}
.pagination-buttons {
    display: flex;
    gap: 7px;
}
.security-checkbox {
    display: flex;
    align-items: center;
    gap: 8px;
}
.settings-groups {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 18px;
    align-items: start;
}
.settings-group .panel-heading {
    padding: 13px 16px;
}
.settings-link {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 15px 16px;
    min-height: 48px;
    border-top: 1px solid #e2e8f0;
}
.settings-link:first-of-type {
    border-top: 0;
}
.settings-link:hover {
    background: #eff4fa;
    text-decoration: none;
}
.settings-link > span:last-child {
    font-size: 20px;
    color: #758ba7;
}
.search-prefix-legend {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 12px;
    margin: 20px 0;
}
.search-prefix-legend b {
    display: inline-block;
    min-width: 30px;
    color: #244b7e;
}
.search-scope {
    padding: 8px 12px;
    font-size: 11px;
    font-weight: 600;
    color: #335d8d;
    background: #edf3fb;
    border-bottom: 1px solid #dbe3ed;
}
@media (max-width: 650px) {
    .settings-groups {
        grid-template-columns: 1fr;
    }
    .search-prefix-legend {
        grid-template-columns: 1fr;
    }
}
.pagination .button {
    padding: 4px 10px;
    min-height: 28px;
    min-width: 34px;
}
.field {
    display: flex;
    flex-direction: column;
    gap: 6px;
    margin-bottom: 16px;
    font-size: 12px;
    color: #536680;
}
input,
select,
textarea {
    border: 1px solid #c5d0de;
    border-radius: 3px;
    min-width: 0;
    padding: 9px;
    background: #fff;
    color: #263c5a;
    outline-color: #668cc2;
}
textarea {
    resize: vertical;
    min-height: 75px;
}
.form-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0 16px;
}
.settings-panel {
    max-width: 850px;
    padding: 20px;
}
.settings-panel h2 {
    margin-bottom: 20px;
}
.brand-logo {
    width: 30px;
    height: 30px;
    object-fit: contain;
    background: white;
    border-radius: 3px;
    padding: 2px;
    flex-shrink: 0;
}
.auth-header .brand-logo {
    vertical-align: middle;
    margin-right: 8px;
}
.branding-preview {
    padding: 16px;
    background: #f5f7fa;
    border: 1px solid #dbe3ed;
    border-radius: 4px;
    margin-bottom: 20px;
}
.branding-preview img {
    display: block;
    max-width: 240px;
    max-height: 160px;
    width: auto;
    height: auto;
    object-fit: contain;
}
.branding-preview p {
    margin-top: 10px;
}
#payment-reminder-settings > h2:not(:first-child) {
    margin-top: 24px;
}
.pdf-layout-editor {
    display: grid;
    grid-template-columns: minmax(320px, 1fr) minmax(350px, 1fr);
    gap: 20px;
    align-items: start;
}
.pdf-layout-editor .settings-panel {
    max-width: none;
}
.pdf-layout-editor h2:not(:first-child) {
    margin-top: 20px;
}
.pdf-layout-editor input[type='color'] {
    width: 100%;
    min-height: 38px;
}
.pdf-layout-preview {
    min-width: 0;
}
.pdf-layout-preview > p {
    padding: 12px;
}
.pdf-layout-pages {
    padding: 10px;
    background: #e6eaf0;
}
.pdf-layout-pages canvas {
    display: block;
    width: 100%;
    height: auto;
    margin-bottom: 10px;
    background: white;
}
@media (max-width: 1100px) {
    .pdf-layout-editor {
        grid-template-columns: minmax(0, 1fr);
    }
}
.notice {
    margin-bottom: 16px;
    border: 1px solid #e3d4a4;
    background: #fff9e8;
    color: #8a742f;
    padding: 11px 13px;
    border-radius: 3px;
    font-size: 12px;
    line-height: 1.6;
}
.export-list {
    padding: 0 15px;
}
.export-list > div {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 0;
    border-bottom: 1px solid #dde4ed;
    gap: 12px;
}
.export-list > div:last-child {
    border: 0;
}
.export-list b {
    font-size: 12px;
}
.export-list small {
    display: block;
    font-size: 11px;
    color: #7e8ba1;
    margin-top: 4px;
}
dialog {
    width: min(760px, calc(100% - 24px));
    max-height: 90dvh;
    border: 1px solid #c7d2e0;
    border-radius: 5px;
    box-shadow: 0 12px 50px #233b6133;
    padding: 20px;
    color: var(--ink);
}
dialog::backdrop {
    background: #15274070;
}
.dialog-heading {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 20px;
    border-bottom: 1px solid #d6dfeb;
    padding-bottom: 12px;
}
.dialog-heading h2 {
    margin: 0;
    font-size: 18px;
    color: #28476f;
}
.dialog-actions {
    display: flex;
    justify-content: flex-end;
    gap: 8px;
    border-top: 1px solid var(--line);
    margin-top: 18px;
    padding-top: 15px;
}
.item-heading {
    display: flex;
    justify-content: space-between;
    font-size: 12px;
    margin: 12px 0;
}
.item-heading > span {
    color: #8592a4;
    font-size: 11px;
}
.invoice-item {
    display: grid;
    grid-template-columns: 3fr 1fr 1.3fr 1fr 30px;
    align-items: end;
    gap: 8px;
    margin-bottom: 12px;
}
.invoice-item label {
    font-size: 11px;
    color: #70829a;
}
.invoice-item input,
.invoice-item textarea,
.invoice-item select {
    width: 100%;
    padding: 8px;
    margin-top: 5px;
}
#live-total {
    text-align: right;
    font-weight: 600;
    font-size: 14px;
    padding: 16px 0;
}
#form-error {
    color: #b24141;
    font-size: 12px;
    line-height: 1.6;
}
#toast {
    position: fixed;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%) translateY(100px);
    max-width: 90vw;
    background: #233e65;
    color: white;
    border-radius: 4px;
    padding: 12px 18px;
    z-index: 100;
    box-shadow: 0 3px 15px #172e5322;
    font-size: 12px;
    transition: transform 0.2s;
}
#toast.show {
    transform: translateX(-50%) translateY(0);
}
#confirmation {
    width: min(440px, calc(100% - 24px));
    padding: 0;
}
#confirmation .dialog-heading {
    margin: 0;
    padding: 14px 18px;
    background: #233e65;
    border: 0;
}
#confirmation .dialog-heading h2,
#confirmation .dialog-heading .icon {
    color: #fff;
}
#confirmation-message {
    margin: 0;
    padding: 20px 18px;
    line-height: 1.6;
    overflow-wrap: anywhere;
}
#confirmation .dialog-actions {
    margin: 0;
    padding: 12px 18px;
    background: #f4f7fb;
    flex-wrap: wrap;
}
.mobile-menu {
    display: none;
}
@media (max-width: 950px) {
    .stats {
        grid-template-columns: 1fr 1fr;
    }
    #sidebar {
        width: 185px;
    }
    .main-shell {
        margin-left: 185px;
    }
    .brand {
        font-size: 16px;
        padding-inline: 13px;
    }
    main {
        padding: 20px;
    }
    .stats strong {
        font-size: 21px;
    }
}
@media (max-width: 650px) {
    #sidebar {
        width: 220px;
        top: 54px;
        transform: translateX(-100%);
        transition: transform 0.2s;
        box-shadow: 15px 0 40px #142e4e22;
    }
    #sidebar.opened {
        transform: translateX(0);
    }
    .main-shell {
        margin-left: 0;
    }
    header {
        height: 54px;
        padding: 0 12px;
        gap: 8px;
    }
    .mobile-menu {
        display: block;
    }
    .breadcrumb {
        flex: 1;
        font-size: 11px;
    }
    .breadcrumb span {
        padding: 0 5px;
    }
    .header-right {
        gap: 8px;
    }
    main {
        padding: 18px 12px;
    }
    .page-heading {
        gap: 8px;
        margin-bottom: 15px;
    }
    h1 {
        font-size: 20px;
    }
    .button {
        padding: 8px 10px;
        min-height: 36px;
    }
    .stats {
        gap: 9px;
    }
    .stats article {
        padding: 12px;
    }
    .stats article > div {
        font-size: 11px;
    }
    .stats strong {
        font-size: 20px;
    }
    .list-toolbar {
        align-items: stretch;
        flex-direction: column;
        padding: 9px;
    }
    .search input {
        width: 100%;
    }
    .tabs button {
        padding: 8px;
    }
    .form-grid {
        grid-template-columns: 1fr;
        gap: 0;
    }
    .invoice-item {
        grid-template-columns: 1fr 1fr 1fr 30px;
        background: #f3f6fa;
        padding: 10px;
        border-radius: 3px;
    }
    .invoice-item label:first-child {
        grid-column: 1/-1;
    }
    dialog {
        padding: 16px;
    }
    .dialog-heading h2 {
        font-size: 16px;
    }
    .panel-heading {
        padding: 11px 12px;
    }
    th,
    td {
        padding: 10px 12px;
    }
    .export-list {
        padding: 0 12px;
    }
    .export-list .button {
        font-size: 11px;
    }
    .pagination {
        padding: 10px;
        font-size: 10px;
    }
    .dashboard-actions {
        gap: 6px;
    }
    .dashboard-actions .button {
        font-size: 11px;
    }
}
/* Navigation and record actions */
.navigation-toggle {
    display: none;
    flex-shrink: 0;
}
#sidebar {
    transition: transform 0.2s;
}
.row-delete {
    border: 0;
    background: transparent;
    color: #ab5353;
    padding: 6px 8px;
    font-size: 11px;
    cursor: pointer;
}
.button.danger {
    border-color: #e1c4c4;
    color: #a24b4b;
}
.button.danger:hover,
.row-delete:hover {
    background: #fff0f0;
}
.button[hidden] {
    display: none;
}
#delete-record {
    margin-right: auto;
}
@media (max-width: 650px) {
    .navigation-toggle {
        display: inline-flex;
    }
}
.download-pdf {
    display: inline-block;
    padding: 6px;
    font-size: 11px;
}
.pdf-download {
    margin-top: 12px;
}

.table-actions {
    display: flex;
    align-items: center;
    flex-wrap: nowrap;
    gap: 5px;
    width: max-content;
}

.table-actions .action-button {
    flex-shrink: 0;
    min-height: 30px;
    padding: 5px 8px;
    font-size: 11px;
    white-space: nowrap;
}

.table-actions a:hover {
    text-decoration: none;
}

.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

.smtp-panel,
.import-panel {
    margin-bottom: 20px;
}
.workflow-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin: 15px 0;
}
.document-meta {
    display: flex;
    justify-content: space-between;
    gap: 20px;
    font-size: 13px;
    line-height: 1.7;
}
.document-description {
    white-space: pre-wrap;
    overflow-wrap: anywhere;
    min-width: 130px;
    max-width: 380px;
}
.document-total {
    text-align: right;
    font-size: 17px;
    font-weight: 600;
    margin: 18px 0;
}
.document-notes {
    white-space: pre-wrap;
}
.document-history > div {
    display: flex;
    justify-content: space-between;
    gap: 15px;
    padding: 10px 0;
    border-bottom: 1px solid #e0e7ef;
    font-size: 12px;
}
.document-history small {
    display: block;
    color: #7c8da4;
    font-size: 11px;
    margin-top: 4px;
}
.inline-error,
#import-feedback,
#smtp-feedback {
    color: #9e4a40;
    line-height: 1.6;
    font-size: 12px;
}
.validation-success {
    background: #edf6ed;
    border-color: #c6dcc7;
    color: #416f47;
}
#import-preview {
    margin-top: 20px;
}
.import-panel p {
    font-size: 12px;
    line-height: 1.6;
    color: #75869e;
}
#document-feedback {
    white-space: pre-wrap;
    line-height: 1.6;
    font-size: 12px;
    margin: 12px 0;
}
@media (max-width: 650px) {
    .document-meta {
        flex-direction: column;
        gap: 5px;
    }
    .document-history > div {
        flex-wrap: wrap;
    }
    .document-total {
        font-size: 15px;
    }
}

header .breadcrumb {
    flex: 1;
    min-width: 0;
}

.global-search {
    position: relative;
    width: clamp(180px, 22vw, 300px);
}

.global-search input {
    width: 100%;
    padding: 8px 10px;
}

.customer-picker {
    position: relative;
    min-width: 0;
}

.customer-picker .field:first-child {
    margin-bottom: 10px;
}

.search-results {
    position: absolute;
    top: 100%;
    left: 0;
    width: max(100%, 340px);
    max-width: min(440px, calc(100vw - 30px));
    max-height: 360px;
    overflow-y: auto;
    overscroll-behavior: contain;
    z-index: 30;
    border: 1px solid #bccbde;
    border-radius: 4px;
    background: #fff;
    box-shadow: 0 8px 24px #243f6926;
}

.search-results[hidden] {
    display: none;
}

.global-search .search-results {
    left: auto;
    right: 0;
    margin-top: 6px;
}

.customer-picker .search-results {
    top: 60px;
    width: 100%;
    max-height: 240px;
}

.search-result {
    display: block;
    width: 100%;
    padding: 12px;
    text-align: left;
    border: 0;
    border-bottom: 1px solid #e1e8f1;
    color: #304e77;
    background: #fff;
    white-space: normal;
    overflow-wrap: anywhere;
}

.search-result:hover,
.search-result:focus,
.search-result[aria-selected='true'] {
    background: #eaf1fb;
    outline: 2px solid #8ca9d0;
    outline-offset: -2px;
}

.search-result strong {
    display: block;
    font-size: 13px;
    font-weight: 600;
}

.search-result small {
    display: block;
    margin-top: 4px;
    font-size: 11px;
    color: #74859c;
}

.search-message {
    padding: 14px 12px;
    font-size: 12px;
    color: #74859c;
}

@media (max-width: 850px) {
    header .breadcrumb {
        display: none;
    }
}

@media (max-width: 650px) {
    .main-shell,
    #app,
    .panel {
        min-width: 0;
    }
    #sidebar:not(.opened) {
        box-shadow: none;
    }
    .header-right {
        flex: 1;
        min-width: 0;
    }
    .global-search {
        flex: 1;
        width: auto;
        min-width: 0;
    }
    .global-search .search-results {
        position: fixed;
        top: 58px;
        left: 10px;
        right: 10px;
        width: auto;
        max-width: none;
        max-height: 65dvh;
        margin-top: 0;
    }
    input,
    select,
    textarea {
        font-size: 16px;
    }
    .button,
    .icon,
    .search-result,
    .logout-button {
        min-height: 44px;
    }
    .global-search input {
        min-height: 40px;
    }
    .record-table,
    .record-table tbody {
        display: block;
        width: 100%;
    }
    .record-table thead {
        display: none;
    }
    .record-table tbody tr {
        display: grid;
        grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
        border-bottom: 1px solid #cdd8e7;
        background: #fff;
    }
    .record-table tbody tr:last-child {
        border-bottom: 0;
    }
    .record-table td {
        display: block;
        min-width: 0;
        white-space: normal;
        overflow-wrap: anywhere;
        border: 0;
        padding: 10px 12px;
    }
    .record-table td::before {
        content: attr(data-label);
        display: block;
        margin-bottom: 6px;
        font-size: 11px;
        font-weight: 400;
        color: #7c8ca2;
    }
    .record-table td:first-child,
    .record-table td:last-child {
        grid-column: 1 / -1;
    }
    .record-table td:first-child {
        background: #f4f7fb;
    }
    .record-table .row-link {
        max-width: 100%;
        white-space: normal;
        overflow-wrap: anywhere;
        font-size: 14px;
    }
    .table-actions {
        display: grid;
        grid-template-columns: repeat(3, minmax(0, 1fr));
        width: 100%;
        gap: 7px;
    }
    .table-actions .action-button {
        min-height: 44px;
        padding: 8px 5px;
        font-size: 12px;
    }
    .page-heading {
        flex-wrap: wrap;
    }
    .pagination {
        flex-wrap: wrap;
    }
    .pagination > span {
        flex: 1 1 150px;
    }
    .pagination .button {
        min-width: 44px;
        min-height: 44px;
    }
    dialog {
        max-height: calc(100dvh - 20px);
    }
    .dialog-actions {
        flex-wrap: wrap;
    }
    .invoice-item {
        grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) minmax(0, 1fr) 30px;
    }
}

/* List layout follows its own available width, including a visible sidebar. */
@container records (max-width: 960px) {
    .list-toolbar {
        flex-wrap: wrap;
    }
    .sort-toolbar {
        display: flex;
    }
    .sort-toolbar select,
    .sort-direction {
        min-height: 44px;
    }
    .record-table,
    .record-table tbody {
        display: block;
        width: 100%;
    }
    .record-table thead {
        display: none;
    }
    .record-table tbody tr {
        display: grid;
        grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
        border-bottom: 1px solid #cdd8e7;
        background: #fff;
    }
    .record-table tbody tr:last-child {
        border-bottom: 0;
    }
    .record-table td {
        display: block;
        min-width: 0;
        white-space: normal;
        overflow-wrap: anywhere;
        border: 0;
        padding: 10px 12px;
    }
    .record-table td::before {
        content: attr(data-label);
        display: block;
        margin-bottom: 6px;
        font-size: 11px;
        font-weight: 400;
        color: #7c8ca2;
    }
    .business-records td:first-child::before,
    .business-records td:nth-child(4)::before,
    .business-records td:last-child::before {
        display: none;
    }
    .record-table td:first-child,
    .record-table td:last-child {
        grid-column: 1 / -1;
    }
    .record-table td:first-child {
        background: #f4f7fb;
    }
    .record-table .row-link {
        max-width: 100%;
        white-space: normal;
        overflow-wrap: anywhere;
        font-size: 14px;
    }
    .table-actions {
        display: flex;
        flex-wrap: wrap;
        width: 100%;
        gap: 7px;
    }
    .table-actions .action-button {
        min-height: 44px;
        padding: 8px;
        font-size: 12px;
    }
    .pagination {
        flex-wrap: wrap;
    }
    .pagination > span {
        flex: 1 1 150px;
    }
    .pagination .button {
        min-width: 44px;
        min-height: 44px;
    }
}

/* Medium panels retain a compact row instead of stretching a phone card. */
@container records (min-width: 500px) and (max-width: 960px) {
    .business-records tbody tr {
        grid-template-columns: minmax(0, 1.1fr) minmax(0, 1.2fr) minmax(140px, 0.7fr);
        grid-template-rows: auto auto;
    }
    .business-records tbody tr:nth-child(even) {
        background: #f8fafd;
    }
    .business-records td {
        padding: 8px 12px;
    }
    .business-records td:first-child {
        grid-column: 1;
        grid-row: 1;
        background: transparent;
    }
    .business-records td:nth-child(2) {
        grid-column: 2;
        grid-row: 1;
    }
    .business-records td:nth-child(3) {
        grid-column: 3;
        grid-row: 1;
        overflow-wrap: normal;
    }
    .business-records td:nth-child(4) {
        grid-column: 1;
        grid-row: 2;
        align-self: center;
        padding-top: 0;
    }
    .business-records td:last-child {
        grid-column: 2 / -1;
        grid-row: 2;
        padding-top: 0;
    }
    .business-records td::before {
        margin-bottom: 3px;
    }
    .business-records .row-link {
        font-size: 12px;
    }
    .business-records .table-actions {
        justify-content: flex-end;
        gap: 5px;
    }
    .business-records .action-button {
        min-height: 32px;
        padding: 5px 8px;
        font-size: 11px;
    }
}
@media (pointer: coarse) {
    .record-panel .table-actions .action-button {
        min-height: 44px;
    }
}
/* Customer history keeps document actions readable at narrow widths. */
.customer-history-details {
    display: flex;
    justify-content: space-between;
    gap: 20px;
    flex-wrap: wrap;
    margin-bottom: 20px;
}
.customer-history-entry {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto auto auto;
    align-items: center;
    gap: 16px;
    padding: 14px;
    border-top: 1px solid var(--border, #d3deec);
}
.customer-history-entry:nth-child(even) {
    background: #f7f9fc;
}
.customer-history-entry small {
    display: block;
    color: #70829c;
    margin: 3px 0;
}
.customer-history-entry .row-link {
    overflow-wrap: anywhere;
}
@media (max-width: 850px) {
    .customer-history-entry {
        grid-template-columns: minmax(0, 1fr) auto;
        gap: 10px;
    }
    .customer-history-entry .table-actions {
        grid-column: 1 / -1;
    }
    .customer-history-entry .amount {
        grid-column: 2;
        grid-row: 1;
    }
    .customer-history-entry .customer-history-status {
        grid-column: 1 / -1;
    }
}
.service-template-picker {
    margin: 14px 0;
}
.service-template-picker summary {
    cursor: pointer;
    color: #31588e;
    margin-bottom: 12px;
}
.service-template-result {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 16px;
    padding: 12px;
    width: 100%;
    text-align: left;
    background: #f7f9fc;
    border: 1px solid #d3deec;
    color: inherit;
    cursor: pointer;
}
.service-template-result small {
    display: block;
    margin-top: 4px;
    overflow-wrap: anywhere;
}
.service-template-result > span:first-child {
    min-width: 0;
}
.service-template-result > span:last-child {
    flex-shrink: 0;
    text-align: right;
}
.service-template-entry {
    display: flex;
    justify-content: space-between;
    gap: 16px;
    flex-wrap: wrap;
    padding: 16px 0;
    border-bottom: 1px solid #d3deec;
}
.service-template-entry > div:first-child {
    min-width: 0;
    flex: 1 1 240px;
}
.service-description {
    white-space: pre-wrap;
    overflow-wrap: anywhere;
}
#payment-amount-field[hidden] {
    display: none;
}
.invoice-payment-summary {
    border-top: 1px solid #d3deec;
    padding-top: 8px;
    margin-bottom: 16px;
}
