:root {
    --bg: #f4f6f8;
    --paper: #ffffff;
    --ink: #172026;
    --muted: #65717c;
    --line: #d9e0e6;
    --accent: #1b6fb8;
    --accent-strong: #0e528c;
    --success: #157a4f;
    --danger: #b3261e;
    --soft: #eaf3fb;
    --shadow: 0 10px 30px rgba(23, 32, 38, 0.08);
    font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
    box-sizing: border-box;
}

html {
    overflow-x: clip;
    overflow-y: scroll;
}

body {
    margin: 0;
    color: var(--ink);
    background: var(--bg);
    line-height: 1.5;
    overflow-x: clip;
}

a {
    color: var(--accent);
    text-decoration: none;
}

a:hover {
    color: var(--accent-strong);
}

.topbar {
    position: sticky;
    top: 0;
    z-index: 10;
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: nowrap;
    gap: 24px;
    min-height: 72px;
    padding: 12px clamp(18px, 4vw, 48px);
    background: rgba(255, 255, 255, 0.94);
    border-bottom: 1px solid var(--line);
    backdrop-filter: blur(12px);
}

.topbar-right {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 14px;
    flex: 0 1 auto;
    min-width: 0;
}

.topbar-brand {
    display: inline-flex;
    align-items: flex-end;
    gap: 8px;
    min-width: 0;
    flex: 0 1 auto;
}

.brand,
.doc-brand {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    min-width: 0;
    color: var(--ink);
    font-weight: 800;
    letter-spacing: 0;
}

.doc-brand-copy {
    display: grid;
    gap: 3px;
    min-width: 0;
}

.doc-brand-copy strong,
.doc-brand-copy span {
    overflow-wrap: anywhere;
}

.doc-brand-copy span {
    color: var(--muted);
    font-size: 13px;
    font-weight: 650;
}

.brand-logo {
    display: block;
    width: auto;
    max-width: 142px;
    max-height: 42px;
    object-fit: contain;
}

.app-info {
    flex: 0 0 auto;
    max-width: 16ch;
    overflow: hidden;
    color: var(--muted);
    font-size: 11px;
    font-weight: 700;
    line-height: 1;
    opacity: 0.65;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.doc-logo {
    max-width: 170px;
    max-height: 54px;
}

.brand-mark {
    display: inline-grid;
    place-items: center;
    width: 38px;
    height: 38px;
    border-radius: 8px;
    color: #fff;
    background: linear-gradient(135deg, #1b6fb8, #14936d);
    font-weight: 800;
}

.main-nav {
    display: flex;
    align-items: center;
    gap: 6px;
    flex-wrap: nowrap;
    overflow: visible;
}

.main-nav a,
.nav-dropdown-trigger {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    min-height: 40px;
    padding: 0 13px;
    border: 0;
    border-radius: 8px;
    color: var(--muted);
    background: transparent;
    font: inherit;
    font-weight: 650;
    text-decoration: none;
    white-space: nowrap;
    cursor: pointer;
}

.main-nav a.is-active,
.main-nav a:hover,
.main-nav a:focus-visible,
.nav-dropdown-trigger.is-active,
.nav-dropdown-trigger:hover,
.nav-dropdown-trigger:focus-visible,
.nav-dropdown[open] > .nav-dropdown-trigger,
.nav-dropdown:focus-within > .nav-dropdown-trigger {
    color: var(--accent-strong);
    background: var(--soft);
}

.nav-dropdown,
.user-menu {
    position: relative;
}

.nav-dropdown summary,
.user-menu summary {
    list-style: none;
}

.nav-dropdown summary::-webkit-details-marker,
.user-menu summary::-webkit-details-marker {
    display: none;
}

.dropdown-caret {
    flex: 0 0 auto;
    width: 14px;
    height: 14px;
    fill: none;
    stroke: currentColor;
    stroke-width: 2.4;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.nav-dropdown-menu {
    position: absolute;
    top: calc(100% + 8px);
    left: 0;
    z-index: 30;
    display: none;
    min-width: 168px;
    padding: 6px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #fff;
    box-shadow: 0 18px 45px rgba(16, 24, 40, 0.16);
}

.nav-dropdown[open] > .nav-dropdown-menu,
.user-menu[open] > .nav-dropdown-menu {
    display: grid;
    gap: 2px;
}

.nav-dropdown-menu .inline-form {
    display: block;
    width: 100%;
}

.dropdown-account-label {
    padding: 7px 10px 8px;
    color: var(--muted);
    font-size: 12px;
    font-weight: 500;
    line-height: 1.35;
    overflow-wrap: anywhere;
    cursor: default;
}

.nav-dropdown-menu a,
.dropdown-submit {
    display: flex;
    align-items: center;
    width: 100%;
    min-height: 36px;
    padding: 0 10px;
    border: 0;
    border-radius: 6px;
    color: var(--muted);
    background: transparent;
    font: inherit;
    font-size: 13px;
    font-weight: 700;
    text-align: left;
    text-decoration: none;
    white-space: nowrap;
    cursor: pointer;
}

.nav-dropdown-menu a.is-active,
.dropdown-submit.is-active,
.nav-dropdown-menu a:hover,
.nav-dropdown-menu a:focus-visible,
.dropdown-submit:hover,
.dropdown-submit:focus-visible {
    color: var(--accent-strong);
    background: var(--soft);
}

.dropdown-separator {
    height: 1px;
    margin: 4px 2px;
    background: var(--line);
}

.user-menu {
    display: flex;
    align-items: center;
    padding-left: 14px;
    border-left: 1px solid var(--line);
    white-space: nowrap;
}

.user-menu-trigger {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    min-height: 36px;
    padding: 0 10px;
    border-radius: 8px;
    color: var(--muted);
    font: inherit;
    font-size: 13px;
    font-weight: 750;
    cursor: pointer;
}

.user-menu-trigger.is-active,
.user-menu-trigger:hover,
.user-menu-trigger:focus-visible,
.user-menu[open] > .user-menu-trigger,
.user-menu:focus-within > .user-menu-trigger {
    color: var(--accent-strong);
    background: var(--soft);
}

.user-dropdown-menu {
    right: 0;
    left: auto;
    min-width: 176px;
}

.mobile-menu {
    position: relative;
    display: none;
    flex: 0 0 auto;
    margin-left: auto;
}

.topbar.is-nav-collapsed .topbar-right {
    display: none;
}

.topbar.is-nav-collapsed .mobile-menu {
    display: block;
}

.mobile-menu summary {
    list-style: none;
}

.mobile-menu summary::-webkit-details-marker {
    display: none;
}

.mobile-menu-trigger {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 42px;
    height: 42px;
    border: 1px solid var(--line);
    border-radius: 8px;
    color: var(--ink);
    background: #fff;
    cursor: pointer;
}

.mobile-menu-trigger:hover,
.mobile-menu-trigger:focus-visible,
.mobile-menu[open] > .mobile-menu-trigger {
    color: var(--accent-strong);
    border-color: #b7c6d2;
    background: var(--soft);
}

.burger-icon {
    display: grid;
    gap: 4px;
    width: 18px;
}

.burger-icon span {
    display: block;
    height: 2px;
    border-radius: 999px;
    background: currentColor;
}

.mobile-menu-panel {
    position: absolute;
    top: calc(100% + 10px);
    right: 0;
    z-index: 40;
    display: none;
    width: min(320px, calc(100vw - 24px));
    padding: 8px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #fff;
    box-shadow: 0 18px 45px rgba(16, 24, 40, 0.16);
}

.mobile-menu[open] > .mobile-menu-panel {
    display: grid;
}

.mobile-nav,
.mobile-nav-group {
    display: grid;
    gap: 2px;
}

.mobile-nav-group {
    margin-top: 6px;
    padding-top: 8px;
    border-top: 1px solid var(--line);
}

.mobile-nav-heading {
    padding: 6px 10px 4px;
    color: var(--muted);
    font-size: 11px;
    font-weight: 800;
    text-transform: uppercase;
    overflow-wrap: anywhere;
}

.mobile-nav .inline-form {
    display: block;
    width: 100%;
}

.mobile-nav a,
.mobile-nav .dropdown-submit {
    display: flex;
    align-items: center;
    width: 100%;
    min-height: 38px;
    padding: 0 10px;
    border: 0;
    border-radius: 6px;
    color: var(--muted);
    background: transparent;
    font: inherit;
    font-size: 13px;
    font-weight: 700;
    text-align: left;
    text-decoration: none;
    white-space: nowrap;
    cursor: pointer;
}

.mobile-nav a.is-active,
.mobile-nav .dropdown-submit.is-active,
.mobile-nav a:hover,
.mobile-nav a:focus-visible,
.mobile-nav .dropdown-submit:hover,
.mobile-nav .dropdown-submit:focus-visible {
    color: var(--accent-strong);
    background: var(--soft);
}

.visually-hidden {
    position: absolute !important;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0 0 0 0);
    white-space: nowrap;
    border: 0;
}

.topbar-button {
    min-height: 34px;
    padding: 0 11px;
    border: 1px solid var(--line);
    border-radius: 8px;
    color: var(--ink);
    background: #fff;
    font: inherit;
    font-size: 13px;
    font-weight: 750;
    cursor: pointer;
}

.topbar-button:hover {
    color: var(--accent-strong);
    border-color: #b7c6d2;
}

.page-shell {
    width: min(1240px, calc(100% - 32px));
    margin: 0 auto;
    padding: 34px 0 64px;
}

.page-heading,
.section-title,
.panel-title {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 18px;
}

.page-heading {
    margin-bottom: 24px;
}

.page-heading h1,
.panel-title h2,
.section-title h2 {
    margin: 0;
}

.page-heading h1 {
    font-size: 34px;
    line-height: 1.1;
}

.eyebrow {
    align-items: center;
    background: var(--soft);
    border-radius: 999px;
    color: var(--accent-strong);
    display: inline-flex;
    font-size: 12px;
    font-weight: 800;
    min-height: 26px;
    padding: 0 9px;
    width: max-content;
}

.settings-company-panel {
    display: grid;
    gap: 16px;
    margin-bottom: 22px;
}

.company-switch-list {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.company-switch-list .inline-form {
    max-width: 100%;
    min-width: 0;
}

.company-switch-button {
    display: inline-flex;
    align-items: center;
    min-height: 36px;
    max-width: 100%;
    padding: 0 12px;
    border: 1px solid var(--line);
    border-radius: 8px;
    color: var(--muted);
    background: #fff;
    font: inherit;
    font-size: 13px;
    font-weight: 750;
    overflow-wrap: anywhere;
    text-align: left;
    white-space: normal;
    cursor: pointer;
}

.company-switch-button.is-active,
.company-switch-button:hover,
.company-switch-button:focus-visible {
    color: var(--accent-strong);
    border-color: #b7c6d2;
    background: var(--soft);
}

.company-delete-button {
    width: 34px;
    height: 34px;
}

.company-create-form {
    display: grid;
    grid-template-columns: minmax(220px, 1fr) auto;
    align-items: end;
    gap: 12px;
}

.actions,
.form-actions {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 8px;
    flex-wrap: wrap;
}

.row-actions {
    width: 1%;
    white-space: nowrap;
    text-align: right;
}

.row-actions > * {
    vertical-align: middle;
}

.row-actions > * + * {
    margin-left: 8px;
}

.button,
button.button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 42px;
    padding: 0 16px;
    border: 1px solid var(--line);
    border-radius: 8px;
    color: var(--ink);
    background: #fff;
    font: inherit;
    font-weight: 750;
    cursor: pointer;
}

.button:hover {
    border-color: #b7c6d2;
    color: var(--accent-strong);
}

.button.primary {
    color: #fff;
    border-color: var(--accent);
    background: var(--accent);
}

.button.primary:hover {
    color: #fff;
    border-color: var(--accent-strong);
    background: var(--accent-strong);
}

.button.danger {
    color: var(--danger);
    border-color: #efb4af;
    background: #fff5f4;
}

.button.danger:hover {
    color: #fff;
    border-color: var(--danger);
    background: var(--danger);
}

.icon-button {
    display: inline-grid;
    place-items: center;
    width: 34px;
    height: 34px;
    border: 1px solid var(--line);
    border-radius: 8px;
    color: var(--muted);
    background: #fff;
    font: inherit;
    font-weight: 800;
    cursor: pointer;
}

.icon-button:hover {
    color: var(--accent-strong);
    border-color: #b7c6d2;
}

.icon-button svg {
    width: 20px;
    height: 20px;
    fill: none;
    stroke: currentColor;
    stroke-width: 2.4;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.icon-button.delete-button svg {
    width: 19px;
    height: 19px;
    stroke-width: 2.7;
}

.icon-button.danger:hover {
    color: var(--danger);
    border-color: #efb4af;
}

.flash {
    margin-bottom: 18px;
    padding: 14px 16px;
    border-radius: 8px;
    border: 1px solid var(--line);
    background: #fff;
    box-shadow: var(--shadow);
}

.flash-success {
    color: var(--success);
    border-color: #b7dfce;
    background: #f1fbf6;
}

.flash-error {
    color: var(--danger);
    border-color: #efb4af;
    background: #fff5f4;
}

.stats-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 14px;
    margin-bottom: 24px;
}

.stat-card,
.panel,
.content-block,
.empty-state,
.print-sheet {
    min-width: 0;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--paper);
    box-shadow: var(--shadow);
}

.stat-card {
    display: block;
    padding: 20px;
    color: var(--ink);
}

.stat-card span {
    display: block;
    font-size: 34px;
    font-weight: 850;
    line-height: 1;
}

.stat-card strong {
    display: block;
    margin-top: 8px;
    color: var(--muted);
}

.content-block,
.panel {
    padding: 20px;
}

.api-key-section {
    display: grid;
    gap: 12px;
    padding-top: 16px;
    border-top: 1px solid var(--line);
}

.api-key-section h3 {
    margin: 0;
    font-size: 16px;
}

.api-key-section p {
    margin: 8px 0 14px;
    color: var(--muted);
}

.api-key-actions {
    justify-content: flex-start;
}

.secret-output {
    font-family: ui-monospace, SFMono-Regular, Consolas, "Liberation Mono", monospace;
}

.filter-summary {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 14px;
    padding-bottom: 14px;
    border-bottom: 1px solid var(--line);
    color: var(--muted);
    font-size: 13px;
    font-weight: 750;
}

.filter-summary a {
    white-space: nowrap;
}

.empty-state {
    padding: 34px;
    text-align: center;
}

.content-block > .empty-state,
.panel > .empty-state {
    border: 0;
    background: transparent;
    box-shadow: none;
}

.empty-state h1,
.empty-state h2 {
    margin: 0 0 8px;
}

.empty-state p {
    margin: 0 auto 16px;
    max-width: 520px;
    color: var(--muted);
}

.empty-state pre {
    white-space: pre-wrap;
    text-align: left;
    background: #f7f9fb;
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 14px;
}

.split-layout {
    display: grid;
    grid-template-columns: minmax(320px, 0.85fr) minmax(0, 1.15fr);
    gap: 18px;
    align-items: start;
}

.settings-columns {
    grid-template-columns: repeat(2, minmax(0, 1fr));
}

.split-layout > *,
.form-grid > *,
.document-form > *,
.document-bottom > *,
.table-wrap {
    min-width: 0;
}

.form-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 14px;
}

.form-grid .panel-title,
.form-grid .form-actions,
.span-2 {
    grid-column: 1 / -1;
}

.field {
    display: grid;
    gap: 7px;
    color: var(--muted);
    font-size: 13px;
    font-weight: 750;
}

.form-note {
    margin: -4px 0 4px;
    color: var(--muted);
    font-size: 13px;
}

.button:disabled,
button.button:disabled {
    cursor: not-allowed;
    opacity: 0.55;
}

.subscription-panel {
    display: grid;
    gap: 20px;
    margin-bottom: 22px;
}

.subscription-heading,
.subscription-actions {
    align-items: center;
    gap: 16px;
}

.subscription-current {
    padding: 7px 12px;
    border-radius: 999px;
    color: var(--accent-strong);
    background: var(--soft);
    font-size: 13px;
}

.plan-usage {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
}

.plan-usage span {
    padding: 8px 11px;
    border: 1px solid var(--line);
    border-radius: 8px;
    color: var(--muted);
    background: #fff;
    font-size: 13px;
}

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

.plan-card {
    display: flex;
    flex-direction: column;
    gap: 14px;
    min-width: 0;
    padding: 18px;
    border: 1px solid var(--line);
    border-radius: 12px;
    background: #fff;
}

.plan-card.is-current {
    border-color: var(--accent);
    box-shadow: 0 0 0 2px rgba(27, 111, 184, 0.1);
}

.plan-card-header h3,
.plan-card-header p {
    margin: 0;
}

.plan-price {
    color: var(--muted);
    font-weight: 700;
}

.plan-card ul {
    flex: 1;
    margin: 0;
    padding-left: 20px;
    color: var(--muted);
}

.plan-card form,
.plan-card .button {
    width: 100%;
}

.plan-current-button {
    justify-content: center;
    cursor: default;
}

.subscription-actions {
    display: flex;
    justify-content: space-between;
    padding-top: 16px;
    border-top: 1px solid var(--line);
}

.subscription-actions p {
    margin: 0;
    color: var(--muted);
}

.document-logo-preview {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
}

.document-logo-preview-frame {
    display: grid;
    place-items: center;
    width: min(220px, 100%);
    height: 82px;
    padding: 12px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #fff;
}

.document-logo-preview-frame img,
.document-logo-preview-image {
    display: block;
    width: auto;
    max-width: 100%;
    max-height: 58px;
    object-fit: contain;
}

.document-logo-empty {
    color: var(--muted);
    font-size: 13px;
    font-weight: 750;
}

.checkbox-field {
    display: flex;
    align-items: center;
    align-self: end;
    min-height: 42px;
    padding: 0 0 4px;
}

.checkbox-field input {
    width: 18px;
    min-height: 18px;
}

input,
select,
textarea {
    width: 100%;
    min-height: 42px;
    padding: 10px 12px;
    border: 1px solid var(--line);
    border-radius: 8px;
    color: var(--ink);
    background: #fff;
    font: inherit;
    font-size: 15px;
}

input[type="date"] {
    -webkit-appearance: none;
    appearance: none;
    box-sizing: border-box;
    display: block;
    inline-size: 100%;
    min-inline-size: 0;
    max-inline-size: 100%;
    text-align: left;
}

input[type="date"]::-webkit-date-and-time-value {
    margin: 0;
    min-width: 0;
    text-align: left;
}

.date-control {
    display: block;
    width: 100%;
    min-width: 0;
    max-width: 100%;
    overflow: hidden;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #fff;
}

.date-control input[type="date"] {
    width: 100%;
    min-height: 40px;
    padding: 10px 12px;
    border: 0;
    border-radius: 0;
    background: transparent;
}

.date-control:focus-within {
    outline: 3px solid rgba(27, 111, 184, 0.16);
    border-color: var(--accent);
}

.date-control input[type="date"]:focus {
    outline: 0;
}

@supports (-webkit-touch-callout: none) {
    input[type="date"] {
        width: -webkit-fill-available;
    }
}

textarea {
    min-height: 86px;
    resize: vertical;
}

input:focus,
select:focus,
textarea:focus {
    outline: 3px solid rgba(27, 111, 184, 0.16);
    border-color: var(--accent);
}

.table-wrap {
    max-width: 100%;
    overflow-x: auto;
}

.table-wrap.compact {
    max-height: 620px;
}

table {
    width: 100%;
    border-collapse: collapse;
}

th,
td {
    padding: 12px 10px;
    border-bottom: 1px solid var(--line);
    text-align: left;
    vertical-align: top;
}

th {
    color: var(--muted);
    font-size: 12px;
    letter-spacing: 0.04em;
    text-transform: uppercase;
}

td small {
    display: block;
    margin-top: 3px;
    color: var(--muted);
}

.master-data-table tr.is-editing {
    background: #f0f7fd;
}

.master-data-table tr.is-editing td {
    border-bottom-color: #b7c6d2;
}

.num {
    text-align: right;
    white-space: nowrap;
}

.nowrap {
    white-space: nowrap;
}

.pill {
    display: inline-flex;
    align-items: center;
    min-height: 26px;
    padding: 0 9px;
    border-radius: 999px;
    color: var(--accent-strong);
    background: var(--soft);
    font-size: 12px;
    font-weight: 800;
    white-space: nowrap;
}

.inline-form {
    display: inline-flex;
    margin: 0;
}

.document-form {
    display: grid;
    gap: 18px;
}

.document-form + .document-form {
    margin-top: 24px;
}

.document-meta {
    grid-template-columns: repeat(4, minmax(0, 1fr));
}

.auto-invoice-options {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 14px;
}

.line-editor .panel-title {
    margin-bottom: 14px;
}

.lines th:nth-child(1) {
    width: 210px;
}

.lines th:nth-child(3),
.lines th:nth-child(4),
.lines th:nth-child(5),
.lines th:nth-child(6) {
    width: 110px;
}

.lines th:nth-child(8) {
    width: 48px;
}

.line-row textarea {
    width: 100%;
    min-width: 0;
    height: 140px;
    min-height: 100px;
}

.document-bottom {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 360px;
    gap: 18px;
    align-items: start;
}

.totals-box dl,
.print-summary dl,
.document-facts {
    margin: 0;
}

.totals-box dl div,
.print-summary dl div,
.document-facts div {
    display: flex;
    justify-content: space-between;
    gap: 18px;
    padding: 8px 0;
    border-bottom: 1px solid var(--line);
}

.totals-box dt,
.print-summary dt,
.document-facts dt {
    color: var(--muted);
    font-weight: 750;
}

.totals-box dd,
.print-summary dd,
.document-facts dd {
    margin: 0;
    text-align: right;
    font-weight: 800;
}

.totals-box .grand,
.print-summary .grand {
    padding-top: 14px;
    border-bottom: 0;
    font-size: 20px;
}

.print-sheet {
    max-width: 920px;
    margin: 0 auto;
    padding: 54px;
}

.document-head,
.document-addresses {
    display: flex;
    justify-content: space-between;
    gap: 32px;
}

.document-head {
    align-items: flex-start;
    margin-bottom: 54px;
}

.doc-title {
    text-align: right;
}

.doc-title h2 {
    margin: 0;
    font-size: 34px;
}

.doc-title p {
    margin: 6px 0 0;
    color: var(--muted);
    font-weight: 800;
}

.document-addresses {
    align-items: flex-start;
    margin-bottom: 34px;
}

.address-stack {
    width: min(430px, 100%);
}

.sender-address {
    margin-bottom: 18px;
    padding-bottom: 14px;
    border-bottom: 1px solid var(--line);
}

.sender-address address {
    color: var(--muted);
    font-size: 13px;
}

.sender-address p {
    margin: 6px 0 0;
    color: var(--muted);
    font-size: 13px;
}

address {
    margin-top: 8px;
    font-style: normal;
    white-space: pre-line;
}

.label {
    color: var(--muted);
    font-size: 12px;
    font-weight: 800;
    letter-spacing: 0.06em;
    text-transform: uppercase;
}

.document-facts {
    min-width: 280px;
}

.document-text,
.document-notes {
    margin: 26px 0;
}

.print-lines {
    margin-top: 24px;
}

.print-summary {
    display: flex;
    justify-content: flex-end;
    margin-top: 24px;
}

.print-summary dl {
    width: min(390px, 100%);
}

.auth-page {
    min-height: 100vh;
    background:
        linear-gradient(135deg, rgba(27, 111, 184, 0.12), rgba(20, 147, 109, 0.1)),
        var(--bg);
}

.auth-shell {
    display: grid;
    place-items: center;
    min-height: 100vh;
    padding: 24px;
}

.auth-panel {
    width: min(460px, 100%);
    padding: 32px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--paper);
    box-shadow: var(--shadow);
}

.auth-brand {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 18px;
    margin-bottom: 26px;
}

.auth-logo {
    display: block;
    width: auto;
    max-width: 190px;
    max-height: 58px;
    object-fit: contain;
}

.auth-copy {
    margin-bottom: 20px;
}

.auth-copy h1 {
    margin: 0;
    font-size: 28px;
    line-height: 1.12;
}

.auth-muted {
    margin: 10px 0 0;
    color: var(--muted);
    font-size: 14px;
    font-weight: 650;
}

.auth-form {
    display: grid;
    gap: 14px;
}

.auth-actions {
    display: grid;
    gap: 10px;
}

.auth-secondary {
    margin: 18px 0 0;
    color: var(--muted);
    font-size: 14px;
    font-weight: 650;
    text-align: center;
}

@media (max-width: 980px) {
    .plan-grid {
        grid-template-columns: 1fr;
    }

    .page-heading,
    .document-head,
    .document-addresses {
        align-items: flex-start;
        flex-direction: column;
    }

    .topbar {
        gap: 12px;
        padding-inline: clamp(12px, 4vw, 24px);
    }

    .topbar-right {
        display: none;
    }

    .mobile-menu {
        display: block;
    }

    .split-layout,
    .document-bottom,
    .auto-invoice-options {
        grid-template-columns: 1fr;
    }

    .stats-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .document-meta {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .doc-title {
        text-align: left;
    }
}

@media (max-width: 760px) {
    .documents-table-wrap,
    .table-wrap.compact.master-data-table-wrap {
        overflow-x: visible;
        overflow-y: visible;
        max-height: none;
    }

    .documents-table,
    .documents-table tbody,
    .master-data-table,
    .master-data-table tbody {
        display: block;
        width: 100%;
    }

    .documents-table thead,
    .master-data-table thead {
        position: absolute;
        width: 1px;
        height: 1px;
        padding: 0;
        margin: -1px;
        overflow: hidden;
        clip: rect(0 0 0 0);
        white-space: nowrap;
        border: 0;
    }

    .documents-table tbody,
    .master-data-table tbody {
        display: grid;
        gap: 12px;
    }

    .documents-table tr,
    .master-data-table tr {
        display: grid;
        padding: 12px;
        border: 1px solid var(--line);
        border-radius: 8px;
        background: #fff;
    }

    .documents-table td,
    .master-data-table td {
        display: grid;
        grid-template-columns: 86px minmax(0, 1fr);
        gap: 10px;
        min-width: 0;
        padding: 8px 0;
        border-bottom: 1px solid var(--line);
    }

    .master-data-table td {
        grid-template-columns: 104px minmax(0, 1fr);
    }

    .master-data-table td small {
        display: none;
    }

    .documents-table td::before,
    .master-data-table td::before {
        color: var(--muted);
        font-size: 11px;
        font-weight: 800;
        letter-spacing: 0.04em;
        text-transform: uppercase;
    }

    .documents-table td:nth-child(1)::before {
        content: "Nummer";
    }

    .documents-table td:nth-child(2)::before {
        content: "Datum";
    }

    .documents-table td:nth-child(3)::before {
        content: "Kunde";
    }

    .documents-table td:nth-child(4)::before {
        content: "Status";
    }

    .documents-table td:nth-child(5)::before {
        content: "Summe";
    }

    .customers-table td:nth-child(1)::before {
        content: "Kundennr.";
    }

    .customers-table td:nth-child(2)::before {
        content: "Name";
    }

    .customers-table td:nth-child(3)::before {
        content: "Ort";
    }

    .customers-table td:nth-child(4)::before {
        content: "Kontakt";
    }

    .items-table td:nth-child(1)::before {
        content: "Nr.";
    }

    .items-table td:nth-child(2)::before {
        content: "Artikel";
    }

    .items-table td:nth-child(3)::before {
        content: "Einheit";
    }

    .items-table td:nth-child(4)::before {
        content: "Netto";
    }

    .items-table td:nth-child(5)::before {
        content: "USt.";
    }

    .users-table td:nth-child(1)::before {
        content: "Benutzer";
    }

    .users-table td:nth-child(2)::before {
        content: "Rolle";
    }

    .users-table td:nth-child(3)::before {
        content: "Status";
    }

    .users-table td:nth-child(4)::before {
        content: "Letzte Anmeldung";
    }

    .documents-table td:last-child,
    .master-data-table td:last-child {
        border-bottom: 0;
    }

    .documents-table .num,
    .master-data-table .num {
        text-align: left;
        white-space: normal;
    }

    .documents-table .pill,
    .master-data-table .pill {
        justify-self: start;
        max-width: 100%;
    }

    .documents-table .row-actions,
    .master-data-table .row-actions {
        display: flex;
        flex-wrap: wrap;
        gap: 8px;
        justify-content: flex-start;
        width: 100%;
        white-space: normal;
        text-align: left;
    }

    .documents-table .row-actions::before,
    .master-data-table .row-actions::before {
        display: none;
    }

    .documents-table .row-actions > * + *,
    .master-data-table .row-actions > * + * {
        margin-left: 0;
    }

    .line-editor .panel-title {
        align-items: flex-start;
        flex-direction: column;
        gap: 10px;
    }

    .line-editor .panel-title .button {
        width: 100%;
    }

    .table-wrap.lines {
        overflow-x: visible;
    }

    .lines table,
    .lines tbody {
        display: block;
        width: 100%;
    }

    .lines thead {
        position: absolute;
        width: 1px;
        height: 1px;
        padding: 0;
        margin: -1px;
        overflow: hidden;
        clip: rect(0 0 0 0);
        white-space: nowrap;
        border: 0;
    }

    .lines tbody {
        display: grid;
        gap: 14px;
    }

    .lines .line-row {
        display: grid;
        gap: 12px;
        padding: 14px;
        border: 1px solid var(--line);
        border-radius: 8px;
        background: #fff;
    }

    .lines .line-row td {
        display: grid;
        gap: 6px;
        width: 100%;
        min-width: 0;
        padding: 0;
        border-bottom: 0;
    }

    .lines .line-row td::before {
        color: var(--muted);
        font-size: 12px;
        font-weight: 800;
        letter-spacing: 0.04em;
        text-transform: uppercase;
    }

    .lines .line-row td:nth-child(1)::before {
        content: "Artikel";
    }

    .lines .line-row td:nth-child(2)::before {
        content: "Beschreibung";
    }

    .lines .line-row td:nth-child(3)::before {
        content: "Menge";
    }

    .lines .line-row td:nth-child(4)::before {
        content: "Einheit";
    }

    .lines .line-row td:nth-child(5)::before {
        content: "Preis";
    }

    .lines .line-row td:nth-child(6)::before {
        content: "Steuer";
    }

    .lines .line-row td:nth-child(7)::before {
        content: "Summe";
    }

    .lines .line-row td:nth-child(8) {
        justify-items: end;
    }

    .lines .line-row td:nth-child(8)::before {
        display: none;
    }

    .lines .line-row textarea {
        width: 100%;
        min-width: 0;
        height: auto;
        min-height: 120px;
    }

    .lines .line-total {
        text-align: left;
        white-space: normal;
    }
}

@media (max-width: 620px) {
    .subscription-actions {
        align-items: stretch;
        flex-direction: column;
    }

    .page-shell {
        width: 100%;
        padding: 20px 10px 64px;
    }

    .page-heading h1 {
        font-size: 28px;
    }

    .stats-grid,
    .form-grid,
    .document-meta,
.company-create-form {
        grid-template-columns: 1fr;
    }

    .span-2,
    .form-grid .panel-title,
    .form-grid .form-actions {
        grid-column: auto;
    }

    .content-block,
    .panel,
    .print-sheet {
        padding: 16px;
    }

    .auth-panel {
        padding: 22px;
    }

    .actions {
        width: 100%;
        justify-content: flex-start;
    }
	
    .filter-summary {
        align-items: flex-start;
        flex-direction: column;
    }

    .button {
        flex: 1 1 auto;
    }
}


@media (max-width: 320px) {
	.actions > .inline-form {
        flex: 1 1 auto;
        flex: 1 1 100%;
        min-width: 0;
        width: 100%;
    }
}

@page {
    size: A4;
    margin: 0;
}

@media print {
    html,
    body {
        background: #fff;
        overflow: visible;
    }

    .topbar,
    .no-print,
    .flash {
        display: none !important;
    }

    .page-shell {
        width: 100%;
        padding: 0;
    }

    .print-sheet {
        width: 100%;
        max-width: none;
        min-height: auto;
        border: 0;
        border-radius: 0;
        box-shadow: none;
        padding: 16mm;
    }

    a {
        color: inherit;
    }
}
