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 .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;
}

: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) {
    #modalContent {
        padding-top: 1rem;
    }

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

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

    #modalContent .modal-desktop-results summary {
        border-left-width: 0;
        color: white;
        padding-top: 0.55rem;
        padding-bottom: 0.55rem;
    }

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

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

    #modalContent [data-modal-card="growth-desktop"] > summary { background: #16a34a; }
    #modalContent [data-modal-card="revenue"] > summary { background: #db2777; }
    #modalContent [data-modal-card="clb"] > summary { background: #d99f00; }
    #modalContent [data-modal-card="existing"] > summary { background: #7c3aed; }
    #modalContent [data-modal-card="t-life"] > summary { background: #2563eb; }
    #modalContent [data-modal-card="welcome"] > summary { background: #0891b2; }

    #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.65rem;
        padding-bottom: 0.65rem;
    }
}

@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 {
        min-width: 960px;
    }

    #performanceTable th,
    #performanceTable td {
        padding-left: 0.4rem !important;
        padding-right: 0.4rem !important;
    }

    #performanceTable tbody tr {
        height: 42px;
    }

    #matrixHint {
        font-size: 0.68rem !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;
    }
}
