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

:root {
    --navy-950: #0b1220;
    --navy-900: #0f172a;
    --navy-800: #1e293b;
    --slate-600: #475569;
    --slate-500: #64748b;
    --slate-400: #94a3b8;
    --slate-200: #e2e8f0;
    --slate-100: #f1f5f9;
    --slate-50: #f8fafc;
    --emerald-600: #059669;
    --emerald-500: #10b981;
    --emerald-50: #ecfdf5;
    --blue-600: #2563eb;
    --danger: #dc2626;
    --radius: 12px;
    --shadow: 0 1px 2px rgba(15, 23, 42, 0.04), 0 8px 24px rgba(15, 23, 42, 0.04);
    --font: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

body {
    font-family: var(--font);
    background: linear-gradient(180deg, #f4f7fb 0%, var(--slate-50) 240px);
    color: var(--navy-800);
    font-size: 14px;
    line-height: 1.55;
    -webkit-font-smoothing: antialiased;
}

a { color: #1d4ed8; }

.layout { min-height: 100vh; display: flex; flex-direction: column; }

.site-header {
    background: rgba(11, 18, 32, 0.92);
    backdrop-filter: blur(10px);
    color: #f1f5f9;
    padding: 0 1.5rem;
    min-height: 64px;
    display: flex;
    align-items: center;
    border-bottom: 1px solid rgba(148, 163, 184, 0.12);
    position: sticky;
    top: 0;
    z-index: 20;
}
.header-inner {
    display: flex;
    align-items: center;
    gap: 1.25rem;
    width: 100%;
    max-width: 1120px;
    margin: 0 auto;
    flex-wrap: wrap;
    padding: 0.65rem 0;
}
.logo {
    font-size: 1.15rem;
    font-weight: 700;
    letter-spacing: -0.03em;
    color: #f8fafc;
    text-decoration: none;
}
.logo-accent { color: var(--emerald-500); }
.logo:hover { color: #fff; }
.site-nav { display: flex; gap: 0.35rem; align-items: center; }
.site-nav a, .header-auth a {
    color: var(--slate-400);
    text-decoration: none;
    font-size: 0.86rem;
    font-weight: 600;
    padding: 0.4rem 0.7rem;
    border-radius: 8px;
    transition: color 0.15s, background 0.15s;
}
.site-nav a:hover, .header-auth a:hover { color: #e2e8f0; background: rgba(255,255,255,.06); }
.site-nav a.active, .header-auth a.active { color: #fff; background: rgba(16, 185, 129, 0.18); }
.header-auth { margin-left: auto; display: flex; align-items: center; gap: 0.35rem; }
.btn-nav {
    background: var(--emerald-600) !important;
    color: #fff !important;
}
.btn-nav:hover { background: #047857 !important; }
.nav-quiet { opacity: 0.85; }

.site-main {
    flex: 1;
    padding: 2rem 1.5rem 3rem;
    max-width: 1120px;
    margin: 0 auto;
    width: 100%;
}

.site-footer {
    border-top: 1px solid var(--slate-200);
    background: #fff;
    padding: 1.25rem 1.5rem;
    color: var(--slate-500);
    font-size: 0.8rem;
}
.footer-inner {
    max-width: 1120px;
    margin: 0 auto;
    display: flex;
    justify-content: space-between;
    gap: 1rem;
    flex-wrap: wrap;
}
.footer-links { display: flex; gap: 1rem; }
.footer-links a { color: var(--slate-500); text-decoration: none; }
.footer-links a:hover { color: var(--navy-800); }

.card {
    background: #fff;
    border: 1px solid var(--slate-200);
    border-radius: var(--radius);
    padding: 1.5rem 1.75rem;
    margin-bottom: 1.5rem;
    box-shadow: var(--shadow);
}
.card h2 {
    font-size: 0.8rem;
    font-weight: 650;
    color: var(--slate-500);
    text-transform: uppercase;
    letter-spacing: .06em;
    margin-bottom: 1.1rem;
}

.params-row { display: flex; align-items: flex-end; gap: 1.25rem; flex-wrap: wrap; }
.param-group { display: flex; flex-direction: column; gap: 0.35rem; margin-bottom: 0.85rem; }
.param-group label {
    font-size: 0.72rem;
    font-weight: 650;
    color: var(--slate-500);
    text-transform: uppercase;
    letter-spacing: .04em;
}
.param-group select,
.param-group input,
.auth-card input {
    border: 1px solid #cbd5e1;
    border-radius: 8px;
    padding: 0.55rem 0.8rem;
    font-size: 0.92rem;
    background: #fff;
    color: var(--navy-800);
    min-width: 200px;
    outline: none;
    font-family: inherit;
    transition: border-color 0.15s, box-shadow 0.15s;
}
.param-group select:focus,
.param-group input:focus,
.auth-card input:focus {
    border-color: var(--emerald-500);
    box-shadow: 0 0 0 3px rgba(16, 185, 129, 0.15);
}

.btn-primary {
    background: linear-gradient(180deg, #10b981, #059669);
    color: #fff;
    border: none;
    border-radius: 8px;
    padding: 0.6rem 1.35rem;
    font-size: 0.92rem;
    font-weight: 650;
    cursor: pointer;
    transition: filter 0.15s, opacity 0.15s, transform 0.1s;
    white-space: nowrap;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    font-family: inherit;
}
.btn-primary:hover:not(:disabled) { filter: brightness(1.05); }
.btn-primary:disabled { opacity: 0.55; cursor: not-allowed; }

.btn-secondary {
    display: inline-block;
    background: #fff;
    color: var(--navy-800);
    border: 1px solid var(--slate-200);
    border-radius: 8px;
    padding: 0.55rem 1.1rem;
    font-size: 0.88rem;
    font-weight: 600;
    text-decoration: none;
    cursor: pointer;
    font-family: inherit;
}
.btn-secondary:hover { background: var(--slate-100); }

.status-msg { margin-top: 0.75rem; color: var(--slate-500); font-size: 0.85rem; }
.muted { color: var(--slate-500); }
.tiny { font-size: 0.75rem; margin-top: 0.5rem; }

.results-header {
    display: flex;
    gap: 1.75rem;
    flex-wrap: wrap;
    margin-bottom: 1.75rem;
    padding-bottom: 1.25rem;
    border-bottom: 1px solid var(--slate-100);
}
.metric { display: flex; flex-direction: column; gap: 0.2rem; }
.metric-label { font-size: 0.7rem; font-weight: 650; text-transform: uppercase; letter-spacing: .05em; color: var(--slate-400); }
.metric-value { font-size: 1.45rem; font-weight: 700; color: var(--navy-950); letter-spacing: -0.02em; }

.positive { color: var(--emerald-600); }
.negative { color: var(--danger); }

.chart-container {
    position: relative;
    height: 280px;
    margin-bottom: 1.5rem;
}
.chart-container canvas { width: 100% !important; height: 100% !important; }
.chart-hero { height: 300px; margin-bottom: 0.25rem; }

.results-table { width: 100%; border-collapse: collapse; font-size: 0.88rem; }
.results-table th {
    text-align: left;
    padding: 0.5rem 0.75rem;
    font-size: 0.7rem;
    font-weight: 650;
    text-transform: uppercase;
    letter-spacing: .04em;
    color: var(--slate-500);
    border-bottom: 2px solid var(--slate-100);
}
.results-table td {
    padding: 0.65rem 0.75rem;
    border-bottom: 1px solid #f8fafc;
    color: #334155;
}
.results-table tbody tr:hover { background: #f8fafc; }
.results-table td:nth-child(4),
.results-table td:nth-child(5),
.results-table td:nth-child(6) { text-align: right; font-variant-numeric: tabular-nums; }

.results-table th:first-child { width: 1.5rem; }
.expand-cell { color: var(--slate-400); text-align: center; width: 1.5rem; }
.expand-icon { font-size: 0.6rem; }
.period-row { cursor: pointer; }
.period-row:hover { background: #f0fdf4 !important; }
.period-row.is-expanded { background: var(--emerald-50) !important; }
.period-row.is-expanded td { border-bottom: none; }
.detail-row > td { padding: 0 !important; border-bottom: 2px solid #a7f3d0 !important; }
.trades-panel {
    padding: 0.75rem 1rem 1rem 2.5rem;
    background: var(--slate-50);
    border-top: 1px solid var(--slate-200);
}

.trades-table { width: 100%; border-collapse: collapse; font-size: 0.8rem; }
.trades-table th {
    text-align: left;
    padding: 0.35rem 0.6rem;
    font-size: 0.68rem;
    font-weight: 650;
    text-transform: uppercase;
    letter-spacing: .04em;
    color: var(--slate-400);
    border-bottom: 1px solid var(--slate-200);
}
.trades-table td {
    padding: 0.45rem 0.6rem;
    border-bottom: 1px solid var(--slate-100);
    color: #334155;
    font-variant-numeric: tabular-nums;
}
.trades-table td:nth-child(n+3) { text-align: right; }
.trades-table td:nth-child(2) { text-align: left; }
.trades-table tbody tr:last-child td { border-bottom: none; }
.ticker-cell { font-weight: 650; color: #1e3a8a; font-size: 0.85rem; }
.company-cell {
    color: var(--slate-500);
    max-width: 180px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    text-align: left !important;
}

.change-badge {
    display: inline-block;
    padding: 0.15rem 0.45rem;
    border-radius: 4px;
    font-size: 0.68rem;
    font-weight: 700;
    letter-spacing: .04em;
    white-space: nowrap;
}
.change-new { background: #dcfce7; color: #15803d; }
.change-increased, .change-buy, .change-add { background: #d1fae5; color: #065f46; }
.change-held { background: var(--slate-100); color: var(--slate-500); }
.change-trimmed, .change-sell, .change-trim { background: #fff7ed; color: #c2410c; }
.change-exited, .change-exit { background: #fee2e2; color: #b91c1c; }
.trade-row-exited td { opacity: 0.7; }

.skipped-badge {
    display: inline-block;
    margin-left: 0.5rem;
    font-size: 0.7rem;
    color: var(--slate-400);
    background: var(--slate-100);
    border-radius: 4px;
    padding: 0.1rem 0.4rem;
}

.disclaimer {
    margin-top: 1.25rem;
    font-size: 0.75rem;
    color: var(--slate-400);
    line-height: 1.6;
}

.error-card { border-color: #fecaca; background: #fff5f5; }
.error-card p { color: var(--danger); }

.filings-intro { color: var(--slate-500); font-size: 0.9rem; margin-bottom: 1rem; }
.accession-cell { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 0.75rem; color: var(--slate-500); }
.param-group input[type="number"] { min-width: 120px; }

.filer-hero-top { display: flex; justify-content: space-between; align-items: flex-start; gap: 1rem; flex-wrap: wrap; margin-bottom: 1.25rem; }
.filer-name { font-size: 1.55rem; font-weight: 700; color: var(--navy-950); margin: 0 0 0.25rem; letter-spacing: -0.03em; text-transform: none; }
.filer-meta { color: var(--slate-500); font-size: 0.9rem; margin: 0; }
.stats-row { display: flex; flex-wrap: wrap; gap: 1.25rem; }
.stat { display: flex; flex-direction: column; gap: 0.15rem; min-width: 120px; }
.stat-label { font-size: 0.7rem; font-weight: 650; text-transform: uppercase; letter-spacing: .05em; color: var(--slate-400); }
.stat-value { font-size: 1.35rem; font-weight: 700; color: var(--navy-950); }
.stat-value-sm { font-size: 1.05rem; }
.stat-sub { font-size: 0.78rem; color: var(--slate-500); }
.two-col { display: grid; grid-template-columns: 1.2fr 1fr; gap: 1.5rem; }
@media (max-width: 900px) { .two-col { grid-template-columns: 1fr; } }
.chart-sm { height: 260px; }
.filer-link { color: #1e40af; font-weight: 650; text-decoration: none; }
.filer-link:hover { text-decoration: underline; }

/* Landing */
.hero {
    display: grid;
    grid-template-columns: 1.05fr 1.15fr;
    gap: 1.75rem;
    align-items: stretch;
    margin-bottom: 1.75rem;
}
@media (max-width: 960px) { .hero { grid-template-columns: 1fr; } }
.hero-copy {
    padding: 1.25rem 0.25rem;
    display: flex;
    flex-direction: column;
    justify-content: center;
}
.eyebrow {
    font-size: 0.75rem;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--emerald-600);
    margin-bottom: 0.75rem;
}
.hero h1 {
    font-size: clamp(1.85rem, 3vw, 2.45rem);
    line-height: 1.15;
    letter-spacing: -0.035em;
    color: var(--navy-950);
    margin-bottom: 0.9rem;
    font-weight: 750;
}
.hero-lead {
    font-size: 1.05rem;
    color: var(--slate-600);
    max-width: 36rem;
    margin-bottom: 1.5rem;
}
.hero-cta { display: flex; gap: 0.75rem; flex-wrap: wrap; }
.hero-chart { margin-bottom: 0; }
.hero-chart-head {
    display: flex;
    justify-content: space-between;
    gap: 1rem;
    align-items: flex-start;
    margin-bottom: 0.75rem;
    flex-wrap: wrap;
}
.hero-chart-head h2 { margin-bottom: 0.25rem; }
.hero-legend {
    display: flex;
    align-items: center;
    gap: 0.55rem;
    font-size: 0.78rem;
    color: var(--slate-500);
    font-weight: 600;
}
.legend-swatch {
    width: 12px;
    height: 12px;
    border-radius: 999px;
    display: inline-block;
}
.legend-swatch.strategy { background: var(--emerald-600); }
.legend-swatch.spy { background: var(--slate-500); box-shadow: inset 0 0 0 2px transparent; }

.feature-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 1rem;
    margin-bottom: 1.5rem;
}
@media (max-width: 800px) { .feature-grid { grid-template-columns: 1fr; } }
.feature-card { margin-bottom: 0; }
.feature-card h3 {
    font-size: 1rem;
    font-weight: 700;
    color: var(--navy-950);
    margin-bottom: 0.45rem;
    letter-spacing: -0.02em;
}
.feature-card p { color: var(--slate-600); font-size: 0.92rem; }

.managers-strip { margin-bottom: 0; }
.managers-head {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    gap: 1rem;
    margin-bottom: 1rem;
}
.managers-head a { font-weight: 600; text-decoration: none; font-size: 0.88rem; }
.manager-chips { display: flex; flex-wrap: wrap; gap: 0.65rem; }
.manager-chip {
    display: flex;
    flex-direction: column;
    gap: 0.15rem;
    padding: 0.75rem 1rem;
    border-radius: 10px;
    border: 1px solid var(--slate-200);
    background: var(--slate-50);
    text-decoration: none;
    min-width: 180px;
    transition: border-color 0.15s, background 0.15s;
}
.manager-chip:hover { border-color: #a7f3d0; background: var(--emerald-50); }
.chip-name { font-weight: 650; color: var(--navy-950); font-size: 0.9rem; }
.chip-cik { font-size: 0.72rem; color: var(--slate-500); }

/* Auth */
.auth-card { max-width: 420px; margin: 1rem auto 2rem; }
.auth-card .param-group input { width: 100%; min-width: 0; }
.auth-card .btn-primary { width: 100%; justify-content: center; margin-top: 0.35rem; }
.auth-switch { margin-top: 1rem; font-size: 0.88rem; color: var(--slate-500); }
.auth-error, .auth-errors { color: var(--danger); font-size: 0.85rem; margin: 0.5rem 0; }
.check-row {
    display: flex;
    align-items: center;
    gap: 0.45rem;
    font-size: 0.88rem;
    color: var(--slate-600);
    margin: 0.35rem 0 0.85rem;
}

/* Accessibility: visible focus for keyboard users */
:focus-visible {
    outline: 2px solid var(--emerald-500);
    outline-offset: 2px;
}
a:focus-visible, button:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible {
    outline: 2px solid var(--emerald-500);
    outline-offset: 2px;
}
.logout-form { display: inline; margin: 0; }
.logout-form.inline-form { margin-top: 0.75rem; }
.logout-btn {
    background: none;
    border: none;
    cursor: pointer;
    font: inherit;
    color: var(--slate-400);
    font-size: 0.86rem;
    font-weight: 600;
    padding: 0.4rem 0.7rem;
    border-radius: 8px;
}
.logout-btn:hover { color: #e2e8f0; background: rgba(255,255,255,.06); }
.demo-banner {
    margin-top: 0.5rem;
    padding: 0.5rem 0.65rem;
    background: #fff7ed;
    border: 1px solid #fed7aa;
    border-radius: 8px;
    color: #9a3412;
}

.filer-actions { display: flex; flex-wrap: wrap; gap: 0.5rem; align-items: center; }
