* { box-sizing: border-box; margin: 0; padding: 0; }
html, body {
    overflow-x: hidden;
    max-width: 100vw;
}
body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: #1a1a1a;
    color: #e0e0e0;
    min-height: 100vh;
}
.header {
    background: #2d2d2d;
    padding: 15px 20px;
    border-bottom: 1px solid #444;
}
.header h1 {
    color: #4fc3f7;
    font-size: 24px;
    margin-bottom: 15px;
}
.search-form {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    align-items: center;
}
.search-form input {
    padding: 10px 15px;
    font-size: 16px;
    background: #3a3a3a;
    border: 1px solid #555;
    border-radius: 4px;
    color: #fff;
    width: 150px;
}
.search-form input::placeholder { color: #888; }
.search-form button {
    padding: 10px 20px;
    font-size: 16px;
    color: #fff;
    border: none;
    border-radius: 4px;
    cursor: pointer;
}
.search-form button:disabled { background: #555; cursor: not-allowed; }
.analyze-btn { background: #1976d2; }
.analyze-btn:hover:not(:disabled) { background: #1565c0; }
.compare-btn { background: #388e3c; }
.compare-btn:hover:not(:disabled) { background: #2e7d32; }
.stock-chips {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    margin-top: 10px;
    min-height: 0;
}
.stock-chip {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 4px 10px;
    border-radius: 16px;
    font-size: 13px;
    font-weight: bold;
    color: #fff;
}
.stock-chip .remove-chip {
    cursor: pointer;
    font-size: 15px;
    line-height: 1;
    opacity: 0.8;
    background: none;
    border: none;
    color: inherit;
    padding: 0 2px;
}
.stock-chip .remove-chip:hover { opacity: 1; }
.chart-toggle { margin-top: 10px; }
.toggle-label { display: inline-flex; align-items: center; gap: 6px; cursor: pointer; font-size: 13px; color: #aaa; }
.toggle-label input[type="checkbox"] { accent-color: #4fc3f7; width: 16px; height: 16px; cursor: pointer; }
.chart-box-combined { grid-column: 1 / -1; min-height: 400px; }
.stats-panel {
    background: #2d2d2d;
    padding: 12px 20px;
    border-bottom: 1px solid #444;
    font-size: 14px;
}
.stats-panel .stat {
    display: inline-block;
    margin-right: 20px;
    margin-bottom: 5px;
}
.stats-panel .label { color: #888; }
.stats-panel .value { color: #4fc3f7; font-weight: bold; }
.stats-panel .zoom-hint { color: #666; font-style: italic; margin-left: 20px; }
.stats-row {
    padding: 6px 0;
    border-bottom: 1px solid #333;
}
.stats-row:last-child { border-bottom: none; }
.stats-row .stock-label {
    font-weight: bold;
    margin-right: 15px;
    display: inline-block;
    min-width: 60px;
}
.charts-container { padding: 15px; }
#charts {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 15px;
}
.chart-box {
    background: #252525;
    border-radius: 8px;
    padding: 10px;
    min-height: 300px;
    touch-action: pan-y;
}
.loading {
    text-align: center;
    padding: 100px 20px;
    color: #888;
}
.loading-spinner::after {
    content: '';
    display: block;
    width: 40px;
    height: 40px;
    margin: 20px auto;
    border: 3px solid #333;
    border-top-color: #4fc3f7;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.error { text-align: center; padding: 50px 20px; color: #ff6b6b; }

/* Tablet */
@media (max-width: 900px) {
    #charts { grid-template-columns: 1fr; }
}

/* Mobile */
@media (max-width: 600px) {
    .header { padding: 12px 15px; }
    .header h1 { font-size: 20px; margin-bottom: 12px; }
    .search-form { gap: 8px; }
    .search-form input {
        width: 100%;
        padding: 12px;
        font-size: 16px; /* Prevents iOS zoom */
    }
    .search-form button {
        flex: 1;
        padding: 12px;
        font-size: 16px;
    }
    #companyName {
        width: 100%;
        margin-left: 0 !important;
        margin-top: 8px;
        font-size: 14px;
        text-align: center;
    }
    .stock-chips { margin-top: 8px; }
    .stats-panel {
        padding: 8px 12px;
        font-size: 11px;
    }
    .stats-panel.single-mode {
        display: grid;
        grid-template-columns: 1fr 1fr;
        gap: 4px 8px;
    }
    .stats-panel.single-mode .stat {
        margin-right: 0;
        margin-bottom: 0;
    }
    .stats-panel .zoom-hint {
        margin-left: 0;
        margin-top: 4px;
    }
    .stats-panel.single-mode .zoom-hint {
        grid-column: 1 / -1;
    }
    .charts-container { padding: 8px; overflow-x: hidden; }
    #charts { gap: 10px; }
    .chart-box {
        padding: 5px;
        min-height: 250px;
        max-width: 100%;
        overflow: hidden;
    }
    .chart-box-combined { min-height: 280px; }
    .chart-box > div {
        width: 100% !important;
        max-width: 100% !important;
    }
    .loading { padding: 60px 15px; }
}

/* Small mobile */
@media (max-width: 380px) {
    .header h1 { font-size: 18px; }
    .stats-panel { font-size: 11px; }
    .chart-box { min-height: 220px; }
}
