:root {
    --brand: #4f46e5;
    --brand-ink: #4338ca;
    --brand-soft: #eef0ff;
    --accent: #0d9488;
    --up: #16a34a;
    --up-soft: #eafbef;
    --down: #dc2626;
    --down-soft: #fdeeed;
    --warn: #b45309;
    --warn-soft: #fef6e7;

    --ink-900: #0f172a;
    --ink-700: #334155;
    --ink-500: #64748b;
    --ink-300: #cbd5e1;
    --ink-200: #e2e8f0;
    --ink-100: #eef1f6;

    --surface: #ffffff;
    --bg: #f3f5f9;

    --radius-lg: 16px;
    --radius-md: 12px;
    --radius-sm: 9px;

    --shadow-sm: 0 1px 2px rgba(15, 23, 42, .06), 0 1px 1px rgba(15, 23, 42, .04);
    --shadow-md: 0 10px 24px -12px rgba(15, 23, 42, .22);
    --shadow-lg: 0 24px 48px -20px rgba(15, 23, 42, .28);
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }

body {
    background: var(--bg);
    color: var(--ink-700);
    display: flex;
    flex-direction: column;
    font-family: "Roboto", Arial, sans-serif;
    min-height: 100vh;
    -webkit-font-smoothing: antialiased;
}

main { flex: 1; }

h1, h2, h3, h4, h5, h6 { color: var(--ink-900); letter-spacing: -.01em; }

a { color: var(--brand); }
a:hover { color: var(--brand-ink); }

:focus-visible {
    outline: 2px solid var(--brand);
    outline-offset: 2px;
    border-radius: 4px;
}

/* ---------- Nav ---------- */
.navbar {
    background: rgba(255, 255, 255, .92) !important;
    backdrop-filter: saturate(180%) blur(8px);
    border-bottom: 1px solid var(--ink-200);
    padding: .7rem 0;
}

.navbar-brand {
    color: var(--ink-900) !important;
    font-size: 1.3rem;
    font-weight: 800;
    letter-spacing: -.02em;
}

.navbar-brand img {
    border-radius: 50%;
    object-fit: contain;
}

.nav-link {
    color: var(--ink-500) !important;
    font-weight: 600;
    margin-left: .65rem;
}

.nav-link:hover { color: var(--brand) !important; }

/* ---------- Hero / banner ---------- */
.dashboard-banner {
    background: linear-gradient(120deg, #211f54 0%, #322f8c 45%, var(--brand) 100%);
    color: #fff;
    position: relative;
    overflow: hidden;
}
.dashboard-banner::after {
    content: "";
    position: absolute;
    inset: 0;
    background: radial-gradient(60% 140% at 85% 0%, rgba(255, 255, 255, .16), transparent 60%);
    pointer-events: none;
}
.dashboard-heading { padding-bottom: 0; position: relative; }
.dashboard-heading h1 { color: #fff; font-weight: 800; }
.eyebrow { color: rgba(255, 255, 255, .78); font-size: .72rem; font-weight: 700; letter-spacing: .12em; }
.dashboard-content { padding-bottom: 3rem; position: relative; top: -1px; }

.hero-stats { display: flex; flex-wrap: wrap; gap: .5rem; margin-top: .65rem; }
.stat-chip {
    align-items: center;
    background: rgba(255, 255, 255, .12);
    border: 1px solid rgba(255, 255, 255, .22);
    border-radius: 999px;
    color: #fff;
    display: inline-flex;
    font-size: .8rem;
    font-weight: 600;
    gap: .4rem;
    padding: .35rem .75rem;
}
.stat-chip i { font-size: .75rem; opacity: .9; }

/* ---------- Toolbar ---------- */
.toolbar { border: 0; box-shadow: var(--shadow-md); margin-top: -1.75rem; z-index: 2; }
.toolbar:hover, .market-table-card:hover { transform: none; }

.form-select, .form-control {
    border-color: var(--ink-200);
}
.form-select:focus, .form-control:focus {
    border-color: var(--brand);
    box-shadow: 0 0 0 3px var(--brand-soft);
}

/* ---------- Cards ---------- */
.card {
    border: 0;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
    overflow: hidden;
    transition: transform .18s ease, box-shadow .18s ease;
}

.card:hover {
    box-shadow: var(--shadow-md);
    transform: translateY(-2px);
}

.market-table-card { border: 1px solid var(--ink-200); box-shadow: none; }

.card-header {
    background: #fff;
    border-bottom: 1px solid var(--ink-100);
    font-weight: 700;
}
.card-header.section-header {
    align-items: center;
    color: var(--ink-900);
    display: flex;
    font-size: .95rem;
    gap: .5rem;
}
.card-header.section-header i {
    align-items: center;
    background: var(--brand-soft);
    border-radius: 8px;
    color: var(--brand);
    display: inline-flex;
    font-size: .8rem;
    height: 26px;
    justify-content: center;
    width: 26px;
}

.card-body { padding: 1.35rem; }

/* ---------- Research card (dashboard) ---------- */
.research-card { border-top: 3px solid var(--brand); }
.research-card:hover { border-top-color: var(--accent); }
.research-card .ticker-link { color: var(--ink-900); font-size: 1.3rem; font-weight: 800; text-decoration: none; }
.research-card .ticker-link:hover { color: var(--brand); }
.company-name { color: var(--ink-500); font-size: .84rem; font-weight: 500; margin-top: .1rem; }

.stat-row {
    background: var(--ink-100);
    border-radius: var(--radius-md);
    display: grid;
    gap: 1px;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    margin-bottom: 1rem;
    overflow: hidden;
}
.stat-tile { background: #fff; display: flex; flex-direction: column; padding: .65rem .8rem; }
.stat-label { color: var(--ink-500); font-size: .68rem; font-weight: 600; letter-spacing: .05em; text-transform: uppercase; }
.stat-value { color: var(--ink-900); font-size: .95rem; font-weight: 700; margin-top: .15rem; }
.stat-value.positive { color: var(--up); }
.stat-value.negative { color: var(--down); }
.stat-value.warn { color: var(--warn); }
.stat-source { font-size: .67rem; margin-top: .3rem; text-decoration: none; }

.research-readout { color: var(--ink-700); font-size: .86rem; line-height: 1.5; min-height: 3.7em; }

.synthesis-preview {
    background: linear-gradient(180deg, rgba(79, 70, 229, .05), transparent 65%);
    border-left: 3px solid var(--brand);
    border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
    color: inherit;
    display: block;
    margin-bottom: .85rem;
    padding: .55rem .8rem;
    text-decoration: none;
    transition: background .15s ease;
}
.synthesis-preview:hover { background: var(--brand-soft); color: inherit; }
.synthesis-preview span { color: var(--brand); font-size: .68rem; font-weight: 700; letter-spacing: .05em; text-transform: uppercase; }
.synthesis-preview span::before { content: "\2726"; margin-right: .35rem; }
.synthesis-preview p { display: -webkit-box; font-size: .83rem; line-height: 1.42; margin: .25rem 0 0; overflow: hidden; -webkit-box-orient: vertical; -webkit-line-clamp: 3; }
.synthesis-card { border-left: 4px solid var(--brand); }

.card-footer-row { border-top: 1px solid var(--ink-100); display: flex; font-size: .8rem; justify-content: space-between; padding-top: .75rem; }
.card-footer-row span { color: var(--ink-500); }
.card-footer-row a { color: var(--brand); font-weight: 700; text-decoration: none; }
.card-footer-row a:hover { text-decoration: underline; }

.headline-block { background: var(--ink-100); border-radius: var(--radius-sm); display: flex; flex-direction: column; gap: .2rem; margin-top: .8rem; padding: .65rem .8rem; }
.headline-block > span { color: var(--ink-500); font-size: .68rem; font-weight: 600; letter-spacing: .04em; text-transform: uppercase; }
.headline-block a { color: var(--ink-900); font-size: .83rem; font-weight: 500; line-height: 1.35; text-decoration: none; }
.headline-block a:hover { color: var(--brand); text-decoration: underline; }
.headline-block em { color: var(--ink-500); font-size: .83rem; }

/* ---------- Sentiment / posture chips ---------- */
.sentiment, .posture {
    border-radius: 999px;
    display: inline-flex;
    align-items: center;
    font-size: .74rem;
    font-weight: 700;
    padding: .3rem .65rem .3rem .5rem;
    text-transform: capitalize;
}
.sentiment::before, .posture::before {
    content: "";
    border-radius: 999px;
    display: inline-block;
    height: 6px;
    margin-right: .4rem;
    width: 6px;
    background: currentColor;
}
.sentiment-bullish, .posture-positive { background: var(--up-soft); color: var(--up); }
.sentiment-bearish, .posture-negative { background: var(--down-soft); color: var(--down); }
.sentiment-mixed, .posture-mixed { background: var(--warn-soft); color: var(--warn); }
.sentiment-neutral { background: var(--ink-100); color: var(--ink-500); }

/* ---------- Spotlight profile header ---------- */
.profile-header {
    align-items: flex-start;
    background: var(--surface);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
    display: flex;
    flex-wrap: wrap;
    gap: 1rem;
    justify-content: space-between;
    padding: 1.5rem 1.65rem;
}
.profile-ticker { color: var(--ink-900); font-size: 1.9rem; font-weight: 800; letter-spacing: -.02em; line-height: 1.1; }
.profile-company { color: var(--ink-500); font-size: 1rem; font-weight: 500; margin-top: .15rem; }
.profile-meta { display: flex; flex-wrap: wrap; gap: .5rem; margin-top: .85rem; }
.chip {
    background: var(--ink-100);
    border-radius: 999px;
    color: var(--ink-700);
    font-size: .78rem;
    font-weight: 600;
    padding: .3rem .7rem;
}
.chip a { color: inherit; text-decoration: none; }
.chip a:hover { color: var(--brand); }
.chip i { color: var(--ink-500); margin-right: .35rem; }

/* ---------- Metric / analysis grid (spotlight) ---------- */
.metric-grid {
    background: var(--ink-100);
    border-radius: var(--radius-md);
    display: grid;
    gap: 1px;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    overflow: hidden;
}

.metric-grid > div {
    background: #fff;
    display: flex;
    flex-direction: column;
    padding: .8rem .9rem;
}

.metric-grid span { color: var(--ink-500); font-size: .72rem; font-weight: 600; letter-spacing: .03em; text-transform: uppercase; }
.metric-grid strong { color: var(--ink-900); font-size: 1.02rem; font-weight: 700; margin-top: .2rem; }
.metric-grid strong.value-positive { color: var(--up); }
.metric-grid strong.value-negative { color: var(--down); }
.metric-grid strong.value-warn { color: var(--warn); }

/* ---------- Loading / skeleton states ---------- */
.skeleton {
    background: linear-gradient(100deg, var(--ink-100) 30%, var(--ink-200) 45%, var(--ink-100) 60%);
    background-size: 250% 100%;
    animation: skeleton-shimmer 1.4s ease-in-out infinite;
    border-radius: var(--radius-sm);
}
@keyframes skeleton-shimmer {
    0% { background-position: 120% 0; }
    100% { background-position: -20% 0; }
}
.skeleton-card { border-radius: var(--radius-lg); height: 100%; min-height: 280px; padding: 1.35rem; }
.skeleton-line { height: 12px; margin-bottom: .6rem; }

/* ---------- Buttons / misc ---------- */
.btn-primary, .btn-custom {
    background: var(--brand);
    border: 0;
    border-radius: 20px;
    color: #fff;
    padding: 10px 20px;
}

.btn-primary:hover, .btn-custom:hover { background: var(--brand-ink); color: #fff; }
.btn-outline-secondary { border-color: var(--ink-200); color: var(--ink-700); }
.btn-outline-secondary:hover { background: var(--ink-900); border-color: var(--ink-900); color: #fff; }

.badge-soft { background: #fff; color: var(--brand); padding: .5rem .85rem; }

.list-unstyled li { margin-bottom: .45rem; }
.list-unstyled a { color: var(--ink-900); text-decoration: none; }
.list-unstyled a:hover { color: var(--brand); text-decoration: underline; }

.site-footer { background: var(--ink-900); color: #fff; margin-top: auto; }
.site-footer small { color: rgba(255, 255, 255, .72); }

@media (max-width: 767px) {
    .nav-link { margin-left: 0; }
    .metric-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .toolbar { margin-top: -1.25rem; }
    .profile-header { padding: 1.25rem; }
    .profile-ticker { font-size: 1.5rem; }
}
