:root {
    --bg: #0a0d0c;
    --panel: #111614;
    --panel2: #0e1311;
    --line: #1f2a26;
    --ink: #e7efe9;
    --mute: #7d8f87;
    --faint: #4d5a54;
    --accent: #c6f432;
    --accent-dim: #8aa823;
    --up: #3ddc97;
    --down: #ff6b6b;
    --warn: #ffce5c;
    --mono: 'IBM Plex Mono', ui-monospace, Menlo, monospace;
    --disp: 'Bricolage Grotesque', system-ui, sans-serif;
}

* {
    box-sizing: border-box
}

html,
body {
    margin: 0
}

body {
    background:
        radial-gradient(900px 500px at 85% -10%, rgba(198, 244, 50, .07), transparent 60%),
        radial-gradient(700px 600px at -5% 110%, rgba(61, 220, 151, .05), transparent 55%),
        var(--bg);
    color: var(--ink);
    font-family: var(--mono);
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
}

.wrap {
    max-width: 100%;
    padding: 26px 32px 60px
}

header.top {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: 20px;
    flex-wrap: wrap;
    margin-bottom: 18px
}

h1 {
    font-family: var(--disp);
    font-weight: 800;
    font-size: clamp(26px, 4vw, 42px);
    letter-spacing: -.02em;
    margin: 0;
    line-height: 1
}

h1 .dot {
    color: var(--accent)
}

.sub {
    color: var(--mute);
    font-size: 12.5px;
    margin-top: 8px;
    max-width: 46ch
}

.badge {
    font-size: 10.5px;
    letter-spacing: .14em;
    text-transform: uppercase;
    color: var(--bg);
    background: var(--accent);
    padding: 5px 9px;
    border-radius: 999px;
    font-weight: 600;
    white-space: nowrap
}

.srcbar {
    display: flex;
    gap: 8px;
    align-items: center;
    margin: 6px 0 18px;
    flex-wrap: wrap
}

.srcbar input {
    flex: 1;
    min-width: 240px;
    background: var(--panel2);
    border: 1px solid var(--line);
    color: var(--ink);
    font-family: var(--mono);
    font-size: 12px;
    padding: 9px 11px;
    border-radius: 9px
}

.srcbar input:focus {
    outline: none;
    border-color: var(--accent-dim)
}

.srcbar input.invalid {
    border-color: var(--down)
}

button {
    font-family: var(--mono);
    cursor: pointer;
    border: 1px solid var(--line);
    background: var(--panel);
    color: var(--ink);
    padding: 9px 14px;
    border-radius: 9px;
    font-size: 12.5px;
    transition: .15s
}

button:hover {
    border-color: var(--accent-dim)
}

button.primary {
    background: var(--accent);
    color: #0a0d0c;
    border-color: var(--accent);
    font-weight: 600
}

button.primary:hover {
    filter: brightness(1.06)
}

button:disabled {
    opacity: .4;
    cursor: not-allowed
}

.status {
    font-size: 12.5px;
    padding: 11px 14px;
    border-radius: 10px;
    border: 1px solid var(--line);
    background: var(--panel2);
    margin-bottom: 18px;
    display: flex;
    gap: 10px;
    align-items: flex-start
}

.status.err {
    border-color: #5a2330;
    background: #1b0f12;
    color: #ffb3bd
}

.status.ok {
    border-color: #234a37;
    background: #0d1813;
    color: #bdf3d6
}

.status.warn {
    border-color: #5a4a23;
    background: #1b160d;
    color: #ffe2a6
}

.status .spin {
    width: 14px;
    height: 14px;
    border: 2px solid var(--faint);
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: s .7s linear infinite;
    flex: none;
    margin-top: 2px
}

@keyframes s {
    to {
        transform: rotate(360deg)
    }
}

.status code {
    background: #000;
    padding: 1px 5px;
    border-radius: 4px;
    color: var(--accent);
    font-size: 11.5px
}

.grid {
    display: grid;
    grid-template-columns: 320px 1fr;
    gap: 18px;
    align-items: start
}

.grid.hide-sidebar {
    grid-template-columns: 1fr
}

@media(max-width:860px) {
    .grid {
        grid-template-columns: 1fr
    }
}

.card {
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: 14px;
    padding: 16px
}

.card h2 {
    font-family: var(--disp);
    font-weight: 600;
    font-size: 14px;
    margin: 0 0 12px;
    letter-spacing: .01em
}

.card h2 .c {
    color: var(--accent-dim)
}

.schema-card {
    position: sticky;
    top: 18px
}

.schema-card .hdr {
    display: flex;
    align-items: center;
    justify-content: space-between
}

.schema-card .hdr button {
    background: none;
    border: none;
    color: #ff6b6b;
    font-size: 22px;
    padding: 0 4px;
    cursor: pointer;
    line-height: 1;
    font-weight: 600
}

.schema-card .hdr button:hover {
    filter: brightness(1.4)
}

.schema {
    max-height: calc(100vh - 250px);
    overflow: auto;
    padding-right: 4px;
}

.schema::-webkit-scrollbar {
    width: 4px;
}

.schema::-webkit-scrollbar-thumb {
    background: var(--line);
    border-radius: 10px;
}

.schema-card.hidden {
    display: none
}

.schema-search {
    width: 100%;
    background: var(--panel2);
    border: 1px solid var(--line);
    color: var(--ink);
    font-family: var(--mono);
    font-size: 11px;
    padding: 8px 10px;
    border-radius: 8px;
    margin-bottom: 14px;
}

.schema-search:focus {
    outline: none;
    border-color: var(--accent-dim);
}

.tbl-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 12px;
    border-radius: 10px;
    margin-bottom: 4px;
    cursor: pointer;
    transition: all 0.2s ease;
    border: 1px solid transparent;
}

.tbl-item:hover {
    background: rgba(198, 244, 50, 0.04);
    border-color: rgba(198, 244, 50, 0.15);
}

.tbl-item .name {
    font-size: 12.5px;
    font-weight: 500;
    color: var(--ink);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.tbl-item:hover .name {
    color: var(--accent);
}

.tbl-item .count {
    font-size: 10px;
    color: var(--faint);
    font-weight: 600;
    background: var(--panel2);
    padding: 2px 6px;
    border-radius: 6px;
    margin-left: 8px;
    flex-shrink: 0;
}

.tabs {
    display: flex;
    gap: 6px;
    margin-bottom: 14px;
    flex-wrap: wrap
}

.tab {
    font-size: 12px;
    padding: 7px 13px;
    border-radius: 999px;
    border: 1px solid var(--line);
    background: var(--panel2);
    color: var(--mute)
}

.tab.active {
    background: var(--accent);
    color: #0a0d0c;
    border-color: var(--accent);
    font-weight: 600
}

.ctrls {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    align-items: flex-end;
    margin-bottom: 14px
}

.field {
    display: flex;
    flex-direction: column;
    gap: 5px
}

.field label {
    font-size: 10px;
    letter-spacing: .12em;
    text-transform: uppercase;
    color: var(--faint)
}

select,
.multi {
    background: var(--panel2);
    border: 1px solid var(--line);
    color: var(--ink);
    font-family: var(--mono);
    font-size: 12.5px;
    padding: 8px 10px;
    border-radius: 9px;
    min-width: 130px
}

select:focus {
    outline: none;
    border-color: var(--accent-dim)
}

.multi {
    min-width: 200px;
    min-height: 90px
}

/* ── shadcn-style custom dropdown ── */
.cdd {
    position: relative;
    display: inline-block;
    min-width: 170px;
    font-family: var(--mono);
    font-size: 12.5px;
    user-select: none
}

.cdd-trigger {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    width: 100%;
    padding: 8px 10px;
    background: var(--panel2);
    border: 1px solid var(--line);
    border-radius: 9px;
    color: var(--ink);
    font-family: inherit;
    font-size: inherit;
    cursor: pointer;
    transition: border-color .15s
}

.cdd-trigger:hover {
    border-color: var(--faint)
}

.cdd-trigger:focus-visible {
    outline: none;
    border-color: var(--accent-dim);
    box-shadow: 0 0 0 2px rgba(198, 244, 50, .15)
}

.cdd.cdd-open .cdd-trigger {
    border-color: var(--accent-dim);
    border-bottom-color: var(--panel2);
    border-radius: 9px 9px 0 0
}

.cdd-value {
    flex: 1;
    text-align: left;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    color: var(--ink)
}

.cdd-value.placeholder {
    color: var(--faint)
}

.cdd-chevron {
    flex: none;
    width: 16px;
    height: 16px;
    color: var(--mute);
    transition: transform .2s
}

.cdd.cdd-open .cdd-chevron {
    transform: rotate(180deg)
}

.cdd-menu {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    z-index: 50;
    max-height: 260px;
    overflow-y: auto;
    background: var(--panel2);
    border: 1px solid var(--line);
    border-top: none;
    border-radius: 0 0 9px 9px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, .5);
    display: none;
    padding: 4px
}

.cdd.cdd-open .cdd-menu {
    display: block
}

.cdd-menu::-webkit-scrollbar {
    width: 4px
}

.cdd-menu::-webkit-scrollbar-thumb {
    background: var(--line);
    border-radius: 10px
}

.cdd-option {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 7px 10px;
    border-radius: 6px;
    cursor: pointer;
    color: var(--mute);
    font-size: 12px;
    transition: background .1s, color .1s
}

.cdd-option:hover,
.cdd-option.active {
    background: rgba(198, 244, 50, .07);
    color: var(--ink)
}

.cdd-option:focus-visible {
    outline: none;
    background: rgba(198, 244, 50, .1);
    color: var(--ink)
}

.cdd-option.selected {
    color: var(--accent);
    font-weight: 500
}

.cdd-option input[type="checkbox"] {
    accent-color: var(--accent);
    width: 14px;
    height: 14px;
    margin: 0;
    flex: none;
    pointer-events: none
}

.cdd-multi .cdd-option.selected {
    color: var(--ink);
    background: rgba(198, 244, 50, .06)
}

.cdd-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 18px;
    height: 18px;
    padding: 0 5px;
    border-radius: 999px;
    background: var(--accent);
    color: #0a0d0c;
    font-size: 10px;
    font-weight: 600;
    line-height: 1
}

.cdd-clear {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: transparent;
    border: none;
    color: var(--faint);
    cursor: pointer;
    font-size: 14px;
    padding: 0;
    line-height: 1;
    transition: color .15s, background .15s;
    flex: none
}

.cdd-clear:hover {
    color: var(--down);
    background: rgba(255, 107, 107, .1)
}

.cdd-multi .cdd-trigger {
    min-height: 37px
}

.seg {
    display: inline-flex;
    border: 1px solid var(--line);
    border-radius: 9px;
    overflow: hidden
}

.seg button {
    border: none;
    border-radius: 0;
    background: var(--panel2);
    padding: 8px 12px
}

.seg button.on {
    background: var(--accent);
    color: #0a0d0c;
    font-weight: 600
}

.chk {
    display: flex;
    align-items: center;
    gap: 7px;
    font-size: 12px;
    color: var(--mute);
    cursor: pointer;
    user-select: none
}

.chk input {
    accent-color: var(--accent);
    width: 15px;
    height: 15px
}

.stats {
    display: flex;
    gap: 18px;
    flex-wrap: wrap;
    margin: 4px 0 14px;
    font-size: 11.5px;
    color: var(--mute)
}

.stats b {
    color: var(--ink);
    font-weight: 600
}

/* explore: ticker header */
.tickerHead {
    display: flex;
    align-items: center;
    gap: 20px;
    flex-wrap: wrap;
    margin-bottom: 16px
}

.tickerSel {
    font-family: var(--disp);
    font-weight: 700;
    font-size: 21px;
    letter-spacing: -.01em;
    background: var(--panel2);
    border: 1px solid var(--line);
    color: var(--ink);
    padding: 9px 14px;
    border-radius: 12px;
    min-width: 150px;
    cursor: pointer
}

.tickerName {
    font-family: var(--disp);
    font-size: 21px;
    color: #ffffff;
    font-weight: 700;
    margin: 0 auto;
    text-align: center;
}

.tickerSel:focus {
    outline: none;
    border-color: var(--accent-dim)
}

.px {
    display: flex;
    align-items: baseline;
    gap: 12px
}

#ex_last {
    font-family: var(--disp);
    font-weight: 800;
    font-size: 30px;
    line-height: 1
}

.chg {
    font-size: 14px;
    font-weight: 600;
    font-family: var(--mono)
}

.chg.up {
    color: var(--up)
}

.chg.down {
    color: var(--down)
}

/* explore: toolbar (period + chart type) */
.toolbar {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
    margin-bottom: 14px
}

.seg.periods button {
    padding: 7px 13px;
    font-size: 12px
}

.rangeToggle {
    font-size: 12px;
    padding: 8px 13px;
    border-radius: 9px
}

.rangeToggle.on {
    background: var(--accent);
    color: #0a0d0c;
    border-color: var(--accent);
    font-weight: 600
}

.customRange {
    display: flex;
    align-items: center;
    gap: 8px
}

.customRange input[type=date] {
    background: var(--panel2);
    border: 1px solid var(--line);
    color: var(--ink);
    font-family: var(--mono);
    font-size: 12px;
    padding: 7px 9px;
    border-radius: 8px;
    color-scheme: dark
}

.customRange input[type=date]:focus {
    outline: none;
    border-color: var(--accent-dim)
}

/* explore: stat cards + advanced */
.statbar {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    margin: 14px 0 4px
}

.st {
    background: var(--panel2);
    border: 1px solid var(--line);
    border-radius: 10px;
    padding: 8px 13px;
    min-width: 84px
}

.st.st-warn {
    border-color: #5a4a23
}

.st .k {
    display: block;
    font-size: 9.5px;
    letter-spacing: .13em;
    text-transform: uppercase;
    color: var(--faint)
}

.st.st-warn .k {
    color: var(--warn)
}

.st .v {
    display: block;
    font-size: 13.5px;
    color: var(--ink);
    margin-top: 3px;
    font-weight: 500
}

details.adv {
    margin-top: 10px
}

details.adv summary {
    cursor: pointer;
    font-size: 11px;
    color: var(--faint);
    letter-spacing: .04em
}

details.adv summary:hover {
    color: var(--mute)
}

details.adv .ctrls {
    margin-top: 12px
}

#chart,
#chartCompare {
    width: 100%;
    height: min(62vh, 640px);
    min-height: 440px
}

.card[data-pane="explore"] {
    width: 100%
}

.hint {
    font-size: 11px;
    color: var(--faint);
    margin-top: 8px
}

textarea {
    width: 100%;
    min-height: 120px;
    background: #070a09;
    border: 1px solid var(--line);
    color: var(--ink);
    font-family: var(--mono);
    font-size: 12.5px;
    padding: 12px;
    border-radius: 10px;
    resize: vertical
}

textarea:focus {
    outline: none;
    border-color: var(--accent-dim)
}

.results {
    margin-top: 14px;
    overflow: auto;
    max-height: 380px;
    border: 1px solid var(--line);
    border-radius: 10px
}

table.res {
    border-collapse: collapse;
    width: 100%;
    font-size: 11.5px
}

table.res th {
    position: sticky;
    top: 0;
    background: var(--panel2);
    color: var(--accent-dim);
    text-align: left;
    padding: 7px 10px;
    border-bottom: 1px solid var(--line);
    font-weight: 600;
    white-space: nowrap
}

table.res td {
    padding: 6px 10px;
    border-bottom: 1px solid #161e1b;
    color: var(--mute);
    white-space: nowrap
}

table.res tr:hover td {
    color: var(--ink);
    background: #0c110f
}

.hidden {
    display: none !important
}

details.notes {
    margin-top: 22px;
    border: 1px solid var(--line);
    border-radius: 12px;
    background: var(--panel2);
    padding: 0 16px
}

details.notes summary {
    cursor: pointer;
    padding: 14px 0;
    font-family: var(--disp);
    font-weight: 600;
    font-size: 13.5px;
    color: var(--accent-dim)
}

details.notes pre {
    background: #000;
    border: 1px solid var(--line);
    border-radius: 9px;
    padding: 12px;
    overflow: auto;
    font-size: 11.5px;
    color: var(--ink)
}

details.notes p {
    font-size: 12.5px;
    color: var(--mute)
}

details.notes code {
    color: var(--accent)
}

a {
    color: var(--accent-dim)
}
