/* BerkshireScalpaway Dark Dashboard */

:root {
    --bg: #0d1117;
    --panel: #161b22;
    --border: #30363d;
    --text: #c9d1d9;
    --text-muted: #8b949e;
    --green: #3fb950;
    --red: #f85149;
    --yellow: #d29922;
    --blue: #58a6ff;
    --accent: #1f6feb;
}

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

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

.header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 24px;
    border-bottom: 1px solid var(--border);
}

.header h1 { font-size: 18px; font-weight: 600; }

.status-bar {
    display: flex;
    gap: 16px;
    align-items: center;
    font-size: 12px;
    color: var(--text-muted);
}

.status-badge {
    padding: 2px 8px;
    border-radius: 12px;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
}

.badge-paper { background: #1f3a5f; color: var(--blue); }
.badge-live { background: #2d1b1b; color: var(--red); }
.badge-ok { background: #1b2d1b; color: var(--green); }
.badge-halted { background: #2d1b1b; color: var(--red); }

.dashboard {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
    padding: 16px 24px;
    max-width: 1600px;
    margin: 0 auto;
}

.panel {
    background: var(--panel);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 16px;
}

.panel-full { grid-column: 1 / -1; }

.panel h2 {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 12px;
    padding-bottom: 8px;
    border-bottom: 1px solid var(--border);
}

/* Metrics grid */
.metrics {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
    gap: 12px;
    margin-bottom: 12px;
}

.metric {
    text-align: center;
}

.metric-value {
    font-size: 22px;
    font-weight: 700;
    font-variant-numeric: tabular-nums;
}

.metric-label {
    font-size: 11px;
    color: var(--text-muted);
    text-transform: uppercase;
    margin-top: 2px;
}

.color-green { color: var(--green); }
.color-red { color: var(--red); }
.color-yellow { color: var(--yellow); }

/* Chart containers */
.chart-container {
    position: relative;
    width: 100%;
    height: 200px;
}

.chart-container-tall {
    height: 300px;
}

/* Portfolio donut */
.portfolio-layout {
    display: flex;
    gap: 16px;
    align-items: flex-start;
}

.portfolio-chart { flex: 0 0 200px; height: 200px; }
.portfolio-info { flex: 1; }

.total-equity {
    font-size: 24px;
    font-weight: 700;
    margin-bottom: 8px;
}

/* Donut legend */
.donut-legend {
    display: flex;
    flex-direction: column;
    gap: 4px;
    margin-top: 4px;
}

.legend-item {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 12px;
}

.legend-swatch {
    display: inline-block;
    width: 10px;
    height: 10px;
    border-radius: 2px;
    flex-shrink: 0;
}

.legend-label {
    color: var(--text);
    font-weight: 500;
    min-width: 40px;
}

.legend-pct {
    color: var(--text-muted);
    font-variant-numeric: tabular-nums;
}

/* Universe chips */
.universe-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-top: 8px;
}

.chip {
    padding: 2px 10px;
    border-radius: 12px;
    font-size: 11px;
    background: #21262d;
    border: 1px solid var(--border);
    color: var(--text-muted);
}

/* Watchlist grid */
.watchlist-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.watchlist-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 8px 14px;
    border-radius: 8px;
    background: #21262d;
    border: 1px solid var(--border);
    min-width: 110px;
    transition: border-color 0.2s;
}

.watchlist-item.wl-holding {
    border-color: var(--blue);
    background: #0d1f3c;
    box-shadow: 0 0 6px rgba(88, 166, 255, 0.15);
}

.watchlist-item.wl-signal {
    border-color: var(--green);
    background: #12261e;
    box-shadow: 0 0 8px rgba(63, 185, 80, 0.2);
}

.watchlist-item.wl-near {
    border-color: var(--yellow);
    background: #1f1d12;
    box-shadow: 0 0 6px rgba(210, 153, 34, 0.12);
}

.watchlist-item.wl-far {
    border-color: #da3633;
    background: #1a1214;
}

.watchlist-ticker {
    font-weight: 600;
    font-size: 13px;
    margin-bottom: 2px;
}

.watchlist-price {
    font-size: 11px;
    color: var(--text-muted);
    font-variant-numeric: tabular-nums;
}

.watchlist-tags {
    display: flex;
    gap: 4px;
    margin-top: 4px;
}

.watchlist-tag {
    font-size: 9px;
    padding: 1px 5px;
    border-radius: 4px;
    font-weight: 600;
    text-transform: uppercase;
}

.tag-buy { background: #1b3d2a; color: var(--green); }
.tag-hold { background: #1a2744; color: var(--blue); }
.tag-up { background: #1b3d2a; color: var(--green); }
.tag-down { background: #3d1b1b; color: var(--red); }

/* Condition bar (7 dots for 7 entry conditions) */
.cond-bar {
    display: flex;
    gap: 3px;
    margin-top: 4px;
    justify-content: center;
}

.cond-dot {
    width: 8px;
    height: 8px;
    border-radius: 2px;
}

.cond-pass { background: var(--green); }
.cond-fail { background: #30363d; }

/* Position cards */
.position-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(450px, 1fr));
    gap: 12px;
}

.position-card {
    background: #0d1117;
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 12px;
}

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

.position-market { font-weight: 600; font-size: 15px; }

.position-pnl {
    font-weight: 700;
    font-size: 15px;
    font-variant-numeric: tabular-nums;
}

.position-levels {
    display: flex;
    gap: 12px;
    font-size: 11px;
    color: var(--text-muted);
    margin-bottom: 8px;
}

.position-levels span { white-space: nowrap; }
.level-entry { color: var(--blue); }
.level-tp { color: var(--green); }
.level-stop { color: var(--red); }
.level-trail { color: var(--yellow); }

.position-chart { width: 100%; height: 250px; }

/* Trade log table */
.trade-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
    font-variant-numeric: tabular-nums;
}

.trade-table th {
    text-align: left;
    padding: 6px 8px;
    border-bottom: 1px solid var(--border);
    color: var(--text-muted);
    font-weight: 500;
    font-size: 11px;
    text-transform: uppercase;
}

.trade-table td {
    padding: 6px 8px;
    border-bottom: 1px solid #21262d;
}

.trade-table tr:hover { background: #1c2128; }

.empty-state {
    text-align: center;
    padding: 40px;
    color: var(--text-muted);
}

/* ============================================================
   Flash / pulse animations for state changes
   ============================================================ */

@keyframes flash-glow {
    0%   { opacity: 1; }
    20%  { opacity: 0.3; }
    40%  { opacity: 1; }
    60%  { opacity: 0.3; }
    80%  { opacity: 1; }
    100% { opacity: 1; }
}

@keyframes flash-border {
    0%   { border-color: #fff; box-shadow: 0 0 12px rgba(255,255,255,0.4); }
    25%  { border-color: inherit; box-shadow: none; }
    50%  { border-color: #fff; box-shadow: 0 0 12px rgba(255,255,255,0.4); }
    75%  { border-color: inherit; box-shadow: none; }
    100% { border-color: inherit; box-shadow: none; }
}

@keyframes cond-pop {
    0%   { transform: scale(1); box-shadow: 0 0 0 rgba(63,185,80,0); }
    30%  { transform: scale(1.8); box-shadow: 0 0 8px rgba(63,185,80,0.8); }
    60%  { transform: scale(1); box-shadow: 0 0 4px rgba(63,185,80,0.4); }
    80%  { transform: scale(1.3); box-shadow: 0 0 6px rgba(63,185,80,0.6); }
    100% { transform: scale(1); box-shadow: 0 0 0 rgba(63,185,80,0); }
}

@keyframes legend-flash {
    0%   { background: rgba(255,255,255,0.15); }
    50%  { background: transparent; }
    100% { background: rgba(255,255,255,0.15); }
}

/* Applied to watchlist cards when tier changes */
.flash-card {
    animation: flash-border 1.2s ease-out;
}

/* Applied to condition dots when they flip to pass */
.flash-dot {
    animation: cond-pop 0.8s ease-out;
}

/* Applied to donut legend items when value changes */
.flash-legend {
    animation: legend-flash 0.5s ease-in-out 3;
    border-radius: 4px;
}

/* Responsive */
@media (max-width: 900px) {
    .dashboard { grid-template-columns: 1fr; }
    .portfolio-layout { flex-direction: column; }
    .position-grid { grid-template-columns: 1fr; }
}
