:root {
    --bg-primary: #f5f6f8;
    --bg-secondary: #ffffff;
    --bg-card: #ffffff;
    --bg-hover: #eef0f5;
    --border: #e0e4ea;
    --text-primary: #1a1d28;
    --text-secondary: #5c6070;
    --text-muted: #8b8f9b;
    --accent: #3b82f6;
    --accent-hover: #2563eb;
    --green: #16a34a;
    --red: #dc2626;
    --orange: #ea580c;
    --yellow: #ca8a04;
    --blue: #3b82f6;
    --purple: #9333ea;
    --radius: 12px;
    --radius-sm: 8px;
    --shadow: 0 1px 3px rgba(0,0,0,0.08), 0 1px 2px rgba(0,0,0,0.06);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    font-size: 14px;
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
}

#app {
    min-height: 100vh;
}

/* ── Layout ───────────────────────────── */
.app-layout {
    display: flex;
    min-height: 100vh;
}

.sidebar {
    width: 240px;
    background: var(--bg-secondary);
    border-right: 1px solid var(--border);
    padding: 20px 0;
    flex-shrink: 0;
    position: sticky;
    top: 0;
    height: 100vh;
    overflow-y: auto;
}

.sidebar-logo {
    padding: 0 24px 20px;
    font-size: 18px;
    font-weight: 700;
    color: var(--accent);
    border-bottom: 1px solid var(--border);
    margin-bottom: 12px;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 24px;
    color: var(--text-secondary);
    cursor: pointer;
    transition: all 0.15s;
    font-weight: 500;
    border-left: 3px solid transparent;
}

.nav-item:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
}

.nav-item.active {
    color: var(--accent);
    border-left-color: var(--accent);
    background: rgba(79, 140, 247, 0.08);
}

.nav-icon {
    width: 20px;
    text-align: center;
    font-size: 16px;
}

.main-content {
    flex: 1;
    padding: 24px 32px;
    overflow-y: auto;
    max-width: calc(100vw - 240px);
}

/* ── Header ─────────────────────────── */
.page-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 24px;
}

.page-title {
    font-size: 24px;
    font-weight: 700;
}

.page-subtitle {
    color: var(--text-muted);
    font-size: 13px;
    margin-top: 4px;
}

/* ── Cards ──────────────────────────── */
.card {
    background: var(--bg-card);
    border-radius: var(--radius);
    border: 1px solid var(--border);
    padding: 20px;
    box-shadow: var(--shadow);
}

.card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
}

.card-title {
    font-size: 16px;
    font-weight: 600;
}

/* ── Stats Grid ─────────────────────── */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 16px;
    margin-bottom: 24px;
}

.stat-card {
    background: var(--bg-card);
    border-radius: var(--radius);
    border: 1px solid var(--border);
    padding: 20px;
    display: flex;
    align-items: center;
    gap: 16px;
}

.stat-icon {
    width: 48px;
    height: 48px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 22px;
    flex-shrink: 0;
}

.stat-icon.green { background: rgba(0, 200, 83, 0.15); color: var(--green); }
.stat-icon.red { background: rgba(255, 23, 68, 0.15); color: var(--red); }
.stat-icon.blue { background: rgba(41, 121, 255, 0.15); color: var(--blue); }
.stat-icon.purple { background: rgba(170, 0, 255, 0.15); color: var(--purple); }

.stat-info {
    flex: 1;
}

.stat-value {
    font-size: 28px;
    font-weight: 700;
    line-height: 1.2;
}

.stat-label {
    color: var(--text-secondary);
    font-size: 13px;
    margin-top: 2px;
}

/* ── Skill Cards Grid ───────────────── */
.skills-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(340px, 1fr));
    gap: 16px;
    margin-bottom: 24px;
}

.skill-card {
    background: var(--bg-card);
    border-radius: var(--radius);
    border: 1px solid var(--border);
    padding: 20px;
    cursor: pointer;
    transition: all 0.2s;
    position: relative;
}

.skill-card:hover {
    border-color: var(--accent);
    transform: translateY(-2px);
    box-shadow: 0 8px 32px rgba(0,0,0,0.4);
}

.skill-card-header {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 12px;
}

.skill-icon {
    width: 40px;
    height: 40px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    flex-shrink: 0;
    background: rgba(79, 140, 247, 0.15);
    color: var(--accent);
}

.skill-name {
    font-size: 15px;
    font-weight: 600;
    flex: 1;
}

.skill-category {
    font-size: 11px;
    padding: 2px 8px;
    border-radius: 4px;
    font-weight: 500;
    text-transform: uppercase;
}

.cat-stock { background: rgba(0, 200, 83, 0.15); color: var(--green); }
.cat-futures { background: rgba(255, 145, 0, 0.15); color: var(--orange); }
.cat-options { background: rgba(170, 0, 255, 0.15); color: var(--purple); }

.skill-desc {
    color: var(--text-secondary);
    font-size: 13px;
    margin-bottom: 12px;
    line-height: 1.5;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.skill-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding-top: 12px;
    border-top: 1px solid var(--border);
}

.skill-status {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 12px;
    color: var(--text-muted);
}

.status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
}

.status-dot.success { background: var(--green); }
.status-dot.failed { background: var(--red); }
.status-dot.running { background: var(--yellow); animation: pulse 1s infinite; }
.status-dot.idle { background: var(--text-muted); }

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.4; }
}

.skill-signals {
    font-size: 12px;
    color: var(--accent);
    font-weight: 600;
}

.skill-actions {
    display: flex;
    gap: 8px;
    margin-top: 12px;
}

/* ── Buttons ────────────────────────── */
.btn {
    padding: 8px 16px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
    background: var(--bg-secondary);
    color: var(--text-primary);
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.15s;
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.btn:hover {
    background: var(--bg-hover);
    border-color: var(--accent);
}

.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.btn-primary {
    background: var(--accent);
    border-color: var(--accent);
    color: white;
}

.btn-primary:hover {
    background: var(--accent-hover);
    border-color: var(--accent-hover);
}

.btn-sm {
    padding: 5px 10px;
    font-size: 12px;
}

.btn-danger {
    border-color: var(--red);
    color: var(--red);
}

/* ── Table ──────────────────────────── */
.table-container {
    overflow-x: auto;
}

table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
}

th {
    text-align: left;
    padding: 12px 16px;
    color: var(--text-secondary);
    font-weight: 500;
    border-bottom: 1px solid var(--border);
    white-space: nowrap;
}

td {
    padding: 12px 16px;
    border-bottom: 1px solid var(--border);
}

tr:hover {
    background: var(--bg-hover);
}

/* ── Badges ─────────────────────────── */
.badge {
    display: inline-block;
    padding: 3px 10px;
    border-radius: 4px;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
}

.badge-long { background: rgba(0, 200, 83, 0.15); color: var(--green); }
.badge-short { background: rgba(255, 23, 68, 0.15); color: var(--red); }
.badge-watch { background: rgba(255, 214, 0, 0.15); color: var(--yellow); }
.badge-info { background: rgba(41, 121, 255, 0.15); color: var(--blue); }
.badge-success { background: rgba(0, 200, 83, 0.15); color: var(--green); }
.badge-failed { background: rgba(255, 23, 68, 0.15); color: var(--red); }
.badge-running { background: rgba(255, 214, 0, 0.15); color: var(--yellow); }

/* ── Filters ────────────────────────── */
.filters {
    display: flex;
    gap: 12px;
    margin-bottom: 20px;
    flex-wrap: wrap;
}

.filter-group {
    display: flex;
    align-items: center;
    gap: 8px;
}

.filter-label {
    font-size: 13px;
    color: var(--text-secondary);
}

select, input {
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    padding: 8px 12px;
    font-size: 13px;
    outline: none;
}

select:focus, input:focus {
    border-color: var(--accent);
}

/* ── Log Viewer ─────────────────────── */
.log-viewer {
    background: #f0f1f5;
    border-radius: var(--radius);
    border: 1px solid var(--border);
    padding: 16px;
    font-family: 'JetBrains Mono', 'Consolas', monospace;
    font-size: 12px;
    line-height: 1.6;
    max-height: 500px;
    overflow-y: auto;
    white-space: pre-wrap;
    word-break: break-all;
}

.log-line {
    color: #3a3d4a;
}

.log-line.error { color: var(--red); }
.log-line.success { color: var(--green); }
.log-line.warning { color: var(--orange); }

/* ── Markdown ───────────────────────── */
.markdown-body {
    color: var(--text-primary);
    line-height: 1.8;
    font-size: 14px;
}

.markdown-body h1 { font-size: 24px; font-weight: 700; margin: 20px 0 12px; }
.markdown-body h2 { font-size: 20px; font-weight: 600; margin: 18px 0 10px; border-bottom: 1px solid var(--border); padding-bottom: 6px; }
.markdown-body h3 { font-size: 16px; font-weight: 600; margin: 14px 0 8px; }
.markdown-body p { margin: 8px 0; }
.markdown-body ul, .markdown-body ol { margin: 8px 0; padding-left: 24px; }
.markdown-body li { margin: 4px 0; }
.markdown-body code { background: #eef0f5; padding: 2px 6px; border-radius: 4px; font-family: monospace; font-size: 13px; color: #d63384; }
.markdown-body pre { background: #f0f1f5; padding: 12px; border-radius: var(--radius-sm); overflow-x: auto; margin: 8px 0; }
.markdown-body pre code { background: none; padding: 0; color: inherit; }
.markdown-body table { width: 100%; border-collapse: collapse; margin: 8px 0; }
.markdown-body th, .markdown-body td { padding: 8px 12px; border: 1px solid var(--border); }
.markdown-body th { background: var(--bg-secondary); font-weight: 600; }
.markdown-body strong { font-weight: 600; color: var(--text-primary); }
.markdown-body blockquote { border-left: 3px solid var(--accent); padding-left: 16px; margin: 8px 0; color: var(--text-secondary); }

/* ── Tabs ───────────────────────────── */
.tabs {
    display: flex;
    gap: 4px;
    margin-bottom: 16px;
    border-bottom: 1px solid var(--border);
}

.tab {
    padding: 10px 20px;
    cursor: pointer;
    color: var(--text-secondary);
    font-weight: 500;
    border-bottom: 2px solid transparent;
    transition: all 0.15s;
}

.tab:hover { color: var(--text-primary); }
.tab.active { color: var(--accent); border-bottom-color: var(--accent); }

/* ── Toast ──────────────────────────── */
.toast-container {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 9999;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.toast {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 12px 20px;
    box-shadow: var(--shadow);
    display: flex;
    align-items: center;
    gap: 10px;
    animation: slideIn 0.3s ease;
    min-width: 280px;
}

.toast.success { border-left: 3px solid var(--green); }
.toast.error { border-left: 3px solid var(--red); }
.toast.info { border-left: 3px solid var(--accent); }

@keyframes slideIn {
    from { transform: translateX(100%); opacity: 0; }
    to { transform: translateX(0); opacity: 1; }
}

/* ── Modal ──────────────────────────── */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.7);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

.modal {
    background: var(--bg-card);
    border-radius: var(--radius);
    border: 1px solid var(--border);
    max-width: 600px;
    width: 90%;
    max-height: 80vh;
    overflow-y: auto;
    box-shadow: var(--shadow);
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px;
    border-bottom: 1px solid var(--border);
}

.modal-body {
    padding: 20px;
}

.modal-footer {
    padding: 16px 20px;
    border-top: 1px solid var(--border);
    display: flex;
    justify-content: flex-end;
    gap: 8px;
}

/* ── Progress ───────────────────────── */
.progress-bar {
    width: 100%;
    height: 4px;
    background: var(--bg-secondary);
    border-radius: 2px;
    overflow: hidden;
}

.progress-fill {
    height: 100%;
    background: var(--accent);
    transition: width 0.3s;
}

/* ── Scrollbar ──────────────────────── */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: var(--bg-primary);
}

::-webkit-scrollbar-thumb {
    background: var(--border);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--text-muted);
}

/* ── Chart ──────────────────────────── */
.chart-container {
    width: 100%;
    height: 300px;
}

/* ── Run History Timeline ───────────── */
.timeline {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.timeline-item {
    display: flex;
    gap: 12px;
    padding: 12px;
    border-radius: var(--radius-sm);
    background: var(--bg-secondary);
    cursor: pointer;
    transition: background 0.15s;
}

.timeline-item:hover {
    background: var(--bg-hover);
}

.timeline-time {
    color: var(--text-muted);
    font-size: 12px;
    white-space: nowrap;
    min-width: 140px;
}

.timeline-status {
    font-weight: 600;
    min-width: 80px;
}

.timeline-info {
    color: var(--text-secondary);
    flex: 1;
}

/* ── Pagination ───────────────────────── */
.pagination {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    margin-top: 16px;
    padding-top: 12px;
    border-top: 1px solid var(--border);
}

.pagination-info {
    font-size: 13px;
    color: var(--text-secondary);
    min-width: 60px;
    text-align: center;
}

.pagination .btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* ── Empty State ────────────────────── */
.empty-state {
    text-align: center;
    padding: 60px 20px;
    color: var(--text-muted);
}

.empty-state-icon {
    font-size: 48px;
    margin-bottom: 12px;
}

/* ── Responsive ─────────────────────── */
@media (max-width: 768px) {
    .sidebar { width: 60px; }
    .sidebar-logo { display: none; }
    .nav-item { padding: 10px; justify-content: center; }
    .nav-item span { display: none; }
    .main-content { padding: 16px; max-width: calc(100vw - 60px); }
    .skills-grid { grid-template-columns: 1fr; }
    .stats-grid { grid-template-columns: 1fr 1fr; }
}
