:root {
    --bg-dark: #0d1117;
    --bg-card: #161b22;
    --bg-hover: #1c2333;
    --border: #30363d;
    --text-primary: #e6edf3;
    --text-secondary: #8b949e;
    --green: #3fb950;
    --green-bg: rgba(63, 185, 80, 0.1);
    --red: #f85149;
    --red-bg: rgba(248, 81, 73, 0.1);
    --yellow: #d29922;
    --yellow-bg: rgba(210, 153, 34, 0.1);
    --blue: #58a6ff;
    --purple: #bc8cff;
}

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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Helvetica, Arial, sans-serif;
    background: var(--bg-dark);
    color: var(--text-primary);
    line-height: 1.5;
}

.container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 20px;
}

header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px 0;
    border-bottom: 1px solid var(--border);
    margin-bottom: 30px;
}

header h1 { font-size: 24px; font-weight: 600; }
header h1 span { color: var(--green); }
.header-info { color: var(--text-secondary); font-size: 14px; }

/* Navigation */
.nav-tabs {
    display: flex;
    gap: 4px;
    margin-bottom: 24px;
    border-bottom: 1px solid var(--border);
    overflow-x: auto;
}

.nav-tabs a {
    color: var(--text-secondary);
    text-decoration: none;
    padding: 8px 16px;
    border-bottom: 2px solid transparent;
    font-size: 14px;
    transition: all 0.2s;
    white-space: nowrap;
}

.nav-tabs a:hover { color: var(--text-primary); border-bottom-color: var(--border); }
.nav-tabs a.active { color: var(--text-primary); border-bottom-color: var(--green); font-weight: 500; }

/* Cards */
.card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 20px;
    margin-bottom: 20px;
}

.card h2 { font-size: 16px; font-weight: 600; margin-bottom: 16px; color: var(--text-primary); }
.card h3 { font-size: 14px; color: var(--text-secondary); margin-bottom: 12px; }

/* Stats row */
.stats-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 16px;
    margin-bottom: 24px;
}

.stat-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 16px 20px;
}

.stat-card .label {
    color: var(--text-secondary);
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.stat-card .value { font-size: 28px; font-weight: 600; margin-top: 4px; }

/* Tables */
table { width: 100%; border-collapse: collapse; font-size: 14px; }

th {
    text-align: left;
    padding: 10px 12px;
    color: var(--text-secondary);
    font-weight: 500;
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    border-bottom: 1px solid var(--border);
}

td { padding: 10px 12px; border-bottom: 1px solid var(--border); }
tr:hover td { background: var(--bg-hover); }

.symbol { font-weight: 600; color: var(--blue); text-decoration: none; }
.symbol:hover { text-decoration: underline; }
.stock-name { color: var(--text-secondary); font-size: 12px; }

/* Signal badges */
.signal {
    display: inline-block;
    padding: 2px 10px;
    border-radius: 12px;
    font-size: 12px;
    font-weight: 500;
}

.signal-bullish { background: var(--green-bg); color: var(--green); }
.signal-bearish { background: var(--red-bg); color: var(--red); }

/* Trend indicators */
.trend-up { color: var(--green); }
.trend-down { color: var(--red); }
.trend-strong-bull { color: var(--green); font-weight: 600; }
.trend-bull { color: var(--green); }
.trend-neutral { color: var(--yellow); }
.trend-bear { color: var(--red); }
.trend-strong-bear { color: var(--red); font-weight: 600; }

/* Progress bar */
.progress-bar { width: 100%; height: 8px; background: var(--bg-dark); border-radius: 4px; overflow: hidden; }
.progress-fill { height: 100%; border-radius: 4px; transition: width 0.3s; }
.progress-green { background: var(--green); }
.progress-red { background: var(--red); }
.progress-yellow { background: var(--yellow); }

/* ========== Dashboard ========== */

/* Watchlist grid */
.watchlist-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 12px;
}

.watchlist-item {
    display: block;
    background: var(--bg-dark);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 14px 16px;
    text-decoration: none;
    color: var(--text-primary);
    transition: all 0.2s;
}

.watchlist-item:hover { border-color: var(--blue); background: var(--bg-hover); }

.watchlist-symbol { font-size: 16px; font-weight: 700; color: var(--blue); }
.watchlist-name { font-size: 11px; color: var(--text-secondary); margin-bottom: 8px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.watchlist-price { font-size: 18px; font-weight: 600; }
.watchlist-change { font-size: 13px; font-weight: 500; margin-top: 2px; }

.crypto-grid { grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); }

/* News */
.dashboard-news-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
    margin-bottom: 0;
}

.news-list { display: flex; flex-direction: column; gap: 2px; }

.news-item {
    display: block;
    padding: 10px 12px;
    border-radius: 6px;
    text-decoration: none;
    color: var(--text-primary);
    transition: background 0.2s;
}

.news-item:hover { background: var(--bg-hover); }

.news-title {
    font-size: 13px;
    font-weight: 500;
    line-height: 1.4;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.news-meta { display: flex; gap: 12px; margin-top: 4px; font-size: 11px; color: var(--text-secondary); }
.news-source { font-weight: 500; }

/* Sector sparklines */
.sector-spark-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 12px;
}

.sector-spark-card {
    background: var(--bg-dark);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 12px 14px;
}

.sector-spark-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 2px; }
.sector-spark-name { font-size: 13px; font-weight: 600; }
.sector-spark-etf { font-size: 11px; color: var(--text-secondary); }
.sector-spark-change { font-size: 14px; font-weight: 600; margin-bottom: 6px; }
.sector-spark-chart { width: 100%; height: 50px; }

/* ========== Detail Pages ========== */

.detail-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 20px;
    flex-wrap: wrap;
    gap: 16px;
}

.detail-symbol { font-size: 28px; font-weight: 700; margin-bottom: 2px; }
.detail-name { font-size: 16px; color: var(--text-secondary); }
.detail-sector { font-size: 13px; color: var(--text-secondary); margin-top: 4px; }
.detail-price-block { text-align: right; }
.detail-price { font-size: 32px; font-weight: 700; }
.detail-change { font-size: 16px; font-weight: 500; }

/* ========== Existing Sections ========== */

/* Sector grid (sectors page) */
.sector-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
    gap: 16px;
}

.sector-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 16px 20px;
}

.sector-card .sector-name { font-size: 15px; font-weight: 600; margin-bottom: 4px; }
.sector-card .sector-trend { font-size: 13px; margin-bottom: 12px; }
.sector-card .ma-row { display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px; font-size: 13px; }
.sector-card .ma-label { color: var(--text-secondary); }
.sector-card .ma-value { font-weight: 500; }

/* Links */
a.chart-link { color: var(--blue); text-decoration: none; font-size: 13px; }
a.chart-link:hover { text-decoration: underline; }

/* Empty state */
.empty-state { text-align: center; padding: 60px 20px; }
.empty-state h2 { font-size: 20px; margin-bottom: 12px; }
.empty-state p { color: var(--text-secondary); margin-bottom: 24px; max-width: 500px; margin-left: auto; margin-right: auto; }

/* Buttons */
.btn {
    display: inline-block;
    padding: 8px 20px;
    border-radius: 6px;
    font-size: 14px;
    font-weight: 500;
    text-decoration: none;
    cursor: pointer;
    border: 1px solid var(--border);
    background: var(--bg-card);
    color: var(--text-primary);
    transition: all 0.2s;
}

.btn:hover { background: var(--bg-hover); }
.btn-primary { background: var(--green); color: #000; border-color: var(--green); }
.btn-primary:hover { opacity: 0.9; }

code { background: var(--bg-dark); padding: 2px 6px; border-radius: 4px; font-size: 13px; color: var(--purple); }

.ma-period {
    display: inline-block;
    padding: 1px 6px;
    border-radius: 4px;
    font-size: 11px;
    font-weight: 600;
    background: var(--bg-dark);
    color: var(--text-secondary);
}

/* Flash messages */
.flash { padding: 12px 16px; border-radius: 6px; margin-bottom: 20px; font-size: 14px; }
.flash-success { background: var(--green-bg); color: var(--green); border: 1px solid rgba(63, 185, 80, 0.3); }
.flash-error { background: var(--red-bg); color: var(--red); border: 1px solid rgba(248, 81, 73, 0.3); }
.flash-info { background: rgba(88, 166, 255, 0.1); color: var(--blue); border: 1px solid rgba(88, 166, 255, 0.3); }

/* Responsive - Tablet */
@media (max-width: 768px) {
    .container { padding: 12px; }
    header { flex-direction: column; gap: 8px; }
    .stats-row { grid-template-columns: repeat(2, 1fr); }
    .sector-grid { grid-template-columns: 1fr; }
    .dashboard-news-row { grid-template-columns: 1fr; }
    .watchlist-grid { grid-template-columns: repeat(2, 1fr); }
    .sector-spark-grid { grid-template-columns: repeat(2, 1fr); }
    .detail-header { flex-direction: column; }
    .detail-price-block { text-align: left; }
    table { font-size: 12px; }
    th, td { padding: 8px 6px; }
}

/* Responsive - Phone */
@media (max-width: 480px) {
    .container { padding: 8px; }

    header { padding: 12px 0; margin-bottom: 16px; }
    header h1 { font-size: 20px; }
    .header-info { font-size: 12px; }

    /* Scrollable nav tabs */
    .nav-tabs { gap: 0; margin-bottom: 16px; -webkit-overflow-scrolling: touch; }
    .nav-tabs a { padding: 8px 12px; font-size: 13px; }

    /* Single column watchlist */
    .watchlist-grid { grid-template-columns: 1fr 1fr; gap: 8px; }
    .watchlist-item { padding: 10px 12px; }
    .watchlist-symbol { font-size: 14px; }
    .watchlist-price { font-size: 16px; }
    .watchlist-change { font-size: 12px; }

    .crypto-grid { grid-template-columns: 1fr 1fr; }

    /* Stats cards */
    .stats-row { grid-template-columns: 1fr 1fr; gap: 8px; }
    .stat-card { padding: 12px; }
    .stat-card .value { font-size: 20px; }

    /* Sector sparklines */
    .sector-spark-grid { grid-template-columns: 1fr; }

    /* Detail pages */
    .detail-symbol { font-size: 22px; }
    .detail-name { font-size: 14px; }
    .detail-price { font-size: 24px; }
    .detail-change { font-size: 14px; }
    #detail-chart { height: 280px !important; }

    /* Tables - horizontal scroll */
    .card { padding: 12px; overflow-x: auto; }
    table { min-width: 500px; }
    th, td { padding: 8px 6px; white-space: nowrap; }

    /* News */
    .news-title { font-size: 12px; -webkit-line-clamp: 3; }
    .news-meta { font-size: 10px; }

    /* Buttons */
    .btn { padding: 10px 16px; font-size: 14px; width: 100%; text-align: center; }

    /* Sector page */
    .sector-grid { grid-template-columns: 1fr; }
    .sector-card { padding: 12px 14px; }
}
