:root {
    --bg: #07111f;
    --bg-deep: #030813;
    --panel: rgba(11, 21, 37, 0.88);
    --panel-strong: #0f1d32;
    --panel-soft: rgba(18, 31, 51, 0.72);
    --ink: #f3f7ff;
    --muted: #9aabc5;
    --line: rgba(146, 170, 206, 0.18);
    --accent: #49c6ff;
    --accent-strong: #2f9eff;
    --accent-soft: rgba(73, 198, 255, 0.14);
    --success: #57d98d;
    --success-soft: rgba(87, 217, 141, 0.16);
    --warning: #ffb657;
    --warning-soft: rgba(255, 182, 87, 0.16);
    --danger: #ff7f81;
    --danger-soft: rgba(255, 127, 129, 0.16);
    --shadow: 0 28px 80px rgba(0, 0, 0, 0.45);
    --radius-xl: 30px;
    --radius-lg: 22px;
    --radius-md: 16px;
}

* {
    box-sizing: border-box;
}

html {
    color-scheme: dark;
}

body {
    margin: 0;
    min-height: 100vh;
    color: var(--ink);
    background:
        radial-gradient(circle at top left, rgba(47, 158, 255, 0.22), transparent 22rem),
        radial-gradient(circle at top right, rgba(87, 217, 141, 0.10), transparent 18rem),
        linear-gradient(180deg, #091223 0%, var(--bg) 48%, var(--bg-deep) 100%);
    font-family: "Space Grotesk", "Segoe UI Variable", sans-serif;
}

a {
    color: inherit;
}

button,
input,
select,
textarea {
    font: inherit;
}

[hidden] {
    display: none !important;
}

.app-shell__header {
    padding: 1.4rem clamp(1rem, 2vw, 2rem) 0.4rem;
}

.app-shell__home {
    text-decoration: none;
    font-weight: 700;
    font-size: clamp(1.5rem, 2vw, 1.9rem);
    letter-spacing: 0.1em;
    display: inline-block;
}

.surface-card__header p,
.report-page__meta,
.hero-panel__lede,
.form-message,
.report-placeholder p,
.metric-card__label,
.trace-list small,
.source-list small,
.provider-usage-list small,
.chat-bubble__meta,
.chat-empty-state__copy {
    color: var(--muted);
}

.app-shell__main {
    padding: 0 clamp(1rem, 2vw, 2rem) 2rem;
}

.hero-stage {
    min-height: calc(100vh - 7rem);
    display: grid;
    align-items: center;
}

.hero-panel,
.surface-card,
.progress-panel {
    background: var(--panel);
    border: 1px solid var(--line);
    box-shadow: var(--shadow);
    backdrop-filter: blur(18px);
}

.hero-panel {
    display: grid;
    gap: 1.5rem;
    padding: clamp(1.5rem, 3vw, 2.6rem);
    border-radius: var(--radius-xl);
    justify-items: center;
    text-align: center;
    max-width: 52rem;
    margin: 0 auto;
}

.hero-panel--landing {
    width: min(100%, 52rem);
}

.hero-panel__copy {
    display: grid;
    gap: 0.75rem;
    justify-items: center;
    width: min(100%, 36rem);
    margin: 0 auto;
}

.hero-panel h1,
.report-page__header h1 {
    margin: 0;
    font-size: clamp(2.1rem, 4vw, 4.2rem);
    line-height: 0.98;
    letter-spacing: -0.04em;
}

.hero-panel__lede {
    margin: 0;
    width: min(100%, 28rem);
    font-size: 1rem;
    line-height: 1.6;
    text-wrap: balance;
}

.control-panel {
    display: grid;
    gap: 1rem;
    width: min(100%, 40rem);
}

.chat-form,
.report-content,
.chat-panel {
    display: grid;
    gap: 1rem;
    width: 100%;
}

.field-label {
    font-size: 0.92rem;
    font-weight: 700;
}

.field-label--inline {
    min-width: 3.5rem;
}

.field-row,
.chat-actions,
.report-page__actions {
    display: flex;
    gap: 0.75rem;
    flex-wrap: wrap;
    align-items: center;
}

.field-row {
    width: 100%;
}

.field-row--stock {
    align-items: center;
}

.autocomplete-shell,
.select-shell {
    position: relative;
    flex: 1 1 18rem;
}

.autocomplete-shell {
    min-width: 0;
}

.select-shell::after {
    content: "▾";
    position: absolute;
    top: 50%;
    right: 1rem;
    transform: translateY(-50%);
    color: var(--muted);
    pointer-events: none;
}

.select-input,
.chat-input {
    width: 100%;
    border: 1px solid var(--line);
    border-radius: var(--radius-md);
    background: rgba(4, 10, 20, 0.72);
    color: var(--ink);
    padding: 0.95rem 1rem;
}

.select-input {
    appearance: none;
    padding-right: 2.5rem;
}

.ticker-results {
    position: absolute;
    top: calc(100% + 0.45rem);
    left: 0;
    right: 0;
    z-index: 20;
    display: grid;
    gap: 0.35rem;
    padding: 0.45rem;
    border: 1px solid var(--line);
    border-radius: var(--radius-md);
    background: rgba(6, 12, 22, 0.96);
    box-shadow: 0 18px 40px rgba(0, 0, 0, 0.35);
}

.ticker-result {
    display: grid;
    gap: 0.15rem;
    width: 100%;
    text-align: left;
    padding: 0.8rem 0.9rem;
    border: 1px solid transparent;
    border-radius: 14px;
    background: rgba(255, 255, 255, 0.03);
    color: var(--ink);
    cursor: pointer;
}

.ticker-result:hover {
    border-color: var(--line);
    background: rgba(73, 198, 255, 0.08);
}

.ticker-result span,
.ticker-result small {
    color: var(--muted);
}

.chat-input {
    min-height: 4.25rem;
    resize: vertical;
    line-height: 1.5;
}

.chat-input:disabled {
    opacity: 0.55;
    cursor: not-allowed;
}

.primary-button,
.secondary-button,
.ghost-button,
.status-badge {
    border-radius: 999px;
}

.primary-button,
.secondary-button,
.ghost-button {
    border: 1px solid transparent;
    cursor: pointer;
    transition: transform 140ms ease, background 140ms ease, border-color 140ms ease, opacity 140ms ease;
    padding: 0.9rem 1.15rem;
    font-weight: 700;
}

.primary-button {
    background: linear-gradient(135deg, var(--accent), var(--accent-strong));
    color: #021019;
    margin-left: auto;
}

.primary-button--icon {
    display: inline-flex;
    align-items: center;
    gap: 0.45rem;
}

.secondary-button {
    background: rgba(255, 255, 255, 0.08);
    color: var(--ink);
    border-color: var(--line);
}

.ghost-button {
    background: transparent;
    color: var(--muted);
    border-color: var(--line);
}

.ghost-button--icon {
    padding-inline: 0.9rem;
}

.primary-button:hover,
.secondary-button:hover,
.ghost-button:hover {
    transform: translateY(-1px);
}

.primary-button:disabled,
.secondary-button:disabled,
.ghost-button:disabled {
    opacity: 0.45;
    cursor: not-allowed;
    transform: none;
}

.report-page {
    display: grid;
    gap: 1.1rem;
    position: relative;
    max-width: 88rem;
    margin: 0 auto;
}

.report-page__header {
    display: flex;
    justify-content: space-between;
    gap: 1rem;
    align-items: flex-start;
    flex-wrap: wrap;
}

.report-page__meta {
    margin: 0;
}

.report-page__actions {
    justify-content: flex-end;
}

.status-badge {
    display: inline-flex;
    align-items: center;
    padding: 0.62rem 0.9rem;
    border: 1px solid var(--line);
    background: rgba(255, 255, 255, 0.04);
    font-size: 0.9rem;
    font-weight: 700;
}

.status-badge--queued {
    color: var(--warning);
}

.status-badge--running {
    color: var(--accent);
}

.status-badge--completed {
    color: var(--success);
}

.status-badge--failed {
    color: var(--danger);
}

.report-main {
    display: grid;
    grid-template-columns: minmax(0, 1.25fr) minmax(22rem, 0.75fr);
    gap: 1rem;
    align-items: start;
}

.surface-card {
    border-radius: var(--radius-xl);
    padding: 1.25rem;
}

.surface-card--hero,
.chat-card {
    min-height: 27rem;
}

.surface-card__header {
    margin-bottom: 0.85rem;
}

.surface-card__header--compact h2 {
    margin-bottom: 0.2rem;
}

.surface-card__header--centered {
    text-align: center;
}

.surface-card__header h2 {
    margin: 0;
    font-size: 1.15rem;
}

.report-overview {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0.85rem;
}

.metric-card,
.report-placeholder,
.chat-bubble,
.source-list li,
.provider-usage-list li,
.report-list li,
.report-section {
    border-radius: var(--radius-lg);
    background: var(--panel-soft);
    border: 1px solid var(--line);
}

.metric-card {
    padding: 1rem;
}

.metric-card strong {
    font-size: 1.45rem;
}

.metric-card--signal.metric-card--bullish {
    background: linear-gradient(135deg, rgba(87, 217, 141, 0.24), rgba(12, 24, 39, 0.92));
}

.metric-card--signal.metric-card--neutral {
    background: linear-gradient(135deg, rgba(255, 182, 87, 0.22), rgba(12, 24, 39, 0.92));
}

.metric-card--signal.metric-card--bearish {
    background: linear-gradient(135deg, rgba(255, 127, 129, 0.22), rgba(12, 24, 39, 0.92));
}

.metric-card--confidence.metric-card--high {
    background: linear-gradient(135deg, rgba(73, 198, 255, 0.22), rgba(12, 24, 39, 0.92));
}

.metric-card--confidence.metric-card--medium {
    background: linear-gradient(135deg, rgba(255, 182, 87, 0.2), rgba(12, 24, 39, 0.92));
}

.metric-card--confidence.metric-card--low {
    background: linear-gradient(135deg, rgba(255, 127, 129, 0.2), rgba(12, 24, 39, 0.92));
}

.report-section {
    display: grid;
    gap: 0.7rem;
    padding: 1rem 1.05rem;
}

.report-section h3 {
    margin: 0;
    font-size: 0.98rem;
}

.report-section p {
    margin: 0;
    line-height: 1.65;
}

.report-section__subtle {
    color: var(--muted);
}

.report-list,
.source-list,
.provider-usage-list,
.warning-list,
.trace-list {
    margin: 0;
    padding: 0;
    list-style: none;
}

.report-list,
.source-list,
.provider-usage-list {
    display: grid;
    gap: 0.75rem;
}

.report-list li,
.source-list li,
.provider-usage-list li {
    padding: 0.95rem 1rem;
}

.report-list li {
    border-left: 3px solid var(--accent);
}

.source-list li {
    display: grid;
    gap: 0.32rem;
    border-left: 3px solid var(--success);
}

.provider-usage-list li {
    display: grid;
    gap: 0.28rem;
    border-left: 3px solid var(--warning);
}

.source-list span,
.provider-usage-list span {
    color: #dce8fa;
}

.report-placeholder {
    display: grid;
    gap: 0.8rem;
    place-content: center;
    min-height: 18rem;
    padding: 1.5rem;
    text-align: center;
}

.report-placeholder__status {
    margin: 0;
    color: var(--accent);
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.14em;
    font-size: 0.75rem;
}

.report-placeholder h2 {
    margin: 0;
    font-size: 1.7rem;
}

.inline-progress {
    display: grid;
    gap: 0.65rem;
    width: min(100%, 24rem);
    margin: 0.15rem auto 0;
    text-align: left;
}

.inline-progress__meta {
    display: flex;
    justify-content: space-between;
    gap: 1rem;
    align-items: center;
    font-size: 0.92rem;
    color: var(--ink);
}

.inline-progress__meta span:last-child {
    color: var(--muted);
    font-variant-numeric: tabular-nums;
}

.inline-progress__track {
    position: relative;
    overflow: hidden;
    height: 0.7rem;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid rgba(255, 255, 255, 0.06);
}

.inline-progress__fill {
    height: 100%;
    border-radius: inherit;
    background: linear-gradient(90deg, var(--accent), var(--success));
    box-shadow: 0 0 24px rgba(73, 198, 255, 0.28);
    transition: width 220ms ease;
}

.failure-panel {
    margin-top: 1rem;
    padding: 1rem;
    border-radius: var(--radius-lg);
    background: var(--danger-soft);
    color: var(--danger);
    border: 1px solid rgba(255, 127, 129, 0.2);
}

.chat-card {
    display: grid;
    align-content: start;
}

.chat-panel {
    width: 100%;
}

.chat-empty-state {
    display: grid;
    gap: 0.65rem;
    justify-items: center;
    text-align: center;
    padding: 1.25rem 0 0.75rem;
}

.chat-empty-state.is-hidden {
    display: none;
}

.chat-empty-state__title {
    margin: 0;
    font-size: 1rem;
    color: var(--ink);
}

.chat-empty-state__copy {
    margin: 0;
}

.chat-suggestions {
    display: flex;
    gap: 0.6rem;
    flex-wrap: wrap;
    justify-content: center;
}

.chat-suggestion {
    padding: 0.75rem 0.95rem;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid var(--line);
    color: var(--ink);
    cursor: pointer;
}

.chat-suggestion:disabled {
    opacity: 0.45;
    cursor: not-allowed;
}

.chat-transcript {
    min-height: 14rem;
    max-height: 30rem;
    overflow-y: auto;
    display: grid;
    gap: 0.75rem;
    padding-right: 0.15rem;
}

.chat-bubble {
    display: grid;
    gap: 0.45rem;
    padding: 0.85rem 1rem;
}

.chat-bubble--user {
    margin-left: auto;
    max-width: 85%;
    background: rgba(73, 198, 255, 0.12);
}

.chat-bubble--assistant {
    max-width: 92%;
}

.chat-bubble__body {
    line-height: 1.6;
}

.chat-bubble__body h1,
.chat-bubble__body h2,
.chat-bubble__body h3,
.chat-bubble__body h4 {
    margin: 0;
    line-height: 1.2;
    letter-spacing: -0.02em;
}

.chat-bubble__body h2 {
    font-size: 1.02rem;
}

.chat-bubble__body h3,
.chat-bubble__body h4 {
    font-size: 0.95rem;
}

.chat-bubble__body p,
.chat-bubble__body ol,
.chat-bubble__body ul {
    margin: 0;
}

.chat-bubble__body p + h1,
.chat-bubble__body p + h2,
.chat-bubble__body p + h3,
.chat-bubble__body p + h4,
.chat-bubble__body h1 + p,
.chat-bubble__body h2 + p,
.chat-bubble__body h3 + p,
.chat-bubble__body h4 + p,
.chat-bubble__body h1 + ol,
.chat-bubble__body h2 + ol,
.chat-bubble__body h3 + ol,
.chat-bubble__body h4 + ol,
.chat-bubble__body h1 + ul,
.chat-bubble__body h2 + ul,
.chat-bubble__body h3 + ul,
.chat-bubble__body h4 + ul {
    margin-top: 0.8rem;
}

.chat-bubble__body p + p,
.chat-bubble__body p + ol,
.chat-bubble__body p + ul,
.chat-bubble__body ol + p,
.chat-bubble__body ul + p,
.chat-bubble__body ol + ol,
.chat-bubble__body ul + ul,
.chat-bubble__body ol + h1,
.chat-bubble__body ol + h2,
.chat-bubble__body ol + h3,
.chat-bubble__body ol + h4,
.chat-bubble__body ul + h1,
.chat-bubble__body ul + h2,
.chat-bubble__body ul + h3,
.chat-bubble__body ul + h4 {
    margin-top: 0.8rem;
}

.chat-bubble__body ol,
.chat-bubble__body ul {
    padding-left: 1.2rem;
}

.chat-bubble__body li + li {
    margin-top: 0.45rem;
}

.chat-bubble__meta {
    font-size: 0.84rem;
}

.chat-bubble__meta:empty {
    display: none;
}

.chat-actions {
    justify-content: flex-end;
}

.progress-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(3, 8, 19, 0.32);
    z-index: 40;
}

.progress-panel {
    position: fixed;
    top: 1rem;
    right: 1rem;
    width: min(24rem, calc(100vw - 2rem));
    height: calc(100vh - 2rem);
    padding: 1.1rem;
    border-radius: 28px;
    transform: translateX(calc(100% + 1.5rem));
    transition: transform 180ms ease;
    z-index: 50;
    overflow: auto;
}

.progress-panel.is-open {
    transform: translateX(0);
}

.progress-panel__header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 1rem;
    margin-bottom: 1rem;
}

.progress-panel__header h2 {
    margin: 0;
    font-size: 1.2rem;
}

.progress-panel__meta {
    margin: 0.35rem 0 0;
    color: var(--muted);
    font-size: 0.88rem;
    word-break: break-all;
}

.warning-list {
    color: var(--warning);
    display: grid;
    gap: 0.4rem;
    margin-bottom: 1rem;
}

.trace-list {
    display: grid;
    gap: 0.75rem;
}

.trace-list li {
    padding: 0.95rem;
    border-radius: var(--radius-md);
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid rgba(255, 255, 255, 0.05);
}

.trace-list__meta {
    display: flex;
    justify-content: space-between;
    gap: 1rem;
    align-items: center;
    margin-bottom: 0.45rem;
}

.trace-list__meta strong {
    font-size: 0.92rem;
}

.trace-list__meta span {
    color: var(--muted);
    font-size: 0.82rem;
}

.trace-list p {
    margin: 0 0 0.4rem;
    color: #dce8fa;
    line-height: 1.45;
}

code {
    font-family: "Space Grotesk", sans-serif;
    background: rgba(255, 255, 255, 0.06);
    padding: 0.15rem 0.4rem;
    border-radius: 0.5rem;
}

@media (max-width: 1100px) {
    .report-main {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 700px) {
    .hero-stage {
        min-height: auto;
        align-items: stretch;
    }

    .hero-panel h1,
    .report-page__header h1 {
        font-size: 2.1rem;
    }

    .field-row,
    .field-row--stock,
    .report-page__actions {
        flex-direction: column;
        align-items: stretch;
    }

    .field-label--inline {
        min-width: 0;
    }

    .primary-button {
        margin-left: 0;
    }

    .report-overview {
        grid-template-columns: 1fr;
    }

    .progress-panel {
        top: auto;
        bottom: 0;
        left: 0.75rem;
        right: 0.75rem;
        width: auto;
        height: 70vh;
        border-bottom-left-radius: 0;
        border-bottom-right-radius: 0;
        transform: translateY(calc(100% + 1rem));
    }

    .progress-panel.is-open {
        transform: translateY(0);
    }
}
