/* Shared styles for reporting components. Loaded globally from
   wwwroot/index.html so classes like .oc-report-filters can be used from
   any Razor page or shared component without Blazor CSS isolation.
   Governed by PartnerPortal/PartnerPortal/design-system/70-reporting.md. */

/* =========================================================================
   Report header (section 2.1) - name, description, purpose, action bar.
   ========================================================================= */
.oc-report-header {
    display: flex;
    flex-direction: column;
    gap: var(--oc-space-3, 12px);
    padding: var(--oc-space-5, 20px) var(--oc-space-6, 24px);
    background: var(--oc-surface, #fff);
    border: 1px solid var(--oc-gray-200, #e5e7eb);
    border-radius: var(--oc-radius-lg, 18px);
    box-shadow: var(--oc-shadow-sm);
    margin-bottom: var(--oc-space-4, 16px);
    /* Prevent flex children from forcing parent > viewport width. */
    max-width: 100%;
    box-sizing: border-box;
    min-width: 0;
    overflow-wrap: anywhere;
}

.oc-report-header-main {
    display: flex;
    flex-wrap: wrap;
    gap: var(--oc-space-4, 16px);
    align-items: flex-start;
    justify-content: space-between;
    min-width: 0;
    width: 100%;
}

.oc-report-header-text { flex: 1 1 320px; min-width: 0; max-width: 100%; }

.oc-report-header-crumbs {
    display: flex;
    flex-wrap: wrap;
    gap: 0.35rem;
    align-items: center;
    font-size: var(--oc-fs-xs, 0.75rem);
    color: var(--oc-gray-500);
    margin-bottom: 0.4rem;
    min-width: 0;
    max-width: 100%;
}
.oc-report-header-crumbs a { color: var(--oc-gray-600); text-decoration: none; }
.oc-report-header-crumbs a:hover { color: var(--oc-orange); }
.oc-report-header-crumb-current { color: var(--oc-gray-800); font-weight: 600; }

.oc-report-header-title {
    margin: 0 0 0.25rem 0;
    font-size: var(--oc-fs-h1, 1.6rem);
    font-weight: 700;
    color: var(--oc-gray-900);
    display: flex;
    align-items: center;
    gap: 0.6rem;
    flex-wrap: wrap;
}
.oc-report-header-id {
    font-family: var(--oc-font-mono);
    font-size: 0.7rem;
    font-weight: 600;
    padding: 0.15rem 0.5rem;
    border-radius: 999px;
    background: var(--oc-gray-100);
    color: var(--oc-gray-600);
    letter-spacing: 0.04em;
}

.oc-report-header-desc {
    margin: 0 0 0.6rem 0;
    color: var(--oc-gray-700);
    font-size: var(--oc-fs-body, 0.95rem);
    max-width: 80ch;
    min-width: 0;
    overflow-wrap: anywhere;
    word-break: break-word;
}

.oc-report-header-purpose {
    display: flex;
    align-items: flex-start;
    gap: 0.5rem;
    padding: 0.55rem 0.75rem;
    background: var(--oc-orange-50, #fef5f1);
    border: 1px solid var(--oc-orange-100, #fde8df);
    border-radius: var(--oc-radius-md, 12px);
    color: var(--oc-gray-800);
    font-size: var(--oc-fs-sm, 0.85rem);
    max-width: 80ch;
    min-width: 0;
    overflow-wrap: anywhere;
    word-break: break-word;
}
.oc-report-header-purpose > div { min-width: 0; flex: 1 1 auto; }
.oc-report-header-purpose > i { color: var(--oc-orange-600); font-size: 1rem; margin-top: 0.1rem; }
.oc-report-header-purpose-label { font-weight: 700; margin-right: 0.3rem; color: var(--oc-orange-700); }

.oc-report-header-actions { flex: 0 0 auto; }
.oc-report-header-meta {
    display: flex; gap: 0.5rem; flex-wrap: wrap; align-items: center;
    padding-top: 0.5rem; border-top: 1px dashed var(--oc-gray-200);
    color: var(--oc-gray-600); font-size: var(--oc-fs-sm);
}

/* =========================================================================
   Action bar (section 2.3) - icon-first, consistent on every report.
   ========================================================================= */
.oc-report-actions {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.35rem;
}
.oc-report-action {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    padding: 0.45rem 0.7rem;
    background: var(--oc-surface);
    border: 1px solid var(--oc-gray-200);
    border-radius: var(--oc-radius-md);
    color: var(--oc-gray-800);
    font-size: var(--oc-fs-sm);
    cursor: pointer;
    transition: background-color var(--oc-dur-fast) var(--oc-ease), border-color var(--oc-dur-fast) var(--oc-ease), color var(--oc-dur-fast) var(--oc-ease);
}
.oc-report-action:hover {
    background: var(--oc-orange-50);
    border-color: var(--oc-orange);
    color: var(--oc-orange-700);
}
.oc-report-action:disabled { opacity: 0.55; cursor: not-allowed; }
.oc-report-action > i { font-size: 1.05rem; }
.oc-report-action-label { font-weight: 600; }
.oc-report-action-status {
    font-size: var(--oc-fs-xs);
    color: var(--oc-gray-600);
    margin-left: 0.3rem;
}
.oc-report-action-status.is-error { color: var(--oc-danger, #7a1710); }

/* =========================================================================
   Filter bar (section 3) - single-row on desktop, wraps on tablet,
   stacks on phone. Every selector inside it shares the exact same
   height, font, and spacing via the .oc-report-selector shell.
   ========================================================================= */
.oc-report-filters {
    display: flex;
    flex-wrap: wrap;
    align-items: stretch;
    gap: var(--oc-space-3, 12px);
    padding: var(--oc-space-3, 12px) var(--oc-space-4, 16px);
    background: var(--oc-gray-50, #fafbfc);
    border: 1px solid var(--oc-gray-200, #e5e7eb);
    border-radius: var(--oc-radius-md, 12px);
    margin-bottom: var(--oc-space-4, 16px);
}

.oc-report-filters-actions {
    margin-left: auto;
    display: flex;
    align-items: flex-end;
}

.oc-report-filters-custom {
    display: flex;
    flex-wrap: wrap;
    gap: var(--oc-space-3, 12px);
    align-items: flex-end;
}

.oc-report-date,
.oc-report-selector {
    display: flex;
    flex-direction: column;
    gap: 0.3rem;
    min-width: 210px;
    max-width: 100%;
}

.oc-report-date-label,
.oc-report-selector-label {
    font-size: var(--oc-fs-xs, 0.75rem);
    font-weight: 700;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    color: var(--oc-gray-600, #555c6b);
}

.oc-report-date-preview,
.oc-report-selector-preview {
    font-size: var(--oc-fs-xs, 0.75rem);
    color: var(--oc-gray-500);
}

/* Force every dropdown / select / tri-mode selector inside the filter bar
   to share the same shell - height, border radius, font, padding. This is
   what prevents the "some boxes look different" drift the CEO flagged. */
.oc-report-filters select,
.oc-report-filters .form-select,
.oc-report-filters .form-control,
.oc-report-filters input[type="date"],
.oc-report-filters input[type="text"],
.oc-scope-segmented,
.oc-scope-edit {
    height: 36px;
    border-radius: var(--oc-radius-md, 12px) !important;
    border: 1px solid var(--oc-gray-300, #d1d5db);
    background: var(--oc-surface);
    color: var(--oc-gray-800);
    font-size: var(--oc-fs-sm, 0.85rem);
    padding: 0 0.65rem;
    box-shadow: none;
}
.oc-report-filters select:focus,
.oc-report-filters .form-select:focus,
.oc-report-filters .form-control:focus,
.oc-report-filters input:focus,
.oc-scope-edit:focus {
    outline: none;
    border-color: var(--oc-orange);
    box-shadow: var(--oc-shadow-focus, 0 0 0 3px rgba(238,87,44,.25));
}

.oc-report-date-custom {
    display: flex;
    align-items: center;
    gap: 0.35rem;
    margin-top: 0.2rem;
}
.oc-report-date-sep { font-size: var(--oc-fs-sm); color: var(--oc-gray-500); }

/* =========================================================================
   Tri-mode scope selector (section 3.2).
   ========================================================================= */
.oc-scope-row {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex-wrap: wrap;
}
.oc-scope-segmented {
    display: inline-flex;
    padding: 2px;
    gap: 2px;
    align-items: center;
    height: 36px;
    background: var(--oc-gray-100);
    border: 1px solid var(--oc-gray-200) !important;
    border-radius: var(--oc-radius-md, 12px);
}
.oc-scope-seg {
    appearance: none;
    border: none;
    background: transparent;
    color: var(--oc-gray-700);
    font-size: var(--oc-fs-sm);
    font-weight: 600;
    padding: 0 0.75rem;
    height: 30px;
    border-radius: calc(var(--oc-radius-md, 12px) - 3px);
    cursor: pointer;
    transition: background-color var(--oc-dur-fast) var(--oc-ease), color var(--oc-dur-fast) var(--oc-ease);
}
.oc-scope-seg:hover { background: var(--oc-gray-50); }
.oc-scope-seg.is-on {
    background: var(--oc-surface);
    color: var(--oc-orange-700);
    box-shadow: var(--oc-shadow-xs);
}

.oc-scope-edit {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    color: var(--oc-orange-700);
    font-weight: 600;
    cursor: pointer;
    max-width: 100%;
}
.oc-scope-edit:hover { background: var(--oc-orange-50); border-color: var(--oc-orange); }
.oc-scope-edit span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 14ch; }
.oc-scope-helper { font-size: var(--oc-fs-xs); color: var(--oc-gray-500); }

/* Scope picker - uses the native <dialog> element so the picker renders in
   the browser's top layer (above the sidebar's z-index: 9999 stacking
   context and any toasts). No manual z-index required. */
dialog.oc-scope-dialog {
    padding: 0;
    border: 1px solid var(--oc-gray-200);
    border-radius: var(--oc-radius-lg, 18px);
    background: var(--oc-surface);
    box-shadow: var(--oc-shadow-lg);
    width: min(720px, calc(100vw - 32px));
    max-width: 720px;
    max-height: calc(100vh - 48px);
    overflow: hidden;
}
dialog.oc-scope-dialog[open] {
    display: flex;
    flex-direction: column;
}
dialog.oc-scope-dialog::backdrop {
    background: rgba(17, 20, 24, 0.55);
    backdrop-filter: blur(1px);
}

.oc-scope-modal-head {
    display: flex; align-items: flex-start; justify-content: space-between; gap: 0.75rem;
    padding: 0.95rem 1.15rem 0.75rem;
    border-bottom: 1px solid var(--oc-gray-200);
}
.oc-scope-modal-title { margin: 0; font-size: var(--oc-fs-h3, 1.05rem); font-weight: 700; color: var(--oc-gray-900); }
.oc-scope-modal-sub {
    font-size: var(--oc-fs-xs); color: var(--oc-gray-600); margin-top: 0.15rem;
}
.oc-scope-modal-sub strong { color: var(--oc-gray-900); font-weight: 700; }
.oc-scope-modal-close {
    appearance: none; border: none; background: transparent;
    font-size: 1rem; color: var(--oc-gray-500); cursor: pointer;
    padding: 0.25rem 0.5rem; border-radius: var(--oc-radius-sm);
    flex: 0 0 auto;
}
.oc-scope-modal-close:hover { color: var(--oc-gray-900); background: var(--oc-gray-100); }

.oc-scope-modal-section {
    display: flex; flex-direction: column;
    padding: 0.65rem 1.15rem;
    border-bottom: 1px solid var(--oc-gray-200);
}
.oc-scope-modal-section:last-of-type { border-bottom: none; }
.oc-scope-modal-items-section {
    flex: 1 1 auto; min-height: 0; /* allow child list to scroll */
}
.oc-scope-section-head {
    display: flex; align-items: center; justify-content: space-between; gap: 0.6rem;
    margin-bottom: 0.5rem;
    flex-wrap: wrap;
}
.oc-scope-section-label {
    font-size: var(--oc-fs-xs); font-weight: 700; letter-spacing: 0.06em;
    color: var(--oc-gray-500); text-transform: uppercase;
    margin-right: 0.5rem;
}
.oc-scope-section-count {
    font-size: var(--oc-fs-xs); color: var(--oc-gray-600);
}
.oc-scope-section-count strong { color: var(--oc-gray-900); font-weight: 700; }
.oc-scope-section-bulk {
    display: inline-flex; align-items: center; gap: 0.35rem;
    font-size: var(--oc-fs-xs);
}
.oc-scope-link {
    appearance: none; border: none; background: transparent;
    color: var(--oc-primary, #E77619); font-weight: 600;
    padding: 0.1rem 0.3rem; border-radius: var(--oc-radius-sm); cursor: pointer;
    font-size: var(--oc-fs-xs);
}
.oc-scope-link:hover { background: var(--oc-orange-50); }
.oc-scope-sep { color: var(--oc-gray-400); }

.oc-scope-search {
    position: relative; width: 100%;
    margin-bottom: 0.5rem;
}
/* Icon sits above the input; pointer-events: none so clicks pass through to
   the field. The wrapped <i> also needs an explicit line-height / width so
   nothing collapses it to 0 when a parent rule clobbers inline defaults. */
dialog.oc-scope-dialog .oc-scope-search > i.bi {
    position: absolute; left: 0.75rem; top: 50%;
    transform: translateY(-50%);
    color: var(--oc-gray-500);
    font-size: 0.95rem;
    line-height: 1;
    pointer-events: none;
    z-index: 1;
}
/* High-specificity padding so the app-wide input resets in app.css / Bootstrap
   can't shrink our left gutter back to 0 and slide the caret under the icon. */
dialog.oc-scope-dialog .oc-scope-search input.oc-scope-search-input {
    width: 100%;
    height: 36px;
    padding-top: 0;
    padding-right: 2rem;
    padding-bottom: 0;
    padding-left: 2.25rem;
    border-radius: var(--oc-radius-md);
    border: 1px solid var(--oc-gray-300);
    background: var(--oc-surface);
    font-size: var(--oc-fs-sm);
    box-sizing: border-box;
}
dialog.oc-scope-dialog .oc-scope-search input.oc-scope-search-input:focus {
    outline: none;
    border-color: var(--oc-primary, #E77619);
    box-shadow: 0 0 0 3px rgba(231, 118, 25, 0.18);
}
.oc-scope-search-clear {
    position: absolute; right: 0.5rem; top: 50%; transform: translateY(-50%);
    appearance: none; border: none; background: transparent;
    color: var(--oc-gray-400); cursor: pointer; padding: 0.15rem;
    font-size: 0.85rem;
    z-index: 1;
}
.oc-scope-search-clear:hover { color: var(--oc-gray-700); }

.oc-scope-modal-tags {
    display: flex; flex-wrap: wrap; align-items: center; gap: 0.4rem;
}
.oc-scope-tag {
    appearance: none;
    border: 1px solid var(--oc-gray-300);
    background: var(--oc-surface);
    color: var(--oc-gray-700);
    font-size: var(--oc-fs-xs); font-weight: 600;
    padding: 0.2rem 0.6rem;
    border-radius: 999px; cursor: pointer;
}
.oc-scope-tag.is-on { color: #fff !important; }

.oc-scope-modal-list {
    flex: 1 1 auto; overflow-y: auto; min-height: 160px; max-height: 42vh;
    padding: 0.15rem 0.25rem 0.15rem 0.1rem;
    border: 1px solid var(--oc-gray-200);
    border-radius: var(--oc-radius-md);
    background: var(--oc-gray-50);
}
.oc-scope-modal-hidden-note {
    display: flex; align-items: center; gap: 0.4rem;
    padding: 0.45rem 0.6rem; margin: 0.25rem 0.25rem 0.35rem;
    background: var(--oc-warning-bg); color: var(--oc-warning-text);
    border: 1px solid #F7E3A8; border-radius: var(--oc-radius-sm);
    font-size: var(--oc-fs-xs);
}
.oc-scope-item {
    display: grid;
    grid-template-columns: 22px 1fr auto;
    align-items: center;
    gap: 0.6rem;
    padding: 0.4rem 0.55rem;
    border-radius: var(--oc-radius-sm);
    cursor: pointer;
    background: var(--oc-surface);
    margin: 0.15rem;
    border: 1px solid transparent;
}
.oc-scope-item:hover { background: var(--oc-gray-100); }
.oc-scope-item.is-on { background: var(--oc-orange-50); border-color: #F3C597; }
.oc-scope-item-name { font-size: var(--oc-fs-sm); color: var(--oc-gray-800); display: inline-flex; align-items: center; gap: 0.45rem; }
.oc-scope-tag-dot {
    display: inline-block; width: 10px; height: 10px; border-radius: 50%;
    border: 1px solid rgba(0,0,0,0.1); flex: 0 0 auto;
}
.oc-scope-item-tags { display: flex; gap: 0.25rem; flex-wrap: wrap; justify-content: flex-end; }
.oc-scope-item-tag {
    font-size: 0.65rem; font-weight: 700; letter-spacing: 0.03em;
    padding: 0.1rem 0.4rem; border-radius: 999px; border: 1px solid;
}
.oc-scope-modal-loading, .oc-scope-modal-empty {
    padding: 1.5rem; color: var(--oc-gray-500); text-align: center;
}
.oc-scope-modal-foot {
    display: flex; align-items: center; justify-content: space-between; gap: 0.75rem;
    padding: 0.75rem 1.15rem; border-top: 1px solid var(--oc-gray-200);
    background: var(--oc-gray-50);
}
.oc-scope-foot-count {
    font-size: var(--oc-fs-sm); color: var(--oc-gray-700);
}
.oc-scope-foot-count strong { color: var(--oc-gray-900); font-weight: 700; }
.oc-scope-foot-actions {
    display: inline-flex; gap: 0.5rem;
}

@media (max-width: 520px) {
    dialog.oc-scope-dialog {
        width: calc(100vw - 16px);
        max-height: calc(100vh - 24px);
    }
    .oc-scope-section-head { flex-direction: column; align-items: flex-start; }
}

/* =========================================================================
   Data grid (section 5) - sortable columns, per-column filters, zoom.
   ========================================================================= */
.oc-rg {
    background: var(--oc-surface);
    border: 1px solid var(--oc-gray-200);
    border-radius: var(--oc-radius-lg, 18px);
    box-shadow: var(--oc-shadow-sm);
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

.oc-rg-toolbar {
    display: flex; align-items: center; justify-content: space-between;
    gap: 0.5rem; flex-wrap: wrap;
    padding: 0.55rem 0.85rem;
    border-bottom: 1px solid var(--oc-gray-200);
    background: var(--oc-gray-50);
}
.oc-rg-toolbar-left, .oc-rg-toolbar-right { display: flex; align-items: center; gap: 0.35rem; flex-wrap: wrap; }
.oc-rg-count { font-size: var(--oc-fs-sm); color: var(--oc-gray-600); font-weight: 600; }
.oc-rg-clear { padding: 0; font-size: var(--oc-fs-xs); }

.oc-rg-iconbtn {
    appearance: none; border: 1px solid var(--oc-gray-200);
    background: var(--oc-surface);
    color: var(--oc-gray-700);
    width: 32px; height: 32px;
    border-radius: var(--oc-radius-md);
    display: inline-flex; align-items: center; justify-content: center;
    cursor: pointer;
    transition: background-color var(--oc-dur-fast) var(--oc-ease), border-color var(--oc-dur-fast) var(--oc-ease);
}
.oc-rg-iconbtn:hover { background: var(--oc-orange-50); border-color: var(--oc-orange); color: var(--oc-orange-700); }
.oc-rg-iconbtn.is-on { background: var(--oc-orange); border-color: var(--oc-orange); color: #fff; }
.oc-rg-zoomlabel { font-size: 0.7rem; font-weight: 700; }

.oc-rg-columns-collector { display: none !important; }

.oc-rg-scroll {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    max-width: 100%;
}
.oc-rg-table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
    font-size: calc(var(--oc-fs-sm, 0.85rem) * var(--oc-rg-zoom, 1));
    color: var(--oc-gray-900);
    transform-origin: top left;
}

.oc-rg-th {
    position: sticky; top: 0; z-index: 2;
    text-align: left;
    font-weight: 700;
    letter-spacing: 0.03em;
    text-transform: uppercase;
    font-size: calc(var(--oc-fs-xs, 0.75rem) * var(--oc-rg-zoom, 1));
    color: var(--oc-gray-500);
    background: var(--oc-surface);
    border-bottom: 1px solid var(--oc-gray-200);
    padding: 0.7rem 0.9rem;
    white-space: nowrap;
    user-select: none;
}
.oc-rg-th.is-sortable { cursor: pointer; }
.oc-rg-th.is-sortable:hover { color: var(--oc-orange-700); background: var(--oc-orange-50); }
.oc-rg-th.is-sort-asc, .oc-rg-th.is-sort-desc { color: var(--oc-orange-700); }

.oc-rg-th-label { margin-right: 0.3rem; }
.oc-rg-sorticon { color: var(--oc-gray-400); }
.oc-rg-th.is-sort-asc .oc-rg-sorticon,
.oc-rg-th.is-sort-desc .oc-rg-sorticon { color: var(--oc-orange); }

.oc-rg-filters-row .oc-rg-filter-th {
    padding: 0.3rem 0.5rem;
    background: var(--oc-gray-50);
    border-bottom: 1px solid var(--oc-gray-200);
    position: sticky; top: calc(0.7rem * 2 + 1rem); z-index: 1;
}
.oc-rg-filter-input {
    width: 100%;
    height: 28px;
    padding: 0 0.5rem;
    font-size: var(--oc-fs-xs);
    border: 1px solid var(--oc-gray-300);
    border-radius: var(--oc-radius-sm);
    background: var(--oc-surface);
    color: var(--oc-gray-900);
}
.oc-rg-filter-input:focus { outline: none; border-color: var(--oc-orange); box-shadow: var(--oc-shadow-focus); }

.oc-rg-tr { transition: background-color var(--oc-dur-fast) var(--oc-ease); }
.oc-rg-tr:nth-child(even) { background: var(--oc-gray-50); }
.oc-rg-tr:hover { background: var(--oc-orange-50); }

.oc-rg-td {
    padding: 0.7rem 0.9rem;
    border-bottom: 1px solid var(--oc-gray-100);
    vertical-align: middle;
}

[data-oc-theme="dark"] .oc-scope-modal-hidden-note {
    background: var(--oc-amber-100);
    border-color: rgba(255, 208, 138, 0.28);
    color: var(--oc-amber-800);
}

[data-oc-theme="dark"] .oc-rg,
[data-oc-theme="dark"] .oc-rg-table {
    color: var(--oc-gray-900);
}

[data-oc-theme="dark"] .oc-rg-td a:not(.btn),
[data-oc-theme="dark"] .oc-rg-card-value a:not(.btn),
[data-oc-theme="dark"] .oc-report-header-crumbs a {
    color: var(--oc-link, #ff9b78);
}

[data-oc-theme="dark"] .oc-rg-td a:not(.btn):hover,
[data-oc-theme="dark"] .oc-rg-card-value a:not(.btn):hover,
[data-oc-theme="dark"] .oc-report-header-crumbs a:hover {
    color: var(--oc-link-hover, #ffc2ad);
}

[data-oc-theme="dark"] .oc-rg-th {
    background: var(--oc-gray-100);
    color: var(--oc-gray-700);
}

[data-oc-theme="dark"] .oc-rg-filters-row .oc-rg-filter-th {
    background: var(--oc-gray-50);
}

[data-oc-theme="dark"] .oc-report-filters select,
[data-oc-theme="dark"] .oc-report-filters .form-select,
[data-oc-theme="dark"] .oc-report-filters .form-control,
[data-oc-theme="dark"] .oc-report-filters input[type="date"],
[data-oc-theme="dark"] .oc-report-filters input[type="text"],
[data-oc-theme="dark"] .oc-scope-segmented,
[data-oc-theme="dark"] .oc-scope-edit {
    background: var(--oc-surface);
    border-color: var(--oc-gray-300);
    color: var(--oc-gray-900);
}

[data-oc-theme="dark"] .oc-report-date-label,
[data-oc-theme="dark"] .oc-report-selector-label {
    color: var(--oc-gray-700);
}
.oc-rg.is-dense .oc-rg-td { padding: 0.35rem 0.65rem; }
.oc-rg.is-dense .oc-rg-th { padding: 0.4rem 0.65rem; }

.oc-align-right  { text-align: right; }
.oc-align-center { text-align: center; }

.oc-rg-footer {
    display: flex; justify-content: space-between; align-items: center;
    padding: 0.65rem 0.9rem;
    border-top: 1px solid var(--oc-gray-200);
    background: var(--oc-gray-50);
    color: var(--oc-gray-600);
    font-size: var(--oc-fs-sm);
}

.oc-rg-loading { padding: 1rem; display: flex; flex-direction: column; gap: 0.4rem; }

/* Mobile: switch to stacked cards and grow the action targets. */
.oc-rg-cards { display: none; flex-direction: column; gap: 0.5rem; padding: 0.65rem; }
.oc-rg-card {
    background: var(--oc-surface);
    border: 1px solid var(--oc-gray-200);
    border-radius: var(--oc-radius-md);
    padding: 0.75rem 0.9rem;
    box-shadow: var(--oc-shadow-xs);
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
}
.oc-rg-card-row {
    display: flex; justify-content: space-between; gap: 0.75rem;
    align-items: baseline;
}
.oc-rg-card-label {
    font-size: var(--oc-fs-xs);
    font-weight: 700; letter-spacing: 0.04em;
    text-transform: uppercase;
    color: var(--oc-gray-500);
    flex-shrink: 0;
}
.oc-rg-card-value {
    text-align: right; color: var(--oc-gray-900);
    font-size: var(--oc-fs-sm); min-width: 0; word-break: break-word;
}

@media (max-width: 720px) {
    .oc-rg-scroll { display: none; }
    .oc-rg-cards  { display: flex; }
    .oc-rg-toolbar { padding: 0.45rem 0.65rem; }
}

/* =========================================================================
   Audit status badges
   - Used on /reports/audit and /reports/core-numbers ONLY.
   - Reports themselves never render audit chips (background-only - see
     design-system/70-reporting.md sections 7-8).
   ========================================================================= */
.oc-report-audit-badge {
    font-size: 0.7rem; font-weight: 700; letter-spacing: 0.04em;
    text-transform: uppercase; padding: 0.125rem 0.5rem;
    border-radius: 999px; color: #fff;
}
.oc-report-audit-pass    { background: var(--oc-success-bg); color: var(--oc-success-text); }
.oc-report-audit-warn    { background: var(--oc-orange-600, #d44a23); }
.oc-report-audit-fail    { background: var(--oc-danger-bg); color: var(--oc-danger-text); }
.oc-report-audit-error   { background: #5a0f0a; }
.oc-report-audit-unknown { background: #9aa1ad; color: #1f2430; }   /* constant-bg grey badge — hard-pin dark text so it reads in BOTH modes (var(--oc-text) flipped to near-white in dark = 2.38:1 on grey) */

/* Legacy export button keeps working but newer pages should use OcReportActionBar. */
.oc-report-export { display: flex; align-items: center; gap: 0.5rem; margin-top: var(--oc-space-3); }
.oc-report-export-error { font-size: var(--oc-fs-sm); }

/* =========================================================================
   Mobile tweaks - filter bar stacks, header actions move below title.
   ========================================================================= */
@media (max-width: 760px) {
    .oc-report-header { padding: var(--oc-space-4) var(--oc-space-4); }
    .oc-report-header-main { flex-direction: column; }
    .oc-report-header-actions { width: 100%; }
    .oc-report-actions { flex-wrap: nowrap; overflow-x: auto; -webkit-overflow-scrolling: touch; }
    .oc-report-actions .oc-report-action { flex: 0 0 auto; justify-content: center; padding: 0.4rem 0.6rem; }
    .oc-report-filters { padding: var(--oc-space-3); }
    .oc-report-filters-actions { margin-left: 0; width: 100%; }
    .oc-report-filters-actions .btn { width: 100%; }
    .oc-report-date, .oc-report-selector { min-width: 100%; }
}

/* =========================================================================
   Phone-sized: force every reporting element to hard-cap at the viewport
   width so NOTHING can drive a horizontal scrollbar or bleed past the
   phone frame. This is defense-in-depth - we already set min-width: 0 on
   the flex chain, but on real iPhones Safari is far more aggressive about
   honoring intrinsic widths of table/pre/code/badge content.
   ========================================================================= */
@media (max-width: 500px) {
    .oc-report-header,
    .oc-report-filters,
    .oc-rg {
        max-width: 100%;
        width: 100%;
        box-sizing: border-box;
    }

    .oc-report-header { padding: 0.85rem 0.9rem; border-radius: var(--oc-radius-md); }
    .oc-report-header-main { gap: 0.6rem; }
    .oc-report-header-text { flex: 1 1 100%; max-width: 100%; min-width: 0; }
    .oc-report-header-title { font-size: 1.1rem; line-height: 1.2; gap: 0.35rem; flex-wrap: wrap; }
    .oc-report-header-id { font-size: 0.6rem; padding: 0.1rem 0.4rem; }
    .oc-report-header-desc,
    .oc-report-header-purpose-text,
    .oc-report-header-purpose-label {
        max-width: 100%;
        min-width: 0;
        overflow-wrap: anywhere;
        word-break: break-word;
        hyphens: auto;
    }
    .oc-report-header-desc { font-size: 0.85rem; line-height: 1.35; }
    .oc-report-header-purpose { padding: 0.5rem 0.6rem; font-size: 0.78rem; }
    .oc-report-header-purpose > div { min-width: 0; width: 100%; }

    .oc-report-actions .oc-report-action { font-size: var(--oc-fs-xs); }
    .oc-report-actions .oc-report-action > i { font-size: 0.95rem; }
}

/* Final safety net: never let a reporting page drive a horizontal
   scrollbar on the whole document. If a table or pre block really is
   wider than the viewport it will scroll inside its own .oc-rg-scroll
   container.

   IMPORTANT: we cap against the VIEWPORT, not just the parent. Parents
   in the portal shell can occasionally stretch wider than the viewport
   during Blazor's initial prerender (before the grid has sized) and a
   plain max-width: 100% would let the report card drag past the phone
   edge for one repaint. `calc(100vw - 1rem)` pins every card to the
   viewport minus a 0.5rem gutter on each side so the rounded corners
   are always visible regardless of what the parent is doing. */
.oc-report-header,
.oc-report-filters,
.oc-rg {
    max-width: 100%;
    box-sizing: border-box;
}

@media (max-width: 500px) {
    .oc-report-header,
    .oc-report-filters,
    .oc-rg {
        max-width: calc(100vw - 1rem);
        margin-left: auto;
        margin-right: auto;
    }

    /* Every descendant of a report card must also respect the parent
       width. This catches stray long tokens (license IDs, emails, URLs)
       that would otherwise force-stretch their container. */
    .oc-report-header *,
    .oc-report-filters * {
        max-width: 100%;
        min-width: 0;
    }

    /* Only the data grid is allowed to scroll horizontally — that's the
       surface the CEO explicitly wants pinch-to-zoom / horizontal scroll
       on. The grid's inner .oc-rg-scroll already has overflow-x: auto. */
    .oc-rg { overflow: hidden; }
}

/* ---------------------------------------------------------------------------
   Expandable rows (OcReportDataGrid DetailTemplate). Opt-in "hamburger" detail
   per row — see design-system/70-reporting.md section 5. The leading chevron
   column is narrow; the detail panel spans the full grid width beneath its row.
   --------------------------------------------------------------------------- */
.oc-rg-expander-th { width: 2.25rem; padding-left: 0.25rem; padding-right: 0.25rem; }

.oc-rg-expander-cell {
    width: 2.25rem;
    text-align: center;
    padding-left: 0.25rem;
    padding-right: 0.25rem;
}

.oc-rg-expander {
    border: none;
    background: transparent;
    color: var(--oc-gray-600);
    cursor: pointer;
    padding: 0.2rem;
    line-height: 1;
    border-radius: var(--oc-radius-sm, 8px);
    transition: transform 0.12s ease, background-color 0.12s ease, color 0.12s ease;
}
.oc-rg-expander:hover { background: var(--oc-gray-100); color: var(--oc-gray-900); }
.oc-rg-expander.is-open { transform: rotate(90deg); color: var(--oc-primary, #2563eb); }

.oc-rg-tr.is-expanded { background: var(--oc-gray-50, #f8fafc); }

.oc-rg-detail-row > .oc-rg-detail-cell {
    padding: 0;
    background: var(--oc-gray-50, #f8fafc);
    border-bottom: 1px solid var(--oc-gray-200, #e5e7eb);
}

/* Mobile card detail toggle + panel. */
.oc-rg-card-expander {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    border: 1px solid var(--oc-gray-300);
    background: var(--oc-gray-50, #f8fafc);
    color: var(--oc-gray-700);
    border-radius: var(--oc-radius-md, 12px);
    padding: 0.35rem 0.6rem;
    font-size: var(--oc-fs-sm);
    margin-top: 0.5rem;
    cursor: pointer;
}
.oc-rg-card-expander .bi { transition: transform 0.12s ease; }
.oc-rg-card-expander.is-open .bi { transform: rotate(90deg); }
.oc-rg-card-detail { margin-top: 0.5rem; }

/* ---------------------------------------------------------------------------
   Site Income report (RPT_SITE_INCOME) expandable detail panel. Rendered inside
   OcReportDataGrid's DetailTemplate full-width cell. Three side-by-side source
   breakdowns; stacks on narrow screens.
   --------------------------------------------------------------------------- */
.sir-detail {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: var(--oc-space-4, 1rem);
    padding: var(--oc-space-4, 1rem) var(--oc-gutter, 1rem);
}
@media (max-width: 720px) {
    .sir-detail { grid-template-columns: 1fr; }
}
.sir-detail-title {
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--oc-gray-600);
    margin: 0 0 0.4rem 0;
}
.sir-detail-empty { color: var(--oc-gray-500); font-size: var(--oc-fs-sm); margin: 0; }
.sir-detail-table { width: 100%; border-collapse: collapse; font-size: var(--oc-fs-sm); }
.sir-detail-table td { padding: 0.2rem 0; border-bottom: 1px solid var(--oc-gray-200, #e5e7eb); }
.sir-detail-table .sir-amt { text-align: right; font-variant-numeric: tabular-nums; }
.sir-detail-subtotal td { font-weight: 600; border-bottom: none; padding-top: 0.4rem; }

/* Site Income billing-edit popup: license checklist / covered-licenses list. */
.sir-license-list { max-height: 220px; overflow-y: auto; padding: 0.25rem 0.1rem; }
ul.sir-license-list { list-style: disc; padding-left: 1.25rem; }
.sir-license-list .form-check { margin-bottom: 0.15rem; }
