/* ==============================================================================
   Quantum Theme Stylesheet - Stock Recommendation System
   ============================================================================== */

:root {
    --bg-dark: #0a0d14;
    --card-bg: rgba(18, 22, 33, 0.75);
    --border-color: rgba(255, 255, 255, 0.07);
    --border-hover: rgba(0, 210, 255, 0.3);
    
    /* Neon Accents */
    --accent-cyan: #00d2ff;
    --accent-blue: #0066ff;
    --accent-green: #00ff66;
    --accent-red: #ff0055;
    
    /* Text Colors */
    --text-primary: #f1f3f9;
    --text-secondary: #9aa2b1;
    --text-muted: #5e6675;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    background-color: var(--bg-dark);
    color: var(--text-primary);
    font-family: 'Inter', -apple-system, sans-serif;
    line-height: 1.6;
    background-image: 
        radial-gradient(at 0% 0%, rgba(0, 102, 255, 0.08) 0px, transparent 50%),
        radial-gradient(at 100% 100%, rgba(0, 210, 255, 0.05) 0px, transparent 50%);
    background-attachment: fixed;
}

.app-container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 20px;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* Header */
.app-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 15px 25px;
    background: rgba(18, 22, 33, 0.5);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    backdrop-filter: blur(12px);
    margin-bottom: 20px;
}

.logo-area {
    display: flex;
    align-items: center;
    gap: 12px;
}

.logo-area h1 {
    font-family: 'Orbitron', sans-serif;
    font-weight: 900;
    font-size: 20px;
    letter-spacing: 2px;
    color: var(--text-primary);
}

.logo-area h1 span {
    color: var(--accent-cyan);
}

.pulse-ring {
    width: 10px;
    height: 10px;
    background: var(--accent-cyan);
    border-radius: 50%;
    box-shadow: 0 0 0 0 rgba(0, 210, 255, 0.7);
    animation: pulse 1.6s infinite;
}

@keyframes pulse {
    0% {
        transform: scale(0.95);
        box-shadow: 0 0 0 0 rgba(0, 210, 255, 0.7);
    }
    70% {
        transform: scale(1);
        box-shadow: 0 0 0 8px rgba(0, 210, 255, 0);
    }
    100% {
        transform: scale(0.95);
        box-shadow: 0 0 0 0 rgba(0, 210, 255, 0);
    }
}

.system-status {
    display: flex;
    align-items: center;
    gap: 12px;
}

.status-label {
    font-size: 12px;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 1px;
}

.status-badge {
    padding: 6px 14px;
    border-radius: 30px;
    font-size: 12px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.2);
}

.status-idle {
    background: rgba(94, 102, 117, 0.2);
    border: 1px solid var(--text-muted);
    color: var(--text-secondary);
}

.status-running {
    background: rgba(0, 210, 255, 0.15);
    border: 1px solid var(--accent-cyan);
    color: var(--accent-cyan);
    animation: blink 1.5s infinite alternate;
}

.status-done {
    background: rgba(0, 255, 102, 0.15);
    border: 1px solid var(--accent-green);
    color: var(--accent-green);
}

.status-failed {
    background: rgba(255, 0, 85, 0.15);
    border: 1px solid var(--accent-red);
    color: var(--accent-red);
}

@keyframes blink {
    from { opacity: 0.7; }
    to { opacity: 1; }
}

/* Grids & Cards */
.dashboard-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
    margin-bottom: 20px;
}

@media (max-width: 900px) {
    .dashboard-grid {
        grid-template-columns: 1fr;
    }
}

.glass-card {
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: 16px;
    padding: 25px;
    backdrop-filter: blur(16px);
    transition: border-color 0.3s ease, box-shadow 0.3s ease;
}

.glass-card:hover {
    border-color: rgba(255, 255, 255, 0.12);
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
}

.card-header {
    margin-bottom: 20px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
    padding-bottom: 15px;
}

.card-header h2 {
    font-size: 18px;
    font-weight: 700;
    color: var(--text-primary);
}

.card-subtitle {
    font-size: 12px;
    color: var(--text-secondary);
}

/* Buttons */
.btn-primary, .btn-secondary {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    padding: 14px;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.3s ease;
    border: none;
}

.btn-primary {
    background: linear-gradient(135deg, var(--accent-blue) 0%, var(--accent-cyan) 100%);
    color: white;
    box-shadow: 0 4px 15px rgba(0, 102, 255, 0.3);
}

.btn-primary:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(0, 210, 255, 0.5);
}

.btn-primary:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

.btn-secondary {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--border-color);
    color: var(--text-primary);
}

.btn-secondary:hover:not(:disabled) {
    background: rgba(255, 255, 255, 0.1);
    border-color: var(--text-secondary);
}

.btn-loader {
    width: 18px;
    height: 18px;
    border: 3px solid rgba(255, 255, 255, 0.3);
    border-radius: 50%;
    border-top-color: white;
    animation: spin 1s ease-in-out infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

.hidden {
    display: none !important;
}

/* Progress bar */
.progress-section {
    margin: 25px 0;
}

.progress-labels {
    display: flex;
    justify-content: space-between;
    margin-bottom: 8px;
    font-size: 13px;
}

#current-step-text {
    color: var(--accent-cyan);
    font-weight: 500;
}

.progress-bar-container {
    height: 8px;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 10px;
    overflow: hidden;
    border: 1px solid rgba(255, 255, 255, 0.03);
}

.progress-bar-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--accent-blue) 0%, var(--accent-cyan) 100%);
    border-radius: 10px;
    width: 0%;
    transition: width 0.4s ease;
    box-shadow: 0 0 10px var(--accent-cyan);
}

/* Step list */
.steps-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.step-item {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 13px;
    color: var(--text-muted);
    transition: color 0.3s ease;
}

.step-dot {
    width: 8px;
    height: 8px;
    background: var(--text-muted);
    border-radius: 50%;
    transition: background 0.3s ease, box-shadow 0.3s ease;
}

.step-item.active {
    color: var(--accent-cyan);
    font-weight: 600;
}

.step-item.active .step-dot {
    background: var(--accent-cyan);
    box-shadow: 0 0 8px var(--accent-cyan);
}

.step-item.completed {
    color: var(--text-primary);
}

.step-item.completed .step-dot {
    background: var(--accent-green);
    box-shadow: 0 0 8px var(--accent-green);
}

/* Live Terminal Panel */
.terminal-panel {
    display: flex;
    flex-direction: column;
}

.terminal-body {
    flex-grow: 1;
    background: #06090e;
    border: 1px solid rgba(255, 255, 255, 0.04);
    border-radius: 8px;
    padding: 15px;
    font-family: 'Courier New', Courier, monospace;
    font-size: 12px;
    overflow-y: auto;
    max-height: 380px;
    min-height: 250px;
    box-shadow: inset 0 2px 10px rgba(0,0,0,0.8);
}

.terminal-line {
    margin-bottom: 6px;
    word-break: break-all;
    white-space: pre-wrap;
    color: var(--text-secondary);
}

.terminal-line.system-line {
    color: var(--accent-cyan);
}

.terminal-line.warning-line {
    color: #ffaa00;
}

.terminal-line.error-line {
    color: var(--accent-red);
}

.terminal-line.success-line {
    color: var(--accent-green);
}

/* Portfolio weights form */
.portfolio-form h3 {
    font-size: 14px;
    color: var(--text-secondary);
    margin: 20px 0 10px 0;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 15px;
    margin-bottom: 15px;
}

.form-group {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.form-group label {
    font-size: 12px;
    color: var(--text-secondary);
}

.form-group input, .form-group select {
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    padding: 10px 14px;
    color: var(--text-primary);
    font-size: 14px;
    transition: all 0.3s ease;
}

.form-group input:focus, .form-group select:focus {
    outline: none;
    border-color: var(--accent-cyan);
    box-shadow: 0 0 8px rgba(0, 210, 255, 0.2);
}

.form-group select option {
    background-color: #121621;
    color: var(--text-primary);
}

.weight-inputs-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 15px;
    margin-bottom: 20px;
}

.range-container {
    display: flex;
    align-items: center;
    gap: 10px;
}

.range-container input {
    width: 80px;
    text-align: center;
}

.weight-total-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 18px;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    margin-bottom: 20px;
}

.total-status-indicator {
    width: 14px;
    height: 14px;
    border-radius: 50%;
    background: var(--text-muted);
}

.total-status-indicator.valid {
    background: var(--accent-green);
    box-shadow: 0 0 10px var(--accent-green);
}

.total-status-indicator.invalid {
    background: var(--accent-red);
    box-shadow: 0 0 10px var(--accent-red);
}

/* Reports Archiver */
.reports-archiver-container {
    max-height: 270px;
    overflow-y: auto;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    background: rgba(0, 0, 0, 0.15);
}

.reports-list-items {
    list-style: none;
}

.reports-list-items li {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 18px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.03);
    cursor: pointer;
    transition: background 0.2s ease;
}

.reports-list-items li:hover {
    background: rgba(255, 255, 255, 0.02);
}

.reports-list-items li:last-child {
    border-bottom: none;
}

.reports-list-items li.empty-item {
    justify-content: center;
    color: var(--text-muted);
    font-size: 13px;
    cursor: default;
}

.report-file-name {
    font-size: 13px;
    font-weight: 500;
    color: var(--text-primary);
}

.btn-report-view {
    padding: 4px 10px;
    background: rgba(0, 210, 255, 0.1);
    border: 1px solid var(--accent-cyan);
    color: var(--accent-cyan);
    border-radius: 4px;
    font-size: 11px;
    cursor: pointer;
    font-weight: 600;
    transition: all 0.2s ease;
}

.btn-report-view:hover {
    background: var(--accent-cyan);
    color: var(--bg-dark);
}

/* Report Viewer Section */
.report-viewer-card {
    grid-column: 1 / -1;
    margin-top: 20px;
    border-color: var(--border-hover);
    box-shadow: 0 4px 20px rgba(0, 210, 255, 0.1);
    animation: fadeIn 0.4s ease;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

.report-viewer-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.btn-close {
    padding: 6px 16px;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    color: var(--text-primary);
    cursor: pointer;
    font-size: 12px;
    transition: all 0.2s ease;
}

.btn-close:hover {
    background: rgba(255, 0, 85, 0.1);
    border-color: var(--accent-red);
    color: var(--accent-red);
}

.trend-btn {
    font-family: 'Inter', sans-serif;
    background: rgba(13, 17, 38, 0.7);
    border: 1px solid rgba(255,255,255,0.15);
    color: #ffffff;
    padding: 6px 12px;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.3s ease;
}

.trend-btn:hover {
    border-color: var(--accent-cyan);
    box-shadow: 0 0 12px rgba(0,242,254,0.4);
    transform: translateY(-2px);
}

.report-markdown-content {
    background: rgba(0, 0, 0, 0.2);
    border: 1px solid rgba(255, 255, 255, 0.03);
    border-radius: 8px;
    padding: 25px;
    font-size: 14px;
    max-height: 500px;
    overflow-y: auto;
    color: #e2e8f0;
}

.report-markdown-content h1, .report-markdown-content h2, .report-markdown-content h3, .report-markdown-content h4 {
    margin: 20px 0 10px 0;
    color: white;
}

.report-markdown-content h1 {
    font-size: 22px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
    padding-bottom: 8px;
}

.report-markdown-content h2 { font-size: 18px; }
.report-markdown-content h3 { font-size: 15px; color: var(--accent-cyan); }

.report-markdown-content p {
    margin-bottom: 12px;
}

.report-markdown-content ul, .report-markdown-content ol {
    margin-left: 20px;
    margin-bottom: 15px;
}

.report-markdown-content table {
    width: 100%;
    border-collapse: collapse;
    margin: 15px 0;
}

.report-markdown-content th, .report-markdown-content td {
    border: 1px solid rgba(255, 255, 255, 0.08);
    padding: 8px 12px;
    text-align: left;
}

.report-markdown-content th {
    background: rgba(255, 255, 255, 0.03);
    color: white;
}

/* Footer */
.app-footer {
    text-align: center;
    padding: 30px 0;
    color: var(--text-muted);
    font-size: 12px;
    margin-top: auto;
}

/* Caveats Display Box in Control Panel */
.caveats-box {
    margin-top: 25px;
    padding: 18px;
    background: rgba(255, 255, 255, 0.02);
    border: 1px solid var(--border-color);
    border-radius: 10px;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: inset 0 1px 1px rgba(255, 255, 255, 0.05);
}

.caveats-box.highlight {
    background: rgba(0, 210, 255, 0.04);
    border-color: rgba(0, 210, 255, 0.25);
    box-shadow: 0 0 15px rgba(0, 210, 255, 0.08), inset 0 1px 1px rgba(0, 210, 255, 0.05);
}

.caveats-title {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 10px;
}

.caveats-title h4 {
    font-size: 13px;
    font-weight: 700;
    color: var(--accent-cyan);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.glowing-dot {
    width: 6px;
    height: 6px;
    background: var(--accent-cyan);
    border-radius: 50%;
    box-shadow: 0 0 8px var(--accent-cyan);
    animation: glow-pulse 1.8s infinite;
}

@keyframes glow-pulse {
    0% {
        box-shadow: 0 0 0 0 rgba(0, 210, 255, 0.6);
    }
    70% {
        box-shadow: 0 0 0 6px rgba(0, 210, 255, 0);
    }
    100% {
        box-shadow: 0 0 0 0 rgba(0, 210, 255, 0);
    }
}

.caveats-content {
    font-size: 12px;
    color: var(--text-secondary);
    line-height: 1.6;
}

.caveats-content strong {
    color: var(--text-primary);
}

/* ==============================================================================
   Real-time Portfolio Table
   ============================================================================== */
.holdings-table-container, .table-container {
    width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    margin-top: 10px;
}

.holdings-table {
    width: 100%;
    border-collapse: collapse;
    text-align: left;
    font-size: 13px;
}

/* Screener specific rebalanced table layout */
.table-container .holdings-table,
.screener-table {
    min-width: 1250px;
    table-layout: fixed;
}

.holdings-table th {
    background: rgba(255, 255, 255, 0.02);
    padding: 12px 16px;
    font-weight: 600;
    color: var(--text-secondary);
    border-bottom: 1px solid var(--border-color);
    text-transform: uppercase;
    font-size: 11px;
    letter-spacing: 0.5px;
}

.table-container .holdings-table th,
.screener-table th {
    padding: 10px 8px;
    white-space: nowrap;
}

.holdings-table th.col-rationale {
    min-width: 280px;
    white-space: normal;
}

.holdings-table th.sortable {
    cursor: pointer;
    user-select: none;
    transition: background-color 0.2s ease, color 0.2s ease;
}

.holdings-table th.sortable:hover {
    background: rgba(255, 255, 255, 0.06);
    color: var(--text-primary);
}

.holdings-table th.sortable .sort-icon {
    display: inline-block;
    margin-left: 4px;
    font-size: 10px;
    color: rgba(255, 255, 255, 0.3);
    transition: color 0.2s ease;
}

.holdings-table th.sortable:hover .sort-icon {
    color: var(--accent-cyan);
}

.holdings-table th.sortable.active-sort {
    color: var(--accent-cyan);
    background: rgba(0, 242, 254, 0.03);
}

.holdings-table th.sortable.active-sort .sort-icon {
    color: var(--accent-cyan);
}

.holdings-table td {
    padding: 12px 16px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.03);
    color: var(--text-primary);
}

.table-container .holdings-table td,
.screener-table td {
    padding: 10px 8px;
}

.holdings-table td.col-rationale-cell {
    min-width: 280px;
    font-size: 0.84rem;
    line-height: 1.5;
    color: #e2e8f0;
    white-space: normal;
    word-break: keep-all; /* 단어 단위 줄바꿈으로 한글 가독성 극대화 */
    overflow-wrap: break-word;
    padding: 10px 14px;
}

.holdings-table tbody tr:hover {
    background: rgba(255, 255, 255, 0.02);
}

.holdings-table td.ticker-cell {
    font-family: 'Orbitron', monospace;
    font-weight: 700;
    color: var(--accent-cyan);
}

.holdings-table td.number-cell {
    font-family: 'Orbitron', monospace;
    text-align: right;
}

.holdings-table td.pos-return {
    color: var(--accent-green) !important;
    text-shadow: 0 0 4px rgba(0, 255, 102, 0.2);
}

.holdings-table td.neg-return {
    color: var(--accent-red) !important;
    text-shadow: 0 0 4px rgba(255, 0, 85, 0.2);
}

.loading-holdings {
    text-align: center;
    padding: 30px !important;
    color: var(--text-secondary);
    font-style: italic;
}

/* Portfolio Summary Bar */
.portfolio-summary-bar {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 15px;
    margin-top: 15px;
    margin-bottom: 20px;
    width: 100%;
}

.summary-card {
    background: rgba(255, 255, 255, 0.02);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 15px;
    display: flex;
    flex-direction: column;
    gap: 6px;
    transition: border-color 0.3s ease, box-shadow 0.3s ease;
}

.summary-card:hover {
    border-color: rgba(255, 255, 255, 0.1);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}

.summary-card .summary-label {
    font-size: 11px;
    color: var(--text-muted);
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.summary-card .summary-value {
    font-family: 'Orbitron', monospace;
    font-size: 20px;
    font-weight: 700;
    color: var(--text-primary);
}

.summary-card.profit-card.pos-return .summary-value {
    color: var(--accent-green);
    text-shadow: 0 0 8px rgba(0, 255, 102, 0.3);
}

.summary-card.profit-card.neg-return .summary-value {
    color: var(--accent-red);
    text-shadow: 0 0 8px rgba(255, 0, 85, 0.3);
}

/* ==============================================================================
   Rebalance Strategy Panel Styles
   ============================================================================== */

.rebalance-strategy-panel {
    border-color: rgba(0, 210, 255, 0.15) !important;
    box-shadow: 0 4px 20px rgba(0, 210, 255, 0.05) !important;
}

.rebalance-strategy-panel:hover {
    border-color: rgba(0, 210, 255, 0.3) !important;
}

.rebalance-markdown-content {
    background: rgba(0, 0, 0, 0.25) !important;
    border: 1px solid rgba(255, 255, 255, 0.05) !important;
    border-radius: 8px;
    padding: 25px;
    font-size: 14px;
    line-height: 1.6;
    color: #e2e8f0;
}

.rebalance-markdown-content h1, 
.rebalance-markdown-content h2, 
.rebalance-markdown-content h3, 
.rebalance-markdown-content h4 {
    margin: 20px 0 10px 0;
    color: white;
}

.rebalance-markdown-content h1 {
    font-family: 'Orbitron', sans-serif;
    font-size: 22px;
    border-bottom: 1px solid rgba(0, 210, 255, 0.2);
    padding-bottom: 8px;
    color: var(--accent-cyan);
}

.rebalance-markdown-content h2 { 
    font-size: 18px; 
    border-bottom: 2px solid var(--accent-cyan);
}

/* 20일 상승률 뱃지 */
.trend-pct-badge {
    display: inline-block;
    padding: 2px 7px;
    border-radius: 10px;
    font-size: 0.75rem;
    font-weight: 700;
    font-family: 'Roboto Mono', monospace;
    letter-spacing: 0.02em;
    margin-top: 4px;
}
.trend-pct-up   { background: rgba(16,185,129,0.15); color: #10b981; border: 1px solid rgba(16,185,129,0.3); }
.trend-pct-down { background: rgba(239,68,68,0.13);  color: #f87171; border: 1px solid rgba(239,68,68,0.3);  }
.trend-pct-flat { background: rgba(148,163,184,0.12); color: #94a3b8; border: 1px solid rgba(148,163,184,0.25); }
    padding-left: 10px;
    margin-top: 25px;
}

.rebalance-markdown-content h3 { 
    font-size: 15px; 
    color: var(--accent-cyan); 
}

.rebalance-markdown-content p {
    margin-bottom: 12px;
}

.rebalance-markdown-content ul, 
.rebalance-markdown-content ol {
    margin-left: 20px;
    margin-bottom: 15px;
}

.rebalance-markdown-content li {
    margin-bottom: 6px;
}

.rebalance-markdown-content table {
    width: 100%;
    border-collapse: collapse;
    margin: 15px 0;
    background: rgba(255, 255, 255, 0.01);
}

.rebalance-markdown-content th, 
.rebalance-markdown-content td {
    border: 1px solid rgba(255, 255, 255, 0.08);
    padding: 10px 14px;
    text-align: left;
}

.rebalance-markdown-content th {
    background: rgba(0, 210, 255, 0.05);
    color: var(--accent-cyan);
    font-weight: 600;
}

.rebalance-markdown-content td strong {
    color: white;
}

/* ==============================================================================
   Premium UI/UX Modals & Layout Styles (User-Centric Redesign)
   ============================================================================== */

/* Modal Overlays & Containers */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(5, 7, 18, 0.85);
    backdrop-filter: blur(10px);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease, visibility 0.3s ease;
}

.modal-overlay.active {
    opacity: 1;
    visibility: visible;
}

.modal-container {
    background: rgba(18, 22, 33, 0.95);
    border: 1px solid rgba(0, 210, 255, 0.2);
    border-radius: 20px;
    width: 90%;
    max-width: 650px;
    max-height: 85vh;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    box-shadow: 0 10px 40px rgba(0, 210, 255, 0.15), 0 0 100px rgba(0, 0, 0, 0.6);
    transform: scale(0.9);
    transition: transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.modal-overlay.active .modal-container {
    transform: scale(1);
}

.modal-container.large {
    max-width: 900px;
}

.modal-header {
    padding: 20px 25px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.modal-header h3 {
    font-family: 'Orbitron', sans-serif;
    font-size: 1.25rem;
    color: #ffffff;
    font-weight: 700;
    display: flex;
    align-items: center;
    gap: 10px;
}

.modal-body {
    padding: 25px;
    overflow-y: auto;
    flex-grow: 1;
}

.modal-body::-webkit-scrollbar {
    width: 6px;
}

.modal-body::-webkit-scrollbar-thumb {
    background: rgba(0, 210, 255, 0.25);
    border-radius: 3px;
}

.modal-footer {
    padding: 15px 25px;
    border-top: 1px solid rgba(255, 255, 255, 0.08);
    display: flex;
    justify-content: flex-end;
    gap: 12px;
}

/* Header Buttons for Settings & Log */
.btn-header {
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid rgba(255, 255, 255, 0.1);
    color: var(--text-primary);
    padding: 8px 14px;
    border-radius: 6px;
    font-family: 'Inter', sans-serif;
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    transition: all 0.2s ease;
}

.btn-header:hover {
    background: rgba(0, 210, 255, 0.08);
    border-color: rgba(0, 210, 255, 0.4);
    box-shadow: 0 0 10px rgba(0, 210, 255, 0.2);
}

/* Visualization Layout & Charts Grid */
.charts-grid {
    display: grid;
    grid-template-columns: 1.2fr 1fr;
    gap: 20px;
    margin-bottom: 20px;
}

@media (max-width: 950px) {
    .charts-grid {
        grid-template-columns: 1fr;
    }
}

.chart-container-wrapper {
    position: relative;
    width: 100%;
    height: 250px;
    display: flex;
    justify-content: center;
    align-items: center;
}

/* Macro Summary Bar */
.macro-summary-bar {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    gap: 15px;
    margin-bottom: 20px;
}

.macro-card {
    background: rgba(255, 255, 255, 0.02);
    border: 1px solid var(--border-color);
    border-radius: 10px;
    padding: 15px;
    display: flex;
    flex-direction: column;
    gap: 4px;
    transition: all 0.3s ease;
}

.macro-card:hover {
    border-color: rgba(0, 210, 255, 0.2);
    transform: translateY(-2px);
}

.macro-label {
    font-size: 10px;
    color: var(--text-muted);
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.macro-val {
    font-family: 'Orbitron', monospace;
    font-size: 15px;
    font-weight: 700;
}

/* Rebalancing Action Cards */
.rebalance-cards-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 15px;
    margin-top: 15px;
}

.rebalance-action-card {
    background: rgba(0, 0, 0, 0.25);
    border: 1px solid rgba(255, 255, 255, 0.05);
    border-radius: 12px;
    padding: 18px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    position: relative;
    overflow: hidden;
    transition: all 0.3s ease;
}

.rebalance-action-card:hover {
    transform: translateY(-3px);
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.3);
}

.action-badge {
    position: absolute;
    top: 15px;
    right: 15px;
    padding: 4px 10px;
    border-radius: 4px;
    font-family: 'Orbitron', sans-serif;
    font-weight: 900;
    font-size: 10px;
    letter-spacing: 0.5px;
}

.action-buy {
    border-color: rgba(0, 255, 102, 0.4) !important;
    box-shadow: 0 0 15px rgba(0, 255, 102, 0.15) !important;
}
.action-buy:hover {
    border-color: rgba(0, 255, 102, 0.75) !important;
    box-shadow: 0 0 25px rgba(0, 255, 102, 0.35) !important;
}
.action-buy .action-badge {
    background: rgba(0, 255, 102, 0.15);
    color: var(--accent-green);
    border: 1px solid var(--accent-green);
}

.action-sell {
    border-color: rgba(255, 0, 85, 0.4) !important;
    box-shadow: 0 0 15px rgba(255, 0, 85, 0.15) !important;
}
.action-sell:hover {
    border-color: rgba(255, 0, 85, 0.75) !important;
    box-shadow: 0 0 25px rgba(255, 0, 85, 0.35) !important;
}
.action-sell .action-badge {
    background: rgba(255, 0, 85, 0.15);
    color: var(--accent-red);
    border: 1px solid var(--accent-red);
}

.action-hold {
    border-color: rgba(255, 255, 255, 0.1) !important;
}
.action-hold .action-badge {
    background: rgba(255, 255, 255, 0.08);
    color: var(--text-secondary);
    border: 1px solid var(--text-secondary);
}

.rebalance-card-ticker {
    font-family: 'Orbitron', sans-serif;
    font-weight: 700;
    font-size: 16px;
    color: #ffffff;
}

.rebalance-card-name {
    font-size: 11px;
    color: var(--text-secondary);
    margin-top: -4px;
}

.rebalance-card-qty {
    font-family: 'Orbitron', monospace;
    font-size: 14px;
    color: #ffffff;
    font-weight: 600;
    margin-top: 10px;
}

.rebalance-card-weight {
    display: flex;
    justify-content: space-between;
    font-size: 11px;
    color: var(--text-muted);
    margin-top: 5px;
}

.rebalance-card-weight span strong {
    color: #ffffff;
}

.rebalance-card-reason {
    font-size: 12px;
    color: var(--text-secondary);
    margin-top: 10px;
    padding-top: 10px;
    border-top: 1px solid rgba(255, 255, 255, 0.05);
    line-height: 1.5;
}

/* Skeleton Loading Animation */
@keyframes skeleton-loading {
    0% {
        background-color: rgba(255, 255, 255, 0.03);
    }
    50% {
        background-color: rgba(255, 255, 255, 0.08);
    }
    100% {
        background-color: rgba(255, 255, 255, 0.03);
    }
}

.skeleton-placeholder {
    animation: skeleton-loading 1.5s infinite ease-in-out;
    border-radius: 4px;
    display: inline-block;
    width: 100%;
    height: 16px;
}

.skeleton-row td {
    padding: 12px 16px;
}

.skeleton-card {
    background: rgba(0, 0, 0, 0.15);
    border: 1px solid rgba(255, 255, 255, 0.03);
    border-radius: 12px;
    padding: 18px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    animation: skeleton-loading 1.5s infinite ease-in-out;
    height: 180px;
}

/* Cooldown Timer UI */
.cooldown-timer-box {
    margin-top: 15px;
    padding: 15px;
    background: rgba(245, 158, 11, 0.04);
    border: 1px solid rgba(245, 158, 11, 0.15);
    border-radius: 10px;
    box-shadow: 0 4px 15px rgba(245, 158, 11, 0.05);
    transition: all 0.3s ease;
}

.cooldown-timer-box.hidden {
    display: none !important;
}

.cooldown-timer-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 8px;
}

.cooldown-timer-title {
    font-size: 12px;
    font-weight: 700;
    color: #f59e0b;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    display: flex;
    align-items: center;
    gap: 6px;
}

.cooldown-timer-seconds {
    font-family: 'Orbitron', monospace;
    font-weight: 700;
    font-size: 13px;
    color: #f59e0b;
}

.cooldown-bar-container {
    height: 6px;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 4px;
    overflow: hidden;
}

.cooldown-bar-fill {
    height: 100%;
    background: linear-gradient(90deg, #f59e0b 0%, #ffbb00 100%);
    border-radius: 4px;
    width: 100%;
    transition: width 1s linear;
    box-shadow: 0 0 8px rgba(245, 158, 11, 0.5);
}

/* Premium Warning Banner */
.warning-banner {
    background: linear-gradient(135deg, rgba(245, 158, 11, 0.1) 0%, rgba(220, 38, 38, 0.1) 100%);
    border: 1px solid rgba(245, 158, 11, 0.25);
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3), 0 0 15px rgba(245, 158, 11, 0.08);
    border-radius: 10px;
    padding: 15px 20px;
    margin-bottom: 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    animation: slideDown 0.4s cubic-bezier(0.16, 1, 0.3, 1);
    backdrop-filter: blur(10px);
}

.warning-banner.hidden {
    display: none !important;
}

.warning-content {
    display: flex;
    align-items: center;
    gap: 12px;
}

.warning-icon {
    font-size: 20px;
    animation: warning-pulse 1.5s infinite alternate;
}

@keyframes warning-pulse {
    from { transform: scale(1); filter: drop-shadow(0 0 2px #f59e0b); }
    to { transform: scale(1.15); filter: drop-shadow(0 0 8px #f59e0b); }
}

.warning-text h4 {
    font-size: 13px;
    color: #ffffff;
    font-weight: 700;
    margin-bottom: 2px;
}

.warning-text p {
    font-size: 12px;
    color: var(--text-secondary);
}

.btn-warning-action {
    background: #f59e0b;
    color: #000000;
    border: none;
    padding: 8px 16px;
    border-radius: 6px;
    font-size: 12px;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.2s ease;
}

.btn-warning-action:hover {
    background: #ffbb00;
    box-shadow: 0 0 10px rgba(245, 158, 11, 0.4);
    transform: translateY(-1px);
}

/* User Guide Panel */
.guide-panel {
    margin-top: 25px;
    background: rgba(18, 22, 33, 0.4);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 20px;
}

.guide-header {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 12px;
}

.guide-header h3 {
    font-size: 14px;
    font-weight: 700;
    color: var(--accent-cyan);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.guide-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 15px;
}

.guide-item {
    background: rgba(0, 0, 0, 0.15);
    border: 1px solid rgba(255, 255, 255, 0.02);
    border-radius: 8px;
    padding: 12px 15px;
    display: flex;
    gap: 10px;
}

.guide-num {
    font-family: 'Orbitron', sans-serif;
    font-weight: 700;
    font-size: 14px;
    color: var(--accent-cyan);
    background: rgba(0, 210, 255, 0.1);
    border-radius: 50%;
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.guide-desc h4 {
    font-size: 12px;
    font-weight: 600;
    color: #ffffff;
    margin-bottom: 3px;
}

.guide-desc p {
    font-size: 11px;
    color: var(--text-secondary);
    line-height: 1.4;
}

/* Responsive Table Scroller */
.holdings-table-container::-webkit-scrollbar {
    height: 6px;
}
.holdings-table-container::-webkit-scrollbar-track {
    background: rgba(0, 0, 0, 0.2);
    border-radius: 3px;
}
.holdings-table-container::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.1);
    border-radius: 3px;
}
.holdings-table-container::-webkit-scrollbar-thumb:hover {
    background: var(--border-hover);
}

@keyframes slideDown {
    from { transform: translateY(-15px); opacity: 0; }
    to { transform: translateY(0); opacity: 1; }
}

/* ==============================================================================
   Mobile Responsiveness (Added for v3.2+)
   ============================================================================== */
@media (max-width: 768px) {
    /* Stack flex elements and grids */
    .app-header {
        flex-direction: column;
        gap: 15px;
    }
    
    .screener-header {
        flex-direction: column;
        gap: 15px;
        align-items: flex-start;
    }
    
    .form-row, .weight-inputs-grid, .portfolio-summary-bar {
        grid-template-columns: 1fr;
    }
    
    .dashboard-grid {
        grid-template-columns: 1fr;
    }
    
    .config-bar {
        grid-template-columns: 1fr;
    }
    
    /* Enhance Table Scrolling */
    .table-container, .holdings-table-container {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        width: 100%;
        display: block;
    }
    
    /* Optimize Touch Areas for Mobile */
    button, .btn-primary, .btn-secondary, .market-tab, .btn-back-dashboard, .trend-btn, .btn-report-view, .btn-header {
        min-height: 44px;
        padding: 12px 16px;
    }
    
    /* Adjust Font Sizes */
    body {
        font-size: 14px;
    }
    
    .logo-area h1 {
        font-size: 18px;
    }
    
    .screener-title h1 {
        font-size: 1.5rem;
    }
    
    .market-tabs {
        flex-direction: column;
        width: 100%;
    }
    
    .market-tab {
        width: 100%;
        margin-bottom: 5px;
    }
    
    .hide-on-mobile {
        display: none !important;
    }
    
    .mobile-ellipsis {
        max-width: 100px;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
    }
}

/* Account Type Badges */
.badge {
    display: inline-block;
    padding: 3px 8px;
    border-radius: 4px;
    font-size: 11px;
    font-weight: 600;
    text-align: center;
    white-space: nowrap;
}

.badge-stock {
    background: rgba(0, 210, 255, 0.12);
    color: var(--accent-cyan);
    border: 1px solid rgba(0, 210, 255, 0.4);
}

.badge-pension {
    background: rgba(245, 158, 11, 0.12);
    color: #f59e0b;
    border: 1px solid rgba(245, 158, 11, 0.4);
}

/* Sparkline Styling */
.sparkline-container {
    display: inline-block;
    vertical-align: middle;
    background: rgba(0, 0, 0, 0.2);
    border-radius: 4px;
    padding: 2px;
    border: 1px solid rgba(255, 255, 255, 0.05);
    width: 124px;
    height: 38px;
    cursor: pointer;
    transition: opacity 0.2s, border-color 0.2s;
}

.sparkline-container:hover {
    opacity: 0.8;
    border-color: rgba(0, 210, 255, 0.4);
    box-shadow: 0 0 8px rgba(0, 210, 255, 0.2);
}

.sparkline-svg {
    display: block;
}

.sparkline-svg rect {
    transition: height 0.3s ease, y 0.3s ease;
}

.sparkline-svg path {
    transition: d 0.3s ease;
}

/* Opinions Table Styling */
.opinions-table th {
    color: var(--text-muted);
    font-size: 11px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.opinions-table td {
    padding: 10px 8px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.04);
}

.opinions-table tbody tr:hover {
    background: rgba(255, 255, 255, 0.02);
}

/* Report Smart Search & Filter UI */
.report-filter-chips .filter-chip {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.1);
    color: var(--text-secondary);
    padding: 7px 14px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
}

.report-filter-chips .filter-chip:hover {
    background: rgba(255, 255, 255, 0.1);
    color: #fff;
    border-color: rgba(255, 255, 255, 0.2);
}

.report-filter-chips .filter-chip.active {
    background: rgba(0, 242, 254, 0.18);
    color: var(--accent-cyan);
    border-color: var(--accent-cyan);
    box-shadow: 0 0 10px rgba(0, 242, 254, 0.25);
}

.report-search-bar-container input:focus {
    border-color: var(--accent-cyan) !important;
    box-shadow: 0 0 12px rgba(0, 242, 254, 0.25);
}

/* ==============================================================================
   Candlestick & Interactive Trend Chart Modal Styles
   ============================================================================== */
.chart-header-container {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-bottom: 12px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
    padding-bottom: 12px;
}

.chart-header-top {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 12px;
}

.chart-modal-title {
    font-family: 'Inter', 'Orbitron', sans-serif;
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--accent-cyan);
    letter-spacing: 0.5px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.chart-controls-wrap {
    display: flex;
    align-items: center;
    gap: 12px;
}

.chart-toggle-group {
    display: inline-flex;
    background: rgba(10, 15, 28, 0.85);
    border: 1px solid rgba(0, 210, 255, 0.25);
    border-radius: 8px;
    padding: 3px;
    gap: 2px;
}

.chart-toggle-btn {
    background: transparent;
    border: none;
    color: var(--text-secondary);
    padding: 6px 14px;
    border-radius: 6px;
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    display: flex;
    align-items: center;
    gap: 5px;
}

.chart-toggle-btn:hover {
    color: var(--text-primary);
    background: rgba(255, 255, 255, 0.06);
}

.chart-toggle-btn.active {
    background: linear-gradient(135deg, rgba(0, 210, 255, 0.25) 0%, rgba(0, 102, 255, 0.25) 100%);
    color: #00f2fe;
    border: 1px solid rgba(0, 242, 254, 0.5);
    box-shadow: 0 0 10px rgba(0, 242, 254, 0.3);
}

/* Smart OHLCV Header Strip */
.chart-ohlc-strip {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 10px 16px;
    font-family: 'Roboto Mono', monospace;
    font-size: 11.5px;
    background: rgba(255, 255, 255, 0.02);
    border-radius: 6px;
    padding: 6px 12px;
    border: 1px solid rgba(255, 255, 255, 0.04);
}

.ohlc-item {
    display: inline-flex;
    align-items: center;
    gap: 5px;
}

.ohlc-label {
    color: var(--text-muted);
    font-size: 10.5px;
    text-transform: uppercase;
    font-weight: 500;
}

.ohlc-val {
    font-weight: 600;
    color: var(--text-primary);
}

.ohlc-val.up {
    color: #ff3366 !important;
    text-shadow: 0 0 8px rgba(255, 51, 102, 0.4);
}

.ohlc-val.down {
    color: #00d2ff !important;
    text-shadow: 0 0 8px rgba(0, 210, 255, 0.4);
}

.ohlc-val.vol {
    color: #a78bfa;
}

.ohlc-val.ma5 {
    color: #00ff66;
}

.ohlc-val.ma20 {
    color: #ff00ff;
}

.ohlc-val.ma200 {
    color: #ff9900;
}

/* ==============================================================================
   v3.5: as-of labels, brokerage-style holdings list, phone layout
   ============================================================================== */
:root {
    /* Korean market convention: rise / gain = red, fall / loss = blue */
    --price-up: #ff4d5e;
    --price-down: #4a9eff;
}

.price-up { color: var(--price-up); }
.price-down { color: var(--price-down); }
.price-flat { color: var(--text-secondary); }

.full-width-grid {
    grid-template-columns: 1fr;
}

.card-header-row {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 6px 12px;
}

.asof-label {
    font-size: 12px;
    color: var(--text-secondary);
    white-space: nowrap;
    font-variant-numeric: tabular-nums;
    padding-top: 4px;
}

.asof-label:empty {
    display: none;
}

.btn-header {
    text-decoration: none;
}

.btn-header-quiet {
    color: var(--text-secondary);
}

.table-empty {
    padding: 20px;
    text-align: center;
    color: var(--text-muted);
}

/* Opinions table */
.opinions-table-container {
    overflow-x: auto;
}

.opinions-table {
    width: 100%;
    border-collapse: collapse;
    text-align: left;
    font-size: 12px;
    color: var(--text-secondary);
}

.opinions-table th {
    padding: 10px 8px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.opinions-table .op-name {
    font-weight: 600;
    color: var(--text-primary);
}

.opinions-table .op-index {
    color: var(--text-muted);
    font-family: monospace;
    font-size: 11px;
}

.opinions-table .op-value {
    text-align: right;
    white-space: nowrap;
    font-variant-numeric: tabular-nums;
    color: var(--text-primary);
}

.opinions-table th.op-value {
    color: var(--text-muted);
}

.opinions-table .op-value.op-missing {
    color: var(--text-muted);
}

.opinions-table .op-rating {
    text-align: center;
    white-space: nowrap;
}

.opinions-table .op-reason {
    min-width: 150px;
    line-height: 1.4;
}

.rating-strong-buy { color: #00ff88; font-weight: 700; }
.rating-buy { color: #a3ff00; font-weight: 600; }
.rating-hold { color: #ffcc00; }
.rating-sell { color: #ff8833; font-weight: 600; }
.rating-strong-sell { color: #ff3333; font-weight: 700; }

/* Holdings: summary */
.holdings-summary {
    margin-bottom: 16px;
    font-variant-numeric: tabular-nums;
}

.holdings-total {
    font-size: 28px;
    font-weight: 700;
    line-height: 1.2;
    color: var(--text-primary);
}

.holdings-total-pl {
    margin-top: 4px;
    font-size: 15px;
    font-weight: 600;
}

.holdings-total-invested {
    margin-top: 4px;
    font-size: 13px;
    color: var(--text-secondary);
}

/* Holdings: market tabs, sort, toggles */
.holdings-tabs {
    display: flex;
    gap: 20px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.holdings-tabs .holdings-tab {
    min-height: 44px;
    margin-bottom: -1px;
    padding: 10px 2px;
    background: none;
    border: none;
    border-bottom: 2px solid transparent;
    color: var(--text-secondary);
    font-family: inherit;
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
}

.holdings-tabs .holdings-tab.active {
    color: var(--text-primary);
    border-bottom-color: var(--text-primary);
}

.holdings-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 8px;
    padding: 12px 0 4px;
}

.holdings-sort {
    min-height: 44px;
    padding: 0 4px 0 0;
    background: transparent;
    border: none;
    color: var(--text-secondary);
    font-family: inherit;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
}

.holdings-sort option {
    background: #141925;
    color: var(--text-primary);
}

.holdings-toggles {
    display: flex;
    gap: 8px;
}

.seg-toggle {
    display: inline-flex;
    padding: 3px;
    background: rgba(255, 255, 255, 0.06);
    border-radius: 10px;
}

.seg-toggle button {
    min-width: 38px;
    min-height: 38px;
    padding: 0 12px;
    background: none;
    border: none;
    border-radius: 8px;
    color: var(--text-secondary);
    font-family: inherit;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
}

.seg-toggle button.active {
    background: rgba(255, 255, 255, 0.14);
    color: var(--text-primary);
}

/* Holdings: rows */
.holdings-list {
    list-style: none;
}

.holding-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 14px 4px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

.holding-clickable {
    cursor: pointer;
}

.holding-clickable:hover {
    background: rgba(255, 255, 255, 0.03);
}

.holding-main {
    min-width: 0;
}

.holding-name {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 2px 6px;
    font-size: 16px;
    font-weight: 600;
    color: var(--text-primary);
    overflow-wrap: anywhere;
}

.holding-name .badge {
    padding: 1px 6px;
    font-size: 10px;
}

.holding-sub {
    font-size: 13px;
    line-height: 1.5;
    color: var(--text-secondary);
}

.holding-side {
    flex-shrink: 0;
    text-align: right;
    font-variant-numeric: tabular-nums;
}

.holding-amount {
    font-size: 16px;
    font-weight: 700;
    color: var(--text-primary);
}

.holding-pl {
    margin-top: 2px;
    font-size: 13px;
}

.holding-change {
    display: inline-block;
    min-width: 84px;
    padding: 4px 10px;
    border-radius: 6px;
    font-size: 15px;
    font-weight: 700;
    text-align: right;
    background: rgba(255, 255, 255, 0.06);
}

.holding-change.price-up { background: rgba(255, 77, 94, 0.14); }
.holding-change.price-down { background: rgba(74, 158, 255, 0.14); }

.holding-price {
    margin-top: 4px;
    font-size: 14px;
    font-weight: 600;
    color: var(--text-secondary);
}

.holdings-message {
    padding: 24px 0;
    text-align: center;
    font-size: 14px;
    color: var(--text-secondary);
}

.holding-skeleton {
    display: block;
    width: 100%;
    height: 48px;
}

/* Wide screens: two columns of holdings instead of one very wide row */
@media (min-width: 1100px) {
    .holdings-list {
        display: grid;
        grid-template-columns: 1fr 1fr;
        column-gap: 48px;
    }

    .holdings-message {
        grid-column: 1 / -1;
    }
}

/* Rebalance cards */
.rebalance-empty {
    grid-column: 1 / -1;
    padding: 30px 0;
    text-align: center;
}

.rebalance-card-ticker {
    padding-right: 96px; /* keep clear of the action badge */
    overflow-wrap: anywhere;
}

.rebalance-card-qty {
    font-family: 'Inter', -apple-system, sans-serif;
    color: var(--accent-cyan);
}

.rebalance-card-scores {
    font-size: 12px;
    color: var(--text-secondary);
}

.rebalance-card-scores strong {
    color: #ffffff;
}

/* Ticker chart modal */
.detail-chart-wrapper {
    position: relative;
    width: 100%;
    height: min(52vh, 420px);
}

/* ------------------------------------------------------------------------------
   Phone layout
   ------------------------------------------------------------------------------ */
@media (max-width: 768px) {
    body {
        background-attachment: scroll;
    }

    .app-container {
        padding: 12px;
    }

    .glass-card {
        padding: 16px;
        border-radius: 14px;
        backdrop-filter: none;
    }

    .dashboard-grid {
        gap: 12px;
        margin-bottom: 12px;
    }

    /* Header: logo on one line, the three buttons sharing the next */
    .app-header {
        align-items: stretch;
        gap: 10px;
        padding: 12px 14px;
        margin-bottom: 12px;
        backdrop-filter: none;
    }

    .logo-area h1 {
        font-size: 16px;
        letter-spacing: 1px;
    }

    .system-status {
        gap: 8px;
    }

    .system-status .btn-header {
        flex: 1;
        justify-content: center;
        min-height: 44px;
        padding: 0 8px;
        font-size: 13px;
        white-space: nowrap;
    }

    .card-header {
        margin-bottom: 14px;
        padding-bottom: 12px;
    }

    .card-header h2 {
        font-size: 17px;
    }

    .card-subtitle {
        display: block;
    }

    /* Portfolio analytics */
    .macro-summary-bar {
        grid-template-columns: 1fr 1fr;
        gap: 10px;
    }

    .macro-card {
        padding: 12px;
    }

    .macro-label {
        font-size: 12px;
    }

    .macro-val {
        font-size: 16px;
    }

    #dynamic-rules-triggers {
        flex-direction: column;
        gap: 8px !important;
        font-size: 13px !important;
    }

    .chart-container-wrapper {
        height: 230px;
    }

    /* Opinions: one card per asset class instead of a 5-column table */
    .opinions-table thead {
        display: none;
    }

    .opinions-table,
    .opinions-table tbody {
        display: block;
    }

    .opinions-table tr {
        display: grid;
        grid-template-columns: 1fr auto;
        gap: 2px 10px;
        padding: 12px 0;
        border-bottom: 1px solid rgba(255, 255, 255, 0.06);
    }

    .opinions-table td {
        display: block;
        padding: 0;
        border: none;
    }

    .opinions-table .op-name { grid-area: 1 / 1; font-size: 15px; }
    .opinions-table .op-rating { grid-area: 1 / 2; font-size: 15px; text-align: right; }
    .opinions-table .op-index { grid-area: 2 / 1; font-size: 12px; }
    .opinions-table .op-value { grid-area: 2 / 2; font-size: 13px; }
    .opinions-table .op-reason { grid-area: 3 / 1 / 4 / 3; min-width: 0; margin-top: 4px; font-size: 13px; }
    .opinions-table .table-empty { grid-column: 1 / -1; padding: 20px 0; }

    /* Holdings */
    .holdings-total {
        font-size: 26px;
    }

    .holding-row {
        padding: 14px 0;
    }

    .holdings-tabs .holdings-tab {
        padding: 10px 2px;
    }

    .seg-toggle button {
        min-height: 38px;
        padding: 0 12px;
    }

    /* Rebalance */
    .rebalance-cards-grid {
        grid-template-columns: 1fr;
        gap: 12px;
    }

    .rebalance-card-name,
    .rebalance-card-weight,
    .rebalance-card-scores {
        font-size: 13px;
    }

    .rebalance-card-reason {
        font-size: 14px;
    }

    /* Reports: same content, sized for a phone */
    #report-search-input,
    .holdings-sort,
    .modal-body select {
        font-size: 16px !important; /* below 16px iOS zooms the page on focus */
    }

    .report-markdown-content {
        overflow-x: auto;
    }

    /* Modals */
    .modal-container,
    .modal-container.large {
        width: 96% !important;
        max-height: 92vh;
        border-radius: 16px;
    }

    .modal-header {
        padding: 14px 16px;
    }

    .modal-body {
        padding: 14px !important;
    }

    .modal-footer {
        padding: 12px 16px;
    }

    .detail-chart-wrapper {
        height: 46vh;
    }

    .chart-ohlc-strip {
        gap: 6px 12px;
        font-size: 12px;
    }

    .ohlc-label {
        font-size: 11px;
    }

    /* Guide */
    .guide-panel {
        margin-top: 12px;
        padding: 16px;
    }

    .guide-grid {
        grid-template-columns: 1fr;
    }

    .guide-desc h4 {
        font-size: 14px;
    }

    .guide-desc p {
        font-size: 13px;
    }
}

/* ==============================================================================
   Screener page (shares the dashboard's header, cards, tabs and list rows)
   ============================================================================== */
.screener-control,
.screener-results {
    margin-bottom: 20px;
}

.screener-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
}

.screener-actions .btn-primary {
    flex: 1 1 220px;
    width: auto;
    max-width: 360px;
    padding: 12px 20px;
    font-size: 14px;
}

.screener-actions .screener-stop {
    flex: 0 0 auto;
    width: auto;
    padding: 12px 20px;
    font-size: 14px;
    border-color: var(--accent-red);
    color: var(--accent-red);
}

.screener-progress {
    display: none;
    margin-top: 16px;
}

.screener-progress.active {
    display: block;
}

.screener-progress-info {
    display: flex;
    justify-content: space-between;
    gap: 10px;
    margin-bottom: 8px;
    font-size: 13px;
    color: var(--text-secondary);
    font-variant-numeric: tabular-nums;
}

.screener-progress-info #scan-progress-text {
    font-weight: 600;
    color: var(--accent-cyan);
}

.screener-progress-track {
    height: 10px;
    background: rgba(255, 255, 255, 0.06);
    border-radius: 5px;
    overflow: hidden;
}

.progress-bar-indicator {
    width: 0;
    height: 100%;
    background: linear-gradient(90deg, var(--accent-cyan), var(--accent-blue));
    border-radius: 5px;
    transition: width 0.4s ease;
}

.screener-terminal {
    max-height: 84px;
    margin-top: 14px;
    padding: 10px 12px;
    overflow-y: auto;
    background: rgba(0, 0, 0, 0.35);
    border: 1px solid rgba(255, 255, 255, 0.06);
    border-radius: 8px;
    font-family: 'Roboto Mono', monospace;
    font-size: 12px;
    line-height: 1.5;
    color: var(--accent-cyan);
}

.screener-search {
    flex: 1 1 180px;
    min-width: 0;
    max-width: 360px;
    min-height: 44px;
    padding: 0 14px;
    background: rgba(0, 0, 0, 0.35);
    border: 1px solid rgba(255, 255, 255, 0.15);
    border-radius: 8px;
    color: #ffffff;
    font-family: inherit;
    font-size: 16px; /* below 16px iOS zooms the page on focus */
    outline: none;
}

.screener-search:focus {
    border-color: var(--accent-cyan);
}

/* Result rows */
.screener-row {
    padding: 14px 4px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
    cursor: pointer;
}

.screener-row:hover {
    background: rgba(255, 255, 255, 0.03);
}

.screener-row-head {
    display: flex;
    align-items: flex-start;
    gap: 10px;
}

.screener-rank {
    flex: 0 0 28px;
    padding-top: 2px;
    text-align: center;
    font-size: 14px;
    font-weight: 700;
    color: var(--accent-cyan);
    font-variant-numeric: tabular-nums;
}

.screener-row .holding-main {
    flex: 1;
}

.screener-row .holding-sub strong {
    color: var(--text-primary);
}

.screener-total {
    display: inline-block;
    min-width: 46px;
    padding: 3px 8px;
    border-radius: 6px;
    background: linear-gradient(135deg, var(--accent-cyan), var(--accent-blue));
    color: #ffffff;
    font-size: 16px;
    font-weight: 800;
    text-align: center;
}

.screener-total.pending {
    background: rgba(255, 255, 255, 0.06);
    color: var(--text-muted);
}

.rating-badge {
    display: inline-block;
    padding: 1px 7px;
    border-radius: 4px;
    background: rgba(255, 255, 255, 0.06);
    font-size: 11px;
    white-space: nowrap;
}

/* Two lines until the row is tapped open */
.screener-rationale {
    display: -webkit-box;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 2;
    margin: 8px 0 0 38px;
    overflow: hidden;
    font-size: 13px;
    line-height: 1.5;
    color: var(--text-secondary);
}

.screener-rationale.pending { font-style: italic; color: var(--text-muted); }
.screener-rationale.excluded { color: var(--accent-red); }
.screener-rationale.warning { color: #f59e0b; }

.screener-row.expanded .screener-rationale {
    display: block;
}

.screener-detail {
    display: none;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px 14px;
    margin: 10px 0 0 38px;
    font-size: 13px;
    color: var(--text-secondary);
    font-variant-numeric: tabular-nums;
}

.screener-row.expanded .screener-detail {
    display: flex;
}

/* Chart modal (screener page) */
.chart-modal-container {
    width: 95%;
    max-width: 950px;
}

.chart-modal-header {
    flex-direction: column;
    align-items: stretch;
    gap: 10px;
}

.chart-modal-header h3 {
    color: var(--accent-cyan);
    font-family: 'Inter', 'Orbitron', sans-serif;
}

@media (max-width: 768px) {
    .screener-control,
    .screener-results {
        margin-bottom: 12px;
    }

    .screener-actions .btn-primary {
        max-width: none;
    }

    .screener-search {
        max-width: none;
    }

    .screener-row {
        padding: 14px 0;
    }

    .screener-rationale,
    .screener-detail {
        margin-left: 0;
    }

    .modal-body input {
        font-size: 16px !important;
    }

    .chart-modal-header h3 {
        font-size: 15px;
    }
}

/* Screener: daily AI recommendation report cards */
.screener-reports {
    margin-bottom: 20px;
}

.screener-report-filters {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 14px;
}

.screener-report-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(min(320px, 100%), 1fr));
    gap: 14px;
}

.screener-report-card {
    display: flex;
    flex-direction: column;
    gap: 8px;
    padding: 16px;
    background: rgba(0, 0, 0, 0.25);
    border: 1px solid rgba(255, 255, 255, 0.06);
    border-radius: 12px;
    cursor: pointer;
    transition: border-color 0.2s ease;
}

.screener-report-card:hover {
    border-color: rgba(0, 210, 255, 0.4);
}

.screener-report-meta {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
}

.screener-report-date {
    font-size: 13px;
    font-weight: 700;
    color: var(--accent-cyan);
    font-variant-numeric: tabular-nums;
}

.screener-report-card h3 {
    font-size: 15px;
    font-weight: 700;
    line-height: 1.4;
    color: var(--text-primary);
}

.screener-report-summary {
    display: -webkit-box;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 3;
    overflow: hidden;
    font-size: 13px;
    line-height: 1.5;
    color: var(--text-secondary);
}

.screener-report-picks {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.pick-tag {
    padding: 2px 8px;
    border: 1px solid rgba(0, 255, 102, 0.25);
    border-radius: 4px;
    background: rgba(0, 255, 102, 0.1);
    color: var(--accent-green);
    font-size: 12px;
    font-weight: 600;
    font-variant-numeric: tabular-nums;
}

.screener-report-open {
    margin-top: auto;
    padding-top: 8px;
    border-top: 1px solid rgba(255, 255, 255, 0.05);
    font-size: 13px;
    font-weight: 600;
    color: var(--accent-cyan);
}

.screener-report-empty {
    grid-column: 1 / -1;
    padding: 24px 0;
    text-align: center;
}

.screener-report-skeleton {
    height: 150px;
}

@media (max-width: 768px) {
    .screener-reports {
        margin-bottom: 12px;
    }
}

/* Wide report tables scroll sideways on phones instead of crushing every column */
@media (max-width: 768px) {
    .report-markdown-content table {
        min-width: 560px;
    }
}
