/* Dashboard theme & layout */
:root {
  --bg: #0d1117; --surface: #161b22; --border: #30363d;
  --text: #c9d1d9; --dim: #8b949e; --green: #3fb950;
  --red: #f85149; --yellow: #d29922; --blue: #58a6ff;
  --cyan: #56d4dd; --purple: #a78bfa;
}
* { box-sizing: border-box; margin: 0; padding: 0; }
body {
  font-family: 'SF Mono', 'Fira Code', 'Consolas', monospace;
  background: var(--bg); color: var(--text); font-size: 13px;
  padding: 12px; max-width: 1600px; margin: 0 auto;
}
.dim { color: var(--dim); }
.positive { color: var(--green); }
.negative { color: var(--red); }
.meta-dim { color: var(--dim); font-size: 11px; }

/* Header */
header {
  display: flex; justify-content: space-between; align-items: center;
  padding: 10px 16px; background: var(--surface); border: 1px solid var(--border);
  border-radius: 8px; margin-bottom: 8px;
}
.header-left, .header-right { display: flex; align-items: center; gap: 10px; }
header h1 { font-size: 16px; font-weight: 600; }
.badge { padding: 3px 8px; border-radius: 10px; font-size: 11px; font-weight: 600; }
.badge-ok { background: #0d3020; color: var(--green); }
.badge-degraded { background: #3d2a00; color: var(--yellow); }
.badge-unhealthy { background: #3d0a0a; color: var(--red); }
.badge-mode { background: #1c2d4d; color: var(--blue); }
.meta { display: flex; gap: 10px; align-items: center; }
#refresh-indicator { font-size: 11px; color: var(--dim); }

/* Tab bar */
.tab-bar {
  display: flex; gap: 2px; margin-bottom: 12px;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 8px; padding: 4px;
}
.tab {
  padding: 8px 20px; border-radius: 6px; border: none; cursor: pointer;
  background: transparent; color: var(--dim); font-size: 13px; font-weight: 600;
  font-family: inherit; transition: all 0.15s;
}
.tab:hover { color: var(--text); }
.tab.active { background: #1c2d4d; color: var(--blue); }
.tab-count { font-size: 10px; margin-left: 4px; opacity: 0.7; }
.tab-content { display: none; }
.tab-content.active { display: block; }

/* Buttons */
.btn-evaluate {
  padding: 5px 14px; border-radius: 6px; font-size: 11px; font-weight: 600;
  cursor: pointer; border: 1px solid var(--blue); background: #1c2d4d; color: var(--blue);
  font-family: inherit; transition: all 0.15s;
}
.btn-evaluate:hover { background: #2a3d5d; }
.btn-link {
  background: none; border: none; color: var(--blue); font-family: inherit;
  font-size: 11px; cursor: pointer; text-decoration: underline;
}
.btn-load-more {
  padding: 8px 24px; border-radius: 6px; border: 1px solid var(--border);
  background: var(--surface); color: var(--text); font-family: inherit;
  font-size: 12px; cursor: pointer;
}
.btn-load-more:hover { border-color: var(--blue); }

/* Summary cards */
.summary-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 8px; margin-bottom: 12px; }
.card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 6px; padding: 12px;
}
.card h2 { font-size: 10px; text-transform: uppercase; color: var(--dim); margin-bottom: 4px; letter-spacing: 0.5px; }
.card .value { font-size: 20px; font-weight: 700; }
.card .label { font-size: 10px; color: var(--dim); margin-top: 2px; }

/* Dashboard two-column layout (trades + audit on main tab) */
.dash-two-col { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-bottom: 12px; }
@media (max-width: 1100px) { .dash-two-col { grid-template-columns: 1fr; } }
.dash-section-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 6px; flex-wrap: wrap; gap: 6px; }
.dash-inline-filters { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.dash-audit-chips { display: flex; gap: 3px; flex-wrap: wrap; margin-bottom: 6px; }

/* Symbol tabs */
.symbol-tabs { display: flex; gap: 4px; margin-bottom: 8px; flex-wrap: wrap; }
.symbol-tab {
  padding: 5px 12px; border-radius: 6px; cursor: pointer;
  background: var(--surface); border: 1px solid var(--border);
  color: var(--dim); font-size: 12px; font-weight: 600;
  transition: all 0.15s;
}
.symbol-tab:hover { border-color: var(--blue); color: var(--text); }
.symbol-tab.active { background: #1c2d4d; border-color: var(--blue); color: var(--blue); }
.symbol-tab .price { font-size: 10px; margin-left: 4px; }

/* Chart */
.chart-container {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 6px; padding: 4px; margin-bottom: 12px; overflow: hidden;
}

/* Indicators */
.indicator-grid { display: grid; grid-template-columns: repeat(5, 1fr); gap: 6px; margin-bottom: 12px; }
.ind-card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 6px; padding: 8px; text-align: center;
}
.ind-card .key { font-size: 10px; color: var(--dim); text-transform: uppercase; }
.ind-card .val { font-size: 16px; font-weight: 700; margin-top: 2px; }

/* Tables */
.section { margin-bottom: 12px; }
.section-title { font-size: 13px; font-weight: 600; margin-bottom: 6px; }
.sub-title { font-size: 11px; color: var(--dim); text-transform: uppercase; margin-bottom: 6px; }
.table-scroll { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th { text-align: left; font-size: 10px; text-transform: uppercase; color: var(--dim); padding: 6px; border-bottom: 1px solid var(--border); white-space: nowrap; }
td { padding: 6px; border-bottom: 1px solid var(--border); font-size: 12px; white-space: nowrap; }
.stats-split { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
@media (max-width: 900px) { .stats-split { grid-template-columns: 1fr; } }

/* Risk panel */
.risk-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 6px; }
.risk-item { background: var(--surface); border: 1px solid var(--border); border-radius: 6px; padding: 8px; }
.risk-item .key { font-size: 10px; color: var(--dim); }
.risk-item .val { font-size: 14px; font-weight: 600; margin-top: 2px; }

/* Error banner */
.error-banner {
  background: #3d0a0a; border: 1px solid var(--red); color: var(--red);
  padding: 6px 12px; border-radius: 6px; margin-bottom: 8px; display: none; font-size: 12px;
}

/* Recent activity log (dashboard sidebar) */
.recent-log { flex: 1; overflow-y: auto; max-height: 360px; }
.recent-entry {
  padding: 4px 8px; border-bottom: 1px solid #21262d; font-size: 11px;
  display: grid; grid-template-columns: 50px auto minmax(0, 1fr); gap: 4px;
}
.recent-entry > span { min-width: 0; overflow-wrap: break-word; word-break: break-word; }
.recent-entry:last-child { border-bottom: none; }

/* ==================== AUDIT LOG ==================== */
.audit-toolbar {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 8px; padding: 12px; margin-bottom: 8px;
}
.audit-toolbar-top { display: flex; gap: 12px; align-items: center; margin-bottom: 8px; flex-wrap: wrap; }
.audit-search {
  flex: 1; min-width: 200px; padding: 7px 12px; border-radius: 6px;
  border: 1px solid var(--border); background: var(--bg); color: var(--text);
  font-family: inherit; font-size: 12px; outline: none;
}
.audit-search:focus { border-color: var(--blue); }
.audit-search::placeholder { color: #484f58; }
.audit-total { font-size: 11px; color: var(--dim); white-space: nowrap; }
.audit-filters { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.audit-select {
  padding: 5px 8px; border-radius: 6px; border: 1px solid var(--border);
  background: var(--bg); color: var(--text); font-family: inherit; font-size: 11px;
}
.audit-date-pills { display: flex; gap: 3px; }

/* Pills and chips */
.pill, .chip {
  padding: 3px 10px; border-radius: 4px; font-size: 10px; font-weight: 600;
  cursor: pointer; border: 1px solid var(--border); background: transparent; color: var(--dim);
  white-space: nowrap; user-select: none;
}
.pill:hover, .chip:hover { border-color: var(--blue); }
.pill.active, .chip.active { border-color: var(--blue); color: var(--blue); background: #1c2d4d; }
.audit-action-chips { display: flex; gap: 3px; flex-wrap: wrap; }

/* Audit entries */
.audit-entries { max-height: calc(100vh - 280px); overflow-y: auto; }
.audit-entry {
  padding: 8px 12px; border-bottom: 1px solid #21262d; font-size: 11px;
  cursor: pointer; transition: background 0.1s;
}
.audit-entry:hover { background: rgba(255,255,255,0.02); }
.audit-entry-row {
  display: grid; grid-template-columns: 130px 75px 85px 1fr; gap: 8px; align-items: start;
}
.audit-ts { color: var(--dim); font-size: 11px; }
.audit-sym { font-weight: 600; }
.audit-action {
  font-weight: 600; padding: 1px 6px; border-radius: 4px; font-size: 10px;
  text-align: center; display: inline-block;
}
.audit-detail { color: var(--dim); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.audit-indicators {
  padding: 8px 10px; margin-top: 6px; background: rgba(255,255,255,0.03);
  border-radius: 4px; border: 1px solid #21262d; font-size: 10px; color: var(--dim);
  display: none;
}
.audit-indicators.open { display: block; }
.audit-ind-section { margin-bottom: 4px; }
.audit-ind-label { color: var(--blue); font-weight: 600; font-size: 9px; text-transform: uppercase; margin-bottom: 2px; }
.audit-ind-row { display: flex; flex-wrap: wrap; gap: 4px 14px; }
.audit-ind-key { color: #484f58; }
.audit-ind-val { font-weight: 600; }
.audit-explain {
  padding: 6px 10px; margin-top: 4px; background: rgba(88,166,255,0.05);
  border-radius: 4px; border: 1px solid #1c2d4d; font-size: 11px; line-height: 1.5;
  display: none;
}
.audit-explain.open { display: block; }
.audit-load-more { text-align: center; padding: 12px; }

/* Action colors */
.action-ENTRY, .action-EARLY_ENTRY { background: #0d3020; color: var(--green); }
.action-EXIT, .action-MONITOR_CLOSE { background: #1c2d4d; color: var(--blue); }
.action-REJECTED { background: #3d2a00; color: var(--yellow); }
.action-BLOCKED { background: #3d0a0a; color: var(--red); }
.action-FILTERED { background: #21262d; color: var(--dim); }
.action-NO_SIGNAL { background: transparent; color: #484f58; }
.action-PARTIAL_TP { background: #1a3320; color: #56dd6e; }
.action-BREAKEVEN { background: #1c2d4d; color: var(--cyan); }
.action-AGENT { background: #1a2233; color: var(--purple); }
.action-SCAN { background: #1a2233; color: var(--cyan); }
.action-PROMOTED { background: #1a3320; color: #56dd6e; }
.action-DEMOTED { background: #33201a; color: #dd9656; }
.action-PROFIT_LOCK { background: #2d1a33; color: #e09cff; }

/* Trades toolbar */
.trades-toolbar {
  display: flex; gap: 12px; align-items: center; flex-wrap: wrap;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 8px; padding: 12px; margin-bottom: 8px;
}

/* Performance tabs */
.perf-tabs { display: flex; gap: 4px; margin-bottom: 8px; }

/* Grade badges */
.grade-badge {
  display: inline-block; padding: 1px 6px; border-radius: 4px;
  font-size: 11px; font-weight: 700; text-align: center; min-width: 24px;
}
.grade-A { background: #0d3020; color: var(--green); }
.grade-B { background: #1a3320; color: #56dd6e; }
.grade-C { background: #3d2a00; color: var(--yellow); }
.grade-D { background: #33201a; color: #dd9656; }
.grade-F { background: #3d0a0a; color: var(--red); }

/* SL/TP coloring */
.sl-near { color: var(--red); font-weight: 600; }
.tp-near { color: var(--green); font-weight: 600; }

/* Live stats bar (dashboard tab) */
.live-stats-bar {
  display: flex; gap: 4px; margin-bottom: 12px; flex-wrap: wrap;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 6px; padding: 8px 12px;
}
.live-stat {
  display: flex; align-items: center; gap: 6px;
  padding: 2px 12px; border-right: 1px solid var(--border);
}
.live-stat:last-child { border-right: none; }
.live-stat-label { font-size: 10px; color: var(--dim); text-transform: uppercase; }
.live-stat-value { font-size: 13px; font-weight: 700; }
.live-stat-sub { font-size: 10px; color: var(--dim); }

/* Decision KPI */
.kpi-hero-grid { display: grid; grid-template-columns: 1.5fr 1fr 1fr 1fr; gap: 8px; margin-bottom: 8px; }
.kpi-hero-main { text-align: center; }
.kpi-grade-badge { margin-top: 4px; }
.kpi-charts-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-bottom: 8px; }
.kpi-breakdown-grid { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 8px; }
.kpi-stacked-bar { display: flex; height: 24px; border-radius: 4px; overflow: hidden; margin-bottom: 6px; }
.kpi-bar-seg { display: flex; align-items: center; justify-content: center; font-size: 11px; font-weight: 700; color: #000; min-width: 2px; }
.kpi-bar-legend { font-size: 11px; color: var(--dim); display: flex; gap: 10px; flex-wrap: wrap; }
.kpi-cal-row { display: flex; align-items: center; gap: 6px; margin: 3px 0; }
.kpi-cal-label { width: 50px; font-size: 11px; color: var(--dim); text-align: right; }
.kpi-cal-bar-wrap { flex: 1; height: 14px; background: var(--border); border-radius: 3px; overflow: hidden; }
.kpi-cal-bar { height: 100%; background: var(--blue); border-radius: 3px; }
.kpi-cal-count { width: 30px; font-size: 11px; color: var(--dim); text-align: right; }
.kpi-cal-wr { width: 55px; font-size: 11px; text-align: right; }
@media (max-width: 1000px) {
  .kpi-hero-grid { grid-template-columns: 1fr 1fr; }
  .kpi-charts-grid { grid-template-columns: 1fr; }
  .kpi-breakdown-grid { grid-template-columns: 1fr; }
}

/* Position management */
.btn-close-pos {
  background: none; border: 1px solid var(--red); color: var(--red);
  border-radius: 4px; cursor: pointer; font-size: 10px; padding: 2px 6px;
  font-family: inherit; opacity: 0.6; transition: opacity 0.15s;
}
.btn-close-pos:hover { opacity: 1; background: rgba(248,81,73,0.1); }
.editable-cell { cursor: pointer; }
.editable-cell:hover { background: rgba(88,166,255,0.08); border-radius: 3px; }

/* Animations */
.price-flash { animation: priceFlash 0.4s ease-out; }
@keyframes priceFlash { 0% { background: rgba(88,166,255,0.15); } 100% { background: transparent; } }
