/* ============================================================
   Trading Hub — minimal dark-mode stylesheet
   Monospace font is applied to data tables; the rest of the UI
   uses a system sans-serif stack for readability.
   ============================================================ */

/* --- CSS custom properties (variables) -------------------- */
:root {
    --bg:           #0d1117;   /* page background */
    --surface:      #161b22;   /* cards, header, table header */
    --border:       #30363d;   /* all borders */
    --text:         #c9d1d9;   /* primary text */
    --text-muted:   #8b949e;   /* secondary text, table headers */
    --accent:       #58a6ff;   /* links, brand, positive highlights */
    --negative:     #f85149;   /* bearish / risk-on signal */
    --positive:     #3fb950;   /* bullish / risk-off signal */
    --header-height: 3rem;
}

/* --- Reset ------------------------------------------------- */
*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

/* --- Base -------------------------------------------------- */
body {
    background: var(--bg);
    color: var(--text);
    /* System font stack: crisp on Mac, Windows, and Linux */
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Helvetica, Arial, sans-serif;
    font-size: 14px;
    line-height: 1.6;
}

/* --- Header / nav ----------------------------------------- */
header {
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    height: var(--header-height);
    display: flex;
    align-items: center;
    padding: 0 1.5rem;
    /* Stays pinned to the top when the user scrolls */
    position: sticky;
    top: 0;
    z-index: 10;
}

.brand {
    font-weight: 700;
    font-size: 13px;
    letter-spacing: 0.1em;
    color: var(--accent);
    text-decoration: none;
}

nav {
    margin-left: 2rem;
    display: flex;
    gap: 1.5rem;
}

nav a {
    color: var(--text-muted);
    text-decoration: none;
    font-size: 13px;
    transition: color 0.15s;
}

nav a:hover,
nav a.active {
    color: var(--text);
}

/* --- Main content area ------------------------------------ */
main {
    max-width: 960px;
    margin: 2rem auto;
    padding: 0 1.5rem;
}

h1 {
    font-size: 1.15rem;
    font-weight: 600;
    margin-bottom: 1.25rem;
}

/* Small "eyebrow" label above sections */
.page-meta {
    font-size: 12px;
    color: var(--text-muted);
    margin-bottom: 1rem;
}

/* --- Tool cards (home page) ------------------------------- */
.tool-grid {
    display: grid;
    /* Responsive: fills columns that are at least 180px wide */
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 1rem;
}

.tool-card {
    display: block;           /* makes the whole card a link target */
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 1.25rem;
    text-decoration: none;
    color: var(--text);
    transition: border-color 0.15s;
}

.tool-card:hover {
    border-color: var(--accent);
}

.tool-card .title {
    font-weight: 600;
    font-size: 1rem;
    color: var(--accent);
}

.tool-card .desc {
    font-size: 12px;
    color: var(--text-muted);
    margin-top: 0.35rem;
}

/* --- Data tables ------------------------------------------ */
/* Wrapper enables horizontal scroll on narrow viewports */
.data-table-wrap {
    overflow-x: auto;
    border: 1px solid var(--border);
    border-radius: 6px;
}

table {
    width: 100%;
    border-collapse: collapse;
    /* Monospace font for tabular data so columns align naturally */
    font-family: "SFMono-Regular", "Consolas", "Liberation Mono", "Courier New", monospace;
    font-size: 13px;
}

thead {
    background: var(--surface);
}

thead th {
    padding: 0.55rem 1rem;
    text-align: left;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--text-muted);
    border-bottom: 1px solid var(--border);
    /* prevent header text from wrapping */
    white-space: nowrap;
}

tbody tr {
    border-bottom: 1px solid var(--border);
}

tbody tr:last-child {
    border-bottom: none;
}

tbody tr:hover {
    background: var(--surface);
}

tbody td {
    padding: 0.55rem 1rem;
    white-space: nowrap;
}

/* Score colouring — applied as classes in sb2.html */
.score-negative { color: var(--negative); }
.score-positive { color: var(--positive); }
.score-neutral  { color: var(--text-muted); }

/* Tier colouring — applied as tier-{tier} classes in sb2.html */
.tier-normal    { color: var(--text-muted); }
.tier-watch     { color: #e3b341; }          /* amber */
.tier-elevated  { color: #f0883e; }          /* orange */
.tier-emergency { color: var(--negative); font-weight: 600; }  /* red, bold */

/* Empty state (shown when DB has no data yet) */
.empty-state {
    color: var(--text-muted);
    font-size: 13px;
    margin-top: 0.5rem;
    line-height: 2;
}

.empty-state code {
    font-family: "SFMono-Regular", "Consolas", monospace;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 4px;
    padding: 0.15rem 0.4rem;
    color: var(--accent);
}

/* CLSK report iframe — fills available width, tall enough to be usable without constant iframe scrolling */
.clsk-report-frame {
    display: block;
    width: 100%;
    min-height: 1200px;
    border: 1px solid var(--border);
    border-radius: 6px;
    background: #fff;
}

/* Refresh bar — sits above the data pane on /clsk-options */
.refresh-bar {
    display: flex;
    align-items: center;
    gap: 1rem;
    margin-bottom: 1rem;
}

.btn-refresh {
    background: var(--accent);
    color: #0d1117;
    border: none;
    border-radius: 4px;
    padding: 0.35rem 1rem;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: opacity 0.15s;
}

.btn-refresh:hover {
    opacity: 0.82;
}

.refresh-status {
    font-size: 12px;
    color: var(--text-muted);
}

.refresh-warn     { color: #e3b341; }
.refresh-unavailable { color: var(--negative); }

.refresh-error {
    background: rgba(248, 81, 73, 0.08);
    border: 1px solid rgba(248, 81, 73, 0.3);
    border-radius: 4px;
    padding: 0.5rem 0.75rem;
    font-size: 12px;
    color: var(--negative);
    margin-bottom: 1rem;
    word-break: break-word;
}

/* Candidate fallback notice — amber, shown when candidates are sample/not live */
.candidate-fallback-warn {
    background: rgba(227, 179, 65, 0.08);
    border: 1px solid rgba(227, 179, 65, 0.35);
    border-radius: 4px;
    padding: 0.5rem 0.75rem;
    font-size: 12px;
    color: #e3b341;
    margin-bottom: 1rem;
    word-break: break-word;
}

/* Coverage info notice — neutral blue, shown when candidates are live but coverage is partial */
.candidate-coverage-info {
    background: rgba(88, 166, 255, 0.06);
    border: 1px solid rgba(88, 166, 255, 0.25);
    border-radius: 4px;
    padding: 0.5rem 0.75rem;
    font-size: 12px;
    color: var(--text-muted);
    margin-bottom: 1rem;
    word-break: break-word;
}
