:root {
  --bg: #0d1117;
  --bg2: #131a22;
  --panel: #161e27;
  --panel2: #1c2632;
  --line: #263341;
  --text: #dfe6ee;
  --muted: #8ba0b4;
  --green: #22c55e;
  --amber: #f59e0b;
  --red: #ef4444;
  --blue: #38bdf8;
  --purple: #a78bfa;
  --copper-a: #f59e0b;
  --copper-b: #d97706;
  --copper-off: #64748b;
  --radius: 10px;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  background: radial-gradient(1200px 700px at 70% -10%, #16222e 0%, var(--bg) 55%);
  color: var(--text);
  font: 13px/1.45 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* ---------- HUD ---------- */
.hud {
  position: sticky; top: 0; z-index: 40;
  display: flex; align-items: center; gap: 18px;
  padding: 10px 16px;
  background: rgba(10, 14, 19, 0.92);
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(6px);
  flex-wrap: wrap;
}
.hud .brand { font-weight: 800; letter-spacing: 1px; color: #f2c66d; }
.hud .round { font-weight: 700; }
.hud .months { display: flex; gap: 4px; }
.hud .months .m { padding: 2px 8px; border-radius: 6px; background: var(--panel2); color: var(--muted); font-size: 11px; border: 1px solid var(--line); }
.hud .months .m.now { color: var(--copper-a); border-color: var(--copper-a); background: rgba(245,158,11,.12); }
.hud .stat { display: flex; flex-direction: column; line-height: 1.1; }
.hud .stat .k { font-size: 10px; color: var(--muted); text-transform: uppercase; letter-spacing: .5px; }
.hud .stat .v { font-size: 14px; font-weight: 700; font-variant-numeric: tabular-nums; }
.hud .stat .v.pos { color: var(--green); }
.hud .stat .v.neg { color: var(--red); }
.hud .spacer { flex: 1; }
.timer { width: 130px; display: flex; flex-direction: column; gap: 3px; }
.timer .tbar { height: 8px; border-radius: 4px; background: var(--panel2); overflow: hidden; border: 1px solid var(--line); }
.timer .tbar div { height: 100%; background: linear-gradient(90deg, var(--blue), var(--copper-a)); width: 100%; transition: width .5s linear; }
.timer .tt { font-size: 10px; color: var(--muted); text-align: right; font-variant-numeric: tabular-nums; }
.risk { width: 90px; }
.risk .rbar { height: 8px; border-radius: 4px; background: var(--panel2); overflow: hidden; border: 1px solid var(--line); }
.risk .rbar div { height: 100%; background: var(--red); }

/* ---------- layout ---------- */
.board {
  flex: 1;
  display: grid;
  grid-template-columns: 300px minmax(400px, 1fr) 305px;
  gap: 14px;
  padding: 14px;
  align-items: start;
}
.col { min-width: 0; }
.col-title {
  font-size: 11px; letter-spacing: 1.5px; color: var(--muted);
  text-transform: uppercase; font-weight: 700;
  display: flex; align-items: baseline; gap: 8px; margin-bottom: 8px;
}
.col-title .hint, .panel-title .hint { color: #54677a; font-weight: 400; letter-spacing: 0; text-transform: none; }
.card-list { display: flex; flex-direction: column; gap: 10px; }

.panel { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 10px 12px; margin-bottom: 12px; }
.panel-title { font-size: 11px; letter-spacing: 1.2px; text-transform: uppercase; font-weight: 700; color: var(--muted); display: flex; gap: 8px; align-items: baseline; margin-bottom: 8px; }

/* ---------- cards ---------- */
.cargo, .demand {
  background: linear-gradient(180deg, var(--panel2), var(--panel));
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 9px 10px;
  cursor: grab;
  position: relative;
  transition: transform .12s, box-shadow .12s, border-color .12s;
  user-select: none;
}
.cargo:hover, .demand:hover { border-color: #3c5168; }
.cargo.held { border-color: var(--blue); box-shadow: 0 0 0 2px rgba(56,189,248,.35); transform: translateY(-2px); }
.cargo.placeholder { border-style: dashed; opacity: .55; }
.demanded-full { opacity: .72; }

.cargo .head { display: flex; align-items: center; gap: 7px; }
.grade-badge {
  width: 22px; height: 22px; border-radius: 6px; display: flex; align-items: center; justify-content: center;
  font-weight: 800; font-size: 11px; color: #0b0f14; flex: none;
}
.grade-A { background: var(--copper-a); }
.grade-B { background: var(--copper-b); color: #fff; }
.grade-off { background: var(--copper-off); color: #fff; }
.cargo .name { font-weight: 700; font-size: 13px; }
.cargo .qty { margin-left: auto; font-weight: 800; font-variant-numeric: tabular-nums; }
.cargo .origin { font-size: 11px; color: var(--muted); }
.chips { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 7px; }
.chip {
  font-size: 10px; padding: 2px 6px; border-radius: 5px; background: var(--bg2);
  border: 1px solid var(--line); color: var(--muted); font-variant-numeric: tabular-nums;
}
.chip.good { color: var(--green); border-color: rgba(34,197,94,.4); }
.chip.warn { color: var(--amber); border-color: rgba(245,158,11,.4); }
.chip.bad { color: var(--red); border-color: rgba(239,68,68,.4); }
.chip.trade { color: var(--blue); border-color: rgba(56,189,248,.4); }

.blocks { display: flex; gap: 3px; margin-top: 8px; align-items: flex-end; }
.block { width: 9px; border-radius: 2px; background: var(--copper-a); opacity: .85; }
.block.b { background: var(--copper-b); }
.block.off { background: var(--copper-off); }

.windowbar { display: flex; margin-top: 8px; height: 16px; border-radius: 5px; overflow: hidden; border: 1px solid var(--line); }
.windowbar .wm { flex: 1; display: flex; align-items: center; justify-content: center; font-size: 9px; color: #0b0f14; }
.windowbar .wm.ship { background: var(--copper-a); font-weight: 800; }
.windowbar .wm.miss { background: var(--bg2); }
.windowbar .wm.del { background: #2b6f46; font-weight: 800; }
.windowbar .wm.late { background: var(--red); color: #fff; font-weight: 800; }

.notes-line { margin-top: 6px; font-size: 10.5px; }
.notes-line .warn { color: var(--amber); }

/* drop preview states */
.drop-green { border-color: var(--green) !important; box-shadow: 0 0 0 2px rgba(34,197,94,.4) !important; }
.drop-amber { border-color: var(--amber) !important; box-shadow: 0 0 0 2px rgba(245,158,11,.4) !important; }
.drop-red { border-color: var(--red) !important; box-shadow: 0 0 0 2px rgba(239,68,68,.4) !important; }
.drop-zone { border-style: dashed; cursor: pointer; }
.drop-green-glow { border: 1px dashed rgba(34,197,94,.5); }

.preview {
  position: absolute; right: -8px; top: 50%; transform: translateY(-50%) translateX(100%);
  background: #0b0f14; border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px;
  min-width: 180px; z-index: 20; box-shadow: 0 6px 24px rgba(0,0,0,.5);
  display: none;
}
.drop-green .preview, .drop-amber .preview, .drop-red .preview { display: block; }
.preview .pm { font-weight: 800; font-size: 15px; font-variant-numeric: tabular-nums; }
.preview .pm.pos { color: var(--green); }
.preview .pm.neg { color: var(--red); }
.preview .pn { font-size: 10.5px; color: var(--muted); margin-top: 3px; }
.preview .pn .warn { color: var(--amber); }
.preview .pn .bad { color: var(--red); }

/* ---------- demand cards ---------- */
.demand .d-head { display: flex; align-items: center; gap: 7px; }
.demand .d-name { font-weight: 700; font-size: 13px; }
.demand .d-prem { margin-left: auto; font-weight: 800; color: var(--green); font-variant-numeric: tabular-nums; }
.demand .d-sub { font-size: 10.5px; color: var(--muted); margin-top: 2px; }
.demand .progress { height: 7px; border-radius: 4px; background: var(--bg2); margin-top: 8px; overflow: hidden; border: 1px solid var(--line); }
.demand .progress div { height: 100%; background: linear-gradient(90deg, #1d7a42, var(--green)); transition: width .3s; }
.demand .d-filled { font-size: 10.5px; color: var(--muted); margin-top: 4px; font-variant-numeric: tabular-nums; }
.demand .d-allocs { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 6px; }
.alloc-chip {
  font-size: 10px; padding: 2px 7px; border-radius: 20px; background: rgba(56,189,248,.12);
  border: 1px solid rgba(56,189,248,.4); color: var(--blue); white-space: nowrap;
}
.alloc-chip .arrow { color: var(--amber); }
.demand .trust { font-size: 11px; color: var(--purple); }
.demand .opt { font-size: 10px; color: var(--muted); }

/* ---------- market columns ---------- */
.curves-row { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 10px; margin-bottom: 12px; }
.curve-box { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 8px; }
.curve-box h4 { margin: 0 0 4px; font-size: 11px; letter-spacing: 1px; color: var(--muted); text-transform: uppercase; }
.curve-box .big { font-size: 18px; font-weight: 800; font-variant-numeric: tabular-nums; }
.curve-box .sub { font-size: 10.5px; color: var(--muted); }
.curve-box svg { width: 100%; height: 70px; display: block; }
.basis-bars { display: flex; gap: 6px; margin-top: 6px; align-items: flex-end; height: 56px; }
.basis-bars .bb { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 3px; }
.basis-bars .bb .val { font-size: 9.5px; }
.basis-bars .bb .bar { width: 100%; border-radius: 3px 3px 0 0; }
.basis-bars .bb .lab { font-size: 9px; color: var(--muted); }
.curve-info { margin-top: 6px; font-size: 10.5px; color: var(--muted); min-height: 14px; }

.news-panel { margin-bottom: 12px; display: flex; flex-direction: column; gap: 6px; }
.news-item {
  display: flex; gap: 8px; align-items: flex-start; font-size: 12px;
  padding: 7px 10px; border-radius: 8px; border: 1px solid var(--line); background: var(--panel);
}
.news-item.warn { border-color: rgba(245,158,11,.5); background: rgba(245,158,11,.07); }
.news-item .ni-title { font-weight: 700; }
.news-item.info .ni-title { color: var(--blue); }
.news-item.warn .ni-title { color: var(--amber); }
.news-item .ni-text { color: var(--muted); }

.spot-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.spot-card { background: var(--panel2); border: 1px solid var(--line); border-radius: 8px; padding: 8px; }
.spot-card .sc-head { display: flex; align-items: center; gap: 6px; }
.spot-card .sc-price { font-weight: 800; color: var(--red); }
.spot-card .sc-qty { margin-left: auto; font-weight: 700; }
.spot-card .sc-meta { font-size: 10px; color: var(--muted); margin-top: 4px; }
.spot-card .sc-note { font-size: 10px; color: var(--amber); margin-top: 3px; }
.spot-card .btn { width: 100%; margin-top: 6px; }
.spot-sell {
  margin-top: 8px; border-radius: 8px; padding: 10px; text-align: center; color: var(--muted);
  font-size: 12px; cursor: pointer; background: var(--panel2);
}
.spot-sell b { color: var(--red); }

.ware-panel .ware-cap { display: flex; align-items: center; gap: 8px; font-size: 11px; color: var(--muted); }
.ware-panel .ware-cap .capbar { flex: 1; height: 7px; border-radius: 4px; background: var(--bg2); border: 1px solid var(--line); overflow: hidden; }
.ware-panel .ware-cap .capbar div { height: 100%; background: var(--purple); }
.ware-chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.ware-chip {
  display: flex; flex-direction: column; gap: 4px; padding: 6px 8px; border-radius: 8px;
  background: var(--panel2); border: 1px solid var(--line); font-size: 10.5px; cursor: grab;
}
.ware-chip .wc-top { display: flex; gap: 6px; align-items: center; }
.ware-chip .wc-name { font-weight: 700; }
.ware-chip .wc-qty { color: var(--muted); }
.ware-chip .wc-actions { display: flex; gap: 4px; }
.ware-chip .btn-sm { font-size: 10px; padding: 2px 6px; }
.ware-empty { font-size: 11px; color: var(--muted); padding: 6px 0; }
.blend-hint { font-size: 10.5px; color: var(--muted); margin-top: 8px; border-top: 1px dashed var(--line); padding-top: 7px; }

.arb-row {
  display: flex; align-items: center; gap: 8px; padding: 7px 8px; border-radius: 8px;
  background: var(--panel2); border: 1px solid var(--line); margin-bottom: 6px; cursor: grab;
}
.arb-row .ar-name { font-weight: 700; font-size: 12px; }
.arb-row .ar-meta { font-size: 10px; color: var(--muted); }
.arb-row .ar-margin { margin-left: auto; text-align: right; }
.arb-row .ar-margin .m { font-weight: 800; font-variant-numeric: tabular-nums; }
.arb-row.exec .m { color: var(--green); }
.arb-row.dead .m { color: var(--red); }
.arb-row .btn { padding: 3px 8px; font-size: 11px; }
.arb-eligible-note { font-size: 10.5px; color: var(--muted); margin-top: 6px; }
.arb-locked { font-size: 11px; color: var(--green); margin-top: 6px; }
.arb-explainer { font-size: 10.5px; color: var(--muted); border-top: 1px dashed var(--line); margin-top: 8px; padding-top: 7px; }

.book-panel .book-row {
  display: flex; align-items: center; gap: 8px; padding: 6px 8px; border-radius: 8px;
  background: var(--panel2); border: 1px solid var(--line); margin-bottom: 5px; font-size: 11.5px;
}
.book-row .br-route { flex: 1; min-width: 0; }
.book-row .br-name { font-weight: 700; }
.book-row .br-to { color: var(--muted); }
.book-row .br-margin { font-weight: 800; font-variant-numeric: tabular-nums; }
.book-row .br-margin.pos { color: var(--green); }
.book-row .br-margin.neg { color: var(--red); }
.book-row .btn-sm { font-size: 10px; padding: 2px 6px; }
.book-total { display: flex; justify-content: space-between; align-items: center; margin-top: 8px; padding-top: 8px; border-top: 1px solid var(--line); font-weight: 700; }
.book-total .bt-val { font-variant-numeric: tabular-nums; }
.book-empty { font-size: 11px; color: var(--muted); padding: 6px 0; }

/* ---------- buttons ---------- */
.btn {
  background: var(--panel2); color: var(--text); border: 1px solid var(--line);
  border-radius: 8px; padding: 7px 14px; font-size: 13px; cursor: pointer; font-weight: 600;
  transition: background .12s, border-color .12s, transform .06s;
}
.btn:hover { background: #243041; border-color: #3c5168; }
.btn:active { transform: translateY(1px); }
.btn-primary { background: linear-gradient(180deg, #1d7a42, #166534); border-color: #1d7a42; color: #fff; }
.btn-primary:hover { background: linear-gradient(180deg, #22944e, #1d7a42); }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn-sm { padding: 3px 8px; font-size: 11px; border-radius: 6px; }
.btn-big { font-size: 16px; padding: 12px 28px; margin-top: 10px; }

.bar {
  position: sticky; bottom: 0; z-index: 40;
  display: flex; align-items: center; gap: 10px; padding: 10px 16px;
  background: rgba(10,14,19,.94); border-top: 1px solid var(--line); backdrop-filter: blur(6px);
}
.bar .spacer { flex: 1; }

/* ---------- overlays ---------- */
.col-empty { font-size: 11px; color: var(--muted); padding: 14px; border: 1px dashed var(--line); border-radius: 8px; }
.sub { font-size: 10px; color: var(--muted); }
.toast {
  position: fixed; left: 50%; bottom: 70px; transform: translateX(-50%) translateY(12px);
  background: #0b0f14; border: 1px solid var(--line); color: var(--text);
  padding: 9px 16px; border-radius: 10px; font-size: 13px; font-weight: 600;
  box-shadow: 0 10px 40px rgba(0,0,0,.5); opacity: 0; transition: opacity .2s, transform .2s; z-index: 200;
  max-width: 80vw;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.toast.ok { border-color: rgba(34,197,94,.6); color: var(--green); }
.toast.err { border-color: rgba(239,68,68,.6); color: var(--red); }
.toast.info { border-color: rgba(56,189,248,.5); color: var(--blue); }

.overlay {
  position: fixed; inset: 0; z-index: 100;
  background: rgba(5,8,12,.82); backdrop-filter: blur(4px);
  display: flex; align-items: center; justify-content: center; padding: 24px;
}
.overlay.hidden { display: none; }
.overlay-card {
  background: var(--bg2); border: 1px solid var(--line); border-radius: 14px;
  padding: 22px 26px; max-width: 860px; width: 100%; max-height: 92vh; overflow: auto;
  box-shadow: 0 20px 80px rgba(0,0,0,.6);
}
.wf-head { display: flex; justify-content: space-between; align-items: flex-start; margin-bottom: 14px; }
.wf-round { font-size: 20px; font-weight: 800; }
.wf-badges { display: inline-flex; gap: 6px; margin-left: 10px; flex-wrap: wrap; }
.badge-pill {
  font-size: 10.5px; font-weight: 700; padding: 3px 8px; border-radius: 20px;
  background: rgba(167,139,250,.15); border: 1px solid rgba(167,139,250,.5); color: var(--purple);
  cursor: help;
}
.wf-total { font-size: 30px; font-weight: 800; font-variant-numeric: tabular-nums; }
.wf-total.pos { color: var(--green); }
.wf-total.neg { color: var(--red); }
.wf-chart { position: relative; height: 320px; border-bottom: 1px solid var(--line); margin: 0 4px; }
.wf-bar { position: absolute; bottom: 0; border-radius: 3px 3px 0 0; transition: height .6s cubic-bezier(.2,.7,.2,1), bottom .6s cubic-bezier(.2,.7,.2,1); }
.wf-bar.pos { background: linear-gradient(180deg, #34d16b, #1d7a42); }
.wf-bar.neg { background: linear-gradient(180deg, #f87171, #b91c1c); }
.wf-bar .wf-label {
  position: absolute; top: 100%; left: 50%; transform: translateX(-50%);
  font-size: 9.5px; color: var(--muted); width: 110px; text-align: center; padding-top: 3px;
  pointer-events: none; white-space: normal;
}
.wf-bar .wf-val { position: absolute; bottom: 100%; left: 50%; transform: translateX(-50%); font-size: 10.5px; font-weight: 700; font-variant-numeric: tabular-nums; margin-bottom: 3px; pointer-events: none; }
.wf-note { font-size: 10px; color: var(--muted); }
.wf-notes { display: flex; flex-direction: column; gap: 4px; margin-top: 34px; font-size: 12px; }
.wf-notes .n { color: var(--muted); }
.wf-notes .n.warn { color: var(--amber); }
.wf-actions { display: flex; justify-content: flex-end; margin-top: 16px; }

.intro-card, .end-card { max-width: 720px; }
.intro-card h1, .end-card h1 { margin: 0 0 8px; color: #f2c66d; font-size: 26px; }
.intro-card .lead { color: var(--muted); }
.intro-card ul.howto { padding-left: 18px; color: var(--text); }
.intro-card ul.howto li { margin: 6px 0; }
.intro-card .hint-line { color: #54677a; font-size: 11px; }
.end-stats { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 10px; margin: 14px 0; }
.end-stat { background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 12px; text-align: center; }
.end-stat .k { font-size: 10px; color: var(--muted); text-transform: uppercase; letter-spacing: .5px; }
.end-stat .v { font-size: 20px; font-weight: 800; margin-top: 4px; font-variant-numeric: tabular-nums; }
.end-stat .v.pos { color: var(--green); }
.end-stat .v.neg { color: var(--red); }
.end-badges { display: flex; flex-wrap: wrap; gap: 6px; justify-content: center; margin-bottom: 12px; }
.end-rating { text-align: center; font-size: 18px; font-weight: 800; color: #f2c66d; margin: 8px 0 4px; }
.end-rating small { display: block; font-size: 11px; color: var(--muted); font-weight: 400; margin-top: 4px; }
.end-card .btn-big { display: block; margin: 14px auto 0; }

@media (max-width: 1150px) {
  .board { grid-template-columns: 260px minmax(360px, 1fr) 265px; }
  .curves-row { grid-template-columns: 1fr 1fr; }
  .curve-box:nth-child(3) { grid-column: span 2; }
}
