.accounting-document-page {
    min-height: calc(100vh - 72px);
    padding: 10px;
    overflow: auto;
    min-width: 0;
    max-width: 100%;
}

.accounting-document-card {
    min-height: calc(100vh - 92px);
    margin: 0;
    display: flex;
    flex-direction: column;
    min-width: 0;
    max-width: 100%;
}

/* List pages (invoices / documents / payments): gap from app header.
   Editors keep their own .is-editor-page spacing. */
.accounting-document-page:not(.is-editor-page) {
    padding: 16px 10px 12px;
}

.accounting-document-page:not(.is-editor-page) .accounting-document-card {
    min-height: calc(100vh - 100px);
    min-height: calc(100dvh - 100px);
}

.accounting-document-header {
    flex: 0 0 auto;
}

.accounting-document-title-row {
    display: flex;
    align-items: center;
    gap: 12px;
}

.accounting-document-title-icon {
    width: 44px;
    height: 44px;
    flex: 0 0 44px;
    display: grid;
    place-items: center;
    border-radius: 12px;
    background: linear-gradient(135deg, var(--primary), var(--primary-dark));
    color: #fff;
    box-shadow: 0 6px 16px rgba(30, 136, 229, .22);
}

.accounting-document-title-icon svg {
    width: 24px;
    height: 24px;
}

.accounting-document-subtitle {
    margin-top: 4px;
    color: var(--text-light);
    font-size: 12px;
}

.accounting-document-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.accounting-document-actions .btn,
.accounting-document-actions .btn-outline {
    min-width: auto;
    min-height: 40px;
    padding: 9px 14px;
    white-space: nowrap;
}

.accounting-document-actions .btn-outline {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 7px;
}

.accounting-document-danger-button {
    color: var(--danger);
    border-color: rgba(244, 67, 54, .35);
}

.accounting-document-danger-button:hover {
    color: #fff;
    background: var(--danger);
    border-color: var(--danger);
}

.wad-action-symbol {
    font-size: 18px;
    font-weight: 800;
    line-height: 1;
}

.accounting-document-body {
    flex: 1;
    min-height: 0;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 12px;
    padding: 14px;
}

.accounting-document-meta {
    flex: 0 0 auto;
    display: flex;
    flex-wrap: wrap;
    align-items: flex-end;
    gap: 12px;
    margin: 0;
    padding: 14px;
}

.accounting-document-field {
    min-width: 0;
    display: flex;
    flex-direction: column;
    justify-content: flex-end;
    gap: 6px;
    flex: 1 1 140px;
}

.accounting-document-number-field {
    flex: 1 1 200px;
    max-width: 280px;
}

.accounting-document-date-field {
    flex: 1 1 150px;
    max-width: 180px;
}

.accounting-document-comment-field {
    flex: 2 1 260px;
}

.accounting-document-year-field {
    flex: 1 1 200px;
    min-width: 0;
    position: relative;
    z-index: 1;
}

.accounting-document-year-field:has(.wad-year-picker.is-open) {
    z-index: 30;
}

.accounting-document-status-field {
    flex: 1 1 140px;
    max-width: 180px;
}

.accounting-document-field .form-control {
    width: 100%;
    min-width: 0;
    height: 42px;
    text-align: right;
    direction: rtl;
    color: var(--text);
}

.accounting-document-field #wad-date {
    text-align: center;
    direction: ltr;
}

.accounting-document-date-field .modal-date-input {
    height: 42px;
    box-sizing: border-box;
    border: 1px solid var(--border);
    border-radius: 10px;
    background: #fff;
    box-shadow: none;
}

.accounting-document-date-field .modal-date-input:focus-within {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(30, 136, 229, .12);
}

.accounting-document-date-field .modal-date-input.is-locked {
    background: #f8fafc;
    color: var(--text-light);
    border-color: var(--border);
}

.accounting-document-date-field .modal-date-segment {
    color: var(--text);
}

.accounting-document-date-field .modal-date-segment:disabled {
    color: var(--text-light);
    cursor: default;
}

.wad-year-picker {
    --wad-year-color: #1e88e5;
    position: relative;
    width: 100%;
}

.wad-year-trigger {
    --wad-year-color: #1e88e5;
    width: 100%;
    min-height: 42px;
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 7px 12px;
    border: 1px solid color-mix(in srgb, var(--wad-year-color) 48%, #cbd5e1);
    border-radius: 12px;
    background:
        linear-gradient(180deg, #fff, color-mix(in srgb, var(--wad-year-color) 14%, #fff));
    color: #26364a;
    box-shadow: 0 4px 14px rgba(15, 23, 42, .05);
    cursor: pointer;
    text-align: right;
    transition: border-color .15s ease, box-shadow .15s ease, background .15s ease;
}

.wad-year-trigger:hover:not(:disabled),
.wad-year-picker.is-open .wad-year-trigger {
    border-color: color-mix(in srgb, var(--wad-year-color) 70%, #94a3b8);
    box-shadow: 0 6px 18px rgba(15, 23, 42, .08);
}

.wad-year-trigger:focus-visible {
    outline: 2px solid color-mix(in srgb, var(--wad-year-color) 55%, transparent);
    outline-offset: 2px;
}

.wad-year-trigger:disabled {
    opacity: .72;
    cursor: default;
    background: #f8fafc;
}

.wad-year-trigger.is-empty {
    --wad-year-color: #94a3b8;
}

.wad-year-swatch {
    width: 10px;
    height: 10px;
    flex: 0 0 10px;
    border-radius: 50%;
    background: var(--wad-year-color, #1e88e5);
    box-shadow: 0 0 0 4px color-mix(in srgb, var(--wad-year-color, #1e88e5) 25%, transparent);
}

.wad-year-trigger-text,
.wad-year-option-text {
    display: flex;
    flex-direction: column;
    gap: 1px;
    min-width: 0;
    flex: 1 1 auto;
    line-height: 1.35;
    text-align: right;
}

.wad-year-trigger-text strong,
.wad-year-option-text strong {
    font-size: 13px;
    font-weight: 700;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.wad-year-trigger-text small,
.wad-year-option-text small {
    color: var(--text-light);
    font-size: 11px;
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.wad-year-caret {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: #64748b;
    transition: transform .15s ease;
}

.wad-year-picker.is-open .wad-year-caret {
    transform: rotate(180deg);
}

.wad-year-menu {
    position: absolute;
    top: calc(100% + 6px);
    right: 0;
    left: 0;
    z-index: 50;
    max-height: 260px;
    overflow: auto;
    padding: 6px;
    border: 1px solid #d7e0ea;
    border-radius: 14px;
    background: #fff;
    box-shadow: 0 16px 36px rgba(15, 23, 42, .14);
}

.wad-year-menu[hidden] {
    display: none;
}

.wad-year-option {
    --wad-year-color: #1e88e5;
    width: 100%;
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    border: 0;
    border-radius: 10px;
    background: transparent;
    color: inherit;
    cursor: pointer;
    text-align: right;
}

.wad-year-option:hover,
.wad-year-option:focus-visible {
    background: color-mix(in srgb, var(--wad-year-color) 10%, #f8fafc);
    outline: none;
}

.wad-year-option.is-selected {
    background: color-mix(in srgb, var(--wad-year-color) 16%, #eef6ff);
}

.wad-year-latest-badge {
    flex: 0 0 auto;
    padding: 3px 8px;
    border-radius: 999px;
    background: color-mix(in srgb, var(--wad-year-color) 18%, #fff);
    border: 1px solid color-mix(in srgb, var(--wad-year-color) 35%, #cbd5e1);
    color: color-mix(in srgb, var(--wad-year-color) 70%, #0f172a);
    font-size: 10px;
    font-weight: 800;
    white-space: nowrap;
}

.accounting-document-field .form-control[readonly] {
    background: #f8fafc;
    color: var(--text-light);
    cursor: default;
}

.accounting-document-status {
    min-height: 42px;
    width: 100%;
    border: 1px solid var(--border);
    font-weight: 700;
}

.accounting-document-status.is-draft {
    background: rgba(255, 152, 0, .12);
    color: #b55a00;
    border-color: rgba(255, 152, 0, .25);
}

.accounting-document-status.is-pending {
    background: rgba(30, 136, 229, .12);
    color: var(--primary-dark);
    border-color: rgba(30, 136, 229, .25);
}

.accounting-document-status.is-submitted {
    background: rgba(76, 175, 80, .12);
    color: #26752a;
    border-color: rgba(76, 175, 80, .28);
}

.accounting-document-message {
    flex: 0 0 auto;
    padding: 11px 14px;
    border: 1px solid transparent;
    border-radius: 10px;
    font-size: 13px;
    font-weight: 700;
    direction: rtl;
    text-align: right;
    unicode-bidi: plaintext;
    line-height: 1.8;
    font-family: inherit;
}

.accounting-document-message[hidden] {
    display: none;
}

.accounting-document-message.info {
    color: #0d5d8c;
    background: #eef8fe;
    border-color: #b8dff3;
}

.accounting-document-message.success {
    color: #246b2a;
    background: #effaf0;
    border-color: #b9dfbc;
}

.accounting-document-message.error {
    color: #a12828;
    background: #fff1f1;
    border-color: #efbaba;
}

.accounting-document-table-container {
    flex: 0 0 auto;
    min-height: 260px;
    height: min(42vh, 420px);
    margin: 0;
    border-radius: 10px;
    overflow: auto;
}

#webAccountingDocument .accounting-document-table {
    min-width: 1380px;
    width: 100%;
    table-layout: fixed;
    border-collapse: separate;
    border-spacing: 0;
}

#webAccountingDocument .accounting-document-table thead th {
    position: sticky;
    top: 0;
    z-index: 4;
    padding: 10px 8px;
    background: linear-gradient(135deg, var(--primary), var(--primary-dark));
    color: #fff;
    font-size: 13px;
    font-weight: 700;
    letter-spacing: 0;
    text-align: center;
    vertical-align: middle;
}

#webAccountingDocument .accounting-document-table tbody tr {
    background: #fff;
    transition: background .15s ease, box-shadow .15s ease;
}

#webAccountingDocument .accounting-document-table tbody tr:nth-child(even) {
    background: #fafcff;
}

#webAccountingDocument .accounting-document-table tbody tr:hover td {
    background: #f1f7ff;
}

#webAccountingDocument .accounting-document-table tbody tr.selected td {
    background: #e3f2fd;
    box-shadow: inset 0 1px 0 rgba(30, 136, 229, .12), inset 0 -1px 0 rgba(30, 136, 229, .12);
}

#webAccountingDocument .accounting-document-table td {
    height: 52px;
    padding: 0;
    border-bottom: 1px solid #d8e0e8;
    border-left: 1px solid #e5e9ee;
    background: inherit;
    vertical-align: middle;
    text-align: center;
}

#webAccountingDocument .wad-col-row { width: 54px; }
#webAccountingDocument .wad-col-code { width: 78px; }
#webAccountingDocument .wad-col-cost { width: 180px; }
#webAccountingDocument .wad-col-account { width: 300px; }
#webAccountingDocument .wad-col-money { width: 145px; }
#webAccountingDocument .wad-col-comment { width: 270px; }
#webAccountingDocument .wad-col-action { width: 52px; }

.wad-row-number {
    text-align: center;
    font-weight: 800;
    color: var(--text-light);
    font-variant-numeric: tabular-nums;
}

#webAccountingDocument .wad-cell-input {
    width: 100%;
    height: 51px;
    border: 0;
    border-radius: 0;
    background: transparent;
    padding: 0 9px;
    color: var(--text);
    font: inherit;
    font-size: 13px;
    font-weight: 600;
    outline: none;
    text-align: center;
}

#webAccountingDocument .wad-cell-input:focus {
    position: relative;
    z-index: 2;
    background: #fff;
    box-shadow: inset 0 0 0 2px var(--primary);
}

#webAccountingDocument .wad-cell-input[readonly] {
    color: #5f6f7f;
    background: rgba(241, 245, 249, .62);
}

#webAccountingDocument .wad-cell-input:disabled {
    color: #84909b;
    background: #f5f7f9;
    cursor: not-allowed;
}

#webAccountingDocument .wad-code-input,
#webAccountingDocument .wad-money-input {
    direction: ltr;
    text-align: center;
    font-variant-numeric: tabular-nums;
}

#webAccountingDocument .wad-money-input.wad-bed {
    color: #1d8529;
    font-weight: 700;
}

#webAccountingDocument .wad-money-input.wad-bes {
    color: #9b2d2d;
    font-weight: 700;
}

#webAccountingDocument .wad-money-input.is-locked {
    background: #f1f5f9;
    color: #94a3b8;
    cursor: not-allowed;
}

#webAccountingDocument .wad-comment-input,
#webAccountingDocument #wad-comment {
    direction: rtl;
    text-align: right;
    unicode-bidi: plaintext;
    font-weight: 600;
    font-size: 13px;
    letter-spacing: 0;
}

.wad-account-cell {
    height: 51px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 0 8px;
}

.wad-account-picker {
    width: 36px;
    height: 36px;
    flex: 0 0 36px;
    display: grid;
    place-items: center;
    border: 1px solid rgba(30, 136, 229, .35);
    border-radius: 8px;
    background: var(--primary-light);
    color: var(--primary-dark);
    cursor: pointer;
}

.wad-account-picker:hover,
.wad-account-picker:focus-visible {
    background: var(--primary);
    color: #fff;
    outline: none;
}

.wad-account-picker:disabled {
    opacity: .5;
    cursor: not-allowed;
}

.wad-account-picker svg {
    width: 19px;
    height: 19px;
}

.wad-account-name {
    min-width: 0;
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    text-align: center;
    color: var(--text);
    font-weight: 600;
    font-size: 13px;
}

.wad-account-name.is-empty {
    color: #8995a1;
    font-weight: 400;
}

.wad-cost-cell {
    height: 51px;
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 0 8px;
    justify-content: center;
}

.wad-cost-name {
    min-width: 0;
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    text-align: center;
    color: var(--text);
    font-weight: 600;
    font-size: 13px;
}

.wad-cost-name.is-empty {
    color: #8995a1;
    font-weight: 400;
}

.wad-optional,
.wad-th-optional {
    color: rgba(255, 255, 255, .78);
    font-size: 11px;
    font-weight: 500;
}

.wad-optional {
    color: var(--text-light);
}

.accounting-document-list-section {
    flex: 0 0 auto;
    margin-top: 0;
    padding-top: 0;
    border-top: 0;
}

.accounting-document-list-section.is-primary {
    flex: 1 1 auto;
    min-height: 0;
    display: flex;
    flex-direction: column;
}

.accounting-document-list-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 10px;
}

.accounting-document-list-title {
    margin: 0;
    font-size: 16px;
    color: var(--text);
}

.accounting-document-list-subtitle {
    margin: 4px 0 0;
    color: var(--text-light);
    font-size: 12px;
}

.accounting-document-list-message {
    margin-bottom: 10px;
    padding: 10px 12px;
    border-radius: 8px;
    font-size: 13px;
    font-weight: 700;
    direction: rtl;
    text-align: right;
}

.accounting-document-list-message.error {
    color: #a12828;
    background: #fff1f1;
    border: 1px solid #efbaba;
}

.accounting-document-list-message.success {
    color: #1b5e20;
    background: #edf7ed;
    border: 1px solid #b7dfb9;
}

.accounting-document-list-message.info {
    color: #0d47a1;
    background: #eef5ff;
    border: 1px solid #bfd6f6;
}

.wad-list-toolbar {
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin-bottom: 12px;
    padding: 12px;
    border: 1px solid var(--border);
    border-radius: 12px;
    background: #f8fbff;
}

.wad-list-search {
    position: relative;
    width: 100%;
}

.wad-list-search-icon {
    position: absolute;
    top: 50%;
    right: 12px;
    transform: translateY(-50%);
    color: #64748b;
    display: inline-flex;
    pointer-events: none;
}

.wad-list-search-input {
    width: 100%;
    min-height: 42px;
    padding: 10px 40px 10px 12px;
    border: 1px solid var(--border);
    border-radius: 10px;
    background: #fff;
    font: inherit;
    font-size: 13px;
    font-weight: 600;
    color: var(--text);
}

.wad-list-search-input:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(30, 136, 229, .12);
}

.wad-list-filters {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    align-items: end;
}

.wad-list-filter {
    display: flex;
    flex-direction: column;
    gap: 4px;
    min-width: 140px;
    flex: 1 1 140px;
}

.wad-list-filter span {
    font-size: 11px;
    font-weight: 700;
    color: var(--text-light);
}

.wad-pretty-select {
    position: relative;
    width: 100%;
}

.wad-pretty-select__trigger {
    width: 100%;
    min-height: 40px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    padding: 8px 12px;
    border: 1px solid var(--border);
    border-radius: 10px;
    background: #fff;
    color: var(--text);
    font: inherit;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    text-align: right;
    transition: border-color .15s ease, box-shadow .15s ease, background .15s ease;
}

.wad-pretty-select__trigger:hover {
    border-color: #c5cdd8;
    background: #fcfdff;
}

.wad-pretty-select.is-open .wad-pretty-select__trigger,
.wad-pretty-select__trigger:focus-visible {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(30, 136, 229, .12);
}

.wad-pretty-select__label {
    min-width: 0;
    flex: 1 1 auto;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.wad-pretty-select__caret {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: #64748b;
    transition: transform .15s ease;
    line-height: 0;
}

.wad-pretty-select.is-open .wad-pretty-select__caret {
    transform: rotate(180deg);
}

.wad-pretty-select__menu {
    position: absolute;
    top: calc(100% + 6px);
    right: 0;
    left: 0;
    z-index: 50;
    max-height: 240px;
    overflow: auto;
    padding: 6px;
    border: 1px solid #d7e0ea;
    border-radius: 12px;
    background: #fff;
    box-shadow: 0 16px 34px rgba(15, 23, 42, .14);
}

.wad-pretty-select__menu[hidden] {
    display: none;
}

.wad-pretty-select__option {
    width: 100%;
    display: flex;
    align-items: center;
    min-height: 38px;
    padding: 8px 10px;
    border: 0;
    border-radius: 9px;
    background: transparent;
    color: #334155;
    font: inherit;
    font-size: 13px;
    font-weight: 600;
    text-align: right;
    cursor: pointer;
}

.wad-pretty-select__option:hover,
.wad-pretty-select__option:focus-visible {
    background: #f1f7ff;
    color: var(--primary-dark);
    outline: none;
}

.wad-pretty-select__option.is-selected {
    background: rgba(30, 136, 229, .12);
    color: var(--primary-dark);
}

#wad-clear-filters {
    min-height: 40px;
    align-self: end;
}

.wad-sort-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 4px;
    width: 100%;
    border: 0;
    background: transparent;
    color: inherit;
    font: inherit;
    font-weight: 700;
    cursor: pointer;
    padding: 0;
}

.wad-sort-btn:hover,
.wad-sort-btn.is-active {
    color: var(--primary-dark, #0b5cab);
}

.wad-sort-indicator {
    font-size: 11px;
    min-width: 10px;
}

.wad-balance-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 28px;
    padding: 4px 10px;
    border-radius: 999px;
    font-size: 12px;
    font-weight: 700;
    white-space: nowrap;
    border: 1px solid transparent;
    margin: 0 auto;
}

.wad-balance-badge.is-balanced {
    color: #1b5e20;
    background: #edf7ed;
    border-color: #b7dfb9;
}

.wad-balance-badge.is-note {
    color: #8a5a00;
    background: #fff7e6;
    border-color: #f0d6a0;
}

.accounting-document-list-table-wrap {
    flex: 1 1 auto;
    max-height: none;
    min-height: 280px;
    overflow: auto;
    border: 1px solid var(--border);
    border-radius: 10px;
    margin: 0;
    -webkit-overflow-scrolling: touch;
}

.accounting-document-list-table {
    width: 100%;
    border-collapse: collapse;
    min-width: 1100px;
}

.accounting-document-list-table thead th {
    position: sticky;
    top: 0;
    z-index: 2;
    padding: 10px 12px;
    background: #f3f7fb;
    color: var(--text);
    font-size: 13px;
    font-weight: 700;
    text-align: center;
    border-bottom: 1px solid var(--border);
}

.accounting-document-list-table td {
    padding: 10px 12px;
    border-bottom: 1px solid #e8eef4;
    font-size: 13px;
    font-weight: 600;
    vertical-align: middle;
    text-align: center;
}

.accounting-document-list-table .wad-list-money {
    direction: ltr;
    text-align: center;
    font-variant-numeric: tabular-nums;
}

.accounting-document-list-table .wad-list-comment {
    max-width: 220px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    text-align: center;
}

.wad-status-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 28px;
    padding: 4px 10px;
    border-radius: 999px;
    font-size: 12px;
    font-weight: 700;
    white-space: nowrap;
    border: 1px solid transparent;
    margin: 0 auto;
}

.wad-status-badge.is-pending {
    color: #8a5a00;
    background: #fff7e6;
    border-color: #f0d6a0;
}

.wad-status-badge.is-applied {
    color: #1b5e20;
    background: #edf7ed;
    border-color: #b7dfb9;
}

.wad-status-badge.is-rejected {
    color: #a12828;
    background: #fff1f1;
    border-color: #efbaba;
}

.wad-status-badge.is-deleted {
    color: #455a64;
    background: #f2f5f7;
    border-color: #cfd8dc;
}

.wad-list-action-group {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex-wrap: wrap;
    gap: 8px;
}

.wad-list-action {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    min-height: 34px;
    padding: 6px 12px;
}

.wad-list-action-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    line-height: 0;
}

.wad-list-action-icon svg {
    display: block;
}

.wad-list-delete {
    color: #a12828;
    border-color: #efbaba;
    background: #fff;
}

/* btn + btn-outline hover (and the white .btn::before ripple) otherwise keep a light
   background while this rule turns the label white — unreadable contrast. */
.btn.btn-outline.wad-list-delete:hover,
.btn.btn-outline.wad-list-delete:focus-visible {
    color: #fff;
    background: var(--danger);
    border-color: var(--danger);
}

.btn.wad-list-delete:hover::before,
.btn.wad-list-delete:focus-visible::before {
    background: rgba(0, 0, 0, .12);
}

.accounting-document-list-empty {
    margin: 16px;
    padding: 24px 16px;
}

.accounting-document-list-empty .btn {
    margin-top: 14px;
}

.accounting-document-list-empty[hidden] {
    display: none;
}

.accounting-document-list-pager {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    margin-top: 10px;
    flex-wrap: wrap;
}

.accounting-document-editor {
    flex: 0 0 auto;
    margin-top: 8px;
    padding-top: 16px;
    border-top: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.accounting-document-editor[hidden] {
    display: none;
}

.accounting-document-editor-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px;
    flex-wrap: wrap;
}

.accounting-document-editor-header .accounting-document-actions {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
}

.accounting-document-page.is-editor-page {
    --wad-editor-height-offset: var(--header-height);
    padding: 12px 10px 10px;
    min-height: 0;
    height: calc(100dvh - var(--wad-editor-height-offset));
    max-height: calc(100dvh - var(--wad-editor-height-offset));
    overflow: hidden;
    box-sizing: border-box;
    display: flex;
    flex-direction: column;
}

.accounting-document-page.is-editor-page .accounting-document-card {
    flex: 1 1 auto;
    min-height: 0;
    max-height: 100%;
    margin-top: 0;
    margin-bottom: 0;
}

.accounting-document-page.is-editor-page .accounting-document-body {
    flex: 1 1 auto;
    min-height: 0;
    overflow: hidden;
}

.accounting-document-page.is-editor-page .accounting-document-meta,
.accounting-document-page.is-editor-page .accounting-document-message,
.accounting-document-page.is-editor-page .wad-find-bar,
.accounting-document-page.is-editor-page .accounting-document-table-scroll-hint {
    flex: 0 0 auto;
}

.accounting-document-page.is-editor-page .accounting-document-table-container {
    flex: 1 1 auto;
    min-height: 160px;
    height: auto;
    max-height: none;
}

.accounting-document-page.is-editor-page .accounting-document-summary {
    flex: 0 0 auto;
    margin-top: auto;
}

.accounting-document-page.is-editor-page .accounting-document-empty:not([hidden]) {
    min-height: 100%;
    margin: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}

.wad-btn-add-row {
    color: #0b6b3a !important;
    border-color: rgba(46, 125, 50, .45) !important;
    background: #f1faf3 !important;
}

.wad-btn-add-row:hover {
    color: #fff !important;
    background: #2e7d32 !important;
    border-color: #2e7d32 !important;
}

.wad-btn-back {
    color: #5d4037 !important;
    border-color: rgba(121, 85, 72, .4) !important;
    background: #faf6f3 !important;
}

.wad-btn-back #wad-back-icon,
.wad-btn-back .wad-btn-back-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    line-height: 0;
}

.wad-btn-back #wad-back-icon svg,
.wad-btn-back .wad-btn-back-icon svg {
    display: block;
}

.wad-btn-back:hover {
    color: #fff !important;
    background: #6d4c41 !important;
    border-color: #6d4c41 !important;
}

.accounting-document-field select.form-control {
    width: 100%;
    min-width: 0;
    height: 42px;
    text-align: right;
    direction: rtl;
    color: var(--text);
    cursor: pointer;
}

.accounting-document-field select.form-control:disabled {
    background: #f8fafc;
    color: var(--text-light);
    cursor: not-allowed;
}

.accounting-document-table-scroll-hint {
    display: none;
    margin: 0 0 8px;
    color: var(--text-light);
    font-size: 12px;
}

.wad-remove-row {
    width: 32px;
    height: 32px;
    display: grid;
    place-items: center;
    margin: auto;
    border: 0;
    border-radius: 8px;
    background: transparent;
    color: var(--danger);
    font-size: 22px;
    cursor: pointer;
}

.wad-remove-row:hover {
    background: rgba(244, 67, 54, .1);
}

.wad-remove-row:disabled {
    opacity: .45;
    cursor: not-allowed;
}

.accounting-document-empty {
    margin: 24px;
    padding: 36px 20px;
}

.accounting-document-empty[hidden] {
    display: none;
}

.accounting-document-empty .btn {
    margin-top: 15px;
}

.accounting-document-summary {
    flex: 0 0 auto;
    grid-template-columns: repeat(4, minmax(180px, 1fr));
    gap: 10px;
    margin: 0;
}

.accounting-document-summary .summary-box {
    min-height: 68px;
    padding: 14px 16px;
    border-width: 1px;
}

.accounting-document-summary .summary-value {
    direction: ltr;
    font-size: 17px;
}

.accounting-document-balance.is-balanced {
    border-color: rgba(76, 175, 80, .35);
    background: linear-gradient(135deg, #fff, #effaf0);
}

.accounting-document-balance.is-balanced .summary-value {
    color: #2e7d32;
}

.accounting-document-balance.is-unbalanced {
    border-color: rgba(244, 67, 54, .35);
    background: linear-gradient(135deg, #fff, #fff0f0);
}

.accounting-document-balance.is-unbalanced .summary-value {
    color: #c62828;
}

.wad-confirm-backdrop {
    position: fixed;
    inset: 0;
    z-index: 4000;
    display: grid;
    place-items: center;
    padding: 20px;
    background: rgba(15, 23, 42, .58);
    backdrop-filter: blur(2px);
}

.wad-confirm-backdrop[hidden] {
    display: none;
}

.wad-confirm-dialog {
    width: min(470px, 94vw);
    padding: 26px;
    border: 1px solid #f2c2c2;
    border-radius: 16px;
    background: #fff;
    box-shadow: 0 24px 70px rgba(15, 23, 42, .28);
    text-align: center;
}

.wad-confirm-icon {
    width: 52px;
    height: 52px;
    display: grid;
    place-items: center;
    margin: 0 auto 12px;
    border-radius: 50%;
    background: rgba(244, 67, 54, .12);
    color: var(--danger);
    font-size: 28px;
    font-weight: 900;
}

.wad-confirm-dialog h2 {
    margin: 0 0 8px;
    color: #b62b2b;
    font-size: 20px;
}

.wad-confirm-dialog p {
    margin: 0;
    color: var(--text-light);
    line-height: 1.9;
}

.wad-confirm-actions {
    display: flex;
    justify-content: center;
    gap: 8px;
    margin-top: 20px;
}

.accounting-document-confirm-danger {
    background: var(--danger);
    color: #fff;
}

.accounting-document-confirm-danger:hover {
    background: #d32f2f;
}

#webAccountingDocument .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;
}

@media (max-width: 1250px) {
    .accounting-document-number-field,
    .accounting-document-date-field,
    .accounting-document-year-field,
    .accounting-document-status-field {
        flex: 1 1 calc(50% - 6px);
        max-width: none;
    }

    .accounting-document-comment-field {
        flex: 1 1 100%;
    }

    .accounting-document-table-container {
        height: min(38vh, 360px);
    }

    .accounting-document-summary {
        grid-template-columns: repeat(2, minmax(180px, 1fr));
    }
}

@media (max-width: 1100px) {
    .accounting-document-list-table {
        min-width: 860px;
    }

    .accounting-document-list-table .wad-list-comment {
        max-width: 160px;
    }
}

@media (max-width: 900px) {
    .accounting-document-page {
        min-height: auto;
        padding: 8px;
        overflow: visible;
    }

    .accounting-document-page.is-editor-page {
        --wad-editor-height-offset: calc(var(--header-height-mobile) + var(--safe-top));
        height: calc(100dvh - var(--wad-editor-height-offset));
        max-height: calc(100dvh - var(--wad-editor-height-offset));
        overflow: hidden;
        padding: 10px 8px 8px;
    }

    .accounting-document-page.is-editor-page .accounting-document-card {
        min-height: 0;
    }

    .accounting-document-page.is-editor-page .accounting-document-table-container {
        height: auto;
        min-height: 0;
        flex: 1 1 auto;
    }

    .accounting-document-page:not(.is-editor-page) {
        padding: 12px 8px 10px;
    }

    .accounting-document-page.is-editor-page {
        padding-top: 10px;
    }

    .accounting-document-card {
        min-height: calc(100vh - 82px);
        min-height: calc(100dvh - 82px);
    }

    .accounting-document-page:not(.is-editor-page) .accounting-document-card {
        min-height: calc(100vh - 90px);
        min-height: calc(100dvh - 90px);
    }

    .accounting-document-header {
        align-items: stretch;
    }

    .accounting-document-title-row {
        align-items: flex-start;
    }

    .accounting-document-title-icon {
        width: 40px;
        height: 40px;
        flex-basis: 40px;
        border-radius: 10px;
    }

    .accounting-document-subtitle {
        line-height: 1.7;
    }

    .accounting-document-actions {
        width: 100%;
        display: flex;
        flex-wrap: wrap;
    }

    .accounting-document-actions .btn,
    .accounting-document-actions .btn-outline {
        flex: 1 1 150px;
        min-height: 44px;
    }

    .accounting-document-body {
        padding: 10px;
        gap: 10px;
    }

    .accounting-document-list-section.is-primary {
        min-height: 0;
    }

    .accounting-document-list-header {
        align-items: flex-start;
        flex-direction: column;
    }

    .accounting-document-list-table-wrap {
        min-height: 0;
        overflow: visible;
        border: 0;
        border-radius: 0;
        background: transparent;
    }

    .accounting-document-list-table {
        min-width: 0;
        width: 100%;
        border-collapse: separate;
        border-spacing: 0 10px;
    }

    .accounting-document-list-table thead {
        display: none;
    }

    .accounting-document-list-table tbody {
        display: block;
    }

    .accounting-document-list-table tr {
        display: grid;
        grid-template-columns: 1fr 1fr;
        gap: 8px 12px;
        margin: 0;
        padding: 14px;
        border: 1px solid var(--border);
        border-radius: 12px;
        background: #fff;
        box-shadow: 0 4px 14px rgba(15, 23, 42, .04);
    }

    .accounting-document-list-table td {
        display: flex;
        flex-direction: column;
        align-items: flex-start;
        gap: 4px;
        padding: 0;
        border: 0;
        font-size: 13px;
        min-width: 0;
    }

    .accounting-document-list-table td::before {
        content: attr(data-label);
        color: var(--text-light);
        font-size: 11px;
        font-weight: 700;
    }

    .accounting-document-list-table .wad-list-date {
        grid-column: 1;
        font-weight: 800;
        color: var(--primary-dark);
    }

    .accounting-document-list-table .wad-list-status {
        grid-column: 2;
        align-items: flex-end;
        text-align: left;
    }

    .accounting-document-list-table .wad-list-balance {
        align-items: flex-start;
    }

    .wad-list-filters {
        gap: 8px;
    }

    .wad-list-filter,
    #wad-clear-filters {
        flex: 1 1 calc(50% - 8px);
        min-width: 0;
    }

    .accounting-document-list-table .wad-list-comment {
        grid-column: 1 / -1;
        max-width: none;
        white-space: normal;
        overflow: visible;
        text-overflow: unset;
        line-height: 1.7;
    }

    .accounting-document-list-table .wad-list-money {
        direction: ltr;
        text-align: left;
        align-items: flex-start;
        font-weight: 700;
    }

    .accounting-document-list-table .wad-list-status,
    .accounting-document-list-table .wad-list-windows-num {
        min-width: 0;
    }

    .accounting-document-list-table .wad-list-actions {
        grid-column: 1 / -1;
        margin-top: 4px;
    }

    .accounting-document-list-table .wad-list-actions::before {
        display: none;
    }

    .wad-list-action-group {
        width: 100%;
    }

    .wad-list-action {
        flex: 1 1 0;
        min-height: 42px;
    }

    .accounting-document-list-empty {
        margin: 0;
        padding: 28px 16px;
        border: 1px dashed var(--border);
        border-radius: 12px;
    }

    .accounting-document-list-pager {
        gap: 8px;
    }

    .accounting-document-list-pager .btn,
    .accounting-document-list-pager .btn-outline {
        flex: 1 1 120px;
        min-height: 42px;
    }

    .accounting-document-editor {
        margin-top: 0;
        padding-top: 0;
        border-top: 0;
    }

    .accounting-document-editor-header {
        flex-direction: column;
    }

    .accounting-document-editor-header .accounting-document-actions {
        width: 100%;
    }

    .accounting-document-table-scroll-hint {
        display: block;
    }

    .accounting-document-table-container {
        height: min(48vh, 420px);
        min-height: 240px;
        -webkit-overflow-scrolling: touch;
        overflow: auto;
        border: 1px solid var(--border);
    }

    .accounting-document-page.is-editor-page .accounting-document-table-container {
        height: auto;
        min-height: 0;
        flex: 1 1 auto;
    }

    #webAccountingDocument .accounting-document-table {
        min-width: 980px;
    }

    #webAccountingDocument .wad-col-account { width: 200px; }
    #webAccountingDocument .wad-col-comment { width: 160px; }
    #webAccountingDocument .wad-col-cost { width: 140px; }
    #webAccountingDocument .wad-col-money { width: 118px; }

    /* ستون ۷ = نام حساب (کلاس روی td نیست) */
    #webAccountingDocument .accounting-document-table th:nth-child(7),
    #webAccountingDocument .accounting-document-table td:nth-child(7) {
        position: sticky;
        right: 0;
        z-index: 5;
        background: #fff;
        box-shadow: -6px 0 10px -6px rgba(15, 23, 42, .2);
    }

    #webAccountingDocument .accounting-document-table thead th:nth-child(7) {
        z-index: 15;
        background: linear-gradient(135deg, var(--primary), var(--primary-dark));
        color: #fff;
    }

    #webAccountingDocument .accounting-document-table tbody tr:nth-child(even) td:nth-child(7) {
        background: #fafcff;
    }

    #webAccountingDocument .accounting-document-table tbody tr:hover td:nth-child(7) {
        background: #f1f7ff;
    }

    #webAccountingDocument .accounting-document-table tbody tr.selected td:nth-child(7) {
        background: #e3f2fd;
    }

    .accounting-document-summary {
        grid-template-columns: repeat(2, minmax(140px, 1fr));
    }
}

@media (max-width: 768px) {
    .accounting-document-meta {
        gap: 10px;
        padding: 12px;
    }

    .accounting-document-field,
    .accounting-document-number-field,
    .accounting-document-date-field,
    .accounting-document-comment-field,
    .accounting-document-year-field,
    .accounting-document-status-field {
        flex: 1 1 100%;
        max-width: none;
    }

    .accounting-document-actions {
        flex-direction: column;
    }

    .accounting-document-actions .btn,
    .accounting-document-actions .btn-outline {
        width: 100%;
        flex-basis: 100%;
    }

    .accounting-document-list-table tr {
        grid-template-columns: 1fr;
    }

    .accounting-document-list-table .wad-list-date,
    .accounting-document-list-table .wad-list-status,
    .accounting-document-list-table .wad-list-comment,
    .accounting-document-list-table .wad-list-actions {
        grid-column: 1;
        align-items: flex-start;
        text-align: right;
    }

    .account-header__value {
        font-size: 16px;
    }
}

@media (max-width: 620px) {
    .accounting-document-page {
        padding: 6px;
    }

    .accounting-document-page:not(.is-editor-page) {
        padding: 10px 6px 8px;
    }

    .accounting-document-card {
        min-height: calc(100vh - 72px);
        min-height: calc(100dvh - 72px);
        border-radius: 12px;
    }

    .accounting-document-page:not(.is-editor-page) .accounting-document-card {
        min-height: calc(100vh - 80px);
        min-height: calc(100dvh - 80px);
    }

    .accounting-document-body {
        padding: 8px;
    }

    .accounting-document-title-icon {
        display: none;
    }

    .accounting-document-subtitle,
    .accounting-document-list-subtitle {
        font-size: 11px;
    }

    .accounting-document-summary {
        grid-template-columns: 1fr;
    }

    .accounting-document-summary .summary-box {
        min-height: 58px;
        padding: 12px 14px;
    }

    .wad-confirm-backdrop {
        padding: 12px;
        align-items: end;
    }

    .wad-confirm-dialog {
        width: 100%;
        border-radius: 16px 16px 12px 12px;
        padding: 20px 16px;
    }

    .wad-confirm-actions {
        flex-direction: column;
    }

    .wad-confirm-actions .btn,
    .wad-confirm-actions .btn-outline {
        width: 100%;
        min-height: 44px;
    }

    .accounting-document-table-container {
        height: min(52vh, 460px);
    }

    .accounting-document-page.is-editor-page .accounting-document-table-container {
        height: auto;
        min-height: 0;
        flex: 1 1 auto;
    }

    #webAccountingDocument .accounting-document-table {
        min-width: 860px;
    }

    #webAccountingDocument .wad-col-account { width: 180px; }
    #webAccountingDocument .wad-col-comment { width: 140px; }
    #webAccountingDocument .wad-col-cost { width: 120px; }
    #webAccountingDocument .wad-col-money { width: 110px; }
    #webAccountingDocument .wad-col-code { width: 64px; }

    .accounting-document-table-container input,
    .accounting-document-table-container select,
    .accounting-document-meta input,
    .accounting-document-meta select,
    .accounting-document-meta textarea {
        font-size: 16px !important;
    }

    .accounting-document-list-pager {
        flex-direction: column;
    }

    .accounting-document-list-pager .btn,
    .accounting-document-list-pager .btn-outline {
        width: 100%;
    }
}

@media (max-width: 420px) {
    .accounting-document-actions .btn,
    .accounting-document-actions .btn-outline {
        white-space: normal;
        line-height: 1.4;
        text-align: center;
    }

    .wad-status-badge {
        white-space: normal;
        text-align: right;
        border-radius: 10px;
        line-height: 1.4;
    }
}

/* Document operations popmenu */
.wad-popmenu {
    --wad-menu-bg: rgba(255, 255, 255, .94);
    --wad-menu-border: rgba(21, 101, 192, .12);
    --wad-menu-hover: #eef6ff;
    --wad-menu-active: #e3f2fd;
    position: fixed;
    z-index: 3600;
    min-width: 292px;
    width: max-content;
    max-width: min(420px, calc(100vw - 16px));
    padding: 8px;
    margin: 0;
    background: var(--wad-menu-bg);
    border: 1px solid var(--wad-menu-border);
    border-radius: 16px;
    box-shadow:
        0 18px 48px rgba(15, 23, 42, .16),
        0 2px 8px rgba(15, 23, 42, .06);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    box-sizing: border-box;
    font-family: 'IRANSans', Tahoma, sans-serif;
    font-size: 13px;
    color: var(--text);
    direction: rtl;
    user-select: none;
    animation: wad-popmenu-in .16s ease-out;
}

.wad-popmenu--sub {
    min-width: 360px;
    z-index: 3601;
    padding-top: 8px;
    animation: wad-popmenu-sub-in .14s ease-out;
}

.wad-popmenu-head {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 12px;
    padding: 8px 12px 10px;
    margin: 0 2px 6px;
    border-bottom: 1px solid rgba(21, 101, 192, .1);
}

.wad-popmenu-head-title {
    font-size: 12px;
    font-weight: 700;
    color: var(--primary-dark);
    letter-spacing: -.01em;
}

.wad-popmenu-head-hint {
    font-size: 11px;
    color: var(--text-light);
}

.wad-popmenu-item > .wad-popmenu {
    position: fixed;
}

.wad-popmenu-item {
    position: relative;
    display: grid;
    grid-template-columns: 32px minmax(0, 1fr) auto 16px;
    align-items: center;
    column-gap: 10px;
    min-height: 40px;
    padding: 7px 10px;
    border: 1px solid transparent;
    border-radius: 10px;
    cursor: pointer;
    white-space: nowrap;
    outline: none;
    transition: background .12s ease, border-color .12s ease, box-shadow .12s ease;
}

.wad-popmenu-item:hover,
.wad-popmenu-item:focus,
.wad-popmenu-item.is-open {
    background: var(--wad-menu-hover);
    border-color: rgba(30, 136, 229, .18);
}

.wad-popmenu-item:focus-visible {
    box-shadow: 0 0 0 3px rgba(30, 136, 229, .18);
}

.wad-popmenu-item.is-open {
    background: var(--wad-menu-active);
}

.wad-popmenu-item.is-disabled {
    color: #94a3b8;
    cursor: default;
    opacity: .72;
}

.wad-popmenu-item.is-disabled:hover,
.wad-popmenu-item.is-disabled:focus,
.wad-popmenu-item.is-disabled.is-open {
    background: transparent;
    border-color: transparent;
    box-shadow: none;
}

.wad-popmenu-icon {
    width: 32px;
    height: 32px;
    display: grid;
    place-items: center;
    border-radius: 9px;
    background: var(--primary-light);
    color: var(--primary-dark);
}

.wad-popmenu-icon:empty {
    background: transparent;
}

.wad-popmenu-item.is-disabled .wad-popmenu-icon {
    background: #f1f5f9;
    color: #94a3b8;
}

.wad-popmenu-label {
    min-width: 0;
    text-align: right;
    line-height: 1.45;
    font-weight: 500;
}

.wad-popmenu-shortcut {
    flex: 0 0 auto;
    margin: 0;
    padding: 3px 7px;
    border-radius: 6px;
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    color: #64748b;
    font-size: 11px;
    font-variant-numeric: tabular-nums;
    direction: ltr;
    unicode-bidi: isolate;
    line-height: 1.2;
}

.wad-popmenu-shortcut:empty {
    display: none;
}

.wad-popmenu-item:hover .wad-popmenu-shortcut,
.wad-popmenu-item:focus .wad-popmenu-shortcut,
.wad-popmenu-item.is-open .wad-popmenu-shortcut {
    background: #fff;
    border-color: rgba(30, 136, 229, .22);
    color: var(--primary-dark);
}

.wad-popmenu-item.is-disabled .wad-popmenu-shortcut {
    color: #94a3b8;
    background: #f8fafc;
    border-color: #eef2f6;
}

.wad-popmenu-arrow {
    width: 16px;
    height: 16px;
    color: #64748b;
    display: grid;
    place-items: center;
}

.wad-popmenu-arrow svg {
    width: 12px;
    height: 12px;
    display: block;
}

.wad-popmenu-item.has-submenu:hover .wad-popmenu-arrow,
.wad-popmenu-item.has-submenu:focus .wad-popmenu-arrow,
.wad-popmenu-item.is-open .wad-popmenu-arrow {
    color: var(--primary-dark);
}

.wad-popmenu-sep {
    height: 1px;
    margin: 6px 10px;
    background: linear-gradient(90deg, transparent, rgba(148, 163, 184, .45), transparent);
}

@keyframes wad-popmenu-in {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

@keyframes wad-popmenu-sub-in {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

@media (prefers-reduced-motion: reduce) {
    .wad-popmenu,
    .wad-popmenu--sub {
        animation: none;
    }
}

.wad-find-bar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
    padding: 8px 10px;
    border: 1px solid var(--border);
    border-radius: 10px;
    background: #f7fafc;
}

.wad-find-bar[hidden] {
    display: none;
}

.wad-find-bar-label {
    font-size: 12px;
    color: var(--text-light);
}

.wad-find-bar-input {
    flex: 1 1 180px;
    min-width: 140px;
    height: 36px;
}

.wad-find-bar-actions {
    display: flex;
    gap: 6px;
}

@media print {
    .wad-popmenu,
    .wad-find-bar,
    .accounting-document-actions,
    .wad-confirm-backdrop {
        display: none !important;
    }
}

/* ========== Mobile layout repair ======================================== */
@media (max-width: 900px) {
    .accounting-document-page,
    .accounting-document-card,
    .accounting-document-body,
    .accounting-document-table-container,
    .accounting-document-list-table-wrap {
        min-width: 0;
        max-width: 100%;
    }

    .accounting-document-page:not(.is-editor-page),
    .accounting-document-page:not(.is-editor-page) .accounting-document-card {
        min-height: 0;
        height: auto;
    }

    .accounting-document-page.is-editor-page {
        height: auto;
        max-height: none;
        min-height: 0;
        overflow: visible;
        padding: 10px 8px 12px;
    }

    .accounting-document-page.is-editor-page .accounting-document-card,
    .accounting-document-page.is-editor-page .accounting-document-body {
        height: auto;
        max-height: none;
        overflow: visible;
        min-height: 0;
    }

    .accounting-document-page.is-editor-page .accounting-document-table-container {
        flex: 0 0 auto;
        height: auto;
        min-height: 0;
        max-height: none;
    }

    .accounting-document-card {
        min-height: 0;
    }

    .accounting-document-header,
    .account-header.accounting-document-header {
        align-items: stretch;
    }

    .accounting-document-page .accounting-document-actions,
    .accounting-document-page .account-header__actions {
        flex-direction: row;
        flex-wrap: wrap;
        width: 100%;
        gap: 8px;
    }

    .accounting-document-page .accounting-document-actions .btn,
    .accounting-document-page .accounting-document-actions .btn-outline,
    .accounting-document-page .account-header__actions .btn,
    .accounting-document-page .account-header__actions .btn-outline {
        flex: 1 1 calc(50% - 8px);
        width: auto;
        min-width: 0;
        min-height: 44px;
        height: auto;
        max-height: none;
        align-self: auto;
    }

    .accounting-document-page .accounting-document-actions .btn-primary {
        flex: 1 1 100%;
    }

    .wad-list-toolbar {
        padding: 10px;
        gap: 8px;
    }

    .wad-list-search-input,
    .wad-pretty-select__trigger,
    #wad-clear-filters {
        min-height: 44px;
    }

    .accounting-document-list-section.is-primary {
        flex: 0 0 auto;
        min-height: 0;
    }

    .accounting-document-list-table-wrap {
        flex: 0 0 auto;
        min-height: 0;
        overflow: visible;
    }

    .accounting-document-list-table tr {
        display: grid;
        grid-template-columns: minmax(0, 1fr) minmax(0, auto);
        grid-template-areas:
            "date status"
            "comment comment"
            "bed bes"
            "balance windows"
            "actions actions";
        gap: 8px 12px;
        padding: 12px;
        overflow: hidden;
    }

    .accounting-document-list-table .wad-list-date { grid-area: date; }
    .accounting-document-list-table .wad-list-comment { grid-area: comment; }
    .accounting-document-list-table .wad-list-money:nth-child(3) { grid-area: bed; }
    .accounting-document-list-table .wad-list-money:nth-child(4) { grid-area: bes; }
    .accounting-document-list-table .wad-list-balance { grid-area: balance; }
    .accounting-document-list-table .wad-list-status { grid-area: status; }
    .accounting-document-list-table .wad-list-windows-num { grid-area: windows; }
    .accounting-document-list-table .wad-list-actions { grid-area: actions; }

    .accounting-document-list-table .wad-list-status,
    .accounting-document-list-table .wad-list-balance {
        align-items: flex-end;
        min-width: 0;
    }

    .wad-status-badge,
    .wad-balance-badge {
        max-width: 100%;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
    }

    .accounting-document-list-pager {
        flex: 0 0 auto;
        flex-direction: row;
        flex-wrap: wrap;
        justify-content: center;
        align-items: center;
        gap: 8px;
        margin-top: 8px;
        padding: 8px 0 4px;
    }

    .accounting-document-list-pager .btn,
    .accounting-document-list-pager .btn-outline {
        flex: 0 0 auto;
        width: auto;
        min-width: 96px;
        min-height: 44px;
        height: 44px;
        max-height: 44px;
    }

    .accounting-document-summary {
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 8px;
    }

    .accounting-document-summary .summary-box {
        min-height: 0;
        padding: 10px 14px 10px 12px;
        align-items: flex-start;
        justify-content: center;
        flex-direction: column;
        gap: 2px;
        min-width: 0;
    }

    .accounting-document-summary .summary-box::before {
        left: auto;
        right: 0;
    }

    .accounting-document-summary .summary-label {
        font-size: 11px;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
        max-width: 100%;
    }

    .accounting-document-summary .summary-value {
        font-size: 15px;
        max-width: 100%;
        overflow: hidden;
        text-overflow: ellipsis;
    }
}

@media (max-width: 768px) {
    .accounting-document-page .accounting-document-actions {
        flex-direction: row;
        flex-wrap: wrap;
    }

    .accounting-document-page .accounting-document-actions .btn,
    .accounting-document-page .accounting-document-actions .btn-outline {
        width: auto;
        flex: 1 1 calc(50% - 8px);
        flex-basis: calc(50% - 8px);
        height: auto;
        max-height: none;
    }

    .accounting-document-page .accounting-document-actions .btn-primary {
        flex: 1 1 100%;
        flex-basis: 100%;
    }

    .accounting-document-list-table tr {
        grid-template-columns: minmax(0, 1fr) minmax(0, auto);
        grid-template-areas:
            "date status"
            "comment comment"
            "bed bes"
            "balance windows"
            "actions actions";
    }

    .accounting-document-list-table .wad-list-date,
    .accounting-document-list-table .wad-list-status,
    .accounting-document-list-table .wad-list-comment,
    .accounting-document-list-table .wad-list-actions {
        grid-column: auto;
        text-align: right;
    }

    .accounting-document-list-table .wad-list-date { grid-area: date; }
    .accounting-document-list-table .wad-list-status {
        grid-area: status;
        align-items: flex-end;
        text-align: left;
    }
    .accounting-document-list-table .wad-list-comment { grid-area: comment; }
    .accounting-document-list-table .wad-list-actions { grid-area: actions; }

    .accounting-document-meta {
        padding: 10px;
        gap: 10px;
    }

    .accounting-document-field .form-control,
    .accounting-document-date-field .modal-date-input,
    .wad-year-trigger {
        min-height: 44px;
        height: 44px;
    }

    .accounting-document-summary {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    /* Editor rows become stacked cards instead of a squashed grid */
    .accounting-document-table-scroll-hint {
        display: none;
    }

    #webAccountingDocument .accounting-document-table-container {
        height: auto;
        min-height: 0;
        overflow: visible;
        border: 0;
        background: transparent;
        -webkit-overflow-scrolling: auto;
    }

    #webAccountingDocument .accounting-document-table,
    #webAccountingDocument .accounting-document-table thead,
    #webAccountingDocument .accounting-document-table tbody,
    #webAccountingDocument .accounting-document-table tr,
    #webAccountingDocument .accounting-document-table th,
    #webAccountingDocument .accounting-document-table td {
        display: revert;
        width: auto;
        min-width: 0;
        position: static;
        box-shadow: none;
        background: transparent;
    }

    #webAccountingDocument .accounting-document-table {
        min-width: 0;
        width: 100%;
        table-layout: auto;
        border-collapse: separate;
        border-spacing: 0 10px;
    }

    #webAccountingDocument .accounting-document-table thead {
        display: none;
    }

    #webAccountingDocument .accounting-document-table tbody {
        display: block;
    }

    #webAccountingDocument .accounting-document-table tbody tr {
        display: grid;
        grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
        gap: 8px;
        margin: 0;
        padding: 12px;
        border: 1px solid var(--border);
        border-radius: 12px;
        background: #fff;
        box-shadow: 0 4px 14px rgba(15, 23, 42, .04);
    }

    #webAccountingDocument .accounting-document-table tbody tr:nth-child(even),
    #webAccountingDocument .accounting-document-table tbody tr:hover td,
    #webAccountingDocument .accounting-document-table tbody tr.selected td {
        background: transparent;
        box-shadow: none;
    }

    #webAccountingDocument .accounting-document-table tbody tr.selected {
        border-color: rgba(30, 136, 229, .45);
        background: #f8fbff;
    }

    #webAccountingDocument .accounting-document-table td {
        display: flex;
        flex-direction: column;
        align-items: stretch;
        justify-content: flex-start;
        height: auto;
        padding: 0;
        border: 0;
        text-align: right;
        min-width: 0;
        background: transparent;
    }

    #webAccountingDocument .accounting-document-table td::before {
        content: attr(data-label);
        color: var(--text-light);
        font-size: 11px;
        font-weight: 700;
        margin-bottom: 4px;
        text-align: right;
    }

    #webAccountingDocument .accounting-document-table td:nth-child(1) {
        flex-direction: row;
        align-items: center;
        gap: 6px;
        font-weight: 800;
        color: var(--primary-dark);
    }

    #webAccountingDocument .accounting-document-table td:nth-child(6),
    #webAccountingDocument .accounting-document-table td:nth-child(7),
    #webAccountingDocument .accounting-document-table td:nth-child(10) {
        grid-column: 1 / -1;
    }

    #webAccountingDocument .accounting-document-table td:nth-child(11) {
        grid-column: 2;
        grid-row: 1;
        align-items: flex-end;
        justify-content: center;
    }

    #webAccountingDocument .accounting-document-table td:nth-child(11)::before {
        display: none;
    }

    #webAccountingDocument .wad-col-row,
    #webAccountingDocument .wad-col-code,
    #webAccountingDocument .wad-col-cost,
    #webAccountingDocument .wad-col-account,
    #webAccountingDocument .wad-col-money,
    #webAccountingDocument .wad-col-comment,
    #webAccountingDocument .wad-col-action {
        width: auto;
    }

    #webAccountingDocument .wad-cell-input {
        height: 44px;
        min-height: 44px;
        border: 1px solid var(--border);
        border-radius: 10px;
        background: #fff;
        padding: 0 10px;
        font-size: 16px;
    }

    #webAccountingDocument .wad-cell-input:focus {
        box-shadow: 0 0 0 3px rgba(30, 136, 229, .12);
    }

    #webAccountingDocument .wad-account-cell,
    #webAccountingDocument .wad-cost-cell {
        height: auto;
        min-height: 44px;
        justify-content: flex-start;
        border: 1px solid var(--border);
        border-radius: 10px;
        padding: 4px 8px;
        background: #fff;
    }

    #webAccountingDocument .wad-account-name,
    #webAccountingDocument .wad-cost-name {
        text-align: right;
        white-space: normal;
    }

    #webAccountingDocument .wad-account-picker {
        width: 44px;
        height: 44px;
        flex-basis: 44px;
    }

    #webAccountingDocument .wad-remove-row {
        width: 44px;
        height: 44px;
        font-size: 24px;
        background: rgba(244, 67, 54, .08);
    }

    .accounting-document-page.is-editor-page .accounting-document-summary {
        position: sticky;
        bottom: 0;
        z-index: 6;
        margin-top: 8px;
        padding-top: 8px;
        padding-bottom: max(4px, env(safe-area-inset-bottom, 0px));
        background: #fff;
    }
}

@media (max-width: 620px) {
    .accounting-document-page:not(.is-editor-page) .accounting-document-card,
    .accounting-document-card {
        min-height: 0;
    }

    .accounting-document-list-pager {
        flex-direction: row;
        flex-wrap: wrap;
    }

    .accounting-document-list-pager .btn,
    .accounting-document-list-pager .btn-outline {
        width: auto;
        flex: 0 0 auto;
        min-width: 88px;
        height: 44px;
        max-height: 44px;
    }

    .accounting-document-summary {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .accounting-document-summary .summary-box {
        min-height: 0;
        padding: 10px 12px;
        flex-direction: column;
        align-items: flex-start;
        text-align: right;
    }

    #webAccountingDocument .accounting-document-table-container {
        height: auto;
        min-height: 0;
    }
}

@media (max-width: 420px) {
    .wad-status-badge {
        white-space: nowrap;
        border-radius: 999px;
        line-height: 1.2;
    }
}

