:root {
    color-scheme: light;
    --app-bg: #f7f8f6;
    --app-surface: #ffffff;
    --app-surface-muted: #f4f6f3;
    --app-text: #15201b;
    --app-muted: #68766f;
    --app-border: #e1e6e1;
    --app-border-strong: #cbd5ce;
    --app-primary: #1f7a5b;
    --app-primary-hover: #175d46;
    --app-primary-soft: #e8f5ef;
    --app-info: #2563a8;
    --app-warning: #b86b0e;
    --app-danger: #b42318;
    --app-success: #1f7a46;
    --app-radius: 8px;
    --app-shadow: 0 18px 48px rgba(21, 32, 27, 0.07);
    --app-shadow-soft: 0 1px 2px rgba(21, 32, 27, 0.04), 0 12px 28px rgba(21, 32, 27, 0.035);

    --bs-body-bg: var(--app-bg);
    --bs-body-color: var(--app-text);
    --bs-body-font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    --bs-border-color: var(--app-border);
    --bs-link-color: var(--app-primary);
    --bs-link-hover-color: var(--app-primary-hover);
    --bs-primary: var(--app-primary);
    --bs-danger: var(--app-danger);
    --bs-success: var(--app-success);
    --bs-warning: var(--app-warning);
    --bs-info: var(--app-info);
    --bs-border-radius: var(--app-radius);
    --bs-border-radius-sm: 6px;
    --bs-border-radius-lg: 8px;
}

html,
body {
    min-height: 100%;
    background: var(--app-bg);
    color: var(--app-text);
    font-size: 15px;
    -webkit-font-smoothing: antialiased;
    text-rendering: optimizeLegibility;
}

body {
    margin: 0;
}

a {
    color: var(--app-primary);
    text-decoration-thickness: 1px;
    text-underline-offset: 0.2em;
}

a:hover {
    color: var(--app-primary-hover);
}

h1,
h2,
h3,
h4,
h5,
h6 {
    color: var(--app-text);
    font-weight: 700;
    letter-spacing: 0;
}

h1 {
    font-size: 2rem;
}

h2 {
    font-size: 1.55rem;
}

h3 {
    font-size: 1.35rem;
}

h4,
h5,
h6 {
    font-size: 1rem;
}

.content {
    width: 100%;
    max-width: 1480px;
    padding-top: 2rem;
    padding-bottom: 3rem;
    margin: 0 auto;
}

.content > h1:first-child,
.content > h2:first-child,
.content > h3:first-child {
    margin-bottom: 1.25rem;
}

.page-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    margin-bottom: 1.5rem;
    padding-bottom: 1.25rem;
    border-bottom: 1px solid var(--app-border);
}

.page-header h1,
.page-header h2,
.page-header h3 {
    margin: 0;
    font-size: 1.75rem;
    line-height: 1.15;
}

.title-with-icon,
.section-title-with-icon,
.metric-label {
    display: inline-flex;
    align-items: center;
    gap: 0.55rem;
}

.section-title-with-icon {
    gap: 0.5rem;
}

.ui-icon {
    display: inline-grid;
    flex: 0 0 auto;
    place-items: center;
    width: 2.15rem;
    height: 2.15rem;
    color: var(--app-primary);
    background: var(--app-primary-soft);
    border: 1px solid #c9e7da;
    border-radius: 8px;
}

.ui-icon::before {
    content: "";
    width: 1.05rem;
    height: 1.05rem;
    background: currentColor;
    mask-position: center;
    mask-repeat: no-repeat;
    mask-size: contain;
}

.ui-icon-sm {
    width: 1.65rem;
    height: 1.65rem;
    border-radius: 7px;
}

.ui-icon-sm::before {
    width: 0.9rem;
    height: 0.9rem;
}

.ui-icon-muted {
    color: #56645d;
    background: #f2f5f2;
    border-color: var(--app-border);
}

.ui-icon-warning {
    color: var(--app-warning);
    background: #fff4e2;
    border-color: #f1d19b;
}

.ui-icon-danger {
    color: var(--app-danger);
    background: #fff0ee;
    border-color: #efc0bb;
}

.ui-icon-info {
    color: var(--app-info);
    background: #eaf3fb;
    border-color: #c8ddf1;
}

.ui-icon-invoice::before {
    mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M6 2h9l5 5v15H6V2Zm8 2.5V8h3.5L14 4.5ZM8 11h8v1.6H8V11Zm0 4h8v1.6H8V15Z'/%3E%3C/svg%3E");
}

.ui-icon-quote::before {
    mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M5 3h14v18H5V3Zm2 2v14h10V5H7Zm2 3h6v1.6H9V8Zm0 3.5h6v1.6H9v-1.6Zm0 3.5h4v1.6H9V15Z'/%3E%3C/svg%3E");
}

.ui-icon-customer::before {
    mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M12 12a4.5 4.5 0 1 0-4.5-4.5A4.5 4.5 0 0 0 12 12Zm0 2c-4 0-7 2-7 4.8V21h14v-2.2C19 16 16 14 12 14Z'/%3E%3C/svg%3E");
}

.ui-icon-calendar::before {
    mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M7 2h2v2h6V2h2v2h4v18H3V4h4V2Zm12 8H5v10h14V10ZM5 8h14V6H5v2Z'/%3E%3C/svg%3E");
}

.ui-icon-catalog::before {
    mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M4 5h16v14H4V5Zm2 2v10h12V7H6Zm2 2h3v3H8V9Zm5 0h3v1.6h-3V9Zm0 3h3v1.6h-3V12Z'/%3E%3C/svg%3E");
}

.ui-icon-payment::before {
    mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M3 5h18v14H3V5Zm2 3v2h14V8H5Zm0 5v4h14v-4H5Zm2 1h5v1.6H7V14Z'/%3E%3C/svg%3E");
}

.ui-icon-reminder::before {
    mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M12 22a2.4 2.4 0 0 0 2.35-2h-4.7A2.4 2.4 0 0 0 12 22Zm7-5v-5a7 7 0 0 0-14 0v5l-2 2h18l-2-2Z'/%3E%3C/svg%3E");
}

.ui-icon-chart::before {
    mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M4 19h16v2H2V3h2v16Zm3-2V9h3v8H7Zm5 0V5h3v12h-3Zm5 0v-6h3v6h-3Z'/%3E%3C/svg%3E");
}

.ui-icon-euro::before {
    mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M14.5 5.5c-2.3 0-4 1.1-4.8 3H16v2H9.2A8 8 0 0 0 9.1 12c0 .5 0 1 .1 1.5H16v2H9.7c.8 1.9 2.5 3 4.8 3 1.4 0 2.6-.4 3.7-1.1v2.5c-1.1.6-2.4.9-3.9.9-3.8 0-6.5-2-7.5-5.3H4v-2h2.4A12 12 0 0 1 6.3 12c0-.5 0-1 .1-1.5H4v-2h2.8C7.8 5.2 10.5 3.2 14.3 3.2c1.5 0 2.8.3 3.9.9v2.5a7.1 7.1 0 0 0-3.7-1.1Z'/%3E%3C/svg%3E");
}

.ui-icon-company::before {
    mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M3 21V3h12v18h-2v-4H5v4H3Zm2-6h8V5H5v10Zm12 6V9h4v12h-4ZM7 7h2v2H7V7Zm4 0h2v2h-2V7Zm-4 4h2v2H7v-2Zm4 0h2v2h-2v-2Z'/%3E%3C/svg%3E");
}

.ui-icon-export::before {
    mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M5 3h10l4 4v14H5V3Zm9 1.8V8h3.2L14 4.8ZM8 11h8v2H8v-2Zm0 4h5v2H8v-2Z'/%3E%3C/svg%3E");
}

.ui-icon-user::before {
    mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M16 11a3.5 3.5 0 1 0-3.5-3.5A3.5 3.5 0 0 0 16 11ZM8 12a3 3 0 1 0-3-3 3 3 0 0 0 3 3Zm8 2c-3.3 0-6 1.7-6 3.8V20h12v-2.2C22 15.7 19.3 14 16 14ZM8 14c-2.7 0-5 1.4-5 3.2V20h5v-2.2c0-1.1.5-2.1 1.4-2.9A7.6 7.6 0 0 0 8 14Z'/%3E%3C/svg%3E");
}

.ui-icon-audit::before {
    mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M4 3h16v2H4V3Zm0 4h16v2H4V7Zm0 4h10v2H4v-2Zm0 4h10v2H4v-2Zm12.5 5-3.2-3.2 1.4-1.4 1.8 1.8 3.8-3.8 1.4 1.4-5.2 5.2Z'/%3E%3C/svg%3E");
}

.page-header p {
    max-width: 720px;
    margin-top: 0.4rem;
    color: var(--app-muted);
    font-size: 0.96rem;
}

.entity-workspace {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(340px, 380px);
    gap: 1.25rem;
    align-items: start;
}

.catalog-list-panel,
.catalog-form-panel {
    min-width: 0;
}

.form-card {
    position: sticky;
    top: 4.5rem;
}

.card {
    background: var(--app-surface);
    border: 1px solid var(--app-border);
    border-radius: var(--app-radius);
    box-shadow: var(--app-shadow-soft);
}

.card-body {
    padding: 1.35rem;
}

.card h5 {
    margin-bottom: 1rem;
    color: var(--app-text);
}

.business-form {
    display: grid;
    gap: 1rem;
}

.business-form-narrow {
    max-width: 980px;
}

.form-section {
    padding: 1.35rem;
    background: var(--app-surface);
    border: 1px solid var(--app-border);
    border-radius: var(--app-radius);
    box-shadow: var(--app-shadow-soft);
}

.form-section-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 1rem;
    margin-bottom: 1rem;
    padding-bottom: 0.85rem;
    border-bottom: 1px solid var(--app-border);
}

.form-section-header h4,
.form-section-header h5 {
    margin: 0;
}

.form-section-header p {
    max-width: 680px;
    margin: 0.25rem 0 0;
    color: var(--app-muted);
    font-size: 0.92rem;
}

.logo-upload-field {
    align-items: center;
    background: #f8fbf9;
    border: 1px solid var(--app-border);
    border-radius: 8px;
    display: flex;
    gap: 1rem;
    padding: 1rem;
}

.logo-preview {
    align-items: center;
    background: #fff;
    border: 1px dashed #b7c9c0;
    border-radius: 8px;
    color: var(--app-muted);
    display: flex;
    flex: 0 0 104px;
    font-size: .78rem;
    font-weight: 800;
    height: 76px;
    justify-content: center;
    letter-spacing: .08em;
    text-transform: uppercase;
}

.logo-preview img {
    max-height: 58px;
    max-width: 86px;
    object-fit: contain;
}

.logo-upload-content {
    flex: 1 1 auto;
    min-width: 0;
}

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

.form-priority-grid,
.form-support-grid,
.form-advanced-grid {
    display: grid;
    grid-template-columns: repeat(12, minmax(0, 1fr));
    gap: 1rem;
}

.form-priority-grid {
    padding: 1rem;
    background: #fbfcfb;
    border: 1px solid var(--app-border);
    border-radius: var(--app-radius);
}

.form-subsection {
    display: grid;
    gap: 0.9rem;
    margin-top: 1rem;
    padding-top: 1rem;
    border-top: 1px solid var(--app-border);
}

.form-subsection-title {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 1rem;
}

.form-subsection-title h6 {
    margin: 0;
    color: var(--app-text);
    font-size: 0.94rem;
    font-weight: 800;
}

.form-subsection-title p {
    margin: 0.2rem 0 0;
    color: var(--app-muted);
    font-size: 0.86rem;
}

.field-primary {
    grid-column: span 5;
}

.field-secondary {
    grid-column: span 3;
}

.field-compact {
    grid-column: span 4;
}

.field-half {
    grid-column: span 6;
}

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

.field-full {
    grid-column: 1 / -1;
}

.form-option-card {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    min-height: 2.75rem;
    padding: 0.7rem 0.85rem;
    background: #fbfcfb;
    border: 1px solid var(--app-border-strong);
    border-radius: var(--app-radius);
}

.form-option-card .form-check-input {
    margin: 0;
}

.form-option-card strong,
.form-option-card span {
    display: block;
}

.form-option-card span {
    color: var(--app-muted);
    font-size: 0.82rem;
    font-weight: 500;
}

.form-field {
    grid-column: span 4;
    min-width: 0;
}

.form-field-half {
    grid-column: span 6;
}

.form-field-wide {
    grid-column: span 8;
}

.form-field-full {
    grid-column: 1 / -1;
}

.form-field textarea.form-control,
textarea.form-control.textarea-tall {
    min-height: 7rem;
}

.form-actions {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: flex-end;
    gap: 0.65rem;
    padding-top: 0.25rem;
}

.form-actions .btn-primary {
    order: 2;
}

.form-actions .btn-secondary,
.form-actions .btn-outline-secondary {
    order: 1;
}

.form-actions-start {
    justify-content: flex-start;
}

.form-hint {
    margin: 0.35rem 0 0;
    color: var(--app-muted);
    font-size: 0.82rem;
}

.form-card-intro {
    margin: -0.25rem 0 1rem;
    color: var(--app-muted);
    font-size: 0.9rem;
}

.form-check-card {
    display: flex;
    align-items: center;
    gap: 0.7rem;
    min-height: 2.75rem;
    padding: 0.65rem 0.8rem;
    background: #fbfcfb;
    border: 1px solid var(--app-border-strong);
    border-radius: var(--app-radius);
}

.form-check-card .form-check-input {
    margin: 0;
}

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

.total-tile {
    padding: 0.95rem 1rem;
    background: #fbfcfb;
    border: 1px solid var(--app-border);
    border-radius: var(--app-radius);
}

.total-tile span {
    display: block;
    color: var(--app-muted);
    font-size: 0.78rem;
    font-weight: 800;
    letter-spacing: 0.04em;
    text-transform: uppercase;
}

.total-tile strong {
    display: block;
    margin-top: 0.25rem;
    color: var(--app-text);
    font-size: 1.12rem;
}

.table-responsive {
    border: 1px solid var(--app-border);
    border-radius: var(--app-radius);
    background: var(--app-surface);
    box-shadow: var(--app-shadow-soft);
    overflow: auto;
}

.line-items-grid {
    position: relative;
    overflow: visible !important;
    border: 1px solid var(--app-border);
    border-radius: var(--app-radius);
    background: var(--app-surface);
    display: grid;
    gap: 0;
    min-width: 1040px;
    box-shadow: 0 1px 2px rgba(25, 40, 34, 0.04);
}

.line-items-header,
.line-item-row {
    display: grid;
    grid-template-columns: minmax(280px, 1.25fr) minmax(300px, 1.45fr) 84px 116px 96px 112px 40px;
    gap: 0.75rem;
    align-items: center;
    padding: 0.72rem 1rem;
}

.line-items-header {
    color: var(--app-muted);
    font-size: 0.74rem;
    font-weight: 700;
    letter-spacing: 0.02em;
    text-transform: uppercase;
    background: var(--app-surface-muted);
    border-bottom: 1px solid var(--app-border);
}

.line-item-row {
    position: relative;
    border-bottom: 1px solid var(--app-border);
    background: #fff;
    transition: background-color 120ms ease;
}

.line-item-row:hover {
    background: #fbfcfb;
}

.line-item-row:last-child {
    border-bottom: 0;
}

.line-item-row .form-control {
    min-height: 2.45rem;
    padding-top: 0.45rem;
    padding-bottom: 0.45rem;
}

.line-item-total {
    font-weight: 700;
    color: var(--app-text);
    white-space: nowrap;
    text-align: right;
}

.line-item-remove {
    width: 30px;
    height: 30px;
    padding: 0;
    justify-self: end;
    border-radius: 6px;
    color: #8c3a34;
    background: transparent;
    border-color: transparent;
    font-size: 1.05rem;
    line-height: 1;
}

.line-item-remove:hover,
.line-item-remove:focus {
    color: var(--app-danger);
    background: #fff0ee;
    border-color: #efc0bb;
}

.table {
    margin-bottom: 0;
    --bs-table-bg: transparent;
    --bs-table-color: var(--app-text);
    --bs-table-border-color: var(--app-border);
    --bs-table-hover-bg: #f7faf7;
    --bs-table-hover-color: var(--app-text);
}

.table thead th {
    background: #fbfcfb;
    color: var(--app-muted);
    border-bottom: 1px solid var(--app-border);
    font-size: 0.72rem;
    font-weight: 700;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    white-space: nowrap;
}

.table th,
.table td {
    padding: 0.95rem 1rem;
    vertical-align: middle;
}

.table tbody tr {
    transition: background-color 120ms ease;
}

.table tbody strong {
    font-weight: 760;
}

.table tbody tr:last-child td {
    border-bottom: 0;
}

.table .user-role-select {
    min-width: 150px;
    min-height: 2.1rem;
    padding-top: 0.25rem;
    padding-bottom: 0.25rem;
}

.form-label,
label {
    color: var(--app-muted);
    font-weight: 600;
}

.form-control,
.form-select {
    min-height: 2.75rem;
    color: var(--app-text);
    background-color: var(--app-surface);
    border: 1px solid var(--app-border-strong);
    border-radius: var(--app-radius);
    box-shadow: none;
}

.form-select {
    cursor: pointer;
    background-color: #fbfcfa;
    background-image:
        linear-gradient(45deg, transparent 50%, var(--app-primary) 50%),
        linear-gradient(135deg, var(--app-primary) 50%, transparent 50%);
    background-position:
        calc(100% - 18px) 50%,
        calc(100% - 12px) 50%;
    background-size:
        6px 6px,
        6px 6px;
    background-repeat: no-repeat;
    padding-right: 2.45rem;
}

.form-select:hover {
    border-color: #97b8ad;
    background-color: #ffffff;
}

.form-select option,
.form-select optgroup {
    color: var(--app-text);
    background-color: #ffffff;
}

.form-select option {
    padding: 0.65rem 0.85rem;
}

.form-select option:checked {
    color: #ffffff;
    background-color: var(--app-primary);
}

.form-select option:hover,
.form-select option:focus {
    color: var(--app-text);
    background-color: var(--app-primary-soft);
}

.form-control:focus,
.form-select:focus,
.form-check-input:focus {
    border-color: var(--app-primary);
    box-shadow: 0 0 0 0.2rem rgba(33, 110, 90, 0.16);
}

.form-floating > label {
    color: var(--app-muted);
}

.form-floating > .form-control,
.form-floating > .form-select {
    min-height: 3.35rem;
}

.form-floating > input[type="time"].form-control {
    cursor: pointer;
    padding-right: 0.9rem;
}

input[type="time"].form-control::-webkit-calendar-picker-indicator {
    cursor: pointer;
    opacity: 0.75;
}

input[type="time"].form-control:hover::-webkit-calendar-picker-indicator {
    opacity: 1;
}

.form-control::placeholder {
    color: #9aa59e;
}

.form-check-input {
    border-color: var(--app-border-strong);
}

.form-check-input:checked {
    background-color: var(--app-primary);
    border-color: var(--app-primary);
}

.btn {
    min-height: 2.35rem;
    border-radius: var(--app-radius);
    font-weight: 650;
    box-shadow: none;
    transition: background-color 120ms ease, border-color 120ms ease, color 120ms ease, box-shadow 120ms ease;
}

.btn-sm {
    min-height: 2rem;
    border-radius: 6px;
    font-weight: 650;
}

.btn-primary {
    color: #fff;
    background-color: var(--app-primary);
    border-color: var(--app-primary);
    box-shadow: 0 8px 18px rgba(31, 122, 91, 0.16);
}

.btn-primary:hover,
.btn-primary:focus {
    color: #fff;
    background-color: var(--app-primary-hover);
    border-color: var(--app-primary-hover);
    box-shadow: 0 10px 24px rgba(31, 122, 91, 0.2);
}

.btn-secondary {
    color: var(--app-text);
    background-color: var(--app-surface);
    border-color: var(--app-border-strong);
}

.btn-secondary:hover,
.btn-outline-secondary:hover {
    color: var(--app-text);
    background-color: var(--app-surface-muted);
    border-color: var(--app-border-strong);
}

.btn-outline-primary {
    color: var(--app-primary);
    border-color: #97b8ad;
}

.btn-outline-primary:hover {
    color: #fff;
    background-color: var(--app-primary);
    border-color: var(--app-primary);
}

.btn-outline-danger {
    color: var(--app-danger);
    border-color: #e0a6a0;
}

.btn-outline-danger:hover {
    color: #fff;
    background-color: var(--app-danger);
    border-color: var(--app-danger);
}

.btn-quiet-danger {
    color: #8c3a34;
    background: transparent;
    border-color: transparent;
}

.btn-quiet-danger:hover,
.btn-quiet-danger:focus {
    color: var(--app-danger);
    background: #fff0ee;
    border-color: #efc0bb;
}

.alert {
    border-radius: var(--app-radius);
    border: 1px solid;
}

.alert-info {
    color: #194f74;
    background-color: #e8f3fa;
    border-color: #c6dfef;
}

.alert-warning {
    color: #704707;
    background-color: #fff6e6;
    border-color: #f2d79c;
}

.alert-danger {
    color: #842018;
    background-color: #fff0ee;
    border-color: #efb8b2;
}

.alert-success {
    color: #185b34;
    background-color: #e7f4ec;
    border-color: #b9dbc7;
}

.badge {
    border-radius: 999px;
    font-weight: 650;
    padding: 0.35rem 0.55rem;
}

.status-badge {
    display: inline-flex;
    align-items: center;
    min-height: 1.72rem;
    padding: 0.27rem 0.62rem;
    border-radius: 999px;
    border: 1px solid;
    font-size: 0.78rem;
    font-weight: 750;
    line-height: 1;
    white-space: nowrap;
}

.status-draft {
    color: #4d5a54;
    background: #f1f4f2;
    border-color: #d6ded8;
}

.status-sent {
    color: #1e4f83;
    background: #eaf3fb;
    border-color: #c8ddf1;
}

.status-paid {
    color: #17603a;
    background: #e7f5ec;
    border-color: #bfe0ca;
}

.status-overdue {
    color: #8a4a06;
    background: #fff4e2;
    border-color: #f1d19b;
}

.status-cancelled {
    color: #8c241c;
    background: #fff0ee;
    border-color: #efc0bb;
}

.list-toolbar {
    display: grid;
    grid-template-columns: minmax(240px, 1fr) repeat(3, minmax(160px, auto));
    gap: 0.75rem;
    align-items: end;
    margin-bottom: 1rem;
    padding: 0.85rem;
    background: var(--app-surface);
    border: 1px solid var(--app-border);
    border-radius: var(--app-radius);
    box-shadow: var(--app-shadow-soft);
}

.loading-state,
.empty-state {
    display: grid;
    justify-items: center;
    gap: 0.6rem;
    padding: 2.5rem 1.5rem;
    color: var(--app-muted);
    text-align: center;
    background: var(--app-surface);
    border: 1px solid var(--app-border);
    border-radius: var(--app-radius);
    box-shadow: var(--app-shadow-soft);
}

.empty-state-icon {
    display: inline-grid;
    place-items: center;
    width: 3rem;
    height: 3rem;
    color: var(--app-primary);
    background: var(--app-primary-soft);
    border: 1px solid #c9e7da;
    border-radius: 999px;
    font-size: 1.3rem;
    font-weight: 850;
}

.empty-state-icon .ui-icon {
    width: 1.35rem;
    height: 1.35rem;
    background: transparent;
    border: 0;
    border-radius: 0;
}

.empty-state-icon .ui-icon::before {
    width: 1.2rem;
    height: 1.2rem;
}

.empty-state h4 {
    margin: 0.2rem 0 0;
    color: var(--app-text);
    font-size: 1.05rem;
}

.empty-state p {
    max-width: 440px;
    margin: 0;
}

.empty-state .btn {
    margin-top: 0.35rem;
}

.empty-state-compact {
    align-content: center;
    min-height: 9rem;
    padding: 1.6rem 1rem;
    box-shadow: none;
}

.empty-state-compact .empty-state-icon {
    width: 2.45rem;
    height: 2.45rem;
}

.info-callout {
    display: flex;
    align-items: flex-start;
    gap: 0.75rem;
    padding: 0.95rem 1rem;
    color: var(--app-muted);
    background: #fbfcfb;
    border: 1px solid var(--app-border);
    border-radius: var(--app-radius);
}

.info-callout p {
    margin: 0;
}

.document-summary {
    display: grid;
    grid-template-columns: minmax(0, 1.3fr) repeat(3, minmax(150px, 0.55fr));
    gap: 1rem;
    margin-bottom: 1rem;
    padding: 1.35rem;
    background: var(--app-surface);
    border: 1px solid var(--app-border);
    border-radius: var(--app-radius);
    box-shadow: var(--app-shadow-soft);
}

.document-summary-main {
    min-width: 0;
}

.document-summary-main h4 {
    margin: 0.35rem 0 0;
    font-size: 1.45rem;
}

.document-summary-main p {
    margin: 0.45rem 0 0;
    color: var(--app-muted);
}

.document-summary-kpi {
    display: grid;
    align-content: center;
    gap: 0.35rem;
    min-height: 5.8rem;
    padding: 0.9rem 1rem;
    background: #fbfcfb;
    border: 1px solid var(--app-border);
    border-radius: var(--app-radius);
}

.document-summary-kpi span {
    color: var(--app-muted);
    font-size: 0.73rem;
    font-weight: 800;
    letter-spacing: 0.06em;
    text-transform: uppercase;
}

.document-summary-kpi strong {
    color: var(--app-text);
    font-size: 1.1rem;
}

.document-actions {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    margin: 0 0 1rem;
    padding: 0.85rem;
    background: var(--app-surface);
    border: 1px solid var(--app-border);
    border-radius: var(--app-radius);
    box-shadow: var(--app-shadow-soft);
}

.document-actions-primary,
.document-actions-secondary {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.55rem;
}

.document-actions-secondary {
    justify-content: flex-end;
}

.next-step-callout {
    display: flex;
    align-items: flex-start;
    gap: 0.85rem;
    margin-bottom: 1rem;
    padding: 1rem;
    background: linear-gradient(180deg, #ffffff 0%, #f7fbf8 100%);
    border: 1px solid #cfe7dc;
    border-radius: var(--app-radius);
    box-shadow: var(--app-shadow-soft);
}

.next-step-callout strong,
.next-step-callout span {
    display: block;
}

.next-step-callout span {
    margin-top: 0.2rem;
    color: var(--app-muted);
}

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

.detail-item {
    min-width: 0;
    padding: 0.85rem;
    background: #fbfcfb;
    border: 1px solid var(--app-border);
    border-radius: var(--app-radius);
}

.detail-item span {
    display: block;
    color: var(--app-muted);
    font-size: 0.76rem;
    font-weight: 800;
    letter-spacing: 0.04em;
    text-transform: uppercase;
}

.detail-item strong {
    display: block;
    margin-top: 0.25rem;
    color: var(--app-text);
    font-weight: 750;
    overflow-wrap: anywhere;
}

.detail-item-wide {
    grid-column: span 2;
}

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

.section-card-header h5 {
    margin: 0;
}

@media (max-width: 1100px) {
    .document-summary,
    .document-details-grid {
        grid-template-columns: 1fr 1fr;
    }

    .document-summary-main,
    .detail-item-wide {
        grid-column: 1 / -1;
    }
}

@media (max-width: 640px) {
    .document-summary,
    .document-details-grid {
        grid-template-columns: 1fr;
    }

    .table-responsive.mobile-card-table {
        overflow: visible;
        border: 0;
        background: transparent;
        box-shadow: none;
    }

    .mobile-card-table .table,
    .mobile-card-table .table thead,
    .mobile-card-table .table tbody,
    .mobile-card-table .table tr,
    .mobile-card-table .table th,
    .mobile-card-table .table td {
        display: block;
        width: 100%;
    }

    .mobile-card-table .table thead {
        display: none;
    }

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

    .mobile-card-table .table tr {
        padding: 0.9rem;
        background: var(--app-surface);
        border: 1px solid var(--app-border);
        border-radius: var(--app-radius);
        box-shadow: var(--app-shadow-soft);
    }

    .mobile-card-table .table td {
        display: grid;
        grid-template-columns: minmax(7.5rem, 0.42fr) minmax(0, 1fr);
        gap: 0.75rem;
        padding: 0.55rem 0;
        border-bottom: 1px solid #eef2ef;
        text-align: left !important;
    }

    .mobile-card-table .table td:last-child {
        border-bottom: 0;
    }

    .mobile-card-table .table td::before {
        content: attr(data-label);
        color: var(--app-muted);
        font-size: 0.72rem;
        font-weight: 800;
        letter-spacing: 0.04em;
        text-transform: uppercase;
    }

    .mobile-card-table .table-actions {
        justify-content: flex-start;
    }
}

.table-actions {
    display: inline-flex;
    flex-wrap: wrap;
    justify-content: flex-end;
    gap: 0.45rem;
}

.table-actions .btn {
    margin: 0 !important;
}

.table-actions .btn-primary {
    order: 1;
}

.table-actions .btn-outline-primary {
    order: 2;
}

.table-actions .btn-outline-secondary {
    order: 3;
}

.table-actions .btn-quiet-danger,
.table-actions .btn-outline-danger {
    order: 4;
}

.list-toolbar .form-floating {
    min-width: 0;
}

.audit-filters {
    grid-template-columns: minmax(220px, 1fr) repeat(4, minmax(150px, auto)) auto;
}

.catalog-toolbar {
    grid-template-columns: minmax(240px, 1fr) minmax(170px, auto) minmax(170px, auto);
}

.catalog-search {
    min-width: 0;
    width: 100%;
}

.catalog-autocomplete {
    position: relative;
    z-index: 20;
}

.catalog-autocomplete-icon {
    position: absolute;
    z-index: 1;
    top: 50%;
    left: 0.75rem;
    width: 0.9rem;
    height: 0.9rem;
    border: 2px solid var(--app-muted);
    border-radius: 50%;
    transform: translateY(-50%);
    pointer-events: none;
    opacity: 0.72;
}

.catalog-autocomplete-icon::after {
    position: absolute;
    right: -0.36rem;
    bottom: -0.22rem;
    width: 0.48rem;
    height: 2px;
    background: var(--app-muted);
    border-radius: 999px;
    content: "";
    transform: rotate(45deg);
}

.catalog-autocomplete .catalog-search {
    padding-left: 2.15rem;
}

.catalog-autocomplete.is-open .catalog-search,
.catalog-autocomplete .catalog-search:focus {
    border-color: rgba(20, 131, 95, 0.45);
    box-shadow: 0 0 0 0.18rem rgba(20, 131, 95, 0.1);
}

.catalog-autocomplete.is-open .catalog-autocomplete-icon,
.catalog-autocomplete:focus-within .catalog-autocomplete-icon {
    border-color: var(--app-primary);
    opacity: 1;
}

.catalog-autocomplete.is-open .catalog-autocomplete-icon::after,
.catalog-autocomplete:focus-within .catalog-autocomplete-icon::after {
    background: var(--app-primary);
}

.catalog-autocomplete-menu {
    position: absolute;
    z-index: 2000;
    top: calc(100% + 0.3rem);
    left: 0;
    width: min(520px, calc(100vw - 2rem));
    max-height: 310px;
    overflow-y: auto;
    padding: 0.35rem;
    background: var(--app-surface);
    border: 1px solid var(--app-border-strong);
    border-radius: var(--app-radius);
    box-shadow: 0 18px 40px rgba(25, 40, 34, 0.16);
}

.line-items-grid .catalog-autocomplete-menu {
    right: auto;
}

@media (max-width: 1100px) {
    .line-items-grid {
        min-width: 0;
        overflow-x: auto !important;
        overflow-y: visible !important;
    }

    .line-items-header,
    .line-item-row {
        min-width: 1040px;
    }
}

.catalog-autocomplete-item {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: center;
    gap: 1.25rem;
    width: 100%;
    min-height: 3.25rem;
    padding: 0.62rem 0.7rem;
    color: var(--app-text);
    text-align: left;
    background: transparent;
    border: 1px solid transparent;
    border-radius: 7px;
    cursor: pointer;
    user-select: none;
}

.catalog-autocomplete-heading,
.catalog-autocomplete-hint {
    padding: 0.32rem 0.55rem;
    color: var(--app-muted);
    font-size: 0.72rem;
    font-weight: 800;
    letter-spacing: 0.04em;
    text-transform: uppercase;
}

.catalog-autocomplete-item:hover,
.catalog-autocomplete-item:focus,
.catalog-autocomplete-item.is-active {
    background: #f3faf6;
    border-color: rgba(20, 131, 95, 0.16);
}

.catalog-autocomplete-main,
.catalog-autocomplete-meta {
    display: grid;
    gap: 0.02rem;
    min-width: 0;
}

.catalog-autocomplete-title {
    display: flex;
    align-items: center;
    gap: 0.45rem;
    min-width: 0;
}

.catalog-autocomplete-main strong {
    overflow: hidden;
    color: var(--app-text);
    font-weight: 700;
    font-size: 0.9rem;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.catalog-autocomplete-title small {
    flex: 0 0 auto;
    padding: 0.12rem 0.42rem;
    color: var(--app-primary);
    font-size: 0.68rem;
    font-weight: 800;
    background: var(--app-primary-soft);
    border: 1px solid rgba(20, 131, 95, 0.18);
    border-radius: 999px;
}

.catalog-autocomplete-main small,
.catalog-autocomplete-meta small {
    color: var(--app-muted);
    font-size: 0.76rem;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.catalog-autocomplete-meta {
    justify-items: end;
    text-align: right;
    white-space: nowrap;
}

.catalog-autocomplete-meta strong {
    color: var(--app-primary);
    font-size: 0.8rem;
    font-weight: 700;
}

.catalog-autocomplete-empty {
    display: grid;
    gap: 0.2rem;
    padding: 0.85rem;
    color: var(--app-muted);
    background: var(--app-surface-muted);
    border: 1px dashed var(--app-border-strong);
    border-radius: 7px;
}

.catalog-autocomplete-empty strong {
    color: var(--app-text);
    font-size: 0.92rem;
}

.catalog-autocomplete-empty span {
    font-size: 0.84rem;
}

.catalog-list-panel .table {
    table-layout: auto;
}

.catalog-list-panel .table th:first-child,
.catalog-list-panel .table td:first-child {
    min-width: 260px;
}

.catalog-list-panel .table th:last-child,
.catalog-list-panel .table td:last-child {
    min-width: 190px;
    white-space: nowrap;
}

.catalog-list-panel .text-muted {
    max-width: 420px;
    line-height: 1.35;
    white-space: normal;
}

.confirm-strip {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    margin-bottom: 1rem;
    padding: 0.9rem 1rem;
    color: #704707;
    background: #fff6e6;
    border: 1px solid #f2d79c;
    border-radius: var(--app-radius);
}

.confirm-strip p {
    margin: 0;
}

.confirm-actions {
    display: flex;
    gap: 0.5rem;
    white-space: nowrap;
}

.audit-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem 1rem;
    margin-top: 1rem;
    padding-top: 1rem;
    color: var(--app-muted);
    border-top: 1px solid var(--app-border);
    font-size: 0.88rem;
}

.text-muted {
    color: var(--app-muted) !important;
}

.validation-message,
.text-danger {
    color: var(--app-danger) !important;
}

.valid.modified:not([type=checkbox]) {
    border-color: var(--app-success);
}

.invalid {
    border-color: var(--app-danger);
}

.dropdown-menu,
.modal-content {
    background: var(--app-surface);
    border-color: var(--app-border);
    border-radius: var(--app-radius);
    box-shadow: var(--app-shadow);
}

.dropdown-item:hover {
    background: var(--app-primary-soft);
}

.auth-shell {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(340px, 460px);
    gap: 2rem;
    align-items: stretch;
    max-width: 1020px;
    margin: 1.5rem auto 0;
}

.auth-intro {
    display: flex;
    flex-direction: column;
    justify-content: flex-end;
    min-height: 520px;
    padding: 2rem;
    color: #f7fbf8;
    background: #14211d;
    border-radius: var(--app-radius);
    box-shadow: var(--app-shadow);
}

.auth-intro .eyebrow {
    color: #a7d5c3;
}

.auth-intro h1 {
    max-width: 580px;
    color: #ffffff;
    font-size: 2.05rem;
    line-height: 1.12;
}

.auth-intro p {
    max-width: 520px;
    margin: 1rem 0 0;
    color: rgba(247, 251, 248, 0.76);
}

.auth-card {
    align-self: center;
    width: 100%;
    padding: 1.6rem;
    background: var(--app-surface);
    border: 1px solid var(--app-border);
    border-radius: var(--app-radius);
    box-shadow: var(--app-shadow);
}

.auth-card h1,
.auth-card h2,
.auth-card h3 {
    margin-bottom: 0.35rem;
}

.auth-subtitle {
    margin-bottom: 1.4rem;
    color: var(--app-muted);
}

.auth-links {
    display: grid;
    gap: 0.45rem;
    margin-top: 1.25rem;
    padding-top: 1.25rem;
    border-top: 1px solid var(--app-border);
}

.auth-links p {
    margin: 0;
}

.settings-shell {
    display: grid;
    grid-template-columns: 260px minmax(0, 1fr);
    gap: 1.25rem;
    align-items: start;
}

.settings-header {
    margin-bottom: 1.5rem;
}

.settings-header h1 {
    margin-bottom: 0.35rem;
}

.settings-header p {
    margin: 0;
    color: var(--app-muted);
}

.settings-nav {
    position: sticky;
    top: 4.5rem;
    padding: 0.75rem;
    background: var(--app-surface);
    border: 1px solid var(--app-border);
    border-radius: var(--app-radius);
    box-shadow: 0 1px 2px rgba(25, 40, 34, 0.04);
}

.settings-panel {
    padding: 1.5rem;
    background: var(--app-surface);
    border: 1px solid var(--app-border);
    border-radius: var(--app-radius);
    box-shadow: 0 1px 2px rgba(25, 40, 34, 0.04);
}

.settings-panel > h1:first-child,
.settings-panel > h2:first-child,
.settings-panel > h3:first-child {
    margin-bottom: 1rem;
}

.settings-nav .nav-pills {
    gap: 0.25rem;
}

.settings-nav .nav-link {
    color: var(--app-muted);
    border-radius: 6px;
    font-weight: 650;
}

.settings-nav .nav-link:hover {
    color: var(--app-text);
    background: var(--app-surface-muted);
}

.settings-nav .nav-link.active {
    color: var(--app-primary);
    background: var(--app-primary-soft);
}

hr {
    border-color: var(--app-border);
    opacity: 1;
}

.blazor-error-boundary {
    color: var(--app-danger);
    background: #fff0ee;
    border: 1px solid #efb8b2;
    border-radius: var(--app-radius);
    padding: 1rem;
}

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

.darker-border-checkbox.form-check-input {
    border-color: var(--app-border-strong);
}

@media (max-width: 640.98px) {
    .content {
        padding-top: 1.25rem;
        padding-bottom: 2rem;
    }

    .d-flex.justify-content-between.align-items-center {
        align-items: flex-start !important;
        gap: 0.75rem;
    }

    .table th,
    .table td {
        padding: 0.75rem;
    }

    .list-toolbar {
        grid-template-columns: 1fr;
    }

    .page-header {
        align-items: flex-start;
        flex-direction: column;
    }

    .confirm-strip {
        align-items: flex-start;
        flex-direction: column;
    }
}

@media (max-width: 900px) {
    .auth-shell {
        grid-template-columns: 1fr;
        max-width: 560px;
    }

    .auth-intro {
        min-height: auto;
    }

    .settings-shell {
        grid-template-columns: 1fr;
    }

    .entity-workspace {
        grid-template-columns: 1fr;
    }

    .form-card {
        position: static;
    }

    .settings-nav {
        position: static;
    }
}

@media (max-width: 900px) {
    .form-field,
    .form-field-half,
    .form-field-wide,
    .form-field-full,
    .field-primary,
    .field-secondary,
    .field-compact,
    .field-half,
    .field-wide,
    .field-full {
        grid-column: 1 / -1;
    }

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