/* Ghost Trader: bot dashboard. Tokens match the marketing site (ghost-trader/app/globals.css). */
@font-face { font-family: "Inter"; src: url("../fonts/inter-latin.woff2") format("woff2"); font-weight: 400 800; font-display: swap; }
:root {
  --bg: #07080b; --bg-2: #0c0e13; --panel: #10131a; --panel-2: #141823;
  --line: rgba(255,255,255,.08); --line-2: rgba(255,255,255,.14);
  --text: #eef1f6; --muted: #a3abba; --dim: #6f7889;
  --mint: #8af7d0; --violet: #8b7bff; --warn: #ffb86b; --loss: #ff7a8f;
  --mint-bg: rgba(138,247,208,.08); --violet-bg: rgba(139,123,255,.10); --loss-bg: rgba(255,122,143,.10); --warn-bg: rgba(255,184,107,.10);
  --grad: linear-gradient(100deg, var(--mint), var(--violet));
  --radius: 18px; --radius-sm: 12px;
  --sans: "Inter", ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
  --mono: ui-monospace, "SFMono-Regular", Menlo, Consolas, monospace;
  --tabbar-h: 64px;
  color-scheme: dark;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--text); font-family: var(--sans); font-size: 15px; line-height: 1.5;
  -webkit-font-smoothing: antialiased; padding-bottom: calc(var(--tabbar-h) + env(safe-area-inset-bottom) + 16px); }
body::before { content: ""; position: fixed; inset: 0 0 auto; height: 520px; pointer-events: none; z-index: -1;
  background: radial-gradient(520px 260px at 10% -10%, rgba(139,123,255,.16), transparent 70%), radial-gradient(480px 240px at 90% 0%, rgba(138,247,208,.10), transparent 70%); }
h1, h2, h3 { margin: 0; letter-spacing: -.02em; line-height: 1.15; }
p { margin: 0; }
button, select, input { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--mint); outline-offset: 2px; border-radius: 8px; }
.skip-link { position: absolute; left: -999px; top: 8px; background: var(--mint); color: #000; padding: 8px 12px; border-radius: 8px; z-index: 100; }
.skip-link:focus { left: 8px; }
.num { font-variant-numeric: tabular-nums; font-feature-settings: "tnum"; }
.mono { font-family: var(--mono); }
.muted { color: var(--muted); } .dim { color: var(--dim); }
.pos { color: var(--mint); } .neg { color: var(--loss); } .warn { color: var(--warn); }
.wrap { max-width: 1280px; margin: 0 auto; padding: 0 16px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* Top bar */
/* backdrop blur lives on ::before so the fixed mobile tab bar inside the header isn't trapped by it */
.topbar { position: sticky; top: 0; z-index: 40; border-bottom: 1px solid var(--line); }
.topbar::before { content: ""; position: absolute; inset: 0; z-index: -1; background: rgba(7,8,11,.8); backdrop-filter: saturate(160%) blur(14px); -webkit-backdrop-filter: saturate(160%) blur(14px); }
.topbar-in { display: flex; flex-wrap: wrap; align-items: center; column-gap: 10px; }
.brand, .top-right { height: 58px; }
.brand { display: inline-flex; align-items: center; gap: 10px; font-weight: 750; letter-spacing: -.01em; text-decoration: none; color: var(--text); min-width: 0; }
.brand-name { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.brand em { font-style: normal; font-weight: 500; color: var(--muted); display: none; }
.top-right { margin-left: auto; display: flex; align-items: center; gap: 8px; }
.badge { display: inline-flex; align-items: center; gap: 6px; height: 26px; padding: 0 10px; border-radius: 999px; font-size: 11.5px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; border: 1px solid var(--line-2); background: rgba(255,255,255,.04); white-space: nowrap; }
.badge.paper { color: var(--violet); border-color: rgba(139,123,255,.35); background: var(--violet-bg); }
.badge.live { color: #1a0509; background: var(--loss); border-color: var(--loss); box-shadow: 0 0 0 3px rgba(255,122,143,.18); }
.status { display: inline-flex; align-items: center; gap: 7px; font-size: 12.5px; color: var(--muted); white-space: nowrap; }
.status .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--dim); flex: none; }
.status.ok .dot { background: var(--mint); animation: pulse 2s infinite; }
.status.stale .dot { background: var(--warn); }
.status.down .dot { background: var(--loss); }
.status-label { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
@keyframes pulse { 0% { box-shadow: 0 0 0 0 rgba(138,247,208,.55); } 70% { box-shadow: 0 0 0 7px rgba(138,247,208,0); } 100% { box-shadow: 0 0 0 0 rgba(138,247,208,0); } }

/* Header quick stats */
.quick { order: 10; width: 100%; display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; padding: 0 0 12px; }
.quick-item { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 8px 12px; min-width: 0; }
.quick-label { font-size: 10.5px; letter-spacing: .1em; text-transform: uppercase; color: var(--dim); }
.quick-value { font-weight: 700; font-size: 16px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* Tabs: bottom bar on mobile, inline on desktop */
.tabs { position: fixed; left: 0; right: 0; bottom: 0; z-index: 45; display: grid; grid-template-columns: repeat(4, 1fr);
  height: calc(var(--tabbar-h) + env(safe-area-inset-bottom)); padding-bottom: env(safe-area-inset-bottom);
  background: rgba(12,14,19,.92); backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px); border-top: 1px solid var(--line); }
.tab { appearance: none; background: none; border: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px; color: var(--dim); font-size: 11.5px; font-weight: 600; cursor: pointer; }
.tab svg { width: 22px; height: 22px; }
.tab[aria-selected="true"] { color: var(--mint); }

main { padding-top: 20px; }
.view[hidden] { display: none !important; }
.section-title { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; margin: 26px 0 12px; }
.section-title h2 { font-size: 17px; font-weight: 700; }
.section-title .hint { font-size: 12.5px; color: var(--dim); }

/* Cards */
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); }
.card-pad { padding: 16px; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 14px 16px; border-bottom: 1px solid var(--line); }
.card-head h3 { font-size: 14px; font-weight: 650; }
.card-head .count { font-size: 12px; color: var(--muted); background: rgba(255,255,255,.05); border: 1px solid var(--line); border-radius: 999px; padding: 1px 8px; }

.kpis { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; }
.kpi { padding: 14px; position: relative; overflow: hidden; min-height: 98px; }
.kpi-label { font-size: 11px; letter-spacing: .1em; text-transform: uppercase; color: var(--dim); display: flex; align-items: center; gap: 6px; }
.kpi-value { font-size: 24px; font-weight: 780; letter-spacing: -.02em; margin-top: 6px; white-space: nowrap; }
.kpi-sub { font-size: 12px; color: var(--muted); margin-top: 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.kpi.accent::after { content: ""; position: absolute; inset: auto -30% -60% auto; width: 160px; height: 160px; background: var(--grad); filter: blur(60px); opacity: .14; }
.meter { height: 6px; border-radius: 99px; background: rgba(255,255,255,.07); margin-top: 10px; overflow: hidden; }
.meter > i { display: block; height: 100%; border-radius: inherit; background: var(--grad); transition: width .4s ease; }
.meter.hot > i { background: linear-gradient(90deg, var(--warn), var(--loss)); }

/* Equity */
.equity-head { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 10px; padding: 16px 16px 4px; }
.equity-value { font-size: 28px; font-weight: 800; letter-spacing: -.025em; }
.seg { display: inline-flex; background: rgba(255,255,255,.04); border: 1px solid var(--line); border-radius: 999px; padding: 3px; }
.seg button { appearance: none; border: 0; background: none; padding: 5px 12px; border-radius: 999px; font-size: 12.5px; font-weight: 600; color: var(--muted); cursor: pointer; min-height: 30px; }
.seg button[aria-pressed="true"] { background: var(--panel-2); color: var(--text); box-shadow: inset 0 0 0 1px var(--line-2); }
.chart { position: relative; height: 220px; margin: 8px 6px 10px; }
.chart > svg { display: block; width: 100%; height: 100%; overflow: visible; }
.chart .grid { stroke: rgba(255,255,255,.06); stroke-dasharray: 3 5; }
.chart .axis { fill: var(--dim); font-size: 10.5px; font-family: var(--sans); }
.chart .base { stroke: rgba(255,255,255,.22); stroke-dasharray: 4 4; }
.chart .cross { stroke: rgba(255,255,255,.3); }
.tooltip { position: absolute; pointer-events: none; background: rgba(20,24,35,.96); border: 1px solid var(--line-2); border-radius: 10px; padding: 7px 10px; font-size: 12px; white-space: nowrap; transform: translate(-50%, -110%); box-shadow: 0 10px 30px -10px rgba(0,0,0,.8); }
.tooltip b { display: block; font-size: 13px; }

/* Layout grids */
.grid-2 { display: grid; gap: 14px; }
.stack { display: grid; gap: 14px; }

/* Positions */
.positions { display: grid; gap: 10px; padding: 12px; }
.pos-card { background: var(--bg-2); border: 1px solid var(--line); border-radius: 14px; padding: 12px 14px; display: grid; gap: 8px; }
.pos-top { display: flex; align-items: center; gap: 8px; }
.pos-title { font-weight: 650; }
.pos-top .chip { margin-left: auto; }
.pos-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; }
.pos-grid div { min-width: 0; }
.pos-grid .l { font-size: 10.5px; color: var(--dim); text-transform: uppercase; letter-spacing: .08em; }
.pos-grid .v { font-weight: 650; font-size: 14px; }
.timebar { height: 4px; border-radius: 99px; background: rgba(255,255,255,.07); overflow: hidden; }
.timebar i { display: block; height: 100%; background: var(--violet); }

/* Chips */
.chip { display: inline-flex; align-items: center; gap: 5px; height: 22px; padding: 0 9px; border-radius: 999px; font-size: 11.5px; font-weight: 700; letter-spacing: .02em; border: 1px solid transparent; white-space: nowrap; }
.chip.up { color: var(--mint); background: var(--mint-bg); border-color: rgba(138,247,208,.22); }
.chip.down { color: var(--loss); background: var(--loss-bg); border-color: rgba(255,122,143,.25); }
.chip.win { color: #06110d; background: var(--mint); }
.chip.loss { color: #1a0509; background: var(--loss); }
.chip.open { color: var(--violet); background: var(--violet-bg); border-color: rgba(139,123,255,.3); }
.chip.est { color: var(--warn); background: var(--warn-bg); border-color: rgba(255,184,107,.25); }
.chip.neutral { color: var(--muted); background: rgba(255,255,255,.05); border-color: var(--line); }

/* Feed */
.feed { list-style: none; margin: 0; padding: 4px 0; max-height: 420px; overflow-y: auto; }
.feed li { display: grid; grid-template-columns: 10px 1fr auto; gap: 10px; align-items: baseline; padding: 9px 16px; font-size: 13px; border-bottom: 1px solid var(--line); }
.feed li:last-child { border-bottom: 0; }
.feed .ev-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--violet); transform: translateY(-1px); }
.feed li.ok .ev-dot { background: var(--mint); } .feed li.bad .ev-dot, .feed li.error .ev-dot, .feed li.critical .ev-dot { background: var(--loss); }
.feed li.error, .feed li.critical { color: var(--loss); }
.feed .ev-time { font-size: 11.5px; color: var(--dim); white-space: nowrap; }
.feed .ev-msg { overflow-wrap: anywhere; color: var(--muted); }

/* Tables -> cards on mobile */
.table { width: 100%; border-collapse: collapse; }
.table th { font-size: 11px; letter-spacing: .08em; text-transform: uppercase; color: var(--dim); font-weight: 600; text-align: left; padding: 10px 14px; border-bottom: 1px solid var(--line); white-space: nowrap; }
.table td { padding: 11px 14px; border-bottom: 1px solid var(--line); font-size: 13.5px; }
.table tr:last-child td { border-bottom: 0; }
.table .r { text-align: right; }
.table tbody tr:hover td { background: rgba(255,255,255,.02); }
@media (max-width: 759px) {
  .table.cards thead { display: none; }
  .table.cards, .table.cards tbody, .table.cards tr, .table.cards td { display: block; width: 100%; }
  .table.cards tr { display: grid; grid-template-columns: 1fr 1fr; gap: 4px 12px; padding: 12px 14px; border-bottom: 1px solid var(--line); }
  .table.cards tr:last-child { border-bottom: 0; }
  .table.cards td { border: 0; padding: 0; text-align: left !important; }
  .table.cards td::before { content: attr(data-label); display: block; font-size: 10.5px; color: var(--dim); text-transform: uppercase; letter-spacing: .08em; }
  .table.cards td.full { grid-column: 1 / -1; }
  .table.cards td.full::before { display: none; }
  .table.cards.compact tr { grid-template-columns: 1.1fr 1.3fr .9fr; }
  .table.cards.compact td { white-space: nowrap; }
  .winbar { width: 48px; }
  .table.cards .hide-sm { display: none; }
  .table.trades tr { grid-template-columns: 1fr auto auto; grid-template-areas: "mkt side res" "time entry pnl"; gap: 6px 14px; align-items: center; }
  .table.trades .c-id, .table.trades .c-size, .table.trades .c-edge { display: none; }
  .table.trades .c-mkt { grid-area: mkt; font-weight: 650; } .table.trades .c-side { grid-area: side; }
  .table.trades .c-res { grid-area: res; text-align: right !important; } .table.trades .c-time { grid-area: time; color: var(--muted); font-size: 12.5px; }
  .table.trades .c-entry { grid-area: entry; } .table.trades .c-pnl { grid-area: pnl; text-align: right !important; font-weight: 650; }
  .table.trades .c-mkt::before, .table.trades .c-side::before, .table.trades .c-res::before, .table.trades .c-time::before, .table.trades .c-pnl::before { display: none; }
  .table.trades .c-entry::before { display: inline; content: "@ "; font-size: 12.5px; letter-spacing: 0; text-transform: none; }
}
.winbar { display: inline-block; width: 64px; height: 6px; border-radius: 99px; background: rgba(255,122,143,.35); overflow: hidden; vertical-align: middle; margin-right: 8px; }
.winbar i { display: block; height: 100%; background: var(--mint); }

/* Filters */
.filters { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; padding: 12px 14px; border-bottom: 1px solid var(--line); }
.fchip { appearance: none; border: 1px solid var(--line-2); background: rgba(255,255,255,.03); color: var(--muted); border-radius: 999px; padding: 0 14px; min-height: 34px; font-size: 13px; font-weight: 600; cursor: pointer; }
.fchip[aria-pressed="true"] { color: #06110d; background: var(--mint); border-color: var(--mint); }
.select { appearance: none; background: var(--bg-2) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%23a3abba' stroke-width='2'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E") no-repeat right 10px center; border: 1px solid var(--line-2); border-radius: 999px; padding: 0 30px 0 14px; min-height: 34px; font-size: 13px; }
.filters .spacer { flex: 1; }

/* Markets */
.markets { display: grid; grid-template-columns: 1fr; gap: 10px; }
.mkt { padding: 14px; display: grid; gap: 10px; }
.mkt-top { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.mkt-name { font-weight: 700; }
.prob { position: relative; height: 30px; border-radius: 10px; overflow: hidden; background: var(--loss-bg); border: 1px solid var(--line); display: flex; }
.prob .upbar { background: linear-gradient(90deg, rgba(138,247,208,.28), rgba(138,247,208,.14)); height: 100%; transition: width .5s ease; }
.prob span { position: absolute; top: 50%; transform: translateY(-50%); font-size: 12px; font-weight: 700; }
.prob .lu { left: 10px; color: var(--mint); } .prob .ld { right: 10px; color: var(--loss); }
.mkt-meta { display: flex; justify-content: space-between; font-size: 12px; color: var(--muted); gap: 8px; flex-wrap: wrap; }

/* Settings */
.dl { display: grid; grid-template-columns: 1fr auto; margin: 0; }
.dl dt, .dl dd { padding: 10px 16px; border-bottom: 1px solid var(--line); font-size: 13.5px; margin: 0; }
.dl dt { color: var(--muted); }
.dl dd { text-align: right; font-weight: 600; overflow-wrap: anywhere; }
.dl dt:nth-last-of-type(1), .dl dd:last-of-type { border-bottom: 0; }
.form { display: grid; gap: 10px; padding: 16px; }
.form label { font-size: 12px; color: var(--muted); display: grid; gap: 6px; }
.input { background: var(--bg-2); border: 1px solid var(--line-2); border-radius: 10px; padding: 10px 12px; min-height: 42px; }
.btn { display: inline-flex; align-items: center; justify-content: center; min-height: 40px; padding: 0 16px; border-radius: 999px; font-weight: 650; font-size: 14px; border: 1px solid var(--line-2); background: rgba(255,255,255,.05); color: var(--text); cursor: pointer; }
.btn-primary { background: var(--grad); color: #06110d; border: 0; }
.row { display: flex; gap: 8px; flex-wrap: wrap; }

/* States */
.empty { display: grid; place-items: center; gap: 8px; text-align: center; padding: 34px 20px; color: var(--muted); font-size: 13.5px; }
.empty svg { opacity: .55; }
.empty strong { color: var(--text); font-size: 14px; }
.banner { display: flex; gap: 10px; align-items: flex-start; padding: 12px 14px; border-radius: var(--radius-sm); font-size: 13.5px; margin-bottom: 12px; }
.banner.bad { background: var(--loss-bg); border: 1px solid rgba(255,122,143,.3); color: #ffd3da; }
.banner.warn { background: var(--warn-bg); border: 1px solid rgba(255,184,107,.3); color: #ffe2c2; }
.banner[hidden] { display: none; }
.skel { position: relative; overflow: hidden; background: rgba(255,255,255,.05); border-radius: 8px; color: transparent !important; min-height: 1em; }
.skel::after { content: ""; position: absolute; inset: 0; transform: translateX(-100%); background: linear-gradient(90deg, transparent, rgba(255,255,255,.07), transparent); animation: shimmer 1.4s infinite; }
@keyframes shimmer { to { transform: translateX(100%); } }
.skel-line { height: 14px; margin: 12px 16px; } .skel-block { height: 180px; margin: 12px; border-radius: 12px; }
.toast-wrap { position: fixed; left: 50%; bottom: calc(var(--tabbar-h) + env(safe-area-inset-bottom) + 12px); transform: translateX(-50%); z-index: 60; display: grid; gap: 8px; width: min(92vw, 420px); }
.toast { background: rgba(20,24,35,.97); border: 1px solid var(--line-2); border-left: 3px solid var(--mint); border-radius: 12px; padding: 10px 14px; font-size: 13px; box-shadow: 0 16px 40px -14px rgba(0,0,0,.9); animation: rise .25s ease; }
@keyframes rise { from { opacity: 0; transform: translateY(8px); } }
footer.foot { color: var(--dim); font-size: 12px; text-align: center; padding: 28px 16px 8px; }

/* ≥ 600px */
@media (min-width: 600px) {
  .brand em { display: inline; }
  .status-label { position: static; width: auto; height: auto; overflow: visible; clip: auto; }
  .kpis { grid-template-columns: repeat(4, 1fr); }
  .markets { grid-template-columns: repeat(2, 1fr); }
  .wrap { padding: 0 24px; }
}
/* ≥ 960px: desktop */
@media (min-width: 960px) {
  body { padding-bottom: 0; }
  .topbar-in { flex-wrap: nowrap; column-gap: 18px; }
  .brand, .top-right { height: 66px; }
  .quick { display: flex; padding: 0; gap: 0; order: 2; width: auto; margin-left: auto; }
  .quick-item { background: none; border: 0; border-left: 1px solid var(--line); border-radius: 0; padding: 2px 18px; }
  .tabs { position: static; display: flex; gap: 4px; height: auto; padding: 0; background: none; border: 0; backdrop-filter: none; -webkit-backdrop-filter: none; order: 1; margin-left: 12px; }
  .tab { flex-direction: row; gap: 8px; padding: 8px 14px; border-radius: 999px; font-size: 13.5px; color: var(--muted); }
  .tab svg { width: 17px; height: 17px; }
  .tab:hover { color: var(--text); background: rgba(255,255,255,.04); }
  .tab[aria-selected="true"] { color: var(--text); background: var(--panel-2); box-shadow: inset 0 0 0 1px var(--line-2); }
  .top-right { order: 3; margin-left: 0; }
  .grid-2 { grid-template-columns: 1.35fr 1fr; align-items: start; }
  .markets { grid-template-columns: repeat(3, 1fr); }
  .chart { height: 280px; }
  .toast-wrap { bottom: 20px; left: auto; right: 20px; transform: none; }
  .kpi-value { font-size: 26px; }
}
@media (min-width: 960px) and (max-width: 1180px) { .quick-item:nth-child(3) { display: none; } }
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation: none !important; transition: none !important; } }
