/* sora.markets - Financial Dashboard
   Palette:
     #0f1117  Dark background
     #1a1d27  Panel background
     #2a2d37  Border
     #e5e7eb  Text
     #22c55e  Up green
     #ef4444  Down red
     #3b82f6  Accent blue
   Fonts: Inter (display+body), Roboto Mono (numerical data)
*/

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

:root {
    --c-dark: #0f1117;
    --c-panel: #1a1d27;
    --c-panel-2: #1f2330;
    --c-border: #2a2d37;
    --c-text: #e5e7eb;
    --c-text-muted: #8a909e;
    --c-up: #22c55e;
    --c-down: #ef4444;
    --c-blue: #3b82f6;
    --c-blue-soft: rgba(59, 130, 246, 0.12);
    --ticker-h: 36px;
    --topbar-h: 56px;
    --footer-h: 40px;
    --gap: 12px;
}

html, body {
    height: 100%;
}

body {
    background: var(--c-dark);
    color: var(--c-text);
    font-family: 'Inter', system-ui, -apple-system, sans-serif;
    font-size: 0.875rem;
    line-height: 1.5;
    font-weight: 400;
    overflow-x: hidden;
}

/* Numerical data shorthand */
.mono, .market-price, .market-change, .chart-price, .chart-change-abs,
.chart-change-pct, .stat-value, .ticker-item, .vol-value, .sector-pct,
.book-row, .orderbook-mid, .pulse-value, .session-clock, .market-symbol,
.news-time, .calendar-time {
    font-family: 'Roboto Mono', ui-monospace, SFMono-Regular, Menlo, monospace;
    font-size: 0.8125rem;
    font-variant-numeric: tabular-nums;
    font-weight: 400;
}

a { color: var(--c-blue); text-decoration: none; }
a:hover { text-decoration: underline; }
button { font: inherit; color: inherit; background: transparent; border: none; cursor: pointer; }
input { font: inherit; color: inherit; background: transparent; border: none; outline: none; }
ul { list-style: none; }

.muted { color: var(--c-text-muted); font-weight: 400; }
.up { color: var(--c-up); }
.down { color: var(--c-down); }

/* ===== TICKER BAR (top scrolling) ===== */
.ticker-bar {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: var(--ticker-h);
    background: #0f1117;
    border-bottom: 1px solid var(--c-border);
    overflow: hidden;
    z-index: 50;
    display: flex;
    align-items: center;
}

.ticker-track {
    display: inline-flex;
    white-space: nowrap;
    animation: ticker 60s linear infinite;
    will-change: transform;
}

.ticker-item {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 0 18px;
    border-right: 1px solid var(--c-border);
    height: var(--ticker-h);
    color: var(--c-text);
}

.ticker-symbol {
    color: var(--c-text-muted);
    font-weight: 500;
}

.ticker-price {
    color: var(--c-text);
}

@keyframes ticker {
    0%   { transform: translateX(0); }
    100% { transform: translateX(-50%); }
}

@media (prefers-reduced-motion: reduce) {
    .ticker-track { animation: none; }
}

/* ===== TOPBAR ===== */
.topbar {
    position: fixed;
    top: var(--ticker-h);
    left: 0;
    right: 0;
    height: var(--topbar-h);
    background: var(--c-panel);
    border-bottom: 1px solid var(--c-border);
    display: grid;
    grid-template-columns: 280px 1fr auto;
    align-items: center;
    padding: 0 16px;
    gap: 16px;
    z-index: 40;
}

.brand {
    display: flex;
    align-items: center;
    gap: 10px;
    min-width: 0;
}

.brand-mark {
    width: 28px;
    height: 28px;
    background: var(--c-blue);
    color: #fff;
    border-radius: 6px;
    display: grid;
    place-items: center;
    font-weight: 700;
    font-size: 0.75rem;
    letter-spacing: 0.5px;
}

.brand-name {
    font-weight: 600;
    font-size: 1rem;
    letter-spacing: -0.01em;
}

.brand-tag {
    color: var(--c-text-muted);
    font-size: 0.75rem;
    border-left: 1px solid var(--c-border);
    padding-left: 10px;
    margin-left: 4px;
}

.topnav {
    display: flex;
    align-items: center;
    gap: 4px;
}

.topnav-link {
    color: var(--c-text-muted);
    padding: 8px 12px;
    border-radius: 6px;
    font-size: 0.8125rem;
    font-weight: 500;
    transition: color 0.15s, background 0.15s;
}

.topnav-link:hover {
    color: var(--c-text);
    background: rgba(255,255,255,0.04);
    text-decoration: none;
}

.topnav-link.active {
    color: var(--c-text);
    background: var(--c-blue-soft);
}

.topbar-meta {
    display: flex;
    align-items: center;
    gap: 14px;
}

.search-box {
    display: flex;
    align-items: center;
    gap: 8px;
    background: var(--c-dark);
    border: 1px solid var(--c-border);
    border-radius: 6px;
    padding: 6px 10px;
    width: 280px;
    transition: border-color 0.15s;
}

.search-box:focus-within {
    border-color: var(--c-blue);
}

.search-icon {
    color: var(--c-text-muted);
    flex-shrink: 0;
}

.search-box input {
    flex: 1;
    font-size: 0.8125rem;
    color: var(--c-text);
}

.search-box input::placeholder {
    color: var(--c-text-muted);
}

.session-info {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 10px;
    background: var(--c-dark);
    border: 1px solid var(--c-border);
    border-radius: 6px;
}

.session-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--c-up);
    box-shadow: 0 0 8px rgba(34, 197, 94, 0.7);
    animation: pulse 2s ease-in-out infinite;
}

.session-label {
    color: var(--c-up);
    font-size: 0.6875rem;
    font-weight: 600;
    letter-spacing: 0.06em;
}

.session-clock {
    color: var(--c-text-muted);
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50%      { opacity: 0.4; }
}

/* ===== DASHBOARD ===== */
.dashboard {
    position: relative;
    margin-top: calc(var(--ticker-h) + var(--topbar-h));
    padding: var(--gap);
    display: grid;
    grid-template-columns: 260px 1fr 280px;
    gap: var(--gap);
    min-height: calc(100vh - var(--ticker-h) - var(--topbar-h) - var(--footer-h));
}

.panel {
    background: var(--c-panel);
    border: 1px solid var(--c-border);
    border-radius: 6px;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

.left-panel,
.right-panel {
    gap: 0;
}

.center-panel {
    background: var(--c-panel);
}

.panel-section {
    border-bottom: 1px solid var(--c-border);
    padding: 0;
}

.panel-section:last-child {
    border-bottom: none;
}

.panel-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 14px;
    border-bottom: 1px solid var(--c-border);
    background: linear-gradient(180deg, rgba(255,255,255,0.02), transparent);
}

.panel-title {
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--c-text);
}

.panel-meta {
    font-size: 0.6875rem;
    color: var(--c-text-muted);
    font-family: 'Roboto Mono', monospace;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.panel-tabs {
    display: flex;
    gap: 2px;
}

.panel-tab {
    color: var(--c-text-muted);
    font-size: 0.6875rem;
    font-weight: 500;
    padding: 4px 8px;
    border-radius: 4px;
    transition: color 0.15s, background 0.15s;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.panel-tab:hover {
    color: var(--c-text);
}

.panel-tab.active {
    color: var(--c-blue);
    background: var(--c-blue-soft);
}

/* ===== MARKET LIST (watchlist) ===== */
.market-list {
    padding: 4px 0;
    max-height: 360px;
    overflow-y: auto;
}

.market-row {
    display: grid;
    grid-template-columns: 1fr auto auto;
    grid-template-rows: auto auto;
    align-items: center;
    column-gap: 8px;
    padding: 8px 14px;
    border-left: 2px solid transparent;
    cursor: pointer;
    transition: background 0.15s, border-color 0.15s;
}

.market-row:hover {
    background: rgba(59, 130, 246, 0.06);
}

.market-row.active {
    background: var(--c-blue-soft);
    border-left-color: var(--c-blue);
}

.market-symbol {
    grid-column: 1;
    grid-row: 1;
    font-weight: 500;
    color: var(--c-text);
    font-size: 0.8125rem;
}

.market-name {
    grid-column: 1;
    grid-row: 2;
    color: var(--c-text-muted);
    font-size: 0.6875rem;
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
}

.market-spark {
    grid-column: 2;
    grid-row: 1 / span 2;
    width: 60px;
    height: 24px;
}

.market-price {
    grid-column: 3;
    grid-row: 1;
    text-align: right;
    color: var(--c-text);
}

.market-change {
    grid-column: 3;
    grid-row: 2;
    text-align: right;
    font-size: 0.6875rem;
}

/* Volume bars in sidebar */
.volume-list {
    padding: 8px 14px 12px;
    display: grid;
    gap: 6px;
}

.vol-row {
    display: grid;
    grid-template-columns: 60px 1fr auto;
    align-items: center;
    gap: 8px;
}

.vol-symbol {
    font-family: 'Roboto Mono', monospace;
    font-size: 0.75rem;
    color: var(--c-text);
}

.vol-bar {
    height: 8px;
    background: rgba(59, 130, 246, 0.08);
    border-radius: 2px;
    overflow: hidden;
}

.vol-bar-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--c-blue), #60a5fa);
    border-radius: 2px;
    transition: width 0.5s ease;
}

.vol-value {
    color: var(--c-text-muted);
    font-size: 0.6875rem;
}

/* Sectors */
.sector-list {
    padding: 8px 14px 12px;
    display: grid;
    gap: 4px;
}

.sector-row {
    display: grid;
    grid-template-columns: 1fr 60px 50px;
    align-items: center;
    gap: 8px;
    padding: 4px 0;
}

.sector-name {
    font-size: 0.75rem;
    color: var(--c-text);
}

.sector-track {
    height: 4px;
    background: rgba(255,255,255,0.05);
    border-radius: 2px;
    position: relative;
}

.sector-bar {
    position: absolute;
    top: 0;
    bottom: 0;
    width: 50%;
    border-radius: 2px;
}

.sector-bar.up { background: var(--c-up); right: 50%; transform-origin: right; }
.sector-bar.down { background: var(--c-down); left: 50%; transform-origin: left; }

.sector-pct {
    text-align: right;
    font-size: 0.6875rem;
}

/* ===== CHART AREA ===== */
.chart-header {
    display: grid;
    grid-template-columns: auto 1fr auto;
    align-items: center;
    gap: 24px;
    padding: 16px 20px;
    border-bottom: 1px solid var(--c-border);
}

.chart-symbol {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.chart-symbol-name {
    font-size: clamp(1.25rem, 2vw, 1.5rem);
    font-weight: 600;
    letter-spacing: -0.02em;
    line-height: 1.1;
}

.chart-symbol-meta {
    color: var(--c-text-muted);
    font-size: 0.75rem;
}

.chart-price-block {
    display: flex;
    align-items: baseline;
    gap: 14px;
    justify-content: flex-start;
}

.chart-price {
    font-size: 1.625rem;
    font-weight: 500;
    letter-spacing: -0.01em;
    color: var(--c-text);
}

.chart-change {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    line-height: 1.2;
    font-size: 0.875rem;
    font-weight: 500;
}

.chart-change-pct {
    font-size: 0.75rem;
    opacity: 0.85;
}

.chart-controls {
    display: flex;
    align-items: center;
    gap: 12px;
}

.chart-ranges {
    display: flex;
    gap: 2px;
    background: var(--c-dark);
    border: 1px solid var(--c-border);
    border-radius: 6px;
    padding: 2px;
}

.range-btn {
    color: var(--c-text-muted);
    font-size: 0.6875rem;
    font-weight: 500;
    padding: 5px 10px;
    border-radius: 4px;
    transition: color 0.15s, background 0.15s;
    letter-spacing: 0.04em;
}

.range-btn:hover {
    color: var(--c-text);
}

.range-btn.active {
    color: var(--c-text);
    background: var(--c-blue);
}

/* SVG chart */
.chart-canvas-wrap {
    position: relative;
    width: 100%;
    height: 320px;
    background: linear-gradient(180deg, transparent, rgba(0,0,0,0.15));
    border-bottom: 1px solid var(--c-border);
}

.chart-canvas {
    width: 100%;
    height: 100%;
    display: block;
}

.chart-grid line {
    stroke: var(--c-border);
    stroke-width: 1;
    stroke-dasharray: 2 4;
    opacity: 0.6;
}

.chart-axis text {
    fill: var(--c-text-muted);
    font-family: 'Roboto Mono', monospace;
    font-size: 10px;
}

.chart-line {
    stroke: var(--c-blue);
    stroke-width: 2;
    fill: none;
    stroke-linejoin: round;
    stroke-linecap: round;
    filter: drop-shadow(0 0 4px rgba(59,130,246,0.35));
}

.chart-area {
    transition: opacity 0.3s;
}

.hover-line {
    pointer-events: none;
}

.hover-dot {
    pointer-events: none;
}

.chart-tooltip {
    position: absolute;
    pointer-events: none;
    background: var(--c-panel-2);
    border: 1px solid var(--c-border);
    border-radius: 6px;
    padding: 6px 10px;
    font-family: 'Roboto Mono', monospace;
    font-size: 0.75rem;
    color: var(--c-text);
    box-shadow: 0 4px 12px rgba(0,0,0,0.4);
    z-index: 5;
    transform: translate(-50%, -120%);
    white-space: nowrap;
}

.tt-time {
    color: var(--c-text-muted);
    font-size: 0.6875rem;
    margin-bottom: 2px;
}

.tt-price {
    color: var(--c-text);
    font-weight: 500;
}

/* Stats row */
.chart-stats {
    display: grid;
    grid-template-columns: repeat(6, 1fr);
    border-bottom: 1px solid var(--c-border);
}

.stat {
    display: flex;
    flex-direction: column;
    gap: 4px;
    padding: 12px 16px;
    border-right: 1px solid var(--c-border);
}

.stat:last-child { border-right: none; }

.stat-label {
    color: var(--c-text-muted);
    font-size: 0.6875rem;
    text-transform: uppercase;
    letter-spacing: 0.06em;
}

.stat-value {
    color: var(--c-text);
    font-size: 0.8125rem;
    font-weight: 500;
}

/* Order book */
.orderflow {
    flex: 1;
    display: flex;
    flex-direction: column;
}

.orderbook {
    display: grid;
    grid-template-rows: 1fr auto 1fr;
    flex: 1;
    min-height: 220px;
}

.orderbook-side {
    display: grid;
    grid-auto-rows: minmax(20px, 1fr);
    padding: 4px 0;
    overflow: hidden;
}

.orderbook-side.asks {
    align-content: end;
}

.book-row {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    align-items: center;
    padding: 2px 16px;
    position: relative;
    font-size: 0.75rem;
    overflow: hidden;
}

.book-row .book-bg {
    position: absolute;
    top: 0; bottom: 0;
    right: 0;
    z-index: 0;
    transition: width 0.4s;
}

.asks .book-bg { background: rgba(239, 68, 68, 0.10); }
.bids .book-bg { background: rgba(34, 197, 94, 0.10); }

.book-row > span { position: relative; z-index: 1; }

.book-price-ask { color: var(--c-down); }
.book-price-bid { color: var(--c-up); }
.book-size, .book-total {
    color: var(--c-text-muted);
    text-align: right;
}
.book-total { color: var(--c-text); }

.orderbook-mid {
    text-align: center;
    padding: 8px;
    background: var(--c-dark);
    border-top: 1px solid var(--c-border);
    border-bottom: 1px solid var(--c-border);
    color: var(--c-blue);
    font-weight: 500;
    font-size: 0.875rem;
}

/* ===== RIGHT PANEL: pulse, news, calendar ===== */
.pulse {
    padding: 12px 14px 14px;
    display: grid;
    gap: 10px;
}

.pulse-row {
    display: grid;
    grid-template-columns: 90px 1fr 32px;
    align-items: center;
    gap: 8px;
}

.pulse-label {
    font-size: 0.75rem;
    color: var(--c-text-muted);
}

.pulse-bar {
    height: 6px;
    background: rgba(255,255,255,0.05);
    border-radius: 3px;
    overflow: hidden;
}

.pulse-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--c-blue), #60a5fa);
    border-radius: 3px;
    transition: width 0.6s ease;
}

.pulse-value {
    text-align: right;
    color: var(--c-text);
    font-size: 0.75rem;
}

/* News */
.news-list {
    padding: 4px 0;
    max-height: 320px;
    overflow-y: auto;
}

.news-item {
    padding: 10px 14px;
    border-bottom: 1px solid var(--c-border);
    display: flex;
    flex-direction: column;
    gap: 4px;
    cursor: pointer;
    transition: background 0.15s;
}

.news-item:last-child { border-bottom: none; }

.news-item:hover {
    background: rgba(255,255,255,0.02);
}

.news-meta {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 0.6875rem;
    color: var(--c-text-muted);
}

.news-source {
    text-transform: uppercase;
    letter-spacing: 0.06em;
    font-weight: 500;
    color: var(--c-blue);
}

.news-time {
    color: var(--c-text-muted);
}

.news-title {
    font-size: 0.8125rem;
    line-height: 1.4;
    color: var(--c-text);
    font-weight: 500;
}

.news-tag {
    display: inline-block;
    padding: 1px 6px;
    border-radius: 3px;
    font-size: 0.625rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-top: 2px;
    align-self: flex-start;
}

.news-tag.tag-up { background: rgba(34, 197, 94, 0.15); color: var(--c-up); }
.news-tag.tag-down { background: rgba(239, 68, 68, 0.15); color: var(--c-down); }
.news-tag.tag-neutral { background: rgba(229, 231, 235, 0.08); color: var(--c-text-muted); }

/* Calendar */
.calendar-list {
    padding: 4px 0;
}

.calendar-item {
    display: grid;
    grid-template-columns: 64px 1fr auto;
    align-items: center;
    gap: 10px;
    padding: 8px 14px;
    border-bottom: 1px solid var(--c-border);
}

.calendar-item:last-child { border-bottom: none; }

.calendar-time {
    color: var(--c-blue);
    font-size: 0.75rem;
}

.calendar-event {
    font-size: 0.8125rem;
    color: var(--c-text);
}

.calendar-event small {
    display: block;
    color: var(--c-text-muted);
    font-size: 0.6875rem;
    margin-top: 1px;
}

.calendar-impact {
    display: inline-flex;
    gap: 2px;
}

.impact-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--c-border);
}

.impact-dot.lit { background: var(--c-blue); }
.impact-high .impact-dot.lit { background: var(--c-down); }
.impact-medium .impact-dot.lit { background: #f59e0b; }

/* Footer */
.footer {
    height: var(--footer-h);
    border-top: 1px solid var(--c-border);
    background: var(--c-panel);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 16px;
    font-size: 0.6875rem;
    color: var(--c-text-muted);
}

.footer-left, .footer-right {
    display: flex;
    align-items: center;
    gap: 10px;
}

.dot-sep { color: var(--c-border); }

.footer-link {
    color: var(--c-text-muted);
    transition: color 0.15s;
}

.footer-link:hover {
    color: var(--c-blue);
    text-decoration: none;
}

/* Scrollbars */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: var(--c-dark);
}

::-webkit-scrollbar-thumb {
    background: var(--c-border);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: #3a3f4d;
}

/* Responsive */
@media (max-width: 1200px) {
    .dashboard {
        grid-template-columns: 240px 1fr 260px;
    }
    .topbar {
        grid-template-columns: 240px 1fr auto;
    }
    .search-box {
        width: 220px;
    }
}

@media (max-width: 980px) {
    .dashboard {
        grid-template-columns: 1fr;
    }
    .topbar {
        grid-template-columns: auto 1fr;
        padding: 0 12px;
    }
    .topnav { display: none; }
    .brand-tag { display: none; }
    .search-box { width: 180px; }
    .chart-stats {
        grid-template-columns: repeat(3, 1fr);
    }
    .stat:nth-child(3) { border-right: none; }
    .stat:nth-child(4), .stat:nth-child(5) {
        border-top: 1px solid var(--c-border);
    }
}

@media (max-width: 640px) {
    .chart-header {
        grid-template-columns: 1fr;
        gap: 12px;
    }
    .chart-stats {
        grid-template-columns: repeat(2, 1fr);
    }
    .stat { border-right: 1px solid var(--c-border); }
    .stat:nth-child(even) { border-right: none; }
    .session-info { display: none; }
}
