/* Mobile CSA view — reuses dashboard KPI accent language */

html:has(body.csa-view),
html:has(body.csa-view-login) {
    font-size: clamp(14px, 3.6vw, 16px);
    -webkit-text-size-adjust: 100%;
    text-size-adjust: 100%;
}

.csa-shell {
    width: 100%;
    max-width: 28rem;
    margin-inline: auto;
    padding-inline: 0.75rem;
    box-sizing: border-box;
}

/* Large Android phones (Pixel class) — slightly larger type, full bleed */
html.csa-lg {
    font-size: clamp(15px, 3.8vw, 17px) !important;
}
html.csa-lg body.csa-view .csa-shell,
html.csa-lg body.csa-view .csa-header-inner,
html.csa-lg body.csa-view main {
    max-width: none !important;
    width: 100%;
}
html.csa-lg body.csa-view .csa-contrib-viewport,
html.csa-lg body.csa-view .csa-contrib-chart-box {
    height: 8.5rem;
}

body.csa-view,
body.csa-view-login {
    background: #0f172a;
    color: #f1f5f9;
}

body.csa-view #btn-sign-out {
    font-size: inherit;
    letter-spacing: inherit;
}

.csa-section-title {
    font-size: 1.05rem;
    margin: 0;
}
.csa-live-tag { font-size: 0.75rem; }
.csa-foot-label { font-size: 0.7rem; }
.csa-foot-brand { font-size: 0.8rem; }
.csa-foot-brand-link {
    text-decoration: none;
    color: inherit;
    transition: opacity 0.15s ease;
}
.csa-foot-brand-link:hover {
    opacity: 0.88;
}
.csa-foot-brand-link:hover .csa-foot-brand {
    color: #86efac;
}

/* Header — match mobile dashboard Next Sync / Last Sync treatment */
.csa-header {
    padding: 0.55rem 0.75rem 0.65rem;
}
.csa-header-inner {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    width: 100%;
}
.csa-header-top {
    display: flex;
    position: relative;
    align-items: flex-start;
    justify-content: space-between;
    gap: 0.65rem;
    padding-right: 3.35rem;
}
.csa-header-actions {
    position: absolute;
    top: 0;
    right: 0;
    display: flex;
    flex-direction: column;
    align-items: stretch;
    gap: 0.18rem;
    z-index: 1;
}
.csa-header-action-btn {
    display: block;
    min-width: 3.1rem;
    padding: 0.18rem 0.4rem;
    font-size: 0.58rem;
    font-weight: 700;
    letter-spacing: 0.05em;
    line-height: 1.15;
    text-align: center;
    text-transform: uppercase;
    text-decoration: none;
    border-radius: 0.35rem;
    background: #0f172a;
    color: #94a3b8;
    border: 1px solid #334155;
    transition: color 0.15s ease, border-color 0.15s ease;
}
.csa-header-action-account:hover {
    color: #7dd3fc;
    border-color: #0ea5e9;
}
.csa-header-action-signout:hover {
    color: #fda4af;
    border-color: #f43f5e;
}
.csa-header-logo {
    height: 3.25rem;
    width: auto;
    max-height: 3.25rem;
}
html.csa-lg body.csa-view .csa-header-logo {
    height: 3.65rem;
    max-height: 3.65rem;
}
.csa-header-sub {
    font-size: 0.82rem;
    letter-spacing: 0.08em;
    margin-top: 0;
    line-height: 1.2;
}
.csa-header-date {
    font-size: 0.85rem;
    margin-top: 0.2rem;
    line-height: 1.15;
    font-weight: 700;
}
.csa-sync-shield {
    width: 100%;
    min-height: 2.85rem;
    padding: 0.55rem 0.75rem;
    display: flex;
    flex-direction: row;
    flex-wrap: wrap;
    align-items: center;
    justify-content: center;
    text-align: center;
    gap: 0.35rem 0.85rem;
    box-sizing: border-box;
}
.csa-sync-shield .csa-sync-next {
    display: flex;
    align-items: center;
    justify-content: center;
    flex-wrap: wrap;
    gap: 0.35rem;
}
.csa-sync-shield .last-sync-wrap {
    text-align: center;
}
.csa-sync-shield #timer-title-text {
    font-size: 0.88rem;
}
.csa-sync-shield #sync-countdown {
    font-size: 1.2rem;
    line-height: 1;
}
.csa-sync-shield .last-sync-wrap {
    font-size: 0.88rem;
}
.csa-sync-shield.sync-urgent {
    border-color: #f43f5e;
    box-shadow: 0 0 16px rgba(244, 63, 94, 0.35);
    animation: csa-sync-urgent-flash 1s ease-in-out infinite;
}
.csa-sync-shield.sync-urgent #timer-title-text,
.csa-sync-shield.sync-urgent #sync-countdown {
    color: #fb7185;
}
@keyframes csa-sync-urgent-flash {
    0%, 100% { background-color: #0f172a; box-shadow: 0 0 12px rgba(244, 63, 94, 0.25); }
    50% { background-color: #3f1219; box-shadow: 0 0 22px rgba(244, 63, 94, 0.55); }
}

.csa-site-card {
    background: #1e293b;
    border: 1px solid rgb(30 41 59);
    border-radius: 1rem;
    padding: 0.75rem 0.8rem 0.85rem;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.22);
}

.csa-site-card-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 0.55rem;
    margin-bottom: 0.6rem;
    padding-bottom: 0.5rem;
    border-bottom: 1px solid rgb(30 41 59 / 0.9);
}

.csa-site-card-head .min-w-0 {
    flex: 1;
    min-width: 0;
}

.csa-site-name {
    font-size: 1rem;
    font-weight: 900;
    letter-spacing: 0.02em;
    color: #e2e8f0;
    line-height: 1.15;
}

.csa-site-head-right {
    display: flex;
    align-items: center;
    gap: 0.45rem;
}

.csa-wa-btn {
    display: inline-flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0.1rem;
    width: 2.35rem;
    height: 2.35rem;
    border-radius: 0.65rem;
    background: #25d366;
    color: #053b1f;
    border: 1px solid #1ebe57;
    box-shadow: 0 4px 10px rgba(37, 211, 102, 0.25);
    cursor: pointer;
    flex-shrink: 0;
}
.csa-wa-btn:active {
    transform: scale(0.96);
}
.csa-wa-btn span {
    font-size: 0.5rem;
    font-weight: 900;
    letter-spacing: 0.04em;
    line-height: 1;
}
.csa-wa-btn .wa-pulse-icon {
    width: 0.95rem;
    height: 0.95rem;
}

.csa-kpi.kpi-pink > h3 { color: #f472b6; }
.csa-kpi.kpi-lime > h3 { color: #a3e635; }

.csa-site-card.has-fs-kpis .csa-kpi-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 0.4rem 0.35rem;
}

.csa-site-rank {
    font-size: 0.72rem;
    font-weight: 900;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: #94a3b8;
}

.csa-site-cap {
    font-size: 1.15rem;
    font-weight: 900;
    font-variant-numeric: tabular-nums;
    color: #fbbf24;
}

/* Cap Rate — red flash <18%, amber flash 18.0–19.9% (matches main dashboard) */
.csa-site-card.kpi-cap-alert .csa-site-cap {
    color: #fecaca;
    text-shadow: 0 0 12px rgba(248, 113, 113, 0.85);
    animation: csa-cap-alert-pulse 1.15s ease-in-out infinite;
}

.csa-site-card.kpi-cap-warn .csa-site-cap {
    color: #fde68a;
    text-shadow: 0 0 10px rgba(251, 191, 36, 0.85);
    animation: csa-cap-amber-blink 0.85s ease-in-out infinite;
}

.csa-site-card.kpi-cap-alert .csa-kpi.kpi-amber {
    border-radius: 0.55rem;
    padding: 0.25rem 0.2rem;
    background: #450a0a;
    animation: csa-cap-alert-pulse 1.15s ease-in-out infinite;
}
.csa-site-card.kpi-cap-alert .csa-kpi.kpi-amber > h3 {
    color: #fecaca !important;
    text-shadow: 0 0 12px rgba(248, 113, 113, 0.85);
}

.csa-site-card.kpi-cap-warn .csa-kpi.kpi-amber {
    border-radius: 0.55rem;
    padding: 0.25rem 0.2rem;
    animation: csa-cap-amber-blink 0.85s ease-in-out infinite;
}
.csa-site-card.kpi-cap-warn .csa-kpi.kpi-amber > h3 {
    color: #fde68a !important;
    text-shadow: 0 0 10px rgba(251, 191, 36, 0.85);
}

@keyframes csa-cap-alert-pulse {
    0%, 100% { filter: brightness(1); box-shadow: inset 0 0 0 1px rgba(244, 63, 94, 0.45), 0 0 10px rgba(185, 28, 28, 0.4); }
    50% { filter: brightness(1.12); box-shadow: inset 0 0 0 2px rgba(248, 113, 113, 0.85), 0 0 28px rgba(239, 68, 68, 0.85); }
}

@keyframes csa-cap-amber-blink {
    0%, 100% { filter: brightness(1); box-shadow: inset 0 0 0 1px rgba(245, 158, 11, 0.35); }
    50% { filter: brightness(1.25); box-shadow: inset 0 0 0 2px rgba(251, 191, 36, 0.95), 0 0 22px rgba(245, 158, 11, 0.7); }
}

.csa-kpi-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0.45rem 0.55rem;
}

.csa-kpi {
    display: flex;
    flex-direction: column;
    gap: 0.12rem;
    min-width: 0;
}

.csa-kpi > p {
    margin: 0;
    font-size: 0.68rem;
    font-weight: 900;
    letter-spacing: 0.05em;
    text-transform: uppercase;
    color: #64748b;
    line-height: 1.15;
}

.csa-site-card.has-fs-kpis .csa-kpi > p {
    font-size: 0.62rem;
    letter-spacing: 0.03em;
}

.csa-kpi > h3 {
    margin: 0;
    font-size: 1.25rem;
    font-weight: 900;
    line-height: 1.05;
    font-variant-numeric: tabular-nums;
}

.csa-kpi.kpi-sky > h3 { color: #38bdf8; }
.csa-kpi.kpi-emerald > h3 { color: #34d399; }
.csa-kpi.kpi-amber > h3 { color: #fbbf24; }
.csa-kpi.kpi-orange-soft > h3 { color: #fdba74; }

.csa-rank-metric-head {
    letter-spacing: 0.06em;
    line-height: 1.15;
    font-size: 0.62rem !important;
}

.csa-rank-row {
    display: grid;
    grid-template-columns: 2rem minmax(0, 1fr) auto;
    gap: 0.55rem;
    align-items: center;
    padding: 0.7rem 0.75rem;
}

.csa-rank-pos {
    font-size: 0.85rem;
    font-weight: 900;
    color: #64748b;
    font-variant-numeric: tabular-nums;
}

.csa-rank-name {
    font-size: 0.95rem;
    font-weight: 800;
    color: #e2e8f0;
    line-height: 1.2;
}

.csa-rank-site {
    font-size: 0.72rem;
    font-weight: 700;
    letter-spacing: 0.05em;
    text-transform: uppercase;
    color: #64748b;
    margin-top: 0.12rem;
}

.csa-rank-metrics {
    display: flex;
    align-items: flex-end;
    justify-content: flex-end;
    gap: 0.55rem;
}

.csa-rank-metric {
    text-align: right;
    min-width: 2.15rem;
}

.csa-rank-metric-val {
    display: block;
    font-size: 1.05rem;
    font-weight: 900;
    font-variant-numeric: tabular-nums;
    line-height: 1.1;
}

.csa-rank-metric-val.arm { color: #34d399; }
.csa-rank-metric-val sup.arm-best {
  font-size: 0.52em;
  font-weight: 700;
  line-height: 0;
  margin-right: 0.06em;
  color: #64748b;
  cursor: help;
  vertical-align: super;
  position: relative;
  top: -0.05em;
}
.csa-rank-metric-val sup.arm-best.is-record {
  color: #94a3b8;
}
.csa-rank-metric-val.expint { color: #f472b6; }
.csa-rank-metric-val.detail { color: #a3e635; }

.csa-rank-metric-lbl {
    display: block;
    margin-top: 0.1rem;
    font-size: 0.58rem;
    font-weight: 900;
    letter-spacing: 0.05em;
    text-transform: uppercase;
    color: #64748b;
}

.csa-rank-row.is-top .csa-rank-pos {
    color: #fbbf24;
}

.csa-contrib-wrap {
    margin-top: 0.75rem;
    padding-top: 0.65rem;
    border-top: 1px solid rgb(30 41 59 / 0.9);
}

.csa-contrib-head {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 0.5rem;
    margin-bottom: 0.4rem;
}

.csa-contrib-head > h3 {
    margin: 0;
    font-size: 0.78rem;
    font-weight: 900;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    color: #34d399;
}

.csa-contrib-head > span {
    font-size: 0.65rem;
    font-weight: 800;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: #64748b;
}

.csa-contrib-legend {
    display: flex;
    flex-wrap: wrap;
    gap: 0.3rem 0.55rem;
    margin-bottom: 0.4rem;
}

.csa-contrib-legend-item {
    display: inline-flex;
    align-items: center;
    gap: 0.28rem;
    font-size: 0.75rem;
    font-weight: 700;
    color: #94a3b8;
}

.csa-contrib-legend-item > i {
    width: 0.5rem;
    height: 0.5rem;
    border-radius: 999px;
    display: inline-block;
}

.csa-contrib-chart-box {
    position: relative;
    height: 6.5rem;
    width: 100%;
    min-width: 0;
}

.csa-contrib-scroll {
    width: 100%;
    max-width: 100%;
    min-width: 0;
    overflow-x: auto;
    overflow-y: hidden;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior-x: contain;
    touch-action: pan-x;
    padding-bottom: 0.15rem;
    padding-right: 2px;
    box-sizing: border-box;
}

.csa-contrib-viewport {
    position: relative;
    height: 6.5rem;
    width: 100%;
    min-width: 100%;
    background: #1e293b;
    box-sizing: content-box;
    padding-right: 8px;
}

.csa-contrib-viewport canvas {
    display: block;
    width: 100%;
    height: 100%;
}

.csa-contrib-viewport canvas.is-empty {
    display: none;
}

.csa-contrib-empty {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0;
    font-size: 0.82rem;
    font-weight: 700;
    color: #64748b;
    pointer-events: none;
}

.csa-contrib-empty[hidden] {
    display: none !important;
}

.csa-contrib-scroll::-webkit-scrollbar { height: 8px; width: 8px; }
.csa-contrib-scroll::-webkit-scrollbar-track { background: #0f172a; border-radius: 4px; }
.csa-contrib-scroll::-webkit-scrollbar-thumb { background: #334155; border-radius: 4px; border: 1px solid #1e293b; }

@media (orientation: landscape) and (max-height: 540px) {
    body.csa-view > header.csa-header {
        padding-top: 0.35rem;
        padding-bottom: 0.4rem;
    }
    body.csa-view .csa-header-inner {
        gap: 0.35rem;
    }
    body.csa-view .csa-header-logo {
        height: 2.85rem;
        max-height: 2.85rem;
    }
    body.csa-view .csa-header-sub,
    body.csa-view .csa-header-date {
        font-size: 0.72rem;
        margin: 0;
    }
    body.csa-view .csa-header-top {
        padding-right: 2.85rem;
    }
    body.csa-view .csa-header-action-btn {
        min-width: 2.75rem;
        padding: 0.12rem 0.35rem;
        font-size: 0.52rem;
    }
    body.csa-view .csa-sync-shield {
        min-height: 2.35rem;
        padding: 0.35rem 0.55rem;
    }
    body.csa-view .csa-sync-shield #timer-title-text {
        font-size: 0.78rem;
    }
    body.csa-view .csa-sync-shield #sync-countdown {
        font-size: 1.05rem;
    }
    body.csa-view .csa-sync-shield .last-sync-wrap {
        font-size: 0.78rem;
    }
}
