/* Excel A1 axes beside a table scrollport. Column letters scroll on X only;
   row numbers scroll on Y only. Frozen panes keep their ticks put. */

.ascent-pivot-drop-zones > .ascent-pivot-dz-table-area.ascent-excel-sheet-chrome,
.ascent-pivot-dz-table-area.ascent-excel-sheet-chrome {
    --ascent-excel-gutter-width: 2rem;
    --ascent-excel-letter-height: 1.15rem;
    --ascent-excel-axis-bg: var(--aaem-header, var(--ascent-table-header-bg, color-mix(in srgb, var(--ascent-brand-blue, var(--color-brand-blue, #1078be)) 6%, var(--ascent-card-bg, var(--color-card-bg)))));
    --ascent-excel-axis-text: var(--aaem-muted, var(--ascent-text-muted, var(--color-text-muted)));
    --ascent-excel-axis-line: var(--aaem-grid, var(--ascent-table-border, var(--ascent-card-border, var(--color-card-border))));
    /* !important: scoped drop-zone / analysis-panel rules set display:flex on this node. */
    display: grid !important;
    grid-template-columns: var(--ascent-excel-gutter-width) minmax(0, 1fr);
    grid-template-rows: var(--ascent-excel-letter-height) minmax(0, 1fr);
    align-items: stretch;
    padding: 0;
}

.ascent-excel-sheet-chrome__corner {
    grid-column: 1;
    grid-row: 1;
    z-index: 4;
    box-sizing: border-box;
    border-right: 1px solid var(--ascent-excel-axis-line);
    border-bottom: 1px solid var(--ascent-excel-axis-line);
    background: var(--ascent-excel-axis-bg);
}

.ascent-excel-sheet-chrome__cols {
    grid-column: 2;
    grid-row: 1;
    z-index: 3;
    display: flex;
    min-width: 0;
    overflow: hidden;
    background: var(--ascent-excel-axis-bg);
    border-bottom: 1px solid var(--ascent-excel-axis-line);
}

.ascent-excel-sheet-chrome__cols-frozen,
.ascent-excel-sheet-chrome__cols-strip {
    display: flex;
    flex: 0 0 auto;
    height: 100%;
}

.ascent-excel-sheet-chrome__cols-frozen {
    z-index: 1;
    background: var(--ascent-excel-axis-bg);
    box-shadow: 1px 0 0 var(--ascent-excel-axis-line);
}

.ascent-excel-sheet-chrome__cols-scroll {
    flex: 1 1 auto;
    min-width: 0;
    overflow: hidden;
}

.ascent-excel-sheet-chrome__cols-strip,
.ascent-excel-sheet-chrome__rows-strip {
    will-change: transform;
}

.ascent-excel-sheet-chrome__col-letter,
.ascent-excel-sheet-chrome__row-number {
    box-sizing: border-box;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    font-size: 0.6rem;
    font-variant-numeric: tabular-nums;
    line-height: 1;
    color: var(--ascent-excel-axis-text);
    user-select: none;
    cursor: pointer;
}

.ascent-excel-sheet-chrome__col-letter {
    position: relative;
    overflow: visible;
    border-right: 1px solid var(--ascent-excel-axis-line);
}

.ascent-excel-sheet-chrome__col-resize {
    position: absolute;
    top: 0;
    right: 0;
    z-index: 2;
    width: 8px;
    height: 100%;
    cursor: col-resize;
    touch-action: none;
}

.ascent-excel-sheet-chrome__col-resize::after {
    content: '';
    position: absolute;
    top: 0;
    bottom: 0;
    left: auto;
    right: -1px;
    width: 2px;
    transform: none;
    background: transparent;
}

.ascent-excel-sheet-chrome__col-resize:hover::after,
.ascent-excel-sheet-chrome__col-resize.is-active::after {
    background: var(--aaem-accent, var(--ascent-brand-blue, #1078be));
}

.ascent-excel-sheet-chrome__rows {
    grid-column: 1;
    grid-row: 2;
    z-index: 3;
    display: flex;
    flex-direction: column;
    min-height: 0;
    overflow: hidden;
    background: var(--ascent-excel-axis-bg);
    border-right: 1px solid var(--ascent-excel-axis-line);
}

.ascent-excel-sheet-chrome__rows-frozen,
.ascent-excel-sheet-chrome__rows-strip,
.ascent-excel-sheet-chrome__rows-footer {
    display: flex;
    flex-direction: column;
    flex: 0 0 auto;
    width: 100%;
}

.ascent-excel-sheet-chrome__rows-frozen {
    z-index: 1;
    background: var(--ascent-excel-axis-bg);
    box-shadow: 0 1px 0 var(--ascent-excel-axis-line);
}

.ascent-excel-sheet-chrome__rows-footer {
    z-index: 1;
    background: var(--ascent-excel-axis-bg);
    box-shadow: 0 -1px 0 var(--ascent-excel-axis-line);
}

.ascent-excel-sheet-chrome__rows-scroll {
    flex: 1 1 auto;
    min-height: 0;
    overflow: hidden;
}

.ascent-excel-sheet-chrome__row-number {
    border-bottom: 1px solid var(--ascent-excel-axis-line);
}

.ascent-excel-sheet-chrome__col-letter.is-active,
.ascent-excel-sheet-chrome__row-number.is-active {
    background: color-mix(in srgb, var(--aaem-accent, var(--ascent-brand-blue, #1078be)) 18%, var(--ascent-excel-axis-bg));
    color: var(--aaem-accent, var(--ascent-brand-blue, #1078be));
    font-weight: 700;
}

/* Name box + fx + value, matching collection templates. */
.aaem-excel__formula-bar[data-ascent-excel-formula-bar] {
    display: flex;
    align-items: center;
    gap: 6px;
    height: 1.5rem;
    min-height: 1.5rem;
    padding: 0 0.35rem;
    background: var(--aaem-surface, var(--ascent-card-bg, #fff));
    border-bottom: 1px solid var(--aaem-border, var(--ascent-card-border));
    font-size: 0.7rem;
    color: var(--aaem-text, var(--ascent-text-primary, #2f546a));
    flex: 0 0 auto;
}

.aaem-excel__formula-bar[data-ascent-excel-formula-bar] .aaem-excel__name-box {
    flex: 0 0 auto;
    min-width: 4.5rem;
    padding: 2px 6px;
    border: 1px solid var(--aaem-border, var(--ascent-card-border));
    border-radius: 2px;
    background: var(--aaem-surface, var(--ascent-card-bg, #fff));
    text-align: left;
    font-variant-numeric: tabular-nums;
}

.aaem-excel__formula-bar[data-ascent-excel-formula-bar] .aaem-excel__fx {
    flex: 0 0 auto;
    padding: 0 4px;
    font-style: italic;
    font-weight: 600;
}

.aaem-excel__formula-bar[data-ascent-excel-formula-bar] .aaem-excel__formula {
    flex: 1 1 auto;
    min-width: 0;
    padding: 2px 6px;
    border: 1px solid var(--aaem-border, var(--ascent-card-border));
    border-radius: 2px;
    color: var(--aaem-text, var(--ascent-text-primary, #2f546a));
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.ascent-excel-sheet-chrome table.pvtTable th,
.ascent-excel-sheet-chrome table.pvtTable td,
.ascent-excel-sheet-chrome table.ascent-pivot-data-table th,
.ascent-excel-sheet-chrome table.ascent-pivot-data-table td,
.ascent-excel-sheet-chrome table.ascent-template-sheet__grid th,
.ascent-excel-sheet-chrome table.ascent-template-sheet__grid td,
.ascent-report-paper table.pvtTable th,
.ascent-report-paper table.pvtTable td,
.ascent-pivot-table-shell--report-output table.pvtTable th,
.ascent-pivot-table-shell--report-output table.pvtTable td {
    cursor: cell;
}

.ascent-pivot-dz-table-area.ascent-excel-sheet-chrome > .ascent-pivot-table-scroll,
.ascent-report-paper .ascent-pivot-table-scroll,
.ascent-pivot-table-shell--report-output .ascent-pivot-table-scroll {
    position: relative;
}

.ascent-excel-sheet-chrome__selection {
    position: absolute;
    box-sizing: border-box;
    border: 2px solid var(--aaem-accent, var(--ascent-brand-blue, #1078be));
    pointer-events: none;
    z-index: 6;
    display: none;
}

.ascent-excel-sheet-chrome table.pvtTable th.is-excel-active,
.ascent-excel-sheet-chrome table.pvtTable td.is-excel-active,
.ascent-excel-sheet-chrome table.ascent-pivot-data-table th.is-excel-active,
.ascent-excel-sheet-chrome table.ascent-pivot-data-table td.is-excel-active,
.ascent-excel-sheet-chrome table.ascent-template-sheet__grid th.is-excel-active,
.ascent-excel-sheet-chrome table.ascent-template-sheet__grid td.is-excel-active,
.ascent-report-paper table.pvtTable th.is-excel-active,
.ascent-report-paper table.pvtTable td.is-excel-active,
.ascent-pivot-table-shell--report-output table.pvtTable th.is-excel-active,
.ascent-pivot-table-shell--report-output table.pvtTable td.is-excel-active {
    outline: none;
}

.is-exporting .ascent-excel-sheet-chrome__selection {
    display: none !important;
}

.ascent-pivot-drop-zones > .ascent-pivot-dz-table-area.ascent-excel-sheet-chrome > .ascent-pivot-table-scroll,
.ascent-pivot-dz-table-area.ascent-excel-sheet-chrome > .ascent-pivot-table-scroll {
    grid-column: 2;
    grid-row: 2;
    min-width: 0;
    min-height: 0;
    width: auto;
    max-width: none;
    align-self: stretch;
}

/* Values stay inside the A1 cell they belong to — interactive analysis only.
   Paginated paper / report output must not clip wrapping labels. */
.ascent-excel-sheet-chrome > .ascent-pivot-table-scroll table.pvtTable th,
.ascent-excel-sheet-chrome > .ascent-pivot-table-scroll table.pvtTable td,
.ascent-excel-sheet-chrome > .ascent-pivot-table-scroll table.ascent-pivot-data-table th,
.ascent-excel-sheet-chrome > .ascent-pivot-table-scroll table.ascent-pivot-data-table td {
    box-sizing: border-box;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.ascent-excel-sheet-chrome > .ascent-pivot-table-scroll table.pvtTable th:not([rowspan]),
.ascent-excel-sheet-chrome > .ascent-pivot-table-scroll table.pvtTable th[rowspan="1"],
.ascent-excel-sheet-chrome > .ascent-pivot-table-scroll table.pvtTable td:not([rowspan]),
.ascent-excel-sheet-chrome > .ascent-pivot-table-scroll table.pvtTable td[rowspan="1"],
.ascent-excel-sheet-chrome > .ascent-pivot-table-scroll table.ascent-pivot-data-table th:not([rowspan]),
.ascent-excel-sheet-chrome > .ascent-pivot-table-scroll table.ascent-pivot-data-table th[rowspan="1"],
.ascent-excel-sheet-chrome > .ascent-pivot-table-scroll table.ascent-pivot-data-table td:not([rowspan]),
.ascent-excel-sheet-chrome > .ascent-pivot-table-scroll table.ascent-pivot-data-table td[rowspan="1"] {
    height: var(--aaem-row-height, 2rem);
    max-height: var(--aaem-row-height, 2rem);
}

.ascent-pivot-table-shell--report-output .ascent-excel-sheet-chrome__corner,
.ascent-pivot-table-shell--report-output .ascent-excel-sheet-chrome__cols,
.ascent-pivot-table-shell--report-output .ascent-excel-sheet-chrome__rows,
.ascent-report-paper .ascent-excel-sheet-chrome__corner,
.ascent-report-paper .ascent-excel-sheet-chrome__cols,
.ascent-report-paper .ascent-excel-sheet-chrome__rows {
    display: none;
}

.ascent-pivot-table-shell--report-output .ascent-pivot-dz-table-area.ascent-excel-sheet-chrome,
.ascent-report-paper .ascent-pivot-dz-table-area.ascent-excel-sheet-chrome {
    display: flex !important;
    grid-template-columns: none;
    grid-template-rows: none;
}

/* Domain Analysis + Report Studio hide the field builder. Keep A, B, C flush
   under the formula bar like data-request templates (no reserved 12px row). */
.aaem-analysis-panel .ascent-dashboard-analysis-panel__pivot .ascent-pivot-drop-zones,
.aaem-analysis-panel .ascent-pivot-drop-zones {
    gap: 0;
    grid-template-rows: minmax(0, 1fr);
}

.aaem-analysis-panel .ascent-dashboard-analysis-panel__pivot .ascent-pivot-table-shell:not(.ascent-pivot-table-shell--report-output) .ascent-pivot-dz-table-area,
.aaem-analysis-panel .ascent-pivot-table-shell:not(.ascent-pivot-table-shell--report-output) .ascent-pivot-dz-table-area {
    grid-row: 1;
    padding: 0;
}

.aaem-analysis-panel,
.ascent-pivot-dz-table-area.ascent-excel-sheet-chrome {
    --ascent-pivot-radius: 0;
}

.aaem-analysis-panel .ascent-pivot-table-shell,
.aaem-analysis-panel .ascent-pivot-dz-table-area,
.ascent-pivot-dz-table-area.ascent-excel-sheet-chrome {
    border-radius: 0;
}

.aaem-analysis-panel .ascent-pivot-drop-zones > .ascent-pivot-dz-table-area > .ascent-pivot-table-scroll,
.ascent-pivot-dz-table-area.ascent-excel-sheet-chrome > .ascent-pivot-table-scroll {
    border-radius: 0;
    box-shadow: none;
}

/* Square cells so header/row-label fill reaches the gridline — no clipped
   top-left / bottom-left corners from the scrollport radius. */
.ascent-excel-sheet-chrome__corner,
.ascent-excel-sheet-chrome__col-letter,
.ascent-excel-sheet-chrome__row-number,
.ascent-excel-sheet-chrome table.pvtTable th,
.ascent-excel-sheet-chrome table.pvtTable td,
.ascent-excel-sheet-chrome table.ascent-pivot-data-table th,
.ascent-excel-sheet-chrome table.ascent-pivot-data-table td,
.aaem-analysis-panel table.pvtTable th,
.aaem-analysis-panel table.pvtTable td {
    border-radius: 0;
}
