/* ==========================================
   UI-05 — Báo cáo (Graphite), approved preview 02/10/2026
   Loaded after graphite.css and expenses.css (UI-04 page pieces, scoped .ex). The page root carries both .ex and
   .rp, so head / period bar / figures / tables / panel / dialogs / toast reuse the Chi phí rules; only the pieces
   below are new. Colours come from --g-* tokens (Dark and Light).
   ========================================== */

:root, [data-theme="dark"] { --rp-bar: #a9c7d8; --rp-bar-partial: #a9c7d855; --rp-paid: #9bc8b7; --rp-gap: #8f8d9566; --rp-grid: #ffffff12; }
[data-theme="light"] { --rp-bar: #2c5f7c; --rp-bar-partial: #2c5f7c40; --rp-paid: #2f7a5c; --rp-gap: #6f6e7555; --rp-grid: #0000000f; }

.rp :is(.rp-big, .rp-tile b, .rp-comp dd, .rp-axis) { font-variant-numeric: tabular-nums; }
.rp-section-title { display: flex; align-items: baseline; flex-wrap: wrap; gap: 6px 12px; margin: 26px 0 10px; }
.rp-section-title h2 { margin: 0; font-size: 15px; font-weight: 550; color: var(--g-text); letter-spacing: 0; }
.rp-section-title span { font-size: 12px; color: var(--g-muted); }

/* The period bar's grid track must not grow to the unwrapped preset buttons (they scroll inside .ex-periods);
   otherwise <main> scrolls sideways at phone width. */
.rp .ex-filters { grid-template-columns: minmax(0, 1fr); }
.rp .ex-filter-row, .rp .ex-scope { min-width: 0; }

/* ---- Revenue of the period: summary + chart ---- */
.rp-rev-grid { display: grid; grid-template-columns: minmax(250px, 320px) minmax(0, 1fr); gap: 0; padding: 12px 22px 18px; }
.rp-sum { padding-right: 22px; border-right: 1px solid var(--ex-fig-line); }
.rp-big { margin: 4px 0 2px; font-size: 30px; font-weight: 500; letter-spacing: -.8px; line-height: 1.2; white-space: nowrap; }
.rp-big .ex-ge { font-size: 22px; letter-spacing: 0; }
.rp-comp { margin: 10px 0 0; font-size: 12px; }
.rp-comp > div { display: flex; justify-content: space-between; gap: 10px; padding: 4px 0; border-bottom: 1px solid var(--g-line-soft); }
.rp-comp > div:last-child { border-bottom: 0; }
.rp-comp dt { color: var(--g-muted); min-width: 0; }
.rp-comp dt i { display: inline-block; width: 8px; height: 8px; margin-right: 6px; border-radius: 2px; vertical-align: 0; }
.rp-comp dd { margin: 0; color: var(--g-text-2); white-space: nowrap; text-align: right; }
.rp-comp .k-day { background: var(--rp-bar); } .rp-comp .k-period { background: none; border: 1px dashed var(--g-muted); } .rp-comp .k-wait { background: none; border: 1px dotted var(--g-muted); }
.rp-sum .ex-link { margin-top: 10px; }

.rp-chart-col { min-width: 0; padding-left: 22px; }
.rp-chart-bar { display: flex; align-items: center; flex-wrap: wrap; gap: 8px 14px; margin-bottom: 8px; }
.rp-chart-bar .sd-seg button { height: 28px; font-size: 12px; }
.rp-legend { display: flex; flex-wrap: wrap; gap: 4px 14px; margin: 0; padding: 0; list-style: none; font-size: 11.5px; color: var(--g-muted); }
.rp-legend i { display: inline-block; width: 10px; height: 10px; margin-right: 5px; border-radius: 2px; vertical-align: -1px; }
.rp-legend .l-full { background: var(--rp-bar); } .rp-legend .l-partial { background: var(--rp-bar-partial); border: 1px solid var(--rp-bar); }
.rp-legend .l-gap { background: repeating-linear-gradient(135deg, var(--rp-gap) 0 2px, transparent 2px 4px); border: 1px solid var(--rp-gap); }
.rp-legend .l-paid { background: var(--rp-paid); }
.rp-chart { position: relative; display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 0 8px; width: 100%; }
.rp-yaxis { display: flex; flex-direction: column; justify-content: space-between; height: 190px; margin-top: -6px; margin-bottom: -6px; font-size: 10.5px; color: var(--g-muted); text-align: right; font-variant-numeric: tabular-nums; }
.rp-plot { position: relative; min-width: 0; }
/* width/height attributes keep Graphite's icon rule (.g-app svg:not([width])) off the chart; CSS sets the size. */
.rp-chart svg { display: block; width: 100%; height: 178px; overflow: visible; }
.rp-xaxis { position: relative; height: 18px; margin-top: 4px; font-size: 10.5px; color: var(--g-muted); font-variant-numeric: tabular-nums; }
.rp-xaxis span { position: absolute; top: 0; transform: translateX(-50%); white-space: nowrap; }
.rp-xaxis span:last-child { transform: translateX(-100%); }
.rp-skel-chart { display: block; height: 190px; border-radius: 8px; }
.rp-chart .grid { stroke: var(--rp-grid); stroke-width: 1; }
.rp-chart .rp-axis { fill: var(--g-muted); font-size: 10.5px; }
.rp-chart .bar { fill: var(--rp-bar); cursor: pointer; }
.rp-chart .bar.partial { fill: var(--rp-bar-partial); stroke: var(--rp-bar); stroke-width: 1; }
.rp-chart .bar.paid { fill: var(--rp-paid); }
.rp-chart .gap { fill: var(--rp-gap); stroke: var(--rp-gap); stroke-width: 1; stroke-dasharray: 2 2; cursor: pointer; }
.rp-chart .hit { fill: transparent; cursor: pointer; }
.rp-chart .rp-col:hover :is(.bar, .gap) { opacity: .75; }
.rp-chart .sel { fill: var(--g-coral); opacity: .14; }
.rp-chart-note { display: flex; gap: 8px; align-items: flex-start; margin: 10px 0 0; font-size: 12px; line-height: 1.5; color: var(--g-text-2); }
.rp-chart-note svg { width: 15px; height: 15px; flex: none; margin-top: 1px; color: var(--ex-info); }
.rp-period-box { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-top: 10px; padding: 9px 12px; border: 1px dashed var(--g-line); border-radius: 9px; font-size: 12px; color: var(--g-text-2); }
.rp-period-box b { font-weight: 550; color: var(--g-text); white-space: nowrap; }

/* ---- Operations at load time ---- */
.rp-ops { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); border: 1px solid var(--g-line); border-radius: 13px; background: var(--g-panel); overflow: hidden; }
.rp-tile { display: grid; gap: 3px; min-width: 0; padding: 14px 18px; border-left: 1px solid var(--g-line-soft); }
.rp-tile:first-child { border-left: 0; }
.rp-tile span { font-size: 12px; color: var(--g-muted); }
.rp-tile b { font-size: 22px; font-weight: 500; letter-spacing: -.5px; color: var(--g-text); white-space: nowrap; }
.rp-tile b small { font-size: 13px; color: var(--g-muted); font-weight: 400; letter-spacing: 0; }
.rp-tile em { font-style: normal; font-size: 11.5px; color: var(--g-muted); }
.rp-ops-state { grid-column: 1 / -1; margin: 0; border: 0; border-radius: 0; }

/* ---- Tables ---- */
.rp-th-sort { display: inline-flex; align-items: center; gap: 4px; padding: 0; border: 0; background: none; color: inherit; font: inherit; letter-spacing: inherit; text-transform: inherit; cursor: pointer; }
.rp-th-sort:hover { color: var(--g-text); }
.rp-th-sort svg { width: 11px; height: 11px; opacity: .45; }
th[aria-sort] .rp-th-sort svg { opacity: 1; color: var(--g-coral-ink); }
th[aria-sort="descending"] .rp-th-sort svg { transform: rotate(180deg); }
.rp-name { display: flex; align-items: center; min-width: 0; max-width: 260px; }
.rp-name .sd-trunc { min-width: 0; }
.rp-comp-out { margin-top: 8px; padding-top: 6px; border-top: 1px dashed var(--g-line); }
.rp-dot { display: inline-block; flex: none; width: 7px; height: 7px; margin-right: 7px; border-radius: 50%; background: var(--g-ok); vertical-align: 1px; }
.rp-dot.off { background: var(--g-muted); }
.rp-blocked { margin-left: 6px; color: var(--g-bad); font-size: 11.5px; }
.rp-bar-cell { position: relative; }
.rp-meter { display: block; height: 4px; margin-top: 4px; border-radius: 2px; background: var(--g-line-soft); overflow: hidden; }
.rp-meter i { display: block; height: 100%; background: var(--g-text-2); }
.rp-meter.hot i { background: var(--g-bad); } .rp-meter.warm i { background: var(--g-warn); }
.rp-days td.primary { white-space: nowrap; }
.rp-acct-bar { justify-content: space-between; }
.rp-acct-bar .ex-field-inline select { max-width: 220px; }
.rp-tabs { margin-top: 22px; }
.rp-days td.primary .sd-tag { margin-left: 6px; }

/* ---- Export menu ---- */
.rp-menu { min-width: 290px; }
/* The menu sits beside its .g-popover-scrim (z-index 60) in .ex-pop-wrap; it must be above it to receive pointer input. */
.rp .rp-menu { z-index: 61; }
.rp-menu button[aria-disabled="true"] { opacity: .55; }
.rp-menu hr { margin: 4px 6px; border: 0; border-top: 1px solid var(--g-line-soft); }
.rp-menu .rp-menu-note { padding: 6px 10px 4px; font-size: 11.5px; color: var(--g-muted); line-height: 1.45; }
.rp-busy { animation: rp-pulse 1s ease-in-out infinite; }
@keyframes rp-pulse { 50% { opacity: .55; } }

/* ---- Responsive ---- */
@media (max-width: 1150px) {
    .rp-rev-grid { grid-template-columns: 1fr; row-gap: 16px; }
    .rp-sum { padding-right: 0; border-right: 0; padding-bottom: 14px; border-bottom: 1px solid var(--ex-fig-line); }
    .rp-chart-col { padding-left: 0; }
    .rp-ops { grid-template-columns: repeat(3, minmax(0, 1fr)); }
    .rp-tile:nth-child(4) { border-left: 0; }
    .rp-tile:nth-child(n+4) { border-top: 1px solid var(--g-line-soft); }
}
@media (max-width: 720px) {
    .rp-rev-grid { padding: 10px 16px 14px; }
    .rp-big { font-size: 26px; }
    .rp-chart svg { height: 148px; }
    .rp-yaxis { height: 160px; }
    .rp-ops { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .rp-tile, .rp-tile:nth-child(4) { border-left: 1px solid var(--g-line-soft); }
    .rp-tile:nth-child(odd) { border-left: 0; }
    .rp-tile:nth-child(n+3) { border-top: 1px solid var(--g-line-soft); }
    .rp-tile b { font-size: 19px; }
    .rp-acct-bar .ex-field-inline select { max-width: none; }
    .rp-period-box { flex-direction: column; align-items: flex-start; gap: 2px; }
}
