/* Charts for the Merchant Hub and the shared reports (js/charts.js). Colours follow the day/night theme. */
:root, [data-theme="day"] {
    --ch-1: #3A3631; --ch-2: #B0226A; --ch-3: #0E7A4E; --ch-4: #B7791F; --ch-5: #2F6FB0; --ch-6: #8A8378; --ch-7: #764BA2;
    --ch-band: rgba(14, 122, 78, 0.14); --ch-band-line: rgba(14, 122, 78, 0.55);
}
[data-theme="night"] {
    --ch-1: #C9C2B8; --ch-2: #F07DBA; --ch-3: #7FD1A5; --ch-4: #E8C547; --ch-5: #8FB8E8; --ch-6: #7A7368; --ch-7: #B79BE0;
    --ch-band: rgba(127, 209, 165, 0.16); --ch-band-line: rgba(127, 209, 165, 0.6);
}
.ch-c1 { --c: var(--ch-1); } .ch-c2 { --c: var(--ch-2); } .ch-c3 { --c: var(--ch-3); } .ch-c4 { --c: var(--ch-4); }
.ch-c5 { --c: var(--ch-5); } .ch-c6 { --c: var(--ch-6); } .ch-c7 { --c: var(--ch-7); }

/* ---- Chart / Table switch */
.view-switch { display: flex; justify-content: flex-end; margin: 0 0 10px; }
.view-switch button { font: 500 10px var(--mono, 'Martian Mono'), monospace; letter-spacing: .12em; text-transform: uppercase; cursor: pointer;
    padding: 6px 12px; background: transparent; color: var(--ink-3); border: 1px solid var(--line-2); margin-left: -1px; }
.view-switch button[aria-pressed="true"] { background: var(--ink); color: var(--bg); border-color: var(--ink); }
.view-switch button:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
.views[data-view="chart"] .view-table, .views[data-view="table"] .view-chart { display: none; }
.view-chart { border: 1px solid var(--line); background: var(--surface); padding: 16px 16px 14px; }

.ch-empty { margin: 0; color: var(--ink-3); font-size: 13px; }
.ch-legend { display: flex; flex-wrap: wrap; gap: 6px 16px; margin: 0 0 12px; font: 10px var(--mono, 'Martian Mono'), monospace;
    letter-spacing: .1em; text-transform: uppercase; color: var(--ink-3); }
.ch-legend i { display: inline-block; width: 10px; height: 10px; margin-right: 6px; vertical-align: -1px; background: var(--c); }
.ch-legend i.ln { height: 3px; vertical-align: 2px; }
.ch-legend i.ch-bandkey { background: var(--ch-band); border: 1px solid var(--ch-band-line); }

/* ---- horizontal bars */
.ch-hbars { display: grid; gap: 10px; max-height: 440px; overflow: auto; overscroll-behavior: contain; }
.ch-hrow { display: grid; grid-template-columns: minmax(120px, 32%) minmax(0, 1fr); gap: 12px; align-items: center; }
.ch-hlabel { font-size: 13px; line-height: 1.3; min-width: 0; }
.ch-hlabel .t { overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.ch-hlabel small { display: block; font-size: 11px; color: var(--ink-3); }
.ch-htrack { display: grid; gap: 3px; }
.ch-hline { display: flex; align-items: center; gap: 8px; min-height: 12px; }
.ch-hline i { display: block; flex: none; height: 12px; min-width: 0; max-width: calc(100% - 64px); background: var(--c); }
.ch-hline span { font: 11px var(--mono, 'Martian Mono'), monospace; color: var(--ink-2); white-space: nowrap; }

/* ---- the box for columns and lines */
.ch-area { position: relative; height: 220px; margin: 10px 6px 0 46px; border-bottom: 1px solid var(--line-2); }
.ch-area.has-right, .ch-x.has-right { margin-right: 46px; }
.ch-grid { position: absolute; left: 0; right: 0; border-top: 1px dashed var(--line); }
.ch-grid span { position: absolute; left: -46px; width: 40px; text-align: right; transform: translateY(-50%);
    font: 10px var(--mono, 'Martian Mono'), monospace; color: var(--ink-3); }
.ch-grid span.r { left: auto; right: -46px; text-align: left; }
.ch-groups { position: absolute; inset: 0; display: flex; }
.ch-group { flex: 1; display: flex; justify-content: center; gap: 3px; padding: 0 3px; min-width: 0; }
.ch-slot { position: relative; flex: 0 1 44px; min-width: 2px; height: 100%; }
.ch-slot i { position: absolute; left: 0; right: 0; background: var(--c); }
.ch-slot em { position: absolute; left: 50%; transform: translateX(-50%); margin-bottom: 4px; font: normal 10px var(--mono, 'Martian Mono'), monospace;
    color: var(--ink-2); white-space: nowrap; }
.ch-whisk { position: absolute; left: 50%; width: 0; border-left: 1.5px solid var(--ink-2); }
.ch-whisk::before, .ch-whisk::after { content: ''; position: absolute; left: -5px; width: 8px; border-top: 1.5px solid var(--ink-2); }
.ch-whisk::before { top: 0; } .ch-whisk::after { bottom: 0; }
.ch-lines { position: absolute; inset: 0; width: 100%; height: 100%; overflow: visible; pointer-events: none; }
.ch-lines polyline { fill: none; stroke: var(--c); stroke-width: 2.5; vector-effect: non-scaling-stroke; stroke-linejoin: round; stroke-linecap: round; }
.ch-dot { position: absolute; z-index: 1; width: 10px; height: 10px; border-radius: 50%; background: var(--c); border: 2px solid var(--surface);
    transform: translate(-50%, 50%); }
.ch-x { display: flex; margin: 6px 6px 0 46px; }
.ch-x span { flex: 1; min-width: 0; text-align: center; font-size: 11px; color: var(--ink-3); white-space: nowrap; }
.ch-x.dense span { overflow: visible; }                 /* only every few days is labelled: let it spill */
.ch-x:not(.dense) span { overflow: hidden; text-overflow: ellipsis; padding: 0 2px; }

/* ---- ranges: dot + 95% range over the benchmark band, one scale per row */
.ch-ranges { display: grid; max-height: 440px; overflow: auto; overscroll-behavior: contain; }
.ch-rrow { display: grid; grid-template-columns: minmax(130px, 30%) minmax(0, 1fr) minmax(64px, auto); gap: 14px; align-items: center;
    padding: 10px 0 16px; border-bottom: 1px solid var(--line); }
.ch-rrow:last-child { border-bottom: 0; }
.ch-rtrack { position: relative; height: 24px; border-left: 1px solid var(--line-2); }
.ch-band { position: absolute; top: 2px; bottom: 2px; background: var(--ch-band); border: 1px solid var(--ch-band-line); }
.ch-rwhisk { position: absolute; height: 0; border-top: 2.5px solid var(--c); transform: translateY(-50%); }
.ch-rtrack .ch-dot { bottom: auto; transform: translate(-50%, -50%); }
.ch-rmin, .ch-rmax { position: absolute; top: 100%; margin-top: 2px; font: 9.5px var(--mono, 'Martian Mono'), monospace; color: var(--ink-3); }
.ch-rmin { left: 0; } .ch-rmax { right: 0; }
.ch-rnone { position: absolute; left: 0; top: 50%; transform: translateY(-50%); padding-right: 8px; background: var(--surface); font-size: 12px; color: var(--ink-3); }
.ch-rval { display: grid; gap: 2px; justify-items: end; font: 11px var(--mono, 'Martian Mono'), monospace; color: var(--ink); white-space: nowrap; }
.ch-rval i { display: inline-block; width: 8px; height: 8px; margin-right: 5px; border-radius: 50%; background: var(--c); }

/* ---- capped charts: fade + "Show all" bar (charts.js capControls) */
.ch-hbars.full, .ch-ranges.full { max-height: none; }
.ch-hbars.more::after, .ch-ranges.more::after { content: ''; position: sticky; bottom: 0; display: block; height: 36px; margin-top: -36px;
    pointer-events: none; background: linear-gradient(to bottom, transparent, var(--surface)); }
.ch-more { display: flex; align-items: center; justify-content: center; gap: 9px; width: calc(100% + 32px); margin: 12px -16px -14px; padding: 10px 12px;
    cursor: pointer; font: 500 10px var(--mono, 'Martian Mono'), monospace; letter-spacing: .14em; text-transform: uppercase; color: var(--ink-2);
    background: var(--surface); border: 0; border-top: 1px solid var(--line-2); }
.ch-more[hidden] { display: none; }
.ch-more:hover { color: var(--ink); background: var(--bg); }
.ch-more:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }
.ch-more i { width: 7px; height: 7px; margin-top: -4px; border-right: 2px solid currentColor; border-bottom: 2px solid currentColor; transform: rotate(45deg); transition: transform .15s; }
.ch-more.up i { transform: rotate(-135deg); margin-top: 4px; }

@media (max-width: 640px) {
    .ch-hrow, .ch-rrow { grid-template-columns: minmax(0, 1fr); gap: 6px; }
    .ch-rval { justify-items: start; grid-auto-flow: column; justify-content: start; gap: 10px; margin-top: 12px; }
    .ch-area, .ch-x { margin-left: 38px; }
    .ch-grid span { left: -38px; width: 34px; }
}
@media print {
    .view-switch, .ch-more { display: none !important; }
    .ch-hbars.more::after, .ch-ranges.more::after { display: none; }
    .ch-hbars, .ch-ranges { max-height: none; overflow: visible; }
    .view-chart { break-inside: avoid; }
}
