/* Fixed light report surface. Preview, print, and PDF export must match. */
:root {
    --report-a4-preview-width: 794px;
}

.report-preview,
.report-light {
    color-scheme: light;
    display: grid;
    gap: 16px;
    justify-items: center;
    width: max-content;
    min-width: calc(var(--report-a4-preview-width) + 36px);
    max-width: none;
    background: #e5e7eb;
    color: #111111;
    padding: 18px;
}

.report-light,
.report-light * {
    font-variant-numeric: tabular-nums;
}

.report-light .legacy-report {
    width: var(--report-a4-preview-width);
    min-width: var(--report-a4-preview-width);
    max-width: none;
    margin: 0 auto;
    padding: 24px 28px;
    background: #ffffff !important;
    color: #111111 !important;
    border: 1px solid #cfd4dc;
    box-shadow: 0 12px 30px rgba(15, 23, 42, .14);
    font-family: Arial, Helvetica, sans-serif;
    font-size: 14px;
    line-height: 1.38;
    box-sizing: border-box;
    break-after: auto;
    page-break-after: auto;
}

.report-light .legacy-page {
    margin-bottom: 22px;
    background: #ffffff !important;
    color: #111111 !important;
}

.report-light .legacy-page:not(:last-child) {
    break-after: page;
    page-break-after: always;
}

.report-light .legacy-page:last-child,
.report-light .legacy-report:last-child {
    break-after: auto;
    page-break-after: auto;
}

.report-light .doctor-page-break {
    break-before: page;
    page-break-before: always;
}

.report-light .doctor-monthly-page {
    break-after: auto;
    page-break-after: auto;
}

.report-light .legacy-report-header {
    display: grid;
    grid-template-columns: 82px minmax(0, 1fr) 220px;
    align-items: center;
    gap: 14px;
    text-align: left;
    margin-bottom: 14px;
    padding-bottom: 10px;
    border-bottom: 2px solid #111111;
    line-height: 1.25;
    font-weight: 700;
    color: #000000 !important;
    opacity: 1 !important;
}

.report-light .legacy-report-brand {
    display: grid;
    place-items: center;
}

.report-light .legacy-report-logo,
.report-light .legacy-report-logo-fallback {
    width: 58px;
    height: 58px;
    border-radius: 12px;
}

.report-light .legacy-report-logo {
    object-fit: contain;
    background: #ffffff !important;
}

.report-light .legacy-report-logo-fallback {
    display: grid;
    place-items: center;
    background: #2563eb !important;
    color: #ffffff !important;
    font-size: 19px;
    font-weight: 900;
    letter-spacing: 0;
}

.report-light .legacy-report-heading {
    min-width: 0;
    text-align: center;
}

.report-light .legacy-report-header h3 {
    margin: 0;
    color: #000000 !important;
    opacity: 1 !important;
    font-size: 20px;
    font-weight: 800;
    text-transform: uppercase;
}

.report-light .legacy-report-subtitle {
    margin-top: 2px;
    font-size: 13.5px;
    font-weight: 700;
}

.report-light .legacy-report-title {
    margin-top: 5px;
    font-size: 16px;
    font-weight: 800;
}

.report-light .legacy-report-meta {
    display: grid;
    gap: 4px;
    justify-items: stretch;
    font-size: 11.5px;
    font-weight: 700;
}

.report-light .legacy-report-meta div {
    display: grid;
    grid-template-columns: 68px minmax(0, 1fr);
    gap: 8px;
    align-items: baseline;
}

.report-light .legacy-report-meta span {
    color: #475569 !important;
    text-align: left;
}

.report-light .legacy-report-meta b {
    color: #000000 !important;
    text-align: right;
}

.report-light .legacy-report-meta .legacy-report-extra {
    grid-template-columns: 1fr;
}

.report-light .legacy-report-meta .legacy-report-extra b {
    text-align: right;
}

.report-light .legacy-report-header div,
.report-light .legacy-report-header span,
.report-light .legacy-report h5,
.report-light .legacy-summary,
.report-light .legacy-summary span,
.report-light .legacy-summary b,
.report-light .legacy-summary strong {
    color: #000000 !important;
    opacity: 1 !important;
}

.report-light .legacy-report h5 {
    margin: 14px 0 7px;
    font-size: 14px;
    font-weight: 800;
    text-align: center;
    text-transform: uppercase;
}

.report-light .legacy-table {
    width: 100%;
    border-collapse: collapse;
    margin: 7px 0 10px;
    table-layout: fixed;
    background: #ffffff !important;
    color: #111111 !important;
}

.report-light .legacy-table th,
.report-light .legacy-table td {
    border: 1px solid #111111;
    padding: 6px 8px;
    vertical-align: top;
    word-break: normal;
    overflow-wrap: break-word;
    color: #111111 !important;
    opacity: 1 !important;
}

.report-light .legacy-table th {
    background: #f2f4f7 !important;
    font-weight: 800;
    text-align: center;
}

.report-light .legacy-table td {
    background: #ffffff !important;
}

.report-light .legacy-table tr:hover td {
    background: #ffffff !important;
    color: #111111 !important;
}

.report-light .legacy-table td:nth-child(n+3),
.report-light .legacy-table th:nth-child(n+3) {
    text-align: right;
}

.report-light .legacy-table td:first-child,
.report-light .legacy-table th:first-child,
.report-light .legacy-table td:nth-child(2),
.report-light .legacy-table th:nth-child(2) {
    text-align: left;
}

.report-light .legacy-table th.legacy-col-text,
.report-light .legacy-table td.legacy-col-text {
    text-align: left;
}

.report-light .legacy-total-row td {
    font-weight: 800;
    background: #f8fafc !important;
}

.report-light .legacy-summary {
    width: min(460px, 100%);
    margin: 9px 0 12px auto;
    display: grid;
    gap: 5px;
}

.report-light .legacy-summary > div {
    display: flex;
    justify-content: space-between;
    gap: 16px;
}

.report-light .legacy-summary span {
    text-align: right;
}

.report-light .legacy-summary b {
    min-width: 140px;
    text-align: right;
}

.report-light .legacy-summary strong {
    text-align: center;
    font-size: 13px;
}

.report-light .legacy-empty {
    border: 1px dashed #6b7280;
    padding: 18px;
    text-align: center;
    color: #111111 !important;
    background: #ffffff !important;
}

.report-light .combined-financial-report {
    width: var(--report-a4-preview-width);
    min-width: var(--report-a4-preview-width);
    max-width: none;
    overflow: visible;
}

.report-light .combined-report-section {
    padding: 0;
    margin: 0 0 14px;
    background: #ffffff !important;
    color: #111111 !important;
    border-bottom: 0;
    break-inside: auto;
    page-break-inside: auto;
}

.report-light .combined-report-section:last-child {
    border-bottom: 0;
}

.report-light .combined-report-section h5 {
    margin: 0 0 12px;
    padding-bottom: 7px;
    border-bottom: 2px solid #111111;
    text-align: left;
    break-after: avoid;
    page-break-after: avoid;
}

.report-light .combined-report-section h6 {
    margin: 4px 0 8px;
    color: #111111 !important;
    font-size: 12px;
    font-weight: 900;
    text-transform: uppercase;
}

.report-light .combined-summary-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 10px;
}

.report-light .combined-summary-card {
    min-height: 66px;
    display: grid;
    align-content: center;
    gap: 5px;
    padding: 12px;
    border: 1px solid #cfd4dc;
    border-radius: 8px;
    background: #f8fafc !important;
    break-inside: avoid;
    page-break-inside: avoid;
}

.report-light .combined-summary-card span {
    color: #374151 !important;
    font-size: 11px;
    font-weight: 800;
    text-transform: uppercase;
}

.report-light .combined-summary-card strong {
    color: #111111 !important;
    font-size: 18px;
    font-weight: 900;
    text-align: right;
}

.report-light .legacy-report-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-top: 14px;
    padding-top: 8px;
    border-top: 1px solid #111111;
    color: #111111 !important;
    font-size: 11.5px;
    font-weight: 700;
}

.report-light .legacy-page-number::after {
    content: " Preview";
}

.report-light .combined-two-column {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 16px;
    align-items: start;
}

@media print {
    @page {
        size: A4 portrait;
        margin: 10mm;
    }

    html,
    body {
        width: 100% !important;
        min-height: auto !important;
        height: auto !important;
        overflow: visible !important;
        background: #ffffff !important;
        color: #111111 !important;
        -webkit-print-color-adjust: exact !important;
        print-color-adjust: exact !important;
    }

    body * {
        visibility: hidden !important;
    }

    #reportPrint,
    #reportPrint * {
        visibility: visible !important;
    }

    #reportPrint {
        display: block !important;
        position: absolute !important;
        inset: 0 auto auto 0 !important;
        width: 100% !important;
        min-width: 0 !important;
        max-width: none !important;
        min-height: auto !important;
        height: auto !important;
        margin: 0 !important;
        padding: 0 !important;
        overflow: visible !important;
        background: #ffffff !important;
        color: #111111 !important;
    }

    #sidebar,
    #topbar,
    .sidebar,
    .topbar,
    .main-area > header,
    .reports-page,
    .report-grid-preview,
    .printable-preview-header,
    .printable-preview-scroll-hint,
    #toast,
    .toast-box,
    .confirm-overlay,
    .no-print {
        display: none !important;
    }

    .app-shell,
    .main-area,
    #app-content,
    #content,
    .printable-preview-shell,
    .report-preview-scroll {
        display: block !important;
        width: 100% !important;
        min-width: 0 !important;
        max-width: none !important;
        height: auto !important;
        min-height: auto !important;
        margin: 0 !important;
        padding: 0 !important;
        overflow: visible !important;
        background: #ffffff !important;
        box-shadow: none !important;
        border: 0 !important;
    }

    .report-light,
    .report-light .legacy-report {
        width: 100% !important;
        max-width: none !important;
        min-width: 0 !important;
        min-height: auto !important;
        margin: 0 !important;
        background: #ffffff !important;
        color: #111111 !important;
        border: 0 !important;
        box-shadow: none !important;
        break-after: auto !important;
        page-break-after: auto !important;
        break-before: auto !important;
        page-break-before: auto !important;
        break-inside: auto !important;
        page-break-inside: auto !important;
    }

    .report-light .legacy-report {
        padding: 0 !important;
        font-size: 10pt !important;
        line-height: 1.28 !important;
    }

    .report-light .combined-report-section {
        padding: 0 !important;
        margin: 0 0 4.5mm !important;
        background: #ffffff !important;
        color: #111111 !important;
        border-bottom: 0 !important;
        break-inside: auto !important;
        page-break-inside: auto !important;
    }

    .report-light .combined-report-section h5,
    .report-light .combined-report-section h6,
    .report-light .combined-summary-card,
    .report-light .legacy-summary {
        break-inside: avoid !important;
        page-break-inside: avoid !important;
    }

    .report-light .combined-summary-grid {
        grid-template-columns: repeat(3, 1fr) !important;
        gap: 5mm !important;
    }

    #reportPrint .combined-summary-grid,
    #reportPrint .summary-grid,
    #reportPrint .report-summary-grid,
    #reportPrint .kpi-grid {
        display: grid !important;
        grid-template-columns: repeat(3, 1fr) !important;
        gap: 10px !important;
        break-inside: avoid !important;
        page-break-inside: avoid !important;
    }

    #reportPrint .combined-summary-card,
    #reportPrint .summary-card,
    #reportPrint .report-summary-card,
    #reportPrint .kpi-card {
        display: block !important;
        border: 1px solid #cfd8e3 !important;
        border-radius: 6px !important;
        padding: 10px 12px !important;
        min-height: 58px !important;
        background: #f8fafc !important;
        break-inside: avoid !important;
        page-break-inside: avoid !important;
    }

    #reportPrint .combined-summary-card span,
    #reportPrint .summary-card label,
    #reportPrint .summary-card .label,
    #reportPrint .report-summary-card label,
    #reportPrint .report-summary-card .label,
    #reportPrint .kpi-card label,
    #reportPrint .kpi-card .label {
        display: block !important;
        font-size: 10px !important;
        font-weight: 700 !important;
        text-transform: uppercase !important;
        margin-bottom: 6px !important;
        color: #374151 !important;
    }

    #reportPrint .combined-summary-card strong,
    #reportPrint .summary-card strong,
    #reportPrint .summary-card .value,
    #reportPrint .report-summary-card strong,
    #reportPrint .report-summary-card .value,
    #reportPrint .kpi-card strong,
    #reportPrint .kpi-card .value {
        display: block !important;
        text-align: right !important;
        font-size: 16px !important;
        font-weight: 800 !important;
        color: #111111 !important;
    }

    .report-light .combined-two-column {
        grid-template-columns: 1fr 1fr !important;
        gap: 6mm !important;
    }

    .report-light .legacy-report:last-child {
        break-after: auto !important;
        page-break-after: auto !important;
    }

    .report-light .legacy-page {
        margin: 0 !important;
        padding: 0 !important;
        break-inside: auto !important;
        page-break-inside: auto !important;
    }

    .report-light .legacy-page:not(:last-child) {
        break-after: auto !important;
        page-break-after: auto !important;
    }

    .report-light .legacy-page:last-child {
        break-after: auto !important;
        page-break-after: auto !important;
    }

    .report-light .doctor-page-break {
        break-before: page !important;
        page-break-before: always !important;
    }

    .report-light .doctor-monthly-page {
        break-after: auto !important;
        page-break-after: auto !important;
    }

    .report-light .legacy-report-header {
        grid-template-columns: 20mm minmax(0, 1fr) 48mm !important;
        gap: 4mm !important;
        margin-bottom: 4mm !important;
        padding-bottom: 3mm !important;
    }

    .report-light .legacy-report-logo,
    .report-light .legacy-report-logo-fallback {
        width: 16mm !important;
        height: 16mm !important;
        border-radius: 3mm !important;
    }

    .report-light .legacy-report-logo-fallback {
        font-size: 14pt !important;
    }

    .report-light .legacy-report-header h3 {
        font-size: 15pt !important;
    }

    .report-light .legacy-report-subtitle {
        font-size: 10pt !important;
    }

    .report-light .legacy-report-title {
        font-size: 12pt !important;
    }

    .report-light .legacy-report-meta {
        font-size: 8.5pt !important;
        gap: 1.3mm !important;
    }

    .report-light .legacy-report-meta div {
        grid-template-columns: 17mm minmax(0, 1fr) !important;
        gap: 2mm !important;
    }

    .report-light .legacy-table {
        width: 100% !important;
        max-width: 100% !important;
        margin: 2.5mm 0 3.5mm !important;
        page-break-inside: auto !important;
        break-inside: auto !important;
        table-layout: fixed !important;
    }

    .report-light .legacy-table tr {
        break-inside: avoid !important;
        page-break-inside: avoid !important;
    }

    .report-light .legacy-table thead {
        display: table-header-group !important;
    }

    .report-light .legacy-table tfoot {
        display: table-footer-group !important;
    }

    .report-light .legacy-table th,
    .report-light .legacy-table td {
        padding: 3.2pt 4pt !important;
        overflow-wrap: anywhere !important;
        word-break: normal !important;
    }

    .report-light .legacy-table,
    .report-light .legacy-table td,
    .report-light .legacy-empty {
        background: #ffffff !important;
        color: #111111 !important;
    }

    .report-light .legacy-table th,
    .report-light .legacy-total-row td {
        background: #f2f4f7 !important;
        color: #111111 !important;
    }

    .report-light .legacy-report-header,
    .report-light .legacy-report-header h3,
    .report-light .legacy-report-header div,
    .report-light .legacy-report-header span {
        color: #000000 !important;
        opacity: 1 !important;
    }

    .report-light .legacy-summary {
        margin: 2.5mm 0 3.5mm auto !important;
    }

    .report-light .legacy-report-footer {
        position: static !important;
        margin: 0 !important;
        padding-top: 3mm !important;
        background: #ffffff !important;
        font-size: 8.5pt !important;
        break-inside: avoid !important;
        page-break-inside: avoid !important;
    }

    .report-light .legacy-page-number::after {
        content: " " counter(page) " of " counter(pages);
    }
}
