/* Site analytics tab (admin portal). Uses the admin plane's tokens. */

.sa-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 1rem; flex-wrap: wrap; margin-bottom: 1.1rem; }
.sa-head h1 { font-family: var(--font-cond); font-size: 2rem; font-weight: 600; color: var(--white); line-height: 1.1; }
.sa-head .page-sub { display: flex; align-items: center; gap: 0.5rem; flex-wrap: wrap; }
.sa-controls { display: flex; align-items: center; gap: 0.5rem; flex-wrap: wrap; }

.sa-live { display: inline-flex; align-items: center; gap: 0.5rem; padding: 0.4rem 0.8rem; border-radius: 999px; border: 1px solid rgba(104,211,145,0.35); background: rgba(104,211,145,0.08); color: var(--white); font-size: 0.88rem; font-weight: 500; cursor: pointer; }
.sa-live:hover { background: rgba(104,211,145,0.14); }
.sa-live .n { font-family: var(--font-cond); font-size: 1.1rem; font-weight: 600; }

.sa-seg { display: inline-flex; background: var(--navy); border: 1px solid var(--border-strong); border-radius: var(--radius-s); padding: 3px; gap: 2px; flex-wrap: wrap; }
.sa-seg button { border: 0; background: none; color: var(--silver-dark); padding: 0.32rem 0.65rem; border-radius: 4px; font-size: 0.85rem; font-weight: 500; cursor: pointer; white-space: nowrap; }
.sa-seg button:hover { color: var(--white); }
.sa-seg button[aria-pressed="true"] { background: var(--raised); color: var(--white); }
.sa-custom { display: none; align-items: center; gap: 0.4rem; }
.sa-custom.open { display: inline-flex; }
.sa-custom input { padding: 0.35rem 0.5rem; background: var(--navy); border: 1px solid var(--border-strong); border-radius: var(--radius-s); color: var(--white); font: inherit; font-size: 0.85rem; color-scheme: dark; }
.sa-check { display: inline-flex; align-items: center; gap: 0.4rem; font-size: 0.88rem; color: var(--silver); cursor: pointer; white-space: nowrap; }

.sa-filters { display: flex; gap: 0.5rem; flex-wrap: wrap; align-items: center; margin-bottom: 1rem; min-height: 0; }
.sa-filters:empty { display: none; }
.sa-chip { display: inline-flex; align-items: center; gap: 0.4rem; padding: 0.3rem 0.4rem 0.3rem 0.75rem; border-radius: 999px; background: var(--accent-wash); border: 1px solid rgba(124,187,228,0.35); color: var(--white); font-size: 0.85rem; max-width: 100%; }
.sa-chip span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sa-chip em { font-style: normal; color: var(--silver-dark); }
.sa-chip button { width: 22px; height: 22px; border-radius: 50%; border: 0; background: none; color: var(--silver); cursor: pointer; display: inline-flex; align-items: center; justify-content: center; font-size: 1rem; }
.sa-chip button:hover { background: var(--raised); color: var(--white); }

/* KPI strip doubles as the metric picker for the main chart. */
.sa-kpis { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); background: var(--navy-lighter); border: 1px solid var(--border); border-radius: var(--radius-m) var(--radius-m) 0 0; border-bottom: 0; overflow: hidden; }
.sa-kpi { text-align: left; padding: 0.95rem 1.1rem 0.85rem; border: 0; border-right: 1px solid var(--border); border-bottom: 1px solid var(--border); background: none; cursor: pointer; position: relative; min-width: 0; color: inherit; }
.sa-kpi:nth-child(4n) { border-right: 0; }
.sa-kpi:hover { background: var(--raised); }
.sa-kpi[aria-pressed="true"] { background: var(--accent-wash); }
.sa-kpi[aria-pressed="true"]::after { content: ''; position: absolute; left: 0; right: 0; bottom: -1px; height: 2px; background: var(--accent); }
.sa-kpi .l { font-size: 0.85rem; color: var(--silver-dark); }
.sa-kpi .v { font-family: var(--font-cond); font-size: 1.95rem; font-weight: 600; color: var(--white); line-height: 1.15; font-variant-numeric: tabular-nums; }
.sa-delta { font-size: 0.8rem; font-weight: 500; display: inline-flex; align-items: center; gap: 0.2rem; }
.sa-delta.good { color: var(--success); }
.sa-delta.bad { color: var(--error); }
.sa-delta.flat { color: var(--silver-dark); }
.sa-main { background: var(--navy-lighter); border: 1px solid var(--border); border-radius: 0 0 var(--radius-m) var(--radius-m); padding: 0.9rem 1.15rem 1rem; margin-bottom: 1.25rem; }
.sa-main-head { display: flex; justify-content: space-between; align-items: center; gap: 1rem; flex-wrap: wrap; margin-bottom: 0.6rem; }
.sa-main-head h2 { font-size: 0.98rem; font-weight: 600; color: var(--white); }
.sa-legend { display: flex; gap: 1rem; font-size: 0.82rem; color: var(--silver); flex-wrap: wrap; }
.sa-legend i { display: inline-block; width: 18px; height: 0; border-top: 2px solid var(--accent); vertical-align: middle; margin-right: 0.35rem; }
.sa-legend i.prev { border-top: 2px dashed var(--silver-dark); }
.sa-main-chart { position: relative; height: 290px; }

.sa-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 1rem; margin-bottom: 1rem; }
.sa-grid.three { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.sa-card { background: var(--navy-lighter); border: 1px solid var(--border); border-radius: var(--radius-m); min-width: 0; display: flex; flex-direction: column; }
.sa-card-head { display: flex; align-items: center; justify-content: space-between; gap: 0.75rem; padding: 0.85rem 1.1rem 0; flex-wrap: wrap; }
.sa-card-head h2 { font-size: 0.98rem; font-weight: 600; color: var(--white); }
.sa-card-head .hint { font-size: 0.8rem; color: var(--silver-dark); }
.sa-card-body { padding: 0.75rem 1.1rem 1rem; flex: 1; min-width: 0; }
.sa-card-foot { padding: 0 1.1rem 0.85rem; display: flex; justify-content: space-between; gap: 0.5rem; align-items: center; }
.sa-card.span-2 { grid-column: span 2; }

.sa-tabs { display: flex; gap: 0.15rem; padding: 0.55rem 1.1rem 0; border-bottom: 1px solid var(--border); overflow-x: auto; scrollbar-width: none; }
.sa-tabs button { border: 0; background: none; color: var(--silver-dark); padding: 0.45rem 0.6rem; font-size: 0.86rem; font-weight: 500; border-bottom: 2px solid transparent; cursor: pointer; white-space: nowrap; }
.sa-tabs button:hover { color: var(--white); }
.sa-tabs button[aria-selected="true"] { color: var(--white); border-bottom-color: var(--accent); }

/* Breakdown rows: a quiet bar behind each label, value at right. */
.sa-cols { display: flex; justify-content: space-between; font-size: 0.78rem; color: var(--silver-dark); padding: 0 0.5rem 0.35rem; }
.sa-rows { display: flex; flex-direction: column; gap: 3px; }
.sa-row { position: relative; display: grid; grid-template-columns: minmax(0, 1fr) auto auto; align-items: center; gap: 0.75rem; padding: 0.4rem 0.5rem; border: 0; background: none; text-align: left; border-radius: 4px; cursor: pointer; color: var(--silver); font-size: 0.9rem; width: 100%; min-height: 32px; }
.sa-row.static { cursor: default; }
.sa-row::before { content: ''; position: absolute; inset: 0 auto 0 0; width: var(--w, 0%); background: rgba(124,187,228,0.13); border-radius: 4px; }
.sa-row:not(.static):hover { background: rgba(201,213,226,0.05); }
.sa-row:not(.static):hover .lbl { color: var(--white); text-decoration: underline; text-decoration-color: var(--border-strong); }
.sa-row > * { position: relative; }
.sa-row .lbl { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sa-row .lbl small { color: var(--silver-dark); margin-left: 0.4rem; }
.sa-row .val { font-variant-numeric: tabular-nums; color: var(--white); font-weight: 500; text-align: right; min-width: 3ch; }
.sa-row .pct { font-variant-numeric: tabular-nums; color: var(--silver-dark); font-size: 0.8rem; text-align: right; min-width: 3.5ch; }
.sa-empty { color: var(--text-muted); font-size: 0.9rem; padding: 1.75rem 0.5rem; text-align: center; }

/* Funnel */
.sa-funnel { display: flex; flex-direction: column; gap: 0.55rem; }
.sa-step { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 0.25rem 0.75rem; font-size: 0.9rem; }
.sa-step .name { color: var(--silver); }
.sa-step .num { color: var(--white); font-weight: 600; font-variant-numeric: tabular-nums; text-align: right; }
.sa-step .track { grid-column: 1 / -1; height: 10px; background: var(--navy); border-radius: 5px; overflow: hidden; }
.sa-step .fill { height: 100%; border-radius: 5px; background: var(--accent); }
.sa-step .sub { grid-column: 1 / -1; font-size: 0.8rem; color: var(--silver-dark); }
.sa-step .sub b { color: var(--error); font-weight: 500; }

.sa-mini-title { font-size: 0.85rem; color: var(--silver-dark); margin: 0.9rem 0 0.4rem; }
.sa-mini-title:first-child { margin-top: 0; }
.sa-table { width: 100%; border-collapse: collapse; font-size: 0.88rem; }
.sa-table th { text-align: left; font-weight: 500; color: var(--silver-dark); font-size: 0.8rem; padding: 0.4rem 0.5rem; border-bottom: 1px solid var(--border-strong); white-space: nowrap; }
.sa-table td { padding: 0.45rem 0.5rem; border-bottom: 1px solid var(--border); color: var(--silver); vertical-align: top; }
.sa-table tr:last-child td { border-bottom: 0; }
.sa-table .n, .sa-table th.n { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.sa-table td.wrap { overflow-wrap: anywhere; }
.sa-table tbody tr.click { cursor: pointer; }
.sa-table tbody tr.click:hover td { background: rgba(124,187,228,0.05); }
.sa-scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.sa-scroll > .sa-table, .sa-scroll .sa-table { min-width: 620px; }
#saConv .sa-table, #saEvents .sa-table { min-width: 0; }
.sa-muted { color: var(--silver-dark); }
.sa-code { font-family: ui-monospace, SFMono-Regular, Consolas, monospace; font-size: 0.82rem; color: var(--silver); overflow-wrap: anywhere; }

/* Distribution bars */
.sa-dist { display: flex; flex-direction: column; gap: 0.35rem; }
.sa-dist-row { display: grid; grid-template-columns: 6.5rem minmax(0, 1fr) 3.5rem; align-items: center; gap: 0.6rem; font-size: 0.85rem; }
.sa-dist-row .k { color: var(--silver); white-space: nowrap; }
.sa-dist-row .bar { height: 12px; background: var(--navy); border-radius: 3px; overflow: hidden; }
.sa-dist-row .bar span { display: block; height: 100%; background: var(--accent); border-radius: 0 4px 4px 0; }
.sa-dist-row .v { text-align: right; color: var(--white); font-variant-numeric: tabular-nums; }

/* Heatmap: 7 x 24, single-hue sequential ramp (darker = fewer). */
.sa-heat { display: grid; grid-template-columns: 2.6rem repeat(24, minmax(0, 1fr)); gap: 3px; align-items: center; }
.sa-heat .d { font-size: 0.78rem; color: var(--silver-dark); }
.sa-heat .h { font-size: 0.7rem; color: var(--silver-dark); text-align: center; }
.sa-heat .c { aspect-ratio: 1.4; min-height: 12px; border-radius: 3px; background: var(--navy); }
.sa-heat .c[data-l="1"] { background: #184f95; }
.sa-heat .c[data-l="2"] { background: #256abf; }
.sa-heat .c[data-l="3"] { background: #3987e5; }
.sa-heat .c[data-l="4"] { background: #6da7ec; }
.sa-heat .c[data-l="5"] { background: #b7d3f6; }
.sa-heat-legend { display: flex; align-items: center; gap: 4px; font-size: 0.78rem; color: var(--silver-dark); margin-top: 0.6rem; justify-content: flex-end; }
.sa-heat-legend i { width: 14px; height: 10px; border-radius: 2px; display: inline-block; }

/* Web vitals */
.sa-vitals { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 0.75rem; margin-bottom: 1rem; }
.sa-vital { background: var(--navy); border: 1px solid var(--border); border-radius: var(--radius-m); padding: 0.8rem 0.85rem; min-width: 0; }
.sa-vital .name { font-size: 0.85rem; color: var(--silver); font-weight: 500; }
.sa-vital .name small { display: block; color: var(--silver-dark); font-weight: 400; font-size: 0.76rem; }
.sa-vital .p75 { font-family: var(--font-cond); font-size: 1.6rem; font-weight: 600; color: var(--white); margin: 0.25rem 0 0.15rem; font-variant-numeric: tabular-nums; }
.sa-rating { display: inline-flex; align-items: center; gap: 0.3rem; font-size: 0.8rem; font-weight: 500; }
.sa-rating svg { width: 14px; height: 14px; }
.sa-rating.good { color: #5fd38a; }
.sa-rating.ni { color: var(--warning); }
.sa-rating.poor { color: var(--error); }
.sa-stack { display: flex; gap: 2px; height: 8px; margin-top: 0.55rem; border-radius: 4px; overflow: hidden; }
.sa-stack span { display: block; height: 100%; }
.sa-stack .g { background: #0ca30c; }
.sa-stack .n { background: #fab219; }
.sa-stack .p { background: #d03b3b; }
.sa-stack-legend { font-size: 0.74rem; color: var(--silver-dark); margin-top: 0.35rem; display: flex; gap: 0.6rem; flex-wrap: wrap; }

/* Health & security */
.sa-health-stats { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 0.75rem; margin-bottom: 0.9rem; }
.sa-hstat { background: var(--navy); border: 1px solid var(--border); border-radius: var(--radius-m); padding: 0.7rem 0.85rem; }
.sa-hstat .v { font-family: var(--font-cond); font-size: 1.55rem; font-weight: 600; color: var(--white); line-height: 1.1; }
.sa-hstat .l { font-size: 0.82rem; color: var(--silver-dark); }
.sa-note { display: flex; gap: 0.6rem; align-items: flex-start; padding: 0.7rem 0.85rem; border-radius: var(--radius-s); background: rgba(124,187,228,0.07); border: 1px solid rgba(124,187,228,0.22); font-size: 0.86rem; color: var(--silver); margin-bottom: 0.75rem; }
.sa-note svg { width: 18px; height: 18px; color: var(--accent); flex-shrink: 0; margin-top: 1px; }

/* Setup */
.sa-setup { background: var(--navy-lighter); border: 1px solid rgba(232,180,74,0.4); border-radius: var(--radius-m); padding: 1.25rem 1.35rem; margin-bottom: 1.25rem; }
.sa-setup h2 { font-family: var(--font-cond); font-size: 1.5rem; font-weight: 600; color: var(--white); margin-bottom: 0.35rem; }
.sa-setup p { color: var(--silver); font-size: 0.93rem; max-width: 70ch; }
.sa-setup ol { margin: 0.9rem 0 1rem 1.25rem; color: var(--silver); font-size: 0.93rem; display: grid; gap: 0.35rem; }
.sa-setup .actions { display: flex; gap: 0.6rem; flex-wrap: wrap; }

/* Journey timeline */
.sa-journey { list-style: none; position: relative; margin: 0.5rem 0 0; padding-left: 1.35rem; }
.sa-journey::before { content: ''; position: absolute; left: 0.42rem; top: 0.4rem; bottom: 0.4rem; width: 2px; background: var(--border-strong); }
.sa-journey li { position: relative; padding: 0.35rem 0 0.6rem; }
.sa-journey li::before { content: ''; position: absolute; left: -1.1rem; top: 0.72rem; width: 10px; height: 10px; border-radius: 50%; background: var(--navy-lighter); border: 2px solid var(--accent); }
.sa-journey li.ev::before { width: 8px; height: 8px; left: -1.03rem; border-color: var(--silver-dark); }
.sa-journey li.goal::before { border-color: var(--success); background: var(--success); }
.sa-journey .t { font-size: 0.78rem; color: var(--silver-dark); }
.sa-journey .what { color: var(--white); font-size: 0.92rem; overflow-wrap: anywhere; }
.sa-journey .meta { color: var(--silver-dark); font-size: 0.82rem; }
.sa-attrs { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 0.6rem 1rem; padding: 0.75rem 0.9rem; background: var(--navy); border: 1px solid var(--border); border-radius: var(--radius-m); font-size: 0.88rem; }
.sa-attrs div span { display: block; color: var(--silver-dark); font-size: 0.78rem; }
.sa-attrs div b { color: var(--white); font-weight: 500; overflow-wrap: anywhere; }

.sa-pager { display: flex; align-items: center; justify-content: space-between; gap: 0.75rem; padding-top: 0.6rem; font-size: 0.85rem; color: var(--silver-dark); }
.sa-pill { display: inline-flex; align-items: center; gap: 0.3rem; padding: 0.1rem 0.5rem; border-radius: 999px; font-size: 0.76rem; font-weight: 500; background: rgba(104,211,145,0.12); color: var(--success); white-space: nowrap; }
.sa-loading { opacity: 0.55; transition: opacity 0.2s; pointer-events: none; }
.sa-spark { display: flex; align-items: flex-end; gap: 2px; height: 56px; margin: 0.5rem 0 1rem; }
.sa-spark span { flex: 1; background: var(--accent); border-radius: 2px 2px 0 0; min-height: 2px; opacity: 0.85; }

@media (max-width: 1180px) {
    .sa-vitals { grid-template-columns: repeat(3, minmax(0, 1fr)); }
    .sa-grid.three { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 900px) {
    .sa-grid, .sa-grid.three { grid-template-columns: minmax(0, 1fr); }
    .sa-card.span-2 { grid-column: auto; }
    .sa-kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .sa-kpi:nth-child(4n) { border-right: 1px solid var(--border); }
    .sa-kpi:nth-child(2n) { border-right: 0; }
    .sa-health-stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 560px) {
    .sa-vitals { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .sa-kpi .v { font-size: 1.6rem; }
    .sa-main-chart { height: 230px; }
    .sa-heat { grid-template-columns: 2.2rem repeat(24, minmax(0, 1fr)); gap: 2px; }
    .sa-heat .h { font-size: 0.6rem; }
    .sa-dist-row { grid-template-columns: 5.5rem minmax(0, 1fr) 3rem; }
}
