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

:root {
    --primary-color: #667eea;
    --secondary-color: #764ba2;
    --success-color: #10b981;
    --danger-color: #ef4444;
    --warning-color: #f59e0b;
    --dark-bg: #1f2937;
    --light-bg: #f9fafb;
    --border-color: #e5e7eb;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen', 'Ubuntu', 'Cantarell', sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    padding: 20px;
    color: #333;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    background: white;
    border-radius: 12px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    overflow: hidden;
}

header {
    background: linear-gradient(135deg, var(--primary-color) 0%, var(--secondary-color) 100%);
    color: white;
    padding: 40px 30px;
    text-align: center;
}

header h1 {
    font-size: 2.5em;
    margin-bottom: 10px;
    font-weight: 700;
}

header p {
    font-size: 1.1em;
    opacity: 0.9;
    font-weight: 300;
}

.info-bar {
    display: flex;
    justify-content: space-around;
    align-items: center;
    padding: 20px 30px;
    background: var(--light-bg);
    border-bottom: 1px solid var(--border-color);
    flex-wrap: wrap;
    gap: 20px;
}

.info-item {
    display: flex;
    align-items: center;
    gap: 10px;
}

.info-item .label {
    font-weight: 600;
    color: #666;
}

.info-item .value {
    font-weight: 700;
    font-size: 1.1em;
}

.badge {
    display: inline-block;
    padding: 6px 14px;
    border-radius: 20px;
    font-size: 0.9em;
    font-weight: 600;
}

.badge.bull {
    background: #d1fae5;
    color: #065f46;
}

.badge.bear {
    background: #fee2e2;
    color: #7f1d1d;
}

.badge.highlight {
    background: var(--primary-color);
    color: white;
}

.refresh-btn {
    padding: 10px 20px;
    background: var(--primary-color);
    color: white;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-weight: 600;
    transition: all 0.3s;
}

.refresh-btn:hover {
    background: var(--secondary-color);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.4);
}

main {
    padding: 40px;
}

.section {
    margin-bottom: 40px;
    border: 1px solid var(--border-color);
    border-radius: 10px;
    overflow: hidden;
}

.section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: var(--light-bg);
    padding: 20px;
    border-bottom: 2px solid var(--primary-color);
}

.section-header h2 {
    font-size: 1.5em;
    color: #333;
    margin: 0;
}

.badge-system {
    display: inline-block;
    padding: 5px 12px;
    background: var(--primary-color);
    color: white;
    border-radius: 20px;
    font-size: 0.85em;
    font-weight: 600;
}

.badge-system.consensus {
    background: var(--success-color);
}

.highlight-section {
    background: #f0f9ff;
    border-color: var(--success-color);
}

.highlight-section .section-header {
    border-bottom-color: var(--success-color);
    background: #ecfdf5;
}

.results-container {
    padding: 20px;
}

.results-table {
    width: 100%;
    border-collapse: collapse;
    margin: 0;
}

.results-table.aligned-table {
    table-layout: fixed;
}

.results-table.aligned-table th,
.results-table.aligned-table td {
    width: 25%;
}

.results-table thead {
    background: var(--light-bg);
}

.results-table th {
    padding: 15px;
    text-align: left;
    font-weight: 700;
    color: #333;
    border-bottom: 2px solid var(--border-color);
    font-size: 0.95em;
}

.results-table td {
    padding: 15px;
    border-bottom: 1px solid var(--border-color);
    vertical-align: middle;
}

.results-table th.signal-col {
    text-align: center;
}

.results-table tbody tr {
    transition: background-color 0.2s;
}

.results-table tbody tr:hover {
    background: #f9fafb;
}

.results-table tbody tr.signal-buy {
    background: #f0fdf4;
}

.results-table tbody tr.signal-hold {
    background: #fffbeb;
}

.results-table.compact th,
.results-table.compact td {
    padding: 10px;
    font-size: 0.88em;
}

.metrics-table th {
    white-space: nowrap;
    padding: 6px 4px;
    font-size: 0.74em;
    letter-spacing: -0.02em;
}

.metrics-table th:nth-child(3) {
    padding-left: 1.5em;
}

.metrics-table {
    width: 100%;
    table-layout: fixed;
}

.metrics-table td {
    padding: 8px 4px;
    font-size: 0.82em;
}

.stock-code {
    color: var(--primary-color);
    font-weight: 700;
    font-family: 'Courier New', monospace;
}

.score {
    font-weight: 700;
    color: #059669;
}

.confidence {
    font-weight: 600;
    color: #666;
}

.signal {
    text-align: center;
}

.badge-signal {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 64px;
    padding: 8px 14px;
    border-radius: 8px;
    font-size: 0.85em;
    font-weight: 700;
    line-height: 1;
}

.signal-buy .badge-signal {
    background: var(--success-color);
    color: #ffffff;
}

.signal-hold .badge-signal {
    background: #e5e7eb;
    color: #4b5563;
}

.model-group, .model-name {
    font-weight: 600;
    color: #555;
}

.consensus-container {
    padding: 20px;
}

.consensus-list {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    gap: 15px;
}

.consensus-item {
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 20px;
    background: linear-gradient(135deg, #10b981 0%, #059669 100%);
    border-radius: 8px;
}

.stock-badge {
    color: white;
    font-weight: 700;
    font-size: 1.2em;
    font-family: 'Courier New', monospace;
}

.history-layout {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 20px;
    padding: 20px;
}

.history-block {
    border: 1px solid var(--border-color);
    border-radius: 10px;
    background: #fff;
}

.history-block h3 {
    padding: 14px 16px;
    border-bottom: 1px solid var(--border-color);
    background: var(--light-bg);
    font-size: 1.05em;
}

.table-scroll {
    overflow-x: auto;
}

.return-positive {
    color: #b91c1c;
    font-weight: 700;
}

.return-negative {
    color: #047857;
    font-weight: 700;
}

.return-pending {
    color: #6b7280;
    font-weight: 600;
}

.mini-chart-grid {
    margin-top: 14px;
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 12px;
}

.mini-chart-card {
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 10px;
    background: #fff;
}

.mini-chart-title {
    font-size: 0.85em;
    font-weight: 700;
    color: #4b5563;
    margin-bottom: 6px;
}

.mini-chart-svg {
    width: 100%;
    height: 96px;
    display: block;
}

.mini-chart-svg .axis-line {
    stroke: #d1d5db;
    stroke-width: 1;
}

.mini-chart-svg .curve-line {
    fill: none;
    stroke-width: 2;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.mini-chart-svg .curve-line.positive {
    stroke: #b91c1c;
}

.mini-chart-svg .curve-line.negative {
    stroke: #047857;
}

.mini-chart-foot {
    margin-top: 4px;
    font-size: 0.82em;
    font-weight: 700;
}

.mini-chart-foot.positive {
    color: #b91c1c;
}

.mini-chart-foot.negative {
    color: #047857;
}

.combined-chart-card {
    margin-top: 12px;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 12px;
    background: #fff;
}

.combined-chart-controls {
    display: flex;
    flex-wrap: wrap;
    gap: 10px 14px;
    margin-bottom: 10px;
}

.combined-option {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 0.85em;
    color: #374151;
    font-weight: 600;
}

.combined-option.disabled {
    color: #9ca3af;
}

.combined-chart-content .empty-state {
    padding: 20px 12px;
    font-size: 0.9em;
}

.mini-chart-subtitle {
    font-size: 0.8em;
    color: #6b7280;
    margin-bottom: 6px;
}

.combined-foot-row {
    margin-top: 4px;
    display: flex;
    flex-wrap: wrap;
    gap: 10px 14px;
    align-items: center;
}

.empty-state, .error-state, .loading {
    text-align: center;
    padding: 40px 20px;
    font-size: 1.1em;
    color: #999;
}

.loading {
    font-size: 1em;
}

.error-state {
    color: var(--danger-color);
    font-weight: 600;
}

footer {
    background: var(--dark-bg);
    color: white;
    padding: 30px;
    text-align: center;
    border-top: 1px solid #333;
}

.footer-content p {
    margin: 10px 0;
    line-height: 1.6;
}

.footer-content strong {
    font-weight: 700;
}

.footer-meta {
    font-size: 0.9em;
    opacity: 0.8;
    margin-top: 15px;
}

.footer-meta a {
    color: var(--primary-color);
    text-decoration: none;
    font-weight: 600;
}

.footer-meta a:hover {
    text-decoration: underline;
}

@media (max-width: 900px) {
    .history-layout {
        grid-template-columns: 1fr;
    }

    .mini-chart-grid {
        grid-template-columns: 1fr;
    }

    .combined-foot-row {
        gap: 6px 10px;
    }
}

@media (max-width: 768px) {
    body {
        padding: 10px;
    }
    header h1 {
        font-size: 1.8em;
    }
    header p {
        font-size: 0.95em;
    }
    .info-bar {
        padding: 15px;
        flex-direction: column;
        gap: 10px;
    }
    .info-item {
        flex-direction: column;
        gap: 5px;
    }
    main {
        padding: 20px;
    }
    .section {
        margin-bottom: 25px;
    }
    .section-header {
        flex-direction: column;
        gap: 10px;
        align-items: flex-start;
    }
    .results-table th, .results-table td {
        padding: 10px;
        font-size: 0.9em;
    }
    .consensus-list {
        grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
    }
    .stock-badge {
        font-size: 1em;
    }
    footer {
        padding: 20px;
    }
}

@media (max-width: 480px) {
    header h1 {
        font-size: 1.4em;
    }
    header p {
        font-size: 0.85em;
    }
    .section-header h2 {
        font-size: 1.2em;
    }
    .results-table th, .results-table td {
        padding: 8px 5px;
        font-size: 0.8em;
    }
    .consensus-list {
        grid-template-columns: 1fr;
    }
}
