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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    background: #e5e5e5;
    color: #333;
    min-height: 100vh;
    line-height: 1.6;
}

body.left-sidebar-open {
    padding-left: 0;
}

body.left-sidebar-collapsed {
    padding-left: 0;
}

/* Login Page */
.login-page {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
}

.login-container {
    width: 100%;
    max-width: 400px;
    padding: 20px;
}

.login-box {
    background: white;
    padding: 40px;
    border-radius: 12px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.2);
}

.login-title {
    font-size: 2.5em;
    font-weight: 700;
    color: #000;
    margin-bottom: 10px;
    text-align: center;
}

.login-subtitle {
    text-align: center;
    color: #666;
    margin-bottom: 30px;
}

.error-message {
    background: #f5f5f5;
    color: #000;
    padding: 12px;
    border-radius: 6px;
    margin-bottom: 20px;
    text-align: center;
    border: 1px solid #999;
}

.login-form {
    display: flex;
    flex-direction: column;
}

.form-group {
    margin-bottom: 20px;
}

.form-group label {
    display: block;
    margin-bottom: 8px;
    color: #333;
    font-weight: 500;
}

.form-group input {
    width: 100%;
    padding: 12px;
    border: 2px solid #e0e0e0;
    border-radius: 6px;
    font-size: 16px;
    transition: border-color 0.3s;
}

.form-group input:focus {
    outline: none;
    border-color: #666;
}

.login-button {
    background: #000;
    color: white;
    padding: 14px;
    border: none;
    border-radius: 6px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: transform 0.2s, box-shadow 0.2s;
}

.login-button:hover {
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.3);
    background: #333;
}

/* Navbar */
.navbar {
    background: white;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
    padding: 15px 0;
    position: sticky;
    top: 0;
    z-index: 1000;
}

.nav-container {
    max-width: 1960px; /* Increased from 1400px to 1960px to match container width */
    margin: 0 auto;
    padding: 0 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 20px;
}

.nav-left {
    display: flex;
    align-items: center;
    gap: 16px;
}

.hamburger-btn {
    width: 42px;
    height: 42px;
    border-radius: 10px;
    border: 1px solid rgba(15, 23, 42, 0.2);
    background: linear-gradient(135deg, #ffffff 0%, #e2e8f0 100%);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    flex-direction: column;
    cursor: pointer;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
    box-shadow: 0 10px 30px rgba(15, 23, 42, 0.12);
}

.hamburger-btn span {
    display: block;
    width: 60%;
    height: 2px;
    border-radius: 999px;
    background: #0f172a;
    transition: transform 0.2s ease;
}

.hamburger-btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 14px 36px rgba(15, 23, 42, 0.18);
}

.nav-title {
    font-size: 1.8em;
    font-weight: 700;
    color: #000;
}

.nav-controls {
    display: flex;
    align-items: center;
    gap: 20px;
}

.ticker-selector {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.95em;
    color: #374151;
}

.ticker-selector label {
    font-weight: 500;
}

.ticker-selector select {
    padding: 6px 12px;
    border: 2px solid #d1d5db;
    border-radius: 6px;
    font-size: 0.95em;
    background: white;
    color: #111827;
    transition: border-color 0.2s ease;
}

.ticker-selector select:focus {
    outline: none;
    border-color: #6366f1;
}

.time-selector {
    display: flex;
    align-items: center;
    gap: 10px;
}

.time-selector label {
    font-weight: 500;
    color: #333;
}

.time-selector input {
    padding: 8px 12px;
    border: 2px solid #e0e0e0;
    border-radius: 6px;
    font-size: 14px;
    transition: border-color 0.2s, background-color 0.2s;
}

.time-selector input.invalid-date {
    border-color: #f44336;
    background-color: #ffebee;
}

.time-selector input.invalid-date:focus {
    outline: none;
    border-color: #f44336;
    box-shadow: 0 0 0 3px rgba(244, 67, 54, 0.1);
}

.btn-primary {
    background: #000;
    color: white;
    padding: 8px 20px;
    border: none;
    border-radius: 6px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: transform 0.2s, box-shadow 0.2s;
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.3);
    background: #333;
}

.logout-link {
    color: #000;
    text-decoration: none;
    font-weight: 500;
    padding: 8px 16px;
    border-radius: 6px;
    transition: background 0.3s;
}

.logout-link:hover {
    background: #e0e0e0;
}

/* Container */
.container {
    max-width: 1960px; /* Increased from 1400px to 1960px (1400 * 1.4 = 1960, 20% wider on each side) */
    margin: 0 auto;
    padding: 30px 20px;
}

body.left-sidebar-open .container {
    margin: 30px 20px 30px 260px;
    max-width: calc(100% - 280px);
}

body.left-sidebar-collapsed .container {
    margin: 30px 20px 30px 80px;
    max-width: calc(100% - 120px);
}

body.chat-open .container {
    margin-right: 460px;
}

body.chat-open .main-content,
body.chat-open .sidebar,
body.chat-open #options-chain-section,
body.chat-open #volatility-smile-section,
body.chat-open #chain-summary-section,
body.chat-open #iv-rv-chart-section,
body.chat-open #iv-rv-ratio-chart-section,
body.chat-open #strike-history-section {
    padding-right: 20px;
}

body.chat-collapsed .container {
    margin-right: 20px;
}

/* Main Layout with Sidebars */
.main-layout {
    display: flex;
    gap: 20px;
    align-items: flex-start;
    transition: margin-left 0.3s ease;
    margin-left: 0;
}

.sidebar {
    flex: 0 0 540px;
    width: 540px;
    background: white;
    border: 1px solid #ccc;
    border-radius: 12px;
    padding: 10px 20px 20px;
    position: sticky;
    top: 90px;
    align-self: flex-start;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.08);
    transition: width 0.2s ease;
}

.sidebar .mode-section {
    width: 100%;
}

.sidebar-section-title {
    font-size: 1.6em;
    font-weight: 700;
    color: #000;
    margin-bottom: 20px;
    border-bottom: 3px solid #000;
    padding-bottom: 10px;
}

.main-content {
    flex: 1;
    min-width: 0; /* Allows flex item to shrink below content size */
}

/* Left Sidebar */
.left-sidebar {
    width: 240px;
    background: white;
    border: 1px solid #ccc;
    border-right: 1px solid #ccc;
    border-radius: 0;
    padding: 40px 20px 20px;
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    height: 100vh;
    overflow-y: auto;
    scrollbar-width: thin;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    z-index: 1200;
    transition: transform 0.3s ease, opacity 0.3s ease;
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.left-sidebar.collapsed {
    transform: translateX(-210px);
    opacity: 1;
}

.left-sidebar-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 10px;
    border-bottom: 1px solid #ccc;
    padding-bottom: 10px;
    position: relative;
}

.left-sidebar-brand {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.left-sidebar-logo {
    display: flex;
    align-items: center;
    gap: 8px;
}

.voltrader-logo-mark {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: #000;
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 16px;
    letter-spacing: 0.5px;
}

.voltrader-logo-text {
    font-weight: 700;
    font-size: 16px;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

.sidebar-toggle-btn {
    background: white;
    border: 1px solid #ccc;
    color: #000;
    font-size: 1.1em;
    cursor: pointer;
    width: 26px;
    height: 26px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 6px;
    transition: background 0.2s, box-shadow 0.2s;
}

.sidebar-toggle-btn:hover {
    background: #f5f5f5;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.15);
}

.left-sidebar.collapsed .sidebar-toggle-btn {
    position: absolute;
    right: -36px;
    top: 12px;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.15);
}

/* Mode Selector */
.sidebar-mode-selector {
    margin-bottom: 20px;
}

.mode-buttons {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.mode-btn {
    padding: 12px 15px;
    border: 2px solid #000;
    background: white;
    color: #000;
    border-radius: 6px;
    cursor: pointer;
    font-weight: 500;
    font-size: 13px;
    transition: all 0.3s;
    text-align: center;
    text-decoration: none;
    display: block;
}

.mode-btn:hover {
    background: #f5f5f5;
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
}

.mode-btn.active {
    background: #000;
    color: white;
}

.mode-section {
    margin-top: 20px;
}

/* Backtest styles */
.backtest-conditions-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin: 25px 0 20px;
    flex-wrap: wrap;
    gap: 10px;
}

.backtest-condition-card {
    background: #f7f7f7;
    border: 1px solid #e0e0e0;
    border-radius: 10px;
    padding: 20px;
    margin-bottom: 25px;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.05);
}

.condition-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
}

.condition-header-actions {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

.condition-header-actions button:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    background-color: #ccc;
    color: #666;
}

.condition-header-actions button:disabled:hover {
    background-color: #ccc;
    transform: none;
    box-shadow: none;
}

.condition-section {
    margin-top: 20px;
}

.condition-sections-row {
    display: flex;
    flex-wrap: wrap;
    gap: 20px;
    margin-top: 20px;
}

.condition-sections-row .condition-section {
    flex: 1 1 320px;
    margin-top: 0;
}

.backtest-legs-table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 10px;
}

.backtest-legs-table thead th {
    text-transform: uppercase;
    font-size: 0.75em;
    letter-spacing: 0.05em;
    color: #555;
    padding: 8px;
    background: #ededed;
}

.backtest-legs-table tbody td {
    padding: 8px;
    border-bottom: 1px solid #e2e2e2;
    vertical-align: middle;
}

.condition-subcard {
    background: #ffffff;
    border: 1px solid #e2e2e2;
    border-radius: 6px;
    padding: 15px;
    margin-bottom: 15px;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.04);
}

.condition-subcard-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 10px;
    gap: 10px;
}

.condition-subcard-body {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.backtest-input {
    padding: 8px;
    border: 1px solid #ccc;
    border-radius: 6px;
    font-size: 0.9em;
    background: #fff;
    color: #000;
    width: 100%;
}

.backtest-inline-inputs {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}

.condition-note {
    font-size: 0.9em;
    color: #555;
    margin: 5px 0;
}

.backtest-date-range {
    margin-bottom: 25px;
}

.backtest-date-range-fields {
    display: flex;
    gap: 20px;
    align-items: flex-end;
    flex-wrap: wrap;
}

.backtest-management-toggle {
    min-width: 260px;
}

.switch-label {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    font-size: 0.9em;
}

.toggle-switch {
    position: relative;
    width: 44px;
    height: 24px;
    border-radius: 999px;
    border: none;
    background: #ccc;
    padding: 0;
    cursor: pointer;
    transition: background 0.2s ease;
}

.toggle-switch-thumb {
    position: absolute;
    top: 2px;
    left: 2px;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: #fff;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
    transition: transform 0.2s ease;
}

.toggle-switch[data-state='on'] {
    background: #000;
}

.toggle-switch[data-state='on'] .toggle-switch-thumb {
    transform: translateX(20px);
}

.backtest-execute-actions {
    margin-top: 25px;
    display: flex;
    justify-content: flex-end;
}

.backtest-result-card {
    background: #f7f7f7;
    border: 1px solid #e0e0e0;
    border-radius: 8px;
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.backtest-result-label {
    font-size: 0.85rem;
    color: #555;
    letter-spacing: 0.02em;
    text-transform: uppercase;
}

.backtest-result-value {
    font-size: 1.25rem;
    font-weight: 600;
    color: #111;
}

#backtest-progress {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 25px;
    padding: 12px 18px;
    border: 1px solid #d0d0d0;
    border-radius: 8px;
    background: #f5f5f5;
    color: #333;
    font-size: 0.95rem;
}

#backtest-progress .spinner {
    width: 18px;
    height: 18px;
    border: 2px solid #ccc;
    border-top-color: #333;
    border-radius: 50%;
    animation: backtest-spin 0.8s linear infinite;
}

@keyframes backtest-spin {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

.backtest-summary-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 18px;
    margin-bottom: 25px;
}

#backtest-trades-table {
    overflow-x: auto;
}

.backtest-trades-table {
    width: 100%;
    border-collapse: collapse;
    min-width: 900px;
}

.backtest-trades-table thead th {
    text-align: left;
    font-size: 0.85rem;
    font-weight: 600;
    padding: 10px;
    border-bottom: 1px solid #d0d0d0;
    background: #fafafa;
}

.backtest-trades-table tbody td {
    padding: 10px;
    border-bottom: 1px solid #e5e5e5;
    font-size: 0.9rem;
    white-space: nowrap;
}

.backtest-trades-table tbody tr:hover {
    background: #f2f2f2;
}

.backtest-trades-table .pnl-positive {
    color: #16a34a;
    font-weight: 600;
}

.backtest-trades-table .pnl-negative {
    color: #dc2626;
    font-weight: 600;
}

.backtest-condition-card {
    background: #f6f6f6;
    border: 1px solid #dcdcdc;
    border-radius: 8px;
    padding: 20px;
    margin-bottom: 25px;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.05);
}

/* Strike History Chart (now in main content area) */
#strike-history-section {
    margin-top: 30px;
}

#strike-history-chart {
    width: 100% !important;
    height: 400px !important;
    min-height: 400px !important;
    max-height: 500px !important;
}

/* Chat Sidebar (Right Side) */
.chat-window {
    position: fixed;
    top: 0;
    right: 0;
    width: 420px;
    height: 100vh;
    background: linear-gradient(180deg, #0b1220 0%, #10192d 55%, #0f172a 100%);
    color: #f3f4f6;
    border-left: 1px solid rgba(148, 163, 184, 0.2);
    box-shadow: -24px 0 60px rgba(15, 23, 42, 0.35);
    display: flex;
    flex-direction: column;
    z-index: 1200;
    transform: translateX(100%);
    transition: transform 0.3s ease-in-out;
    backdrop-filter: blur(18px);
}

.chat-window.open {
    transform: translateX(0);
}

.chat-window.collapsed {
    transform: translateX(100%);
}

.chat-window.maximized {
    width: min(80vw, 960px);
    max-width: 960px;
}

.chat-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 20px;
    padding: 20px 24px;
    background: rgba(15, 23, 42, 0.8);
    border-bottom: 1px solid rgba(148, 163, 184, 0.2);
    flex-shrink: 0;
}

.chat-header-info {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.chat-header-title {
    font-size: 1.05em;
    font-weight: 600;
    letter-spacing: 0.04em;
    color: #f9fafb;
}

.chat-header-status {
    font-size: 0.72em;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: #a5b4fc;
    display: flex;
    align-items: center;
    gap: 8px;
}

.chat-status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #34d399;
    box-shadow: 0 0 10px rgba(52, 211, 153, 0.9);
}

.chat-header-buttons {
    display: flex;
    align-items: center;
    gap: 8px;
}

.chat-header-buttons button {
    border: 1px solid rgba(148, 163, 184, 0.3);
    background: rgba(17, 24, 39, 0.6);
    color: #e2e8f0;
    font-size: 0.75em;
    font-weight: 500;
    padding: 6px 12px;
    border-radius: 8px;
    cursor: pointer;
    transition: background 0.2s ease, border-color 0.2s ease, transform 0.2s ease;
}

.chat-header-buttons button:hover {
    background: rgba(30, 41, 59, 0.9);
    border-color: rgba(148, 163, 184, 0.6);
    transform: translateY(-1px);
}

.chat-toggle-btn {
    font-size: 1.2em;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 34px;
    height: 34px;
    padding: 0;
}

.chat-body {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 24px;
    display: flex;
    flex-direction: column;
    gap: 18px;
    background: transparent;
}

.chat-messages::-webkit-scrollbar {
    width: 6px;
}

.chat-messages::-webkit-scrollbar-thumb {
    background: rgba(148, 163, 184, 0.3);
    border-radius: 999px;
}

.chat-message-container {
    display: flex;
    flex-direction: column;
    gap: 6px;
    max-width: 88%;
}

.chat-message-container-user {
    align-self: flex-end;
    align-items: flex-end;
}

.chat-message-container-assistant {
    align-self: flex-start;
    align-items: flex-start;
}

.chat-role-label {
    font-size: 0.65em;
    letter-spacing: 0.14em;
    text-transform: uppercase;
    color: rgba(148, 163, 184, 0.75);
}

.chat-message-container-user .chat-role-label {
    color: rgba(226, 232, 240, 0.7);
}

.chat-message {
    padding: 14px 16px;
    border-radius: 18px;
    line-height: 1.5;
    font-size: 0.95em;
    box-shadow: 0 16px 40px rgba(15, 23, 42, 0.25);
    border: 1px solid transparent;
    backdrop-filter: blur(14px);
    word-break: break-word;
}

.chat-message-user {
    background: linear-gradient(135deg, #2563eb 0%, #0ea5e9 100%);
    color: #f8fafc;
    border-color: rgba(59, 130, 246, 0.6);
    box-shadow: 0 18px 36px rgba(37, 99, 235, 0.35);
}

.chat-message-assistant {
    background: rgba(148, 163, 184, 0.12);
    color: #e2e8f0;
    border-color: rgba(148, 163, 184, 0.25);
    box-shadow: 0 18px 40px rgba(15, 23, 42, 0.4);
}

.chat-input-wrapper {
    background: rgba(15, 23, 42, 0.9);
    border-top: 1px solid rgba(148, 163, 184, 0.2);
    padding: 0 24px 24px;
    display: flex;
    flex-direction: column;
    gap: 14px;
}

.chat-suggestions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.chat-suggestion-btn {
    background: rgba(148, 163, 184, 0.15);
    border: 1px solid rgba(148, 163, 184, 0.25);
    color: #e2e8f0;
    font-size: 0.72em;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    padding: 6px 14px;
    border-radius: 999px;
    cursor: pointer;
    transition: background 0.2s ease, border-color 0.2s ease, transform 0.2s ease;
}

.chat-suggestion-btn:hover {
    background: rgba(191, 219, 254, 0.25);
    border-color: rgba(191, 219, 254, 0.45);
    transform: translateY(-1px);
}

.chat-input-container {
    display: flex;
    align-items: flex-end;
    gap: 12px;
    padding: 14px;
    border-radius: 16px;
    background: rgba(17, 24, 39, 0.92);
    border: 1px solid rgba(148, 163, 184, 0.3);
    box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.02);
}

.chat-input {
    flex: 1;
    min-height: 42px;
    max-height: 180px;
    resize: none;
    background: transparent;
    border: none;
    color: #f9fafb;
    font-size: 0.95em;
    line-height: 1.5;
    outline: none;
    padding: 0;
    font-family: inherit;
}

.chat-input::placeholder {
    color: rgba(148, 163, 184, 0.6);
}

.chat-send-btn {
    width: 46px;
    height: 46px;
    border-radius: 14px;
    background: linear-gradient(140deg, #38bdf8 0%, #6366f1 100%);
    border: none;
    color: #f8fafc;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.2em;
    cursor: pointer;
    box-shadow: 0 18px 30px rgba(99, 102, 241, 0.4);
    transition: transform 0.15s ease, box-shadow 0.15s ease, opacity 0.15s ease;
}

.chat-send-btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 18px 36px rgba(99, 102, 241, 0.55);
}

.chat-send-btn:active {
    transform: translateY(1px);
}

.chat-send-btn:disabled {
    opacity: 0.45;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

.chat-send-icon {
    transform: translateX(2px);
}

.chat-loading {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 0.8em;
    color: rgba(148, 163, 184, 0.75);
    padding: 0 4px;
}

.spinner-small {
    border: 2px solid rgba(148, 163, 184, 0.25);
    border-top: 2px solid #38bdf8;
    border-radius: 50%;
    width: 16px;
    height: 16px;
    animation: spin 1s linear infinite;
}

.chat-open-btn {
    position: fixed;
    bottom: 32px;
    right: 32px;
    width: 58px;
    height: 58px;
    border-radius: 50%;
    background: linear-gradient(140deg, #38bdf8 0%, #6366f1 100%);
    color: #f9fafc;
    border: none;
    box-shadow: 0 18px 36px rgba(59, 130, 246, 0.35);
    cursor: pointer;
    z-index: 1100;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.chat-open-btn:hover {
    transform: scale(1.04);
    box-shadow: 0 20px 40px rgba(99, 102, 241, 0.45);
}

.chat-open-icon {
    font-size: 1.4em;
}

/* Markdown styling in chat messages */
.chat-message h1, .chat-message h2, .chat-message h3 {
    margin-top: 0.5em;
    margin-bottom: 0.5em;
    font-weight: 600;
}

.chat-message h1 { font-size: 1.3em; }
.chat-message h2 { font-size: 1.2em; }
.chat-message h3 { font-size: 1.1em; }

.chat-message p {
    margin: 0.5em 0;
}

.chat-message code {
    background: rgba(0, 0, 0, 0.1);
    padding: 2px 4px;
    border-radius: 3px;
    font-family: 'Courier New', monospace;
    font-size: 0.9em;
}

.chat-message pre {
    background: rgba(0, 0, 0, 0.05);
    padding: 10px;
    border-radius: 6px;
    overflow-x: auto;
    margin: 0.5em 0;
}

.chat-message pre code {
    background: none;
    padding: 0;
}

.chat-message ul, .chat-message ol {
    margin: 0.5em 0;
    padding-left: 1.5em;
}

.chat-message li {
    margin: 0.25em 0;
}

.chat-message blockquote {
    border-left: 3px solid #ccc;
    padding-left: 10px;
    margin: 0.5em 0;
    color: #666;
}

.chat-message strong {
    font-weight: 600;
}

.chat-message em {
    font-style: italic;
}

.chat-message table {
    border-collapse: collapse;
    margin: 0.5em 0;
    width: 100%;
}

.chat-message table th,
.chat-message table td {
    border: 1px solid #ccc;
    padding: 6px 10px;
    text-align: left;
}

.chat-message table th {
    background: rgba(0, 0, 0, 0.05);
    font-weight: 600;
}

.section {
    background: white;
    border-radius: 12px;
    padding: 30px;
    margin-bottom: 30px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.1);
}

.section h2 {
    font-size: 1.8em;
    margin-bottom: 20px;
    color: #000;
    border-bottom: 3px solid #000;
    padding-bottom: 10px;
}

.backtest-tabs {
    display: inline-flex;
    gap: 8px;
    border-bottom: 1px solid #ddd;
    margin-bottom: 10px;
}

.backtest-tab {
    padding: 6px 12px;
    border: 1px solid #ccc;
    border-bottom: none;
    background: #f9f9f9;
    cursor: pointer;
    font-size: 0.9em;
    border-radius: 6px 6px 0 0;
}

.backtest-tab.active {
    background: #000;
    color: #fff;
    border-color: #000;
}

.backtest-tab-panel {
    display: none;
}

.backtest-tab-panel.active {
    display: block;
}

/* Options Chain Table */
.options-chain-table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 20px;
    font-size: 14px;
}

.options-chain-table thead {
    background: #000;
    color: white;
}

.options-chain-table th {
    padding: 12px 8px;
    text-align: center;
    font-weight: 600;
}

.options-chain-table td {
    padding: 10px 8px;
    text-align: center;
    border-bottom: 1px solid #e0e0e0;
}

.options-chain-table tbody tr:hover {
    background: #f5f5f5;
}

.strike-column {
    background: #f5f5f5;
    font-weight: 600;
    font-size: 16px;
}

.call-column {
    text-align: left;
}

.put-column {
    text-align: right;
}

/* Expiration Buttons */
.expiration-tabs {
    display: flex;
    gap: 10px;
    margin-bottom: 20px;
    flex-wrap: wrap;
}

.expiration-button {
    padding: 10px 20px;
    border: 2px solid #000;
    background: white;
    color: #000;
    border-radius: 6px;
    cursor: pointer;
    font-weight: 500;
    transition: all 0.3s;
    font-size: 14px;
}

.expiration-button:hover {
    background: #f5f5f5;
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
}

.expiration-button[data-active='true'] {
    background: #000;
    color: white;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}

/* Expiration Row - Expandable */
.expiration-row {
    cursor: pointer;
    transition: background-color 0.2s;
    user-select: none;
}

.expiration-row:hover {
    background-color: #f5f5f5 !important;
}

.expiration-row[data-expanded="true"] {
    background-color: #e0e0e0 !important;
}

.expand-icon {
    font-size: 12px;
    color: #000;
    font-weight: bold;
    text-align: center;
    transition: transform 0.2s;
}

.expiration-row[data-expanded="true"] .expand-icon {
    color: #333;
}

/* Expiration Detail Row */
.expiration-detail-row {
    background-color: #f5f5f5;
}

.expiration-detail-cell {
    padding: 20px !important;
    background-color: #f5f5f5;
    overflow: visible !important; /* Let child handle scrolling */
    max-width: 100%;
    width: 100%;
    /* Remove any height restrictions to allow natural growth */
    max-height: none !important;
    height: auto !important;
}

.inline-chain-container {
    padding: 0;
    width: 100%;
    max-width: 100%;
    overflow: visible;
}

/* Scrollable wrapper for the table */
.inline-chain-container .table-scroll-wrapper {
    width: 100%;
    overflow-x: auto !important;
    overflow-y: visible !important;
    -webkit-overflow-scrolling: touch; /* Smooth scrolling on iOS */
}

/* DataTables scroll wrapper for inline chain tables */
.inline-chain-container .dataTables_wrapper {
    width: 100%;
    min-width: 100%;
    overflow-x: auto !important;
    overflow-y: visible !important;
    position: relative;
}

.inline-chain-container .dataTables_scroll {
    width: 100%;
    overflow-x: auto !important;
    overflow-y: visible !important;
    position: relative;
}

.inline-chain-container .dataTables_scrollBody {
    overflow-x: auto !important;
    overflow-y: visible !important;
    min-width: 100% !important;
}

.inline-chain-container .dataTables_scrollHead {
    overflow-x: auto !important;
    overflow-y: visible !important;
    min-width: 100% !important;
}

.inline-chain-container table {
    min-width: 1200px !important; /* Ensure table has minimum width for all columns */
    width: 100% !important;
    table-layout: auto !important;
}

.detail-loading {
    padding: 20px;
    text-align: center;
    color: #666;
}

.detail-loading .spinner {
    display: inline-block;
    width: 20px;
    height: 20px;
    border: 3px solid #e0e0e0;
    border-top: 3px solid #000;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin-right: 10px;
}

.green {
    color: #666;
}

.red {
    color: #333;
}

/* Data Table */
.data-table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 20px;
    font-size: 13px;
}

.data-table thead {
    background: #000;
    color: white;
}

.data-table th {
    padding: 12px 8px;
    text-align: center;
    font-weight: 600;
    white-space: nowrap;
}

.data-table td {
    padding: 10px 8px;
    text-align: center;
    border-bottom: 1px solid #e0e0e0;
}

.data-table tbody tr:hover {
    background: #f5f5f5;
}

/* Chain Summary Container - Scrolling */
#chain-summary-container {
    width: 100%;
    overflow: auto;
    max-height: 500px;
}

#chain-summary-table th.sticky-summary-col-1,
#chain-summary-table td.sticky-summary-col-1 {
    position: sticky;
    left: 0;
    z-index: 6;
    background: #ffffff;
    box-shadow: 4px 0 12px rgba(15, 23, 42, 0.08);
}

#chain-summary-table th.sticky-summary-col-2,
#chain-summary-table td.sticky-summary-col-2 {
    position: sticky;
    left: 160px;
    z-index: 5;
    background: #ffffff;
    box-shadow: 4px 0 10px rgba(15, 23, 42, 0.06);
}

#chain-summary-table tbody tr:hover td.sticky-summary-col-1,
#chain-summary-table tbody tr:hover td.sticky-summary-col-2 {
    background: #f5f5f5;
}

#chain-summary-table thead th.sticky-summary-col-1,
#chain-summary-table thead th.sticky-summary-col-2 {
    background: #ededed;
}

#chain-summary-table thead th:nth-child(2),
#chain-summary-table tbody td:nth-child(2) {
    text-align: left;
}

/* Chain summary chart buttons */
.chain-summary-chart-btn {
    padding: 6px 12px;
    background: #f3f4f6;
    border: 1px solid #d1d5db;
    border-radius: 6px;
    color: #374151;
    font-size: 0.875rem;
    cursor: pointer;
    transition: all 0.2s ease;
    font-weight: 500;
}

.chain-summary-chart-btn:hover {
    background: #e5e7eb;
    border-color: #9ca3af;
    color: #111827;
}

.chain-summary-chart-btn.active {
    background: #3b82f6;
    border-color: #3b82f6;
    color: #ffffff;
    font-weight: 600;
}

/* Chain summary chart container */
#chain-summary-chart-container {
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    padding: 15px;
    background: #ffffff;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

/* DataTables Wrapper - Scrolling */
.dataTables_wrapper {
    width: 100%;
    position: relative;
}

.dataTables_wrapper .dataTables_scroll {
    position: relative;
    clear: both;
}

.dataTables_wrapper .dataTables_scrollBody {
    overflow-y: auto !important;
    overflow-x: auto !important;
    max-height: 400px !important;
}

.dataTables_wrapper .dataTables_scrollHead {
    overflow-x: auto !important;
}

/* Chart Container */
.chart-container {
    position: relative;
    height: 400px;
    margin-top: 20px;
}

.chart-row {
    display: flex;
    gap: 20px;
    flex-wrap: wrap;
}

.chart-panel {
    flex: 1 1 0;
    min-width: 300px;
    background: white;
    border: 1px solid #e2e2e2;
    border-radius: 8px;
    padding: 20px;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.05);
}

.chart-panel h3 {
    margin-top: 0;
    margin-bottom: 10px;
    font-size: 1.1em;
}

.chart-controls {
    margin-top: 15px;
    display: flex;
    align-items: center;
    gap: 10px;
}

.chart-controls label {
    font-weight: 500;
}

.chart-controls select {
    padding: 8px 12px;
    border: 2px solid #e0e0e0;
    border-radius: 6px;
    font-size: 14px;
}

/* Volatility Smile Charts */
.volatility-smile-container {
    display: grid !important;
    grid-template-columns: repeat(5, minmax(0, 1fr)) !important;
    gap: 20px !important;
    margin-top: 20px;
    width: 100%;
    align-items: start;
    max-height: 980px; /* Show 3 rows (5 × 300px + gaps) ≈ 980px */
    overflow-y: auto; /* Enable vertical scrolling when more than 3 rows */
    overflow-x: hidden; /* Disable horizontal scrolling */
    padding-right: 10px; /* Space for scrollbar */
}

.volatility-smile-chart {
    position: relative;
    height: 300px !important;
    min-height: 300px !important;
    max-height: 300px !important;
    box-sizing: border-box;
    padding-bottom: 20px;
    overflow: hidden;
}

.volatility-smile-chart h3 {
    margin-bottom: 10px;
    margin-top: 0;
    color: #000;
    font-size: 1em;
    line-height: 1.3;
    padding-bottom: 5px;
    word-wrap: break-word;
    overflow-wrap: break-word;
}

/* Responsive: 2 charts per row on tablets */
@media (max-width: 1024px) {
    .volatility-smile-container {
        grid-template-columns: repeat(2, 1fr);
    }
}

/* Responsive: 1 chart per row on mobile */
@media (max-width: 768px) {
    .volatility-smile-container {
        grid-template-columns: 1fr;
    }
}

/* Loading Spinner */
.loading {
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 40px;
    color: #666;
}

.spinner {
    border: 4px solid #e0e0e0;
    border-top: 4px solid #000;
    border-radius: 50%;
    width: 40px;
    height: 40px;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* DataTables Styling */
.dataTables_wrapper {
    margin-top: 20px;
}

.dataTables_filter input,
.dataTables_length select {
    padding: 6px 10px;
    border: 2px solid #e0e0e0;
    border-radius: 6px;
    font-size: 14px;
    margin: 0 5px;
}

.dataTables_wrapper .dataTables_paginate .paginate_button {
    padding: 6px 12px;
    margin: 0 2px;
    border-radius: 4px;
    border: 1px solid #ccc;
    background: white;
    color: #000 !important;
}

.dataTables_wrapper .dataTables_paginate .paginate_button:hover {
    background: #f5f5f5;
    border-color: #999;
}

.dataTables_wrapper .dataTables_paginate .paginate_button.current {
    background: #000 !important;
    color: white !important;
    border-color: #000;
}

.dataTables_wrapper .dataTables_info {
    padding-top: 8px;
    color: #666;
}

/* Options Chain Table Container */
.options-chain-table-container {
    overflow-x: auto;
}

.expiration-tabs {
    margin-bottom: 20px;
}

.tab-button:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.3);
}

.left-sidebar-title {
    font-size: 1.1em;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

.sidebar-logout {
    display: block;
    margin-top: auto;
    padding: 12px 15px;
    border: 2px solid #000;
    border-radius: 6px;
    text-align: center;
    text-decoration: none;
    color: #000;
    font-weight: 600;
    transition: all 0.3s;
    position: sticky;
    bottom: 20px;
    background: white;
}

.sidebar-logout:hover {
    background: #f5f5f5;
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
}

.sidebar-bottom {
    margin-top: auto;
}

.sidebar-logout-btn {
    width: 100%;
    padding: 12px 15px;
    border: 2px solid #000;
    border-radius: 6px;
    background: #000;
    color: #fff;
    font-weight: 600;
    letter-spacing: 0.04em;
    cursor: pointer;
    transition: all 0.3s;
}

.sidebar-logout-btn:hover {
    background: #fff;
    color: #000;
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
}

/* Responsive */
@media (max-width: 768px) {
    .nav-container {
        flex-direction: column;
        gap: 15px;
    }
    
    .time-selector {
        flex-direction: column;
        width: 100%;
    }
    
    .options-chain-table {
        font-size: 12px;
    }
    
    .data-table {
        font-size: 11px;
        overflow-x: auto;
        display: block;
    }
    
    .dataTables_wrapper {
        overflow-x: auto;
    }
}

.volatility-smile-3d-section {
    margin-bottom: 25px;
    background: #ffffff;
    border: 1px solid #e5e7eb;
    border-radius: 12px;
    padding: 20px;
    box-shadow: 0 10px 28px rgba(15, 23, 42, 0.08);
    width: 80%;
    max-width: 80%;
    min-width: 360px;
}

.volatility-smile-3d-section h3 {
    margin-bottom: 12px;
    font-size: 1.2em;
    font-weight: 600;
    color: #111827;
}

.volatility-surface-3d {
    width: 100%;
    height: 420px;
}

@media (max-width: 1400px) {
    .volatility-smile-3d-section {
        width: 100%;
        max-width: 100%;
    }

    .sidebar {
        flex: 0 0 360px;
        width: 360px;
        padding-top: 10px;
    }

    .chat-window.maximized {
        width: 100%;
        max-width: 100%;
    }
}

#expirations-table thead th {
    text-align: left;
}

#expirations-table tbody td {
    text-align: left;
}

#expirations-table .dte-col {
    text-align: left;
}

#expirations-table .strike-count-col,
#expirations-table .open-interest-col,
#expirations-table tbody td:nth-child(4),
#expirations-table tbody td:nth-child(5) {
    text-align: right;
}

/* Data Availability Modal */
.modal {
    display: none;
    position: fixed;
    z-index: 2000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    overflow: auto;
    background-color: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(4px);
    align-items: center;
    justify-content: center;
}

.modal-content {
    background: linear-gradient(180deg, #0b1220 0%, #10192d 55%, #0f172a 100%);
    margin: auto;
    padding: 0;
    border: 1px solid rgba(148, 163, 184, 0.2);
    border-radius: 12px;
    width: 90%;
    max-width: 1000px;
    max-height: 90vh;
    display: flex;
    flex-direction: column;
    box-shadow: 0 24px 60px rgba(15, 23, 42, 0.5);
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 24px;
    border-bottom: 1px solid rgba(148, 163, 184, 0.2);
}

.modal-header h2 {
    color: #f9fafb;
    font-size: 1.5em;
    font-weight: 600;
    margin: 0;
}

.modal-close {
    background: none;
    border: none;
    color: #e2e8f0;
    font-size: 2em;
    cursor: pointer;
    padding: 0;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 6px;
    transition: background 0.2s ease;
}

.modal-close:hover {
    background: rgba(148, 163, 184, 0.2);
}

.modal-body {
    padding: 24px;
    overflow-y: auto;
    flex: 1;
}

.data-availability-table {
    width: 100%;
    border-collapse: collapse;
    color: #e2e8f0;
    font-size: 0.9em;
}

.data-availability-table thead {
    background: rgba(15, 23, 42, 0.6);
    position: sticky;
    top: 0;
    z-index: 10;
}

.data-availability-table th {
    padding: 12px;
    text-align: left;
    font-weight: 600;
    color: #a5b4fc;
    border-bottom: 2px solid rgba(148, 163, 184, 0.3);
}

.data-availability-table td {
    padding: 12px;
    border-bottom: 1px solid rgba(148, 163, 184, 0.1);
}

.data-availability-table tbody tr:hover {
    background: rgba(148, 163, 184, 0.1);
}

.data-availability-table code {
    background: rgba(15, 23, 42, 0.6);
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 0.85em;
    color: #60a5fa;
}

.loading-spinner {
    text-align: center;
    padding: 40px;
    color: #a5b4fc;
}

.error-message {
    padding: 20px;
    background: rgba(239, 68, 68, 0.1);
    border: 1px solid rgba(239, 68, 68, 0.3);
    border-radius: 8px;
    color: #fca5a5;
    text-align: center;
}


