:root {
    --page-bg: #f6f8fb;
    --panel: #ffffff;
    --panel-soft: #f1f4f8;
    --ink: #151922;
    --muted: #647083;
    --line: #d9e0ea;
    --brand: #1a5cff;
    --brand-soft: #e8efff;
    --green: #13795b;
    --green-soft: #e3f5ee;
    --red: #b42318;
    --red-soft: #fee7e5;
    --amber: #976400;
    --amber-soft: #fff2cf;
    --shadow: 0 18px 50px rgba(21, 25, 34, 0.08);
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    min-height: 100vh;
    color: var(--ink);
    font-family: Inter, "Avenir Next", "Segoe UI", Arial, sans-serif;
    background:
        linear-gradient(180deg, rgba(255, 255, 255, 0.86), rgba(246, 248, 251, 0.95)),
        var(--page-bg);
}

button,
select,
a {
    font: inherit;
}

.login-page {
    display: grid;
    place-items: center;
    padding: 24px;
}

.login-shell {
    width: min(100%, 440px);
}

.login-panel {
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: 8px;
    box-shadow: var(--shadow);
    padding: 32px;
}

.login-kicker,
.panel-eyebrow,
.rail-label,
.symbol-control label,
.chart-control label {
    margin: 0 0 8px;
    color: var(--brand);
    font-size: 12px;
    font-weight: 800;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

.login-panel h1 {
    margin: 0;
    font-size: 32px;
    line-height: 1.12;
}

.login-copy,
.login-footnote {
    color: var(--muted);
    line-height: 1.55;
}

.login-copy {
    margin: 14px 0 24px;
}

.login-footnote {
    margin: 18px 0 0;
    font-size: 13px;
}

.notice {
    border-radius: 8px;
    margin-bottom: 16px;
    padding: 12px 14px;
    font-weight: 700;
}

.notice-error {
    background: var(--red-soft);
    color: var(--red);
}

.notice-success {
    background: var(--green-soft);
    color: var(--green);
}

.google-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    width: 100%;
    min-height: 48px;
    color: var(--ink);
    text-decoration: none;
    background: #ffffff;
    border: 1px solid var(--line);
    border-radius: 8px;
    font-weight: 800;
    box-shadow: 0 8px 22px rgba(21, 25, 34, 0.08);
}

.google-mark {
    display: inline-grid;
    place-items: center;
    width: 28px;
    height: 28px;
    color: var(--brand);
    background: var(--brand-soft);
    border-radius: 50%;
    font-weight: 900;
}

.button-disabled {
    pointer-events: none;
    opacity: 0.58;
}

.explorer-page {
    padding: 18px;
}

.app-shell {
    width: min(100%, 1440px);
    margin: 0 auto;
}

.app-topbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 16px;
    min-height: 64px;
    margin-bottom: 16px;
}

.brand-lockup,
.account-chip {
    display: inline-flex;
    align-items: center;
    gap: 10px;
}

.brand-lockup {
    color: var(--ink);
    text-decoration: none;
    font-size: 18px;
    font-weight: 900;
}

.brand-mark {
    display: inline-grid;
    place-items: center;
    width: 36px;
    height: 36px;
    color: #ffffff;
    background: linear-gradient(135deg, var(--brand), #0f9f62);
    border-radius: 8px;
    font-size: 12px;
    letter-spacing: 0.04em;
}

.account-cluster {
    display: flex;
    align-items: center;
    gap: 12px;
}

.account-chip {
    max-width: 280px;
    padding: 6px 10px 6px 6px;
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: 999px;
    color: var(--muted);
    font-size: 14px;
    font-weight: 700;
}

.account-chip span:last-child {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.account-avatar {
    width: 30px;
    height: 30px;
    border-radius: 50%;
    object-fit: cover;
}

.account-avatar-fallback {
    display: inline-grid;
    place-items: center;
    color: #ffffff;
    background: var(--brand);
    font-weight: 900;
}

.text-button {
    min-height: 36px;
    padding: 0 14px;
    color: var(--brand);
    background: var(--brand-soft);
    border: 0;
    border-radius: 999px;
    cursor: pointer;
    font-weight: 800;
}

.mini-button {
    min-height: 30px;
    padding: 0 10px;
    color: var(--brand);
    background: var(--brand-soft);
    border: 0;
    border-radius: 999px;
    cursor: pointer;
    font-size: 12px;
    font-weight: 900;
}

.mini-button:disabled {
    cursor: wait;
    opacity: 0.58;
}

.explorer-grid {
    display: grid;
    grid-template-columns: minmax(210px, 260px) minmax(0, 1fr) minmax(310px, 380px);
    gap: 16px;
    align-items: start;
}

.symbol-rail,
.market-panel,
.agent-panel {
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: 8px;
    box-shadow: var(--shadow);
}

.symbol-rail {
    position: sticky;
    top: 18px;
    display: grid;
    gap: 22px;
    padding: 18px;
}

.symbol-control label {
    display: block;
}

#symbolSelect {
    width: 100%;
    min-height: 44px;
    padding: 0 12px;
    color: var(--ink);
    background: var(--panel-soft);
    border: 1px solid var(--line);
    border-radius: 8px;
    font-weight: 900;
}

.recent-list {
    display: grid;
    gap: 8px;
}

.recent-button,
.range-button {
    border: 1px solid var(--line);
    background: #ffffff;
    color: var(--ink);
    cursor: pointer;
    font-weight: 800;
}

.recent-button {
    display: flex;
    justify-content: space-between;
    align-items: center;
    width: 100%;
    min-height: 38px;
    padding: 0 10px;
    border-radius: 8px;
}

.recent-button.is-active,
.range-button.is-active {
    color: var(--brand);
    background: var(--brand-soft);
    border-color: rgba(26, 92, 255, 0.26);
}

.market-panel {
    min-width: 0;
    padding: 18px;
}

.quote-header,
.agent-heading {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 16px;
}

.company-name {
    margin: 0 0 4px;
    color: var(--muted);
    font-size: 15px;
    font-weight: 800;
}

.quote-header h1 {
    margin: 0;
    font-size: 40px;
    line-height: 1;
}

.quote-price-block {
    text-align: right;
}

.last-price {
    display: block;
    font-size: 32px;
    font-weight: 900;
    line-height: 1;
}

.price-change {
    display: inline-flex;
    margin-top: 8px;
    padding: 6px 9px;
    border-radius: 999px;
    color: var(--muted);
    background: var(--panel-soft);
    font-size: 13px;
    font-weight: 900;
}

.price-up {
    color: var(--green);
    background: var(--green-soft);
}

.price-down {
    color: var(--red);
    background: var(--red-soft);
}

.range-tabs {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin: 18px 0 12px;
}

.range-button {
    min-width: 54px;
    height: 34px;
    border-radius: 999px;
}

.chart-toolbar {
    display: flex;
    align-items: flex-end;
    gap: 12px;
    margin: 0 0 12px;
}

.chart-control {
    flex: 1 1 180px;
    min-width: 160px;
}

.chart-control label {
    display: block;
}

.chart-select {
    width: 100%;
    min-height: 36px;
    padding: 0 10px;
    color: var(--ink);
    background: #ffffff;
    border: 1px solid var(--line);
    border-radius: 8px;
    font-size: 12px;
    font-weight: 900;
}

.reset-chart-button {
    flex: 0 0 auto;
    min-height: 36px;
}

.indicator-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    min-height: 30px;
    margin: -2px 0 10px;
}

.indicator-chip {
    display: inline-flex;
    align-items: center;
    min-height: 28px;
    padding: 0 10px;
    color: var(--ink);
    background: #ffffff;
    border: 1px solid var(--line);
    border-left: 4px solid var(--indicator-color, var(--brand));
    border-radius: 999px;
    cursor: pointer;
    font-size: 12px;
    font-weight: 900;
}

.chart-status {
    min-height: 22px;
    color: var(--muted);
    font-size: 13px;
    font-weight: 700;
}

.chart-status.is-error {
    color: var(--red);
}

.chart-surface {
    width: 100%;
    height: clamp(360px, 58vh, 620px);
}

.chart-attribution {
    margin: 10px 0 0;
    color: var(--muted);
    font-size: 11px;
}

.agent-panel {
    padding: 18px;
}

.agent-heading h2 {
    margin: 0;
    font-size: 22px;
}

.signal-pill {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 76px;
    min-height: 34px;
    padding: 0 12px;
    border-radius: 999px;
    font-size: 12px;
    font-weight: 900;
    letter-spacing: 0.06em;
    text-transform: uppercase;
}

.signal-buy {
    color: var(--green);
    background: var(--green-soft);
}

.signal-sell,
.signal-error {
    color: var(--red);
    background: var(--red-soft);
}

.signal-hold {
    color: var(--amber);
    background: var(--amber-soft);
}

.signal-unknown {
    color: var(--muted);
    background: var(--panel-soft);
}

.agent-content {
    display: grid;
    gap: 16px;
    margin-top: 18px;
}

.metric-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
}

.metric {
    min-height: 78px;
    padding: 12px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--panel-soft);
}

.metric-label {
    display: block;
    margin-bottom: 8px;
    color: var(--muted);
    font-size: 11px;
    font-weight: 900;
    letter-spacing: 0.06em;
    text-transform: uppercase;
}

.metric-value {
    display: block;
    overflow-wrap: anywhere;
    font-size: 18px;
    font-weight: 900;
    line-height: 1.2;
}

.reason-block {
    padding: 14px;
    border-left: 3px solid var(--brand);
    background: var(--brand-soft);
    border-radius: 8px;
    color: #22314a;
    line-height: 1.55;
}

.empty-state {
    margin: 18px 0 0;
    color: var(--muted);
    line-height: 1.55;
}

.run-meta {
    margin-top: 18px;
    color: var(--muted);
    font-size: 12px;
    line-height: 1.55;
}

.companion-section {
    margin-top: 24px;
    padding-top: 18px;
    border-top: 1px solid var(--line);
}

.companion-heading,
.companion-card-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 12px;
}

.companion-status {
    min-height: 20px;
    margin-bottom: 10px;
    color: var(--muted);
    font-size: 12px;
    font-weight: 700;
}

.companion-summary {
    min-height: 20px;
    margin: 4px 0 6px;
    color: #273449;
    font-size: 12px;
    font-weight: 800;
}

.companion-status.is-error {
    color: var(--red);
}

.companion-list {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(142px, 1fr));
    gap: 10px;
}

.companion-card {
    --gauge-color: var(--muted);
    position: relative;
    min-height: 168px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #ffffff;
    padding: 12px;
    cursor: help;
    outline: none;
    transition: border-color 140ms ease, box-shadow 140ms ease, transform 140ms ease;
}

.companion-card:hover,
.companion-card:focus-visible,
.companion-card.is-tooltip-open {
    border-color: rgba(26, 92, 255, 0.28);
    box-shadow: 0 14px 34px rgba(21, 25, 34, 0.12);
    transform: translateY(-1px);
}

.companion-error {
    border-color: rgba(180, 35, 24, 0.18);
}

.companion-score-bullish {
    --gauge-color: var(--green);
}

.companion-score-neutral {
    --gauge-color: var(--amber);
}

.companion-score-bearish,
.companion-score-unavailable {
    --gauge-color: var(--red);
}

.companion-score-unavailable {
    --gauge-color: var(--muted);
}

.companion-card h3 {
    margin: 0;
    font-size: 14px;
    line-height: 1.2;
}

.companion-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 24px;
    padding: 0 8px;
    border-radius: 999px;
    font-size: 10px;
    font-weight: 900;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    white-space: nowrap;
}

.companion-badge-ok {
    color: var(--green);
    background: var(--green-soft);
}

.companion-badge-error {
    color: var(--red);
    background: var(--red-soft);
}

.companion-gauge {
    display: grid;
    justify-items: center;
    gap: 8px;
    margin-top: 16px;
}

.companion-gauge-dial {
    position: relative;
    width: min(100%, 116px);
    aspect-ratio: 1;
    border-radius: 50%;
    background:
        radial-gradient(circle at center, #ffffff 0 53%, transparent 54%),
        conic-gradient(from -135deg, #b42318 0deg, #f59e0b 135deg, #13795b 270deg, #e7edf5 270deg 360deg);
    box-shadow: inset 0 0 0 1px rgba(217, 224, 234, 0.9);
}

.companion-gauge-dial::before {
    content: "";
    position: absolute;
    inset: 9px;
    border-radius: 50%;
    background:
        conic-gradient(from -135deg, var(--gauge-color) var(--score-angle, 0deg), #e7edf5 0deg 270deg, transparent 270deg 360deg);
    -webkit-mask: radial-gradient(circle at center, transparent 0 57%, #000 58%);
    mask: radial-gradient(circle at center, transparent 0 57%, #000 58%);
}

.companion-gauge-dial::after {
    content: "";
    position: absolute;
    inset: 22px;
    border-radius: 50%;
    background: #ffffff;
    box-shadow: inset 0 0 0 1px var(--line);
}

.companion-gauge-needle {
    position: absolute;
    left: 50%;
    top: 50%;
    z-index: 2;
    width: 3px;
    height: 40%;
    border-radius: 999px;
    background: #1f2937;
    transform: translate(-50%, -96%) rotate(var(--needle-angle));
    transform-origin: 50% 96%;
}

.companion-gauge-hub {
    position: absolute;
    left: 50%;
    top: 50%;
    z-index: 3;
    width: 12px;
    height: 12px;
    border: 2px solid #ffffff;
    border-radius: 50%;
    background: var(--gauge-color);
    transform: translate(-50%, -50%);
    box-shadow: 0 2px 8px rgba(21, 25, 34, 0.22);
}

.companion-score-value {
    display: flex;
    align-items: baseline;
    justify-content: center;
    gap: 2px;
    min-height: 36px;
    color: var(--ink);
    font-size: 32px;
    font-weight: 900;
    line-height: 1;
}

.companion-score-value span {
    color: var(--muted);
    font-size: 12px;
    font-weight: 900;
}

.companion-tooltip {
    position: absolute;
    right: 0;
    top: calc(100% + 10px);
    z-index: 30;
    width: min(330px, calc(100vw - 36px));
    padding: 12px 14px;
    border: 1px solid rgba(148, 163, 184, 0.24);
    border-radius: 8px;
    background: #17263c;
    color: #f8fbff;
    box-shadow: 0 24px 44px rgba(15, 23, 42, 0.28);
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transform: translateY(6px);
    transition: opacity 140ms ease, transform 140ms ease, visibility 140ms ease;
}

.companion-tooltip::before {
    content: "";
    position: absolute;
    right: 18px;
    bottom: 100%;
    border-width: 8px;
    border-style: solid;
    border-color: transparent transparent #17263c transparent;
}

.companion-card:hover .companion-tooltip,
.companion-card:focus-within .companion-tooltip,
.companion-card.is-tooltip-open .companion-tooltip {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

.companion-tooltip-title {
    margin: 0 0 8px;
    color: #dbeafe;
    font-size: 12px;
    font-weight: 900;
    letter-spacing: 0.04em;
    text-transform: uppercase;
}

.companion-tooltip ul {
    display: grid;
    gap: 6px;
    margin: 0;
    padding-left: 18px;
    font-size: 13px;
    line-height: 1.4;
}

@media (max-width: 1120px) {
    .explorer-grid {
        grid-template-columns: minmax(190px, 240px) minmax(0, 1fr);
    }

    .agent-panel {
        grid-column: 1 / -1;
    }
}

@media (max-width: 760px) {
    .explorer-page {
        padding: 12px;
    }

    .app-topbar,
    .quote-header {
        align-items: stretch;
        flex-direction: column;
    }

    .account-cluster {
        align-items: flex-start;
        flex-direction: column;
    }

    .explorer-grid {
        grid-template-columns: 1fr;
    }

    .symbol-rail {
        position: static;
    }

    .quote-price-block {
        text-align: left;
    }

    .chart-toolbar {
        align-items: stretch;
        flex-direction: column;
    }

    .chart-control,
    .reset-chart-button {
        width: 100%;
    }

    .quote-header h1 {
        font-size: 34px;
    }

    .last-price {
        font-size: 28px;
    }

    .chart-surface {
        height: 380px;
    }
}
