/*
 * Tiverton House Dashboard Styles
 *



 */
/* Import serif fonts - Libre Baskerville for readability */
@import url('https://fonts.googleapis.com/css2?family=Libre+Baskerville:wght@400;700&family=Source+Serif+4:wght@400;500;600;700&display=swap');

:root {
    /* Victorian warm tones on near-black ink, sharpened for screen contrast */
    --bg-primary: #14110e;
    --bg-secondary: #1c1815;
    --bg-tertiary: #241f1a;
    --bg-card: #1f1a16;
    --border-color: #332c24;
    --border-hairline: rgba(201, 169, 97, 0.16);
    --border-gold: #7c6a52;
    --text-primary: #f0e7d8;
    --text-secondary: #b6a891;
    --text-muted: #97896e;
    --accent-primary: #c9a961;
    --accent-gold: #c9a961;
    --accent-burgundy: #722f37;
    --accent-green: #6f9e57;
    --accent-red: #b8494c;
    --accent-blue: #4a6d8a;
    --accent-cream: #f6f1e6;
    --accent-yellow: #c9a961;
    --accent-purple: #6a5973;
}

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

html {
    height: 100%;
    overflow-x: hidden;
}

body {
    min-height: 100%;
    width: 100%;
    max-width: 100vw;
    margin: 0;
    padding: 0;
    overflow-x: hidden;
    font-family: 'Source Serif 4', 'Georgia', serif;
    background-color: var(--bg-primary);
    background-image:
        radial-gradient(ellipse at top, rgba(191, 162, 79, 0.025) 0%, transparent 50%),
        radial-gradient(ellipse at bottom, rgba(114, 47, 55, 0.04) 0%, transparent 50%);
    color: var(--text-primary);
    line-height: 1.5;
    font-size: 15px;
}

.dashboard {
    display: flex;
    flex-direction: column;
    gap: 8px;
    padding: 8px 10px 24px;
    max-width: min(1720px, 100%);
    margin: 0 auto;
    width: 100%;
}

.dashboard-page {
    width: 100%;
}

/* Stacked flow: the layout wrappers are transparent so phones and short
   windows keep the plain top-to-bottom document. The single-screen grid
   below overrides them on a real desktop viewport. */
.dashboard-main,
.dashboard-side {
    display: contents;
}

/* The chat toggle sets the `hidden` attribute on the floor rail. Both layout
   modes give the rail an explicit display, which would otherwise beat the
   user-agent's [hidden] rule, so state it once here. */
.dashboard-side[hidden] {
    display: none;
}

turbo-frame#trader-grid {
    display: block;
    min-width: 0;
}

@media (max-width: 768px) {
    .dashboard {
        gap: 14px;
        padding: 12px 10px 32px;
    }
}

@media (max-width: 480px) {
    .dashboard {
        padding: 10px 8px 28px;
    }
}

/* Compact header bar */
.header {
    position: sticky;
    top: 0;
    z-index: 100;
    background: var(--bg-primary);
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
    align-items: center;
    gap: 4px 10px;
    padding: 4px 10px;
    border-bottom: 1px solid var(--border-hairline);
    max-width: 100%;
}

/* Turbo frame for portfolio bar - must be sticky */
turbo-frame#portfolio-bar {
    display: block;
    position: sticky;
    top: 50px;   /* height of the sticky header at desktop widths */
    z-index: 99;
}

/* On a phone the header can wrap, which makes any fixed offset wrong and
   stacks two bars over a short viewport. Keep the header pinned; let the
   portfolio bar scroll with the page. */
@media (max-width: 768px) {
    turbo-frame#portfolio-bar {
        position: static;
    }
}

/* Sticky portfolio bar */
.portfolio-bar {
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border-color);
    padding: 4px 12px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 20px;
    flex-wrap: wrap;
    max-width: 100%;
}

.portfolio-bar-left {
    display: flex;
    align-items: baseline;
    gap: 20px;
}

.portfolio-bar-equity {
    display: flex;
    align-items: baseline;
    gap: 8px;
}

.portfolio-bar-equity .value {
    font-family: 'Libre Baskerville', serif;
    font-size: 18px;
    font-weight: 700;
    color: var(--accent-cream);
    letter-spacing: -0.2px;
    font-variant-numeric: tabular-nums;
}

.portfolio-bar-equity .label {
    font-size: 10px;
    text-transform: uppercase;
    letter-spacing: 1.4px;
    color: var(--text-muted);
}

.portfolio-bar-change {
    display: flex;
    align-items: baseline;
    gap: 6px;
}

.portfolio-bar-change .value {
    font-family: 'Source Serif 4', serif;
    font-size: 15px;
    font-weight: 600;
}

.portfolio-bar-change .percent {
    font-size: 13px;
    opacity: 0.8;
}

.portfolio-bar-change .label {
    font-size: 10px;
    text-transform: uppercase;
    letter-spacing: 1.2px;
    color: var(--text-muted);
}

.portfolio-bar-right {
    display: flex;
    gap: 24px;
    align-items: center;
}

.portfolio-bar-stat {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 2px;
}

.portfolio-bar-stat .value {
    font-family: 'Source Serif 4', serif;
    font-size: 13px;
    font-weight: 600;
    color: var(--text-primary);
    font-variant-numeric: tabular-nums;
}

.portfolio-bar-stat .value.source {
    letter-spacing: 0.6px;
}

.portfolio-bar-stat .value.source-live {
    color: var(--accent-green);
}

.portfolio-bar-stat .value.source-internal {
    color: var(--accent-yellow);
}

.portfolio-bar-stat .label {
    font-size: 10px;
    text-transform: uppercase;
    letter-spacing: 1.1px;
    color: var(--text-muted);
}

@media (max-width: 768px) {
    .portfolio-bar-equity .value {
        font-size: 18px;
    }

    .portfolio-bar-change .value {
        font-size: 15px;
    }

    .portfolio-bar-right {
        gap: 12px;
    }

    .portfolio-bar-stat .value {
        font-size: 13px;
    }
}

@media (max-width: 480px) {
    /* Wrap the stats rather than hide them: a phone reader was left with an
       equity figure and nothing to read it against. */
    .portfolio-bar-right {
        width: 100%;
        gap: 16px 20px;
        flex-wrap: wrap;
        justify-content: flex-start;
    }

    .portfolio-bar-stat {
        align-items: flex-start;
    }

    .portfolio-bar {
        padding: 10px 12px;
        gap: 12px;
    }
}

/* News ticker positioning */
.news-ticker {
    margin: 0;
    background: #0a0a0a;
    padding: 2px 0;
    border-top: 1px solid #1a1a1a;
    border-bottom: 1px solid #1a1a1a;
}

.header-left {
    display: flex;
    align-items: center;
    gap: 8px;
}

.nav-links {
    display: flex;
    align-items: center;
    gap: 12px;
}

.nav-link {
    color: var(--text-secondary);
    text-decoration: none;
    font-size: 12px;
    letter-spacing: 0.3px;
    padding: 3px 2px;
    border-bottom: 1px solid transparent;
    transition: color 0.15s ease, border-color 0.15s ease;
    white-space: nowrap;
    font-family: inherit;
}

.nav-link:hover {
    color: var(--accent-primary);
    border-bottom-color: var(--accent-primary);
}

.header h1 {
    font-family: 'Libre Baskerville', 'Georgia', serif;
    font-size: 16px;
    font-weight: 600;
    white-space: nowrap;
    letter-spacing: 2px;
    text-transform: uppercase;
    color: var(--accent-cream);
    margin: 0;
}

.header h1 .brand-accent {
    color: var(--accent-gold);
}

.header-tiverton {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    color: var(--text-secondary);
    text-decoration: none;
    font-size: 11px;
    white-space: nowrap;
    transition: color 0.15s ease;
}

.header-tiverton:hover { color: var(--accent-gold); }

.header-tiverton-avatar {
    width: 26px;
    height: 26px;
    border-radius: 50%;
    border: 1px solid var(--border-gold);
    object-fit: cover;
}

.floor-toggle {
    appearance: none;
    border: 0;
    border-bottom: 1px solid transparent;
    border-radius: 0;
    background: transparent;
    cursor: pointer;
}

.floor-toggle:focus-visible {
    color: var(--accent-primary);
    border-bottom-color: var(--accent-primary);
    outline: 1px solid var(--accent-primary);
    outline-offset: 3px;
}

.header-status-badges {
    display: flex;
    gap: 3px;
    align-items: center;
}

.health-summary {
    font-size: 10px;
    letter-spacing: 0.6px;
    text-transform: uppercase;
    color: var(--text-muted);
}

.health-summary.ok {
    color: var(--accent-green);
}

.health-summary.warning {
    color: var(--accent-yellow);
}

.health-summary.error {
    color: var(--accent-red);
}

.status-badge {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    cursor: help;
}

.status-badge.ok { background: var(--accent-green); }
.status-badge.warning { background: var(--accent-yellow); }
.status-badge.error { background: var(--accent-red); }
.status-badge.unknown { background: var(--text-muted); }

.header-right {
    display: flex;
    align-items: center;
    gap: 8px;
}

.market-badge {
    padding: 2px 6px;
    border-radius: 3px;
    font-size: 9px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    white-space: nowrap;
}

.market-badge.open { background: var(--accent-green); color: #000; }
.market-badge.pre-market { background: var(--accent-yellow); color: #000; }
.market-badge.after-hours { background: var(--accent-purple); color: #fff; }
.market-badge.closed { background: var(--text-muted); color: #fff; }

.card {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 3px;
    overflow: hidden;
    min-width: 0;
    max-width: 100%;
    box-sizing: border-box;
}

.card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 7px 12px 6px;
    background: transparent;
    border-bottom: 1px solid var(--border-hairline);
}

.card-title {
    font-family: 'Libre Baskerville', serif;
    font-size: 13px;
    font-weight: 600;
    color: var(--accent-gold);
    text-transform: uppercase;
    letter-spacing: 2.2px;
}

/* Thesis card - playing card style */
.thesis-card {
    background: linear-gradient(135deg, var(--bg-card) 0%, var(--bg-tertiary) 100%);
    border: 1px solid var(--border-gold);
    border-radius: 12px;
    margin: 12px 8px 16px 8px;
    box-shadow: 0 4px 16px rgba(0,0,0,0.3), inset 0 1px 0 rgba(255,255,255,0.05);
    overflow: hidden;
    max-width: 100%;
}

.thesis-card-header {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px 16px;
    background: linear-gradient(90deg, rgba(201, 162, 39, 0.1) 0%, transparent 100%);
    border-bottom: 1px solid var(--border-color);
    flex-wrap: wrap;
}

.thesis-card-body {
    padding: 16px;
}

.thesis-text {
    font-size: 15px;
    line-height: 1.7;
    color: var(--text-primary);
    font-style: italic;
    word-wrap: break-word;
    overflow-wrap: break-word;
}

.thesis-card-footer {
    display: flex;
    flex-wrap: wrap;
    gap: 16px;
    padding: 16px 20px;
    background: var(--bg-tertiary);
    border-top: 1px solid var(--border-color);
}

.thesis-stat {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.thesis-stat .label {
    font-size: 10px;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: var(--text-muted);
}

.thesis-stat .value {
    font-family: 'Libre Baskerville', serif;
    font-size: 15px;
    font-weight: 600;
    color: var(--accent-gold);
}

.thesis-links {
    display: flex;
    gap: 12px;
    margin-left: auto;
}

.thesis-link {
    font-size: 13px;
    color: var(--text-secondary);
    text-decoration: none;
    padding: 6px 12px;
    border: 1px solid var(--border-color);
    border-radius: 4px;
    transition: all 0.2s;
}

.thesis-link:hover {
    color: var(--accent-gold);
    border-color: var(--accent-gold);
}

/* Ticker metrics panel inside thesis card */
.metrics-panel {
    border-top: 1px solid var(--border-color);
    background: linear-gradient(180deg, rgba(26, 22, 18, 0.6) 0%, rgba(26, 22, 18, 0.3) 100%);
}

.metrics-panel-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 16px 0 16px;
}

.metrics-panel-title {
    font-size: 10px;
    text-transform: uppercase;
    letter-spacing: 1.5px;
    color: var(--text-muted);
    font-weight: 600;
}

.metrics-panel-period {
    font-size: 11px;
    color: var(--text-muted);
    font-style: italic;
}

.metrics-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 0;
    padding: 8px 8px 12px 8px;
}

.metrics-group {
    padding: 8px;
}

.metrics-group-label {
    font-size: 11px;
    font-weight: 600;
    color: var(--accent-gold);
    margin-bottom: 6px;
    padding-bottom: 4px;
    border-bottom: 1px solid rgba(124, 106, 82, 0.3);
    letter-spacing: 0.3px;
}

.metric-item {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    padding: 2px 0;
}

.metric-name {
    font-size: 12px;
    color: var(--text-secondary);
}

.metric-value {
    font-family: 'Libre Baskerville', serif;
    font-size: 13px;
    font-weight: 600;
    color: var(--text-primary);
    letter-spacing: -0.3px;
}

.metric-value.positive {
    color: var(--accent-green);
}

.metric-value.negative {
    color: var(--accent-red);
}

@media (max-width: 768px) {
    .metrics-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (max-width: 480px) {
    .metrics-grid {
        grid-template-columns: 1fr;
    }
}

.card-body {
    padding: 12px 14px;
    min-width: 0;
    overflow: hidden;
}

/* The floor feed supplies its own row padding — it reads as a column of
   entries rather than a boxed panel. */
.card-body:has(> turbo-frame#trading-floor) {
    padding: 0;
}

.filter-empty-state {
    margin-top: 12px;
}

.trader-overview-panel {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-top: 1px solid var(--accent-gold);
    border-radius: 2px;
    padding: 18px 20px;
}

.trader-overview-label {
    font-size: 10px;
    letter-spacing: 1.2px;
    text-transform: uppercase;
    color: var(--text-muted);
}

.watchlist-panel {
    margin-top: 0;
}

.watchlist-panel-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

.watchlist-panel-count {
    color: var(--text-muted);
    font-size: 11px;
    letter-spacing: 0.6px;
    text-transform: uppercase;
}

.watchlist-chip-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 4px 16px;
    margin-top: 12px;
}

.watchlist-chip {
    display: inline-flex;
    align-items: center;
    color: var(--text-secondary);
    font-size: 13px;
    letter-spacing: 0.7px;
}

.watchlist-empty {
    margin-top: 10px;
    color: var(--text-muted);
    font-size: 13px;
}

.trader-overview-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 12px;
}

.trader-overview-copy {
    margin-top: 10px;
    color: var(--text-primary);
    font-size: 14px;
    line-height: 1.6;
}

/* Position row highlighting */
.position-row.highlighted {
    background: rgba(212, 175, 55, 0.1) !important;
}

.position-row.dimmed {
    opacity: 0.3;
}

/* Tables */
.table-wrapper {
    overflow-x: auto;
    max-width: 100%;
    width: 100%;
}

table {
    width: 100%;
    border-collapse: collapse;
    table-layout: fixed;
}

th, td {
    padding: 8px 12px;
    text-align: left;
    border-bottom: 1px solid var(--border-color);
}

th {
    font-size: 11px;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    background: var(--bg-tertiary);
    overflow: hidden;
    text-overflow: ellipsis;
}

td {
    font-size: 12px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

tr:hover {
    background: var(--bg-tertiary);
}

/* Position colors */
.positive { color: var(--accent-green); }
.negative { color: var(--accent-red); }
.neutral { color: var(--text-secondary); }
.fresh { color: var(--accent-green); }
.stale { color: var(--accent-red); }

/* Positions table column widths */
#positions-table {
    table-layout: auto;
}

#positions-table th,
#positions-table td {
    font-size: 14px;
    padding: 10px 12px;
    white-space: nowrap;
}

#positions-table td:first-child {
    width: auto;
}

.position-details td {
    white-space: normal !important;
    padding: 0 !important;
}

/* Trade status badges */
.badge {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 12px;
    font-size: 10px;
    font-weight: 600;
    text-transform: uppercase;
}

.badge-pending { background: var(--accent-yellow); color: #000; }
.badge-approved { background: var(--accent-blue); color: #000; }
.badge-queued { background: #725c2f; color: #f7e8c0; }
.badge-executing { background: var(--accent-purple); color: #fff; }
.badge-partially_filled { background: #7c6a52; color: #f5ead7; }
.badge-filled { background: var(--accent-green); color: #000; }
.badge-denied { background: var(--accent-red); color: #fff; }
.badge-failed { background: var(--accent-red); color: #fff; }
.badge-cancelled { background: var(--text-muted); color: #fff; }
.badge-passed { background: #4c4c4c; color: #ddd; }
.badge-proposed { background: #37526a; color: #d2e6f3; }

.market-queue-indicator {
    font-size: 14px;
    margin-left: 4px;
    cursor: help;
    opacity: 0.9;
}

/* Empty states */
.empty-state {
    text-align: center;
    padding: 28px 20px;
    color: var(--text-muted);
    font-size: 14px;
    font-style: italic;
}

/* Trading Floor Feed */
.live-indicator {
    display: inline-block;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--accent-green);
    margin-right: 8px;
    animation: livePulse 2.8s ease-in-out infinite;
}

@keyframes livePulse {
    0%, 100% { opacity: 0.55; }
    50% { opacity: 1; }
}

.trading-floor-content {
    max-height: 440px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 0;
    padding: 0;
    font-family: 'Source Serif 4', 'Georgia', serif;
    font-size: 14px;
    line-height: 1.55;
    color: var(--text-secondary);
    background: transparent;
    border: none;
}

.feed-row {
    display: flex;
    flex-direction: column;
    gap: 4px;
    padding: 10px 14px;
    border-left: 2px solid transparent;
    border-bottom: 1px solid var(--border-hairline);
    transition: background 0.15s ease;
}

.feed-row:last-child { border-bottom: none; }

.feed-row:hover {
    background: rgba(255, 255, 255, 0.02);
}

.feed-row.latest {
    border-left-color: var(--accent-gold);
}

.feed-row.latest:hover {
    background: rgba(201, 169, 97, 0.05);
}

.feed-row.latest.pulse {
    animation: latestPulse 1.6s ease-in-out 0s 2;
}

.feed-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
}

.feed-author {
    font-family: 'Libre Baskerville', serif;
    font-size: 12px;
    font-weight: 700;
    color: var(--accent-cream);
    letter-spacing: 0.4px;
}

.feed-time {
    font-size: 11px;
    font-style: italic;
    color: var(--text-muted);
    letter-spacing: 0.3px;
}

/* Floor notes arrive as markdown and are rendered to real elements, so this
   must not be pre-wrap — that would double every paragraph break. */
.feed-msg {
    overflow-wrap: break-word;
    color: var(--text-secondary);
    font-size: 13px;
    line-height: 1.5;
}

.feed-msg > :first-child { margin-top: 0; }
.feed-msg > :last-child { margin-bottom: 0; }

.feed-msg p { margin: 0 0 8px 0; }
.feed-msg ul,
.feed-msg ol { margin: 0 0 8px 0; padding-left: 20px; }
.feed-msg li { margin-bottom: 2px; }
.feed-msg strong { color: var(--text-primary); font-weight: 700; }
.feed-msg em { font-style: italic; }
.feed-msg a { color: var(--accent-gold); text-decoration: none; border-bottom: 1px solid rgba(201, 169, 97, 0.35); }
.feed-msg a:hover { border-bottom-color: var(--accent-gold); }

.feed-msg code {
    font-family: 'Consolas', 'Monaco', monospace;
    font-size: 0.9em;
    color: var(--accent-cream);
    background: rgba(201, 169, 97, 0.1);
    padding: 1px 4px;
    border-radius: 2px;
}

.feed-msg pre {
    margin: 0 0 8px 0;
    padding: 10px 12px;
    overflow-x: auto;
    background: rgba(0, 0, 0, 0.28);
    border-radius: 2px;
}

.feed-msg pre code { background: none; padding: 0; }

.feed-msg blockquote {
    margin: 0 0 8px 0;
    padding-left: 12px;
    border-left: 2px solid var(--border-color);
    color: var(--text-muted);
}

/* Discord mention styling */
.feed-msg .mention {
    color: var(--accent-gold);
    font-weight: 600;
}

@keyframes latestPulse {
    0% { background: rgba(191, 162, 79, 0.06); }
    50% { background: rgba(191, 162, 79, 0.15); }
    100% { background: rgba(191, 162, 79, 0.06); }
}

/* Loading */
.loading {
    text-align: center;
    padding: 40px;
    color: var(--text-secondary);
}

.spinner {
    display: inline-block;
    width: 20px;
    height: 20px;
    border: 2px solid var(--border-color);
    border-top-color: var(--accent-primary);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* Mobile adjustments */
@media (max-width: 768px) {
    .header {
        gap: 4px 8px;
        padding: 5px 8px;
    }

    .header h1 {
        font-size: 14px;
    }

    .header-tiverton span { display: none; }
    .header-tiverton-avatar { width: 24px; height: 24px; }

    .header-left {
        flex-shrink: 0;
    }

    .header-right {
        flex-shrink: 1;
        min-width: 0;
        overflow: hidden;
    }

    .header-status-badges {
        display: none;
    }

    .health-summary {
        font-size: 9px;
    }

    .nav-links {
        gap: 10px;
    }

    .nav-link {
        font-size: 10px;
        padding: 2px 1px;
    }

    .hide-mobile {
        display: none !important;
    }

    th, td {
        padding: 6px 8px;
        font-size: 11px;
    }

    .card-body {
        padding: 12px;
    }

    

    

    .metric-value {
        font-size: 13px;
    }

    .metric-value.large {
        font-size: 16px;
    }

    
}

@media (max-width: 480px) {
    .hide-small {
        display: none !important;
    }

    /* Keep orientation and the chat control; secondary docs can move below. */
    .nav-link:not(:first-child):not(.floor-toggle) {
        display: none;
    }

    th, td {
        padding: 4px 6px;
        font-size: 10px;
    }

    .badge {
        font-size: 9px;
        padding: 1px 6px;
    }

    .card {
        border-radius: 4px;
    }

    .card-body {
        padding: 12px;
    }

    

    

    

    
}

/* Split-flap departure board */
.flip-ticker {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 0;
    padding: 0;
    margin: 0 auto;
    max-width: 100%;
}

.flip-cell {
    width: 12px;
    height: 18px;
    background: #0a0a0a;
    border-left: 1px solid #151515;
    position: relative;
    overflow: hidden;
}

.flip-cell:first-child {
    border-left: none;
}

.flip-cell::after {
    content: '';
    position: absolute;
    left: 0;
    right: 0;
    top: 50%;
    height: 1px;
    background: #1a1a1a;
    z-index: 10;
    pointer-events: none;
}

.flip-card {
    width: 100%;
    height: 100%;
    position: relative;
    transform-style: preserve-3d;
}

.flip-cell.flip .flip-card {
    animation: flip-clack 0.06s linear;
}

.flip-face {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    font-family: 'Consolas', 'Monaco', 'Courier New', monospace;
    font-size: 11px;
    font-weight: 700;
    background: #0a0a0a;
    color: #f0c020;
    text-shadow: 0 0 2px rgba(240, 192, 32, 0.3);
    border: none;
    border-radius: 0;
    margin: 0;
    padding: 0;
}

.flip-back {
    transform: rotateX(180deg);
    backface-visibility: hidden;
}

.flip-front {
    backface-visibility: hidden;
}

@keyframes flip-clack {
    0% { transform: rotateX(0deg); }
    100% { transform: rotateX(-180deg); }
}

@media (max-width: 768px) {
    .flip-cell {
        width: 9px;
        height: 16px;
    }
    .flip-face {
        font-size: 10px;
    }
}

/* ============================================================ */
/* Desk lead + trader grid                                       */
/* Aesthetic: aristocratic trading-house ledger.                 */
/* Pure typography over chrome — italics + small caps + hairline */
/* rules rather than pills or boxed badges. Tabular nums for     */
/* every column of numbers so values line up like a hand-set     */
/* spreadsheet.                                                  */
/* ============================================================ */

/* Desk-lead: one slim masthead line, not a band. */

/* --- Grid -------------------------------------------------- */

.trader-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 8px;
    margin: 0;
}

/* Two columns is the working layout: four traders sit as a 2x2 block and each
   ledger keeps enough width that no cell has to truncate. A third column only
   earns its place once every card is still ~560px wide. */
@media (min-width: 900px) {
    .trader-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (min-width: 1800px) {
    .trader-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}

/* --- Card ------------------------------------------------- */

.trader-card {
    display: flex;
    flex-direction: column;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-top: 1px solid var(--accent-gold);
    border-radius: 2px;
    padding: 6px 10px 4px;
    min-width: 0;
}

.trader-card-head {
    display: flex;
    align-items: center;
    gap: 8px;
    padding-bottom: 4px;
    margin-bottom: 4px;
    border-bottom: 1px solid var(--border-hairline);
    min-width: 0;
}

.trader-card-avatar {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    border: 1px solid var(--border-gold);
    object-fit: cover;
    flex-shrink: 0;
}

.trader-card-identity { min-width: 0; }

.trader-card-name {
    font-family: 'Libre Baskerville', serif;
    font-weight: 700;
    font-size: 14px;
    color: var(--accent-cream);
    letter-spacing: 0.3px;
    line-height: 1.1;
}

.trader-card-name-link {
    color: inherit;
    text-decoration: none;
    border-bottom: 1px solid transparent;
    transition: border-color 0.15s;
}

.trader-card-name-link:hover { border-bottom-color: var(--accent-gold); }

.trader-card-style {
    font-size: 9px;
    letter-spacing: 1.4px;
    text-transform: uppercase;
    color: var(--text-muted);
    margin-top: 1px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* --- Hero value: lives inside the card head --------------- */

.trader-card-hero-figure {
    min-width: 0;
    text-align: right;
    margin-left: auto;
    flex-shrink: 0;
}

.trader-card-hero-value {
    font-family: 'Libre Baskerville', serif;
    font-size: 18px;
    font-weight: 700;
    color: var(--accent-cream);
    letter-spacing: 0.2px;
    font-variant-numeric: tabular-nums;
    line-height: 1.1;
}

.trader-card-hero-delta {
    font-family: 'Libre Baskerville', serif;
    font-size: 11.5px;
    font-weight: 600;
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
    line-height: 1.2;
}

.trader-card-hero-delta.positive { color: var(--accent-green); }
.trader-card-hero-delta.negative { color: var(--accent-red); }

.trader-card-hero-pct {
    font-family: 'Source Serif 4', serif;
    font-size: 11px;
    font-weight: 400;
    font-style: italic;
    opacity: 0.85;
}

/* Realized / Unrealized / Deployed as one inline rule of pairs */
.trader-card-metrics {
    display: flex;
    flex-wrap: wrap;
    gap: 2px 14px;
    margin: 0 0 4px 0;
    padding-bottom: 3px;
    border-bottom: 1px solid var(--border-hairline);
}

.trader-card-metric {
    min-width: 0;
    display: flex;
    align-items: baseline;
    gap: 4px;
}

.trader-card-metric dt {
    font-size: 9px;
    letter-spacing: 1.1px;
    text-transform: uppercase;
    color: var(--text-muted);
}

.trader-card-metric dd {
    margin: 0;
    font-family: 'Libre Baskerville', serif;
    font-size: 11.5px;
    font-weight: 600;
    font-variant-numeric: tabular-nums;
    color: var(--accent-cream);
    white-space: nowrap;
}

.trader-card-metric dd.positive { color: var(--accent-green); }
.trader-card-metric dd.negative { color: var(--accent-red); }

/* --- Section heads (Positions / Recent Trades) ------------ */

.trader-card-section {
    min-width: 0;
    margin-bottom: 4px;
}

.trader-card-section:last-of-type { margin-bottom: 3px; }

.trader-card-section-head {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 10px;
    margin-bottom: 2px;
}

.trader-card-section-title {
    font-family: 'Libre Baskerville', serif;
    font-size: 10px;
    letter-spacing: 1.8px;
    text-transform: uppercase;
    color: var(--accent-gold);
    font-weight: 600;
}

.trader-card-section-count {
    font-size: 10px;
    color: var(--text-muted);
    font-style: italic;
    letter-spacing: 0.3px;
}

.trader-card-empty {
    font-size: 13px;
    color: var(--text-muted);
    font-style: italic;
    padding: 8px 0;
}

/* --- Ledger table (shared by positions + trades) ---------- */

.ledger-table {
    width: 100%;
    border-collapse: collapse;
    table-layout: fixed;
    font-variant-numeric: tabular-nums;
}

.ledger-table th {
    font-size: 9px;
    letter-spacing: 1.2px;
    text-transform: uppercase;
    text-align: left;
    color: var(--text-muted);
    font-weight: 500;
    padding: 0 6px 3px 0;
    background: transparent;
    border-bottom: 1px solid var(--border-hairline);
    white-space: nowrap;
}

.ledger-table th.num { text-align: right; }
.ledger-table th:last-child,
.ledger-table td:last-child { padding-right: 0; }

/* No ellipsis: a clipped number is worse than a wrapped one, and the column
   set is sized so ordinary rows fit outright. */
.ledger-table td {
    padding: 3px 6px 3px 0;
    font-size: 11.5px;
    line-height: 1.25;
    border-bottom: 1px solid rgba(51, 44, 36, 0.55);
    white-space: nowrap;
    color: var(--text-primary);
    vertical-align: baseline;
}

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

.ledger-table td.muted { color: var(--text-muted); }

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

.ledger-table .position-row { cursor: pointer; }
.ledger-table .position-row:hover {
    background: rgba(198, 173, 99, 0.05);
}

.ledger-ticker {
    font-family: 'Libre Baskerville', serif;
    font-weight: 700;
    font-size: 11.5px;
    color: var(--accent-cream);
    letter-spacing: 0.2px;
}

.ledger-details-cell {
    padding: 0 !important;
    white-space: normal !important;
}

.ledger-details-cell .thesis-card {
    margin: 4px 0 8px 0;
}

/* Trade-row state typography (no pills) */
.ledger-trades .side-buy {
    color: var(--accent-green);
    font-style: italic;
    font-variant: small-caps;
    letter-spacing: 0.8px;
}

.ledger-trades .side-sell {
    color: var(--accent-red);
    font-style: italic;
    font-variant: small-caps;
    letter-spacing: 0.8px;
}

.ledger-trades .status-filled,
.ledger-trades .status-active,
.ledger-trades .status-soft,
.ledger-trades .status-bad {
    font-style: italic;
    font-size: 11.5px;
    letter-spacing: 0.2px;
}

.ledger-trades .status-filled { color: var(--text-secondary); }
.ledger-trades .status-active { color: var(--accent-gold); }
.ledger-trades .status-soft   { color: var(--text-muted); }
.ledger-trades .status-bad    { color: var(--accent-red); }

.ledger-trades .row-soft td { opacity: 0.8; }

/* Working orders are the only repeating motion on the ledger. The long,
   low-contrast breath distinguishes broker-bound work from settled history
   without turning the desk into an alert console. */
.ledger-trades .trade-row-active td {
    animation: workingTradePulse 4.8s ease-in-out infinite;
}

.ledger-trades .trade-row-active td:first-child {
    box-shadow: inset 1px 0 rgba(201, 169, 97, 0.55);
}

@keyframes workingTradePulse {
    0%, 100% { background-color: rgba(201, 169, 97, 0.012); }
    50% { background-color: rgba(201, 169, 97, 0.065); }
}

.ledger-trades .ledger-time {
    color: var(--text-muted);
    font-size: 11px;
    font-style: italic;
}

.ledger-trades .ledger-fill { font-size: 11.5px; color: var(--text-secondary); }

/* Percentages ride under their amount rather than beside it, so a wide
   figure never pushes the column into a truncation. */
.ledger-pct {
    display: block;
    color: var(--text-muted);
    font-size: 10px;
    font-style: italic;
    line-height: 1.3;
}

/* Column widths */
/* Ticker | Qty | Value | Unrealized */
.ledger-positions .ledger-col-ticker { width: 30%; }
.ledger-positions .ledger-col-qty    { width: 16%; }
.ledger-positions .ledger-col-value  { width: 26%; }
.ledger-positions .ledger-col-pnl    { width: 28%; }

/* Time | Ticker | Side | Size | Value | Outcome */
.ledger-trades .ledger-col-time    { width: 10%; }
.ledger-trades .ledger-col-ticker  { width: 16%; }
.ledger-trades .ledger-col-side    { width: 11%; }
.ledger-trades .ledger-col-fill    { width: 25%; }
.ledger-trades .ledger-col-value   { width: 17%; }
.ledger-trades .ledger-col-outcome { width: 21%; }

/* --- Watchlist chips -------------------------------------- */

/* The watchlist is context, not a control surface — set it as a run of names
   on a rule rather than a tray of buttons. */
.trader-card-watchlist {
    display: flex;
    align-items: baseline;
    gap: 10px;
    margin-top: auto;   /* anchor to the foot of the card in an even grid row */
    padding-top: 6px;
    border-top: 1px solid var(--border-hairline);
    min-width: 0;
}

.trader-card-watchlist-label {
    font-size: 10px;
    letter-spacing: 1.6px;
    text-transform: uppercase;
    color: var(--text-muted);
    flex-shrink: 0;
}

/* One line, clipped: the full list rides in the title attribute. */
.trader-card-watchlist-chips {
    display: flex;
    flex-wrap: nowrap;
    gap: 2px 12px;
    flex: 1;
    min-width: 0;
    overflow: hidden;
}

.trader-card-watchlist-chip {
    font-size: 11px;
    color: var(--text-secondary);
    letter-spacing: 0.6px;
    white-space: nowrap;
}

.trader-card-watchlist-more {
    font-size: 11px;
    color: var(--text-muted);
    font-style: italic;
    flex-shrink: 0;
}

/* --- Universal color helpers for ledger cells ------------- */
.ledger-table td.positive { color: var(--accent-green); }
.ledger-table td.negative { color: var(--accent-red); }

/* --- Narrow column trims at very small widths -------------
   Below ~560px a six-column trade row cannot hold "200 × $412.10" without
   spilling. Value is the column that can go: it is size × price, which the
   row already shows. */
@media (max-width: 560px) {
    .ledger-table td { font-size: 11.5px; padding: 5px 5px 5px 0; }
    .ledger-table th { font-size: 9px; letter-spacing: 0.9px; }

    .ledger-trades .ledger-col-value,
    .ledger-trades .ledger-value { display: none; }

    .ledger-trades .ledger-col-time    { width: 12%; }
    .ledger-trades .ledger-col-ticker  { width: 20%; }
    .ledger-trades .ledger-col-side    { width: 13%; }
    .ledger-trades .ledger-col-fill    { width: 30%; }
    .ledger-trades .ledger-col-outcome { width: 25%; }
}

@media (prefers-reduced-motion: reduce) {
    .ledger-trades .trade-row-active td,
    .live-indicator,
    .feed-row.latest.pulse,
    .flip-cell.flip .flip-card {
        animation: none;
    }

    .ledger-trades .trade-row-active td {
        background-color: rgba(201, 169, 97, 0.045);
    }
}

/* Metrics grid inside an inline thesis expansion gets a single
   column in the narrow trader-card context. */
.ledger-details-cell .metrics-grid {
    grid-template-columns: 1fr;
}

@media (min-width: 600px) {
    .ledger-details-cell .metrics-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

/* ============================================================ */
/* Single-screen desktop layout                                  */
/* On a real desktop viewport the whole desk fits one screen:    */
/* traders 2x2 on the left, the floor feed as a full-height      */
/* right rail. Panels scroll internally. The document itself     */
/* still scrolls, but only past the desk: the house history      */
/* section sits below the 100dvh desk and is revealed by a       */
/* deliberate scroll.                                            */
/* ============================================================ */
@media (min-width: 1160px) and (min-height: 700px) {
    html, body {
        height: auto;
        min-height: 100%;
        overflow-x: hidden;
        overflow-y: auto;
    }

    .dashboard-page {
        height: 100dvh;
        display: flex;
        flex-direction: column;
        overflow: hidden;
    }

    .header { position: static; flex-shrink: 0; }
    .news-ticker { flex-shrink: 0; overflow: hidden; }
    turbo-frame#portfolio-bar { position: static; flex-shrink: 0; }

    /* One clipped line; a wrapped split-flap board would eat a whole row. */
    .flip-ticker { flex-wrap: nowrap; justify-content: flex-start; }

    .dashboard {
        flex: 1;
        min-height: 0;
        display: grid;
        grid-template-columns: minmax(0, 1fr) clamp(330px, 27vw, 440px);
        grid-template-rows: minmax(0, 1fr);
        gap: 6px;
        padding: 6px;
        max-width: none;
    }

    .dashboard.is-floor-hidden {
        grid-template-columns: minmax(0, 1fr);
    }

    .dashboard.is-floor-hidden .dashboard-main {
        grid-column: 1 / -1;
    }

    .dashboard-main {
        display: flex;
        flex-direction: column;
        gap: 0;
        min-height: 0;
        grid-column: 1;
        grid-row: 1;
    }

    turbo-frame#trader-grid {
        display: flex;
        flex: 1;
        min-height: 0;
    }

    turbo-frame#trader-grid > .trader-grid {
        flex: 1;
        min-height: 0;
    }

    .dashboard-side {
        display: flex;
        min-height: 0;
        grid-column: 2;
        grid-row: 1;
    }

    .dashboard-side .card {
        flex: 1;
        display: flex;
        flex-direction: column;
        min-height: 0;
    }

    .dashboard-side .card-body {
        flex: 1;
        min-height: 0;
        display: flex;
        flex-direction: column;
        overflow: hidden;
        padding: 0;
    }

    .dashboard-side turbo-frame#trading-floor,
    .dashboard-side [data-agent-filter-section] {
        display: flex;
        flex-direction: column;
        flex: 1;
        min-height: 0;
    }

    .dashboard-side .trading-floor-content {
        max-height: none;
        flex: 1;
        min-height: 0;
    }

    

    .trader-grid {
        flex: 1;
        min-height: 0;
        display: grid;
        grid-template-columns: repeat(2, minmax(0, 1fr));
        grid-template-rows: repeat(2, minmax(0, 1fr));
        gap: 6px;
    }

    .trader-card {
        min-height: 0;
        overflow: hidden;
    }

    /* The removed activity band gives both ledgers a real reading budget.
       Positions may use just under half the card; trades take the balance. */
    .trader-card-positions {
        flex-shrink: 0;
        max-height: 46%;
        overflow-y: auto;
    }

    .trader-card-trades {
        flex: 1;
        min-height: 104px;
        overflow-y: auto;
        margin-bottom: 0;
    }
}

/* On shorter desktops the watchlist line is the first thing to go — trades
   and positions matter more than context chips. */
@media (min-width: 1160px) and (min-height: 700px) and (max-height: 900px) {
    .trader-card-watchlist { display: none; }
}

/* Tall desktops have room for a full book before the positions pane
   starts scrolling. */
@media (min-width: 1160px) and (min-height: 980px) {
    .trader-card-positions { max-height: 50%; }
}
/* ============================================================ */
/* House history — trading logic and operations timeline,        */
/* rendered below the live desk. Reads as a progression, not a   */
/* second dashboard.                                              */
/* ============================================================ */

.house-history {
    border-top: 1px solid var(--border-gold);
    background:
        linear-gradient(180deg, rgba(201, 169, 97, 0.05) 0, transparent 120px),
        var(--bg-primary);
    padding: 40px 16px 64px;
}

.house-history-inner {
    max-width: 960px;
    margin: 0 auto;
}

.house-history-head {
    display: flex;
    justify-content: space-between;
    align-items: flex-end;
    gap: 16px;
    flex-wrap: wrap;
    margin-bottom: 18px;
}

.house-history-title {
    font-family: 'Libre Baskerville', serif;
    font-size: 24px;
    font-weight: 700;
    color: var(--accent-cream);
    letter-spacing: 0.3px;
    margin: 0 0 4px;
}

.house-history-kicker {
    font-size: 13px;
    color: var(--text-secondary);
    font-style: italic;
    margin: 0;
}

.house-history-updated {
    margin-left: 10px;
    color: var(--text-muted);
    font-style: normal;
    font-size: 12px;
    letter-spacing: 0.4px;
    text-transform: uppercase;
}

.house-history-top {
    font-size: 12px;
    color: var(--text-secondary);
    text-decoration: none;
    border-bottom: 1px solid transparent;
    white-space: nowrap;
}

.house-history-top:hover {
    color: var(--accent-gold);
    border-color: var(--accent-gold);
}

.house-history-intro {
    font-size: 14.5px;
    line-height: 1.6;
    color: var(--text-secondary);
    max-width: 760px;
    margin: 0 0 28px;
}

.house-history-intro p { margin: 0 0 8px; }

.history-eras {
    list-style: none;
    margin: 0;
    padding: 0;
    position: relative;
}

.history-eras::before {
    content: "";
    position: absolute;
    left: 7px;
    top: 6px;
    bottom: 6px;
    width: 1px;
    background: var(--border-gold);
    opacity: 0.6;
}

.history-era {
    position: relative;
    display: grid;
    grid-template-columns: 16px minmax(0, 1fr);
    gap: 0 18px;
    padding: 0 0 30px;
}

.history-era-marker {
    width: 15px;
    height: 15px;
    border-radius: 50%;
    background: var(--bg-primary);
    border: 2px solid var(--accent-gold);
    margin-top: 6px;
    box-shadow: 0 0 0 4px var(--bg-primary);
}

.history-era-title {
    font-family: 'Libre Baskerville', serif;
    font-size: 17px;
    font-weight: 700;
    color: var(--accent-gold);
    margin: 0 0 8px;
    letter-spacing: 0.2px;
}

.history-era-summary {
    font-size: 14px;
    line-height: 1.6;
    color: var(--text-secondary);
    margin: 0 0 12px;
    max-width: 760px;
}

.history-entries {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.history-entry {
    display: grid;
    grid-template-columns: 56px minmax(0, 1fr);
    gap: 0 12px;
    font-size: 13.5px;
    line-height: 1.5;
    color: var(--text-primary);
}

.history-entry-date {
    font-variant-numeric: tabular-nums;
    color: var(--text-muted);
    font-size: 12px;
    letter-spacing: 0.4px;
    text-transform: uppercase;
    padding-top: 2px;
    white-space: nowrap;
}

.history-entry-text code {
    font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
    font-size: 12px;
    color: var(--accent-cream);
    background: var(--bg-tertiary);
    padding: 0 4px;
    border-radius: 2px;
}

.history-entry-text a {
    color: var(--accent-gold);
    text-decoration: none;
    border-bottom: 1px solid var(--border-gold);
}

@media (max-width: 600px) {
    .house-history { padding: 28px 12px 48px; }
    .house-history-title { font-size: 20px; }
    .history-entry { grid-template-columns: 1fr; gap: 0; }
    .history-entry-date { padding-top: 0; }
}

@media (prefers-reduced-motion: no-preference) {
    .history-era { transition: opacity 0.3s ease; }
}
