/* ==========================================================
   analytics — dashboard styles

   One idea carries the interface: the accent colour *is* the
   platform. Amber means you are looking at web traffic, ice
   blue means app. Switch the toggle and the whole surface
   retints, so you can never misread which numbers you are on.
   ========================================================== */

:root {
    --bg: #0a0b0c;
    --panel: #111315;
    --panel-2: #16191b;
    --line: #22272a;
    --line-soft: #191d1f;
    --text: #e9edef;
    --muted: #79838a;
    --muted-2: #545d63;

    --accent: #ffb020;
    --accent-dim: rgba(255, 176, 32, 0.16);
    --accent-ghost: rgba(255, 176, 32, 0.06);

    --sans: "IBM Plex Sans", ui-sans-serif, system-ui, sans-serif;
    --mono: "IBM Plex Mono", ui-monospace, "SF Mono", monospace;

    --r: 4px;
}

[data-platform="app"] {
    --accent: #56c2ff;
    --accent-dim: rgba(86, 194, 255, 0.16);
    --accent-ghost: rgba(86, 194, 255, 0.06);
}

[data-platform="bot"] {
    --accent: #8f7ae6;
    --accent-dim: rgba(143, 122, 230, 0.16);
    --accent-ghost: rgba(143, 122, 230, 0.06);
}

[data-platform="all"] {
    --accent: #c8ccce;
    --accent-dim: rgba(200, 204, 206, 0.14);
    --accent-ghost: rgba(200, 204, 206, 0.05);
}

* { box-sizing: border-box; }

html, body {
    margin: 0;
    padding: 0;
    background: var(--bg);
    color: var(--text);
    font-family: var(--sans);
    font-size: 14px;
    -webkit-font-smoothing: antialiased;
}

a { color: inherit; text-decoration: none; }

:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
}

.mono { font-family: var(--mono); }

.eyebrow {
    font-family: var(--mono);
    font-size: 10px;
    letter-spacing: 0.14em;
    text-transform: uppercase;
    color: var(--muted-2);
}

/* ---------- shell ---------- */

.shell { max-width: 1180px; margin: 0 auto; padding: 0 20px 64px; }

.topbar {
    position: sticky;
    top: 0;
    z-index: 20;
    background: rgba(10, 11, 12, 0.86);
    backdrop-filter: blur(10px);
    border-bottom: 1px solid var(--line);
}

.topbar__inner {
    max-width: 1180px;
    margin: 0 auto;
    padding: 12px 20px;
    display: flex;
    align-items: center;
    column-gap: 14px;
    row-gap: 10px;
    flex-wrap: wrap;
}

.topbar__inner > form { margin: 0; }

.brand {
    flex: 0 0 auto;
    font-family: var(--mono);
    font-size: 13px;
    letter-spacing: 0.04em;
    display: flex;
    align-items: center;
    gap: 8px;
}

.brand__dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-dim);
    transition: background 0.25s ease, box-shadow 0.25s ease;
}

.spacer { flex: 1 1 auto; }

.site-pick {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    min-width: 0;
}

.site-pick__icon {
    width: 18px;
    height: 18px;
    border-radius: 3px;
    object-fit: contain;
    flex: 0 0 auto;
}

.select {
    appearance: none;
    background: var(--panel-2);
    color: var(--text);
    border: 1px solid var(--line);
    border-radius: var(--r);
    height: 32px;
    padding: 0 28px 0 10px;
    font-family: var(--mono);
    font-size: 12px;
    line-height: 32px;
    cursor: pointer;
    background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%),
                      linear-gradient(135deg, var(--muted) 50%, transparent 50%);
    background-position: calc(100% - 14px) 52%, calc(100% - 9px) 52%;
    background-size: 5px 5px, 5px 5px;
    background-repeat: no-repeat;
}

/* ---------- segmented controls ---------- */

.seg {
    display: inline-flex;
    border: 1px solid var(--line);
    border-radius: var(--r);
    overflow: hidden;
    background: var(--panel-2);
}

.seg__btn {
    appearance: none;
    display: inline-flex;
    align-items: center;
    height: 30px;
    background: none;
    border: 0;
    border-right: 1px solid var(--line);
    color: var(--muted);
    font-family: var(--mono);
    font-size: 11px;
    letter-spacing: 0.06em;
    padding: 0 11px;
    white-space: nowrap;
    cursor: pointer;
    transition: color 0.15s ease, background 0.15s ease;
}

.seg__btn:last-child { border-right: 0; }
.seg__btn:hover { color: var(--text); }

.seg__btn.is-on {
    color: var(--bg);
    background: var(--accent);
    font-weight: 600;
}

.seg--platform .seg__btn.is-on { letter-spacing: 0.1em; }

/* ---------- live ---------- */

.live {
    display: inline-flex;
    align-items: center;
    height: 32px;
    gap: 7px;
    white-space: nowrap;
    font-family: var(--mono);
    font-size: 12px;
    color: var(--muted);
}

.live__pulse {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--accent);
    animation: pulse 2.4s ease-in-out infinite;
}

@keyframes pulse {
    0%, 100% { opacity: 1; transform: scale(1); }
    50% { opacity: 0.35; transform: scale(0.82); }
}

@media (prefers-reduced-motion: reduce) {
    .live__pulse { animation: none; }
    * { transition: none !important; }
}

/* ---------- metric row ---------- */

.metrics {
    display: grid;
    grid-template-columns: repeat(5, minmax(0, 1fr));
    border: 1px solid var(--line);
    border-radius: var(--r);
    background: var(--panel);
    margin: 22px 0 18px;
    overflow: hidden;
}

.metric {
    padding: 16px 18px 18px;
    border-right: 1px solid var(--line-soft);
    position: relative;
}

.metric:last-child { border-right: 0; }

.metric::before {
    content: "";
    position: absolute;
    inset: 0 0 auto 0;
    height: 2px;
    background: var(--accent);
    opacity: 0;
    transition: opacity 0.25s ease;
}

.metric--lead::before { opacity: 1; }

.metric__label {
    font-family: var(--mono);
    font-size: 10px;
    letter-spacing: 0.13em;
    text-transform: uppercase;
    color: var(--muted-2);
}

.metric__value {
    display: flex;
    align-items: baseline;
    font-family: var(--mono);
    font-size: 30px;
    white-space: nowrap;
    font-weight: 500;
    letter-spacing: -0.02em;
    font-variant-numeric: tabular-nums;
    margin-top: 8px;
    line-height: 1;
}

.metric__unit { font-size: 15px; color: var(--muted); margin-left: 2px; }

/* ---------- panels ---------- */

.panel {
    border: 1px solid var(--line);
    border-radius: var(--r);
    background: var(--panel);
    margin-bottom: 18px;
}

.panel__head {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 16px;
    border-bottom: 1px solid var(--line-soft);
    flex-wrap: wrap;
}

.panel__title {
    font-family: var(--mono);
    font-size: 11px;
    letter-spacing: 0.13em;
    text-transform: uppercase;
    color: var(--muted);
}

.panel__body { padding: 14px 16px 16px; }

.chart { width: 100%; height: 280px; min-height: 280px; }
.chart--donut { height: 210px; min-height: 210px; }
.chart--heat { height: 210px; min-height: 210px; }

.grid--charts { margin-bottom: 18px; }

.grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    align-items: start;
    gap: 18px;
}

.grid > .panel { margin-bottom: 0; }

/* ---------- breakdown lists ---------- */

.tabs { display: flex; gap: 2px; }

.tab {
    appearance: none;
    background: none;
    border: 0;
    color: var(--muted-2);
    font-family: var(--mono);
    font-size: 10px;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    padding: 4px 7px;
    border-radius: 3px;
    cursor: pointer;
}

.tab:hover { color: var(--text); }
.tab.is-on { color: var(--accent); background: var(--accent-ghost); }

.rows { display: flex; flex-direction: column; }

.row {
    position: relative;
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 7px 8px;
    min-height: 32px;
    border-bottom: 1px solid var(--line-soft);
    font-size: 13px;
}

.row:last-child { border-bottom: 0; }

.row__bar {
    position: absolute;
    pointer-events: none;
    left: 0;
    top: 0;
    bottom: 0;
    background: var(--accent-ghost);
    border-left: 2px solid var(--accent-dim);
    border-radius: 2px;
    transition: width 0.4s cubic-bezier(0.2, 0.7, 0.3, 1);
}

.row__icon {
    position: relative;
    flex: 0 0 auto;
    width: 16px;
    height: 16px;
    border-radius: 3px;
    object-fit: contain;
}

.row__flag {
    position: relative;
    flex: 0 0 auto;
    width: 18px;
    font-size: 14px;
    line-height: 1;
    text-align: center;
}

.row__label {
    position: relative;
    flex: 1 1 auto;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.row__value {
    position: relative;
    flex: 0 0 auto;
    font-family: var(--mono);
    font-variant-numeric: tabular-nums;
    color: var(--muted);
    font-size: 12px;
}

.empty {
    padding: 24px 8px;
    color: var(--muted-2);
    font-size: 13px;
}

/* ---------- forms & auth ---------- */

.auth {
    min-height: 100vh;
    display: grid;
    place-items: center;
    padding: 24px;
}

.card {
    width: 100%;
    max-width: 380px;
    border: 1px solid var(--line);
    border-radius: var(--r);
    background: var(--panel);
    padding: 28px;
}

.card__title {
    font-family: var(--mono);
    font-size: 18px;
    letter-spacing: -0.01em;
    margin: 14px 0 4px;
}

.card__sub { color: var(--muted); font-size: 13px; margin: 0 0 22px; }

.field { margin-bottom: 14px; }

.field__label {
    display: block;
    font-family: var(--mono);
    font-size: 10px;
    letter-spacing: 0.13em;
    text-transform: uppercase;
    color: var(--muted-2);
    margin-bottom: 6px;
}

.input {
    width: 100%;
    background: var(--panel-2);
    border: 1px solid var(--line);
    border-radius: var(--r);
    color: var(--text);
    font-family: var(--sans);
    font-size: 14px;
    padding: 9px 11px;
}

.input:focus { border-color: var(--accent); outline: none; }

.btn {
    appearance: none;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    min-height: 36px;
    line-height: 1;
    background: var(--accent);
    color: var(--bg);
    border: 0;
    border-radius: var(--r);
    font-family: var(--mono);
    font-size: 12px;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    font-weight: 600;
    padding: 11px;
    cursor: pointer;
}

.btn:hover { filter: brightness(1.08); }

.btn--ghost {
    width: auto;
    height: 32px;
    min-height: 0;
    background: none;
    color: var(--muted);
    border: 1px solid var(--line);
    padding: 0 12px;
    white-space: nowrap;
}

.btn--ghost:hover { color: var(--text); filter: none; }

.alert {
    border: 1px solid var(--line);
    border-left: 2px solid var(--accent);
    background: var(--accent-ghost);
    border-radius: var(--r);
    padding: 10px 12px;
    font-size: 13px;
    margin-bottom: 16px;
}

.note { color: var(--muted); font-size: 13px; line-height: 1.6; }

.snippet {
    font-family: var(--mono);
    font-size: 12px;
    background: var(--bg);
    border: 1px solid var(--line);
    border-radius: var(--r);
    padding: 12px;
    overflow-x: auto;
    color: var(--muted);
    white-space: pre;
}

.key {
    font-family: var(--mono);
    font-size: 12px;
    background: var(--panel-2);
    border: 1px solid var(--line);
    border-radius: 3px;
    padding: 3px 6px;
    user-select: all;
}

.site-row {
    display: flex;
    align-items: center;
    gap: 14px 18px;
    padding: 14px 16px;
    border-bottom: 1px solid var(--line-soft);
    flex-wrap: wrap;
}

.site-row:last-child { border-bottom: 0; }
.site-row__name { font-weight: 600; }
.site-row > div { min-width: 0; }
.site-row__icon {
    width: 28px;
    height: 28px;
    border-radius: 5px;
    object-fit: contain;
    flex: 0 0 auto;
}
.site-row .key { display: inline-block; margin-top: 4px; word-break: break-all; }

/* ---------- responsive ---------- */

@media (max-width: 900px) {
    .metrics { grid-template-columns: repeat(2, 1fr); }
    .metric { border-bottom: 1px solid var(--line-soft); }
    .metric:nth-last-child(-n + 1) { border-bottom: 0; }
    .metric:nth-child(2n) { border-right: 0; }
    .grid { grid-template-columns: 1fr; }
}

@media (max-width: 560px) {
    .metrics { grid-template-columns: 1fr; }
    .metric__value { font-size: 26px; }
    .topbar__inner { gap: 10px; }
}