* { margin: 0; padding: 0; box-sizing: border-box; }
html, body { width: 100%; overflow-x: clip; }

:root {
    /* Bible Studio palette, with a more restrained set for a data-dense control panel */
    --bg: #090c13;
    --bg_elevated: #0f1421;
    --bg_card: #131a2a;
    --text: rgba(244, 248, 255, 0.96);
    --muted: rgba(234, 242, 255, 0.72);
    --muted2: rgba(234, 242, 255, 0.45);
    --muted3: rgba(234, 242, 255, 0.20);

    --border: 1px solid rgba(255, 255, 255, 0.08);
    --border_strong: 1px solid rgba(255, 255, 255, 0.14);

    --accentA: #1aaaff;
    --accentB: #3b82f6;
    --warn: #ff9800;
    --bad: #ef4444;
    --good: #22c55e;
    --paper: #a78bfa;

    --r_xl: 18px;
    --r_lg: 14px;
    --r_md: 10px;
    --r_sm: 6px;

    --shadow: 0 18px 60px rgba(0, 0, 0, 0.40);

    --font_sans: -apple-system, BlinkMacSystemFont, "Roboto Flex", "Segoe UI", system-ui, sans-serif;
    --font_mono: ui-monospace, "JetBrains Mono", "SF Mono", Menlo, Consolas, monospace;
}

body {
    background: var(--bg);
    color: var(--text);
    font-family: var(--font_sans);
    font-feature-settings: "ss01", "ss02";
    min-height: 100vh;
    line-height: 1.45;
}

a { color: inherit; text-decoration: none; }

/* ---------- Topbar ---------- */
.topbar {
    position: fixed;
    left: 0; right: 0; top: 0;
    height: 56px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 18px;
    z-index: 50;

    background: rgba(9, 12, 19, 0.65);
    backdrop-filter: blur(14px);
    -webkit-backdrop-filter: blur(14px);
    border-bottom: var(--border);
}

.topbar_left { display: flex; align-items: center; gap: 16px; }
.topbar_right { display: flex; align-items: center; gap: 12px; }

.brand {
    font-family: var(--font_sans);
    font-weight: 800;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    font-size: 14px;
    color: var(--text);
}
.brand_dot { color: var(--accentA); }

.env_pill {
    font-family: var(--font_mono);
    font-size: 11px;
    padding: 4px 10px;
    border-radius: 999px;
    border: var(--border);
    color: var(--muted);
    text-transform: uppercase;
    letter-spacing: 0.08em;
}
.env_pill.paper { color: var(--paper); border-color: rgba(167, 139, 250, 0.30); }
.env_pill.live  { color: var(--bad);   border-color: rgba(239, 68, 68, 0.40); }

.icon_btn {
    width: 36px; height: 36px;
    display: inline-flex; align-items: center; justify-content: center;
    border-radius: var(--r_sm);
    color: var(--muted);
    cursor: pointer;
    transition: background 0.12s ease, color 0.12s ease;
}
.icon_btn:hover { background: rgba(255,255,255,0.05); color: var(--text); }

/* ---------- Drawer (hamburger menu, mirrored from Bible Studio) ---------- */
.overlay {
    position: fixed; inset: 0;
    background: rgba(0, 0, 0, 0.55);
    backdrop-filter: blur(4px);
    z-index: 60;
    opacity: 0; visibility: hidden;
    transition: opacity 0.18s ease, visibility 0.18s ease;
}
.overlay.open { opacity: 1; visibility: visible; }

.drawer {
    position: fixed;
    top: 0; right: 0; bottom: 0;
    width: 320px; max-width: 88vw;
    background: var(--bg_elevated);
    border-left: var(--border);
    z-index: 70;
    transform: translateX(100%);
    transition: transform 0.22s ease;
    display: flex; flex-direction: column;
}
.drawer.open { transform: translateX(0); }

.drawer_header {
    height: 56px;
    display: flex; align-items: center; justify-content: space-between;
    padding: 0 18px;
    border-bottom: var(--border);
}
.drawer_header .brand { font-size: 13px; }

.drawer_list { flex: 1; overflow-y: auto; padding: 8px 0; }
.drawer_item {
    display: flex; align-items: center; justify-content: space-between;
    padding: 14px 18px;
    color: var(--muted);
    border-bottom: 1px solid rgba(255,255,255,0.04);
    cursor: pointer;
    transition: background 0.12s ease, color 0.12s ease;
}
.drawer_item:hover { background: rgba(26, 170, 255, 0.06); color: var(--text); }
.drawer_item.active { color: var(--text); background: rgba(26, 170, 255, 0.10); }
.drawer_item .left { display: flex; align-items: center; gap: 14px; }
.drawer_item .left i { color: var(--accentA); width: 16px; text-align: center; }
.drawer_item .left span { font-size: 14px; font-weight: 500; }
.drawer_item .chev { opacity: 0.45; font-size: 12px; }

.drawer_divider { height: 1px; background: rgba(255,255,255,0.06); margin: 6px 0; }

/* ---------- Page layout ---------- */
.main {
    padding: 88px 24px 60px;
    max-width: 1280px;
    margin: 0 auto;
}
.page_h {
    display: flex; align-items: baseline; justify-content: space-between;
    margin-bottom: 24px;
}
.page_h h1 {
    font-size: 22px; font-weight: 600; letter-spacing: -0.01em;
}
.page_h .subtle { color: var(--muted2); font-size: 13px; }

/* ---------- Card grid ---------- */
.grid {
    display: grid;
    gap: 14px;
    grid-template-columns: repeat(12, minmax(0, 1fr));
}
.card {
    background: var(--bg_card);
    border: var(--border);
    border-radius: var(--r_lg);
    padding: 18px;
}
.card_h {
    display: flex; align-items: center; justify-content: space-between;
    margin-bottom: 12px;
}
.card_h h2 {
    font-size: 12px;
    font-weight: 600;
    color: var(--muted);
    text-transform: uppercase;
    letter-spacing: 0.08em;
}
.card.span_3  { grid-column: span 3; }
.card.span_4  { grid-column: span 4; }
.card.span_6  { grid-column: span 6; }
.card.span_8  { grid-column: span 8; }
.card.span_12 { grid-column: span 12; }
@media (max-width: 900px) {
    .card.span_3, .card.span_4, .card.span_6, .card.span_8 { grid-column: span 12; }
}

/* ---------- Stats / KPI ---------- */
.stat {
    display: flex; flex-direction: column; gap: 4px;
}
.stat_value {
    font-family: var(--font_mono);
    font-size: 26px;
    font-weight: 600;
    letter-spacing: -0.01em;
}
.stat_label {
    color: var(--muted2);
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.06em;
}
.stat_value.good { color: var(--good); }
.stat_value.bad  { color: var(--bad); }
.stat_value.warn { color: var(--warn); }

/* Generic semantic-color helpers for any text element (table cells, inline
   spans, etc). Scoped to NOT apply on .dot which uses .good/.bad for
   background-color via separate rules below; setting `color` on a dot is
   harmless since the dot has no text content. */
td.good, span.good, div.good { color: var(--good); }
td.bad,  span.bad,  div.bad  { color: var(--bad); }
td.warn, span.warn, div.warn { color: var(--warn); }

/* ---------- Status indicators ---------- */
.dot {
    display: inline-block; width: 8px; height: 8px;
    border-radius: 50%;
    margin-right: 8px;
    vertical-align: middle;
}
.dot.good { background: var(--good); box-shadow: 0 0 8px rgba(34, 197, 94, 0.6); }
.dot.bad  { background: var(--bad);  box-shadow: 0 0 8px rgba(239, 68, 68, 0.6); }
.dot.warn { background: var(--warn); }
.dot.muted { background: var(--muted3); }

.row_kv {
    display: flex; align-items: center; justify-content: space-between;
    padding: 8px 0;
    border-bottom: 1px solid rgba(255,255,255,0.04);
    font-size: 13px;
}
.row_kv:last-child { border-bottom: none; }
.row_kv .k { color: var(--muted); }
.row_kv .v { font-family: var(--font_mono); color: var(--text); }

/* ---------- Tables ---------- */
table.dt {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
}
table.dt th, table.dt td {
    text-align: left;
    padding: 10px 12px;
    border-bottom: 1px solid rgba(255,255,255,0.05);
}
table.dt tbody tr:hover {
    background: rgba(26, 170, 255, 0.04);
}
table.dt th {
    color: var(--muted2);
    font-weight: 500;
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    background: rgba(255,255,255,0.02);
}
table.dt td.num { font-family: var(--font_mono); text-align: right; }

/* ---------- Killswitch button ---------- */
.kill_btn {
    background: rgba(239, 68, 68, 0.12);
    border: 1px solid rgba(239, 68, 68, 0.35);
    color: var(--bad);
    padding: 7px 14px;
    border-radius: var(--r_sm);
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    cursor: pointer;
}
.kill_btn:hover { background: rgba(239, 68, 68, 0.20); }

/* ---------- Empty state ---------- */
.empty {
    text-align: center;
    padding: 48px 24px;
    color: var(--muted2);
    font-size: 13px;
}

/* ---------- Bellwether 2 dashboard ---------- */
.pos { color: var(--good, #34d399); }
.neg { color: var(--bad, #ef4444); }

.b2_stats {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 12px;
    margin-bottom: 16px;
}
.b2_sub { font-size: 12px; color: var(--muted2); margin-top: 4px; }
/* color the total line red/green - beats .b2_sub's muted color on specificity */
.b2_sub.pos { color: var(--good, #34d399); }
.b2_sub.neg { color: var(--bad, #ef4444); }

.b2_books { display: flex; flex-direction: column; gap: 8px; }
.b2_book {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
    padding: 8px 10px;
    border-radius: var(--r_sm);
    background: rgba(255,255,255,0.02);
}
.b2_book_name { font-weight: 600; min-width: 110px; }
.b2_book_kv { font-size: 12px; color: var(--muted); font-family: var(--font_mono); }

.b2_pill {
    display: inline-block;
    padding: 2px 9px;
    border-radius: 999px;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    background: rgba(255,255,255,0.06);
    color: var(--muted);
}
.b2_pill.active      { background: rgba(52, 211, 153, 0.14); color: #34d399; }
.b2_pill.shadow_only { background: rgba(167, 139, 250, 0.14); color: #a78bfa; }
.b2_pill.paused      { background: rgba(251, 191, 36, 0.14); color: #fbbf24; }
.b2_pill.killed      { background: rgba(239, 68, 68, 0.14); color: #ef4444; }
.b2_pill.side_yes    { background: rgba(52, 211, 153, 0.14); color: #34d399; }
.b2_pill.side_no     { background: rgba(239, 68, 68, 0.14); color: #ef4444; }
.b2_pill.book        { background: rgba(96, 165, 250, 0.14); color: #60a5fa; }

.b2_trade {
    padding: 12px 4px;
    border-bottom: 1px solid rgba(255,255,255,0.05);
}
.b2_trade:last-child { border-bottom: none; }
.b2_trade_q { font-size: 14px; font-weight: 500; margin-bottom: 7px; line-height: 1.35; }
.b2_trade_meta { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 9px; }
.b2_trade_grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 7px 14px;
}
.b2_trade_grid > div { display: flex; flex-direction: column; }
.b2_k { font-size: 10px; text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted2); }
.b2_v { font-size: 13px; font-family: var(--font_mono); }

@media (max-width: 760px) {
    .b2_stats { grid-template-columns: repeat(2, 1fr); }
    .b2_trade_grid { grid-template-columns: repeat(2, 1fr); }
    .b2_book_name { min-width: 100%; }
    
    .main {
        padding: 88px 10px 60px;
    }
}

.b2_bracket { font-size: 12px; color: var(--muted); margin: -3px 0 8px; }
.b2_ext { font-family: var(--font_mono); color: var(--muted2); font-size: 11px; }

/* Uniform vertical spacing between B2 page containers (title, stats, each card) */
.b2_page { display: flex; flex-direction: column; gap: 16px; }
.b2_page .page_h, .b2_page .b2_stats { margin-bottom: 0; }
