/* ============================================================
   WDO Trading Platform — design system (tema escuro de pregão)
   ============================================================ */
:root {
  --bg: #0a0e15;
  --bg-grad: radial-gradient(1200px 600px at 75% -10%, #13203a 0%, transparent 60%),
             radial-gradient(900px 500px at -10% 110%, #101b2e 0%, transparent 55%);
  --panel: #121826;
  --panel-2: #0d1320;
  --panel-border: #222c3e;
  --panel-border-soft: #1a2334;
  --text: #e3eaf5;
  --muted: #8295ac;
  --accent: #3da9fc;
  --green: #22c98c;
  --red: #ff5b6e;
  --amber: #f5b942;
  --violet: #b58cff;
  --radius: 12px;
  --radius-sm: 8px;
  --shadow: 0 10px 30px rgba(0, 0, 0, .35);
  --focus: 0 0 0 2px rgba(61, 169, 252, .45);
  --trans: .18s ease;
  font-size: 14px;
}

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

body {
  background: var(--bg);
  background-image: var(--bg-grad);
  color: var(--text);
  font-family: "Inter", "Segoe UI", system-ui, sans-serif;
  height: 100vh;
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
}

.mono, input[type="number"] { font-family: "JetBrains Mono", Consolas, monospace; }

/* ---------- scrollbars ---------- */
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #27344a; border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: #33425c; }

/* ---------- botões (sistema) ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  border: 1px solid var(--panel-border); border-radius: var(--radius-sm);
  background: var(--panel-2); color: var(--text);
  padding: 8px 14px; font: 600 13px "Inter", sans-serif; letter-spacing: .2px;
  cursor: pointer; transition: transform var(--trans), box-shadow var(--trans),
    background var(--trans), border-color var(--trans), opacity var(--trans);
  user-select: none;
}
.btn:hover { border-color: #35455f; transform: translateY(-1px); }
.btn:active { transform: translateY(0); }
.btn:focus-visible { outline: none; box-shadow: var(--focus); }
.btn:disabled { opacity: .45; cursor: not-allowed; transform: none; }
.btn-lg { padding: 12px 16px; font-size: 14px; border-radius: 10px; }
.btn-primary {
  background: linear-gradient(135deg, #3da9fc, #2f7fe0); color: #051425; border-color: transparent;
}
.btn-primary:hover { box-shadow: 0 6px 18px rgba(61, 169, 252, .35); }
.btn-ghost { background: transparent; color: var(--muted); }
.btn-ghost:hover { color: var(--text); }
.btn-buy {
  background: linear-gradient(135deg, #22c98c, #169d6c); color: #04170e; border-color: transparent;
}
.btn-buy:hover { box-shadow: 0 6px 18px rgba(34, 201, 140, .35); }
.btn-sell {
  background: linear-gradient(135deg, #ff5b6e, #e03a50); color: #1d050a; border-color: transparent;
}
.btn-sell:hover { box-shadow: 0 6px 18px rgba(255, 91, 110, .35); }
.btn-warn {
  width: 100%; margin-top: 8px; background: rgba(245, 185, 66, .12);
  color: var(--amber); border-color: rgba(245, 185, 66, .4);
}
.btn-warn:hover:not(:disabled) { background: rgba(245, 185, 66, .2); }

/* ---------- login ---------- */
#login-overlay {
  position: fixed; inset: 0; z-index: 50;
  display: flex; align-items: center; justify-content: center;
  background: var(--bg); background-image: var(--bg-grad);
}
#login-form {
  width: 360px; padding: 40px 34px;
  background: linear-gradient(180deg, #151c2c, #10161f);
  border: 1px solid var(--panel-border);
  border-radius: 16px; box-shadow: var(--shadow);
  animation: rise .4s ease;
}
@keyframes rise { from { opacity: 0; transform: translateY(10px); } }
.brand-mark {
  width: 56px; height: 56px; border-radius: 14px; margin-bottom: 18px;
  display: flex; align-items: center; justify-content: center;
  background: linear-gradient(135deg, #3da9fc33, #22c98c22);
  border: 1px solid #2c3c56; color: var(--accent);
}
#login-form h1 { font-size: 24px; letter-spacing: .5px; font-weight: 800; }
#login-form h1 span { color: var(--accent); font-weight: 400; }
.login-sub { color: var(--muted); font-size: 11.5px; margin: 8px 0 26px; line-height: 1.5; }
#login-form label { display: block; font-size: 12px; font-weight: 600; color: var(--muted); margin: 14px 0 5px; }
#login-form input {
  width: 100%; padding: 11px 12px; border-radius: var(--radius-sm);
  border: 1px solid var(--panel-border); background: var(--panel-2); color: var(--text);
  transition: border-color var(--trans), box-shadow var(--trans);
}
#login-form input:focus { outline: none; border-color: var(--accent); box-shadow: var(--focus); }
#login-btn { width: 100%; margin-top: 24px; }
#login-error { color: var(--red); font-size: 12px; margin-top: 12px; min-height: 16px; }

/* ---------- layout ---------- */
#app { display: flex; flex-direction: column; height: 100vh; }
#app[hidden] { display: none; }

header {
  display: flex; justify-content: space-between; align-items: center; gap: 10px;
  padding: 10px 16px;
  background: rgba(13, 19, 32, .85); backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--panel-border);
}
.brand { display: flex; align-items: center; gap: 9px; font-size: 16px; font-weight: 800; letter-spacing: .4px; }
.brand span:last-child { color: var(--accent); font-weight: 400; }
.brand-icon {
  width: 30px; height: 30px; border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  background: linear-gradient(135deg, #3da9fc33, #22c98c22);
  border: 1px solid #2c3c56; color: var(--accent);
}
.head-info { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.chip {
  padding: 5px 11px; border-radius: 20px; font-size: 12px; font-weight: 500;
  background: var(--panel-2); border: 1px solid var(--panel-border); color: var(--muted);
  transition: background var(--trans), color var(--trans);
}
.chip.price { color: var(--text); font-weight: 700; min-width: 92px; text-align: center; font-size: 13px; }
.chip.price.up { color: var(--green); background: rgba(34, 201, 140, .1); }
.chip.price.down { color: var(--red); background: rgba(255, 91, 110, .1); }
.chip.mode { color: var(--amber); border-color: rgba(245,185,66,.5); text-transform: uppercase; font-weight: 700; font-size: 11px; }
.chip.mode.live { color: var(--red); border-color: rgba(255,91,110,.6); }
.chip.mode.paper { color: var(--accent); border-color: rgba(61,169,252,.5); }
.chip.status { display: inline-flex; align-items: center; gap: 6px; }
.chip.status .dot { width: 7px; height: 7px; border-radius: 50%; background: var(--muted); }
.chip.status.on { color: var(--green); border-color: rgba(34,201,140,.4); }
.chip.status.on .dot { background: var(--green); animation: pulse 2s infinite; }
@keyframes pulse { 0%,100% { box-shadow: 0 0 0 0 rgba(34,201,140,.5);} 50% { box-shadow: 0 0 0 4px rgba(34,201,140,0);} }

main {
  flex: 1; display: grid; gap: 10px; padding: 10px;
  grid-template-columns: 250px 1fr 300px;
  grid-template-rows: minmax(0, 1fr) 220px;
  grid-template-areas: "dom chart side" "dom bottom side";
  min-height: 0;
}

.panel {
  background: var(--panel); border: 1px solid var(--panel-border-soft);
  border-radius: var(--radius); padding: 12px; min-height: 0; overflow: hidden;
  box-shadow: 0 1px 0 rgba(255,255,255,.02) inset;
}
.panel-title {
  font-size: 10.5px; text-transform: uppercase; letter-spacing: 1.2px; font-weight: 700;
  color: var(--muted); margin-bottom: 10px;
}
.panel-title.spaced { margin-top: 14px; }
.chart-panel { grid-area: chart; display: flex; flex-direction: column; }
#chart { flex: 1; min-height: 0; }

.side {
  grid-area: side; display: flex; flex-direction: column; gap: 10px;
  min-height: 0; overflow-y: auto;
}
.side .panel { flex-shrink: 0; }
.side .panel.grow { flex: 1 1 120px; display: flex; flex-direction: column; min-height: 120px; }

/* ---------- boleta ---------- */
.ticket-params { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-bottom: 10px; }
.param label { display: block; font-size: 10.5px; font-weight: 600; color: var(--muted); margin-bottom: 4px; }
.stepper {
  display: grid; grid-template-columns: 26px 1fr 26px;
  border: 1px solid var(--panel-border); border-radius: var(--radius-sm); overflow: hidden;
  background: var(--panel-2);
}
.stepper input {
  border: 0; background: transparent; color: var(--text); text-align: center;
  font-size: 13px; font-weight: 600; padding: 7px 0; -moz-appearance: textfield;
}
.stepper input::-webkit-outer-spin-button, .stepper input::-webkit-inner-spin-button { -webkit-appearance: none; }
.stepper input:focus { outline: none; }
.step-btn {
  border: 0; background: transparent; color: var(--muted); font-size: 15px;
  cursor: pointer; transition: background var(--trans), color var(--trans);
}
.step-btn:hover { background: #1a2334; color: var(--text); }
.ticket-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
#ticket-msg { font-size: 11.5px; min-height: 16px; margin-top: 8px; color: var(--muted); }
#ticket-msg.err { color: var(--red); }
#ticket-msg.ok { color: var(--green); }

/* ---------- risco ---------- */
.pnl-row { display: flex; justify-content: space-between; align-items: baseline; margin: 6px 0; }
.pnl-row strong { font-size: 17px; }
.pnl-row.small { color: var(--muted); font-size: 12px; }
.pnl-bar {
  position: relative; height: 10px; border-radius: 5px;
  background: var(--panel-2); border: 1px solid var(--panel-border); overflow: hidden;
}
#pnl-fill { position: absolute; top: 0; bottom: 0; left: 50%; width: 0; background: var(--green); transition: all .3s; }
.pnl-zero { position: absolute; top: 0; bottom: 0; left: 50%; width: 1px; background: var(--muted); }
.pnl-limits { display: flex; justify-content: space-between; font-size: 11px; color: var(--muted); margin-top: 4px; }
.halted {
  background: rgba(255,91,110,.12); border: 1px solid var(--red); color: var(--red);
  padding: 8px 10px; border-radius: var(--radius-sm); font-size: 12px; margin-bottom: 8px;
  animation: blink 1.6s ease infinite;
}
@keyframes blink { 50% { opacity: .65; } }

/* ---------- posição ---------- */
#position-box { font-size: 13px; }
#position-box.empty { color: var(--muted); font-style: italic; }
#position-box .pos-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 5px 10px; }
#position-box .side-tag { font-weight: 700; padding: 2px 9px; border-radius: 5px; font-size: 12px; }
#position-box .side-tag.BUY { background: rgba(34,201,140,.15); color: var(--green); }
#position-box .side-tag.SELL { background: rgba(255,91,110,.15); color: var(--red); }

/* ---------- estratégias / segmented ---------- */
.strategy-row {
  display: flex; justify-content: space-between; align-items: center;
  padding: 8px 0; border-bottom: 1px solid var(--panel-border-soft); font-size: 13px;
}
.strategy-row:last-child { border-bottom: 0; }
.strategy-row .meta { color: var(--muted); font-size: 11px; margin-top: 2px; }
.switch {
  width: 40px; height: 21px; border-radius: 12px; border: 1px solid var(--panel-border);
  background: var(--panel-2); cursor: pointer; position: relative; flex-shrink: 0;
  transition: background var(--trans), border-color var(--trans);
}
.switch::after {
  content: ""; position: absolute; top: 2px; left: 2px; width: 15px; height: 15px;
  border-radius: 50%; background: var(--muted); transition: all .2s;
}
.switch.on { background: rgba(34,201,140,.25); border-color: var(--green); }
.switch.on::after { left: 21px; background: var(--green); }
.switch:focus-visible { outline: none; box-shadow: var(--focus); }

.segmented {
  display: flex; gap: 0; background: var(--panel-2);
  border: 1px solid var(--panel-border); border-radius: var(--radius-sm); padding: 3px;
}
.segmented > button {
  flex: 1; padding: 6px 10px; border: 0; border-radius: 6px; cursor: pointer; font-size: 12px;
  font-weight: 600; background: transparent; color: var(--muted);
  transition: background var(--trans), color var(--trans);
}
.segmented > button:hover { color: var(--text); }
.segmented > button.active, .segmented > .mode-btn.active {
  color: var(--accent); background: rgba(61,169,252,.12);
}
.segmented > .mode-btn.danger.active { color: var(--red); background: rgba(255,91,110,.12); }
.segmented > button:focus-visible { outline: none; box-shadow: var(--focus); }

/* ---------- feeds ---------- */
#flow-feed { list-style: none; overflow-y: auto; flex: 1; font-size: 12px; min-height: 0; }
#flow-feed li {
  padding: 7px 9px; border-left: 3px solid var(--accent);
  background: var(--panel-2); border-radius: 5px; margin-bottom: 6px;
  animation: slide-in .25s ease;
}
@keyframes slide-in { from { opacity: 0; transform: translateX(-6px); } }
#flow-feed li.AGGRESSION { border-color: var(--red); }
#flow-feed li.ICEBERG { border-color: var(--amber); }
#flow-feed li.RVOL_SPIKE { border-color: var(--accent); }
#flow-feed li.DOM_IMBALANCE { border-color: var(--green); }
#flow-feed .kind { font-weight: 700; font-size: 11px; }
#flow-feed .ts { color: var(--muted); float: right; font-size: 10px; }

.bottom { grid-area: bottom; display: flex; flex-direction: column; }
.tabs { margin-bottom: 8px; align-self: flex-start; }
.tab .badge {
  background: rgba(61,169,252,.2); color: var(--accent); border-radius: 10px;
  font-size: 10px; padding: 1px 7px; margin-left: 4px;
}
.tab-body { flex: 1; overflow-y: auto; min-height: 0; }

#tape { list-style: none; font-size: 12px; }
#tape li { display: flex; gap: 16px; padding: 1.5px 6px; border-radius: 3px; }
#tape li:first-child { background: rgba(255,255,255,.03); }
#tape li.BUY .px { color: var(--green); }
#tape li.SELL .px { color: var(--red); }
#tape .ts { color: var(--muted); }
#tape .vol { min-width: 50px; text-align: right; }

table { width: 100%; border-collapse: collapse; font-size: 12px; }
th, td { text-align: left; padding: 5px 8px; border-bottom: 1px solid var(--panel-border-soft); }
th { color: var(--muted); font-weight: 600; position: sticky; top: 0; background: var(--panel); font-family: "Inter", sans-serif; }
td.pos { color: var(--green); } td.neg { color: var(--red); }

#audit-feed { list-style: none; font-size: 12px; }
#audit-feed li { padding: 4px 6px; border-bottom: 1px solid var(--panel-border-soft); }
#audit-feed .cat { color: var(--accent); font-weight: 600; margin-right: 6px; }
#audit-feed .ts { color: var(--muted); margin-right: 6px; font-size: 11px; font-family: "JetBrains Mono", monospace; }

/* ---------- SuperDOM ---------- */
.dom-panel { grid-area: dom; display: flex; flex-direction: column; }
.dom-imbalance {
  position: relative; height: 8px; border-radius: 4px; overflow: hidden;
  background: rgba(255,91,110,.25); border: 1px solid var(--panel-border);
}
#dom-imb-fill { position: absolute; top: 0; bottom: 0; left: 0; width: 50%; background: rgba(34,201,140,.55); transition: width .25s; }
.dom-imb-zero { position: absolute; top: 0; bottom: 0; left: 50%; width: 1px; background: var(--text); opacity: .5; }
.dom-imb-labels { display: flex; justify-content: space-between; font-size: 10px; color: var(--muted); margin: 3px 0 8px; }
.dom-head, .dom-row {
  display: grid; grid-template-columns: 52px 1fr 56px 1fr; gap: 4px;
  align-items: center; font-family: "JetBrains Mono", Consolas, monospace; font-size: 11.5px;
}
.dom-head {
  color: var(--muted); font-size: 9.5px; text-transform: uppercase;
  letter-spacing: .5px; padding: 2px 0 6px; text-align: center; font-family: "Inter", sans-serif; font-weight: 600;
}
.dom-head span:first-child { text-align: left; }
#dom-ladder { flex: 1; overflow-y: auto; min-height: 0; }
.dom-row { padding: 1px 0; border-radius: 3px; }
.dom-row .cell { position: relative; height: 17px; line-height: 17px; }
.dom-row .vp { color: var(--muted); font-size: 10px; text-align: left; }
.dom-row .vp .bar { position: absolute; left: 0; top: 3px; bottom: 3px; background: rgba(61,169,252,.25); border-radius: 2px; }
.dom-row .vp .num { position: relative; padding-left: 2px; }
.dom-row .bid { text-align: right; color: var(--green); }
.dom-row .ask { text-align: left; color: var(--red); }
.dom-row .bid .bar { position: absolute; right: 0; top: 2px; bottom: 2px; background: rgba(34,201,140,.18); border-radius: 2px; }
.dom-row .ask .bar { position: absolute; left: 0; top: 2px; bottom: 2px; background: rgba(255,91,110,.18); border-radius: 2px; }
.dom-row .bid .num, .dom-row .ask .num { position: relative; padding: 0 4px; }
.dom-row .px { text-align: center; color: var(--muted); }
.dom-row.best-bid .px, .dom-row.best-ask .px { color: var(--text); }
.dom-row.last .px { color: #04121f; font-weight: 700; border-radius: 3px; }
.dom-row.last.buy .px { background: var(--green); }
.dom-row.last.sell .px { background: var(--red); }
.dom-foot {
  display: flex; justify-content: space-between; margin-top: 6px;
  font-size: 11px; color: var(--muted); font-family: "JetBrains Mono", monospace;
}

/* ---------- responsivo ---------- */
@media (max-width: 1100px) {
  body { overflow: auto; }
  main {
    grid-template-columns: 1fr;
    grid-template-rows: 420px 440px auto 260px;
    grid-template-areas: "chart" "dom" "side" "bottom";
  }
}
