/*
 * MetaPulse experience layer
 * Shared across every workspace after the page-specific stylesheet. It adds the
 * softer dimensional glass/clay finish, fixes narrow-screen visibility, and
 * supplies hooks for the progressive motion helpers in motion.js.
 */
:root {
    --mp-glass: rgba(255, 255, 255, .72);
    --mp-glass-strong: rgba(252, 253, 251, .9);
    --mp-glass-line: rgba(255, 255, 255, .86);
    --mp-ink: #1b2a25;
    --mp-soft-ink: #63726b;
    --mp-accent: #315d53;
    --mp-accent-2: #78a597;
    --mp-warm: #e3af6e;
    --mp-card-shadow: 0 20px 45px rgba(54, 72, 63, .085), 0 3px 10px rgba(54, 72, 63, .045);
}

html { background: #edf1ed; }
body {
    min-height: 100vh;
    background:
        radial-gradient(circle at var(--mp-pointer-x, 82%) var(--mp-pointer-y, 7%), rgba(189, 219, 207, .72), transparent 30rem),
        radial-gradient(circle at 16% 52%, rgba(218, 229, 241, .46), transparent 26rem),
        radial-gradient(circle at 74% 104%, rgba(242, 214, 181, .48), transparent 30rem),
        #edf1ed;
    background-attachment: fixed;
}
body::after {
    content: '';
    position: fixed;
    z-index: -1;
    inset: 0;
    pointer-events: none;
    opacity: .7;
    background:
        radial-gradient(circle at 12% 16%, rgba(255,255,255,.78) 0 2px, transparent 3px),
        radial-gradient(circle at 86% 72%, rgba(255,255,255,.66) 0 3px, transparent 4px);
    background-size: 94px 94px, 138px 138px;
    mask-image: linear-gradient(to bottom, #000, transparent 82%);
}

/* A fine top progress line makes long analytics pages feel locatable. */
.mp-scroll-progress {
    position: fixed;
    z-index: 200;
    inset: 0 auto auto 0;
    width: 100%;
    height: 3px;
    pointer-events: none;
    transform: scaleX(0);
    transform-origin: left center;
    background: linear-gradient(90deg, #315d53, #83b19f 68%, #e0a962);
    box-shadow: 0 2px 10px rgba(49,93,83,.2);
}

.sidebar {
    border-right-color: rgba(255,255,255,.84);
    background: linear-gradient(160deg, rgba(252,253,251,.9), rgba(243,247,244,.76));
    box-shadow: 14px 0 44px rgba(54,72,63,.055);
}
.brand-mark {
    position: relative;
    overflow: hidden;
    background: linear-gradient(145deg, #274f45, #47796c 70%, #759f93);
    box-shadow: 0 12px 24px rgba(49,93,83,.22), inset 0 1px 1px rgba(255,255,255,.3);
}
.brand-mark::after {
    content: '';
    position: absolute;
    inset: -45% 32% -45% -45%;
    transform: rotate(24deg);
    background: linear-gradient(90deg, transparent, rgba(255,255,255,.22), transparent);
    animation: mp-brand-sheen 7s ease-in-out infinite;
}
@keyframes mp-brand-sheen { 0%, 62% { transform: translateX(-130%) rotate(24deg); } 84%, 100% { transform: translateX(320%) rotate(24deg); } }
.nav-item { position: relative; overflow: hidden; }
.nav-item::after {
    content: '';
    position: absolute;
    left: 8px;
    top: 50%;
    width: 3px;
    height: 0;
    transform: translateY(-50%);
    border-radius: 99px;
    background: #416f65;
    transition: height .22s var(--mp-ease-out);
}
.nav-item.active::after { height: 20px; }
.nav-item.active { padding-left: 15px; }
.api-status-card { backdrop-filter: blur(18px) saturate(130%); -webkit-backdrop-filter: blur(18px) saturate(130%); }

.topbar {
    position: sticky;
    z-index: 60;
    top: 0;
    padding-top: 3px;
    background: linear-gradient(180deg, rgba(239,243,239,.9), rgba(239,243,239,.7) 72%, transparent);
    backdrop-filter: blur(16px) saturate(120%);
    -webkit-backdrop-filter: blur(16px) saturate(120%);
}
.topbar h1 { text-wrap: balance; }
.topbar-actions { flex: none; }
.live-pill { backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px); }
.icon-button, .mobile-menu, .account-avatar { flex: none; }

.filter-bar,
.panel,
.kpi-card,
.summary-item,
.region-stat,
.city-stat,
.podium,
.client-card,
.admin-card,
.sync-card,
.admin-summary .stat {
    border-color: var(--mp-glass-line);
    box-shadow: inset 0 0 0 1px rgba(37,56,48,.055), var(--mp-card-shadow);
    backdrop-filter: blur(24px) saturate(132%);
    -webkit-backdrop-filter: blur(24px) saturate(132%);
}
.panel,
.kpi-card,
.region-stat,
.city-stat,
.summary-item {
    background: linear-gradient(145deg, rgba(255,255,255,.88), rgba(246,250,247,.68));
}
.panel { overflow: clip; }
.pivot-panel,
.monthly-panel,
.campaign-panel,
.traffic-pivot,
.region-pivot,
.lb-panel { overflow: hidden; }
.panel-head h2, .pivot-brand h2 { text-wrap: balance; }

.filter-control select,
.filter-control input,
.date-range-button,
.compact-select select,
.lb-search,
.pivot-search,
.region-search,
.sync-fields input,
.sync-fields select,
.dialog-field input,
.dialog-field select,
.dialog-field textarea {
    border-color: rgba(44,67,57,.1);
    background: rgba(250,252,249,.88);
    box-shadow: inset 0 1px 2px rgba(37,55,47,.025), 0 1px 0 rgba(255,255,255,.75);
}
.filter-control > span,
.compact-select,
.monthly-meta,
.monthly-meta span { color: #76847d; }
.primary-button {
    border-color: #315d53;
    background: linear-gradient(140deg, #284f46, #47786b);
    box-shadow: 0 10px 22px rgba(49,93,83,.2), inset 0 1px 0 rgba(255,255,255,.18);
}
.secondary-button { background: rgba(255,255,255,.74); box-shadow: 0 6px 16px rgba(54,72,63,.05); }

/* The screenshot showed these labels disappearing into the coloured audience bar. */
.pivot-head .monthly-meta,
.pivot-head .monthly-meta span { color: rgba(255,255,255,.72); }
.pivot-head .monthly-meta strong { color: #fff; }
.pivot-head .compact-select { color: rgba(255,255,255,.74); }
.pivot-head .secondary-button {
    color: #315d53;
    background: rgba(255,255,255,.88);
    border-color: rgba(255,255,255,.42);
}
.pivot-head .secondary-button:hover { background: #fff; }

/* Wide reports remain full fidelity, with an explicit small-screen affordance. */
.pivot-wrap,
.table-wrap,
.lb-table-wrap {
    overscroll-behavior-inline: contain;
    scroll-behavior: smooth;
    scrollbar-gutter: stable;
}
.mp-scroll-hint {
    display: none;
    width: 100%;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 9px 14px;
    color: #5c7067;
    background: rgba(232,240,235,.86);
    border: 0;
    border-top: 1px solid rgba(65,111,101,.08);
    text-align: left;
    font-size: 10px;
    font-weight: 720;
    letter-spacing: .2px;
}
.mp-scroll-hint::after { content: '→'; font-size: 16px; transition: transform .2s; }
.mp-scroll-hint.is-end::after { content: '✓'; }
.mp-scroll-hint:not(.is-end):hover::after { transform: translateX(3px); }

/* Do not let long sticky labels paint over numeric cells. */
.region-table td.region-name {
    overflow: hidden;
    white-space: normal;
    overflow-wrap: anywhere;
    line-height: 1.3;
}
.region-table td.region-name small { white-space: nowrap; }
.traffic-table tbody td.page-cell,
.pivot-table tbody td.pivot-date,
.monthly-table td:first-child { overflow: hidden; text-overflow: ellipsis; }

/* Progressive motion. Content is always visible before and without JavaScript. */
.mp-scroll-reveal.mp-inview { animation: mp-reveal-soft .56s var(--mp-ease-out); }
@keyframes mp-reveal-soft {
    from { opacity: .15; transform: translate3d(0, 16px, 0) scale(.992); filter: blur(2px); }
    to { opacity: 1; transform: none; filter: none; }
}
.panel,
.region-stat,
.city-stat,
.summary-item,
.podium,
.client-card,
.admin-card,
.sync-card,
.admin-summary .stat {
    transition: transform .24s var(--mp-ease), box-shadow .24s var(--mp-ease), border-color .24s var(--mp-ease);
}
.panel:not(.pivot-panel):not(.monthly-panel):not(.campaign-panel):not(.lb-panel):hover,
.region-stat:hover,
.city-stat:hover,
.summary-item:hover,
.podium:hover,
.client-card:hover,
.admin-card:hover,
.sync-card:hover,
.admin-summary .stat:hover {
    transform: translate3d(0, -3px, 0);
    border-color: rgba(119,162,146,.32);
    box-shadow: inset 0 0 0 1px rgba(255,255,255,.62), 0 24px 50px rgba(54,72,63,.12);
}
.region-stat::after, .kpi-card::after { transition: transform .45s var(--mp-ease), opacity .3s; }
.region-stat:hover::after, .kpi-card:hover::after { transform: scale(1.18); opacity: .14; }
.chart-wrap canvas,
.traffic-chart-wrap canvas,
.region-chart-wrap canvas,
.city-chart-wrap canvas { animation: mp-chart-arrive .72s var(--mp-ease-out); }
@keyframes mp-chart-arrive { from { opacity: 0; transform: translateY(7px); } to { opacity: 1; transform: none; } }

.mp-sidebar-scrim {
    position: fixed;
    z-index: 19;
    inset: 0;
    visibility: hidden;
    opacity: 0;
    pointer-events: none;
    background: rgba(34,47,41,.24);
    backdrop-filter: blur(3px);
    transition: opacity .22s, visibility .22s;
}

@media (max-width: 980px) {
    .mp-sidebar-scrim.show { visibility: visible; opacity: 1; pointer-events: auto; }
    .sidebar { z-index: 80; }
    .main-content { width: 100%; }
    .mp-scroll-hint { display: flex; }
}

@media (max-width: 760px) {
    .topbar { min-height: 78px; }
    .topbar > div:nth-child(2) { min-width: 0; }
    .topbar h1 { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
    .filter-bar { gap: 9px; }
    .pivot-head,
    .traffic-pivot .pivot-head,
    .region-pivot .pivot-head {
        align-items: stretch;
        flex-direction: column;
    }
    .pivot-head .monthly-tools,
    .pivot-tools,
    .region-tools {
        width: 100%;
        justify-content: flex-start;
    }
    .pivot-head .monthly-meta { justify-items: start; flex: 1 1 100%; }
    .pivot-brand { min-width: 0; }
    .pivot-brand h2 { overflow: hidden; text-overflow: ellipsis; }
    .monthly-tools .secondary-button { flex: 0 0 auto; }

    .region-table .region-corner,
    .region-table td.region-name {
        min-width: 158px;
        width: 158px;
        max-width: 158px;
    }
    .region-table th, .region-table td { min-width: 94px; padding: 10px 9px; }
    .region-table .region-group { min-width: 376px; }
    .region-table .region-grand td { position: static; }
    .region-table .region-grand td.region-name { position: sticky; left: 0; z-index: 8; }
    .traffic-table thead th.pivot-corner,
    .traffic-table tbody td.page-cell { min-width: 178px; max-width: 178px; }
    .monthly-table th:first-child,
    .monthly-table td:first-child { min-width: 88px; max-width: 88px; }
    .pivot-table tbody td.pivot-date,
    .pivot-table tfoot td.pivot-date { min-width: 108px; max-width: 108px; }
}

@media (max-width: 520px) {
    body { background-attachment: scroll; }
    .main-content { padding-inline: 10px; }
    .filter-bar { padding: 11px; border-radius: 17px; }
    .filter-control select, .filter-control input, .date-range-button { min-height: 46px; }
    .panel, .region-stat, .city-stat, .summary-item { border-radius: 19px; }
    .panel { padding: 15px; }
    .pivot-panel, .monthly-panel, .traffic-pivot, .region-pivot, .lb-panel { padding: 0; }
    .pivot-head, .traffic-pivot .pivot-head, .region-pivot .pivot-head { padding: 15px; }
    .region-tools > *, .pivot-tools > * { min-height: 40px; }
    .region-search, .pivot-search { width: 100%; flex-basis: 100%; }
    .monthly-tools { display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: end; }
    .monthly-meta { grid-column: 1 / -1; }
    .monthly-tools .compact-select select { min-height: 40px; }
    .region-method { gap: 9px 14px; }
    .dashboard-footer { padding-bottom: env(safe-area-inset-bottom); }
}

@media (prefers-reduced-motion: reduce) {
    .brand-mark::after,
    .mp-scroll-reveal.mp-inview,
    .chart-wrap canvas,
    .traffic-chart-wrap canvas,
    .region-chart-wrap canvas,
    .city-chart-wrap canvas { animation: none !important; }
    .mp-scroll-progress { display: none; }
}
