/* ── Google Fonts ──────────────────────────────────────────────────────────── */
@import url('https://fonts.googleapis.com/css2?family=Syne:wght@400;500;600;700;800&family=DM+Sans:ital,opsz,wght@0,9..40,300;0,9..40,400;0,9..40,500;1,9..40,300&display=swap');
@import url('https://fonts.googleapis.com/css2?family=Google+Sans:ital,opsz,wght@0,17..18,400..700;1,17..18,400..700&display=swap');
/* ══════════════════════════════════════════════════════════════════════════════
   DESIGN TOKENS
══════════════════════════════════════════════════════════════════════════════ */
:root {
    /* Backgrounds */
    --bg-base:       #e4f1f5;
    --bg-surface:    #ffffff;
    --bg-elevated:   #f1f1f1;
    --bg-hover:      #664fff17;
    --bg-active:     #23273a;

    /* Borders */
    --border-subtle: rgba(255,255,255,0.06);
    --border-mid:    rgba(255,255,255,0.10);

    /* Brand accent — electric teal */
    --accent:        #00d4aa;
    --accent-dim:    #664fff20;
    --accent-glow:   rgba(0,212,170,0.25);

    /* Secondary accent — warm amber */
    --amber:         #f5a623;
    --amber-dim:     rgba(245,166,35,0.12);

    /* Tertiary — soft violet */
    --violet:        #a78bfa;
    --violet-dim:    rgba(167,139,250,0.12);

    /* Text */
    --text-primary:  #241a4f;
    --text-secondary:#664fff;
    --text-muted:    #241a4f;

    /* Status */
    --green:   #00d4aa;
    --red:     #ef4444;

    /* Layout */
    --sidebar-w: 280px;
    --header-h:  64px;
    --sidebar-h: 94px;

    /* Radius */
    --r-sm:  6px;
    --r-md:  12px;
    --r-lg:  18px;
    --r-xl:  24px;

    /* Typography */
    --font-display: "Google Sans", sans-serif;
    --font-body:    'DM Sans', sans-serif;

    /* Transitions */
    --t: 200ms cubic-bezier(0.4,0,0.2,1);
}

/* ══════════════════════════════════════════════════════════════════════════════
   RESET
══════════════════════════════════════════════════════════════════════════════ */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html { height: 100%; }

body {
    font-family: var(--font-body);
    background: var(--bg-base);
    color: var(--text-primary);
    min-height: 100%;
    line-height: 1.55;
    -webkit-font-smoothing: antialiased;
    overflow-x: hidden;
}

a    { text-decoration: none; color: inherit; }
button { cursor: pointer; border: none; background: none; font-family: inherit; }
ul   { list-style: none; }
img  { display: block; max-width: 100%; }

/* ── Custom scrollbar ──────────────────────────────────────────────────────── */
::-webkit-scrollbar            { width: 6px; }
::-webkit-scrollbar-track      { background: transparent; }
::-webkit-scrollbar-thumb      { background: var(--bg-active); border-radius: 99px; }
::-webkit-scrollbar-thumb:hover{ background: var(--text-muted); }


/* ══════════════════════════════════════════════════════════════════════════════
   HEADER
══════════════════════════════════════════════════════════════════════════════ */
.header {
    position: fixed;
    top: 0; left: 0; right: 0;
    z-index: 100;
    height: var(--header-h);
    display: flex;
    align-items: center;
    padding: 0 24px;
    background: #ffffff;
    backdrop-filter: blur(18px) saturate(1.6);
    -webkit-backdrop-filter: blur(18px) saturate(1.6);
    border-bottom: 1px solid #f1f1f1;
}

/* Logo */
.header__logo {
    display: flex;
    align-items: center;
    gap: 10px;
    font-family: var(--font-display);
    font-weight: 700;
    font-size: 1.15rem;
    letter-spacing: -0.3px;
    color: var(--text-primary);
    flex-shrink: 0;
    width: var(--sidebar-w);
    transition: opacity var(--t);
}

.header__logo:hover { opacity: 0.85; }

.header__logo-mark {
    width: 32px;
    height: 32px;
    /*background: var(--accent);
    border-radius: 8px;*/
    display: flex;
    align-items: center;
    justify-content: center;
    /*box-shadow: 0 0 16px var(--accent-glow);*/
    position: relative;
    overflow: hidden;
    flex-shrink: 0;
}

.header__logo-mark::after {
    content: '';
    position: absolute;
    inset: 0;
    /*background: linear-gradient(135deg, rgba(255,255,255,0.25) 0%, transparent 60%);*/
}

.header__logo-mark svg { width: 18px; height: 18px; color: #0d0f14; }

/* Right controls */
.header__right {
    margin-left: auto;
    display: flex;
    align-items: center;
    gap: 8px;
}

/* Icon buttons */
.header__icon-btn {
    width: 36px;
    height: 36px;
    border-radius: var(--r-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-secondary);
    transition: background var(--t), color var(--t);
}

.header__icon-btn:hover,
.header__icon-btn--active {
    background: var(--bg-elevated);
    color: var(--text-primary);
}

.header__icon-btn svg { width: 18px; height: 18px; }

/* Site selector pill */
.header__site-selector {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 12px 6px 10px;
    background: var(--bg-surface);
    border: 1px solid var(--border-subtle);
    border-radius: var(--r-sm);
    font-size: 0.82rem;
    font-weight: 500;
    color: var(--text-primary);
    transition: background var(--t), border-color var(--t);
    cursor: pointer;
    border: 1px solid var(--text-secondary);
}

.header__site-selector:hover {
    background: var(--bg-hover);
    border-color: var(--border-mid);
}

.header__site-dot {
    width: 7px;
    height: 7px;
    background: var(--green);
    border-radius: 50%;
    box-shadow: 0 0 6px var(--green);
    flex-shrink: 0;
}

.header__site-selector svg { width: 14px; height: 14px; color: var(--text-muted); }

/* Divider */
.header__divider {
    width: 1px;
    height: 22px;
    background: var(--border-subtle);
    margin: 0 4px;
}

/* Avatar */
.header__avatar {
    width: 34px;
    height: 34px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--accent) 0%, var(--violet) 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    font-family: var(--font-display);
    font-weight: 700;
    font-size: 0.75rem;
    color: var(--bg-base);
    cursor: pointer;
    flex-shrink: 0;
    transition: box-shadow var(--t);
}

.header__avatar:hover {
    box-shadow: 0 0 0 2px var(--accent-glow), 0 0 12px var(--accent-glow);
}


/* ══════════════════════════════════════════════════════════════════════════════
   LAYOUT SHELL
══════════════════════════════════════════════════════════════════════════════ */
.layout {
    display: flex;
    min-height: 100vh;
    padding-top: var(--header-h);
}


/* ══════════════════════════════════════════════════════════════════════════════
   SIDEBAR
══════════════════════════════════════════════════════════════════════════════ */
.sidebar {
    width: var(--sidebar-w);
    flex-shrink: 0;
    position: sticky;
    top: calc(var(--header-h) + 15px);
    height: calc(100vh - var(--sidebar-h));
    overflow-y: auto;
    padding: 20px 12px;
    border-right: 1px solid var(--border-subtle);
    background: var(--bg-surface);
    display: flex;
    flex-direction: column;
    gap: 2px;
    margin-left: 15px;
    border-radius: var(--r-lg);
}

.sidebar__section-label {
    font-size: 0.68rem;
    font-weight: 400;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--text-muted);
    padding: 12px 10px 8px;
}

.sidebar__nav-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 9px 10px;
    border-radius: var(--r-sm);
    font-size: 1rem;
    font-weight: 400;
    color: var(--text-secondary);
    transition: background var(--t), color var(--t);
    position: relative;
    cursor: pointer;
}

.sidebar__nav-item svg {
    width: 17px;
    height: 17px;
    flex-shrink: 0;
}

.sidebar__nav-item:hover {
    background: var(--accent-dim);
    color: var(--text-primary);
}

/* Active state */
.sidebar__nav-item--active {
    background: var(--accent-dim);
    color: var(--text-secondary);
    font-weight: 500;
}

.sidebar__nav-item--active::before {
    content: '';
    position: absolute;
    left: 0;
    top: 20%;
    bottom: 20%;
    width: 3px;
    background: var(--accent);
    border-radius: 0 3px 3px 0;
    box-shadow: 0 0 8px var(--accent);
}

/* Badge */
.sidebar__badge {
    margin-left: auto;
    font-size: 0.68rem;
    font-weight: 600;
    background: var(--accent-dim);
    color: var(--accent);
    padding: 1px 7px;
    border-radius: 99px;
}

.sidebar__badge--amber {
    background: var(--amber-dim);
    color: var(--amber);
}

/* Spacer + footer */
.sidebar__spacer { flex: 1; }

.sidebar__footer {
    border-top: 1px solid var(--border-subtle);
    padding-top: 12px;
}

.sidebar__footer .sidebar__nav-item { color: var(--text-muted); }

.sidebar__footer .sidebar__nav-item:hover {
    color: var(--red);
    background: rgba(239,68,68,0.08);
}


/* ══════════════════════════════════════════════════════════════════════════════
   MAIN CONTENT AREA
══════════════════════════════════════════════════════════════════════════════ */
.main {
    flex: 1;
    min-width: 0;
    padding: 28px 32px 48px;
    background: var(--bg-base);
    max-width: 1200px;
    margin: 0 auto;
}

/* Page header (title + sub + controls row) */
.page-header {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    margin-bottom: 28px;
    gap: 16px;
    flex-wrap: wrap;
}

.page-header__title {
    font-family: var(--font-display);
    font-size: 1.6rem;
    font-weight: 700;
    color: var(--text-primary);
    letter-spacing: -0.5px;
    line-height: 1.2;
}

.page-header__sub {
    font-size: 1rem;
    color: var(--text-muted);
    margin-top: 4px;
    font-weight: 300;
}

/* Date-range pill */
.date-pill {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 10px 14px;
    background: white;
    border: 1px solid var(--border-subtle);
    border-radius: var(--r-sm);
    font-size: 0.82rem;
    font-weight: 500;
    color: var(--text-secondary);
    transition: background var(--t), border-color var(--t), color var(--t);
    cursor: pointer;
}

.date-pill:hover {
    background: var(--bg-hover);
    border-color: var(--border-mid);
    color: var(--text-primary);
}

.date-pill svg { width: 14px; height: 14px; }


/* ══════════════════════════════════════════════════════════════════════════════
   SHARED COMPONENTS
══════════════════════════════════════════════════════════════════════════════ */

/* ── Card ──────────────────────────────────────────────────────────────────── */
.card {
    background: var(--bg-surface);
    border: 1px solid var(--border-subtle);
    border-radius: var(--r-lg);
    overflow: hidden;
    position: relative;
}

.card::before {
    content: '';
    position: absolute;
    top: 0; left: 0; right: 0;
    height: 1px;
    background: linear-gradient(90deg, transparent, rgba(255,255,255,0.07), transparent);
    pointer-events: none;
}

.card__head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 18px 22px 14px;
    /*border-bottom: 1px solid var(--border-subtle);*/
}

.card__title {
    font-family: var(--font-display);
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--text-primary);
}

.card__action {
    font-size: 0.78rem;
    color: var(--accent);
    font-weight: 500;
    transition: opacity var(--t);
}

.card__action:hover { opacity: 0.75; }

.card__body { padding: 18px 22px; }

/* ── Buttons ───────────────────────────────────────────────────────────────── */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 11px 22px;
    border-radius: var(--r-sm);
    font-size: 0.875rem;
    font-weight: 600;
    font-family: var(--font-body);
    transition: all var(--t);
    cursor: pointer;
    border: none;
}

.btn--primary {
    background: var(--accent);
    color: #0d0f14;
    box-shadow: 0 0 20px var(--accent-glow);
}

.btn--primary:hover {
    background: #00e8bb;
    box-shadow: 0 0 28px var(--accent-glow), 0 4px 16px var(--accent-glow);
    transform: translateY(-1px);
}

.btn--primary svg { width: 16px; height: 16px; }

.btn--ghost {
    background: var(--bg-elevated);
    color: var(--text-secondary);
    border: 1px solid var(--border-subtle);
}

.btn--ghost:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
    border-color: var(--border-mid);
}

/* ── Empty state ───────────────────────────────────────────────────────────── */
.empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 10px;
    padding: 48px 24px;
    color: var(--text-muted);
    text-align: center;
}

.empty-state svg           { width: 36px; height: 36px; opacity: 0.3; }
.empty-state__title        { font-weight: 500; font-size: 0.9rem; color: var(--text-secondary); }
.empty-state__sub          { font-size: 0.8rem; max-width: 240px; line-height: 1.6; }

/* ── Table list (top pages, referrers, etc.) ───────────────────────────────── */
.table-list { display: flex; flex-direction: column; }

.table-list__row {
    display: flex;
    align-items: center;
    padding: 11px 22px;
    gap: 12px;
    border-bottom: 1px solid var(--border-subtle);
    transition: background var(--t);
}

.table-list__row:last-child { border-bottom: none; }
.table-list__row:hover      { background: var(--bg-hover); }

.table-list__rank {
    font-size: 0.72rem;
    font-weight: 700;
    font-family: var(--font-display);
    color: var(--text-muted);
    width: 18px;
    flex-shrink: 0;
    text-align: center;
}

.table-list__label {
    flex: 1;
    min-width: 0;
    font-size: 0.83rem;
    color: var(--text-secondary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.table-list__label strong {
    display: block;
    color: var(--text-primary);
    font-weight: 400;
    font-size: 0.85rem;
}

.table-list__label span { font-size: 0.73rem; color: var(--text-secondary); }

.table-list__bar-wrap {
    width: 80px;
    height: 4px;
    background: var(--bg-active);
    border-radius: 99px;
    overflow: hidden;
    flex-shrink: 0;
}

.table-list__bar {
    height: 100%;
    background: var(--accent);
    border-radius: 99px;
    opacity: 0.7;
}

.table-list__count {
    font-size: 0.82rem;
    font-weight: 600;
    color: var(--text-primary);
    font-family: var(--font-display);
    flex-shrink: 0;
    width: 40px;
    text-align: right;
}

/* ── Code / snippet box ────────────────────────────────────────────────────── */
.code-box {
    background: var(--bg-elevated);
    border: 1px solid var(--border-mid);
    border-radius: var(--r-md);
    padding: 14px 16px;
    font-family: 'Courier New', monospace;
    font-size: 0.73rem;
    color: var(--accent);
    word-break: break-all;
    line-height: 1.7;
    position: relative;
}

.code-box__copy {
    position: absolute;
    top: 10px;
    right: 10px;
    background: var(--bg-active);
    border: 1px solid var(--border-mid);
    border-radius: var(--r-sm);
    padding: 4px 10px;
    font-size: 0.72rem;
    font-family: var(--font-body);
    color: var(--text-secondary);
    cursor: pointer;
    transition: background var(--t), color var(--t);
}

.code-box__copy:hover {
    background: var(--accent-dim);
    color: var(--accent);
}

/* ── Live badge ────────────────────────────────────────────────────────────── */
.live-badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 0.72rem;
    font-weight: 600;
    color: var(--green);
    text-transform: uppercase;
    letter-spacing: 0.06em;
}

.live-badge__dot {
    width: 7px;
    height: 7px;
    background: var(--green);
    border-radius: 50%;
    animation: pulse-dot 1.8s ease-in-out infinite;
}

@keyframes pulse-dot {
    0%, 100% { box-shadow: 0 0 0 0   rgba(34,197,94,0.5); }
    50%       { box-shadow: 0 0 0 5px rgba(34,197,94,0);   }
}

/* ── Content row (2-col grid used on multiple pages) ───────────────────────── */
.content-row {
    display: grid;
    grid-template-columns: 1fr 340px;
    gap: 20px;
    margin-bottom: 20px;
}

/* ── Page fade-in ──────────────────────────────────────────────────────────── */
@keyframes fade-up {
    from { opacity: 0; transform: translateY(10px); }
    to   { opacity: 1; transform: translateY(0); }
}

.main > * {
    animation: fade-up 0.4s ease both;
}

.main > *:nth-child(1) { animation-delay: 0.05s; }
.main > *:nth-child(2) { animation-delay: 0.10s; }
.main > *:nth-child(3) { animation-delay: 0.15s; }
.main > *:nth-child(4) { animation-delay: 0.20s; }
.main > *:nth-child(5) { animation-delay: 0.25s; }


/* ══════════════════════════════════════════════════════════════════════════════
   SITE SWITCHER
══════════════════════════════════════════════════════════════════════════════ */

/* Wrapper — provides the relative positioning anchor */
.site-switcher {
    position: relative;
}

/* The trigger pill — reuses existing .header__site-selector styles */
.site-switcher .header__site-selector {
    display: flex;
    align-items: center;
    gap: 8px;
    max-width: 200px;
}

.site-switcher__current {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 130px;
}

/* Dropdown panel */
.site-switcher__dropdown {
    position: fixed;
    top: calc(var(--header-h) + 8px);
    z-index: 300;
    min-width: 240px;
    background: var(--bg-surface);
    border: 1px solid #e8e8f0;
    border-radius: var(--r-lg);
    box-shadow: 0 8px 32px rgba(36,26,79,0.12), 0 2px 8px rgba(36,26,79,0.06);
    padding: 6px;
    display: none;
    flex-direction: column;
    gap: 2px;
}

.site-switcher__dropdown--open {
    display: flex;
    animation: switcher-in 180ms cubic-bezier(0.34,1.4,0.64,1) both;
}

@keyframes switcher-in {
    from { opacity: 0; transform: translateY(-6px) scale(0.97); }
    to   { opacity: 1; transform: translateY(0)    scale(1);    }
}

/* Section heading */
.site-switcher__heading {
    font-size: 0.68rem;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: #aaa8bf;
    padding: 8px 12px 4px;
}

/* Individual site row */
.site-switcher__item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    width: 100%;
    padding: 9px 12px;
    border-radius: var(--r-md);
    background: none;
    border: none;
    cursor: pointer;
    text-align: left;
    transition: background var(--t);
}

.site-switcher__item:hover {
    background: var(--bg-elevated);
}

.site-switcher__item--active {
    background: var(--accent-dim);
}

.site-switcher__item-info {
    display: flex;
    flex-direction: column;
    gap: 2px;
    min-width: 0;
}

.site-switcher__item-name {
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.site-switcher__item--active .site-switcher__item-name {
    color: var(--text-secondary);
    font-weight: 600;
}

.site-switcher__item-domain {
    font-size: 0.72rem;
    color: #aaa8bf;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.site-switcher__check {
    width: 15px;
    height: 15px;
    flex-shrink: 0;
    color: var(--text-secondary);
}

/* Footer / add site link */
.site-switcher__footer {
    border-top: 1px solid #f0f0f5;
    margin-top: 4px;
    padding-top: 4px;
}

.site-switcher__add {
    display: flex;
    align-items: center;
    gap: 8px;
    width: 100%;
    padding: 9px 12px;
    border-radius: var(--r-md);
    font-size: 0.83rem;
    font-weight: 500;
    color: var(--text-secondary);
    transition: background var(--t);
}

.site-switcher__add:hover {
    background: var(--bg-elevated);
}

.site-switcher__add svg {
    width: 14px;
    height: 14px;
    flex-shrink: 0;
}


/* ══════════════════════════════════════════════════════════════════════════════
   RESPONSIVE
══════════════════════════════════════════════════════════════════════════════ */
@media (max-width: 1100px) {
    .content-row { grid-template-columns: 1fr; }
}

@media (max-width: 768px) {
    :root { --sidebar-w: 0px; }

    .sidebar              { display: none; }
    .main                 { padding: 20px 16px 40px; }
    .header__logo         { width: auto; }
    .header__site-selector span { display: none; }
}

@media (max-width: 480px) {
    .stat-grid { grid-template-columns: 1fr; }
}
