html {
    -webkit-text-size-adjust: 100%;
    text-size-adjust: 100%;
}

body {
    overflow-x: hidden;
}

.tabular-nums,
#performanceTable td,
#performanceTable th {
    font-variant-numeric: tabular-nums;
}

#performanceTable {
    min-width: 1020px;
    border-collapse: separate;
    border-spacing: 0;
}

#performanceTable tbody tr {
    height: 46px;
}

#performanceTable thead tr:first-child {
    background: #b0005f !important;
}

#performanceTable thead tr:nth-child(2) {
    background: #e20074 !important;
}

#performanceTable thead th {
    border-right-color: rgba(255, 255, 255, 0.22) !important;
    box-shadow: none;
}

#performanceTable thead tr:first-child th {
    height: 34px;
    padding-top: 0.35rem !important;
    padding-bottom: 0.35rem !important;
    font-size: 0.62rem !important;
    line-height: 1.08 !important;
    letter-spacing: 0.025em !important;
}

#performanceTable thead tr:first-child th[rowspan] {
    height: 78px;
    vertical-align: middle;
}

#performanceTable thead tr:nth-child(2) th {
    height: 44px;
    padding-top: 0.3rem !important;
    padding-bottom: 0.3rem !important;
    font-size: 0.58rem !important;
    line-height: 1.08 !important;
    letter-spacing: 0.015em !important;
    vertical-align: middle;
}

#performanceTable thead tr:nth-child(2) th > div {
    white-space: nowrap;
}

#performanceTable .metric-weight-label {
    display: inline-flex;
    margin-left: 0.45rem;
    border-radius: 999px;
    padding: 0.14rem 0.4rem;
    background: rgba(255, 255, 255, 0.16);
    font-size: 0.52rem;
    font-weight: 700;
    letter-spacing: 0.04em;
    vertical-align: middle;
}

#performanceTable tbody tr:nth-child(even) td {
    background-color: #fafafa;
}

#performanceTable tbody td {
    border-right-color: #f0f0f0 !important;
}

#performanceTable tbody td:nth-child(3),
#performanceTable thead tr:first-child th:nth-child(3) {
    box-shadow: 5px 0 10px -9px rgba(15, 23, 42, 0.8);
}

#performanceTable .metric-value {
    display: inline-flex;
    min-width: 3.25rem;
    justify-content: flex-end;
    border-radius: 999px;
    padding: 0.18rem 0.38rem;
    font-weight: 700;
    line-height: 1.1;
}

#performanceTable .metric-good {
    color: #166534;
    background: #ecfdf3;
}

#performanceTable .metric-near {
    color: #92400e;
    background: #fffbeb;
}

#performanceTable .metric-focus {
    color: #b42318;
    background: #fff1f2;
}

#performanceTable .metric-neutral {
    color: #27272a;
    background: #f4f4f5;
}

#performanceTable .performance-row:hover td,
#performanceTable .performance-row:focus-visible td {
    background-color: #f9fafb;
}

#performanceTable .performance-row:focus-visible {
    outline: 2px solid #E20074;
    outline-offset: -2px;
}

#performanceTable .sticky-identity {
    box-shadow: 1px 0 0 #e5e7eb;
}

#matrixHint {
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
}

#storeMatrix {
    scrollbar-width: thin;
    scrollbar-color: #9ca3af #f3f4f6;
    scrollbar-gutter: stable;
    overscroll-behavior: contain;
    transition: box-shadow 160ms ease;
}

#storeMatrix[data-overflow="true"] {
    box-shadow: inset -18px 0 18px -22px rgba(15, 23, 42, 0.75);
}

#storeMatrix::-webkit-scrollbar {
    width: 9px;
    height: 9px;
}

#storeMatrix::-webkit-scrollbar-track {
    background: #f3f4f6;
}

#storeMatrix::-webkit-scrollbar-thumb {
    border: 2px solid #f3f4f6;
    border-radius: 999px;
    background: #9ca3af;
}

#dashboardViewport {
    min-height: 100vh;
}

#dashboardHeader {
    box-shadow: 0 8px 24px -18px rgba(15, 23, 42, 0.55) !important;
}

#dashboardHeader input:not([type="radio"]),
#dashboardHeader select,
#dashboardHeader button {
    min-height: 40px;
}

#dashboardContext fieldset,
#dashboardContext > div {
    box-shadow: none !important;
    border-color: #e4e4e7 !important;
    background: #fafafa !important;
}

#dashboardResults {
    border-top: 1px solid #f0f0f0;
    margin-top: 0.75rem !important;
    padding-top: 0.55rem;
}

@media (min-width: 1024px) {
    #dashboardViewport {
        padding-top: 1.5rem !important;
        padding-bottom: 1.5rem !important;
    }

    #topNav .py-4 {
        padding-top: 0.75rem !important;
        padding-bottom: 0.75rem !important;
    }

    #dashboardHeaderLayout {
        grid-template-areas:
            "title context"
            "toolbar toolbar";
        grid-template-columns: minmax(0, 1fr) auto !important;
        column-gap: 1.25rem !important;
        row-gap: 0.75rem !important;
    }

    #dashboardPrimary {
        display: contents;
    }

    #dashboardTitleBlock {
        grid-area: title;
        align-self: center;
    }

    #dashboardContext {
        grid-area: context;
    }

    #dashboardToolbar {
        grid-area: toolbar;
        width: 100%;
        padding-top: 0.75rem;
        border-top: 1px solid #e5e7eb;
        flex-wrap: nowrap !important;
    }

    #filtersPanel {
        flex: 1 1 auto;
        min-width: 0;
        flex-wrap: nowrap !important;
    }

    #filtersPanel > div {
        min-width: 0;
    }

    #filtersPanel > div:nth-child(1) { flex: 1 1 210px; }
    #filtersPanel > div:nth-child(2) { flex: 1 1 220px; }
    #filtersPanel > div:nth-child(3) { flex: 1.3 1 280px; }

    #filtersPanel input,
    #filtersPanel select {
        width: 100% !important;
    }

    #dashboardToolbar > button,
    #dashboardToolbar > .relative {
        flex: 0 0 auto;
    }
}

@media (min-width: 1024px) and (max-width: 1199px) {
    #dashboardToolbar {
        flex-wrap: wrap !important;
    }

    #filtersPanel {
        order: 3;
        flex-basis: 100%;
    }
}

:focus-visible {
    outline: 3px solid #E20074;
    outline-offset: 2px;
}

#storeCards {
    grid-template-columns: 1fr;
}

.mobile-store-card {
    font-family: "Inter", ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    min-width: 0;
    border-width: 1px !important;
    border-color: #e5e7eb !important;
    box-shadow: 0 1px 2px rgba(15, 23, 42, 0.06) !important;
}

.mobile-rank-grid {
    width: 8.25rem;
}

.mobile-rank-label {
    letter-spacing: 0;
}

.mobile-rank-value {
    font-size: clamp(0.88rem, 3.4vw, 1.08rem);
    letter-spacing: 0;
}

.modal-stat-card {
    min-height: 6.25rem;
}

.modal-stat-label,
.modal-metric-label {
    letter-spacing: 0;
}

.modal-stat-value {
    margin-top: 0.35rem;
}

.modal-stat-sub {
    margin-top: 0.25rem;
}

.modal-metric-card {
    min-height: 4.1rem;
}

#modalContent details > summary::-webkit-details-marker {
    display: none;
}

#modalContent details > summary {
    list-style: none;
}

#modalContent table th,
#modalContent table td {
    white-space: nowrap;
}

#modalContent {
    -webkit-overflow-scrolling: touch;
    touch-action: pan-y;
    scrollbar-gutter: stable;
    padding-bottom: max(5rem, env(safe-area-inset-bottom));
}

#storeDetailModal:not(.hidden) {
    display: flex;
}

#storeDetailModal > div {
    height: 90vh;
    height: min(90dvh, 900px);
}

#modalContent .overflow-x-auto {
    touch-action: pan-x pan-y;
}

@media (min-width: 1024px) {
    #storeDetailModal {
        padding: 1.25rem !important;
    }

    #storeDetailModal > div {
        min-width: 44rem;
        min-height: 32rem;
        max-width: calc(100vw - 2.5rem);
        max-height: calc(100dvh - 2.5rem);
        resize: both;
    }

    #storeDetailModal > div {
        width: min(92vw, 1000px) !important;
        height: min(76dvh, 680px) !important;
        max-height: 76dvh !important;
        border-radius: 0.9rem !important;
        box-shadow: 0 24px 60px -30px rgba(0, 0, 0, 0.65) !important;
    }

    #storeDetailModal > div > div:first-child {
        padding: 0.75rem 1rem !important;
        align-items: center !important;
    }

    #modalStoreName {
        font-size: 1.2rem !important;
        line-height: 1.2 !important;
    }

    #modalHeaderSubtitle,
    #modalHeaderMeta {
        margin-top: 0.3rem !important;
        font-size: 0.65rem !important;
        color: #d4d4d8 !important;
    }

    #modalTierBadge {
        padding: 0.35rem 0.7rem !important;
        border-radius: 999px !important;
        font-size: 0.65rem !important;
    }

    #storeDetailModal [data-export-coaching-summary],
    #storeDetailModal [data-export-store-detail] {
        min-height: 0 !important;
        border: 1px solid rgba(255, 255, 255, 0.34);
        border-radius: 999px;
        padding: 0.32rem 0.65rem;
        text-decoration: none !important;
        font-size: 0.68rem !important;
        line-height: 1;
        white-space: nowrap;
        background: rgba(255, 255, 255, 0.08);
    }

    #storeDetailModal [data-export-coaching-summary]:hover,
    #storeDetailModal [data-export-store-detail]:hover {
        background: rgba(255, 255, 255, 0.18);
    }

    #storeDetailModal [data-close-store-detail] {
        min-height: 0 !important;
        width: 1.8rem;
        height: 1.8rem;
        border-radius: 999px;
        font-size: 1.05rem !important;
        background: rgba(255, 255, 255, 0.08);
    }

    #modalContent {
        padding: 1rem !important;
        padding-bottom: 2rem !important;
        background: #fafafa;
    }

    #modalContent .modal-desktop-results {
        gap: 0.65rem;
    }

    #modalContent > div {
        row-gap: 0.8rem !important;
    }

    #modalContent .modal-ranking-summary,
    #modalContent .modal-productivity-summary {
        gap: 0 !important;
        overflow: hidden;
        border: 1px solid #e4e4e7;
        border-radius: 0.6rem;
        background: white;
    }

    #modalContent .modal-ranking-summary > div,
    #modalContent .modal-productivity-summary > div {
        padding: 0.35rem 0.45rem !important;
        border: 0 !important;
        border-right: 1px solid #ececf0 !important;
        border-radius: 0 !important;
        background: white !important;
        box-shadow: none !important;
    }

    #modalContent .modal-ranking-summary > div:last-child,
    #modalContent .modal-productivity-summary > div:last-child {
        border-right: 0 !important;
    }

    #modalContent .modal-ranking-summary > div > div:first-child,
    #modalContent .modal-productivity-summary > div > div:first-child {
        font-size: 0.56rem !important;
    }

    #modalContent .modal-ranking-summary > div > div:last-child,
    #modalContent .modal-productivity-summary > div > div:last-child {
        margin-top: 0.15rem !important;
        font-size: 0.9rem !important;
        line-height: 1.15 !important;
    }

    #modalContent .modal-desktop-results details,
    #modalContent .modal-desktop-results section {
        border-radius: 0.75rem;
        box-shadow: none;
        overflow: hidden;
    }

    #modalContent .modal-results-column {
        row-gap: 0.5rem !important;
    }

    #modalContent .modal-desktop-results summary {
        border-left-width: 0;
        color: white;
        padding-top: 0.42rem;
        padding-bottom: 0.42rem;
        padding-left: 0.75rem !important;
        padding-right: 0.75rem !important;
    }

    #modalContent .modal-desktop-results summary h5,
    #modalContent .modal-desktop-results summary span {
        color: white;
    }

    #modalContent .modal-desktop-results summary h5 {
        font-size: 0.78rem !important;
        letter-spacing: 0.01em;
    }

    #modalContent .modal-desktop-results summary > span {
        display: none;
    }

    #modalContent [data-modal-card] > summary {
        border-left-color: #e20074 !important;
        background: #e20074;
        color: white;
    }

    #modalContent [data-modal-card] > summary h5,
    #modalContent [data-modal-card] > summary p,
    #modalContent [data-modal-card] > summary span {
        color: white !important;
    }

    #modalContent .modal-desktop-results table thead tr {
        background: #e9e9e9;
    }

    #modalContent .modal-desktop-results table tbody tr:nth-child(odd) {
        background: #f7f7f7;
    }

    #modalContent .modal-desktop-results table th,
    #modalContent .modal-desktop-results table td {
        padding-top: 0.42rem;
        padding-bottom: 0.42rem;
        padding-left: 0.45rem !important;
        padding-right: 0.45rem !important;
        font-size: 0.68rem !important;
        overflow: hidden;
        text-overflow: ellipsis;
    }

    #modalContent .modal-mini-table-wrap {
        width: 100%;
        max-width: 100%;
        overflow-x: hidden !important;
    }

    #modalContent .modal-mini-table {
        width: 100% !important;
        min-width: 0 !important;
        table-layout: fixed;
    }

    #modalContent .modal-mini-table th,
    #modalContent .modal-mini-table td {
        min-width: 0 !important;
        padding-left: 0.45rem !important;
        padding-right: 0.45rem !important;
        overflow: hidden;
        text-overflow: ellipsis;
    }

    #modalContent .modal-mini-table-four th:first-child,
    #modalContent .modal-mini-table-four td:first-child {
        width: 34%;
    }

    #modalContent .modal-mini-table-four th:not(:first-child),
    #modalContent .modal-mini-table-four td:not(:first-child) {
        width: 22%;
    }

    #modalContent .modal-mini-table-five th:first-child,
    #modalContent .modal-mini-table-five td:first-child {
        width: 30%;
    }

    #modalContent .modal-mini-table-five th:not(:first-child),
    #modalContent .modal-mini-table-five td:not(:first-child) {
        width: 17.5%;
    }

    #modalContent .modal-mini-table .min-w-14 {
        min-width: 0 !important;
        max-width: 100%;
        padding-left: 0.35rem !important;
        padding-right: 0.35rem !important;
    }

    #modalContent .modal-desktop-results table th {
        font-size: 0.6rem !important;
        color: #71717a;
    }

    #modalContent h4 {
        margin-bottom: 0.35rem !important;
        font-size: 0.9rem !important;
    }
}

@media (max-width: 599px) {
    #storeDetailModal {
        align-items: stretch;
        overflow: hidden;
        padding: 0.5rem !important;
        padding-bottom: max(0.5rem, env(safe-area-inset-bottom)) !important;
    }

    #storeDetailModal > div {
        display: flex !important;
        height: calc(100vh - 1rem);
        height: calc(100dvh - 1rem);
        min-height: 0;
        max-height: calc(100dvh - 1rem) !important;
        overflow: hidden !important;
    }

    #storeDetailModal > div > div:first-child {
        position: relative;
        top: auto;
    }

    #modalContent {
        display: block;
        height: 100%;
        min-height: 0;
        overflow-x: hidden !important;
        overflow-y: auto !important;
        overscroll-behavior-y: contain;
        -webkit-overflow-scrolling: touch;
        touch-action: pan-y;
        padding-bottom: max(5rem, env(safe-area-inset-bottom)) !important;
    }

    #modalContent .modal-mini-table-wrap {
        overflow-x: hidden !important;
        touch-action: pan-y;
    }

    #modalContent .modal-mini-table {
        min-width: 0 !important;
        width: 100% !important;
        table-layout: fixed;
    }

    #modalContent .modal-mini-table th,
    #modalContent .modal-mini-table td {
        padding: 0.55rem 0.25rem !important;
        white-space: normal;
        overflow-wrap: anywhere;
        line-height: 1.15;
    }

    #modalContent .modal-mini-table th {
        font-size: 0.56rem !important;
    }

    #modalContent .modal-mini-table td {
        font-size: 0.68rem !important;
    }

    #modalContent .modal-mini-table td:first-child,
    #modalContent .modal-mini-table th:first-child {
        width: 29%;
        padding-left: 0.75rem !important;
        text-align: left;
    }

    #modalContent .modal-mini-table td:last-child,
    #modalContent .modal-mini-table th:last-child {
        padding-right: 0.5rem !important;
    }

    #modalContent .modal-mini-table .min-w-14 {
        min-width: 0 !important;
        width: 100%;
        padding-left: 0.2rem !important;
        padding-right: 0.2rem !important;
    }
}

@media (max-width: 899px) {
    #dashboardViewport {
        min-height: auto !important;
        height: auto !important;
        padding-top: 0.75rem !important;
        padding-bottom: 0.75rem !important;
    }

    #dashboardShell {
        padding-left: 0.5rem !important;
        padding-right: 0.5rem !important;
    }

    #topNav .py-4 {
        padding-top: 0.6rem !important;
        padding-bottom: 0.6rem !important;
    }

    #dashboardHeader .px-5 {
        padding-left: 0.75rem !important;
        padding-right: 0.75rem !important;
    }

    #dashboardHeader .py-3 {
        padding-top: 0.6rem !important;
        padding-bottom: 0.6rem !important;
    }

    #dashboardHeader h2 {
        font-size: 1.25rem !important;
        line-height: 1.2 !important;
    }

    #dashboardHeader p {
        line-height: 1.25 !important;
    }

    #monthFilter {
        width: 100%;
        min-width: 0 !important;
    }

    #monthFilterOptions label {
        align-items: flex-start;
    }

    #monthFilterOptions span {
        min-width: 0;
        line-height: 1.2;
    }

    #exportMenu {
        left: 0;
        right: 0;
        width: 100% !important;
    }

    #tableCard {
        overflow: visible;
    }

    #storeCards {
        gap: 0.65rem !important;
        padding: 0.65rem !important;
        min-height: 0 !important;
    }

    #storeMatrix[style*="display: none"] {
        max-height: 0 !important;
        overflow: hidden !important;
    }

    .mobile-store-card {
        border-radius: 0.5rem !important;
        padding-top: 0.625rem !important;
        padding-bottom: 0.625rem !important;
    }

    #appFooter {
        margin-top: 1rem !important;
        padding-top: 1rem !important;
        padding-bottom: 1rem !important;
    }
}

@media (min-width: 600px) and (max-width: 899px) {
    #performanceTable {
        width: 100%;
        min-width: 0;
        table-layout: fixed;
    }

    #performanceTable th,
    #performanceTable td {
        min-width: 0 !important;
        padding-left: 0.2rem !important;
        padding-right: 0.2rem !important;
        overflow: hidden;
    }

    #performanceTable tbody tr {
        height: 40px;
    }

    /* Fold/tablet fit-to-width layout. The identity columns stay useful while
       all nine metrics share the remaining space without horizontal swiping. */
    #performanceTable thead tr:first-child th:nth-child(1),
    #performanceTable tbody td:nth-child(1) {
        width: 43px !important;
        left: 0 !important;
    }

    #performanceTable thead tr:first-child th:nth-child(2),
    #performanceTable tbody td:nth-child(2) {
        width: 40px !important;
        left: 43px !important;
    }

    #performanceTable thead tr:first-child th:nth-child(3),
    #performanceTable tbody td:nth-child(3) {
        width: 120px !important;
        left: 83px !important;
    }

    #performanceTable thead tr:first-child th:nth-child(4),
    #performanceTable tbody td:nth-child(4) {
        width: 44px !important;
    }

    #performanceTable thead tr:first-child th:nth-child(5) {
        width: auto !important;
    }

    #performanceTable thead tr:nth-child(2) th,
    #performanceTable tbody td:nth-child(n+5) {
        width: calc((100% - 247px) / 9) !important;
    }

    #performanceTable thead th {
        font-size: 0.48rem !important;
        letter-spacing: 0 !important;
        line-height: 1.05 !important;
        white-space: normal;
        overflow-wrap: anywhere;
    }

    #performanceTable tbody td,
    #performanceTable tbody td span,
    #performanceTable tbody .sme-name-text {
        font-size: 0.55rem !important;
        letter-spacing: -0.01em;
    }

    #performanceTable tbody td:nth-child(n+4) {
        text-align: center !important;
        white-space: nowrap;
    }

    #performanceTable .metric-value {
        min-width: 0;
        max-width: 100%;
        padding: 0.14rem 0.18rem;
        justify-content: center;
        border-radius: 0.3rem;
    }

    #performanceTable .rank-badge {
        width: 0.72rem !important;
        height: 0.72rem !important;
        flex: 0 0 0.72rem;
        font-size: 0.42rem !important;
    }

    #performanceTable tbody td:first-child > div {
        gap: 0.15rem !important;
    }

    #storeMatrix {
        overflow-x: hidden;
    }

    #matrixHint {
        font-size: 0.68rem !important;
    }
}

@media (min-width: 900px) {
    #performanceTable {
        width: 100%;
        min-width: 0;
        table-layout: fixed;
    }

    #performanceTable thead tr:first-child th:nth-child(1),
    #performanceTable tbody td:nth-child(1) {
        width: 6% !important;
        left: 0 !important;
    }

    #performanceTable thead tr:first-child th:nth-child(2),
    #performanceTable tbody td:nth-child(2) {
        width: 6% !important;
        left: 6% !important;
    }

    #performanceTable thead tr:first-child th:nth-child(3),
    #performanceTable tbody td:nth-child(3) {
        width: 22% !important;
        left: 12% !important;
    }

    #performanceTable thead tr:first-child th:nth-child(4),
    #performanceTable tbody td:nth-child(4) {
        width: 6% !important;
    }

    #performanceTable thead tr:first-child th:nth-child(5) {
        width: 60% !important;
    }

    #performanceTable thead tr:nth-child(2) th,
    #performanceTable tbody td:nth-child(n+5) {
        width: 6.6667% !important;
        min-width: 0 !important;
    }

    #performanceTable th,
    #performanceTable td {
        min-width: 0 !important;
        overflow: hidden;
    }

    #performanceTable thead th {
        white-space: normal;
        overflow-wrap: anywhere;
    }

    #performanceTable tbody td:nth-child(n+4) {
        white-space: nowrap;
    }

    #performanceTable .metric-value {
        min-width: 0;
        max-width: 100%;
    }

    #storeMatrix {
        overflow-x: hidden;
    }
}

@media (max-width: 599px) {
    .metric-key {
        display: none !important;
    }
}

@media (max-width: 640px) {
    .modal-stat-card {
        min-height: 6.75rem;
        display: flex;
        flex-direction: column;
        justify-content: center;
    }

    .modal-stat-value {
        font-size: 2rem !important;
        line-height: 0.95 !important;
    }

    .modal-stat-tier,
    .modal-stat-productivity {
        font-size: 1.45rem !important;
        line-height: 1.05 !important;
        margin-top: 0.35rem;
    }

    .modal-stat-label {
        font-size: 0.72rem !important;
    }

    .modal-stat-sub {
        font-size: 0.78rem !important;
    }

    .modal-metric-card {
        min-height: 4.5rem;
        padding-top: 0.625rem !important;
        padding-bottom: 0.625rem !important;
    }

    .modal-metric-target {
        font-size: 1.2rem !important;
        line-height: 1 !important;
    }

    .modal-metric-detail-grid {
        align-items: end;
    }

    .modal-metric-detail-value {
        font-size: 0.95rem !important;
        line-height: 1.1 !important;
    }
}

@media (max-width: 380px) {
    .modal-metric-card {
        padding-top: 0.55rem !important;
        padding-bottom: 0.55rem !important;
    }
}

@media (min-width: 600px) {
    #storeCards {
        display: none !important;
    }

    #storeMatrix {
        display: block;
        max-height: 75vh;
        overflow: auto;
    }
}

@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation: none !important;
        transition: none !important;
        scroll-behavior: auto !important;
    }
}
