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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
    background: #0d1117;
    color: #c9d1d9;
    min-height: 100vh;
}

header {
    background: #161b22;
    border-bottom: 1px solid #30363d;
    padding: 12px 24px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

header h1 {
    font-size: 18px;
    font-weight: 600;
    color: #58a6ff;
}

.header-controls {
    display: flex;
    align-items: center;
    gap: 12px;
}

.header-controls select {
    padding: 6px 10px;
    background: #21262d;
    border: 1px solid #30363d;
    border-radius: 6px;
    color: #c9d1d9;
    font-size: 12px;
}

.btn {
    padding: 8px 14px;
    border: none;
    border-radius: 6px;
    font-size: 12px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-primary {
    background: #238636;
    color: #fff;
}

.btn-primary:hover { background: #2ea043; }
.btn-primary:disabled { background: #21262d; color: #484f58; cursor: not-allowed; }

.btn-secondary {
    background: #21262d;
    color: #c9d1d9;
    border: 1px solid #30363d;
}

.btn-secondary:hover { background: #30363d; }

/* Main Layout */
main {
    display: grid;
    grid-template-columns: 260px 1fr;
    height: calc(100vh - 52px);
}

/* Left Panel */
.sidebar {
    background: #161b22;
    border-right: 1px solid #30363d;
    display: flex;
    flex-direction: column;
}

.panel-section {
    padding: 16px;
    border-bottom: 1px solid #30363d;
}

.panel-title {
    font-size: 11px;
    font-weight: 600;
    color: #8b949e;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 12px;
}

/* Watchlist */
.watchlist-input {
    display: flex;
    gap: 6px;
    margin-bottom: 12px;
}

.watchlist-input input {
    flex: 1;
    padding: 6px 10px;
    background: #0d1117;
    border: 1px solid #30363d;
    border-radius: 4px;
    color: #c9d1d9;
    font-size: 12px;
}

.watchlist-input input:focus {
    outline: none;
    border-color: #58a6ff;
}

/* Symbol Card */
.symbol-card {
    background: #21262d;
    border-radius: 6px;
    padding: 10px 12px;
    margin-bottom: 8px;
    border: 1px solid #30363d;
    cursor: pointer;
    transition: all 0.15s;
    position: relative;
}

.symbol-card:hover { border-color: #58a6ff; }
.symbol-card.selected { border-color: #58a6ff; background: #388bfd1a; }
.symbol-card.loading { opacity: 0.6; }

.symbol-card .delete-btn {
    position: absolute;
    top: 4px;
    right: 4px;
    width: 18px;
    height: 18px;
    border: none;
    background: #30363d;
    color: #8b949e;
    border-radius: 50%;
    cursor: pointer;
    font-size: 12px;
    line-height: 1;
    opacity: 0;
    transition: all 0.15s;
    display: flex;
    align-items: center;
    justify-content: center;
}

.symbol-card:hover .delete-btn {
    opacity: 1;
}

.symbol-card .delete-btn:hover {
    background: #f85149;
    color: #fff;
}

.symbol-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 8px;
}

.symbol-name {
    font-size: 13px;
    font-weight: 600;
}

.entry-score {
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 12px;
    font-weight: 600;
}

.entry-score.excellent { background: #238636; color: #fff; }
.entry-score.good { background: #2ea043; color: #fff; }
.entry-score.marginal { background: #d29922; color: #000; }
.entry-score.poor { background: #f85149; color: #fff; }
.entry-score.avoid { background: #6e7681; color: #fff; }

/* Trend Matrix */
.trend-matrix {
    display: grid;
    grid-template-columns: 36px repeat(3, 1fr);
    gap: 3px;
    font-size: 10px;
}

.trend-matrix .header {
    text-align: center;
    color: #8b949e;
    font-weight: 500;
    padding: 2px;
}

.trend-matrix .tf-row {
    display: contents;
}

.trend-matrix .tf-label {
    color: #8b949e;
    font-weight: 500;
    display: flex;
    align-items: center;
}

.trend-cell {
    padding: 4px 2px;
    text-align: center;
    border-radius: 3px;
    background: #0d1117;
}

.trend-cell.up { color: #3fb950; }
.trend-cell.up-strong { color: #56d364; font-weight: 600; }
.trend-cell.down { color: #f85149; }
.trend-cell.down-strong { color: #ff7b72; font-weight: 600; }
.trend-cell.neutral { color: #8b949e; }

/* Chart Area */
.chart-area {
    display: flex;
    flex-direction: column;
    background: #0d1117;
}

.chart-toolbar {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 16px;
    background: #161b22;
    border-bottom: 1px solid #30363d;
}

.tf-group {
    display: flex;
    gap: 3px;
}

.tf-btn {
    padding: 5px 10px;
    background: #21262d;
    border: 1px solid #30363d;
    border-radius: 4px;
    color: #8b949e;
    font-size: 11px;
    cursor: pointer;
    transition: all 0.15s;
}

.tf-btn:hover { background: #30363d; }
.tf-btn.active { background: #388bfd26; border-color: #58a6ff; color: #58a6ff; }

/* TF Score Badge */
.tf-btn {
    display: flex;
    align-items: center;
    gap: 4px;
}

.tf-score-badge {
    min-width: 14px;
    height: 14px;
    padding: 0 3px;
    border-radius: 7px;
    font-size: 8px;
    font-weight: 600;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #6e7681;
    color: #fff;
}

.tf-score-badge.excellent { background: #238636; }
.tf-score-badge.good { background: #2ea043; }
.tf-score-badge.marginal { background: #d29922; color: #000; }
.tf-score-badge.poor { background: #f85149; }
.tf-score-badge.hidden { display: none; }

/* Highlight TF button with good score */
.tf-btn.has-good-score {
    border-color: #3fb950;
    box-shadow: 0 0 6px rgba(63, 185, 80, 0.4);
}

#chart-container {
    flex: 1;
    position: relative;
}

#chart { width: 100%; height: 100%; }

/* Trend Info Overlay */
.trend-info {
    position: absolute;
    top: 10px;
    left: 10px;
    background: rgba(13, 17, 23, 0.95);
    border: 1px solid #30363d;
    border-radius: 6px;
    padding: 10px 12px;
    font-size: 11px;
    z-index: 10;
    box-sizing: border-box;
}

.trend-info-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 2px 0;
    gap: 8px;
}

.trend-info-row .label { color: #8b949e; }
.trend-info-row .value { font-weight: 500; }

.trend-info-row .value.up { color: #3fb950; }
.trend-info-row .value.up-strong { color: #56d364; font-weight: 600; }
.trend-info-row .value.down { color: #f85149; }
.trend-info-row .value.down-strong { color: #ff7b72; font-weight: 600; }
.trend-info-row .value.neutral { color: #8b949e; }

/* Entry Score Color Coding (matches sidebar legend) */
.trend-info-row .value.excellent { color: #3fb950; font-weight: 600; }
.trend-info-row .value.good { color: #58a6ff; font-weight: 600; }
.trend-info-row .value.marginal { color: #d29922; font-weight: 600; }
.trend-info-row .value.poor { color: #f85149; font-weight: 600; }
.trend-info-row .value.avoid { color: #6e7681; font-weight: 600; }

.trend-info-divider {
    border-top: 1px solid #30363d;
    margin: 4px 0;
}

/* Trend Info Header - Symbol/TF row */
.trend-info-header {
    display: flex;
    align-items: center;
    gap: 4px;
    font-size: 11px;
}

.trend-info-header .label {
    color: #8b949e;
}

.trend-info-header .value {
    font-weight: 600;
    color: #c9d1d9;
}

/* Trend Info Grid - 8 timeframes in compact grid */
.trend-info-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 3px 6px;
    width: 100%;
}

.trend-grid-item {
    display: flex;
    align-items: center;
    gap: 4px;
    font-size: 10px;
    min-width: 0;
    white-space: nowrap;
}

.trend-grid-item .label {
    color: #8b949e;
    min-width: 22px;
    font-weight: 500;
}

.trend-grid-item .value {
    font-weight: 600;
    overflow: hidden;
    text-overflow: ellipsis;
}

.trend-grid-item .value.up { color: #3fb950; }
.trend-grid-item .value.up-strong { color: #56d364; }
.trend-grid-item .value.down { color: #f85149; }
.trend-grid-item .value.down-strong { color: #ff7b72; }
.trend-grid-item .value.neutral { color: #8b949e; }

.entry-recommendation {
    text-align: center;
    padding: 4px;
    border-radius: 4px;
    font-weight: 600;
    font-size: 11px;
    margin-top: 4px;
}

/* Inherit color from score quality */
.entry-recommendation.excellent { background: #23863626; color: #3fb950; }
.entry-recommendation.good { background: #58a6ff26; color: #58a6ff; }
.entry-recommendation.marginal { background: #d2992226; color: #d29922; }
.entry-recommendation.poor { background: #f8514926; color: #f85149; }
.entry-recommendation.avoid { background: #30363d; color: #6e7681; }

/* Loading */
.loading-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(13, 17, 23, 0.8);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 20;
}

.loading-overlay.hidden { display: none; }

.spinner {
    width: 32px;
    height: 32px;
    border: 3px solid #30363d;
    border-top-color: #58a6ff;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

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

/* Settings */
.settings-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
}

.setting-item {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.setting-item label {
    font-size: 10px;
    color: #8b949e;
}

.setting-item input,
.setting-item select {
    padding: 5px 8px;
    background: #0d1117;
    border: 1px solid #30363d;
    border-radius: 4px;
    color: #c9d1d9;
    font-size: 11px;
}

.setting-item.full { grid-column: span 2; }

/* Status */
.status-bar {
    padding: 8px 16px;
    background: #161b22;
    border-top: 1px solid #30363d;
    font-size: 11px;
    color: #8b949e;
    display: flex;
    justify-content: space-between;
}

/* Scrollable */
.scrollable {
    flex: 1;
    overflow-y: auto;
}

/* Score Legend */
.score-legend {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 4px;
    margin-top: 8px;
    font-size: 9px;
    text-align: center;
}

.score-legend-item {
    padding: 4px 2px;
    border-radius: 3px;
}

.score-legend-item.excellent { background: #238636; color: #fff; }
.score-legend-item.good { background: #2ea043; color: #fff; }
.score-legend-item.marginal { background: #d29922; color: #000; }
.score-legend-item.poor { background: #f85149; color: #fff; }
.score-legend-item.avoid { background: #6e7681; color: #fff; }

/* Collapsible Section */
.panel-section.collapsible {
    padding: 0;
}

.panel-section.collapsible .panel-title {
    padding: 16px;
    margin-bottom: 0;
    cursor: pointer;
    display: flex;
    justify-content: space-between;
    align-items: center;
    user-select: none;
}

.panel-section.collapsible .panel-title:hover {
    background: #21262d;
}

.panel-section.collapsible .panel-title::after {
    content: '▼';
    font-size: 10px;
    transition: transform 0.2s;
}

.panel-section.collapsible.collapsed .panel-title::after {
    transform: rotate(-90deg);
}

.panel-section.collapsible .section-content {
    padding: 0 16px 16px 16px;
    overflow: hidden;
    transition: max-height 0.3s ease-out;
}

.panel-section.collapsible.collapsed .section-content {
    display: none;
}

/* Sidebar Footer */
.sidebar-footer {
    padding: 12px 16px;
    border-top: 1px solid #30363d;
    font-size: 9px;
    color: #6e7681;
    text-align: center;
    margin-top: auto;
}

.sidebar-footer a {
    color: #58a6ff;
    text-decoration: none;
}

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

/* Settings Section */
.settings-divider {
    border-top: 1px solid #30363d;
    margin: 12px 0;
}

.settings-row {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-bottom: 8px;
}

.settings-row label {
    font-size: 10px;
    color: #8b949e;
    width: 70px;
    flex-shrink: 0;
}

.settings-row input[type="number"] {
    width: 50px;
    padding: 4px 6px;
    background: #0d1117;
    border: 1px solid #30363d;
    border-radius: 4px;
    color: #c9d1d9;
    font-size: 11px;
    text-align: center;
}

.settings-row select {
    flex: 1;
    padding: 4px 6px;
    background: #0d1117;
    border: 1px solid #30363d;
    border-radius: 4px;
    color: #c9d1d9;
    font-size: 10px;
    cursor: pointer;
}

.settings-row input[type="color"] {
    width: 28px;
    height: 22px;
    padding: 0;
    border: 1px solid #30363d;
    border-radius: 4px;
    cursor: pointer;
    background: transparent;
    flex-shrink: 0;
}

.settings-row input[type="color"]::-webkit-color-swatch-wrapper {
    padding: 2px;
}

.settings-row input[type="color"]::-webkit-color-swatch {
    border: none;
    border-radius: 2px;
}

.settings-row .color-spacer,
.settings-row .value-spacer {
    width: 50px;
}

.btn-reset-field {
    width: 20px;
    height: 20px;
    padding: 0;
    border: 1px solid #30363d;
    border-radius: 4px;
    background: #21262d;
    color: #6e7681;
    cursor: pointer;
    font-size: 12px;
    line-height: 1;
    flex-shrink: 0;
    transition: all 0.15s;
}

.btn-reset-field:hover {
    background: #30363d;
    color: #c9d1d9;
    border-color: #58a6ff;
}
