:root {
  --bg: #060913;
  --bg2: #0b1020;
  --card: #10172a;
  --card2: #172038;
  --glass: rgba(18, 25, 46, .62);
  --glass2: rgba(28, 37, 66, .66);
  --line: rgba(139, 147, 255, .10);
  --line2: rgba(139, 147, 255, .20);
  --text: #eef1ff;
  --muted: #8b93b5;
  --gain: #00e39a;
  --gain-bg: rgba(0, 227, 154, .12);
  --loss: #ff4d6d;
  --loss-bg: rgba(255, 77, 109, .12);
  --accent: #7c5cff;
  --accent2: #22d3ee;
  --accent-bg: rgba(124, 92, 255, .16);
  --grad: linear-gradient(135deg, #8b5cf6 0%, #6366f1 45%, #22d3ee 100%);
  --grad-buy: linear-gradient(160deg, #2bf5b0 0%, #00c98a 55%, #00a676 100%);
  --grad-sell: linear-gradient(160deg, #ff7a93 0%, #ff4d6d 55%, #e0244d 100%);
  --plan: #c084fc;
  --warn: #ffb547;
  --radius: 14px;
  --ease: cubic-bezier(.22, 1, .36, 1);
  --spring: cubic-bezier(.34, 1.56, .64, 1);
  --display: "Sora", "Inter", system-ui, sans-serif;
  --mono: "JetBrains Mono", ui-monospace, Consolas, monospace;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--text);
  font: 14px/1.4 Inter, system-ui, -apple-system, "Segoe UI", sans-serif;
  -webkit-font-smoothing: antialiased;
}
button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; }
.hidden { display: none !important; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.mono { font-family: var(--mono); font-variant-numeric: tabular-nums; }
.gain { color: var(--gain); }
.loss { color: var(--loss); }
.right { text-align: right; }
.grow { flex: 1; }
.mt { margin-top: 18px; }
.row-between { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.row-gap { display: flex; gap: 8px; }

input, select {
  background: var(--bg2); border: 1px solid var(--line2); border-radius: 8px;
  padding: 8px 10px; outline: none; min-width: 0;
}
input:focus, select:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-bg); }

/* ---------- botões ---------- */
.btn {
  border: 1px solid transparent; border-radius: 9px; padding: 9px 14px; font-weight: 600;
  background: var(--card2); transition: background .15s, border-color .15s, transform .05s;
}
.btn:active { transform: translateY(1px); }
.btn.primary { background: var(--accent); color: #fff; }
.btn.primary:hover { background: #6a9dff; }
.btn.ghost { background: transparent; border-color: var(--line2); }
.btn.ghost:hover { background: var(--card2); }
.btn.danger { background: var(--loss-bg); color: var(--loss); border-color: rgba(240,70,90,.35); }
.btn.danger:hover { background: rgba(240,70,90,.22); }
.btn.outline { background: transparent; border-color: var(--line2); }
.btn.buy-o:hover { border-color: var(--gain); color: var(--gain); }
.btn.sell-o:hover { border-color: var(--loss); color: var(--loss); }
.btn.small { padding: 5px 10px; font-size: 12px; }
.btn.block { width: 100%; }
.btn:disabled { opacity: .55; cursor: wait; }
.link { background: none; border: 0; color: var(--accent); padding: 0; font-size: 12px; }
.icon-btn { background: none; border: 0; font-size: 20px; padding: 4px 8px; }

.brand { font-weight: 700; font-size: 16px; display: flex; align-items: center; gap: 8px; letter-spacing: .2px; white-space: nowrap; }
.brand .logo { color: var(--accent); }
.brand small { color: var(--muted); font-weight: 600; }
.brand.big { font-size: 24px; }

/* ---------- login ---------- */
.login-view {
  min-height: 100%; display: grid; place-items: center; padding: 24px 16px;
  background: radial-gradient(1000px 600px at 20% -10%, rgba(79,140,255,.18), transparent 60%),
              radial-gradient(800px 500px at 110% 110%, rgba(25,195,125,.12), transparent 60%), var(--bg);
}
.login-card {
  width: 100%; max-width: 420px; background: var(--card); border: 1px solid var(--line);
  border-radius: 18px; padding: 28px; display: grid; gap: 14px; box-shadow: 0 30px 80px rgba(0,0,0,.45);
}
.login-card p { margin: 0; }
.fld { display: grid; gap: 6px; font-size: 13px; color: var(--muted); }
.fld input, .fld select { color: var(--text); font-size: 14px; }
.fld.inline { margin-bottom: 10px; }
.chk { display: flex; align-items: center; gap: 8px; font-size: 13px; cursor: pointer; user-select: none; }
.chk.strong { font-weight: 600; margin: 8px 0; }
.chk input { width: 16px; height: 16px; accent-color: var(--accent); margin: 0; }
.hint { font-size: 12px; color: var(--muted); }
.hint.warn { color: var(--warn); background: rgba(245,176,65,.08); border: 1px solid rgba(245,176,65,.25); border-radius: 8px; padding: 8px 10px; }
.error { color: var(--loss); min-height: 1em; font-size: 13px; }

/* ---------- app ---------- */
.app { height: 100%; display: flex; flex-direction: column; }
.topbar {
  display: flex; align-items: center; gap: 18px; padding: 10px 16px; border-bottom: 1px solid var(--line);
  background: var(--bg2);
}
.acct { display: flex; align-items: center; gap: 10px; }
.acct-text { display: grid; line-height: 1.2; font-size: 13px; }
.acct-text .muted { font-size: 11px; }
.badge { font-size: 10px; font-weight: 700; padding: 3px 7px; border-radius: 6px; background: var(--accent-bg); color: var(--accent); letter-spacing: .6px; }
.badge.real { background: var(--loss-bg); color: var(--loss); }
.metrics { display: flex; gap: 20px; flex: 1; overflow-x: auto; scrollbar-width: none; }
.metrics::-webkit-scrollbar { display: none; }
.metric { display: grid; line-height: 1.2; white-space: nowrap; }
.metric span { font-size: 11px; color: var(--muted); }
.metric b { font-family: var(--mono); font-weight: 600; font-size: 14px; }
.top-right { display: flex; align-items: center; gap: 12px; }
.conn { display: flex; align-items: center; gap: 6px; font-size: 12px; color: var(--muted); white-space: nowrap; }
.conn i { width: 8px; height: 8px; border-radius: 50%; background: var(--warn); box-shadow: 0 0 0 3px rgba(245,176,65,.15); }
.conn.ok i { background: var(--gain); box-shadow: 0 0 0 3px rgba(25,195,125,.15); }
.conn.bad i { background: var(--loss); box-shadow: 0 0 0 3px rgba(240,70,90,.15); }

.banner { padding: 8px 16px; background: rgba(245,176,65,.12); color: var(--warn); border-bottom: 1px solid rgba(245,176,65,.3); font-size: 13px; }

.layout {
  flex: 1; min-height: 0; display: grid; gap: 10px; padding: 10px;
  grid-template-columns: 250px minmax(0, 1fr) 300px;
  grid-template-rows: minmax(0, 1fr) 280px;
  grid-template-areas: "watch chart ticket" "watch bottom bottom";
}
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); min-width: 0; min-height: 0; }

/* ---------- watchlist ---------- */
.watch { grid-area: watch; display: flex; flex-direction: column; overflow: hidden; }
.watch-search { position: relative; padding: 10px; border-bottom: 1px solid var(--line); }
.watch-search input { width: 100%; }
.sym-results {
  position: absolute; left: 10px; right: 10px; top: calc(100% - 4px); z-index: 30; max-height: 340px; overflow: auto;
  background: var(--card2); border: 1px solid var(--line2); border-radius: 10px; box-shadow: 0 16px 40px rgba(0,0,0,.5);
}
.sym-results div { padding: 8px 10px; cursor: pointer; display: grid; }
.sym-results div:hover, .sym-results div.sel { background: var(--accent-bg); }
.sym-results small { color: var(--muted); font-size: 11px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.watch-head, .watch-row { display: grid; grid-template-columns: 1.3fr 1fr 1fr .8fr; gap: 6px; padding: 6px 12px; align-items: center; }
.watch-head { font-size: 11px; color: var(--muted); border-bottom: 1px solid var(--line); }
.watch-head span:not(:first-child) { text-align: right; }
.watch-list { overflow: auto; flex: 1; }
.watch-row { cursor: pointer; border-bottom: 1px solid rgba(31,42,61,.6); position: relative; }
.watch-row:hover { background: var(--card2); }
.watch-row.active { background: var(--accent-bg); box-shadow: inset 3px 0 0 var(--accent); }
.watch-row .nm { font-weight: 600; font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.watch-row .px { font-family: var(--mono); font-size: 12px; text-align: right; transition: color .3s; }
.watch-row .ch { font-size: 11px; text-align: right; font-family: var(--mono); }
.watch-row .rm { position: absolute; right: 4px; top: 50%; transform: translateY(-50%); display: none; background: var(--card); border: 1px solid var(--line2); border-radius: 6px; font-size: 11px; padding: 1px 6px; }
.watch-row:hover .rm { display: block; }
.up { color: var(--gain) !important; }
.down { color: var(--loss) !important; }

/* ---------- gráfico ---------- */
.chart-area { grid-area: chart; display: flex; flex-direction: column; overflow: hidden; }
.chart-toolbar { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 8px 12px; border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.chart-title b { font-size: 16px; margin-right: 8px; }
.tfs { display: flex; gap: 2px; background: var(--bg2); padding: 3px; border-radius: 9px; border: 1px solid var(--line); }
.tfs button { background: none; border: 0; padding: 4px 9px; border-radius: 6px; font-size: 12px; color: var(--muted); font-weight: 600; }
.tfs button.on { background: var(--card2); color: var(--text); }
.chart-wrap { position: relative; flex: 1; min-height: 0; }
.chart { position: absolute; inset: 0; }
.chart.line-hover, .chart.line-hover * { cursor: ns-resize !important; }
.chart.dragging, .chart.dragging * { cursor: grabbing !important; }
.chart-legend { position: absolute; left: 12px; top: 8px; z-index: 3; pointer-events: none; font-family: var(--mono); font-size: 12px; color: var(--muted); }
.chart-help { padding: 6px 12px; border-top: 1px solid var(--line); }

/* ---------- boleta ---------- */
.ticket { grid-area: ticket; padding: 14px; display: flex; flex-direction: column; gap: 14px; overflow: auto; }
.ticket-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 8px; }
.t-symbol { font-size: 18px; font-weight: 700; }
.quote-btns { display: grid; grid-template-columns: 1fr auto 1fr; gap: 8px; align-items: stretch; }
.trade-btn {
  border: 0; border-radius: 11px; padding: 10px 8px; display: grid; gap: 2px; color: #fff; font-weight: 700;
  transition: filter .15s, transform .05s;
}
.trade-btn span { font-size: 11px; letter-spacing: 1px; opacity: .9; }
.trade-btn b { font-family: var(--mono); font-size: 17px; }
.trade-btn.sell { background: linear-gradient(180deg, #f35b6c, #d93349); }
.trade-btn.buy { background: linear-gradient(180deg, #23cf8a, #12a568); }
.trade-btn:hover { filter: brightness(1.08); }
.trade-btn:active { transform: translateY(1px); }
.trade-btn:disabled { filter: grayscale(.6) brightness(.7); cursor: wait; }
.spread { display: grid; place-items: center; align-content: center; min-width: 46px; }
.spread b { font-family: var(--mono); font-size: 13px; }

.fld-group { display: grid; gap: 8px; }
.fld-group.two { grid-template-columns: 1fr 1fr; gap: 10px; }
.fld-group.two > div { display: grid; gap: 6px; }
.seg { display: inline-flex; background: var(--bg2); border: 1px solid var(--line); border-radius: 8px; padding: 2px; }
.seg button { background: none; border: 0; padding: 4px 10px; border-radius: 6px; font-size: 12px; color: var(--muted); font-weight: 600; }
.seg button.on { background: var(--card2); color: var(--text); }
.stepper { display: grid; grid-template-columns: 34px 1fr 34px; border: 1px solid var(--line2); border-radius: 9px; overflow: hidden; background: var(--bg2); }
.stepper button { background: var(--card2); border: 0; font-size: 16px; }
.stepper button:hover { background: var(--line2); }
.stepper input { border: 0; border-radius: 0; text-align: center; font-family: var(--mono); background: transparent; box-shadow: none !important; width: 100%; }
.stepper.off { opacity: .45; }
.rr { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.rr button { background: var(--bg2); border: 1px solid var(--line2); border-radius: 7px; padding: 3px 9px; font-size: 12px; }
.rr button:hover { border-color: var(--gain); color: var(--gain); }
.plan-btns { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.plan-btns .btn { font-size: 12px; padding: 8px 6px; }
.plan-box { border: 1px solid rgba(167,139,250,.45); background: rgba(167,139,250,.07); border-radius: 11px; padding: 12px; display: grid; gap: 10px; }
.plan-box p { margin: 0; }
.plan-grid { display: grid; grid-template-columns: auto 1fr; gap: 4px 12px; font-size: 13px; }
.plan-grid span { color: var(--muted); }
.plan-grid b { text-align: right; }

.switch { display: flex; align-items: center; gap: 6px; cursor: pointer; user-select: none; }
.switch input { display: none; }
.switch .slider { width: 34px; height: 20px; border-radius: 20px; background: var(--line2); position: relative; transition: background .2s; }
.switch .slider::after { content: ""; position: absolute; width: 14px; height: 14px; border-radius: 50%; background: #fff; top: 3px; left: 3px; transition: left .2s; }
.switch input:checked + .slider { background: var(--warn); }
.switch input:checked + .slider::after { left: 17px; }

/* ---------- painel inferior ---------- */
.bottom { grid-area: bottom; display: flex; flex-direction: column; overflow: hidden; }
.tabs { display: flex; align-items: center; gap: 2px; padding: 6px 8px 0; border-bottom: 1px solid var(--line); }
.tabs button { background: none; border: 0; padding: 8px 12px; font-weight: 600; color: var(--muted); border-bottom: 2px solid transparent; font-size: 13px; }
.tabs button.on { color: var(--text); border-bottom-color: var(--accent); }
.count { background: var(--card2); border-radius: 10px; padding: 1px 7px; font-size: 11px; margin-left: 4px; }
.tab-total { padding-right: 8px; }
.tab-body { flex: 1; min-height: 0; display: flex; flex-direction: column; }
.bulk { display: flex; gap: 6px; padding: 8px 10px; align-items: center; flex-wrap: wrap; }
.bulk select { padding: 4px 8px; font-size: 12px; }
.table-wrap { flex: 1; overflow: auto; min-height: 0; }
.grid { width: 100%; border-collapse: collapse; font-size: 13px; }
.grid th { position: sticky; top: 0; background: var(--card); text-align: left; font-size: 11px; color: var(--muted); font-weight: 600; padding: 6px 10px; border-bottom: 1px solid var(--line); white-space: nowrap; z-index: 1; }
.grid td { padding: 6px 10px; border-bottom: 1px solid rgba(31,42,61,.7); white-space: nowrap; font-variant-numeric: tabular-nums; }
.grid td.num { font-family: var(--mono); font-size: 12px; }
.grid tbody tr:hover { background: rgba(23,32,51,.6); }
.grid tbody tr.cur { box-shadow: inset 3px 0 0 var(--accent); }
.empty { padding: 26px; text-align: center; color: var(--muted); }
.tag { font-size: 10px; font-weight: 700; padding: 2px 6px; border-radius: 5px; letter-spacing: .4px; }
.tag.buy { background: var(--gain-bg); color: var(--gain); }
.tag.sell { background: var(--loss-bg); color: var(--loss); }
.sym-link { font-weight: 600; cursor: pointer; }
.sym-link:hover { color: var(--accent); }

.lvl { display: inline-flex; align-items: center; gap: 2px; }
.lvl button { width: 20px; height: 20px; border-radius: 5px; border: 1px solid var(--line2); background: var(--bg2); font-size: 12px; line-height: 1; padding: 0; color: var(--muted); }
.lvl button:hover { color: var(--text); border-color: var(--accent); }
.lvl .val { font-family: var(--mono); font-size: 12px; min-width: 64px; text-align: center; cursor: text; padding: 2px 4px; border-radius: 5px; }
.lvl .val:hover { background: var(--card2); }
.lvl .val.none { color: var(--muted); }
.lvl input { width: 86px; padding: 2px 6px; font-family: var(--mono); font-size: 12px; }

.chips { display: inline-flex; gap: 4px; }
.chip { font-size: 10px; font-weight: 700; padding: 2px 6px; border-radius: 5px; background: var(--card2); color: var(--muted); border: 1px solid var(--line2); }
.chip.on { color: var(--accent); border-color: rgba(79,140,255,.4); background: var(--accent-bg); }
.chip.done { color: var(--gain); border-color: rgba(25,195,125,.35); background: var(--gain-bg); }
.chip.err { color: var(--loss); border-color: rgba(240,70,90,.35); background: var(--loss-bg); }

.acts { display: inline-flex; gap: 4px; justify-content: flex-end; width: 100%; }
.act { border: 1px solid var(--line2); background: var(--bg2); border-radius: 7px; padding: 3px 8px; font-size: 12px; font-weight: 600; color: var(--text); }
.act:hover { border-color: var(--accent); }
.act.be:hover { border-color: var(--gain); color: var(--gain); }
.act.ts.on { border-color: var(--accent); color: var(--accent); background: var(--accent-bg); }
.act.x { color: var(--loss); }
.act.x:hover { border-color: var(--loss); background: var(--loss-bg); }

/* ---------- automação ---------- */
.auto-grid { display: grid; grid-template-columns: 1.4fr 1fr; gap: 10px; padding: 10px; overflow: auto; }
.auto-card { background: var(--bg2); border: 1px solid var(--line); border-radius: 10px; padding: 14px; }
.auto-card h3 { margin: 0 0 6px; font-size: 14px; }
.auto-card p { margin: 0 0 8px; }
.rule-fields { display: grid; gap: 10px; margin: 8px 0 12px; }
.rule-block { border: 1px solid var(--line); border-radius: 9px; padding: 10px; display: grid; gap: 8px; }
.rule-block .nums { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.rule-block label.n { display: grid; gap: 4px; font-size: 11px; color: var(--muted); }
.rule-block label.n input { padding: 6px 8px; font-family: var(--mono); color: var(--text); }
.rule-block .desc { font-size: 11px; color: var(--muted); }
.event-log { display: grid; gap: 4px; max-height: 220px; overflow: auto; font-size: 12px; }
.event-log div { padding: 4px 0; border-bottom: 1px solid var(--line); }

/* ---------- menus, modal, toasts ---------- */
.ctx {
  position: fixed; z-index: 60; min-width: 230px; background: var(--card2); border: 1px solid var(--line2);
  border-radius: 10px; padding: 5px; box-shadow: 0 18px 50px rgba(0,0,0,.55);
}
.ctx .hd { padding: 6px 10px; font-size: 11px; color: var(--muted); font-family: var(--mono); }
.ctx button { display: block; width: 100%; text-align: left; background: none; border: 0; padding: 8px 10px; border-radius: 7px; font-size: 13px; }
.ctx button:hover { background: var(--accent-bg); }
.ctx hr { border: 0; border-top: 1px solid var(--line2); margin: 4px 0; }

.modal { position: fixed; inset: 0; z-index: 70; background: rgba(5,8,14,.65); display: grid; place-items: center; padding: 16px; backdrop-filter: blur(3px); }
.modal-card { width: 100%; max-width: 460px; background: var(--card); border: 1px solid var(--line2); border-radius: 16px; padding: 20px; display: grid; gap: 14px; max-height: 90vh; overflow: auto; }
.modal-card h3 { margin: 0; font-size: 17px; }
.modal-card .actions { display: flex; justify-content: flex-end; gap: 8px; }
.summary { display: grid; grid-template-columns: auto 1fr; gap: 6px 14px; font-size: 13px; }
.summary span { color: var(--muted); }
.summary b { text-align: right; font-family: var(--mono); }

.toasts { position: fixed; right: 16px; bottom: 16px; z-index: 80; display: grid; gap: 8px; max-width: min(380px, calc(100vw - 32px)); }
.toast { background: var(--card2); border: 1px solid var(--line2); border-left: 4px solid var(--accent); border-radius: 10px; padding: 10px 14px; font-size: 13px; box-shadow: 0 12px 30px rgba(0,0,0,.45); animation: tin .2s ease-out; }
.toast.ok { border-left-color: var(--gain); }
.toast.error { border-left-color: var(--loss); }
@keyframes tin { from { transform: translateY(8px); opacity: 0; } }

.divider { display: flex; align-items: center; gap: 10px; color: var(--muted); font-size: 12px; }
.divider::before, .divider::after { content: ""; flex: 1; border-top: 1px solid var(--line2); }
.link.center { justify-self: center; }
.app { height: 100dvh; }
.topbar { padding-top: max(10px, env(safe-area-inset-top)); padding-left: max(16px, env(safe-area-inset-left)); padding-right: max(16px, env(safe-area-inset-right)); }

/* =================================================================== peças comuns (PC e celular) */
.m-top, .m-nav, .dock, .m-view, .sheet-grab, .sheet-backdrop, .only-mobile { display: none; }

.tool-btn {
  display: inline-flex; align-items: center; gap: 6px; background: var(--bg2); border: 1px solid var(--line);
  border-radius: 9px; padding: 5px 10px; font-size: 12px; font-weight: 600; color: var(--muted);
}
.tool-btn:hover, .tool-btn.on { color: var(--text); border-color: var(--line2); }
.tool-btn .fx { font-style: italic; font-weight: 700; color: var(--accent); }

.chart.placing, .chart.placing * { cursor: crosshair !important; }

.place-banner {
  position: absolute; left: 50%; top: 10px; transform: translateX(-50%); z-index: 6;
  display: flex; align-items: center; gap: 10px; white-space: nowrap;
  background: rgba(79,140,255,.18); border: 1px solid rgba(79,140,255,.55); color: #dbe6ff;
  backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
  padding: 8px 8px 8px 14px; border-radius: 999px; font-size: 13px; font-weight: 600;
  box-shadow: 0 10px 30px rgba(0,0,0,.4); animation: pulse 1.6s ease-in-out infinite;
}
@keyframes pulse { 50% { box-shadow: 0 0 0 6px rgba(79,140,255,.12), 0 10px 30px rgba(0,0,0,.4); } }
.pb-cancel { background: rgba(255,255,255,.1); border: 0; border-radius: 999px; padding: 5px 12px; font-size: 12px; font-weight: 600; }

.float-bars { position: absolute; left: 10px; right: 64px; bottom: 34px; z-index: 5; display: grid; gap: 8px; pointer-events: none; }
.pos-strip, .plan-strip {
  pointer-events: auto; display: flex; align-items: center; gap: 6px; max-width: 560px;
  background: rgba(18,25,39,.86); border: 1px solid rgba(255,255,255,.08); border-radius: 14px;
  padding: 6px; backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px); box-shadow: 0 12px 30px rgba(0,0,0,.45);
}
.plan-strip { border-color: rgba(167,139,250,.5); }
.ps-main { flex: 1; min-width: 0; display: flex; align-items: center; gap: 8px; padding: 0 4px; font-size: 13px; white-space: nowrap; overflow: hidden; }
.ps-main small { color: var(--muted); }
.ps-nav { background: none; border: 0; color: var(--muted); font-size: 20px; width: 26px; padding: 0; }
.ps-acts { display: flex; gap: 4px; }
.ps-acts button, .pill-btn {
  border: 1px solid var(--line2); background: var(--bg2); border-radius: 9px; padding: 6px 10px; font-size: 12px; font-weight: 700;
}
.ps-acts button.loss { color: var(--loss); }
.ps-acts button.gain { color: var(--gain); }
.ps-acts button.x { color: var(--loss); }
.pill-btn.primary { background: var(--plan); border-color: var(--plan); color: #140b2b; }
.pill-btn.ghost { color: var(--muted); }

.presets { display: flex; gap: 6px; flex-wrap: wrap; }
.presets button { flex: 1; min-width: 44px; background: var(--bg2); border: 1px solid var(--line2); border-radius: 8px; padding: 5px 4px; font-size: 12px; font-family: var(--mono); }
.presets button.on { border-color: var(--accent); color: var(--accent); background: var(--accent-bg); }

/* painel lateral (indicadores) no PC */
.sheet {
  position: fixed; z-index: 65; right: 16px; top: 72px; width: 380px; max-height: calc(100dvh - 100px);
  display: flex; flex-direction: column; background: var(--card); border: 1px solid var(--line2); border-radius: 16px;
  box-shadow: 0 30px 80px rgba(0,0,0,.55); visibility: hidden; opacity: 0; transform: translateY(8px);
  transition: opacity .18s, transform .18s, visibility 0s .18s;
}
.sheet.open { visibility: visible; opacity: 1; transform: none; transition: opacity .18s, transform .18s; }
.sheet-head { display: flex; align-items: center; justify-content: space-between; padding: 14px 16px 8px; font-size: 16px; }
.sheet-body { overflow-y: auto; padding: 4px 16px 18px; display: grid; gap: 10px; }

/* indicadores */
.ind-row { background: var(--bg2); border: 1px solid var(--line); border-radius: 12px; padding: 10px 12px; display: grid; gap: 10px; }
.ind-top { display: flex; align-items: center; gap: 10px; }
.ind-top .sw { width: 12px; height: 12px; border-radius: 4px; flex: none; }
.ind-top b { flex: 1; font-size: 14px; }
.ind-params { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.ind-params .lbl { font-size: 11px; color: var(--muted); }
.mini-step { display: inline-flex; align-items: center; border: 1px solid var(--line2); border-radius: 9px; overflow: hidden; background: var(--bg); }
.mini-step button { background: var(--card2); border: 0; width: 32px; height: 30px; font-size: 16px; }
.mini-step b { min-width: 38px; text-align: center; font-family: var(--mono); font-size: 13px; }
.seg.wide { display: flex; width: 100%; }
.seg.wide button { flex: 1; padding: 7px 4px; }
.toggle { position: relative; width: 42px; height: 24px; flex: none; }
.toggle input { position: absolute; opacity: 0; inset: 0; margin: 0; cursor: pointer; z-index: 1; }
.toggle span { position: absolute; inset: 0; border-radius: 99px; background: var(--line2); transition: background .2s; }
.toggle span::after { content: ""; position: absolute; width: 18px; height: 18px; left: 3px; top: 3px; border-radius: 50%; background: #fff; transition: transform .2s; box-shadow: 0 1px 3px rgba(0,0,0,.4); }
.toggle input:checked + span { background: var(--accent); }
.toggle input:checked + span::after { transform: translateX(18px); }

/* cartões (usados na tela do celular) */
.cards { display: grid; gap: 10px; }
.pcard {
  background: linear-gradient(180deg, rgba(23,32,51,.9), rgba(18,25,39,.9)); border: 1px solid rgba(255,255,255,.06);
  border-radius: 18px; padding: 14px; display: grid; gap: 12px; position: relative; overflow: hidden;
}
.pcard::before { content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 3px; background: var(--line2); }
.pcard.buy::before { background: var(--gain); }
.pcard.sell::before { background: var(--loss); }
.pcard.cur { border-color: rgba(79,140,255,.35); }
.pc-top { display: flex; justify-content: space-between; align-items: flex-start; gap: 10px; }
.pc-id { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.pc-id .sym-link { font-size: 17px; }
.pc-id .vol { color: var(--muted); font-family: var(--mono); font-size: 13px; }
.pc-id .vol::after { content: " lote"; }
.pc-pl { text-align: right; display: grid; }
.pc-pl b { white-space: nowrap; font-size: 20px; font-family: var(--mono); font-weight: 600; letter-spacing: -.3px; }
.pc-pl [data-f="pts"] { font-size: 12px; font-family: var(--mono); }
.pc-pl [data-f="pts"]::after { content: " pts"; color: var(--muted); }
.pc-mid { display: grid; grid-template-columns: 1fr 1fr auto; gap: 8px; align-items: end; font-family: var(--mono); font-size: 13px; }
.pc-mid small { display: block; font-family: Inter, sans-serif; font-size: 11px; color: var(--muted); margin-bottom: 2px; }
.pc-lv { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.pc-lvl { background: rgba(10,14,22,.55); border: 1px solid var(--line); border-radius: 12px; padding: 8px; display: grid; gap: 6px; justify-items: center; }
.pc-lvl > small { font-size: 11px; font-weight: 700; letter-spacing: .4px; text-transform: uppercase; }
.pc-lvl .lvl { width: 100%; justify-content: space-between; }
.pc-lvl .lvl .val { flex: 1; }
.pc-acts { display: grid !important; grid-template-columns: repeat(6, 1fr); gap: 6px; }
.pc-acts .act { padding: 10px 0; border-radius: 11px; font-size: 14px; }
.hcard { background: rgba(23,32,51,.7); border: 1px solid rgba(255,255,255,.05); border-radius: 14px; padding: 12px 14px; display: flex; align-items: center; gap: 12px; }
.hcard .h-main { flex: 1; min-width: 0; display: grid; gap: 2px; }
.hcard .h-main b { font-size: 15px; }
.hcard .h-main span { font-size: 12px; color: var(--muted); font-family: var(--mono); }
.hcard .h-net { font-family: var(--mono); font-weight: 600; font-size: 16px; text-align: right; }

.credit { text-align: center; font-size: 11px; color: var(--muted); margin: 22px 0 6px; }
.credit a, .credit-inline a { color: var(--muted); text-decoration: underline; }

/* =================================================================== PC menor */
@media (max-width: 1250px) {
  .layout { grid-template-columns: 220px minmax(0, 1fr) 280px; }
  .metric:nth-child(n+6) { display: none; }
}

/* =================================================================== CELULAR */
@media (max-width: 820px), (max-height: 500px) {
  html, body { height: 100%; overflow: hidden; overscroll-behavior: none; }
  body {
    position: fixed; inset: 0; touch-action: manipulation; -webkit-tap-highlight-color: transparent;
    -webkit-user-select: none; user-select: none; -webkit-touch-callout: none;
    background: radial-gradient(900px 500px at 50% -20%, rgba(79,140,255,.10), transparent 60%), var(--bg);
  }
  input, select, textarea { -webkit-user-select: text; user-select: text; font-size: 16px; }
  .login-view { position: fixed; inset: 0; overflow-y: auto; -webkit-overflow-scrolling: touch; }

  .topbar, .bottom, .chart-help, .chart-title, .watch-head .x { display: none !important; }

  .app { position: fixed; inset: 0; height: auto; display: flex; flex-direction: column; }

  /* ----- cabeçalho */
  .m-top {
    display: flex; align-items: center; justify-content: space-between; gap: 10px;
    padding: calc(env(safe-area-inset-top) + 8px) max(14px, env(safe-area-inset-right)) 8px max(14px, env(safe-area-inset-left));
    background: linear-gradient(180deg, rgba(10,14,22,.95), rgba(10,14,22,.75));
    border-bottom: 1px solid rgba(255,255,255,.05); z-index: 20;
  }
  .m-sym { background: none; border: 0; padding: 0; text-align: left; display: grid; gap: 1px; min-width: 0; }
  .m-sym-name { display: flex; align-items: center; gap: 4px; font-size: 19px; letter-spacing: -.2px; }
  .m-sym-name svg { color: var(--muted); }
  .m-sym-sub { font-size: 12px; color: var(--muted); }
  .m-top-right { display: flex; align-items: center; gap: 10px; }
  .m-eq { display: grid; text-align: right; line-height: 1.15; }
  .m-eq span { font-size: 10px; color: var(--muted); text-transform: uppercase; letter-spacing: .5px; }
  .m-eq b { font-size: 14px; }
  .m-pl { white-space: nowrap; font-size: 13px; font-weight: 600; padding: 6px 10px; border-radius: 10px; background: var(--card2); border: 1px solid var(--line); min-width: 74px; text-align: center; }
  .m-pl.gain { background: var(--gain-bg); border-color: rgba(25,195,125,.3); }
  .m-pl.loss { background: var(--loss-bg); border-color: rgba(240,70,90,.3); }
  .m-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--warn); flex: none; }
  .m-dot.ok { background: var(--gain); box-shadow: 0 0 0 3px rgba(25,195,125,.18); }
  .m-dot.bad { background: var(--loss); }
  .banner { font-size: 12px; padding: 6px 14px; }

  /* ----- telas */
  .layout { flex: 1; min-height: 0; position: relative; display: block; padding: 0; overflow: hidden; }
  .layout > .watch, .layout > .chart-area, .layout > .m-view {
    position: absolute; inset: 0; display: flex; flex-direction: column; border: 0; border-radius: 0; background: transparent;
    visibility: hidden; opacity: 0; transition: opacity .16s ease, visibility 0s .16s;
  }
  .app[data-view="markets"] .watch,
  .app[data-view="chart"] .chart-area,
  .app[data-view="positions"] #mv-positions,
  .app[data-view="history"] #mv-history,
  .app[data-view="account"] #mv-account { visibility: visible; opacity: 1; transition: opacity .16s ease; z-index: 1; }

  .mv-scroll, .watch-list {
    flex: 1; min-height: 0; overflow-y: auto; overflow-x: hidden; overscroll-behavior: contain;
    -webkit-overflow-scrolling: touch; touch-action: pan-y; padding: 10px 12px 18px;
  }

  /* ----- mercado */
  .watch-search { padding: 12px; border: 0; }
  .watch-search input { border-radius: 12px; padding: 12px 14px; background: var(--card); border-color: var(--line); }
  .sym-results { left: 12px; right: 12px; max-height: 60dvh; border-radius: 14px; }
  .sym-results div { padding: 12px 14px; }
  .watch-head { padding: 4px 18px; border: 0; }
  .watch-list { padding: 0 8px 18px; }
  .watch-row { padding: 14px 10px; border: 0; border-bottom: 1px solid rgba(255,255,255,.04); border-radius: 12px; }
  .watch-row.active { background: var(--accent-bg); box-shadow: none; }
  .watch-row .nm { font-size: 15px; }
  .watch-row .px { font-size: 13px; }
  .watch-row .rm { display: none; right: 6px; padding: 6px 10px; font-size: 13px; border-radius: 9px; }
  .watch-row.active .rm { display: block; }
  .watch-row.active .ch { visibility: hidden; }

  /* ----- gráfico */
  .chart-area { background: transparent; }
  .chart-toolbar { padding: 6px 10px; border: 0; flex-wrap: nowrap; gap: 8px; }
  .tfs { flex: 1; overflow-x: auto; scrollbar-width: none; background: var(--card); border-color: var(--line); border-radius: 11px; }
  .tfs::-webkit-scrollbar { display: none; }
  .tfs button { flex: 1; padding: 7px 0; min-width: 36px; font-size: 12px; }
  .tool-btn { padding: 7px 11px; border-radius: 11px; background: var(--card); }
  .tool-btn .tool-lbl { display: none; }
  .chart-wrap { flex: 1; min-height: 0; }
  .chart-wrap { overflow: hidden; display: flex; flex-direction: column; }
  .chart-wrap .chart { position: relative; inset: auto; flex: 1; min-height: 0; }
  .chart-wrap .float-bars { position: static; padding: 6px 8px 0; }
  .chart-wrap .float-bars:not(:has(> :not(.hidden))) { display: none; }
  .place-banner { max-width: calc(100% - 16px); white-space: normal; justify-content: space-between; }
  .pos-strip, .plan-strip { max-width: none; border-radius: 16px; }
  .pos-strip { flex-wrap: wrap; row-gap: 6px; padding: 6px 6px 7px; }
  .pos-strip .ps-nav[data-ps="prev"] { order: 0; }
  .pos-strip .ps-main { order: 1; }
  .pos-strip .ps-nav[data-ps="next"] { order: 2; }
  .pos-strip .ps-acts { order: 3; flex-basis: 100%; display: grid; grid-template-columns: 1fr 1fr 1fr 1fr 1fr; gap: 6px; }
  .ps-acts button, .pill-btn { padding: 10px 6px; font-size: 13px; border-radius: 11px; }
  .ps-main { font-size: 13px; }
  .place-banner { top: 8px; font-size: 13px; }

  /* ----- barra de negociação */
  .dock {
    display: grid; gap: 8px; padding: 8px 10px 10px; border-top: 1px solid rgba(255,255,255,.06);
    background: linear-gradient(180deg, rgba(15,20,32,.6), rgba(10,14,22,.95));
  }
  .dock-row { display: grid; grid-template-columns: 1fr auto 1fr; gap: 8px; align-items: stretch; }
  .d-trade {
    border: 0; border-radius: 16px; padding: 10px 6px; display: grid; gap: 1px; color: #fff; font-weight: 700;
    box-shadow: inset 0 1px 0 rgba(255,255,255,.18), 0 8px 20px rgba(0,0,0,.35); transition: transform .08s, filter .15s;
  }
  .d-trade small { font-size: 11px; letter-spacing: 1.2px; opacity: .92; }
  .d-trade b { font-size: 18px; letter-spacing: -.3px; }
  .d-trade.sell { background: linear-gradient(180deg, #f6596b, #d42e45); }
  .d-trade.buy { background: linear-gradient(180deg, #25d28d, #0f9f63); }
  .d-trade:active, .d-step:active, .dchip:active, .hact:active, .act:active, .ps-acts button:active { transform: scale(.96); }
  .d-trade:disabled { filter: grayscale(.6) brightness(.7); }
  .d-vol { display: grid; grid-template-columns: 38px auto 38px; align-items: stretch; background: var(--card); border: 1px solid var(--line); border-radius: 16px; overflow: hidden; }
  .d-step { background: none; border: 0; font-size: 22px; color: var(--muted); }
  .d-vol-val { background: none; border: 0; display: grid; place-content: center; min-width: 62px; padding: 0 2px; }
  .d-vol-val b { font-size: 16px; }
  .d-vol-val small { font-size: 10px; color: var(--muted); }
  .d-vol-val small.warn { color: var(--warn); }
  .dock-chips { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; }
  .dchip {
    background: var(--card); border: 1px solid var(--line); border-radius: 11px; padding: 8px 4px; font-size: 12px; font-weight: 600;
    color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; display: inline-flex; align-items: center; justify-content: center; gap: 4px;
  }
  .dchip.on { color: var(--text); border-color: var(--line2); background: var(--card2); }
  .dchip.on-sl { color: var(--loss); border-color: rgba(240,70,90,.35); background: var(--loss-bg); }
  .dchip.on-tp { color: var(--gain); border-color: rgba(25,195,125,.35); background: var(--gain-bg); }
  .dchip.more { color: var(--accent); }

  /* ----- painéis que sobem de baixo */
  .sheet-backdrop {
    display: block; position: fixed; inset: 0; z-index: 55; background: rgba(3,6,12,.55);
    backdrop-filter: blur(2px); -webkit-backdrop-filter: blur(2px); opacity: 0; visibility: hidden; transition: opacity .2s, visibility 0s .2s;
  }
  .sheet-backdrop.show { opacity: 1; visibility: visible; transition: opacity .2s; }
  .sheet, .layout > .ticket {
    position: fixed; left: 0; right: 0; bottom: 0; top: auto; width: auto; z-index: 60; max-height: 88dvh;
    border-radius: 24px 24px 0 0; border: 1px solid rgba(255,255,255,.08); border-bottom: 0;
    background: linear-gradient(180deg, #151d2d, #10161f); box-shadow: 0 -20px 60px rgba(0,0,0,.6);
    padding-bottom: calc(14px + env(safe-area-inset-bottom));
    transform: translateY(105%); visibility: hidden; opacity: 1;
    transition: transform .3s cubic-bezier(.2,.8,.2,1), visibility 0s .3s;
    display: flex; flex-direction: column; overflow-y: auto; overscroll-behavior: contain;
  }
  .sheet.open, .layout > .ticket.open { transform: translateY(var(--drag, 0px)); visibility: visible; transition: transform .3s cubic-bezier(.2,.8,.2,1); }
  .sheet.dragging, .layout > .ticket.dragging { transition: none; }
  .sheet-grab { display: flex; justify-content: center; padding: 8px 0 2px; flex: none; touch-action: none; }
  .sheet-grab i { width: 40px; height: 5px; border-radius: 9px; background: rgba(255,255,255,.18); }
  .layout > .ticket { padding: 0 16px calc(16px + env(safe-area-inset-bottom)); gap: 14px; }
  .ticket .quote-btns { display: none; }
  .ticket .stepper { grid-template-columns: 48px 1fr 48px; border-radius: 12px; }
  .ticket .stepper input { padding: 11px 6px; }
  .presets button { padding: 9px 4px; font-size: 13px; border-radius: 10px; }
  .rr button { padding: 7px 12px; font-size: 13px; border-radius: 10px; }
  .plan-btns .btn { padding: 12px 6px; font-size: 13px; border-radius: 12px; }
  .sheet-body { padding: 4px 14px 10px; }

  /* ----- posições / histórico / conta */
  .mv-hero { padding: 12px 14px 10px; display: grid; gap: 12px; border-bottom: 1px solid rgba(255,255,255,.05); }
  .hero-top { display: flex; justify-content: space-between; align-items: flex-end; }
  .hero-lbl { display: block; font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: .6px; }
  .hero-val { font-size: 28px; font-weight: 600; letter-spacing: -.6px; }
  .hero-side { text-align: right; }
  .hero-side b { font-size: 17px; }
  .hero-acts { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; }
  .hact { background: var(--card); border: 1px solid var(--line); border-radius: 11px; padding: 9px 2px; font-size: 11.5px; font-weight: 700; color: var(--text); }
  .hact.gain { color: var(--gain); }
  .hact.loss { color: var(--loss); }
  .hact.danger { color: #fff; background: var(--loss-bg); border-color: rgba(240,70,90,.4); }
  .m-section { margin-top: 18px; }
  .m-section-title { display: flex; justify-content: space-between; align-items: center; font-size: 12px; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: .6px; margin: 16px 2px 8px; }
  .m-empty { text-align: center; color: var(--text); padding: 36px 10px; line-height: 1.6; }
  .m-empty-ico { font-size: 30px; color: var(--line2); margin-bottom: 6px; }
  .lvl button { width: 34px; height: 34px; font-size: 17px; border-radius: 10px; }
  .lvl .val { font-size: 13px; padding: 8px 2px; }
  .lvl input { width: 100%; font-size: 16px; padding: 6px; }
  .chips { flex-wrap: wrap; justify-content: flex-end; }
  #ord-cards .pcard .pc-acts { grid-template-columns: 1fr; }

  .acc-card { background: linear-gradient(160deg, rgba(79,140,255,.16), rgba(23,32,51,.85) 55%); border: 1px solid rgba(255,255,255,.07); border-radius: 20px; padding: 16px; display: grid; gap: 14px; }
  .acc-head { display: flex; justify-content: space-between; align-items: flex-start; }
  .acc-head > div { display: grid; gap: 2px; }
  .acc-head b { font-size: 17px; }
  .acc-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px 16px; }
  .acc-grid span { display: block; font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: .5px; }
  .acc-grid b { font-size: 16px; }
  .acc-buttons { display: grid; gap: 10px; margin-top: 18px; }
  .acc-buttons .btn { padding: 13px; border-radius: 14px; }
  #ma-auto-slot .auto-grid { grid-template-columns: 1fr; padding: 0; overflow: visible; }
  #ma-auto-slot .auto-card { border-radius: 16px; background: var(--card); }
  #ma-auto-slot .rule-block .nums { grid-template-columns: repeat(3, 1fr); }

  /* ----- menu inferior */
  .m-nav {
    display: grid; grid-template-columns: repeat(5, 1fr); z-index: 30; flex: none;
    padding: 6px max(6px, env(safe-area-inset-left)) calc(6px + env(safe-area-inset-bottom)) max(6px, env(safe-area-inset-right));
    background: rgba(12,17,27,.92); backdrop-filter: blur(20px) saturate(140%); -webkit-backdrop-filter: blur(20px) saturate(140%);
    border-top: 1px solid rgba(255,255,255,.06);
  }
  .m-nav button {
    position: relative; background: none; border: 0; display: grid; justify-items: center; gap: 3px; padding: 6px 0 4px;
    color: var(--muted); font-size: 10.5px; font-weight: 600; border-radius: 12px; transition: color .15s;
  }
  .m-nav svg { width: 23px; height: 23px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
  .m-nav button.on { color: var(--text); }
  .m-nav button.on svg { stroke: var(--accent); }
  .m-nav button.on::before { content: ""; position: absolute; top: -6px; width: 26px; height: 3px; border-radius: 0 0 4px 4px; background: var(--accent); }
  .nbadge { position: absolute; top: 2px; left: calc(50% + 6px); min-width: 17px; height: 17px; padding: 0 5px; border-radius: 9px; background: var(--accent); color: #fff; font-size: 10px; font-style: normal; display: grid; place-items: center; }

  /* ----- avisos e menus */
  .toasts { top: calc(env(safe-area-inset-top) + 64px); bottom: auto; left: 12px; right: 12px; max-width: none; }
  .toast { border-radius: 14px; backdrop-filter: blur(12px); background: rgba(23,32,51,.94); }
  .ctx { min-width: 250px; border-radius: 16px; }
  .ctx button { padding: 13px 12px; font-size: 15px; }
  .modal { align-items: end; padding: 0; }
  .modal-card { border-radius: 22px 22px 0 0; max-width: none; padding: 20px 18px calc(18px + env(safe-area-inset-bottom)); }
  .modal-card .actions .btn { flex: 1; padding: 13px; border-radius: 13px; }
}

/* celular deitado: gráfico maior, barra mais baixa */
@media (max-height: 500px) {
  .m-top { padding-top: 4px; padding-bottom: 4px; }
  .dock { grid-template-columns: 1fr auto; align-items: center; }
  .dock-row { grid-template-columns: 1fr auto 1fr; }
  .dock-chips { grid-template-columns: repeat(4, auto); }
  .m-nav button span { display: none; }
  .m-nav { padding-top: 2px; padding-bottom: calc(2px + env(safe-area-inset-bottom)); }
  .m-nav button { padding: 3px 0; }
  .m-nav button.on::before { top: -2px; }
  .m-sym-sub, .m-eq span { display: none; }
  .m-sym-name { font-size: 16px; }
  .chart-toolbar { padding: 3px 8px; }
  .tfs button { padding: 4px 0; }
  .tool-btn { padding: 4px 10px; }
  .dock { padding: 4px 8px 6px; }
  .d-trade { padding: 5px 6px; border-radius: 12px; }
  .d-trade b { font-size: 15px; }
  .dchip { padding: 6px 8px; }
  .pos-strip .ps-acts { flex-basis: auto; order: 3; }
  .pos-strip { flex-wrap: nowrap; }
}

