/* Bloomberg-ish: pure black, amber accents, monospace, sharp borders. */

:root {
    --bg: #000;
    --bg-panel: #0a0a0a;
    --border: #2a2a2a;
    --text: #cccccc;
    --text-dim: #666666;
    --amber: #ff9900;
    --amber-bright: #ffaa33;
    --green: #00ff66;
    --red: #ff4444;
    --blue: #66ccff;
}

* {
    box-sizing: border-box;
}

html, body {
    margin: 0;
    padding: 0;
    background: var(--bg);
    color: var(--text);
    font-family: 'JetBrains Mono', 'Cascadia Code', 'Consolas', 'Menlo', monospace;
    font-size: 13px;
    line-height: 1.5;
    font-feature-settings: 'tnum';
    -webkit-font-smoothing: antialiased;
}

a { color: var(--amber); text-decoration: none; }
a:hover { color: var(--amber-bright); }

.app {
    max-width: 1400px;
    margin: 0 auto;
    padding: 16px;
}

/* ---- Demo-mode banner -------------------------------------------------- */

/* Sits above the .app wrapper. Amber-on-near-black to fit the Bloomberg
   palette without screaming. role="status" so screen readers announce it
   on first load but not on every subsequent fragment swap. */
.demo-banner {
    background: var(--bg-panel);
    color: var(--amber);
    border-bottom: 1px solid var(--amber);
    padding: 6px 16px;
    font-size: 11px;
    letter-spacing: 0.14em;
    text-align: center;
    text-transform: uppercase;
}

.demo-banner strong {
    color: var(--amber-bright);
    font-weight: 700;
    letter-spacing: 0.18em;
}

.demo-banner-sep {
    color: var(--text-dim);
    margin: 0 6px;
}

/* ---- Header ------------------------------------------------------------ */

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

.header .title {
    font-weight: 700;
    color: var(--amber);
    letter-spacing: 0.18em;
    font-size: 14px;
}

.header .clock {
    color: var(--text-dim);
    font-size: 12px;
    letter-spacing: 0.05em;
}

/* ---- Panels ------------------------------------------------------------ */

.panel {
    background: var(--bg-panel);
    border: 1px solid var(--border);
    margin-bottom: 12px;
}

/* Three low-density panels (Run Progress, Watchlist, System) tile across
   the bottom; gap replaces the per-panel margin so the row sits flush. */
.panel-grid-3 {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 12px;
    margin-bottom: 12px;
}

.panel-grid-3 .panel {
    margin-bottom: 0;
    min-width: 0;
}

.panel-title {
    background: var(--bg);
    color: var(--amber);
    font-size: 11px;
    letter-spacing: 0.18em;
    padding: 6px 10px;
    border-bottom: 1px solid var(--border);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.panel-body {
    padding: 10px 12px;
}

/* ---- Summary tiles ---------------------------------------------------- */

.summary-grid {
    display: grid;
    /* auto-fit so panels with 3 children (vs-SPY) fill the row instead of
       leaving a dead 4th cell. The top summary panel's 4 children still
       lay out as 4 columns at desktop widths because each tile clears the
       150px min comfortably. */
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 1px;
    background: var(--border);
    border: 1px solid var(--border);
}

.tile {
    background: var(--bg-panel);
    padding: 12px 14px;
}

.tile .label {
    color: var(--text-dim);
    font-size: 10px;
    letter-spacing: 0.18em;
    margin-bottom: 4px;
}

.tile .value {
    color: var(--amber-bright);
    font-size: 22px;
    font-weight: 600;
    letter-spacing: 0.02em;
}

.tile .sub {
    color: var(--text-dim);
    font-size: 11px;
    margin-top: 2px;
}

.tile.gain .value { color: var(--green); }
.tile.loss .value { color: var(--red); }

/* ---- Tables ----------------------------------------------------------- */

table.data {
    width: 100%;
    border-collapse: collapse;
    font-size: 12px;
}

table.data th {
    text-align: left;
    color: var(--text-dim);
    font-size: 10px;
    letter-spacing: 0.15em;
    font-weight: normal;
    padding: 4px 8px;
    border-bottom: 1px solid var(--border);
}

table.data td {
    padding: 5px 8px;
    border-bottom: 1px dotted var(--border);
}

table.data tr:last-child td {
    border-bottom: none;
}

table.data .num {
    text-align: right;
    font-variant-numeric: tabular-nums;
}

table.data .ticker {
    color: var(--amber-bright);
    font-weight: 600;
}

.empty {
    color: var(--text-dim);
    padding: 16px;
    text-align: center;
    font-style: italic;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    font-size: 11px;
}

/* ---- Rating pills ----------------------------------------------------- */

.pill {
    display: inline-block;
    padding: 1px 6px;
    border: 1px solid currentColor;
    font-size: 10px;
    letter-spacing: 0.12em;
    font-weight: 600;
}

.pill.buy        { color: var(--green); }
.pill.overweight { color: var(--green); opacity: 0.85; }
.pill.hold       { color: var(--text-dim); }
.pill.underweight { color: var(--red); opacity: 0.85; }
.pill.sell       { color: var(--red); }

/* ---- Detail link (per row) ------------------------------------------- */

a.detail-link {
    color: var(--text-dim);
    font-size: 10px;
    letter-spacing: 0.12em;
    text-decoration: none;
    border-bottom: 1px dotted var(--text-dim);
    padding-bottom: 1px;
}

a.detail-link:hover {
    color: var(--amber);
    border-color: var(--amber);
}

/* ---- Full thesis (detail page) --------------------------------------- */

.thesis-full {
    color: var(--text);
    font-size: 13px;
    line-height: 1.7;
}

.thesis-full strong { color: var(--amber-bright); }
.thesis-full h1, .thesis-full h2, .thesis-full h3 {
    color: var(--amber);
    letter-spacing: 0.08em;
    margin: 1.2em 0 0.4em;
}
.thesis-full code {
    background: var(--bg);
    padding: 1px 5px;
    color: var(--blue);
    font-size: 12px;
}

/* ---- Accessibility utilities ----------------------------------------- */

/* Visually hide content but keep it accessible to assistive tech.
   `clip-path: inset(50%)` is the modern equivalent of the deprecated
   `clip: rect(...)` recipe; supported in every browser we care about. */
.visually-hidden {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip-path: inset(50%);
    white-space: nowrap;
    border: 0;
}

/* ---- Watchlist ticker pills ------------------------------------------ */

.ticker-pill {
    display: inline-flex;
    align-items: center;
    background: var(--bg);
    border: 1px solid var(--border);
    color: var(--amber-bright);
    font-size: 11px;
    letter-spacing: 0.1em;
    font-weight: 600;
    padding: 3px 0 3px 8px;
}

.ticker-pill-text { padding-right: 6px; }

.ticker-pill-x {
    background: transparent;
    border: none;
    border-left: 1px solid var(--border);
    color: var(--text-dim);
    cursor: pointer;
    padding: 0 8px;
    font-size: 13px;
    font-family: inherit;
    line-height: 1;
}

.ticker-pill-x:hover {
    color: var(--red);
    background: rgba(255, 68, 68, 0.1);
}

/* ---- Decisions feed --------------------------------------------------- */

.decision {
    border-bottom: 1px dotted var(--border);
    padding: 8px 0;
}

.decision:last-child { border-bottom: none; }

.decision .meta {
    display: flex;
    gap: 14px;
    align-items: center;
    margin-bottom: 4px;
    font-size: 11px;
}

.decision .date  { color: var(--text-dim); }
.decision .thesis {
    color: var(--text);
    font-size: 11px;
    white-space: pre-wrap;
    max-height: 4em;
    overflow: hidden;
    position: relative;
}

/* ---- System bar ------------------------------------------------------- */

.system-bar {
    display: flex;
    align-items: center;
    gap: 16px;
    flex-wrap: wrap;
    font-size: 11px;
    letter-spacing: 0.06em;
}

.kv { color: var(--text-dim); }
.kv b { color: var(--text); font-weight: normal; }

.status-dot {
    display: inline-block;
    width: 8px; height: 8px;
    background: var(--green);
    margin-right: 6px;
    vertical-align: middle;
}
.status-dot.idle    { background: var(--text-dim); }
.status-dot.running { background: var(--amber); animation: blink 1s infinite; }
.status-dot.failed  { background: var(--red); }

@keyframes blink {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.3; }
}

/* ---- Buttons ---------------------------------------------------------- */

button.run-now {
    background: var(--bg);
    color: var(--amber);
    border: 1px solid var(--amber);
    padding: 4px 14px;
    font-family: inherit;
    font-size: 11px;
    letter-spacing: 0.18em;
    cursor: pointer;
    margin-left: auto;
}

button.run-now:hover {
    background: var(--amber);
    color: var(--bg);
}

button.run-now:disabled {
    color: var(--text-dim);
    border-color: var(--text-dim);
    cursor: not-allowed;
}

/* ---- Mobile breakpoint ------------------------------------------------- */

@media (max-width: 720px) {
    .app { padding: 8px; }
    .summary-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .tile .value { font-size: 18px; }
    .header { flex-direction: column; align-items: flex-start; gap: 8px; }
    .header .clock { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }

    .panel-body { overflow-x: auto; }
    table.data { width: max-content; min-width: 100%; }
    table.data td, table.data th { white-space: nowrap; }

    .panel-grid-3 { grid-template-columns: 1fr; gap: 12px; }
}
