:root {
    --bg-color: #0f111a;
    --bg-gradient: radial-gradient(circle at top right, #1a1c29, #0f111a);
    --panel-bg: rgba(26, 28, 41, 0.6);
    --panel-border: rgba(255, 255, 255, 0.05);
    --text-primary: #ffffff;
    --text-secondary: #94a3b8;
    --accent-blue: #00f0ff;
    --accent-green: #00ff9d;
    --accent-red: #ff3381;
    --font-main: 'Inter', sans-serif;
}

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

body {
    font-family: var(--font-main);
    background: var(--bg-color);
    background-image: var(--bg-gradient);
    color: var(--text-primary);
    min-height: 100vh;
    overflow-x: hidden;
}

#app {
    display: flex;
    height: 100vh;
}

.glass-panel {
    background: var(--panel-bg);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid var(--panel-border);
    border-radius: 16px;
    box-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.3);
    margin-bottom: 8px;
}

/* Sidebar */
.sidebar {
    width: 280px;
    background: rgba(15, 17, 26, 0.8);
    border-right: 1px solid var(--panel-border);
    padding: 24px;
    display: flex;
    flex-direction: column;
    gap: 32px;
}

.logo h1 {
    font-size: 32px;
    font-weight: 700;
    letter-spacing: -0.5px;
}

.logo-bird {
    height: 36px;
    width: auto;
    vertical-align: middle;
    margin-bottom: 2px;
}

.search-container {
    display: flex;
    gap: 8px;
    position: relative;
}

.search-container input {
    flex: 1;
    min-width: 0;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--panel-border);
    border-radius: 8px;
    padding: 10px 14px;
    color: var(--text-primary);
    font-family: var(--font-main);
    font-size: 16px;
    outline: none;
    transition: all 0.3s ease;
}

.search-container input:focus {
    border-color: var(--accent-blue);
    background: rgba(255, 255, 255, 0.1);
}

.search-container button {
    background: var(--accent-blue);
    color: #000;
    border: none;
    border-radius: 8px;
    padding: 10px 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: transform 0.2s, opacity 0.2s;
}

.search-container button:hover {
    opacity: 0.9;
    transform: translateY(-1px);
}

.watchlist h3 {
    font-size: 14px;
    text-transform: uppercase;
    color: var(--text-secondary);
    letter-spacing: 1px;
    margin-bottom: 16px;
}

.watchlist ul {
    list-style: none;
}

.watchlist li {
    padding: 10px 12px;
    border-radius: 8px;
    cursor: pointer;
    transition: background 0.2s;
}

.watchlist li:hover {
    background: rgba(255, 255, 255, 0.05);
}

.watchlist-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 8px;
}

.wi-left {
    display: flex;
    flex-direction: column;
    gap: 3px;
    overflow: hidden;
}

.wi-ticker {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-primary);
}

.wi-name {
    font-size: 11px;
    color: var(--text-secondary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 140px;
}

.wi-right {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 3px;
    flex-shrink: 0;
}

.wi-price {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-primary);
}

.wi-change {
    font-size: 11px;
    font-weight: 500;
    color: var(--text-secondary);
}

/* Custom Watchlist */
.watchlist-add-container {
    display: flex;
    gap: 6px;
    margin-bottom: 12px;
}

.watchlist-add-container input {
    flex: 1;
    min-width: 0;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--panel-border);
    border-radius: 6px;
    padding: 6px 10px;
    color: var(--text-primary);
    font-family: var(--font-main);
    font-size: 13px;
    outline: none;
    transition: all 0.3s ease;
}

.watchlist-add-container input:focus {
    border-color: var(--accent-blue);
    background: rgba(255, 255, 255, 0.1);
}

.watchlist-add-container button {
    background: var(--accent-blue);
    color: #000;
    border: none;
    border-radius: 6px;
    padding: 6px 8px;
    cursor: pointer;
    transition: opacity 0.2s;
}

.watchlist-add-container button:hover {
    opacity: 0.9;
}

.custom-watchlist {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-height: 0;
}

.scrollable-list {
    flex: 1;
    overflow-y: auto;
    padding-right: 4px;
    min-height: 0;
}

.scrollable-list::-webkit-scrollbar {
    width: 4px;
}

.scrollable-list::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.2);
    border-radius: 4px;
}

.watchlist-item-wrapper {
    position: relative;
    display: flex;
    align-items: center;
}

.watchlist-item {
    flex: 1;
    transition: opacity 0.2s;
}

.wi-remove,
.wi-star {
    position: absolute;
    right: 8px;
    background: transparent;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    opacity: 0;
    transition: opacity 0.2s, color 0.2s;
    padding: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.wi-remove:hover {
    color: var(--accent-red);
}

.wi-star:hover,
.wi-star.active {
    color: #ffd700;
}

.watchlist li:hover .wi-remove,
.watchlist li:hover .wi-star {
    opacity: 1;
}

.watchlist li:hover .wi-right {
    opacity: 0;
}

/* Dashboard */
.dashboard {
    flex: 1;
    min-width: 800px;
    padding: 16px 40px 32px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 24px;
}

.dashboard-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 24px;
    position: relative;
    z-index: 10;
}

.global-search-container {
    width: 480px;
    max-width: 100%;
}

.global-search-container .search-icon {
    position: absolute;
    left: 12px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-secondary);
    pointer-events: none;
}

.global-search-container input {
    padding-left: 36px;
    width: 100%;
}

.stock-info {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.stock-name-row {
    display: flex;
    align-items: center;
    gap: 12px;
}

.header-star-btn {
    background: transparent;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 4px;
    border-radius: 4px;
    transition: color 0.2s, background 0.2s;
}

.header-star-btn:hover {
    color: #ffd700;
    background: rgba(255, 255, 255, 0.05);
}

.header-star-btn.active {
    color: #ffd700;
    fill: #ffd700;
}
.header-star-btn.active svg {
    fill: currentColor;
}

.stock-name-row h2 {
    font-size: 28px;
    font-weight: 700;
    margin: 0;
}

.stock-name-row #stock-ticker {
    font-size: 14px;
    color: var(--text-secondary);
    background: rgba(255, 255, 255, 0.1);
    padding: 4px 8px;
    border-radius: 4px;
    font-weight: 600;
}

.stock-price-row {
    display: flex;
    align-items: baseline;
    gap: 10px;
}

#current-price {
    font-size: 24px;
    font-weight: 700;
    color: var(--text-primary);
}

#price-change-abs {
    font-size: 20px;
    font-weight: 500;
}

#price-change-pct {
    font-size: 18px;
    font-weight: 400;
}

.quote-time {
    font-size: 14px;
    font-weight: 400;
    color: var(--text-secondary);
    margin-left: 8px;
    padding-bottom: 2px;
}

.positive {
    color: var(--accent-green);
}

.negative {
    color: var(--accent-red);
}

.chart-section {
    width: 100%;
    height: 600px;
    padding: 16px;
    display: flex;
    flex-direction: column;
}

.chart-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-top: 12px;
}

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

.chart-type-selector {
    display: flex;
    gap: 4px;
    background: rgba(0, 0, 0, 0.2);
    padding: 4px;
    border-radius: 8px;
    border: 1px solid var(--panel-border);
}

.chart-type-btn {
    background: transparent;
    border: none;
    color: var(--text-secondary);
    padding: 6px 10px;
    border-radius: 6px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}

.chart-type-btn:hover {
    color: var(--text-primary);
    background: rgba(255, 255, 255, 0.1);
}

.chart-type-btn.active {
    background: var(--accent-blue);
    color: #000;
    box-shadow: 0 0 10px rgba(0, 240, 255, 0.4);
}

.time-range-selector {
    display: flex;
    gap: 4px;
    background: rgba(0, 0, 0, 0.2);
    padding: 4px;
    border-radius: 8px;
    border: 1px solid var(--panel-border);
}

.time-range-selector button {
    background: transparent;
    border: none;
    color: var(--text-secondary);
    padding: 6px 12px;
    border-radius: 6px;
    cursor: pointer;
    font-weight: 600;
    font-family: var(--font-main);
    font-size: 13px;
    transition: all 0.2s;
}

.time-range-selector button:hover {
    color: var(--text-primary);
    background: rgba(255, 255, 255, 0.1);
}

.time-range-selector button.active {
    background: var(--panel-bg);
    color: var(--accent-blue);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

#chart-container {
    flex: 1;
    width: 100%;
}

.metrics-panel {
    display: flex;
    gap: 0;
    padding: 16px 0;
}

.metrics-col {
    flex: 1;
    display: flex;
    flex-direction: column;
    padding: 0 20px;
}

.metrics-divider {
    width: 1px;
    background: var(--panel-border);
    flex-shrink: 0;
}

.metrics-grid {
    display: flex;
    flex-direction: column;
}

.metric-card {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 0;
    border-bottom: 1px solid rgba(255, 255, 255, 0.04);
}

.metric-card:last-child {
    border-bottom: none;
}

.metric-card span {
    font-size: 12px;
    color: var(--text-secondary);
}

.metric-card strong {
    font-size: 13px;
    font-weight: 600;
}

/* Autocomplete Dropdown */
.autocomplete-dropdown {
    position: absolute;
    top: 100%;
    left: 0;
    width: 100%;
    margin-top: 5px;
    background: rgba(18, 18, 20, 0.95);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 8px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(10px);
    max-height: 250px;
    overflow-y: auto;
    -ms-overflow-style: none;
    /* IE and Edge */
    scrollbar-width: none;
    /* Firefox */
    z-index: 1000;
    list-style: none;
    padding: 0;
}

.autocomplete-dropdown::-webkit-scrollbar {
    display: none;
}

.autocomplete-dropdown li {
    padding: 12px 16px;
    cursor: pointer;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
    display: flex;
    flex-direction: column;
}

.autocomplete-dropdown li:last-child {
    border-bottom: none;
}

.autocomplete-dropdown li:hover,
.autocomplete-dropdown li.ac-active {
    background: rgba(255, 255, 255, 0.05);
}

.autocomplete-dropdown li .ac-symbol {
    font-weight: 600;
    color: var(--text-primary);
    font-size: 0.9rem;
}

.autocomplete-dropdown li .ac-name {
    font-size: 0.75rem;
    color: var(--text-secondary);
    margin-top: 2px;
}

/* Financials Panel */
.financials-panel {
    display: flex;
    flex-direction: column;
    padding: 20px;
}

.financials-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
    border-bottom: 1px solid var(--panel-border);
    padding-bottom: 12px;
}

.financials-tabs {
    display: flex;
    gap: 8px;
}

.fin-tab {
    background: transparent;
    border: none;
    color: var(--text-secondary);
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    padding: 8px 12px;
    border-radius: 6px;
    transition: all 0.2s;
    font-family: var(--font-main);
}

.fin-tab:hover {
    color: var(--text-primary);
    background: rgba(255, 255, 255, 0.05);
}

.fin-tab.active {
    color: var(--accent-blue);
    background: rgba(0, 240, 255, 0.1);
}

.financials-toggle {
    display: flex;
    background: rgba(0, 0, 0, 0.2);
    border: 1px solid var(--panel-border);
    border-radius: 8px;
    padding: 4px;
    gap: 4px;
}

.fin-period,
.fin-count {
    background: transparent;
    border: none;
    color: var(--text-secondary);
    padding: 6px 12px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 13px;
    font-weight: 600;
    transition: all 0.2s;
    font-family: var(--font-main);
}

.fin-period.active,
.fin-count.active {
    background: var(--panel-bg);
    color: var(--accent-green);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

.financials-chart-container {
    width: 100%;
    height: 250px;
    margin-bottom: 24px;
    position: relative;
}

.financials-table-container {
    overflow-x: auto;
}

.financials-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 14px;
}

.financials-table th,
.financials-table td {
    padding: 8px 12px;
    text-align: right;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

.financials-table td {
    font-weight: 400;
}

.financials-table th:first-child,
.financials-table td:first-child {
    text-align: left;
    font-weight: 600;
    color: var(--text-secondary);
    width: 30%;
}

.financials-table th {
    color: var(--text-primary);
    font-weight: 700;
}

.financials-table tr:hover td {
    background: rgba(255, 255, 255, 0.02);
}

.top-view-toggle {
    display: flex;
    gap: 8px;
    margin-bottom: 8px;
    border-bottom: 1px solid rgba(255,255,255,0.1);
    padding-bottom: 12px;
}

.top-view-toggle button {
    background: transparent;
    color: var(--text-secondary);
    border: none;
    font-size: 18px;
    font-weight: 600;
    cursor: pointer;
    padding: 8px 16px;
    border-radius: 8px;
    transition: all 0.2s;
}

.top-view-toggle button:hover {
    color: var(--text-primary);
    background: rgba(255,255,255,0.05);
}

.top-view-toggle button.active {
    color: var(--text-primary);
    background: rgba(255,255,255,0.1);
}

.options-header {
    margin-bottom: 24px;
    padding: 16px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.options-controls {
    display: flex;
    gap: 16px;
    align-items: center;
    width: 100%;
}

.expiry-band {
    display: flex;
    gap: 8px;
    overflow-x: auto;
    white-space: nowrap;
    padding-bottom: 4px; /* for scrollbar */
    scrollbar-width: thin;
    scrollbar-color: rgba(255, 255, 255, 0.2) transparent;
    flex: 1;
}

.expiry-band::-webkit-scrollbar {
    height: 4px;
}
.expiry-band::-webkit-scrollbar-track {
    background: transparent;
}
.expiry-band::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.2);
    border-radius: 4px;
}

.expiry-month-group {
    display: flex;
    flex-direction: column;
    align-items: center;
    margin-right: 2px;
}

.expiry-month-label {
    background: rgba(255, 255, 255, 0.1);
    border-radius: 4px;
    font-size: 0.7rem;
    color: var(--text-secondary);
    text-transform: uppercase;
    font-weight: 700;
    text-align: center;
    padding: 3px 6px;
    margin-bottom: 2px;
    width: 100%;
    box-sizing: border-box;
}

.expiry-days {
    display: flex;
    gap: 1px;
    justify-content: center;
}

.expiry-btn {
    background: transparent;
    border: none;
    color: var(--text-primary);
    padding: 5px 10px;
    border-radius: 4px;
    font-family: 'Inter', sans-serif;
    font-size: 0.85rem;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.2s ease;
    flex-shrink: 0;
}

.expiry-btn:hover {
    background: rgba(255, 255, 255, 0.1);
}

.expiry-btn.active {
    background: var(--accent-blue);
    color: #0f172a;
    box-shadow: none;
}

.expiry-loading {
    color: var(--text-secondary);
    font-size: 0.9rem;
    padding: 6px 0;
}

.options-controls-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 20px;
    margin-bottom: 0;
    border-bottom-left-radius: 0;
    border-bottom-right-radius: 0;
}

.options-filters {
    display: flex;
    align-items: center;
    gap: 16px;
}

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

.strike-filter label {
    color: var(--text-secondary);
    font-size: 0.82rem;
    font-weight: 500;
    white-space: nowrap;
}

.options-mode-toggle, .options-type-toggle {
    display: flex;
    background: rgba(0,0,0,0.3);
    border-radius: 6px;
    padding: 4px;
}

.options-mode-toggle button, .options-type-toggle button {
    background: transparent;
    border: none;
    color: var(--text-secondary);
    padding: 6px 12px;
    border-radius: 4px;
    cursor: pointer;
    font-weight: 500;
    transition: all 0.2s;
}

.options-mode-toggle button.active, .options-type-toggle button.active {
    background: var(--accent-blue);
    color: #000;
}

.options-type-toggle button.active {
    background: rgba(255,255,255,0.2);
    color: #fff;
}

#opt-type-calls.active {
    background: var(--accent-green);
    color: #000;
}

#opt-type-puts.active {
    background: var(--accent-red);
    color: #000;
}

.premium-select {
    appearance: none;
    background: rgba(255, 255, 255, 0.07);
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: 6px;
    color: var(--text-primary);
    font-size: 0.8rem;
    font-weight: 600;
    font-family: 'Inter', sans-serif;
    padding: 4px 28px 4px 10px;
    cursor: pointer;
    outline: none;
    transition: border-color 0.2s, background 0.2s;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%2394a3b8' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 8px center;
}

.premium-select:hover {
    border-color: rgba(255, 255, 255, 0.25);
    background-color: rgba(255, 255, 255, 0.1);
}

.premium-select:focus {
    border-color: var(--accent-blue);
}

.premium-select option {
    background: #0f172a;
    color: var(--text-primary);
}

.options-table-container {
    overflow-x: auto;
    overflow-y: auto;
    max-height: 65vh;
    padding: 0 16px 16px 16px;
}

.options-table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
    font-size: 14px;
    text-align: right;
    font-family: 'Noto Sans Mono', 'Consolas', monospace;
}

.options-table th {
    position: sticky;
    top: 0;
    z-index: 10;
    background: rgba(15, 23, 42, 0.95);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    color: var(--text-secondary);
    font-weight: 600;
    padding: 8px 12px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.options-table td {
    padding: 8px 12px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

.options-table th:first-child, .options-table td:first-child {
    text-align: left;
    font-weight: 700;
    color: var(--text-primary);
}

.options-table tr:hover td {
    background: rgba(255, 255, 255, 0.02);
}


.surface-chart-container {
    padding: 16px;
    height: 600px;
}

.options-table tr.itm-row td {
    background: rgba(56, 189, 248, 0.06);
}

.options-table tr.itm-row:hover td {
    background: rgba(56, 189, 248, 0.12);
}

/* Accordion Row & Panel */
.accordion-row td {
    padding: 0 !important;
    border: none !important;
}

.accordion-panel {
    max-height: 0;
    overflow: hidden;
    opacity: 0;
    transition: max-height 0.3s ease-out, opacity 0.2s ease-out;
    background: rgba(15, 23, 42, 0.4);
}

.accordion-panel.open {
    max-height: 400px;
    opacity: 1;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.options-table tr.active-row td {
    background: rgba(56, 189, 248, 0.08);
}

.options-table tr.active-row td:first-child {
    box-shadow: -2px 0 0 0 var(--accent-blue), 0 -2px 0 0 var(--accent-blue), 0 2px 0 0 var(--accent-blue);
}

.options-table tr.active-row td:last-child {
    box-shadow: 2px 0 0 0 var(--accent-blue), 0 -2px 0 0 var(--accent-blue), 0 2px 0 0 var(--accent-blue);
}

.options-table tr.active-row td:not(:first-child):not(:last-child) {
    box-shadow: 0 -2px 0 0 var(--accent-blue), 0 2px 0 0 var(--accent-blue);
}

.contract-chart-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 20px 8px;
    border-top: 1px solid rgba(255, 255, 255, 0.05);
}

.contract-chart-controls {
    display: flex;
    align-items: center;
}

.contract-info-label {
    font-size: 0.85rem;
    color: var(--text-secondary);
    font-weight: 500;
}

.contract-info-label span {
    color: var(--text-primary);
    font-weight: 700;
    margin-right: 12px;
}

.contract-quote {
    display: inline-flex;
    align-items: baseline;
    gap: 8px;
    margin-top: 6px;
}

.contract-quote-price {
    font-size: 0.95rem;
    font-weight: 700;
    color: var(--text-primary);
    letter-spacing: -0.5px;
}

.contract-quote-change {
    font-size: 0.82rem;
    font-weight: 600;
    padding: 2px 7px;
    border-radius: 4px;
}

.contract-quote-change.positive {
    color: var(--accent-green);
    background: rgba(0, 255, 157, 0.1);
}

.contract-quote-change.negative {
    color: var(--accent-red);
    background: rgba(255, 51, 102, 0.1);
}

.contract-chart-container {
    height: 300px;
    padding: 0 20px 20px;
    position: relative;
}

.range-toggle, .granularity-selector {
    display: flex;
    gap: 4px;
    background: rgba(255, 255, 255, 0.05);
    padding: 2px;
    border-radius: 6px;
}

.range-btn, .gran-btn {
    background: transparent;
    border: none;
    color: var(--text-secondary);
    padding: 4px 10px;
    font-size: 0.75rem;
    font-weight: 700;
    cursor: pointer;
    border-radius: 4px;
    transition: all 0.2s;
}

.range-btn:hover, .gran-btn:hover {
    color: var(--text-primary);
}

.range-btn.active, .gran-btn.active {
    background: rgba(255, 255, 255, 0.1);
    color: var(--accent-blue);
}

.chart-loading-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(15, 23, 42, 0.6);
    backdrop-filter: blur(2px);
    z-index: 10;
    color: var(--text-secondary);
    font-size: 0.9rem;
}

.tv-tooltip {
    position: absolute;
    display: none;
    padding: 10px;
    box-sizing: border-box;
    font-size: 13px;
    text-align: left;
    z-index: 1000;
    top: 12px;
    left: 12px;
    pointer-events: none;
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 6px;
    background: rgba(15, 23, 42, 0.85);
    backdrop-filter: blur(4px);
    color: #fff;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.3);
    line-height: 1.4;
}

@media (max-width: 1024px) {
    .metrics-container {
        grid-template-columns: 1fr;
    }
}

/* ========== Sidebar Mode Selector ========== */

.sidebar-mode-selector {
    display: flex;
    gap: 4px;
    padding: 0 16px 16px 16px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.06);
    margin-bottom: 8px;
}

.mode-btn {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 10px 12px;
    background: transparent;
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 10px;
    color: var(--text-secondary);
    font-family: 'Inter', sans-serif;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
}

.mode-btn:hover {
    background: rgba(255, 255, 255, 0.05);
    border-color: rgba(255, 255, 255, 0.15);
    color: var(--text-primary);
}

.mode-btn.active {
    background: rgba(0, 240, 255, 0.08);
    border-color: rgba(0, 240, 255, 0.3);
    color: var(--accent-blue);
}

.mode-btn svg {
    flex-shrink: 0;
}

/* ========== Portfolio Sidebar ========== */

.portfolio-sidebar-info {
    padding: 16px;
}

.portfolio-connection-status {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 16px;
    font-size: 13px;
    color: var(--text-secondary);
}

.status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    flex-shrink: 0;
}

.status-dot.disconnected {
    background: #ff3366;
    box-shadow: 0 0 6px rgba(255, 51, 102, 0.5);
}

.status-dot.connected {
    background: #00ff9d;
    box-shadow: 0 0 6px rgba(0, 255, 157, 0.5);
}

.connect-btn {
    width: 100%;
    padding: 10px 16px;
    background: linear-gradient(135deg, rgba(0, 240, 255, 0.15), rgba(0, 240, 255, 0.05));
    border: 1px solid rgba(0, 240, 255, 0.3);
    border-radius: 10px;
    color: var(--accent-blue);
    font-family: 'Inter', sans-serif;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
}

.connect-btn:hover {
    background: linear-gradient(135deg, rgba(0, 240, 255, 0.25), rgba(0, 240, 255, 0.1));
    border-color: rgba(0, 240, 255, 0.5);
    box-shadow: 0 0 20px rgba(0, 240, 255, 0.1);
}

/* ========== Portfolio Dashboard ========== */

.portfolio-dashboard {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

/* Portfolio Header */
.portfolio-header {
    padding: 20px 24px;
}

.portfolio-header-top {
    display: flex;
    align-items: center;
    gap: 16px;
    margin-bottom: 16px;
}

.portfolio-header-top h2 {
    font-size: 1.4rem;
    font-weight: 700;
    color: var(--text-primary);
    margin: 0;
}

.portfolio-account-selector {
    flex: 1;
}

.portfolio-account-selector .premium-select {
    min-width: 200px;
}

.portfolio-refresh {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 8px;
    padding: 8px;
    color: var(--text-secondary);
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
}

.portfolio-refresh:hover {
    background: rgba(255, 255, 255, 0.1);
    color: var(--text-primary);
    border-color: rgba(255, 255, 255, 0.2);
}

.portfolio-summary-row {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 16px;
}

.portfolio-metric {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.portfolio-metric span {
    font-size: 12px;
    color: var(--text-secondary);
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.portfolio-metric strong {
    font-size: 1.2rem;
    font-weight: 700;
    color: var(--text-primary);
}

/* ========== Portfolio Visualization Area ========== */

.portfolio-viz-section {
    padding: 16px;
}

.portfolio-viz-toggle {
    display: flex;
    gap: 4px;
    margin-bottom: 12px;
}

.portfolio-viz-toggle .chart-type-btn {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 6px 14px;
    font-size: 12px;
}

.portfolio-chart-area {
    height: 300px;
    position: relative;
}

.portfolio-chart-range {
    display: flex;
    gap: 4px;
    margin-top: 8px;
}

.portfolio-chart-range button {
    padding: 4px 12px;
    background: transparent;
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 6px;
    color: var(--text-secondary);
    font-family: 'Inter', sans-serif;
    font-size: 12px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.15s ease;
}

.portfolio-chart-range button:hover {
    background: rgba(255, 255, 255, 0.05);
    color: var(--text-primary);
}

.portfolio-chart-range button.active {
    background: var(--panel-bg);
    color: var(--accent-blue);
    border-color: rgba(0, 240, 255, 0.3);
}

/* ========== Portfolio Tables ========== */

.portfolio-positions,
.portfolio-orders {
    padding: 0;
}

.portfolio-table-container {
    overflow-x: auto;
    overflow-y: auto;
    max-height: 50vh;
    padding: 0 16px 16px 16px;
    scrollbar-width: thin;
    scrollbar-color: rgba(255, 255, 255, 0.08) transparent;
}

.portfolio-table-container::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}

.portfolio-table-container::-webkit-scrollbar-track {
    background: transparent;
}

.portfolio-table-container::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.08);
    border-radius: 3px;
}

.portfolio-table-container::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.15);
}

.portfolio-table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
    font-size: 14px;
    text-align: right;
    font-family: 'Noto Sans Mono', 'Consolas', monospace;
}

.portfolio-table th {
    position: sticky;
    top: 0;
    z-index: 10;
    background: rgba(15, 23, 42, 0.95);
    backdrop-filter: blur(12px);
    color: var(--text-secondary);
    font-weight: 600;
    padding: 8px 12px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.portfolio-table td {
    padding: 8px 12px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

.portfolio-table th:first-child,
.portfolio-table td:first-child {
    text-align: left;
    font-weight: 700;
    color: var(--text-primary);
}

.portfolio-table tr:hover td {
    background: rgba(255, 255, 255, 0.03);
    cursor: pointer;
}

/* Sortable column headers */
.portfolio-table th[data-col] {
    user-select: none;
    white-space: nowrap;
    transition: color 0.15s ease;
}

.portfolio-table th[data-col]:hover {
    color: var(--text-primary);
}

.portfolio-table th.sort-active {
    color: #fff;
}

.sort-indicator {
    display: inline-block;
    font-size: 9px;
    margin-left: 4px;
    opacity: 0.7;
    vertical-align: middle;
}


/* Portfolio accordion */
.portfolio-table .pf-accordion-row td {
    padding: 0;
    border-bottom: none;
}

.pf-accordion-panel {
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.3s ease;
    background: rgba(0, 0, 0, 0.2);
    border-radius: 0 0 8px 8px;
}

.pf-accordion-panel.open {
    max-height: 500px;
}

.pf-accordion-content {
    padding: 16px 20px;
    display: flex;
    gap: 20px;
}

.pf-accordion-chart {
    flex: 1;
    height: 200px;
    min-width: 0;
}

.pf-accordion-stats {
    width: 220px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    font-size: 13px;
}

.pf-stat-row {
    display: flex;
    justify-content: space-between;
    padding: 4px 0;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

.pf-stat-row span:first-child {
    color: var(--text-secondary);
}

.pf-stat-row span:last-child {
    color: var(--text-primary);
    font-weight: 600;
}

.pf-accordion-links {
    display: flex;
    gap: 8px;
    margin-top: 8px;
}

.pf-link-btn {
    padding: 6px 12px;
    background: rgba(0, 240, 255, 0.08);
    border: 1px solid rgba(0, 240, 255, 0.2);
    border-radius: 6px;
    color: var(--accent-blue);
    font-family: 'Inter', sans-serif;
    font-size: 12px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    text-decoration: none;
}

.pf-link-btn:hover {
    background: rgba(0, 240, 255, 0.15);
    border-color: rgba(0, 240, 255, 0.4);
}

/* ========== Portfolio Orders ========== */

.portfolio-orders-filters {
    display: flex;
    gap: 12px;
    padding: 16px;
    flex-wrap: wrap;
    border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}

/* Order status badges */
.order-status {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.3px;
}

.order-status.open {
    background: rgba(255, 215, 0, 0.1);
    color: #ffd700;
}

.order-status.filled {
    background: rgba(0, 255, 157, 0.1);
    color: #00ff9d;
}

.order-status.cancelled {
    background: rgba(255, 255, 255, 0.05);
    color: var(--text-secondary);
}

/* ========== Treemap ========== */

#pf-treemap-svg text {
    font-family: 'Inter', sans-serif;
    font-weight: 600;
    fill: #fff;
    pointer-events: none;
}

#pf-treemap-svg rect {
    stroke: rgba(15, 23, 42, 0.8);
    stroke-width: 2;
    transition: opacity 0.15s ease;
}

#pf-treemap-svg rect:hover {
    opacity: 0.85;
}

/* ============================================
   Strategy Builder Styles
   ============================================ */

.strategy-header {
    padding: 20px;
    margin-bottom: 8px;
}

.strategy-title-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
}

.strategy-name-badge {
    display: flex;
    align-items: center;
    gap: 12px;
}

#strategy-name {
    font-size: 22px;
    font-weight: 700;
    color: var(--text-primary);
}

.strategy-sentiment {
    font-size: 13px;
    font-weight: 600;
    padding: 4px 10px;
    border-radius: 4px;
    background: rgba(0, 240, 255, 0.1);
    color: var(--accent-blue);
}

.strategy-actions {
    display: flex;
    gap: 8px;
}

.strategy-btn {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 8px 14px;
    border: none;
    border-radius: 6px;
    font-family: var(--font-main);
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
}

.strategy-btn-add {
    background: var(--accent-blue);
    color: #000;
}

.strategy-btn-add:hover {
    opacity: 0.9;
    transform: translateY(-1px);
}

.strategy-btn-clear {
    background: rgba(255, 255, 255, 0.08);
    color: var(--text-secondary);
}

.strategy-btn-clear:hover {
    background: rgba(255, 51, 129, 0.2);
    color: var(--accent-red);
}

/* Position Legs */
.strategy-legs {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.strategy-leg-row {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 12px;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid rgba(255, 255, 255, 0.06);
    border-radius: 8px;
    transition: border-color 0.2s;
}

.strategy-leg-row:hover {
    border-color: rgba(255, 255, 255, 0.12);
}

.leg-select {
    appearance: none;
    background: rgba(255, 255, 255, 0.07);
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: 6px;
    color: var(--text-primary);
    font-size: 13px;
    font-weight: 600;
    font-family: 'Inter', sans-serif;
    padding: 6px 28px 6px 10px;
    cursor: pointer;
    outline: none;
    transition: border-color 0.2s;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%2394a3b8' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 8px center;
}

.leg-select:focus {
    border-color: var(--accent-blue);
}

.leg-select option {
    background: #0f172a;
    color: var(--text-primary);
}

.leg-select.leg-side-buy {
    border-color: rgba(0, 255, 157, 0.3);
    color: var(--accent-green);
}

.leg-select.leg-side-sell {
    border-color: rgba(255, 51, 129, 0.3);
    color: var(--accent-red);
}

.leg-qty-input {
    width: 50px;
    background: rgba(255, 255, 255, 0.07);
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: 6px;
    color: var(--text-primary);
    font-size: 13px;
    font-weight: 600;
    font-family: 'Noto Sans Mono', monospace;
    padding: 6px 8px;
    text-align: center;
    outline: none;
}

.leg-qty-input:focus {
    border-color: var(--accent-blue);
}

.leg-price-display {
    font-family: 'Noto Sans Mono', monospace;
    font-size: 13px;
    color: var(--text-secondary);
    min-width: 80px;
    text-align: right;
}

.leg-remove-btn {
    background: transparent;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    padding: 4px;
    border-radius: 4px;
    transition: all 0.2s;
    display: flex;
    align-items: center;
}

.leg-remove-btn:hover {
    color: var(--accent-red);
    background: rgba(255, 51, 129, 0.1);
}

/* Metrics Bar */
.strategy-metrics {
    display: flex;
    padding: 16px 20px;
    margin-bottom: 8px;
    gap: 0;
}

.strategy-metric {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    padding: 0 16px;
    border-right: 1px solid rgba(255, 255, 255, 0.06);
}

.strategy-metric:last-child {
    border-right: none;
}

.metric-label {
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-secondary);
}

.metric-value {
    font-size: 18px;
    font-weight: 700;
    font-family: 'Noto Sans Mono', monospace;
    color: var(--text-primary);
}

/* P/L Chart */
.strategy-chart-panel {
    padding: 20px;
    margin-bottom: 8px;
    height: 400px;
    position: relative;
}

.strategy-chart-panel canvas {
    width: 100% !important;
    height: 100% !important;
}

/* Sliders */
.strategy-sliders {
    padding: 16px 20px;
    margin-bottom: 8px;
}

.slider-row {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 10px;
}

.slider-row:last-child {
    margin-bottom: 0;
}

.slider-row label {
    font-size: 12px;
    font-weight: 700;
    color: var(--text-secondary);
    text-transform: uppercase;
    min-width: 55px;
}

.slider-value-left {
    font-size: 12px;
    font-weight: 600;
    color: var(--text-primary);
    min-width: 100px;
}

.slider-value-right {
    font-size: 12px;
    color: var(--text-secondary);
    min-width: 100px;
    text-align: right;
}

.strategy-slider {
    flex: 1;
    -webkit-appearance: none;
    appearance: none;
    height: 4px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 4px;
    outline: none;
}

.strategy-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: var(--accent-blue);
    cursor: pointer;
    box-shadow: 0 0 8px rgba(0, 240, 255, 0.4);
    transition: transform 0.15s;
}

.strategy-slider::-webkit-slider-thumb:hover {
    transform: scale(1.2);
}

.strategy-slider::-moz-range-thumb {
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: var(--accent-blue);
    cursor: pointer;
    border: none;
}

/* Greeks Display */
.strategy-greeks {
    display: flex;
    padding: 14px 20px;
    margin-bottom: 8px;
}

.greek-item {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
}

.greek-label {
    font-size: 12px;
    font-weight: 600;
    color: var(--text-secondary);
}

.greek-value {
    font-size: 16px;
    font-weight: 700;
    font-family: 'Noto Sans Mono', monospace;
    color: var(--text-primary);
}

/* Analyze button in options table */
.analyze-btn {
    background: transparent;
    border: 1px solid rgba(0, 240, 255, 0.3);
    color: var(--accent-blue);
    padding: 3px 8px;
    border-radius: 4px;
    font-size: 11px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    font-family: var(--font-main);
}

.analyze-btn:hover {
    background: rgba(0, 240, 255, 0.15);
    border-color: var(--accent-blue);
}

/* Risk/Return Surface */
.ror-controls-bar {
    display: flex;
    align-items: center;
    padding: 12px 20px;
    margin-bottom: 0;
    border-bottom-left-radius: 0;
    border-bottom-right-radius: 0;
}

.ror-controls-row {
    display: flex;
    align-items: center;
    gap: 16px;
    flex-wrap: wrap;
    width: 100%;
}

.ror-toggle-group {
    flex-shrink: 0;
}

.ror-slider-group {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-shrink: 0;
}

.ror-slider-group label,
.ror-input-group label {
    color: var(--text-secondary);
    font-size: 0.8rem;
    font-weight: 500;
    white-space: nowrap;
}

.ror-slider-group input[type="range"] {
    width: 100px;
    accent-color: var(--accent-blue);
    cursor: pointer;
}

#ror-target-readout {
    color: var(--accent-blue);
    font-weight: 600;
    font-size: 0.85rem;
    min-width: 32px;
    text-align: center;
}

.ror-input-group {
    display: flex;
    align-items: center;
    gap: 6px;
    flex-shrink: 0;
}

.ror-number-input {
    width: 72px;
    background: rgba(255, 255, 255, 0.07);
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: 6px;
    color: var(--text-primary);
    font-size: 0.8rem;
    font-weight: 600;
    font-family: var(--font-main);
    padding: 5px 8px;
    outline: none;
    transition: border-color 0.2s;
}

.ror-number-input:focus {
    border-color: var(--accent-blue);
}

.ror-number-input::-webkit-inner-spin-button,
.ror-number-input::-webkit-outer-spin-button {
    opacity: 0.5;
}

.ror-chart-container {
    position: relative;
    width: 100%;
    height: 620px;
    border-top-left-radius: 0;
    border-top-right-radius: 0;
    overflow: hidden;
}

#ror-plotly-chart {
    width: 100%;
    height: 100%;
}

.ror-no-data {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    color: var(--text-secondary);
    font-size: 1rem;
    text-align: center;
}

#ror-type-calls.active {
    background: var(--accent-green);
    color: #000;
}

#ror-type-puts.active {
    background: var(--accent-red);
    color: #000;
}

#ror-side-buy.active {
    background: var(--accent-green);
    color: #000;
}

#ror-side-sell.active {
    background: var(--accent-red);
    color: #000;
}