/*
 * Spy design layer, on top of Filament (no build step: loaded as a plain file on every page).
 * Identity: signal teal on ink slate; Space Grotesk for headings and numbers, Inter for text.
 * Filament's own palette variables (--primary-*, --gray-*) drive most colours; this file adds the
 * shape (radii, spacing, depth) and Spy's own pieces (positions, scores, chips, cards).
 */
@import url('https://fonts.googleapis.com/css2?family=Space+Grotesk:wght@500;600;700&display=swap');

:root {
    --spy-radius: 14px;
    --spy-radius-sm: 9px;
    --spy-border: rgba(15, 23, 42, .08);
    --spy-border-strong: rgba(15, 23, 42, .14);
    --spy-card: #ffffff;
    --spy-card-soft: #f6f8fb;
    --spy-text: #0f172a;
    --spy-muted: #64748b;
    --spy-faint: #94a3b8;
    --spy-bg: #f3f6fa;
    --spy-shadow: 0 1px 2px rgba(15, 23, 42, .04), 0 4px 16px -6px rgba(15, 23, 42, .08);
    --spy-good: #0f9f6e;
    --spy-good-bg: rgba(16, 185, 129, .12);
    --spy-warn: #c2770c;
    --spy-warn-bg: rgba(245, 158, 11, .14);
    --spy-bad: #dc3545;
    --spy-bad-bg: rgba(239, 68, 68, .12);
    --spy-accent: #0d9b95;
    --spy-accent-bg: rgba(13, 155, 149, .11);
    --spy-heading: 'Space Grotesk', 'Inter', ui-sans-serif, system-ui, sans-serif;
}

.dark {
    --spy-border: rgba(148, 163, 184, .12);
    --spy-border-strong: rgba(148, 163, 184, .22);
    --spy-card: #0f1729;
    --spy-card-soft: #121c31;
    --spy-text: #e2e8f0;
    --spy-muted: #94a3b8;
    --spy-faint: #64748b;
    --spy-bg: #0a1020;
    --spy-shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 8px 24px -10px rgba(0, 0, 0, .5);
    --spy-good: #34d399;
    --spy-good-bg: rgba(52, 211, 153, .13);
    --spy-warn: #fbbf24;
    --spy-warn-bg: rgba(251, 191, 36, .13);
    --spy-bad: #f87171;
    --spy-bad-bg: rgba(248, 113, 113, .13);
    --spy-accent: #2dd4bf;
    --spy-accent-bg: rgba(45, 212, 191, .12);
}

/* ---------- Canvas ---------- */
body.fi-body {
    background: var(--spy-bg);
}
.dark body.fi-body {
    background: radial-gradient(1200px 600px at 85% -10%, rgba(45, 212, 191, .07), transparent 60%), var(--spy-bg);
}
.fi-main {
    padding-top: 1.25rem;
}

/* ---------- Page header ---------- */
.fi-header-heading {
    font-family: var(--spy-heading);
    font-weight: 700;
    letter-spacing: -.02em;
    font-size: 1.65rem;
    line-height: 1.2;
}
.fi-header-subheading {
    color: var(--spy-muted);
    max-width: 62rem;
    font-size: .92rem;
    line-height: 1.5;
    margin-top: .35rem;
}
.spy-heading-app {
    display: inline-flex;
    align-items: center;
    gap: .75rem;
}
.spy-heading-app img {
    width: 44px;
    height: 44px;
    border-radius: 12px;
    box-shadow: 0 0 0 1px var(--spy-border);
}

/* ---------- Sidebar & top bar ---------- */
.fi-sidebar {
    background: var(--spy-card);
    border-inline-end: 1px solid var(--spy-border);
}
.fi-sidebar-group-label {
    text-transform: uppercase;
    letter-spacing: .08em;
    font-size: .68rem !important;
    color: var(--spy-faint) !important;
}
.fi-sidebar-item-btn,
.fi-sidebar-item > a {
    border-radius: 10px;
}
.fi-sidebar-item.fi-active > a,
.fi-sidebar-item.fi-active .fi-sidebar-item-btn {
    background: var(--spy-accent-bg);
}
.fi-topbar > nav,
.fi-topbar {
    background: color-mix(in srgb, var(--spy-card) 85%, transparent);
    backdrop-filter: saturate(1.4) blur(10px);
    border-bottom: 1px solid var(--spy-border);
    box-shadow: none;
}
.fi-tenant-menu .fi-avatar,
.fi-tenant-menu img {
    border-radius: 8px;
}

/* ---------- Cards, sections, widgets ---------- */
.fi-section:not(.fi-section-not-contained):not(.fi-aside) {
    border-radius: var(--spy-radius);
    box-shadow: var(--spy-shadow);
    --tw-ring-color: var(--spy-border);
}
.fi-section-header-heading {
    font-family: var(--spy-heading);
    font-weight: 600;
    letter-spacing: -.01em;
}
.fi-section-header-description {
    color: var(--spy-muted);
}
.fi-wi-stats-overview-stat {
    border-radius: var(--spy-radius);
    box-shadow: var(--spy-shadow);
}
.fi-wi-stats-overview-stat-label {
    text-transform: uppercase;
    letter-spacing: .06em;
    font-size: .7rem;
    color: var(--spy-muted);
}
.fi-wi-stats-overview-stat-value {
    font-family: var(--spy-heading);
    font-weight: 700;
    letter-spacing: -.02em;
    font-size: 1.6rem;
}
.fi-wi-stats-overview-stat-description {
    font-size: .8rem;
}
.fi-wi-chart .fi-section-header-heading {
    font-size: .95rem;
}

/* ---------- Tables ---------- */
.fi-ta-ctn {
    border-radius: var(--spy-radius);
    box-shadow: var(--spy-shadow);
    overflow: hidden;
}
.fi-ta-header-cell {
    text-transform: uppercase;
    letter-spacing: .06em;
    font-size: .68rem !important;
    color: var(--spy-muted);
}
.fi-ta-row:hover > td {
    background: color-mix(in srgb, var(--spy-accent-bg) 45%, transparent);
}
.fi-badge {
    border-radius: 999px;
}
.fi-empty-state-heading {
    font-family: var(--spy-heading);
}

/* ---------- Buttons & modals ---------- */
.fi-btn {
    border-radius: 10px;
}
.fi-modal-window {
    border-radius: 18px;
}
.fi-modal-heading {
    font-family: var(--spy-heading);
}

/* ---------- Login ---------- */
.fi-simple-layout {
    background:
        radial-gradient(900px 500px at 15% 0%, rgba(13, 155, 149, .14), transparent 60%),
        radial-gradient(700px 500px at 100% 100%, rgba(59, 130, 246, .10), transparent 60%),
        var(--spy-bg);
}
.fi-simple-main {
    border-radius: 20px;
    box-shadow: var(--spy-shadow);
}
.spy-login-tagline {
    text-align: center;
    color: var(--spy-muted);
    font-size: .9rem;
    margin: -.5rem 0 .5rem;
}

/* ---------- Spy pieces ---------- */
.spy-muted { color: var(--spy-muted); }
.spy-faint { color: var(--spy-faint); }
.spy-num { font-family: var(--spy-heading); font-variant-numeric: tabular-nums; }

/* Position pill: #1–3 / top 10 / top 30 / out */
.spy-pos {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 2.6rem;
    padding: .12rem .5rem;
    border-radius: 999px;
    font-family: var(--spy-heading);
    font-weight: 600;
    font-size: .82rem;
    font-variant-numeric: tabular-nums;
    background: var(--spy-card-soft);
    color: var(--spy-text);
    box-shadow: inset 0 0 0 1px var(--spy-border);
}
.spy-pos.is-top3 { background: var(--spy-accent); color: #fff; box-shadow: none; }
.dark .spy-pos.is-top3 { color: #04221f; }
.spy-pos.is-top10 { background: var(--spy-good-bg); color: var(--spy-good); box-shadow: none; }
.spy-pos.is-out { color: var(--spy-faint); font-weight: 500; }

/* Change: ▲ up (better), ▼ down */
.spy-delta { font-family: var(--spy-heading); font-weight: 600; font-size: .82rem; font-variant-numeric: tabular-nums; }
.spy-delta.is-up { color: var(--spy-good); }
.spy-delta.is-down { color: var(--spy-bad); }
.spy-delta.is-flat { color: var(--spy-faint); }

/* Score 0–100 with a small bar */
.spy-score { display: inline-flex; align-items: center; gap: .5rem; min-width: 5.5rem; }
.spy-score b { font-family: var(--spy-heading); font-weight: 600; font-size: .82rem; min-width: 1.6rem; text-align: right; font-variant-numeric: tabular-nums; }
.spy-score i { display: block; height: 6px; width: 3.4rem; border-radius: 99px; background: var(--spy-card-soft); box-shadow: inset 0 0 0 1px var(--spy-border); overflow: hidden; }
.spy-score i::after { content: ''; display: block; height: 100%; width: var(--v, 0%); border-radius: 99px; background: var(--c, var(--spy-accent)); }

/* Chips (status bar, meta) */
.spy-chip {
    display: inline-flex;
    align-items: center;
    gap: .4rem;
    padding: .28rem .65rem;
    border-radius: 999px;
    font-size: .78rem;
    background: var(--spy-card);
    box-shadow: inset 0 0 0 1px var(--spy-border);
    color: var(--spy-text);
    white-space: nowrap;
}
.spy-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--spy-faint); flex: none; }
.spy-dot.is-good { background: var(--spy-good); box-shadow: 0 0 0 3px var(--spy-good-bg); }
.spy-dot.is-warn { background: var(--spy-warn); box-shadow: 0 0 0 3px var(--spy-warn-bg); }
.spy-dot.is-bad { background: var(--spy-bad); box-shadow: 0 0 0 3px var(--spy-bad-bg); }

.spy-statusbar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: .45rem;
    margin-bottom: 1.1rem;
}
.spy-statusbar .spy-latest {
    flex: 1 1 18rem;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    color: var(--spy-muted);
    font-size: .78rem;
    padding: 0 .3rem;
}
.spy-statusbar a { color: var(--spy-accent); font-size: .78rem; font-weight: 600; }

/* App cards (All my apps) */
.spy-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 300px), 1fr)); gap: 1rem; }
.spy-card {
    display: block;
    border-radius: var(--spy-radius);
    background: var(--spy-card);
    box-shadow: var(--spy-shadow), inset 0 0 0 1px var(--spy-border);
    padding: 1.1rem 1.2rem;
    transition: transform .15s ease, box-shadow .15s ease;
    color: var(--spy-text);
}
a.spy-card:hover { transform: translateY(-2px); box-shadow: var(--spy-shadow), inset 0 0 0 1px var(--spy-accent); }
.spy-card-head { display: flex; gap: .8rem; align-items: center; margin-bottom: .9rem; }
.spy-card-head img { width: 46px; height: 46px; border-radius: 12px; box-shadow: 0 0 0 1px var(--spy-border); }
.spy-card-title { font-family: var(--spy-heading); font-weight: 600; font-size: 1.02rem; line-height: 1.25; }
.spy-card-sub { color: var(--spy-muted); font-size: .76rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 15rem; }
.spy-kv { display: grid; grid-template-columns: repeat(3, 1fr); gap: .6rem; }
.spy-kv div { background: var(--spy-card-soft); border-radius: var(--spy-radius-sm); padding: .5rem .6rem; }
.spy-kv dt { font-size: .66rem; text-transform: uppercase; letter-spacing: .06em; color: var(--spy-muted); }
.spy-kv dd { font-family: var(--spy-heading); font-weight: 600; font-size: 1.02rem; margin: .1rem 0 0; font-variant-numeric: tabular-nums; }
.spy-card-add {
    display: flex; flex-direction: column; align-items: center; justify-content: center; gap: .4rem; min-height: 12rem;
    border-radius: var(--spy-radius); border: 1.5px dashed var(--spy-border-strong); color: var(--spy-muted); font-weight: 600;
}
.spy-card-add:hover { border-color: var(--spy-accent); color: var(--spy-accent); }

/* Lists of apps inside sections */
.spy-applist { width: 100%; border-collapse: collapse; font-size: .85rem; }
.spy-applist td { padding: .45rem .5rem; border-top: 1px solid var(--spy-border); vertical-align: middle; }
.spy-applist tr:first-child td { border-top: 0; }
.spy-applist img { width: 30px; height: 30px; border-radius: 8px; box-shadow: 0 0 0 1px var(--spy-border); }
.spy-applist .is-mine td { background: var(--spy-good-bg); }
.spy-applist .is-rival td { background: var(--spy-warn-bg); }
.spy-new { display: inline-block; font-size: .66rem; font-weight: 700; letter-spacing: .04em; padding: .05rem .4rem; border-radius: 99px; background: var(--spy-accent); color: #fff; vertical-align: middle; }
.dark .spy-new { color: #04221f; }

/* Digest columns */
.spy-digest { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 240px), 1fr)); gap: 1.2rem; }
.spy-digest h4 { font-family: var(--spy-heading); font-weight: 600; margin: 0 0 .5rem; font-size: .95rem; }
.spy-digest ul { margin: 0; padding-left: 1.1rem; font-size: .85rem; }
.spy-digest li { margin-bottom: .55rem; }
.spy-digest q { display: block; color: var(--spy-muted); font-style: italic; margin-top: .1rem; }

/* Runs panel (Keywords) */
.spy-runs { display: flex; flex-wrap: wrap; gap: 1.5rem 2.5rem; align-items: flex-start; justify-content: space-between; }
.spy-runs-big { font-family: var(--spy-heading); font-weight: 700; font-size: 1.7rem; letter-spacing: -.02em; }
.spy-progress { height: 7px; width: 16rem; max-width: 100%; border-radius: 99px; background: var(--spy-card-soft); box-shadow: inset 0 0 0 1px var(--spy-border); overflow: hidden; margin-top: .45rem; }
.spy-progress > span { display: block; height: 100%; background: var(--spy-accent); border-radius: 99px; transition: width .4s ease; }
.spy-runs table { font-size: .8rem; border-collapse: collapse; }
.spy-runs td { padding: .2rem .9rem .2rem 0; color: var(--spy-muted); }
.spy-runs td:first-child { color: var(--spy-text); }

/* Fields on custom pages (Listing helper) */
.spy-field {
    width: 100%;
    border-radius: 10px;
    border: 1px solid var(--spy-border-strong);
    background: var(--spy-card);
    color: var(--spy-text);
    padding: .55rem .75rem;
    font-size: .9rem;
    margin-top: .35rem;
}
.spy-field:focus { outline: none; border-color: var(--spy-accent); box-shadow: 0 0 0 3px var(--spy-accent-bg); }
.spy-label { font-size: .8rem; font-weight: 600; display: flex; justify-content: space-between; gap: .5rem; }
.spy-count { font-weight: 500; font-variant-numeric: tabular-nums; color: var(--spy-muted); }
.spy-count.is-near { color: var(--spy-warn); }
.spy-count.is-over { color: var(--spy-bad); }
.spy-cover { width: 100%; border-collapse: collapse; font-size: .84rem; }
.spy-cover th { text-align: left; font-size: .66rem; text-transform: uppercase; letter-spacing: .06em; color: var(--spy-muted); padding: .3rem .4rem; }
.spy-cover td { padding: .38rem .4rem; border-top: 1px solid var(--spy-border); }
.spy-yes { color: var(--spy-good); font-weight: 700; }
.spy-no { color: var(--spy-faint); }
.spy-note { font-size: .88rem; color: var(--spy-muted); margin: 0 0 1rem; max-width: 62rem; line-height: 1.55; }

@media (max-width: 640px) {
    .fi-header-heading { font-size: 1.35rem; }
    .spy-kv { grid-template-columns: repeat(2, 1fr); }
}

/* ---------- Top bar: app switcher ---------- */
.spy-switcher { position: relative; margin-inline-start: 1rem; }
.spy-switcher-btn {
    display: inline-flex; align-items: center; gap: .55rem; max-width: 22rem;
    padding: .32rem .7rem .32rem .35rem; border-radius: 12px;
    background: var(--spy-card-soft); box-shadow: inset 0 0 0 1px var(--spy-border);
    color: var(--spy-text); font-weight: 600; font-size: .88rem; cursor: pointer;
    transition: box-shadow .15s ease;
}
.spy-switcher-btn:hover { box-shadow: inset 0 0 0 1px var(--spy-accent); }
.spy-switcher-btn img { width: 28px; height: 28px; border-radius: 8px; box-shadow: 0 0 0 1px var(--spy-border); flex: none; }
.spy-switcher-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.spy-switcher-panel {
    position: absolute; top: calc(100% + .45rem); inset-inline-start: 0; z-index: 40; width: 21rem; max-height: 70vh; overflow: auto;
    padding: .45rem; border-radius: 14px; background: var(--spy-card); box-shadow: 0 12px 40px -12px rgba(15, 23, 42, .35), inset 0 0 0 1px var(--spy-border);
}
.spy-switcher-label { font-size: .66rem; text-transform: uppercase; letter-spacing: .08em; color: var(--spy-faint); padding: .35rem .55rem .25rem; }
.spy-switcher-item { display: flex; align-items: center; gap: .65rem; padding: .45rem .55rem; border-radius: 10px; color: var(--spy-text); }
.spy-switcher-item:hover { background: var(--spy-card-soft); }
.spy-switcher-item.is-current { background: var(--spy-accent-bg); }
.spy-switcher-item img, .spy-switcher-noicon { width: 32px; height: 32px; border-radius: 9px; box-shadow: 0 0 0 1px var(--spy-border); flex: none; background: var(--spy-card-soft); }
.spy-switcher-item-name { display: block; font-weight: 600; font-size: .86rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.spy-switcher-item-sub { display: block; font-size: .72rem; color: var(--spy-muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 15rem; }
.spy-switcher-check { margin-inline-start: auto; color: var(--spy-accent); font-weight: 700; }
.spy-switcher-sep { height: 1px; background: var(--spy-border); margin: .4rem .3rem; }
.spy-switcher-link { display: block; padding: .5rem .6rem; border-radius: 10px; font-size: .85rem; font-weight: 600; color: var(--spy-text); }
.spy-switcher-link:hover { background: var(--spy-card-soft); }
.spy-switcher-link.is-add { color: var(--spy-accent); }
[x-cloak] { display: none !important; }

/* ---------- Top bar: status ---------- */
.spy-topstatus { display: flex; align-items: center; gap: .4rem; margin-inline-end: .6rem; }
.spy-topstatus .spy-chip { padding: .26rem .6rem; font-size: .76rem; }
.spy-chip-link { color: var(--spy-accent) !important; font-weight: 600; }
.spy-chip-link:hover { box-shadow: inset 0 0 0 1px var(--spy-accent); }
.spy-pulse { animation: spy-pulse 1.6s ease-in-out infinite; }
@keyframes spy-pulse { 50% { box-shadow: 0 0 0 5px var(--spy-good-bg); } }
@media (max-width: 1100px) { .spy-hide-md { display: none !important; } }
@media (max-width: 720px) { .spy-hide-sm { display: none !important; } .spy-switcher-name { max-width: 7rem; } .spy-switcher { margin-inline-start: .4rem; } }

/* ---------- Sidebar: compact, no visible scrollbar ---------- */
.fi-sidebar-nav { scrollbar-width: none; padding-top: 1rem; }
.fi-sidebar-nav::-webkit-scrollbar { display: none; }
.fi-sidebar-nav-groups { gap: 1.1rem; }
.fi-sidebar-group-items { gap: .1rem; }
.fi-sidebar-item > a, .fi-sidebar-item-btn { padding-block: .45rem; }
