.bill-sheet-shell { width: min(1760px, calc(100% - 40px)); }
.bill-sheet-heading { align-items: center; }
.bill-sheet-heading h1 { max-width: none; }
.bill-sheet-actions { display: flex; flex: 0 0 auto; flex-wrap: wrap; justify-content: flex-end; gap: 10px; }

.bill-filter-card {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: end;
    gap: 24px;
    margin-bottom: 20px;
    padding: 18px;
    border: 1px solid var(--line);
    border-radius: 16px;
    background: white;
    box-shadow: var(--shadow);
}
.bill-period-form { display: grid; grid-template-columns: 160px 160px minmax(220px, 1fr) minmax(140px, auto) auto; align-items: end; gap: 10px; }
.bill-address-card { margin-bottom: 20px; padding: 18px; border: 1px solid var(--line); border-radius: 16px; background: white; }
.bill-address-form { display: flex; align-items: end; flex-wrap: wrap; gap: 10px; }
.bill-address-form label { display: flex; flex: 1 1 280px; flex-direction: column; gap: 5px; color: var(--muted); font-size: 11px; font-weight: 800; }
.bill-address-form input:not([type="hidden"]) { width: 100%; min-height: 44px; padding: 9px 11px; border: 1px solid #cbd5cd; border-radius: 10px; }
.bill-address-card details { margin-top: 14px; }
.bill-address-card summary { cursor: pointer; color: var(--green-dark); font-size: 12px; font-weight: 800; }
.bill-address-card details > form { margin-top: 12px; }
.bill-period-form label, .bill-client-filters label { display: flex; min-width: 0; flex-direction: column; gap: 5px; color: var(--muted); font-size: 11px; font-weight: 800; }
.bill-period-form input, .bill-period-form select, .bill-client-filters input, .bill-client-filters select {
    width: 100%;
    min-height: 44px;
    padding: 9px 11px;
    border: 1px solid #cbd5cd;
    border-radius: 10px;
    background: white;
    color: var(--ink);
}
.cache-state { display: flex; min-width: 250px; flex-direction: column; text-align: right; }
.cache-state span { color: var(--green); font-size: 11px; font-weight: 850; letter-spacing: .04em; text-transform: uppercase; }
.cache-state strong { font-size: 16px; }
.cache-state small { color: var(--muted); font-size: 10px; }

.bill-metrics { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 10px; margin-bottom: 20px; }
.pay-desk-metrics { grid-template-columns: repeat(5, minmax(0, 1fr)); }
.bill-metrics article { display: flex; min-height: 112px; flex-direction: column; padding: 15px; border: 1px solid var(--line); border-radius: 14px; background: white; }
.bill-metrics span { color: var(--muted); font-size: 11px; font-weight: 750; }
.bill-metrics strong { margin-top: auto; font-size: 29px; line-height: 1; }
.bill-metrics small { margin-top: 6px; color: var(--muted); font-size: 9px; }
.bill-metrics .metric-green { border-color: #bddfc9; background: #f3fbf6; }
.bill-metrics .metric-green strong { color: var(--green); }
.bill-metrics .metric-amber { border-color: #edd6b2; background: #fffaf2; }
.bill-metrics .metric-amber strong { color: var(--amber); }

.bill-table-card, .bill-files-card { overflow: hidden; margin-bottom: 20px; border: 1px solid var(--line); border-radius: 17px; background: white; box-shadow: var(--shadow); }
.bill-table-heading { display: flex; align-items: center; justify-content: space-between; gap: 24px; padding: 18px 20px; border-bottom: 1px solid var(--line); background: #f8fbf9; }
.bill-table-heading .eyebrow { margin-bottom: 2px; }
.bill-table-heading h2 { margin: 0; font-size: 23px; }
.bill-table-heading p { margin: 3px 0 0; color: var(--muted); font-size: 11px; }
.bill-table-heading > strong { flex: 0 0 auto; padding: 7px 10px; border-radius: 999px; background: var(--green-soft); color: var(--green-dark); font-size: 11px; }
.bill-tabs { display: flex; gap: 8px; padding: 12px 18px 0; border-bottom: 1px solid var(--line); background: #fbfdfb; }
.bill-tab { display: inline-flex; align-items: center; gap: 8px; padding: 10px 14px; border: 1px solid transparent; border-bottom: 0; border-radius: 10px 10px 0 0; color: var(--muted); text-decoration: none; font-size: 13px; font-weight: 800; }
.bill-tab b { min-width: 22px; padding: 2px 7px; border-radius: 999px; background: #e8efe9; color: var(--green-dark); font-size: 11px; text-align: center; }
.bill-tab:hover { color: var(--ink); background: #f3f8f4; }
.bill-tab.is-active { color: var(--ink); background: white; border-color: var(--line); box-shadow: 0 1px 0 white; }
.bill-tab.is-active b { background: var(--green-soft); }
.pay-desk-table { min-width: 980px; }
.pay-desk-table td:last-child { min-width: 120px; }
.pay-desk-group td {
    padding-top: 16px;
    border-bottom-color: #d5e3d9;
    background: #f4f8f5;
    font-size: 13px;
}
.pay-desk-overdue { color: var(--red); }
.pay-desk-route {
    display: inline-flex;
    align-items: center;
    min-height: 24px;
    padding: 2px 8px;
    border-radius: 999px;
    font-size: 11px;
    font-weight: 800;
}
.pay-desk-route-ready { background: var(--green-soft); color: var(--green-dark); }
.pay-desk-route-unmatched,
.pay-desk-route-missing { background: var(--amber-soft); color: var(--amber); }
.pay-desk-route-manual { background: #e8f0fa; color: #28588a; }
.pay-desk-filters { align-items: center; }
.bill-client-filters { display: grid; grid-template-columns: minmax(280px, 1fr) 200px 220px 220px; gap: 9px; padding: 13px 18px; border-bottom: 1px solid var(--line); }
.bill-search { max-width: 720px; }
form.bill-search { display: flex; min-width: 0; gap: 8px; align-items: center; }
form.bill-search label { flex: 1; }
form.bill-search .button { flex-shrink: 0; }
.bill-table-scroll { overflow-x: auto; }
.bill-cell-label { display: none !important; }
.bill-table { width: 100%; min-width: 1280px; border-collapse: collapse; }
.bill-table th { padding: 10px 13px; border-bottom: 1px solid var(--line); background: #fbfcfb; color: var(--muted); font-size: 9px; letter-spacing: .055em; text-align: left; text-transform: uppercase; }
.bill-table td { min-width: 160px; padding: 13px; border-bottom: 1px solid var(--line); vertical-align: top; font-size: 11px; }
.bill-table tr:last-child td { border-bottom: 0; }
.bill-table tr:hover td { background: #fbfdfb; }
.bill-table td:first-child { min-width: 210px; }
.bill-table td:nth-child(2) { min-width: 235px; }
.bill-table td:nth-child(3) { min-width: 180px; }
.bill-table td:nth-child(4) { min-width: 190px; }
.bill-table td:nth-child(5) { min-width: 175px; }
.bill-table td:nth-child(6) { min-width: 190px; }
.bill-table td > strong, .bill-table td > span, .bill-table td > small, .bill-table td > a { display: block; }
.bill-table td > span, .bill-table td > small { margin-top: 3px; }
.bill-table td > small { color: var(--muted); font-size: 9px; overflow-wrap: anywhere; }
.bill-table td > a { width: fit-content; margin-top: 6px; color: var(--green); font-size: 10px; font-weight: 800; }
.bill-table b { color: var(--muted); font-size: 9px; text-transform: uppercase; }
.bill-source, .bill-status { width: fit-content; margin-top: 6px !important; padding: 4px 7px; border-radius: 999px; background: #edf1ee; color: #526159; font-size: 9px; font-weight: 850; }
.bill-source-xero-and-billing { background: var(--green-soft); color: var(--green-dark); }
.bill-source-xero-only { background: #e8f0fa; color: #28588a; }
.bill-source-billing-only { background: var(--amber-soft); color: #74400b; }
.bill-conflict { margin-top: 7px !important; padding: 6px 8px; border-radius: 8px; background: var(--amber-soft); color: #74400b; font-size: 9px; font-weight: 800; }
.bill-filter-empty, .bill-files-note { padding: 16px 20px; color: var(--muted); font-size: 11px; text-align: center; }
.bill-pagination { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px; padding: 14px 18px; border-top: 1px solid var(--line); background: #f8fbf9; }
.bill-pagination strong { color: var(--ink); font-size: 13px; }
.bill-pagination > span { color: var(--muted); font-size: 12px; }
.bill-pagination .button[aria-disabled="true"] { opacity: .45; pointer-events: none; }
.bill-supplier-correction { width: 100%; margin-top: 8px; padding: 7px 9px; border: 1px solid #b8d8c4; border-radius: 8px; background: #f3fbf6; color: var(--green-dark); cursor: pointer; font: inherit; font-size: 10px; font-weight: 850; }
.bill-supplier-correction:hover { background: #e6f6eb; }
.bill-supplier-payment { display: block; width: 100%; margin-top: 8px; padding: 8px 9px; border: 1px solid #7f9cc8; border-radius: 8px; background: #e8eef8; color: #14325a; cursor: pointer; font: inherit; font-size: 11px; font-weight: 850; }
.bill-supplier-payment:hover { background: #d9e4f5; }
.bill-supplier-modal { width: min(620px, calc(100% - 28px)); max-height: min(720px, calc(100% - 32px)); padding: 0; border: 0; border-radius: 18px; box-shadow: 0 24px 90px rgba(20, 40, 26, .35); color: var(--ink); }
.bill-supplier-modal::backdrop { background: rgba(18, 30, 22, .58); }
.bill-supplier-modal form { display: flex; flex-direction: column; gap: 16px; padding: 22px; }
.bill-supplier-modal header { display: flex; align-items: flex-start; justify-content: space-between; gap: 18px; }
.bill-supplier-modal h2 { margin: 2px 0 5px; font-size: 23px; }
.bill-supplier-modal header p { max-width: 520px; margin: 0; color: var(--muted); font-size: 12px; line-height: 1.45; }
.bill-modal-close { display: grid; width: 34px; height: 34px; flex: 0 0 auto; place-items: center; border: 1px solid var(--line); border-radius: 50%; background: white; color: var(--muted); cursor: pointer; font-size: 22px; line-height: 1; }
.bill-supplier-comparison { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin: 0; }
.bill-supplier-comparison div { padding: 12px; border: 1px solid var(--line); border-radius: 10px; background: #f8fbf9; }
.bill-supplier-comparison dt { color: var(--muted); font-size: 10px; font-weight: 850; text-transform: uppercase; }
.bill-supplier-comparison dd { margin: 5px 0 0; font-size: 13px; font-weight: 800; overflow-wrap: anywhere; }
.bill-supplier-modal label:not(.bill-supplier-confirm) { display: flex; flex-direction: column; gap: 6px; color: var(--muted); font-size: 11px; font-weight: 800; }
.bill-supplier-modal input[type="search"],
.bill-supplier-modal input[type="number"],
.bill-supplier-modal select { min-height: 44px; padding: 9px 10px; border: 1px solid #cbd5cd; border-radius: 9px; background: white; color: var(--ink); font: inherit; }
.bill-supplier-modal select { max-height: 220px; }
.bill-supplier-warning { margin: 0; padding: 11px 12px; border-radius: 9px; background: var(--amber-soft); color: #74400b; font-size: 11px; line-height: 1.45; }
.bill-supplier-confirm { display: flex; align-items: flex-start; gap: 9px; font-size: 12px; font-weight: 750; line-height: 1.4; }
.bill-supplier-confirm input { width: 16px; height: 16px; margin-top: 1px; accent-color: var(--green); }
.bill-supplier-modal footer { display: flex; justify-content: flex-end; gap: 9px; padding-top: 2px; }

.bill-files-card > summary { display: flex; align-items: center; justify-content: space-between; gap: 20px; padding: 17px 20px; cursor: pointer; list-style: none; }
.bill-files-card > summary::-webkit-details-marker { display: none; }
.bill-files-card > summary span:first-child { display: flex; flex-direction: column; }
.bill-files-card > summary .eyebrow { margin-bottom: 1px; }
.bill-files-card > summary b { display: grid; min-width: 34px; height: 34px; place-items: center; border-radius: 50%; background: #e8f0fa; color: #28588a; }
.bill-files-card[open] > summary { border-bottom: 1px solid var(--line); background: #f8fbfd; }
.bill-files-note { border-bottom: 1px solid var(--line); background: #fbfcfd; }
.bill-file-table { min-width: 980px; }

@media (max-width: 1320px) {
    .bill-filter-card { grid-template-columns: 1fr; }
    .cache-state { text-align: left; }
    .bill-metrics { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}

@media (max-width: 850px) {
    .bill-sheet-shell { width: min(100% - 24px, 1760px); padding-top: 32px; }
    .bill-sheet-heading { align-items: flex-start; flex-direction: column; gap: 20px; }
    .bill-sheet-actions { width: 100%; justify-content: stretch; }
    .bill-sheet-actions .button { flex: 1 1 190px; }
    .bill-period-form { grid-template-columns: 1fr 1fr; }
    .bill-period-form label:nth-child(3), .bill-period-form .button { grid-column: 1 / -1; }
    .bill-metrics { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .bill-table-heading { align-items: flex-start; flex-direction: column; }
    .bill-client-filters { grid-template-columns: 1fr; }
    .bill-table:not(.bill-file-table) { min-width: 0; display: block; }
    .bill-table:not(.bill-file-table) thead { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
    .bill-table:not(.bill-file-table) tbody { display: grid; gap: 12px; padding: 12px; }
    .bill-table [data-bill-row] { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); border: 1px solid var(--line); border-radius: 12px; overflow: hidden; }
    .bill-table [data-bill-row][hidden] { display: none; }
    .bill-table [data-bill-row] td { min-width: 0; padding: 12px; font-size: 13px; overflow-wrap: anywhere; }
    .bill-table [data-bill-row] td:first-child,
    .bill-table [data-bill-row] td:nth-child(2),
    .bill-table [data-bill-row] td:last-child { grid-column: 1 / -1; }
    .bill-table [data-bill-row] td > small,
    .bill-table [data-bill-row] td > a,
    .bill-table [data-bill-row] b,
    .bill-table [data-bill-row] .bill-source,
    .bill-table [data-bill-row] .bill-status,
    .bill-table [data-bill-row] .bill-conflict { font-size: 12px; }
    .bill-table [data-bill-row] .bill-cell-label { display: block !important; margin: 0 0 6px; color: var(--muted); font-size: 11px; font-weight: 800; }
    .bill-table [data-bill-row] .bill-supplier-correction,
    .bill-table [data-bill-row] .bill-supplier-payment { min-height: 44px; font-size: 13px; }
    .bill-table [data-bill-row] td:last-child { border-bottom: 0; }
}

@media (max-width: 520px) {
    .bill-table [data-bill-row] { grid-template-columns: minmax(0, 1fr); }
    .bill-period-form { grid-template-columns: 1fr; }
    .bill-period-form label:nth-child(3), .bill-period-form .button { grid-column: 1; }
    .bill-metrics { grid-template-columns: 1fr 1fr; }
    .bill-metrics article { min-height: 98px; }
    .bill-supplier-comparison { grid-template-columns: 1fr; }
    .bill-supplier-modal form { padding: 17px; }
    .bill-supplier-modal footer { flex-direction: column-reverse; }
    .bill-supplier-modal footer .button { width: 100%; }
}
.attachment-progress { display: block; }
.attachment-progress h2 { margin: 0 0 12px; font-size: 18px; }
.attachment-progress progress { width: 100%; height: 14px; accent-color: var(--green, #28764c); }
.attachment-progress-counts { display: flex; flex-wrap: wrap; gap: 10px 24px; margin: 16px 0; }
.attachment-progress-counts span { color: var(--muted); }
.attachment-progress-counts strong { color: var(--ink); margin-left: 5px; }
