:root {
  --bg: #07090d;
  --panel: #0e1218;
  --panel-2: #121821;
  --head: #151c26;
  --border: #1e2733;
  --border-2: #2a3544;
  --text: #d3dae3;
  --muted: #7b8796;
  --dim: #56606d;
  --up: #1fc28b;
  --up-bg: rgba(31, 194, 139, .14);
  --down: #f2545b;
  --down-bg: rgba(242, 84, 91, .14);
  --accent: #fa6a2d;       /* Gator orange, toned for dark UI */
  --accent-2: #3b82f6;     /* Gator blue, lifted for contrast */
  --brand-blue: #4f8bff;   /* wordmark blue, bright enough to read on the dark bar */
  --warn: #f5b041;
  --mono: "JetBrains Mono", ui-monospace, "SFMono-Regular", Consolas, monospace;
  --sans: "Inter", system-ui, -apple-system, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--text); font: 12px/1.35 var(--sans); }
body { overflow: hidden; }
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--accent-2); }
[hidden] { display: none !important; }
.mono, td.num, .num { font-family: var(--mono); font-variant-numeric: tabular-nums; }
.up { color: var(--up) !important; }
.down { color: var(--down) !important; }
.muted { color: var(--muted); }
.dim { color: var(--dim); }

/* ---------------------------------------------------------------- buttons & inputs */
.btn { background: var(--panel-2); border: 1px solid var(--border-2); border-radius: 3px; padding: 4px 9px; cursor: pointer; white-space: nowrap; }
.btn:hover { border-color: #3d4b5e; background: #17202b; }
.btn:disabled { opacity: .5; cursor: default; }
.btn.sm { padding: 1px 6px; font-size: 11px; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 600; }
.btn.buy { background: var(--up); border-color: var(--up); color: #04130d; font-weight: 700; }
.btn.sell { background: var(--down); border-color: var(--down); color: #1a0406; font-weight: 700; }
.btn.ghost { background: transparent; }
.btn.danger { color: var(--down); border-color: rgba(242,84,91,.5); }
.btn.active { background: #1c2735; border-color: var(--accent-2); color: #fff; }
input.in, select.in, textarea.in {
  background: #0a0e13; border: 1px solid var(--border-2); border-radius: 3px; padding: 4px 6px; outline: none; min-width: 0;
}
input.in:focus, select.in:focus, textarea.in:focus { border-color: var(--accent-2); }
label.fld { display: flex; flex-direction: column; gap: 2px; color: var(--muted); font-size: 11px; }
label.fld > .in { color: var(--text); font-size: 12px; }

/* ---------------------------------------------------------------- top bar */
.topbar { height: 40px; display: flex; align-items: center; gap: 10px; padding: 0 10px; background: #0b0f15; border-bottom: 1px solid var(--border); }
.brand { font-weight: 800; letter-spacing: .3px; white-space: nowrap; }
.brand { display: flex; align-items: center; gap: 0; }
.brand-logo { width: 22px; height: 22px; margin-right: 8px; flex: none; }
.b-floor { color: var(--accent); }
.b-league { color: var(--brand-blue); margin-left: .28em; }
.sim-badge { background: #b3151d; color: #fff; font-weight: 800; font-size: 10.5px; letter-spacing: .6px; padding: 3px 7px; border-radius: 2px; white-space: nowrap; }
.chip { border: 1px solid var(--border-2); border-radius: 10px; padding: 2px 8px; font-size: 11px; color: var(--muted); white-space: nowrap; }
.chip.live { color: var(--up); border-color: rgba(31,194,139,.4); }
.chip.closed { color: var(--warn); border-color: rgba(245,176,65,.4); }
.chip.synthetic { color: var(--warn); border-color: rgba(245,176,65,.6); }
.metrics { display: flex; gap: 14px; margin-left: 4px; overflow: hidden; flex: 1 1 auto; min-width: 0; }
.metric.hide { display: none; }
.metric { display: flex; flex-direction: column; line-height: 1.1; }
.metric .k { font-size: 9.5px; color: var(--dim); text-transform: uppercase; letter-spacing: .5px; }
.metric .v { font-family: var(--mono); font-size: 12.5px; }
.spacer { flex: 1; }
.userbox { display: flex; align-items: center; gap: 8px; color: var(--muted); white-space: nowrap; flex: none; }
.userbox .who { max-width: 170px; overflow: hidden; text-overflow: ellipsis; }
.topbar > .chip, .topbar > .sim-badge, .topbar > .brand, #acct-sel { flex: none; }
#acct-sel { max-width: 190px; }
@media (max-width: 1440px) { .userbox .who { display: none; } }
@media (max-width: 1280px) { .topbar .sim-badge .long { display: none; } }

/* ---------------------------------------------------------------- grid & panels */
#grid-wrap { position: absolute; top: 40px; bottom: 22px; left: 0; right: 0; overflow: auto; }
.grid-stack { background: var(--bg); }
.grid-stack-item-content { inset: 2px !important; }
.panel { position: absolute; inset: 0; display: flex; flex-direction: column; background: var(--panel); border: 1px solid var(--border); border-radius: 3px; overflow: hidden; }
.panel-head { display: flex; align-items: center; gap: 6px; height: 26px; min-height: 26px; padding: 0 6px; background: var(--head); border-bottom: 1px solid var(--border); cursor: move; user-select: none; }
.panel-head .title { font-size: 10.5px; font-weight: 700; letter-spacing: .6px; text-transform: uppercase; color: #aab4c0; white-space: nowrap; }
.panel-head .tools { display: flex; gap: 4px; align-items: center; margin-left: auto; cursor: default; }
.panel-head .tools > * { cursor: pointer; }
.panel-body { flex: 1; overflow: auto; position: relative; min-height: 0; container-type: inline-size; }
.tabs { display: flex; gap: 2px; }
.tab { background: none; border: 0; color: var(--muted); padding: 3px 6px; cursor: pointer; font-size: 11px; border-radius: 2px; }
.tab.on { color: #fff; background: #1c2735; }

/* ---------------------------------------------------------------- tables */
table.t { width: 100%; border-collapse: collapse; }
table.t th { position: sticky; top: 0; background: var(--panel-2); color: var(--dim); font-weight: 600; font-size: 10.5px; text-transform: uppercase; letter-spacing: .3px; text-align: right; padding: 3px 6px; border-bottom: 1px solid var(--border); z-index: 1; white-space: nowrap; }
table.t td { padding: 2px 6px; text-align: right; border-bottom: 1px solid #141a22; white-space: nowrap; }
table.t th:first-child, table.t td:first-child { text-align: left; }
table.t td.l, table.t th.l { text-align: left; }
table.t tr.click { cursor: pointer; }
table.t tbody tr:hover { background: #131a24; }
table.t tr.sel { background: #16202d; }
.empty { color: var(--dim); padding: 14px; text-align: center; }

@keyframes flashUp { from { background: rgba(31,194,139,.35); } to { background: transparent; } }
@keyframes flashDown { from { background: rgba(242,84,91,.35); } to { background: transparent; } }
.flash-up { animation: flashUp .6s ease-out; }
.flash-down { animation: flashDown .6s ease-out; }

/* ---------------------------------------------------------------- chart */
.chart-wrap { position: absolute; inset: 0; display: flex; flex-direction: column; }
.chart-main { flex: 1; min-height: 0; position: relative; }
.chart-sub { height: 26%; min-height: 60px; border-top: 1px solid var(--border); position: relative; }
.chart-legend { position: absolute; top: 4px; left: 8px; z-index: 3; font-family: var(--mono); font-size: 11px; pointer-events: none; color: var(--muted); }
.chart-legend b { color: var(--text); font-size: 13px; margin-right: 8px; font-family: var(--sans); }
.sym-input { width: 74px; text-transform: uppercase; font-weight: 700; }

/* ---------------------------------------------------------------- order ticket */
.ticket { padding: 6px 7px; display: flex; flex-direction: column; gap: 5px; }
.ticket label.fld { gap: 1px; }
.ticket .in { padding: 3px 5px; }
.ticket .quote { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 4px; text-align: center; }
.ticket .quote div { background: var(--panel-2); border: 1px solid var(--border); border-radius: 3px; padding: 2px 1px; cursor: pointer; min-width: 0; }
.ticket .quote .k { font-size: 9.5px; color: var(--dim); text-transform: uppercase; }
.ticket .quote .v { font-family: var(--mono); font-size: 13px; }
.action-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 4px; }
.action-grid .btn { padding: 6px 0; font-weight: 700; font-size: 11px; }
.action-grid .btn.on-buy { background: var(--up-bg); border-color: var(--up); color: var(--up); }
.action-grid .btn.on-sell { background: var(--down-bg); border-color: var(--down); color: var(--down); }
.action-grid .btn:disabled { opacity: .3; }
.attach-toggle { font-size: 11px; }
.attach { display: flex; flex-direction: column; gap: 4px; padding: 5px; border: 1px dashed var(--border-2); border-radius: 3px; }
.attach-row { display: flex; gap: 4px; align-items: center; min-width: 0; }
.attach-row .in.num { flex: 1 1 0; min-width: 0; width: 0; }
.attach-row select.in { flex: none; width: 62px; padding: 3px 2px; }
.chk { display: flex; align-items: center; gap: 4px; white-space: nowrap; font-size: 11px; color: var(--muted); flex: none; width: 34px; }
.pct-btns { display: flex; gap: 3px; align-items: center; font-size: 10.5px; color: var(--dim); }
.pct-btns .btn { flex: 1; padding: 1px 0; font-size: 10.5px; }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.qty-presets { display: flex; gap: 3px; }
.qty-presets .btn { flex: 1; padding: 2px 0; font-size: 10.5px; min-width: 0; }
.submit-order { padding: 7px 4px; font-size: 12.5px; white-space: normal; }
.est { display: flex; justify-content: space-between; gap: 6px; color: var(--muted); font-size: 11px; }
.est span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* ---------------------------------------------------------------- level 2 */
.l2 { display: grid; grid-template-columns: 1fr 1fr; gap: 1px; background: var(--border); min-height: 100%; }
.l2 > div { background: var(--panel); }
.l2 td { position: relative; cursor: pointer; }
.l2 .bar { position: absolute; top: 1px; bottom: 1px; opacity: .18; z-index: 0; }
.l2 .bid .bar { right: 0; background: var(--up); }
.l2 .ask .bar { left: 0; background: var(--down); }
.l2 td span { position: relative; z-index: 1; }
.l2-note { font-size: 10px; color: var(--dim); padding: 3px 6px; border-top: 1px solid var(--border); background: var(--panel); position: sticky; bottom: 0; }

/* ---------------------------------------------------------------- options */
.opt-chain td.c-bid, .opt-chain td.c-ask, .opt-chain td.p-bid, .opt-chain td.p-ask { cursor: pointer; }
.opt-chain td.c-bid:hover, .opt-chain td.p-bid:hover { background: var(--down-bg); }
.opt-chain td.c-ask:hover, .opt-chain td.p-ask:hover { background: var(--up-bg); }
.opt-chain td.strike { text-align: center; background: #10161f; font-weight: 700; color: #fff; }
.opt-chain tr.itm-c td.call-side { background: rgba(59,130,246,.07); }
.opt-chain tr.itm-p td.put-side { background: rgba(59,130,246,.07); }
.opt-chain tr.atm td.strike { color: var(--accent); }
.opt-layout { display: grid; grid-template-columns: 1fr 260px; height: 100%; }
.opt-layout > div { overflow: auto; min-height: 0; }
.builder { border-left: 1px solid var(--border); padding: 6px; display: flex; flex-direction: column; gap: 6px; }
.leg { display: grid; grid-template-columns: 34px 1fr 44px 18px; gap: 4px; align-items: center; font-size: 11px; }
.leg .side { font-weight: 700; }
canvas.payoff { width: 100%; height: 90px; background: #0a0e13; border: 1px solid var(--border); border-radius: 3px; }

/* ---------------------------------------------------------------- misc panels */
.news-item { padding: 5px 8px; border-bottom: 1px solid #141a22; }
.news-item a { color: var(--text); text-decoration: none; }
.news-item a:hover { color: #fff; text-decoration: underline; }
.news-item .meta { color: var(--dim); font-size: 10.5px; margin-top: 2px; }
.journal-form { display: flex; gap: 6px; padding: 6px; border-bottom: 1px solid var(--border); }
.journal-form textarea { flex: 1; resize: none; height: 44px; }
.hash { font-family: var(--mono); color: var(--muted); font-size: 11px; }
.ok-badge { color: var(--up); font-weight: 700; }
.bad-badge { color: var(--down); font-weight: 700; }
.pad { padding: 8px; }
.notice { margin: 8px; padding: 8px 10px; border: 1px solid rgba(245,176,65,.4); background: rgba(245,176,65,.08); color: #f3d59b; border-radius: 3px; }

.footer { position: absolute; bottom: 0; left: 0; right: 0; height: 22px; display: flex; align-items: center; gap: 14px; padding: 0 10px; background: #0b0f15; border-top: 1px solid var(--border); color: var(--dim); font-size: 10.5px; white-space: nowrap; overflow: hidden; }
.footer kbd { font-family: var(--mono); background: #151c26; border: 1px solid var(--border-2); border-radius: 2px; padding: 0 4px; color: var(--muted); }

/* ---------------------------------------------------------------- toasts & modal */
#toasts { position: fixed; top: 48px; right: 12px; display: flex; flex-direction: column; gap: 6px; z-index: 1000; max-width: 380px; }
.toast { background: #16202b; border: 1px solid var(--border-2); border-left: 3px solid var(--accent-2); padding: 8px 10px; border-radius: 3px; box-shadow: 0 6px 20px rgba(0,0,0,.4); }
.toast.ok { border-left-color: var(--up); }
.toast.err { border-left-color: var(--down); }
.modal-bg { position: fixed; inset: 0; background: rgba(0,0,0,.6); display: flex; align-items: center; justify-content: center; z-index: 900; padding: 16px; }
.modal { background: var(--panel); border: 1px solid var(--border-2); border-radius: 6px; max-width: 560px; width: 100%; max-height: 90vh; overflow: auto; padding: 18px; }
.modal h2 { margin: 0 0 6px; font-size: 18px; }
.rules { white-space: pre-wrap; background: #0a0e13; border: 1px solid var(--border); padding: 8px; border-radius: 3px; max-height: 220px; overflow: auto; }

/* ---------------------------------------------------------------- login */
.login-wrap { min-height: 100%; display: flex; align-items: center; justify-content: center; padding: 24px 16px; overflow: auto; }
.login-card { width: 100%; max-width: 400px; background: var(--panel); border: 1px solid var(--border-2); border-radius: 8px; padding: 26px; }
.login-card h1 { margin: 0; font-size: 22px; letter-spacing: -.2px; }
.login-card h1.brand .brand-logo { width: 28px; height: 28px; }
.login-card p { color: var(--muted); }
.login-card form { display: flex; flex-direction: column; gap: 10px; margin-top: 16px; }
.login-card .in { padding: 9px 10px; font-size: 14px; }
.login-card .btn { padding: 9px; font-size: 14px; }
.login-card .err { color: var(--down); min-height: 16px; }
.code-input { letter-spacing: 8px; font-family: var(--mono); text-align: center; font-size: 20px !important; }
.invite-box { margin-top: 12px; padding: 10px; border: 1px solid rgba(59,130,246,.5); background: rgba(59,130,246,.08); border-radius: 4px; }

/* ---------------------------------------------------------------- statement pages */
body.doc { overflow: auto; font-size: 15px; line-height: 1.6; }
body.doc .topbar { position: sticky; top: 0; z-index: 5; }
body.doc a.brand { text-decoration: none; }
.doc-wrap { max-width: 780px; margin: 0 auto; padding: 28px 16px 64px; }
.doc-wrap h1 { font-size: 28px; margin: 8px 0 4px; letter-spacing: -.3px; }
.doc-wrap h2 { font-size: 18px; margin: 30px 0 8px; color: #fff; }
.doc-wrap p, .doc-wrap li { color: #c3cbd5; }
.doc-wrap ul { padding-left: 22px; }
.doc-wrap li { margin: 5px 0; }
.doc-wrap code, .doc-wrap kbd { font-family: var(--mono); font-size: 13px; background: #151c26; border: 1px solid var(--border-2); border-radius: 3px; padding: 0 4px; }
.doc-meta { color: var(--muted) !important; font-size: 13px; }
.doc-note { border-left: 3px solid var(--brand-blue); padding: 6px 12px; background: rgba(79,139,255,.08); }
.doc-table { width: 100%; border-collapse: collapse; margin: 8px 0; font-size: 14px; }
.doc-table th, .doc-table td { text-align: left; vertical-align: top; padding: 8px 10px; border-bottom: 1px solid var(--border); }
.doc-table th { color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: .4px; }
.doc-links { margin-top: 36px; }
.legal-links a { color: var(--muted); }
.legal-links a:hover { color: var(--text); }

::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-thumb { background: #232d3a; border-radius: 4px; }
::-webkit-scrollbar-track { background: transparent; }

/* ---------------------------------------------------------------- admin */
body.admin { overflow: auto; }
.admin-shell { display: grid; grid-template-columns: 190px 1fr; min-height: calc(100% - 40px); }
.admin-nav { border-right: 1px solid var(--border); padding: 10px 8px; display: flex; flex-direction: column; gap: 4px; background: #0a0d12; }
.admin-nav button { text-align: left; background: none; border: 0; padding: 8px 10px; border-radius: 4px; cursor: pointer; color: var(--muted); font-size: 13px; }
.admin-nav button.on { background: #16202d; color: #fff; }
.admin-main { padding: 16px 20px; overflow: auto; }
.admin-main h2 { margin: 0 0 12px; font-size: 18px; }
.card { background: var(--panel); border: 1px solid var(--border); border-radius: 6px; padding: 14px; margin-bottom: 12px; }
.card h3 { margin: 0 0 4px; font-size: 15px; }
.form-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 10px; }
.status { display: inline-block; padding: 1px 8px; border-radius: 10px; font-size: 11px; font-weight: 700; text-transform: uppercase; }
.status.scheduled { background: rgba(245,176,65,.15); color: var(--warn); }
.status.live { background: var(--up-bg); color: var(--up); }
.status.ended { background: #1b222c; color: var(--muted); }
.row-actions { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; align-items: center; }
.invite-row { display: flex; gap: 6px; margin-top: 10px; }
.invite-row input { flex: 1; font-family: var(--mono); font-size: 11.5px; }
.tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(112px, 1fr)); gap: 8px; margin: 10px 0; }
.tile { background: var(--panel-2); border: 1px solid var(--border); border-radius: 4px; padding: 8px; }
.tile .k { font-size: 10px; color: var(--dim); text-transform: uppercase; letter-spacing: .4px; }
.tile .v { font-family: var(--mono); font-size: 15px; margin-top: 2px; }
.drawer-bg { position: fixed; inset: 0; background: rgba(0,0,0,.55); z-index: 800; display: flex; justify-content: flex-end; }
.drawer { width: min(1100px, 100%); height: 100%; background: var(--bg); border-left: 1px solid var(--border-2); overflow: auto; padding: 16px 20px; }
.section-title { margin: 16px 0 6px; font-size: 12px; text-transform: uppercase; letter-spacing: .5px; color: var(--muted); }
.scroll-box { max-height: 320px; overflow: auto; border: 1px solid var(--border); border-radius: 4px; }
.curve { height: 220px; border: 1px solid var(--border); border-radius: 4px; }

@media (max-width: 760px) {
  .admin-shell { grid-template-columns: 1fr; }
  .admin-nav { flex-direction: row; border-right: 0; border-bottom: 1px solid var(--border); overflow-x: auto; }
  .metrics { display: none; }
}

/* ---------------------------------------------------------------- narrow-panel columns (container queries)
   Panels drop secondary columns instead of scrolling sideways; widen a panel and they come back. */
@container (max-width: 380px) { .wl .c-bid, .wl .c-ask { display: none; } }
@container (max-width: 300px) { .wl .c-vol { display: none; } }
@container (max-width: 300px) { .l2 .mm { display: none; } }
@container (max-width: 880px) { .pos .c-day { display: none; } }
@container (max-width: 760px) { .pos .c-real { display: none; } }
@container (max-width: 680px) { .ord .c-tif, .ord .c-placed { display: none; } }
@container (max-width: 520px) { .ord .c-fill { display: none; } }
table.t td, table.t th { padding-left: 5px; padding-right: 5px; }
/* Form grids: let inputs shrink to their column instead of forcing the panel wider. */
.row2 > * { min-width: 0; }
.ticket label.fld > .in, .ticket label.fld > div > .in { width: 100%; min-width: 0; }
/* Panel headers: the title gives way (ellipsis) before the tools can overflow. */
.panel-head .title { overflow: hidden; text-overflow: ellipsis; min-width: 0; flex: 0 1 auto; }
.panel-head .tools { flex: 0 0 auto; }
@container (max-width: 560px) { .ord .c-fill { display: none; } }

/* ---------------------------------------------------------------- guest mode */
.guest-note { color: var(--muted); font-size: 12px; align-items: center; white-space: nowrap; text-overflow: ellipsis; }
.login-btn { padding: 5px 16px; }
.login-modal .login-wrap { min-height: 0; padding: 0; }
.login-modal .login-card { box-shadow: 0 20px 60px rgba(0,0,0,.6); }
.guest-prompt { height: 100%; min-height: 90px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 8px; text-align: center; padding: 10px; color: var(--muted); }
.guest-prompt p { margin: 0; }

.usage-bar { height: 10px; background: var(--panel-2); border: 1px solid var(--border); border-radius: 5px; overflow: hidden; margin: 8px 0 4px; }
.usage-bar > div { height: 100%; border-radius: 5px; transition: width .4s; }
