/* Reusable MADAR report viewer. */
body.madar-report-open {
    overflow: hidden !important;
}

.madar-report-overlay {
    position: fixed;
    inset: 0;
    z-index: 30000;
    display: grid;
    place-items: center;
    padding: 18px;
    background: rgba(11, 22, 17, 0.72);
    backdrop-filter: blur(3px);
}

.madar-report-viewer {
    display: flex;
    flex-direction: column;
    width: min(97vw, 1320px);
    height: min(96vh, 920px);
    overflow: hidden;
    border: 1px solid #cad5cf;
    border-radius: 16px;
    background: #e9eeeb;
    box-shadow: 0 28px 80px rgba(0, 0, 0, 0.38);
}

.madar-report-toolbar {
    display: flex;
    align-items: center;
    gap: 12px;
    min-height: 62px;
    padding: 9px 14px;
    border-bottom: 1px solid #d5ded9;
    background: #fff;
}

.madar-report-toolbar > strong {
    flex: 1;
    min-width: 140px;
    overflow: hidden;
    color: #17251e;
    font-size: 14px;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.madar-report-pagination {
    display: flex;
    align-items: center;
    gap: 7px;
}
.madar-report-zoom {
    display: flex;
    align-items: center;
    gap: 7px;
}
.madar-report-actions {
    display: flex;
    align-items: center;
    gap: 7px;
}

.madar-report-pagination button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 36px;
    min-height: 36px;
    gap: 7px;
    padding: 7px 10px;
    border: 1px solid var(--action-primary);
    border-radius: 9px;
    color: var(--on-brand);
    background: var(--action-primary);
    cursor: pointer;
}
.madar-report-zoom button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 36px;
    min-height: 36px;
    gap: 7px;
    padding: 7px 10px;
    border: 1px solid var(--action-primary);
    border-radius: 9px;
    color: var(--on-brand);
    background: var(--action-primary);
    cursor: pointer;
}
.madar-report-actions > button:not(.primary-button) {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 36px;
    min-height: 36px;
    gap: 7px;
    padding: 7px 10px;
    border-radius: 9px;
    cursor: pointer;
}

.madar-report-pagination button:disabled {
    cursor: default;
    opacity: 0.4;
}

.madar-report-pagination span {
    min-width: 50px;
    color: #425149;
    font-size: 12px;
    font-weight: 700;
    text-align: center;
}
.madar-report-zoom span {
    min-width: 50px;
    color: #425149;
    font-size: 12px;
    font-weight: 700;
    text-align: center;
}

.madar-report-canvas {
    flex: 1;
    padding: 22px;
    overflow: auto;
}

.madar-report-pages {
    width: calc(274mm * var(--report-zoom, 1));
    margin: auto;
}

.madar-report-page {
    display: none;
    flex-direction: column;
    width: 274mm;
    min-height: 186mm;
    padding: 8mm 8mm 7mm;
    color: #17211c;
    background: #fff;
    box-shadow: 0 6px 28px rgba(0, 0, 0, 0.18);
    transform: scale(var(--report-zoom, 1));
    transform-origin: top right;
}

.madar-report-page.is-current {
    display: flex;
}

.madar-report-head {
    display: grid;
    grid-template-columns: 1fr 1fr;
    align-items: center;
    gap: 10mm;
    padding-bottom: 4mm;
    margin-bottom: 4mm;
    border-bottom: 2px solid #53702f;
}

.madar-report-head > div {
    display: grid;
    gap: 2px;
}

.madar-report-head > div:last-child {
    text-align: end;
}

.madar-report-head img {
    width: 40mm;
    max-height: 15mm;
    object-fit: contain;
    object-position: right center;
}

.madar-report-head strong {
    font-size: 17px;
}

.madar-report-head span {
    color: #58645e;
    font-size: 10px;
}
.madar-report-head small {
    color: #58645e;
    font-size: 10px;
}

.madar-report-filters {
    display: flex;
    flex-wrap: wrap;
    gap: 2mm;
    margin-bottom: 4mm;
}

.madar-report-filters span {
    display: inline-flex;
    gap: 5px;
    padding: 2mm 3mm;
    border: 1px solid #d8e1dc;
    border-radius: 7px;
    color: #445149;
    background: #f7faf8;
    font-size: 9px;
}

.madar-report-page table {
    width: 100%;
    table-layout: fixed;
    border-collapse: collapse;
    font-size: 8.5px;
}

.madar-report-page th {
    padding: 2.1mm 1.5mm;
    overflow-wrap: anywhere;
    border: 1px solid #ccd7d1;
    text-align: start;
    vertical-align: middle;
}
.madar-report-page td {
    padding: 2.1mm 1.5mm;
    overflow-wrap: anywhere;
    border: 1px solid #ccd7d1;
    text-align: start;
    vertical-align: middle;
}

.madar-report-page th {
    color: #fff;
    background: #315f49;
    font-weight: 800;
}

.madar-report-page tbody tr:nth-child(even) {
    background: #f4f8f6;
}

.madar-report-page footer {
    display: flex;
    justify-content: space-between;
    gap: 8px;
    padding-top: 3mm;
    margin-top: auto;
    color: #5a665f;
    border-top: 1px solid #d8e0dc;
    font-size: 8px;
}

html[data-theme='dark'] .madar-report-viewer {
    border-color: #43554c;
    background: #111a16;
}

html[data-theme='dark'] .madar-report-toolbar {
    border-color: #43554c;
    background: #1c2923;
}

html[data-theme='dark'] .madar-report-toolbar > strong {
    color: #f3f7f5;
}

html[data-theme='dark'] .madar-report-pagination span {
    color: #cbd6d0;
}
html[data-theme='dark'] .madar-report-zoom span {
    color: #cbd6d0;
}
