:root {
    --bg: #0a0e14;
    --bg-elevated: rgba(16, 21, 31, 0.82);
    --bg-card: rgba(19, 26, 38, 0.78);
    --border: #1f2937;
    --border-soft: #1a2130;
    --text: #e6ebf2;
    --text-dim: #8b96a8;
    --text-faint: #5b6577;
    --accent: #a855f7;
    --accent-soft: rgba(168, 85, 247, 0.14);
    --green: #34d399;
    --green-soft: rgba(52, 211, 153, 0.12);
    --yellow: #fbbf24;
    --yellow-soft: rgba(251, 191, 36, 0.12);
    --red: #f87171;
    --red-soft: rgba(248, 113, 113, 0.14);
    --radius: 14px;
    --shadow-card: 0 1px 2px rgba(0,0,0,0.4), 0 8px 24px -8px rgba(0,0,0,0.5);
    --mono: "SF Mono", "JetBrains Mono", "Fira Code", ui-monospace, Consolas, monospace;
    --sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Inter, Roboto, sans-serif;
}

* { box-sizing: border-box; }

html, body {
    margin: 0;
    padding: 0;
    background: var(--bg);
    color: var(--text);
    font-family: var(--sans);
    min-height: 100vh;
}

/* Branded backdrop: the SORA hero art, fixed and heavily dimmed so it reads
   as atmosphere rather than competing with the data. Sits in a pseudo-element
   on <body> so it never scrolls with content and never intercepts clicks. */
body::before {
    content: "";
    position: fixed;
    inset: 0;
    z-index: -2;
    background:
        url("/static/img/sora-hero.jpg") no-repeat center 8% / cover;
    opacity: 0.16;
    filter: saturate(1.1);
    pointer-events: none;
}

/* Gradient veil over the art: keeps text contrast intact at the top where
   the artwork is brightest, and fades the image out toward the content. */
body::after {
    content: "";
    position: fixed;
    inset: 0;
    z-index: -1;
    background: linear-gradient(
        180deg,
        rgba(10, 14, 20, 0.55) 0%,
        rgba(10, 14, 20, 0.86) 45%,
        rgba(10, 14, 20, 0.97) 100%
    );
    pointer-events: none;
}

a { color: inherit; text-decoration: none; }

.shell { min-height: 100vh; display: flex; flex-direction: column; }

.topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 18px 32px;
    border-bottom: 1px solid var(--border-soft);
    background: rgba(10, 14, 20, 0.7);
    backdrop-filter: blur(10px);
    position: sticky;
    top: 0;
    z-index: 10;
}

.brand {
    font-weight: 700;
    font-size: 1.15rem;
    letter-spacing: -0.02em;
    display: flex;
    align-items: center;
    gap: 8px;
}
.brand-mark { color: var(--accent); }

.topnav a {
    color: var(--text-dim);
    font-size: 0.9rem;
    padding: 6px 12px;
    border-radius: 8px;
    transition: background 0.15s, color 0.15s;
}
.topnav a:hover { background: var(--bg-elevated); color: var(--text); }

.container {
    max-width: 1180px;
    width: 100%;
    margin: 0 auto;
    padding: 32px 24px 64px;
    flex: 1;
}

/* --- Login --- */
.login-hero {
    width: 128px;
    height: 128px;
    border-radius: 50%;
    margin: 0 auto 18px;
    background: url("/static/img/sora-hero.jpg") no-repeat center 18% / 190%;
    border: 1px solid rgba(168, 85, 247, 0.4);
    box-shadow: 0 0 30px rgba(168, 85, 247, 0.28);
}

.login-screen {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
}
.login-card {
    width: 100%;
    max-width: 360px;
    background: linear-gradient(180deg, var(--bg-card), var(--bg-elevated));
    border: 1px solid var(--border);
    border-radius: 18px;
    padding: 36px 32px;
    box-shadow: var(--shadow-card);
    text-align: center;
}
.login-mark {
    font-size: 2rem;
    color: var(--accent);
    margin-bottom: 8px;
}
.login-card h1 { margin: 0 0 6px; font-size: 1.4rem; letter-spacing: -0.02em; }
.login-sub { color: var(--text-dim); font-size: 0.85rem; margin: 0 0 24px; }
.login-error {
    background: var(--red-soft);
    color: var(--red);
    border-radius: 8px;
    padding: 8px 12px;
    font-size: 0.85rem;
    margin-bottom: 16px;
}
.login-card label { display: block; text-align: left; font-size: 0.8rem; color: var(--text-dim); margin-bottom: 6px; }
.login-card input {
    width: 100%;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 11px 14px;
    color: var(--text);
    font-size: 0.95rem;
    margin-bottom: 20px;
}
.login-card input:focus { outline: none; border-color: var(--accent); }
.login-card button {
    width: 100%;
    padding: 12px;
    border-radius: 10px;
    border: none;
    background: linear-gradient(135deg, var(--accent), #7c3aed);
    color: #fff;
    font-weight: 600;
    font-size: 0.95rem;
    cursor: pointer;
    transition: opacity 0.15s;
}
.login-card button:hover { opacity: 0.9; }

/* --- Page head --- */
.page-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    margin-bottom: 22px;
    gap: 16px;
    flex-wrap: wrap;
}
.page-head h1 { margin: 0 0 4px; font-size: 1.6rem; letter-spacing: -0.02em; }
.muted { color: var(--text-dim); font-size: 0.9rem; margin: 0; }
.live-dot {
    display: flex; align-items: center; gap: 8px;
    font-size: 0.8rem; color: var(--green);
    background: var(--green-soft);
    padding: 6px 12px; border-radius: 999px;
    border: 1px solid rgba(52,211,153,0.25);
}
.dot { width: 7px; height: 7px; border-radius: 50%; background: var(--green); box-shadow: 0 0 8px var(--green); animation: pulse 1.6s infinite; }
@keyframes pulse { 0%,100% { opacity: 1; } 50% { opacity: 0.35; } }

/* --- Category / freshness tab strips (second-level nav) --- */
.tab-group { margin-bottom: 16px; }
.tab-group-label {
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--text-faint);
    margin-bottom: 8px;
}
.cat-tabs {
    display: flex;
    gap: 8px;
    overflow-x: auto;
    padding-bottom: 4px;
    scrollbar-width: thin;
}
.cat-tab.fresh.active { border-color: var(--green); background: var(--green-soft); }
.cat-tab.fresh.active .cat-tab-count { color: var(--green); border-color: rgba(52,211,153,0.35); }
.cat-tab {
    display: flex;
    align-items: center;
    gap: 7px;
    flex: 0 0 auto;
    padding: 9px 14px;
    border-radius: 10px;
    border: 1px solid var(--border);
    background: var(--bg-card);
    font-size: 0.85rem;
    color: var(--text-dim);
    white-space: nowrap;
    transition: border-color 0.15s, color 0.15s, background 0.15s;
}
.cat-tab:hover { color: var(--text); border-color: var(--text-faint); }
.cat-tab.active {
    color: var(--text);
    border-color: var(--accent);
    background: var(--accent-soft);
    font-weight: 600;
}
.cat-tab-emoji { font-size: 0.95rem; }
.cat-tab-count {
    font-family: var(--mono);
    font-size: 0.72rem;
    background: var(--bg);
    border: 1px solid var(--border-soft);
    border-radius: 999px;
    padding: 1px 7px;
    color: var(--text-dim);
}
.cat-tab.active .cat-tab-count { color: var(--accent); border-color: rgba(168,85,247,0.4); }

/* --- Signal chain (decision path on detail page) --- */
.chain { display: flex; flex-direction: column; gap: 0; }
.chain-step { display: flex; gap: 12px; }
.chain-rail { display: flex; flex-direction: column; align-items: center; flex: 0 0 18px; }
.chain-dot {
    width: 11px; height: 11px; border-radius: 50%;
    background: var(--green); flex: 0 0 auto; margin-top: 5px;
    box-shadow: 0 0 0 3px rgba(52,211,153,0.15);
}
.chain-step.is-neutral .chain-dot { background: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.chain-step.is-final .chain-dot { background: var(--yellow); box-shadow: 0 0 0 3px rgba(251,191,36,0.15); }
.chain-line { width: 2px; flex: 1 1 auto; background: var(--border); min-height: 14px; margin-top: 3px; }
.chain-step:last-child .chain-line { display: none; }
.chain-body { padding-bottom: 16px; flex: 1; }
.chain-title { font-size: 0.85rem; font-weight: 600; margin-bottom: 3px; }
.chain-detail { font-size: 0.8rem; color: var(--text-dim); line-height: 1.45; }
.chain-detail .mono { color: var(--text); }

/* --- Filters --- */
.filters {
    display: flex;
    flex-wrap: wrap;
    gap: 14px;
    align-items: flex-end;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 18px;
    margin-bottom: 26px;
}
.filter-field { display: flex; flex-direction: column; gap: 6px; min-width: 130px; }
.filter-field label { font-size: 0.75rem; color: var(--text-dim); }
.filter-field input, .filter-field select {
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 9px 10px;
    color: var(--text);
    font-size: 0.88rem;
}
.filter-field input:focus, .filter-field select:focus { outline: none; border-color: var(--accent); }
.btn-apply {
    background: var(--accent-soft);
    color: var(--accent);
    border: 1px solid rgba(168,85,247,0.4);
    border-radius: 8px;
    padding: 10px 18px;
    font-weight: 600;
    font-size: 0.88rem;
    cursor: pointer;
    transition: background 0.15s;
}
.btn-apply:hover { background: rgba(168,85,247,0.25); }

.empty-state {
    text-align: center;
    color: var(--text-dim);
    padding: 60px 20px;
    border: 1px dashed var(--border);
    border-radius: var(--radius);
}

/* --- Signal grid / cards --- */
.signal-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 16px;
}
.signal-card {
    display: block;
    backdrop-filter: blur(6px);
    background: linear-gradient(160deg, var(--bg-card) 0%, var(--bg-elevated) 100%);
    border: 1px solid var(--border);
    border-left: 3px solid var(--border);
    border-radius: var(--radius);
    padding: 18px;
    box-shadow: var(--shadow-card);
    transition: transform 0.15s ease, border-color 0.15s ease, box-shadow 0.15s ease;
}
.signal-card:hover { transform: translateY(-2px); box-shadow: 0 4px 8px rgba(0,0,0,0.4), 0 16px 32px -12px rgba(0,0,0,0.6); }
.signal-card.tier-green { border-left-color: var(--green); }
.signal-card.tier-yellow { border-left-color: var(--yellow); }
.signal-card.tier-red { border-left-color: var(--red); }

.signal-card-top { display: flex; justify-content: space-between; align-items: center; margin-bottom: 12px; }
.signal-time { font-size: 0.75rem; color: var(--text-faint); }

.score-pill {
    font-weight: 700;
    font-size: 0.85rem;
    padding: 4px 10px;
    border-radius: 999px;
}
.score-pill.tier-green { background: var(--green-soft); color: var(--green); }
.score-pill.tier-yellow { background: var(--yellow-soft); color: var(--yellow); }
.score-pill.tier-red { background: var(--red-soft); color: var(--red); }
.score-pill.big { font-size: 1.05rem; padding: 8px 16px; }

.signal-question {
    font-size: 0.98rem;
    font-weight: 600;
    line-height: 1.35;
    margin-bottom: 12px;
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.signal-meta { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 14px; }
.badge {
    font-size: 0.72rem;
    color: var(--text-dim);
    background: var(--bg);
    border: 1px solid var(--border);
    padding: 3px 10px;
    border-radius: 999px;
}
.badge.outcome { color: var(--accent); border-color: rgba(168,85,247,0.35); }
.badge.notified { color: var(--green); border-color: rgba(52,211,153,0.3); }
.badge.cluster { color: var(--red); border-color: rgba(248,113,113,0.45); background: var(--red-soft); font-weight: 600; }
.badge.correct { color: var(--green); border-color: rgba(52,211,153,0.4); background: var(--green-soft); }
.badge.wrong { color: var(--text-dim); border-color: var(--border); }

.signal-stats {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 10px 8px;
    padding-top: 12px;
    border-top: 1px solid var(--border-soft);
    margin-bottom: 12px;
}
.stat-label { display: block; font-size: 0.68rem; color: var(--text-faint); margin-bottom: 3px; }
.stat-value { display: block; font-size: 0.88rem; font-weight: 600; }

.signal-wallet { font-size: 0.78rem; color: var(--text-dim); }

.mono { font-family: var(--mono); }

/* --- Detail page --- */
.back-link { display: inline-block; color: var(--text-dim); font-size: 0.85rem; margin-bottom: 18px; }
.back-link:hover { color: var(--text); }

.detail-head {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-left: 4px solid var(--border);
    border-radius: var(--radius);
    padding: 26px;
    margin-bottom: 24px;
}
.detail-head.tier-green { border-left-color: var(--green); }
.detail-head.tier-yellow { border-left-color: var(--yellow); }
.detail-head.tier-red { border-left-color: var(--red); }
.detail-head h1 { font-size: 1.35rem; margin: 14px 0; line-height: 1.4; }
.external-link { color: var(--accent); font-size: 0.88rem; display: inline-block; margin-top: 10px; }

.detail-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 16px;
}
.panel {
    backdrop-filter: blur(6px);
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 20px;
}
.panel h2 { font-size: 0.95rem; margin: 0 0 14px; color: var(--text-dim); text-transform: uppercase; letter-spacing: 0.04em; font-weight: 600; }
.kv { display: flex; justify-content: space-between; align-items: center; padding: 8px 0; border-bottom: 1px solid var(--border-soft); font-size: 0.88rem; gap: 12px; }
.kv:last-child { border-bottom: none; }
.kv span:first-child { color: var(--text-dim); }
.kv.total span:last-child { color: var(--accent); font-weight: 700; }
.kv.links { justify-content: flex-start; gap: 20px; }
.kv.links a { color: var(--accent); }

/* --- Tab navigation --- */
.tabnav {
    display: flex;
    gap: 4px;
    background: var(--bg-elevated);
    border: 1px solid var(--border-soft);
    border-radius: 999px;
    padding: 4px;
}
.tabnav a {
    padding: 7px 16px;
    border-radius: 999px;
    font-size: 0.85rem;
    color: var(--text-dim);
    transition: background 0.15s, color 0.15s;
    white-space: nowrap;
}
.tabnav a:hover { color: var(--text); }
.tabnav a.active { background: var(--accent-soft); color: var(--accent); font-weight: 600; }

/* --- Favorite star toggle --- */
.signal-card-wrap { position: relative; }
.fav-toggle {
    position: absolute;
    top: 14px;
    right: 14px;
    z-index: 2;
    background: rgba(10, 14, 20, 0.55);
    border: 1px solid var(--border);
    color: var(--text-faint);
    border-radius: 999px;
    width: 30px;
    height: 30px;
    font-size: 1rem;
    line-height: 1;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: color 0.15s, border-color 0.15s, transform 0.1s;
}
.fav-toggle:hover { color: var(--yellow); border-color: rgba(251, 191, 36, 0.4); transform: scale(1.08); }
.fav-toggle.active { color: var(--yellow); border-color: rgba(251, 191, 36, 0.5); }
.fav-toggle.big { position: static; width: 38px; height: 38px; font-size: 1.3rem; }
.detail-head-top { display: flex; align-items: center; justify-content: space-between; gap: 12px; }

/* --- Overview stat cards --- */
.stat-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
    gap: 14px;
    margin-bottom: 16px;
}
.stat-card {
    backdrop-filter: blur(6px);
    background: linear-gradient(160deg, var(--bg-card) 0%, var(--bg-elevated) 100%);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 16px 18px;
    box-shadow: var(--shadow-card);
    display: flex;
    flex-direction: column;
    gap: 8px;
}
.stat-card.accent { border-left: 3px solid var(--accent); }
.stat-card-label { font-size: 0.76rem; color: var(--text-dim); }
.stat-card-value { font-size: 1.7rem; font-weight: 700; letter-spacing: -0.02em; }
.tier-text-green { color: var(--green); }
.tier-text-yellow { color: var(--yellow); }
.tier-text-red { color: var(--red); }

.overview-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 16px;
    margin-top: 4px;
}
.panel.wide { grid-column: 1 / -1; }

/* --- Donut chart (pure CSS conic-gradient) --- */
.donut-row { display: flex; align-items: center; gap: 28px; flex-wrap: wrap; }
.donut {
    width: 140px;
    height: 140px;
    border-radius: 50%;
    position: relative;
    flex-shrink: 0;
}
.donut-hole {
    position: absolute;
    inset: 18px;
    border-radius: 50%;
    background: var(--bg-card);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}
.donut-hole span { font-size: 1.3rem; font-weight: 700; }
.donut-hole small { font-size: 0.68rem; color: var(--text-dim); }
.donut-legend { display: flex; flex-direction: column; gap: 10px; }
.legend-item { display: flex; align-items: center; gap: 8px; font-size: 0.85rem; color: var(--text-dim); }
.legend-item .mono { margin-left: 4px; color: var(--text); font-weight: 600; }
.legend-dot { width: 10px; height: 10px; border-radius: 50%; display: inline-block; }
.tier-dot-green { background: var(--green); }
.tier-dot-yellow { background: var(--yellow); }
.tier-dot-red { background: var(--red); }

/* --- Horizontal bar list (top categories) --- */
.bar-list { display: flex; flex-direction: column; gap: 12px; }
.bar-row { display: grid; grid-template-columns: 130px 1fr 34px; align-items: center; gap: 10px; }
.bar-row-link { border-radius: 8px; padding: 3px 4px; margin: -3px -4px; transition: background 0.15s; }
.bar-row-link:hover { background: var(--bg-elevated); }
.bar-row-link:hover .bar-label { color: var(--text); }
.bar-label { font-size: 0.82rem; color: var(--text-dim); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bar-track { height: 8px; background: var(--bg); border-radius: 999px; overflow: hidden; border: 1px solid var(--border-soft); }
.bar-fill { height: 100%; border-radius: 999px; background: linear-gradient(90deg, var(--accent), #d8b4fe); }
.bar-value { font-size: 0.8rem; text-align: right; color: var(--text-dim); }

/* --- Hourly bar chart --- */
.hourly-chart {
    display: flex;
    align-items: flex-end;
    gap: 3px;
    height: 120px;
    padding-top: 8px;
}
.hourly-bar {
    flex: 1;
    min-width: 3px;
    background: linear-gradient(180deg, var(--accent) 0%, rgba(109,140,255,0.25) 100%);
    border-radius: 3px 3px 0 0;
    transition: opacity 0.15s;
}
.hourly-bar:hover { opacity: 0.75; }
.hourly-axis { display: flex; justify-content: space-between; margin-top: 8px; font-size: 0.72rem; color: var(--text-faint); }

/* --- Data table (top wallets) --- */
.table-scroll { overflow-x: auto; }
.data-table { width: 100%; border-collapse: collapse; font-size: 0.85rem; }
.data-table th {
    text-align: left;
    color: var(--text-faint);
    font-weight: 600;
    text-transform: uppercase;
    font-size: 0.68rem;
    letter-spacing: 0.04em;
    padding: 0 10px 10px;
    border-bottom: 1px solid var(--border-soft);
}
.data-table td { padding: 10px; border-bottom: 1px solid var(--border-soft); }
.data-table tr:last-child td { border-bottom: none; }
.data-table td a { color: var(--accent); }

@media (max-width: 900px) {
    .overview-grid { grid-template-columns: 1fr; }
    .panel.wide { grid-column: auto; }
}

@media (max-width: 640px) {
    .topbar { padding: 14px 16px; flex-wrap: wrap; gap: 10px; }
    .tabnav { order: 3; width: 100%; justify-content: center; }
    .container { padding: 20px 14px 48px; }
    .filters { flex-direction: column; align-items: stretch; }
    .signal-grid { grid-template-columns: 1fr; }
    .donut-row { justify-content: center; }
    .bar-row { grid-template-columns: 80px 1fr 30px; }
}

.login-hint {
    font-size: 0.74rem;
    color: var(--text-faint);
    margin: 14px 0 0;
    line-height: 1.4;
}
