:root {
    --bg-page: #f0f2f5;
    --bg-card: #ffffff;
    --bg-input: #f7f8fa;
    --border: #e5e7eb;
    --text-primary: #1a1a2e;
    --text-secondary: #6b7280;
    --text-muted: #9ca3af;
    --accent-red: #ef4444;
    --accent-green: #22c55e;
    --accent-blue: #2563eb;
    --accent-yellow: #f59e0b;
    --shadow: 0 1px 3px rgba(0, 0, 0, 0.06), 0 1px 2px rgba(0, 0, 0, 0.04);
    --shadow-md: 0 4px 6px rgba(0, 0, 0, 0.05), 0 2px 4px rgba(0, 0, 0, 0.03);
    --radius: 12px;
}

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

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
    background: var(--bg-page);
    color: var(--text-primary);
    min-height: 100vh;
    -webkit-font-smoothing: antialiased;
}

/* ── Header / Navbar ── */
.header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0 32px;
    height: 56px;
    background: var(--bg-card);
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    z-index: 100;
}

.header h1 {
    font-size: 17px;
    font-weight: 700;
    color: var(--text-primary);
    letter-spacing: -0.3px;
}

.header .date {
    font-size: 13px;
    color: var(--text-secondary);
    font-weight: 500;
}

.header-right {
    display: flex;
    align-items: center;
    gap: 20px;
}

/* ── Status Bar ── */
.status-bar {
    display: flex;
    align-items: center;
    gap: 16px;
    font-size: 12px;
    color: var(--text-secondary);
    font-weight: 500;
}

.status-item {
    display: flex;
    align-items: center;
    gap: 6px;
}

.status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    display: inline-block;
}

.status-dot.connected {
    background: var(--accent-green);
    box-shadow: 0 0 4px rgba(34, 197, 94, 0.4);
}

.status-dot.disconnected {
    background: var(--text-muted);
}

.status-label {
    color: var(--text-muted);
}

/* ── Refresh Button ── */
.btn-refresh {
    width: 30px;
    height: 30px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--bg-card);
    color: var(--text-secondary);
    font-size: 16px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}

.btn-refresh:hover {
    background: var(--bg-page);
    color: var(--text-primary);
    border-color: var(--text-muted);
}

.btn-refresh.loading {
    animation: spin 1s linear infinite;
    pointer-events: none;
    opacity: 0.6;
}

.btn-refresh.success {
    background: var(--accent-green);
    color: #fff;
    border-color: var(--accent-green);
}

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

/* ── Mode Toggle Switch ── */
.mode-switch {
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    font-size: 13px;
    font-weight: 600;
    color: var(--text-primary);
    user-select: none;
}

.mode-switch input {
    display: none;
}

.switch-slider {
    position: relative;
    width: 36px;
    height: 20px;
    background: var(--accent-blue);
    border-radius: 10px;
    transition: background 0.2s;
}

.switch-slider::after {
    content: '';
    position: absolute;
    top: 2px;
    left: 2px;
    width: 16px;
    height: 16px;
    background: #fff;
    border-radius: 50%;
    transition: transform 0.2s;
}

.mode-switch input:checked + .switch-slider {
    background: var(--text-muted);
}

.mode-switch input:checked + .switch-slider::after {
    transform: translateX(16px);
}

/* ── Main ── */
.main {
    max-width: 1360px;
    margin: 0 auto;
    padding: 24px 32px;
}

/* ── Card base ── */
.card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 24px;
}

.input-card, .result-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 24px;
}

/* ── Section titles ── */
.input-card h3, .result-card h3 {
    font-size: 16px;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 16px;
    padding-bottom: 12px;
    border-bottom: 1px solid var(--border);
}

/* ── Straddle section grid ── */
.straddle-section {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
    margin-bottom: 20px;
}

/* ── Symbol label ── */
.symbol-label {
    font-size: 13px;
    font-weight: 700;
    color: var(--text-primary);
    background: var(--bg-page);
    display: inline-block;
    padding: 3px 10px;
    border-radius: 6px;
    margin-bottom: 8px;
}

/* ── Form ── */
.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    gap: 10px;
    margin-bottom: 10px;
}

.form-group label {
    display: block;
    font-size: 12px;
    font-weight: 500;
    color: var(--text-secondary);
    margin-bottom: 4px;
}

.form-group input {
    width: 100%;
    padding: 8px 10px;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: 8px;
    color: var(--text-primary);
    font-family: inherit;
    font-size: 14px;
    transition: border-color 0.15s, box-shadow 0.15s;
}

.form-group input:focus {
    outline: none;
    border-color: var(--accent-blue);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

.form-group input::placeholder {
    color: var(--text-muted);
}

.btn {
    padding: 9px 24px;
    border: none;
    border-radius: 8px;
    font-family: inherit;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.15s;
}

.btn-primary {
    background: var(--text-primary);
    color: #fff;
}

.btn-primary:hover {
    background: #2d2d4e;
    box-shadow: var(--shadow-md);
}

/* ── Result values ── */
.result-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
    margin-bottom: 4px;
}

.result-item {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.result-item .label {
    font-size: 12px;
    font-weight: 500;
    color: var(--text-secondary);
}

.result-item .value {
    font-size: 20px;
    font-weight: 800;
    color: var(--text-primary);
    letter-spacing: -0.5px;
}

.value.red { color: var(--accent-red); }
.value.green { color: var(--accent-green); }
.value.blue { color: var(--accent-blue); }
.value.yellow { color: var(--accent-yellow); }

/* ── Price ruler ── */
.price-ruler {
    margin-top: 14px;
    padding: 10px 0;
    border-top: 1px solid var(--border);
}

.ruler-bar {
    position: relative;
    height: 10px;
    background: linear-gradient(to right, var(--accent-green), #e5e7eb 40%, #e5e7eb 60%, var(--accent-red));
    border-radius: 5px;
    margin: 8px 0;
}

.ruler-marker {
    position: absolute;
    top: -5px;
    width: 20px;
    height: 20px;
    background: var(--text-primary);
    border-radius: 50%;
    transform: translateX(-50%);
    border: 3px solid var(--bg-card);
    box-shadow: var(--shadow-md);
}

.ruler-labels {
    display: flex;
    justify-content: space-between;
    font-size: 11px;
    font-weight: 600;
    color: var(--text-secondary);
}

/* ── Chart grid ── */
.chart-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
    margin-bottom: 16px;
}

.chart-container {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 16px;
}

.chart-container .chart-title {
    font-size: 15px;
    font-weight: 700;
    margin-bottom: 8px;
    color: var(--text-primary);
}

.chart-container .chart-area {
    height: 280px;
    border-radius: 8px;
    overflow: hidden;
}

/* ── Legend ── */
.chart-legend {
    display: flex;
    gap: 28px;
    justify-content: center;
    padding: 10px;
    font-size: 13px;
    font-weight: 500;
    color: var(--text-secondary);
}

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

.legend-line {
    width: 24px;
    height: 2px;
    border-top: 2px dashed;
}

.legend-line.red { border-color: var(--accent-red); }
.legend-line.green { border-color: var(--accent-green); }
.legend-line.yellow { border-color: var(--accent-yellow); border-top-style: solid; }

.legend-swatch {
    width: 20px;
    height: 14px;
    border-radius: 3px;
    border: 1px solid var(--border);
}

.legend-swatch.blue { background: rgba(59, 130, 246, 0.12); }
.legend-swatch.white { background: #ffffff; }
.legend-swatch.purple { background: rgba(139, 92, 246, 0.12); }

/* ── Login Modal ── */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.4);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    backdrop-filter: blur(2px);
}

.modal-card {
    background: var(--bg-card);
    border-radius: var(--radius);
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.15);
    width: 360px;
    overflow: hidden;
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px 24px 0;
}

.modal-header h3 {
    font-size: 17px;
    font-weight: 700;
    color: var(--text-primary);
}

.modal-close {
    background: none;
    border: none;
    font-size: 22px;
    color: var(--text-muted);
    cursor: pointer;
    padding: 0 4px;
    line-height: 1;
}

.modal-close:hover {
    color: var(--text-primary);
}

.modal-body {
    padding: 20px 24px;
    display: flex;
    flex-direction: column;
    gap: 14px;
}

.modal-body .form-group label {
    display: block;
    font-size: 12px;
    font-weight: 500;
    color: var(--text-secondary);
    margin-bottom: 4px;
}

.modal-body .form-group input {
    width: 100%;
    padding: 9px 12px;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: 8px;
    color: var(--text-primary);
    font-family: inherit;
    font-size: 14px;
    transition: border-color 0.15s, box-shadow 0.15s;
}

.modal-body .form-group input:focus {
    outline: none;
    border-color: var(--accent-blue);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

.email-row {
    display: flex;
    gap: 8px;
}

.email-row input {
    flex: 1;
}

.btn-send-code {
    white-space: nowrap;
    padding: 9px 14px;
    font-size: 13px;
    min-width: 90px;
}

.btn-send-code:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

.login-error {
    font-size: 13px;
    color: var(--accent-red);
    font-weight: 500;
    padding: 8px 12px;
    background: rgba(239, 68, 68, 0.08);
    border-radius: 6px;
}

.modal-footer {
    padding: 0 24px 20px;
}

.modal-footer .btn {
    width: 100%;
}

/* ── TOTP Setup ── */
.totp-instruction {
    font-size: 14px;
    color: var(--text-secondary);
    margin-bottom: 12px;
}

.totp-qr-container {
    text-align: center;
    margin-bottom: 16px;
}

.totp-qr-container img {
    width: 200px;
    height: 200px;
    border-radius: 8px;
    border: 1px solid var(--border);
}

.totp-secret-display {
    font-family: 'Courier New', monospace;
    font-size: 14px;
    font-weight: 700;
    background: var(--bg-input);
    padding: 8px 12px;
    border-radius: 6px;
    border: 1px solid var(--border);
    word-break: break-all;
    user-select: all;
    color: var(--text-primary);
}

/* ── Site Footer ── */
.site-footer {
    text-align: center;
    padding: 16px;
    font-size: 12px;
    color: var(--text-muted);
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 16px;
}

.site-footer a {
    color: var(--text-muted);
    text-decoration: none;
}

.site-footer a:hover {
    color: var(--text-secondary);
    text-decoration: underline;
}

/* ── Privacy Page ── */
.privacy-card {
    max-width: 720px;
    margin: 0 auto;
    line-height: 1.7;
}

.privacy-card h2 {
    font-size: 22px;
    font-weight: 800;
    margin-bottom: 4px;
}

.privacy-updated {
    font-size: 13px;
    color: var(--text-muted);
    margin-bottom: 20px;
}

.privacy-card h3 {
    font-size: 16px;
    font-weight: 700;
    margin-top: 24px;
    margin-bottom: 8px;
}

.privacy-card p {
    font-size: 14px;
    color: var(--text-secondary);
    margin-bottom: 12px;
}

.privacy-card ul {
    padding-left: 20px;
    margin-bottom: 12px;
}

.privacy-card li {
    font-size: 14px;
    color: var(--text-secondary);
    margin-bottom: 6px;
}
