/* ==========================================================================
   DASHBOARD — 12-column widget grid (S=4, M=6, L=8, XL=12). Tokens only.
   Charts: 2px lines, flat 8% fill (no gradients), recessive grid.
   ========================================================================== */

.dashboard { flex: 1; overflow-y: auto; padding: var(--sp-4) var(--sp-5) var(--sp-8); background: var(--bg); }
.dtool { display: flex; align-items: center; justify-content: space-between; margin-bottom: var(--sp-3); }
.dtool__sub { font-size: var(--fs-xs); }
.dtool__add { width: auto; height: var(--control-h-sm); font-size: var(--fs-xs); }

/* dense flow back-fills holes; standard widgets share one height, so every row lines up */
.dgrid { display: grid; grid-template-columns: repeat(12, minmax(0, 1fr)); gap: var(--sp-3); align-items: stretch; grid-auto-flow: row dense; }
.span-4 { grid-column: span 4; }
.span-6 { grid-column: span 6; }
.span-8 { grid-column: span 8; }
.span-12 { grid-column: span 12; }
@media (max-width: 1280px) {
  .span-4 { grid-column: span 6; }
  .span-8 { grid-column: span 12; }
}

.dwidget { background: var(--surface); border: var(--border-w) solid var(--border); border-radius: var(--radius-lg); min-width: 0; transition: border-color var(--dur), opacity var(--dur); }
.dwidget.is-bare { background: transparent; border-color: transparent; }
.dgrid.is-editing .dwidget { border-style: dashed; border-color: var(--border-strong); cursor: grab; }
.dgrid.is-editing .dwidget.is-bare { background: var(--surface); }
.dwidget.is-dragging { opacity: 0.4; }
.dwidget.is-over { border-color: var(--accent); border-style: solid; }
.dwidget__head { display: flex; align-items: center; gap: var(--sp-2); padding: var(--sp-3) var(--sp-4) 0; }
.dwidget__title { font-size: var(--fs-2xs); font-weight: var(--fw-semibold); text-transform: uppercase; letter-spacing: var(--tracking-caps); color: var(--text-3); }
.dwidget__grip { color: var(--text-3); font-size: var(--fs-md); }
.dwidget__hide { width: 22px; height: 22px; display: grid; place-items: center; border-radius: var(--radius-xs); color: var(--text-3); }
.dwidget__hide:hover { background: var(--neg-soft); color: var(--neg); }
.dwidget__body { padding: var(--sp-3) var(--sp-4) var(--sp-4); position: relative; }
.dwidget.is-fixed { height: var(--dw-h, 360px); display: flex; flex-direction: column; }
.dwidget.is-fixed .dwidget__body { flex: 1; min-height: 0; overflow-y: auto; }
.dwidget.is-bare .dwidget__body { padding: 0; }
.seg--sm .seg__btn { height: 20px; padding: 0 7px; font-size: var(--fs-2xs); }
.dempty { color: var(--text-3); font-size: var(--fs-sm); padding: var(--sp-2) 0; }
.dkv { display: flex; justify-content: space-between; gap: var(--sp-3); padding: 6px 0; border-bottom: var(--border-w) solid var(--border); font-size: var(--fs-sm); }
.dkv:last-of-type { border-bottom: 0; }
.dkv span { color: var(--text-3); }
.dkv b { font-weight: var(--fw-medium); text-align: right; }
.dactions { display: flex; gap: var(--sp-2); margin-top: var(--sp-3); }
.gold { color: var(--av-gold); }

/* ticker tape */
.ttape { overflow: hidden; border: var(--border-w) solid var(--border); border-radius: var(--radius-lg); background: var(--surface); }
.ttape__run { display: inline-flex; gap: var(--sp-6); padding: 10px var(--sp-4); white-space: nowrap; animation: tape linear infinite; }
.tchip + .tchip::before { content: ""; width: 1px; height: 16px; background: var(--border-strong); margin-right: var(--sp-3); }
.ttape:hover .ttape__run { animation-play-state: paused; }
@keyframes tape { to { transform: translateX(-50%); } }
.ttape__empty { padding: 12px var(--sp-4); font-size: var(--fs-sm); color: var(--text-3); border: var(--border-w) dashed var(--border); border-radius: var(--radius-lg); }
.tchip { display: inline-flex; align-items: center; gap: 8px; font-size: var(--fs-md); }
.tchip__dot { width: 20px; height: 20px; border-radius: 50%; display: grid; place-items: center; font-style: normal; font-size: var(--fs-2xs); font-weight: var(--fw-semibold); background: var(--surface-3); color: var(--text-2); }
.tchip__logo { width: 20px; height: 20px; border-radius: 50%; object-fit: cover; background: var(--surface-3); }
.tchip b { font-weight: var(--fw-semibold); }
.tchip .mono { color: var(--accent); }
.tchip__pct { padding: 2px 8px; border-radius: var(--radius-sm); font-size: var(--fs-xs); }
.tchip__pct.pos { background: var(--pos-soft); color: var(--pos); }
.tchip__pct.neg { background: var(--neg-soft); color: var(--neg); }
.tchip__open { font-size: var(--fs-2xs); color: var(--text-3); text-transform: uppercase; letter-spacing: 0.06em; }

/* hero */
.dhero__top { display: flex; justify-content: space-between; gap: var(--sp-4); }
.dhero__label { font-size: var(--fs-sm); color: var(--text-3); }
.dhero__value { font-size: 52px; font-weight: 800; letter-spacing: -0.04em; line-height: 1.05; margin-top: 4px; font-variant-numeric: tabular-nums; }
.dhero__cents { font-size: 30px; color: var(--text-3); font-weight: var(--fw-semibold); letter-spacing: -0.02em; }
.dhero__change { font-size: var(--fs-lg); font-weight: var(--fw-semibold); margin-top: 4px; font-variant-numeric: tabular-nums; }
.dhero__right { display: flex; flex-direction: column; align-items: flex-end; gap: var(--sp-2); }
.dhero__mult { font-size: var(--fs-lg); font-weight: 700; padding: 6px 16px; border-radius: 999px; font-variant-numeric: tabular-nums; }
.dhero__mult.is-pos { background: var(--pos); color: #000; }
.dhero__mult.is-neg { background: var(--neg); color: #000; }
.dhero__wl { color: var(--text-3); font-size: var(--fs-sm); }
.dhero__chart { position: relative; margin-top: var(--sp-3); min-height: 210px; }
.dhero__src { font-size: var(--fs-2xs); color: var(--text-3); text-align: right; margin-top: 2px; }

/* charts */
.dchart { display: block; overflow: visible; }
.dchart .dgl { stroke: var(--border); stroke-width: 1; stroke-dasharray: 2 4; }
.dchart .daxis { fill: var(--text-3); font-size: 10px; font-family: var(--font-mono); }
.dchart .dzero { stroke: var(--border-strong); stroke-width: 1; }
.dchart .dcross { stroke: var(--text-3); stroke-width: 1; stroke-dasharray: 3 3; }
.dchart .dhit, .dchart .dbar { cursor: crosshair; }
.dtip { position: absolute; pointer-events: none; display: flex; flex-direction: column; gap: 1px; padding: 6px 10px; background: var(--surface-2); border: var(--border-w) solid var(--border-strong); border-radius: var(--radius-sm); box-shadow: var(--shadow-md); font-size: var(--fs-xs); opacity: 0; transition: opacity var(--dur-fast); white-space: nowrap; z-index: 2; }
.dtip.is-on { opacity: 1; }
.dtip b { font-size: var(--fs-md); font-variant-numeric: tabular-nums; }
.dtip small { color: var(--text-3); }
.dpnl__total { display: flex; align-items: baseline; gap: var(--sp-2); margin-bottom: var(--sp-2); }
.dpnl__total b { font-size: var(--fs-xl); font-weight: 700; }
.dpnl__total span { font-size: var(--fs-xs); color: var(--text-3); }
.dpnl__chart { position: relative; }

/* wins & losses */
.dwl { display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: var(--sp-3); margin-bottom: var(--sp-2); }
.dwl__rate b { display: block; font-size: 30px; font-weight: 800; letter-spacing: -0.03em; line-height: 1; }
.dwl__rate span { font-size: var(--fs-2xs); color: var(--text-3); text-transform: uppercase; letter-spacing: var(--tracking-caps); }
.dwl__bar { display: flex; gap: 2px; height: 8px; }
.dwl__bar i { border-radius: 4px; }
.dwl__bar i.pos { background: var(--pos); }
.dwl__bar i.neg { background: var(--neg); }
.dwl__counts { display: flex; gap: 8px; font-size: var(--fs-sm); font-weight: var(--fw-semibold); }

/* agents */
.dagent { display: grid; grid-template-columns: 30px 120px minmax(0, 1fr) auto; align-items: center; gap: var(--sp-2); padding: 5px 4px; border-radius: var(--radius-sm); font-size: var(--fs-sm); }
.dagent.is-killed { background: var(--neg-soft); }
.dagent.is-active { box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--bot-c) 55%, transparent); }
.dagent__tile { width: 30px; height: 30px; border-radius: 8px; display: grid; place-items: center; background: color-mix(in srgb, var(--bot-c) 16%, transparent); }
.dagent__name { font-weight: var(--fw-medium); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.dagent__latest { display: flex; align-items: center; gap: 6px; min-width: 0; overflow: hidden; white-space: nowrap; color: var(--text-2); font-size: var(--fs-xs); }
.dagent__latest .ochip__badge { width: 18px; height: 18px; }
.dagent__pill { font-size: var(--fs-2xs); font-weight: var(--fw-semibold); padding: 3px 9px; border-radius: 999px; color: var(--bot-c); background: color-mix(in srgb, var(--bot-c) 14%, transparent); white-space: nowrap; }
.dagent__pill.is-neg { color: var(--neg); background: var(--neg-soft); }
.dagent__pill.is-pos { color: var(--pos); background: var(--pos-soft); }

/* live round */
.dlive__bots { display: grid; grid-template-columns: repeat(6, 1fr); gap: var(--sp-2); }
.dlive__bot { position: relative; display: grid; place-items: center; height: 54px; border-radius: var(--radius-md); background: color-mix(in srgb, var(--bot-c) 10%, transparent); border: var(--border-w) solid transparent; }
.dlive__bot.is-pending { opacity: 0.4; }
.dlive__bot.is-active { border-color: var(--bot-c); }
.dlive__bot i { position: absolute; right: 6px; top: 6px; width: 7px; height: 7px; border-radius: 50%; background: var(--text-3); }
.dlive__bot.is-done i { background: var(--pos); }
.dlive__bot.is-error i { background: var(--neg); }
.dlive__bot.is-active i { background: var(--bot-c); animation: pulse 1s infinite; }
.dlive__bar { height: 4px; background: var(--surface-3); border-radius: 2px; margin-top: var(--sp-3); overflow: hidden; }
.dlive__bar i { display: block; height: 100%; background: var(--accent); border-radius: 2px; transition: width var(--dur) var(--ease); }
.dlive__text { font-size: var(--fs-xs); color: var(--text-3); margin-top: var(--sp-2); }

/* positions */
.dpos { display: grid; grid-template-columns: 1fr 50px 70px 100px; gap: var(--sp-2); padding: 6px 0; border-bottom: var(--border-w) solid var(--border); font-size: var(--fs-sm); }
.dpos--head { font-size: var(--fs-2xs); color: var(--text-3); text-transform: uppercase; letter-spacing: var(--tracking-caps); padding-top: 0; }
.dpos--foot { border-bottom: 0; color: var(--text-3); }

/* brief, debate, logger */
.dbrief__stats { font-size: var(--fs-xs); color: var(--text-2); letter-spacing: 0.06em; margin-bottom: var(--sp-2); }
.dbrief__row { display: grid; grid-template-columns: 44px minmax(0, 1fr) auto; gap: var(--sp-2); padding: 5px 0; font-size: var(--fs-xs); border-bottom: var(--border-w) solid var(--border); }
.dbrief__row .t { color: var(--text-3); }
.dbrief__row .x { color: var(--text-2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dbrief__row .x b { color: var(--text); }
.dbrief__row .k { font-weight: 700; }
.dbrief__row .k.info { color: var(--accent); }
.dwidget .link { margin-top: var(--sp-2); display: inline-block; }
.dhead-stat { text-align: right; margin: -4px 0 4px; font-size: var(--fs-xs); color: var(--bot-risk); }
.dhead-stat b { font-weight: 700; }
.dlog .lg { font-size: var(--fs-xs); padding: 3px 0; grid-template-columns: 7px 40px minmax(0, 1fr); gap: 8px; }
.dlog .lg:nth-child(5) { opacity: 0.75; }
.dlog .lg:nth-child(6) { opacity: 0.5; }
.dlog .lg:nth-child(7) { opacity: 0.3; }

/* dashboard gets the full width: the account panel is a widget here */
.body.is-wide { grid-template-columns: var(--rail-w) 1fr 0; }
.body.is-wide .side { display: none; }

/* xAI usage */
.dusage__top { display: flex; align-items: flex-start; justify-content: space-between; gap: var(--sp-3); }
.dusage__cost { font-size: 30px; font-weight: 800; letter-spacing: -0.03em; line-height: 1.05; }
.dusage__sub { font-size: var(--fs-2xs); color: var(--text-3); margin-top: 2px; }
.dusage__stats { display: flex; flex-wrap: wrap; gap: 4px var(--sp-4); margin: var(--sp-2) 0; font-size: var(--fs-xs); color: var(--text-3); }
.dusage__stats b { color: var(--text); font-weight: var(--fw-semibold); }
.dusage__budget { display: grid; gap: 4px; margin-bottom: var(--sp-2); font-size: var(--fs-2xs); color: var(--text-3); }
.dusage__bar { height: 6px; background: var(--surface-3); border-radius: 3px; overflow: hidden; }
.dusage__bar i { display: block; height: 100%; border-radius: 3px; }
.dusage__bar i.pos { background: var(--pos); }
.dusage__bar i.warn { background: var(--warn); }
.dusage__bar i.neg { background: var(--neg); }
.durow { display: grid; grid-template-columns: minmax(0, 1fr) 40px 64px 52px 64px 70px; gap: var(--sp-2); align-items: center; padding: 4px 0; font-size: var(--fs-xs); border-bottom: var(--border-w) solid var(--border); }
.durow--head { font-size: var(--fs-2xs); color: var(--text-3); text-transform: uppercase; letter-spacing: var(--tracking-caps); }
.durow__who { display: flex; align-items: center; gap: 6px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.durow__bar { height: 6px; background: var(--surface-3); border-radius: 3px; overflow: hidden; }
.durow__bar i { display: block; height: 100%; background: var(--accent); border-radius: 3px; }
.dusage__foot { margin-top: var(--sp-2); font-size: var(--fs-xs); color: var(--text-2); }
.dusage__tip { margin-top: 4px; color: var(--text-3); }

/* ==========================================================================
   Widgets that fill their box. The body is a size container, so contents
   scale with the widget (S/M/L/XL) instead of leaving empty space.
   ========================================================================== */
.dwidget.is-fixed .dwidget__body { display: flex; flex-direction: column; container-type: size; }
.dfill { flex: 1; min-height: 0; display: flex; flex-direction: column; justify-content: space-between; }
.dfill .dkv { padding: 0; align-items: center; flex: 1; max-height: 44px; }
.dfill .dactions { margin-top: var(--sp-2); }

/* Wins & losses: the rate grows with the box */
.dfill .dwl { margin-bottom: var(--sp-3); }
.dwl__rate b { font-size: clamp(30px, 13cqh, 56px); }
.dwl__bar { height: clamp(8px, 3cqh, 14px); }
.dwl__bar i { border-radius: 999px; }
.dwl__counts { font-size: clamp(12px, 4.5cqh, 18px); }

/* Daily P&L: header + stats, chart takes the rest */
.dpnl { flex: 1; min-height: 0; display: flex; flex-direction: column; gap: var(--sp-2); }
.dpnl__total b { font-size: clamp(20px, 9cqh, 34px); }
.dpnl__desks { display: grid; grid-template-columns: repeat(auto-fit, minmax(92px, 1fr)); gap: 6px; }
.dpnl__desk { display: flex; flex-direction: column; align-items: flex-start; gap: 2px; min-width: 0; padding: 6px 8px; border: 1px solid var(--border); border-radius: var(--radius-xs); background: transparent; color: var(--text-3); font-size: var(--fs-2xs); text-align: left; cursor: pointer; }
.dpnl__desk span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%; text-transform: uppercase; letter-spacing: .06em; }
.dpnl__desk b { font-size: var(--fs-sm); font-weight: var(--fw-semibold); white-space: nowrap; }
.dpnl__desk b.muted { color: var(--text-3); }
.dpnl__desk:hover { border-color: var(--border-strong, var(--text-3)); }
.dpnl__desk.is-on { border-color: var(--accent); background: color-mix(in srgb, var(--accent) 10%, transparent); color: var(--text-2); }
.dpnl__stats { display: flex; flex-wrap: wrap; gap: 2px var(--sp-4); font-size: var(--fs-xs); color: var(--text-3); }
.dpnl__stats b { font-weight: var(--fw-semibold); }
.dpnl__chart { flex: 1; min-height: 90px; position: relative; }
.dchart .dval { fill: var(--text-2); font-size: 10px; font-family: var(--font-mono); }

/* Live round: big tiles, 3×2 in a narrow box, 6×1 in a wide and short one */
.dlive { flex: 1; min-height: 0; display: flex; flex-direction: column; gap: var(--sp-2); }
.dlive__bots { flex: 1; min-height: 0; display: grid; grid-template-columns: repeat(3, 1fr); grid-auto-rows: 1fr; gap: var(--sp-2); }
/* Wide box: one row of six tall tiles, so avatars and labels can be much larger */
@container (min-width: 620px) {
  .dlive__bots { grid-template-columns: repeat(6, 1fr); }
  .dlive__av svg { width: clamp(40px, min(34cqh, 9cqw), 104px) !important; }
  .dlive__name { font-size: clamp(13px, 5cqh, 17px) !important; }
  .dlive__state { font-size: var(--fs-xs) !important; }
}
.dlive__bot { height: auto; min-height: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px; padding: 6px 4px; overflow: hidden; }
.dlive__av { display: grid; place-items: center; }
.dlive__av svg { width: clamp(26px, min(19cqh, 17cqw), 76px); height: auto; }
.dlive__bot.is-active .dlive__av svg { filter: drop-shadow(0 0 6px color-mix(in srgb, var(--bot-c) 55%, transparent)); }
.dlive__name { font-size: clamp(11px, 4cqh, 14px); font-weight: var(--fw-semibold); color: var(--text); }
.dlive__state { font-size: var(--fs-2xs); color: var(--text-3); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%; }
.dlive__bot.is-active .dlive__state { color: var(--bot-c); font-weight: var(--fw-medium); }
.dlive__bot.is-done .dlive__state { color: var(--text-2); }
.dlive__bot.is-error .dlive__state { color: var(--neg); }
.dlive__bar { margin-top: 0; height: 6px; border-radius: 3px; }
.dlive__text { margin-top: 0; }
.dusage__cost small { font-size: 0.5em; color: var(--text-3); font-weight: normal; }
/* Which account the main graph shows */
.dhero__which { display: inline-block; margin-right: 6px; padding: 1px 8px; border-radius: 999px; font-size: 11px; font-weight: 600; letter-spacing: 0.02em; background: color-mix(in srgb, var(--accent) 16%, transparent); color: var(--accent); }
.dhero__which.is-demo { background: color-mix(in srgb, var(--warn) 18%, transparent); color: var(--warn); }
.dhero__which.is-live { background: color-mix(in srgb, var(--neg) 18%, transparent); color: var(--neg); }

/* P&L calendar: a box per day; its size is how big the day was, its colour which way. */
.dcal { display: flex; flex-direction: column; gap: 8px; }
.dcal__head { display: flex; align-items: center; gap: 8px; }
.dcal__month { font-family: var(--font-mono); text-transform: uppercase; letter-spacing: .12em; font-size: var(--fs-sm); min-width: 150px; text-align: center; }
.dcal__nav { min-width: 26px; }
.dcal__total { margin-left: auto; font-size: var(--fs-xs); color: var(--text-3); }
.dcal__grid { display: grid; grid-template-columns: repeat(7, 1fr); grid-auto-rows: max-content; align-content: start; gap: 3px; }
.dcal__wd { font-family: var(--font-mono); font-size: var(--fs-2xs); color: var(--text-3); text-align: center; letter-spacing: .1em; }
.dcal__day { position: relative; height: 34px; display: grid; place-items: center; border: 1px solid var(--border); border-radius: 4px; background: color-mix(in srgb, var(--surface) 70%, transparent); }
.dcal__day.is-today { border-color: var(--accent); }
.dcal__day.is-future { opacity: .4; }
.dcal__num { position: absolute; top: 2px; left: 4px; font-family: var(--font-mono); font-size: 9px; color: var(--text-3); }
.dcal__box { display: block; border-radius: 2px; transition: transform 120ms ease; }
.dcal__box.pos { background: var(--pos); }
.dcal__box.neg { background: var(--neg); }
.dcal__box.is-s { width: 8px; height: 8px; opacity: .75; }
.dcal__box.is-m { width: 14px; height: 14px; opacity: .88; }
.dcal__box.is-l { width: 18px; height: 18px; }
.dcal__day:has(.dcal__box) { cursor: default; }
.dcal__day:hover .dcal__box { transform: scale(1.15); }
.dcal__key { display: flex; align-items: center; gap: 6px; font-size: var(--fs-2xs); color: var(--text-3); font-family: var(--font-mono); }
.dcal__key .dcal__box { flex: none; }
.dcal__key span { margin-right: 6px; }
.dcal__tip { position: fixed; z-index: 9000; display: grid; gap: 2px; padding: 7px 10px; border-radius: 6px; border: 1px solid var(--border-strong); background: var(--surface-2); box-shadow: 0 8px 24px rgba(0,0,0,.35); font-size: var(--fs-xs); pointer-events: none; }
.dcal__tip[hidden] { display: none; }
.dcal__tipday { color: var(--text-3); font-family: var(--font-mono); text-transform: uppercase; letter-spacing: .08em; font-size: var(--fs-2xs); }
.dcal__tip b { font-size: var(--fs-md); }

/* Memecoins: the change in SOL first, the dollar change beside it, quieter. */
.dhero__usd { color: var(--text-3); font-weight: 400; font-size: .85em; }
